@budibase/server 2.13.34 → 2.13.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -373,7 +373,7 @@ Please report this to https://github.com/markedjs/marked.`,b0.silent)return"<p>A
373
373
  -----
374
374
 
375
375
  `]},promptTexts={link:"URL for the link:",image:"URL of the image:"},timeFormat={locale:"en-US",format:{hour:"2-digit",minute:"2-digit"}},blockStyles={bold:"**",code:"```",italic:"*"},imageTexts={sbInit:"Attach files by drag and dropping or pasting from clipboard.",sbOnDragEnter:"Drop image to upload it.",sbOnDrop:"Uploading image #images_names#...",sbProgress:"Uploading #file_name#: #progress#%",sbOnUploaded:"Uploaded #image_name#",sizeUnits:" B, KB, MB"},errorMessages={noFileGiven:"You must select a file.",typeNotAllowed:"This image type is not allowed.",fileTooLarge:`Image #image_name# is too big (#image_size#).
376
- Maximum file size is #image_max_size#.`,importError:"Something went wrong when uploading the image #image_name#."};function EasyMDE(n1){n1=n1||{},n1.parent=this;var e1=!0;if(n1.autoDownloadFontAwesome===!1&&(e1=!1),n1.autoDownloadFontAwesome!==!0)for(var t1=document.styleSheets,r1=0;r1<t1.length;r1++)t1[r1].href&&t1[r1].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/")>-1&&(e1=!1);if(e1){var o1=document.createElement("link");o1.rel="stylesheet",o1.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(o1)}if(n1.element)this.element=n1.element;else if(n1.element===null){console.log("EasyMDE: Error. No element was found.");return}if(n1.toolbar===void 0){n1.toolbar=[];for(var i1 in toolbarBuiltInButtons)Object.prototype.hasOwnProperty.call(toolbarBuiltInButtons,i1)&&(i1.indexOf("separator-")!=-1&&n1.toolbar.push("|"),(toolbarBuiltInButtons[i1].default===!0||n1.showIcons&&n1.showIcons.constructor===Array&&n1.showIcons.indexOf(i1)!=-1)&&n1.toolbar.push(i1))}if(Object.prototype.hasOwnProperty.call(n1,"previewClass")||(n1.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(n1,"status")||(n1.status=["autosave","lines","words","cursor"],n1.uploadImage&&n1.status.unshift("upload-image")),n1.previewRender||(n1.previewRender=function(s1){return this.parent.markdown(s1)}),n1.parsingConfig=extend$1({highlightFormatting:!0},n1.parsingConfig||{}),n1.insertTexts=extend$1({},insertTexts,n1.insertTexts||{}),n1.promptTexts=extend$1({},promptTexts,n1.promptTexts||{}),n1.blockStyles=extend$1({},blockStyles,n1.blockStyles||{}),n1.autosave!=null&&(n1.autosave.timeFormat=extend$1({},timeFormat,n1.autosave.timeFormat||{})),n1.iconClassMap=extend$1({},iconClassMap,n1.iconClassMap||{}),n1.shortcuts=extend$1({},shortcuts,n1.shortcuts||{}),n1.maxHeight=n1.maxHeight||void 0,n1.direction=n1.direction||"ltr",typeof n1.maxHeight<"u"?n1.minHeight=n1.maxHeight:n1.minHeight=n1.minHeight||"300px",n1.errorCallback=n1.errorCallback||function(s1){alert(s1)},n1.uploadImage=n1.uploadImage||!1,n1.imageMaxSize=n1.imageMaxSize||2097152,n1.imageAccept=n1.imageAccept||"image/png, image/jpeg, image/gif, image/avif",n1.imageTexts=extend$1({},imageTexts,n1.imageTexts||{}),n1.errorMessages=extend$1({},errorMessages,n1.errorMessages||{}),n1.imagePathAbsolute=n1.imagePathAbsolute||!1,n1.imageCSRFName=n1.imageCSRFName||"csrfmiddlewaretoken",n1.imageCSRFHeader=n1.imageCSRFHeader||!1,n1.autosave!=null&&n1.autosave.unique_id!=null&&n1.autosave.unique_id!=""&&(n1.autosave.uniqueId=n1.autosave.unique_id),n1.overlayMode&&n1.overlayMode.combine===void 0&&(n1.overlayMode.combine=!0),this.options=n1,this.render(),n1.initialValue&&(!this.options.autosave||this.options.autosave.foundSavedValue!==!0)&&this.value(n1.initialValue),n1.uploadImage){var a1=this;this.codemirror.on("dragenter",function(s1,l1){a1.updateStatusBar("upload-image",a1.options.imageTexts.sbOnDragEnter),l1.stopPropagation(),l1.preventDefault()}),this.codemirror.on("dragend",function(s1,l1){a1.updateStatusBar("upload-image",a1.options.imageTexts.sbInit),l1.stopPropagation(),l1.preventDefault()}),this.codemirror.on("dragleave",function(s1,l1){a1.updateStatusBar("upload-image",a1.options.imageTexts.sbInit),l1.stopPropagation(),l1.preventDefault()}),this.codemirror.on("dragover",function(s1,l1){a1.updateStatusBar("upload-image",a1.options.imageTexts.sbOnDragEnter),l1.stopPropagation(),l1.preventDefault()}),this.codemirror.on("drop",function(s1,l1){l1.stopPropagation(),l1.preventDefault(),n1.imageUploadFunction?a1.uploadImagesUsingCustomFunction(n1.imageUploadFunction,l1.dataTransfer.files):a1.uploadImages(l1.dataTransfer.files)}),this.codemirror.on("paste",function(s1,l1){n1.imageUploadFunction?a1.uploadImagesUsingCustomFunction(n1.imageUploadFunction,l1.clipboardData.files):a1.uploadImages(l1.clipboardData.files)})}}EasyMDE.prototype.uploadImages=function(n1,e1,t1){if(n1.length!==0){for(var r1=[],o1=0;o1<n1.length;o1++)r1.push(n1[o1].name),this.uploadImage(n1[o1],e1,t1);this.updateStatusBar("upload-image",this.options.imageTexts.sbOnDrop.replace("#images_names#",r1.join(", ")))}};EasyMDE.prototype.uploadImagesUsingCustomFunction=function(n1,e1){if(e1.length!==0){for(var t1=[],r1=0;r1<e1.length;r1++)t1.push(e1[r1].name),this.uploadImageUsingCustomFunction(n1,e1[r1]);this.updateStatusBar("upload-image",this.options.imageTexts.sbOnDrop.replace("#images_names#",t1.join(", ")))}};EasyMDE.prototype.updateStatusBar=function(n1,e1){if(this.gui.statusbar){var t1=this.gui.statusbar.getElementsByClassName(n1);t1.length===1?this.gui.statusbar.getElementsByClassName(n1)[0].textContent=e1:t1.length===0?console.log("EasyMDE: status bar item "+n1+" was not found."):console.log("EasyMDE: Several status bar items named "+n1+" was found.")}};EasyMDE.prototype.markdown=function(n1){if(marked){var e1;if(this.options&&this.options.renderingConfig&&this.options.renderingConfig.markedOptions?e1=this.options.renderingConfig.markedOptions:e1={},this.options&&this.options.renderingConfig&&this.options.renderingConfig.singleLineBreaks===!1?e1.breaks=!1:e1.breaks=!0,this.options&&this.options.renderingConfig&&this.options.renderingConfig.codeSyntaxHighlighting===!0){var t1=this.options.renderingConfig.hljs||window.hljs;t1&&(e1.highlight=function(o1,i1){return i1&&t1.getLanguage(i1)?t1.highlight(i1,o1).value:t1.highlightAuto(o1).value})}marked.setOptions(e1);var r1=marked.parse(n1);return this.options.renderingConfig&&typeof this.options.renderingConfig.sanitizerFunction=="function"&&(r1=this.options.renderingConfig.sanitizerFunction.call(this,r1)),r1=addAnchorTargetBlank(r1),r1=removeListStyleWhenCheckbox(r1),r1}};EasyMDE.prototype.render=function(n1){if(n1||(n1=this.element||document.getElementsByTagName("textarea")[0]),this._rendered&&this._rendered===n1)return;this.element=n1;var e1=this.options,t1=this,r1={};for(var o1 in e1.shortcuts)e1.shortcuts[o1]!==null&&bindings[o1]!==null&&function(h1){r1[fixShortcut(e1.shortcuts[h1])]=function(){var g1=bindings[h1];typeof g1=="function"?g1(t1):typeof g1=="string"&&window.open(g1,"_blank")}}(o1);r1.Enter="newlineAndIndentContinueMarkdownList",r1.Tab="tabAndIndentMarkdownList",r1["Shift-Tab"]="shiftTabAndUnindentMarkdownList",r1.Esc=function(h1){h1.getOption("fullScreen")&&toggleFullScreen(t1)},this.documentOnKeyDown=function(h1){h1=h1||window.event,h1.keyCode==27&&t1.codemirror.getOption("fullScreen")&&toggleFullScreen(t1)},document.addEventListener("keydown",this.documentOnKeyDown,!1);var i1,a1;e1.overlayMode?(CodeMirror.defineMode("overlay-mode",function(h1){return CodeMirror.overlayMode(CodeMirror.getMode(h1,e1.spellChecker!==!1?"spell-checker":"gfm"),e1.overlayMode.mode,e1.overlayMode.combine)}),i1="overlay-mode",a1=e1.parsingConfig,a1.gitHubSpice=!1):(i1=e1.parsingConfig,i1.name="gfm",i1.gitHubSpice=!1),e1.spellChecker!==!1&&(i1="spell-checker",a1=e1.parsingConfig,a1.name="gfm",a1.gitHubSpice=!1,typeof e1.spellChecker=="function"?e1.spellChecker({codeMirrorInstance:CodeMirror}):CodeMirrorSpellChecker({codeMirrorInstance:CodeMirror}));function s1(h1,g1,$1){return{addNew:!1}}if(this.codemirror=CodeMirror.fromTextArea(n1,{mode:i1,backdrop:a1,theme:e1.theme!=null?e1.theme:"easymde",tabSize:e1.tabSize!=null?e1.tabSize:2,indentUnit:e1.tabSize!=null?e1.tabSize:2,indentWithTabs:e1.indentWithTabs!==!1,lineNumbers:e1.lineNumbers===!0,autofocus:e1.autofocus===!0,extraKeys:r1,direction:e1.direction,lineWrapping:e1.lineWrapping!==!1,allowDropFileTypes:["text/plain"],placeholder:e1.placeholder||n1.getAttribute("placeholder")||"",styleSelectedText:e1.styleSelectedText!=null?e1.styleSelectedText:!isMobile(),scrollbarStyle:e1.scrollbarStyle!=null?e1.scrollbarStyle:"native",configureMouse:s1,inputStyle:e1.inputStyle!=null?e1.inputStyle:isMobile()?"contenteditable":"textarea",spellcheck:e1.nativeSpellcheck!=null?e1.nativeSpellcheck:!0,autoRefresh:e1.autoRefresh!=null?e1.autoRefresh:!1}),this.codemirror.getScrollerElement().style.minHeight=e1.minHeight,typeof e1.maxHeight<"u"&&(this.codemirror.getScrollerElement().style.height=e1.maxHeight),e1.forceSync===!0){var l1=this.codemirror;l1.on("change",function(){l1.save()})}this.gui={};var c1=document.createElement("div");c1.classList.add("EasyMDEContainer"),c1.setAttribute("role","application");var u1=this.codemirror.getWrapperElement();u1.parentNode.insertBefore(c1,u1),c1.appendChild(u1),e1.toolbar!==!1&&(this.gui.toolbar=this.createToolbar()),e1.status!==!1&&(this.gui.statusbar=this.createStatusbar()),e1.autosave!=null&&e1.autosave.enabled===!0&&(this.autosave(),this.codemirror.on("change",function(){clearTimeout(t1._autosave_timeout),t1._autosave_timeout=setTimeout(function(){t1.autosave()},t1.options.autosave.submit_delay||t1.options.autosave.delay||1e3)}));function f1(h1,g1){var $1,y1=window.getComputedStyle(document.querySelector(".CodeMirror-sizer")).width.replace("px","");return h1<y1?$1=g1+"px":$1=g1/h1*100+"%",$1}var d1=this;function p1(h1,g1){h1.setAttribute("data-img-src",g1.url),h1.setAttribute("style","--bg-image:url("+g1.url+");--width:"+g1.naturalWidth+"px;--height:"+f1(g1.naturalWidth,g1.naturalHeight)),d1.codemirror.setSize()}function m1(){e1.previewImagesInEditor&&c1.querySelectorAll(".cm-image-marker").forEach(function(h1){var g1=h1.parentElement;if(g1.innerText.match(/^!\[.*?\]\(.*\)/g)&&!g1.hasAttribute("data-img-src")){var $1=g1.innerText.match("\\((.*)\\)");if(window.EMDEimagesCache||(window.EMDEimagesCache={}),$1&&$1.length>=2){var y1=$1[1];if(e1.imagesPreviewHandler){var v1=e1.imagesPreviewHandler($1[1]);typeof v1=="string"&&(y1=v1)}if(window.EMDEimagesCache[y1])p1(g1,window.EMDEimagesCache[y1]);else{var S1=document.createElement("img");S1.onload=function(){window.EMDEimagesCache[y1]={naturalWidth:S1.naturalWidth,naturalHeight:S1.naturalHeight,url:y1},p1(g1,window.EMDEimagesCache[y1])},S1.src=y1}}}})}this.codemirror.on("update",function(){m1()}),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element,(e1.autofocus===!0||n1.autofocus)&&this.codemirror.focus();var _1=this.codemirror;setTimeout((function(){_1.refresh()}).bind(_1),0)};EasyMDE.prototype.cleanup=function(){document.removeEventListener("keydown",this.documentOnKeyDown)};function isLocalStorageAvailable(){if(typeof localStorage=="object")try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch{return!1}else return!1;return!0}EasyMDE.prototype.autosave=function(){if(isLocalStorageAvailable()){var n1=this;if(this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to use the autosave feature");return}this.options.autosave.binded!==!0&&(n1.element.form!=null&&n1.element.form!=null&&n1.element.form.addEventListener("submit",function(){clearTimeout(n1.autosaveTimeoutId),n1.autosaveTimeoutId=void 0,localStorage.removeItem("smde_"+n1.options.autosave.uniqueId)}),this.options.autosave.binded=!0),this.options.autosave.loaded!==!0&&(typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)=="string"&&localStorage.getItem("smde_"+this.options.autosave.uniqueId)!=""&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0);var e1=n1.value();e1!==""?localStorage.setItem("smde_"+this.options.autosave.uniqueId,e1):localStorage.removeItem("smde_"+this.options.autosave.uniqueId);var t1=document.getElementById("autosaved");if(t1!=null&&t1!=null&&t1!=""){var r1=new Date,o1=new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale,"en-US"],this.options.autosave.timeFormat.format).format(r1),i1=this.options.autosave.text==null?"Autosaved: ":this.options.autosave.text;t1.innerHTML=i1+o1}}else console.log("EasyMDE: localStorage not available, cannot autosave")};EasyMDE.prototype.clearAutosavedValue=function(){if(isLocalStorageAvailable()){if(this.options.autosave==null||this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to clear the autosave value");return}localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("EasyMDE: localStorage not available, cannot autosave")};EasyMDE.prototype.openBrowseFileWindow=function(n1,e1){var t1=this,r1=this.gui.toolbar.getElementsByClassName("imageInput")[0];r1.click();function o1(i1){t1.options.imageUploadFunction?t1.uploadImagesUsingCustomFunction(t1.options.imageUploadFunction,i1.target.files):t1.uploadImages(i1.target.files,n1,e1),r1.removeEventListener("change",o1)}r1.addEventListener("change",o1)};EasyMDE.prototype.uploadImage=function(n1,e1,t1){var r1=this;e1=e1||function(c1){afterImageUploaded(r1,c1)};function o1(l1){r1.updateStatusBar("upload-image",l1),setTimeout(function(){r1.updateStatusBar("upload-image",r1.options.imageTexts.sbInit)},1e4),t1&&typeof t1=="function"&&t1(l1),r1.options.errorCallback(l1)}function i1(l1){var c1=r1.options.imageTexts.sizeUnits.split(",");return l1.replace("#image_name#",n1.name).replace("#image_size#",humanFileSize(n1.size,c1)).replace("#image_max_size#",humanFileSize(r1.options.imageMaxSize,c1))}if(n1.size>this.options.imageMaxSize){o1(i1(this.options.errorMessages.fileTooLarge));return}var a1=new FormData;a1.append("image",n1),r1.options.imageCSRFToken&&!r1.options.imageCSRFHeader&&a1.append(r1.options.imageCSRFName,r1.options.imageCSRFToken);var s1=new XMLHttpRequest;s1.upload.onprogress=function(l1){if(l1.lengthComputable){var c1=""+Math.round(l1.loaded*100/l1.total);r1.updateStatusBar("upload-image",r1.options.imageTexts.sbProgress.replace("#file_name#",n1.name).replace("#progress#",c1))}},s1.open("POST",this.options.imageUploadEndpoint),r1.options.imageCSRFToken&&r1.options.imageCSRFHeader&&s1.setRequestHeader(r1.options.imageCSRFName,r1.options.imageCSRFToken),s1.onload=function(){try{var l1=JSON.parse(this.responseText)}catch{console.error("EasyMDE: The server did not return a valid json."),o1(i1(r1.options.errorMessages.importError));return}this.status===200&&l1&&!l1.error&&l1.data&&l1.data.filePath?e1((r1.options.imagePathAbsolute?"":window.location.origin+"/")+l1.data.filePath):l1.error&&l1.error in r1.options.errorMessages?o1(i1(r1.options.errorMessages[l1.error])):l1.error?o1(i1(l1.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),o1(i1(r1.options.errorMessages.importError)))},s1.onerror=function(l1){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+l1.target.status+" ("+l1.target.statusText+")"),o1(r1.options.errorMessages.importError)},s1.send(a1)};EasyMDE.prototype.uploadImageUsingCustomFunction=function(n1,e1){var t1=this;function r1(a1){afterImageUploaded(t1,a1)}function o1(a1){var s1=i1(a1);t1.updateStatusBar("upload-image",s1),setTimeout(function(){t1.updateStatusBar("upload-image",t1.options.imageTexts.sbInit)},1e4),t1.options.errorCallback(s1)}function i1(a1){var s1=t1.options.imageTexts.sizeUnits.split(",");return a1.replace("#image_name#",e1.name).replace("#image_size#",humanFileSize(e1.size,s1)).replace("#image_max_size#",humanFileSize(t1.options.imageMaxSize,s1))}n1.apply(this,[e1,r1,o1])};EasyMDE.prototype.setPreviewMaxHeight=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.nextSibling,r1=parseInt(window.getComputedStyle(e1).paddingTop),o1=parseInt(window.getComputedStyle(e1).borderTopWidth),i1=parseInt(this.options.maxHeight),a1=i1+r1*2+o1*2,s1=a1.toString()+"px";t1.style.height=s1};EasyMDE.prototype.createSideBySide=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.nextSibling;if(!t1||!t1.classList.contains("editor-preview-side")){if(t1=document.createElement("div"),t1.className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var r1=0;r1<this.options.previewClass.length;r1++)t1.classList.add(this.options.previewClass[r1]);else typeof this.options.previewClass=="string"&&t1.classList.add(this.options.previewClass);e1.parentNode.insertBefore(t1,e1.nextSibling)}if(typeof this.options.maxHeight<"u"&&this.setPreviewMaxHeight(),this.options.syncSideBySidePreviewScroll===!1)return t1;var o1=!1,i1=!1;return n1.on("scroll",function(a1){if(o1){o1=!1;return}i1=!0;var s1=a1.getScrollInfo().height-a1.getScrollInfo().clientHeight,l1=parseFloat(a1.getScrollInfo().top)/s1,c1=(t1.scrollHeight-t1.clientHeight)*l1;t1.scrollTop=c1}),t1.onscroll=function(){if(i1){i1=!1;return}o1=!0;var a1=t1.scrollHeight-t1.clientHeight,s1=parseFloat(t1.scrollTop)/a1,l1=(n1.getScrollInfo().height-n1.getScrollInfo().clientHeight)*s1;n1.scrollTo(0,l1)},t1};EasyMDE.prototype.createToolbar=function(n1){if(n1=n1||this.options.toolbar,!(!n1||n1.length===0)){var e1;for(e1=0;e1<n1.length;e1++)toolbarBuiltInButtons[n1[e1]]!=null&&(n1[e1]=toolbarBuiltInButtons[n1[e1]]);var t1=document.createElement("div");t1.className="editor-toolbar",t1.setAttribute("role","toolbar");var r1=this,o1={};for(r1.toolbar=n1,e1=0;e1<n1.length;e1++)if(!(n1[e1].name=="guide"&&r1.options.toolbarGuideIcon===!1)&&!(r1.options.hideIcons&&r1.options.hideIcons.indexOf(n1[e1].name)!=-1)&&!((n1[e1].name=="fullscreen"||n1[e1].name=="side-by-side")&&isMobile())){if(n1[e1]==="|"){for(var i1=!1,a1=e1+1;a1<n1.length;a1++)n1[a1]!=="|"&&(!r1.options.hideIcons||r1.options.hideIcons.indexOf(n1[a1].name)==-1)&&(i1=!0);if(!i1)continue}(function(c1){var u1;if(c1==="|"?u1=createSep():c1.children?u1=createToolbarDropdown(c1,r1.options.toolbarTips,r1.options.shortcuts,r1):u1=createToolbarButton(c1,!0,r1.options.toolbarTips,r1.options.shortcuts,"button",r1),o1[c1.name||c1]=u1,t1.appendChild(u1),c1.name==="upload-image"){var f1=document.createElement("input");f1.className="imageInput",f1.type="file",f1.multiple=!0,f1.name="image",f1.accept=r1.options.imageAccept,f1.style.display="none",f1.style.opacity=0,t1.appendChild(f1)}})(n1[e1])}r1.toolbar_div=t1,r1.toolbarElements=o1;var s1=this.codemirror;s1.on("cursorActivity",function(){var c1=getState(s1);for(var u1 in o1)(function(f1){var d1=o1[f1];c1[f1]?d1.classList.add("active"):f1!="fullscreen"&&f1!="side-by-side"&&d1.classList.remove("active")})(u1)});var l1=s1.getWrapperElement();return l1.parentNode.insertBefore(t1,l1),t1}};EasyMDE.prototype.createStatusbar=function(n1){n1=n1||this.options.status;var e1=this.options,t1=this.codemirror;if(!(!n1||n1.length===0)){var r1=[],o1,i1,a1,s1;for(o1=0;o1<n1.length;o1++)if(i1=void 0,a1=void 0,s1=void 0,typeof n1[o1]=="object")r1.push({className:n1[o1].className,defaultValue:n1[o1].defaultValue,onUpdate:n1[o1].onUpdate,onActivity:n1[o1].onActivity});else{var l1=n1[o1];l1==="words"?(s1=function(p1){p1.innerHTML=wordCount(t1.getValue())},i1=function(p1){p1.innerHTML=wordCount(t1.getValue())}):l1==="lines"?(s1=function(p1){p1.innerHTML=t1.lineCount()},i1=function(p1){p1.innerHTML=t1.lineCount()}):l1==="cursor"?(s1=function(p1){p1.innerHTML="1:1"},a1=function(p1){var m1=t1.getCursor(),_1=m1.line+1,h1=m1.ch+1;p1.innerHTML=_1+":"+h1}):l1==="autosave"?s1=function(p1){e1.autosave!=null&&e1.autosave.enabled===!0&&p1.setAttribute("id","autosaved")}:l1==="upload-image"&&(s1=function(p1){p1.innerHTML=e1.imageTexts.sbInit}),r1.push({className:l1,defaultValue:s1,onUpdate:i1,onActivity:a1})}var c1=document.createElement("div");for(c1.className="editor-statusbar",o1=0;o1<r1.length;o1++){var u1=r1[o1],f1=document.createElement("span");f1.className=u1.className,typeof u1.defaultValue=="function"&&u1.defaultValue(f1),typeof u1.onUpdate=="function"&&this.codemirror.on("update",function(p1,m1){return function(){m1.onUpdate(p1)}}(f1,u1)),typeof u1.onActivity=="function"&&this.codemirror.on("cursorActivity",function(p1,m1){return function(){m1.onActivity(p1)}}(f1,u1)),c1.appendChild(f1)}var d1=this.codemirror.getWrapperElement();return d1.parentNode.insertBefore(c1,d1.nextSibling),c1}};EasyMDE.prototype.value=function(n1){var e1=this.codemirror;if(n1===void 0)return e1.getValue();if(e1.getDoc().setValue(n1),this.isPreviewActive()){var t1=e1.getWrapperElement(),r1=t1.lastChild,o1=this.options.previewRender(n1,r1);o1!==null&&(r1.innerHTML=o1)}return this};EasyMDE.toggleBold=toggleBold;EasyMDE.toggleItalic=toggleItalic;EasyMDE.toggleStrikethrough=toggleStrikethrough;EasyMDE.toggleBlockquote=toggleBlockquote;EasyMDE.toggleHeadingSmaller=toggleHeadingSmaller;EasyMDE.toggleHeadingBigger=toggleHeadingBigger;EasyMDE.toggleHeading1=toggleHeading1;EasyMDE.toggleHeading2=toggleHeading2;EasyMDE.toggleHeading3=toggleHeading3;EasyMDE.toggleHeading4=toggleHeading4;EasyMDE.toggleHeading5=toggleHeading5;EasyMDE.toggleHeading6=toggleHeading6;EasyMDE.toggleCodeBlock=toggleCodeBlock;EasyMDE.toggleUnorderedList=toggleUnorderedList;EasyMDE.toggleOrderedList=toggleOrderedList;EasyMDE.cleanBlock=cleanBlock;EasyMDE.drawLink=drawLink;EasyMDE.drawImage=drawImage;EasyMDE.drawUploadedImage=drawUploadedImage;EasyMDE.drawTable=drawTable;EasyMDE.drawHorizontalRule=drawHorizontalRule;EasyMDE.undo=undo$1;EasyMDE.redo=redo$1;EasyMDE.togglePreview=togglePreview;EasyMDE.toggleSideBySide=toggleSideBySide;EasyMDE.toggleFullScreen=toggleFullScreen;EasyMDE.prototype.toggleBold=function(){toggleBold(this)};EasyMDE.prototype.toggleItalic=function(){toggleItalic(this)};EasyMDE.prototype.toggleStrikethrough=function(){toggleStrikethrough(this)};EasyMDE.prototype.toggleBlockquote=function(){toggleBlockquote(this)};EasyMDE.prototype.toggleHeadingSmaller=function(){toggleHeadingSmaller(this)};EasyMDE.prototype.toggleHeadingBigger=function(){toggleHeadingBigger(this)};EasyMDE.prototype.toggleHeading1=function(){toggleHeading1(this)};EasyMDE.prototype.toggleHeading2=function(){toggleHeading2(this)};EasyMDE.prototype.toggleHeading3=function(){toggleHeading3(this)};EasyMDE.prototype.toggleHeading4=function(){toggleHeading4(this)};EasyMDE.prototype.toggleHeading5=function(){toggleHeading5(this)};EasyMDE.prototype.toggleHeading6=function(){toggleHeading6(this)};EasyMDE.prototype.toggleCodeBlock=function(){toggleCodeBlock(this)};EasyMDE.prototype.toggleUnorderedList=function(){toggleUnorderedList(this)};EasyMDE.prototype.toggleOrderedList=function(){toggleOrderedList(this)};EasyMDE.prototype.cleanBlock=function(){cleanBlock(this)};EasyMDE.prototype.drawLink=function(){drawLink(this)};EasyMDE.prototype.drawImage=function(){drawImage(this)};EasyMDE.prototype.drawUploadedImage=function(){drawUploadedImage(this)};EasyMDE.prototype.drawTable=function(){drawTable(this)};EasyMDE.prototype.drawHorizontalRule=function(){drawHorizontalRule(this)};EasyMDE.prototype.undo=function(){undo$1(this)};EasyMDE.prototype.redo=function(){redo$1(this)};EasyMDE.prototype.togglePreview=function(){togglePreview(this)};EasyMDE.prototype.toggleSideBySide=function(){toggleSideBySide(this)};EasyMDE.prototype.toggleFullScreen=function(){toggleFullScreen(this)};EasyMDE.prototype.isPreviewActive=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.lastChild;return t1.classList.contains("editor-preview-active")};EasyMDE.prototype.isSideBySideActive=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.nextSibling;return t1.classList.contains("editor-preview-active-side")};EasyMDE.prototype.isFullscreenActive=function(){var n1=this.codemirror;return n1.getOption("fullScreen")};EasyMDE.prototype.getState=function(){var n1=this.codemirror;return getState(n1)};EasyMDE.prototype.toTextArea=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.parentNode;t1&&(this.gui.toolbar&&t1.removeChild(this.gui.toolbar),this.gui.statusbar&&t1.removeChild(this.gui.statusbar),this.gui.sideBySide&&t1.removeChild(this.gui.sideBySide)),t1.parentNode.insertBefore(e1,t1),t1.remove(),n1.toTextArea(),this.autosaveTimeoutId&&(clearTimeout(this.autosaveTimeoutId),this.autosaveTimeoutId=void 0,this.clearAutosavedValue())};var easymde=EasyMDE;const EasyMDE$1=getDefaultExportFromCjs(easymde),easymde_min="",SpectrumMDE_svelte_svelte_type_style_lang="";function create_fragment$8j(n1){let e1,t1;return{c(){e1=element("div"),t1=element("textarea"),t1.disabled=!0,attr(t1,"id",n1[0]),attr(e1,"style",n1[3]),attr(e1,"class","svelte-1888jbe"),toggle_class(e1,"disabled",n1[1])},m(r1,o1){insert$1(r1,e1,o1),append$1(e1,t1),n1[9](t1)},p(r1,[o1]){o1&1&&attr(t1,"id",r1[0]),o1&8&&attr(e1,"style",r1[3]),o1&2&&toggle_class(e1,"disabled",r1[1])},i:noop$5,o:noop$5,d(r1){r1&&detach(e1),n1[9](null)}}}function instance$8u(n1,e1,t1){let r1,{height:o1=null}=e1,{scroll:i1=!0}=e1,{easyMDEOptions:a1=null}=e1,{mde:s1=null}=e1,{id:l1=null}=e1,{fullScreenOffset:c1=null}=e1,{disabled:u1=!1}=e1,f1;onMount(()=>(t1(4,o1=o1||"200px"),t1(5,s1=new EasyMDE$1({element:f1,spellChecker:!1,status:!1,unorderedListStyle:"-",maxHeight:i1?o1:void 0,minHeight:i1?void 0:o1,...a1})),()=>{s1.toTextArea()}));const d1=m1=>{let _1="";return _1+=`--fullscreen-offset-x:${(m1==null?void 0:m1.x)||"0px"};`,_1+=`--fullscreen-offset-y:${(m1==null?void 0:m1.y)||"0px"};`,_1};function p1(m1){binding_callbacks[m1?"unshift":"push"](()=>{f1=m1,t1(2,f1)})}return n1.$$set=m1=>{"height"in m1&&t1(4,o1=m1.height),"scroll"in m1&&t1(6,i1=m1.scroll),"easyMDEOptions"in m1&&t1(7,a1=m1.easyMDEOptions),"mde"in m1&&t1(5,s1=m1.mde),"id"in m1&&t1(0,l1=m1.id),"fullScreenOffset"in m1&&t1(8,c1=m1.fullScreenOffset),"disabled"in m1&&t1(1,u1=m1.disabled)},n1.$$.update=()=>{n1.$$.dirty&256&&t1(3,r1=d1(c1))},[l1,u1,f1,r1,o1,s1,i1,a1,c1,p1]}class SpectrumMDE extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8u,create_fragment$8j,safe_not_equal,{height:4,scroll:6,easyMDEOptions:7,mde:5,id:0,fullScreenOffset:8,disabled:1})}}function create_key_block$g(n1){let e1,t1,r1;function o1(a1){n1[9](a1)}let i1={scroll:!0,height:n1[1],id:n1[3],fullScreenOffset:n1[4],disabled:n1[5],easyMDEOptions:{initialValue:n1[0],placeholder:n1[2],toolbar:n1[5]||n1[6]?!1:void 0,...n1[7]}};return n1[8]!==void 0&&(i1.mde=n1[8]),e1=new SpectrumMDE({props:i1}),binding_callbacks.push(()=>bind$2(e1,"mde",o1)),{c(){create_component(e1.$$.fragment)},m(a1,s1){mount_component(e1,a1,s1),r1=!0},p(a1,s1){const l1={};s1&2&&(l1.height=a1[1]),s1&8&&(l1.id=a1[3]),s1&16&&(l1.fullScreenOffset=a1[4]),s1&32&&(l1.disabled=a1[5]),s1&229&&(l1.easyMDEOptions={initialValue:a1[0],placeholder:a1[2],toolbar:a1[5]||a1[6]?!1:void 0,...a1[7]}),!t1&&s1&256&&(t1=!0,l1.mde=a1[8],add_flush_callback(()=>t1=!1)),e1.$set(l1)},i(a1){r1||(transition_in(e1.$$.fragment,a1),r1=!0)},o(a1){transition_out(e1.$$.fragment,a1),r1=!1},d(a1){destroy_component(e1,a1)}}}function create_fragment$8i(n1){let e1=n1[1],t1,r1,o1=create_key_block$g(n1);return{c(){o1.c(),t1=empty$1()},m(i1,a1){o1.m(i1,a1),insert$1(i1,t1,a1),r1=!0},p(i1,[a1]){a1&2&&safe_not_equal(e1,e1=i1[1])?(group_outros(),transition_out(o1,1,1,noop$5),check_outros(),o1=create_key_block$g(i1),o1.c(),transition_in(o1,1),o1.m(t1.parentNode,t1)):o1.p(i1,a1)},i(i1){r1||(transition_in(o1),r1=!0)},o(i1){transition_out(o1),r1=!1},d(i1){i1&&detach(t1),o1.d(i1)}}}function instance$8t(n1,e1,t1){let{value:r1=null}=e1,{height:o1=null}=e1,{placeholder:i1=null}=e1,{id:a1=null}=e1,{fullScreenOffset:s1=0}=e1,{disabled:l1=!1}=e1,{readonly:c1=!1}=e1,{easyMDEOptions:u1}=e1;const f1=createEventDispatcher();let d1,p1;const m1=y1=>{p1&&y1!==d1&&p1.value(y1)},g1=((y1,v1)=>{let S1;return()=>{clearTimeout(S1),S1=setTimeout(y1,v1)}})(()=>{d1=p1.value(),f1("change",d1)},250);function $1(y1){p1=y1,t1(8,p1)}return n1.$$set=y1=>{"value"in y1&&t1(0,r1=y1.value),"height"in y1&&t1(1,o1=y1.height),"placeholder"in y1&&t1(2,i1=y1.placeholder),"id"in y1&&t1(3,a1=y1.id),"fullScreenOffset"in y1&&t1(4,s1=y1.fullScreenOffset),"disabled"in y1&&t1(5,l1=y1.disabled),"readonly"in y1&&t1(6,c1=y1.readonly),"easyMDEOptions"in y1&&t1(7,u1=y1.easyMDEOptions)},n1.$$.update=()=>{n1.$$.dirty&1&&m1(r1),n1.$$.dirty&256&&(p1==null||p1.codemirror.on("change",g1)),n1.$$.dirty&352&&(c1||l1)&&(p1==null||p1.togglePreview())},[r1,o1,i1,a1,s1,l1,c1,u1,p1,$1]}class MarkdownEditor extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8t,create_fragment$8i,safe_not_equal,{value:0,height:1,placeholder:2,id:3,fullScreenOffset:4,disabled:5,readonly:6,easyMDEOptions:7})}}const MarkdownViewer_svelte_svelte_type_style_lang="";function create_fragment$8h(n1){let e1,t1,r1;return t1=new MarkdownEditor({props:{value:n1[0],placeholder:n1[1],height:n1[4],id:n1[5],fullScreenOffset:n1[6],disabled:n1[2],easyMDEOptions:n1[7],readonly:n1[3]}}),t1.$on("change",n1[8]),{c(){e1=element("div"),create_component(t1.$$.fragment)},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,[i1]){const a1={};i1&1&&(a1.value=o1[0]),i1&2&&(a1.placeholder=o1[1]),i1&16&&(a1.height=o1[4]),i1&32&&(a1.id=o1[5]),i1&64&&(a1.fullScreenOffset=o1[6]),i1&4&&(a1.disabled=o1[2]),i1&128&&(a1.easyMDEOptions=o1[7]),i1&8&&(a1.readonly=o1[3]),t1.$set(a1)},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function instance$8s(n1,e1,t1){let{value:r1=""}=e1,{placeholder:o1=null}=e1,{disabled:i1=!1}=e1,{readonly:a1=!1}=e1,{height:s1=null}=e1,{id:l1=null}=e1,{fullScreenOffset:c1=null}=e1,{easyMDEOptions:u1=null}=e1;function f1(d1){bubble.call(this,n1,d1)}return n1.$$set=d1=>{"value"in d1&&t1(0,r1=d1.value),"placeholder"in d1&&t1(1,o1=d1.placeholder),"disabled"in d1&&t1(2,i1=d1.disabled),"readonly"in d1&&t1(3,a1=d1.readonly),"height"in d1&&t1(4,s1=d1.height),"id"in d1&&t1(5,l1=d1.id),"fullScreenOffset"in d1&&t1(6,c1=d1.fullScreenOffset),"easyMDEOptions"in d1&&t1(7,u1=d1.easyMDEOptions)},[r1,o1,i1,a1,s1,l1,c1,u1,f1]}class RichTextField extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8s,create_fragment$8h,safe_not_equal,{value:0,placeholder:1,disabled:2,readonly:3,height:4,id:5,fullScreenOffset:6,easyMDEOptions:7})}}function create_default_slot$5e(n1){let e1,t1;return e1=new RichTextField({props:{error:n1[5],disabled:n1[4],value:n1[0],placeholder:n1[3],height:n1[6],id:n1[7],fullScreenOffset:n1[8],easyMDEOptions:n1[9]}}),e1.$on("change",n1[11]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&32&&(i1.error=r1[5]),o1&16&&(i1.disabled=r1[4]),o1&1&&(i1.value=r1[0]),o1&8&&(i1.placeholder=r1[3]),o1&64&&(i1.height=r1[6]),o1&128&&(i1.id=r1[7]),o1&256&&(i1.fullScreenOffset=r1[8]),o1&512&&(i1.easyMDEOptions=r1[9]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$8g(n1){let e1,t1;return e1=new Field({props:{helpText:n1[10],label:n1[1],labelPosition:n1[2],error:n1[5],$$slots:{default:[create_default_slot$5e]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&1024&&(i1.helpText=r1[10]),o1&2&&(i1.label=r1[1]),o1&4&&(i1.labelPosition=r1[2]),o1&32&&(i1.error=r1[5]),o1&9209&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8r(n1,e1,t1){let{value:r1=null}=e1,{label:o1=null}=e1,{labelPosition:i1="above"}=e1,{placeholder:a1=null}=e1,{disabled:s1=!1}=e1,{error:l1=null}=e1,{height:c1=null}=e1,{id:u1=null}=e1,{fullScreenOffset:f1=null}=e1,{easyMDEOptions:d1=null}=e1,{helpText:p1=null}=e1;const m1=createEventDispatcher(),_1=h1=>{t1(0,r1=h1.detail),m1("change",h1.detail)};return n1.$$set=h1=>{"value"in h1&&t1(0,r1=h1.value),"label"in h1&&t1(1,o1=h1.label),"labelPosition"in h1&&t1(2,i1=h1.labelPosition),"placeholder"in h1&&t1(3,a1=h1.placeholder),"disabled"in h1&&t1(4,s1=h1.disabled),"error"in h1&&t1(5,l1=h1.error),"height"in h1&&t1(6,c1=h1.height),"id"in h1&&t1(7,u1=h1.id),"fullScreenOffset"in h1&&t1(8,f1=h1.fullScreenOffset),"easyMDEOptions"in h1&&t1(9,d1=h1.easyMDEOptions),"helpText"in h1&&t1(10,p1=h1.helpText)},[r1,o1,i1,a1,s1,l1,c1,u1,f1,d1,p1,_1]}class RichTextField_1 extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8r,create_fragment$8g,safe_not_equal,{value:0,label:1,labelPosition:2,placeholder:3,disabled:4,error:5,height:6,id:7,fullScreenOffset:8,easyMDEOptions:9,helpText:10})}}const List_svelte_svelte_type_style_lang="",ListItem_svelte_svelte_type_style_lang="",IconSideNav_svelte_svelte_type_style_lang="",IconSideNavItem_svelte_svelte_type_style_lang="",indexVars$1="",Slider_svelte_svelte_type_style_lang="";function create_fragment$8f(n1){let e1,t1,r1,o1;return{c(){e1=element("div"),t1=element("input"),attr(t1,"type","range"),attr(t1,"min",n1[3]),attr(t1,"max",n1[4]),attr(t1,"step",n1[5]),t1.value=n1[0],t1.disabled=n1[2],attr(t1,"id",n1[1]),attr(t1,"class","svelte-13v9q49"),attr(e1,"class","svelte-13v9q49")},m(i1,a1){insert$1(i1,e1,a1),append$1(e1,t1),r1||(o1=listen(t1,"change",n1[6]),r1=!0)},p(i1,[a1]){a1&8&&attr(t1,"min",i1[3]),a1&16&&attr(t1,"max",i1[4]),a1&32&&attr(t1,"step",i1[5]),a1&1&&(t1.value=i1[0]),a1&4&&(t1.disabled=i1[2]),a1&2&&attr(t1,"id",i1[1])},i:noop$5,o:noop$5,d(i1){i1&&detach(e1),r1=!1,o1()}}}function instance$8q(n1,e1,t1){let{value:r1=!1}=e1,{id:o1=null}=e1,{disabled:i1=!1}=e1,{min:a1=0}=e1,{max:s1=100}=e1,{step:l1=1}=e1;const c1=createEventDispatcher(),u1=f1=>{c1("change",f1.target.value)};return n1.$$set=f1=>{"value"in f1&&t1(0,r1=f1.value),"id"in f1&&t1(1,o1=f1.id),"disabled"in f1&&t1(2,i1=f1.disabled),"min"in f1&&t1(3,a1=f1.min),"max"in f1&&t1(4,s1=f1.max),"step"in f1&&t1(5,l1=f1.step)},[r1,o1,i1,a1,s1,l1,u1]}class Slider extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8q,create_fragment$8f,safe_not_equal,{value:0,id:1,disabled:2,min:3,max:4,step:5})}}function create_default_slot$5d(n1){let e1,t1;return e1=new Slider({props:{disabled:n1[6],value:n1[0],min:n1[3],max:n1[4],step:n1[5]}}),e1.$on("change",n1[9]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&64&&(i1.disabled=r1[6]),o1&1&&(i1.value=r1[0]),o1&8&&(i1.min=r1[3]),o1&16&&(i1.max=r1[4]),o1&32&&(i1.step=r1[5]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$8e(n1){let e1,t1;return e1=new Field({props:{helpText:n1[8],label:n1[1],labelPosition:n1[2],error:n1[7],$$slots:{default:[create_default_slot$5d]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&256&&(i1.helpText=r1[8]),o1&2&&(i1.label=r1[1]),o1&4&&(i1.labelPosition=r1[2]),o1&128&&(i1.error=r1[7]),o1&2169&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8p(n1,e1,t1){let{value:r1=null}=e1,{label:o1=null}=e1,{labelPosition:i1="above"}=e1,{min:a1=0}=e1,{max:s1=100}=e1,{step:l1=1}=e1,{disabled:c1=!1}=e1,{error:u1=null}=e1,{helpText:f1=null}=e1;const d1=createEventDispatcher(),p1=m1=>{t1(0,r1=m1.detail),d1("change",m1.detail)};return n1.$$set=m1=>{"value"in m1&&t1(0,r1=m1.value),"label"in m1&&t1(1,o1=m1.label),"labelPosition"in m1&&t1(2,i1=m1.labelPosition),"min"in m1&&t1(3,a1=m1.min),"max"in m1&&t1(4,s1=m1.max),"step"in m1&&t1(5,l1=m1.step),"disabled"in m1&&t1(6,c1=m1.disabled),"error"in m1&&t1(7,u1=m1.error),"helpText"in m1&&t1(8,f1=m1.helpText)},[r1,o1,i1,a1,s1,l1,c1,u1,f1,p1]}class Slider_1 extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8p,create_fragment$8e,safe_not_equal,{value:0,label:1,labelPosition:2,min:3,max:4,step:5,disabled:6,error:7,helpText:8})}}const indexVars="",Accordion_svelte_svelte_type_style_lang="";function create_fragment$8d(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1,u1,f1,d1,p1,m1;const _1=n1[6].default,h1=create_slot(_1,n1,n1[5],null);return{c(){e1=element("div"),t1=element("div"),r1=element("h3"),o1=element("button"),i1=text(n1[1]),a1=space$1(),s1=svg_element("svg"),l1=svg_element("use"),c1=space$1(),u1=element("div"),h1&&h1.c(),attr(o1,"class","spectrum-Accordion-itemHeader svelte-11prom"),attr(o1,"type","button"),xlink_attr(l1,"xlink:href","#spectrum-css-icon-Chevron100"),attr(s1,"class","spectrum-Icon spectrum-UIIcon-ChevronRight100 spectrum-Accordion-itemIndicator"),attr(s1,"focusable","false"),attr(s1,"aria-hidden","true"),attr(r1,"class","spectrum-Accordion-itemHeading"),attr(u1,"class","spectrum-Accordion-itemContent svelte-11prom"),attr(u1,"role",n1[0]),attr(t1,"class",f1="spectrum-Accordion-item "+n1[3](n1[2])+" svelte-11prom"),attr(e1,"class","spectrum-Accordion svelte-11prom"),attr(e1,"role",n1[0])},m(g1,$1){insert$1(g1,e1,$1),append$1(e1,t1),append$1(t1,r1),append$1(r1,o1),append$1(o1,i1),append$1(r1,a1),append$1(r1,s1),append$1(s1,l1),append$1(t1,c1),append$1(t1,u1),h1&&h1.m(u1,null),d1=!0,p1||(m1=listen(o1,"click",n1[7]),p1=!0)},p(g1,[$1]){(!d1||$1&2)&&set_data(i1,g1[1]),h1&&h1.p&&(!d1||$1&32)&&update_slot_base(h1,_1,g1,g1[5],d1?get_slot_changes(_1,g1[5],$1,null):get_all_dirty_from_scope(g1[5]),null),(!d1||$1&1)&&attr(u1,"role",g1[0]),(!d1||$1&4&&f1!==(f1="spectrum-Accordion-item "+g1[3](g1[2])+" svelte-11prom"))&&attr(t1,"class",f1),(!d1||$1&1)&&attr(e1,"role",g1[0])},i(g1){d1||(transition_in(h1,g1),d1=!0)},o(g1){transition_out(h1,g1),d1=!1},d(g1){g1&&detach(e1),h1&&h1.d(g1),p1=!1,m1()}}}function instance$8o(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{itemName:i1}=e1,{initialOpen:a1}=e1,{header:s1}=e1,l1;function c1(f1){return f1===void 0&&(f1=a1),f1?"is-open":""}const u1=()=>t1(2,l1=!l1);return n1.$$set=f1=>{"itemName"in f1&&t1(0,i1=f1.itemName),"initialOpen"in f1&&t1(4,a1=f1.initialOpen),"header"in f1&&t1(1,s1=f1.header),"$$scope"in f1&&t1(5,o1=f1.$$scope)},[i1,s1,l1,c1,a1,o1,r1,u1]}class Accordion extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8o,create_fragment$8d,safe_not_equal,{itemName:0,initialOpen:4,header:1})}}const CheckboxGroup_svelte_svelte_type_style_lang="",File_svelte_svelte_type_style_lang="";function create_if_block$3P(n1){let e1,t1,r1,o1=n1[0].name+"",i1,a1,s1,l1,c1=n1[4]&&create_if_block_4$F(n1),u1=n1[0].size&&create_if_block_2$1d(n1),f1=(!n1[2]||n1[3]===!0&&n1[2])&&create_if_block_1$28(n1);return{c(){e1=element("div"),c1&&c1.c(),t1=space$1(),r1=element("div"),i1=text(o1),a1=space$1(),u1&&u1.c(),s1=space$1(),f1&&f1.c(),attr(r1,"class","filename svelte-hy829z"),attr(e1,"class","file-view svelte-hy829z")},m(d1,p1){insert$1(d1,e1,p1),c1&&c1.m(e1,null),append$1(e1,t1),append$1(e1,r1),append$1(r1,i1),append$1(e1,a1),u1&&u1.m(e1,null),append$1(e1,s1),f1&&f1.m(e1,null),l1=!0},p(d1,p1){d1[4]?c1?c1.p(d1,p1):(c1=create_if_block_4$F(d1),c1.c(),c1.m(e1,t1)):c1&&(c1.d(1),c1=null),(!l1||p1&1)&&o1!==(o1=d1[0].name+"")&&set_data(i1,o1),d1[0].size?u1?u1.p(d1,p1):(u1=create_if_block_2$1d(d1),u1.c(),u1.m(e1,s1)):u1&&(u1.d(1),u1=null),!d1[2]||d1[3]===!0&&d1[2]?f1?(f1.p(d1,p1),p1&12&&transition_in(f1,1)):(f1=create_if_block_1$28(d1),f1.c(),transition_in(f1,1),f1.m(e1,null)):f1&&(group_outros(),transition_out(f1,1,1,()=>{f1=null}),check_outros())},i(d1){l1||(transition_in(f1),l1=!0)},o(d1){transition_out(f1),l1=!1},d(d1){d1&&detach(e1),c1&&c1.d(),u1&&u1.d(),f1&&f1.d()}}}function create_if_block_4$F(n1){let e1,t1;return{c(){e1=element("img"),attr(e1,"class","preview svelte-hy829z"),attr(e1,"alt",""),src_url_equal(e1.src,t1=n1[4])||attr(e1,"src",t1)},m(r1,o1){insert$1(r1,e1,o1)},p(r1,o1){o1&16&&!src_url_equal(e1.src,t1=r1[4])&&attr(e1,"src",t1)},d(r1){r1&&detach(e1)}}}function create_if_block_2$1d(n1){let e1;function t1(i1,a1){return i1[0].size<=BYTES_IN_MB$3?create_if_block_3$T:create_else_block$1p}let r1=t1(n1),o1=r1(n1);return{c(){e1=element("div"),o1.c(),attr(e1,"class","filesize svelte-hy829z")},m(i1,a1){insert$1(i1,e1,a1),o1.m(e1,null)},p(i1,a1){r1===(r1=t1(i1))&&o1?o1.p(i1,a1):(o1.d(1),o1=r1(i1),o1&&(o1.c(),o1.m(e1,null)))},d(i1){i1&&detach(e1),o1.d()}}}function create_else_block$1p(n1){let e1=`${n1[0].size/BYTES_IN_MB$3} MB`,t1;return{c(){t1=text(e1)},m(r1,o1){insert$1(r1,t1,o1)},p(r1,o1){o1&1&&e1!==(e1=`${r1[0].size/BYTES_IN_MB$3} MB`)&&set_data(t1,e1)},d(r1){r1&&detach(t1)}}}function create_if_block_3$T(n1){let e1=`${n1[0].size/BYTES_IN_KB} KB`,t1;return{c(){t1=text(e1)},m(r1,o1){insert$1(r1,t1,o1)},p(r1,o1){o1&1&&e1!==(e1=`${r1[0].size/BYTES_IN_KB} KB`)&&set_data(t1,e1)},d(r1){r1&&detach(t1)}}}function create_if_block_1$28(n1){let e1,t1,r1,o1,i1;return t1=new Icon({props:{name:"Close",size:"XS"}}),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","delete-button svelte-hy829z")},m(a1,s1){insert$1(a1,e1,s1),mount_component(t1,e1,null),r1=!0,o1||(i1=listen(e1,"click",n1[9]),o1=!0)},p:noop$5,i(a1){r1||(transition_in(t1.$$.fragment,a1),r1=!0)},o(a1){transition_out(t1.$$.fragment,a1),r1=!1},d(a1){a1&&detach(e1),destroy_component(t1),o1=!1,i1()}}}function create_default_slot$5c(n1){let e1;return{c(){e1=text(n1[1])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&2&&set_data(e1,t1[1])},d(t1){t1&&detach(e1)}}}function create_fragment$8c(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1=n1[0]&&create_if_block$3P(n1);return i1=new ActionButton({props:{disabled:n1[2],$$slots:{default:[create_default_slot$5c]},$$scope:{ctx:n1}}}),i1.$on("click",function(){is_function(n1[5].click())&&n1[5].click().apply(this,arguments)}),{c(){e1=element("input"),t1=space$1(),r1=element("div"),c1&&c1.c(),o1=space$1(),create_component(i1.$$.fragment),attr(e1,"id",n1[7]),e1.disabled=n1[2],attr(e1,"type","file"),attr(e1,"accept",n1[6]),attr(e1,"class","svelte-hy829z"),attr(r1,"class","field svelte-hy829z")},m(u1,f1){insert$1(u1,e1,f1),n1[14](e1),insert$1(u1,t1,f1),insert$1(u1,r1,f1),c1&&c1.m(r1,null),append$1(r1,o1),mount_component(i1,r1,null),a1=!0,s1||(l1=listen(e1,"change",n1[8]),s1=!0)},p(u1,[f1]){n1=u1,(!a1||f1&4)&&(e1.disabled=n1[2]),(!a1||f1&64)&&attr(e1,"accept",n1[6]),n1[0]?c1?(c1.p(n1,f1),f1&1&&transition_in(c1,1)):(c1=create_if_block$3P(n1),c1.c(),transition_in(c1,1),c1.m(r1,o1)):c1&&(group_outros(),transition_out(c1,1,1,()=>{c1=null}),check_outros());const d1={};f1&4&&(d1.disabled=n1[2]),f1&131074&&(d1.$$scope={dirty:f1,ctx:n1}),i1.$set(d1)},i(u1){a1||(transition_in(c1),transition_in(i1.$$.fragment,u1),a1=!0)},o(u1){transition_out(c1),transition_out(i1.$$.fragment,u1),a1=!1},d(u1){u1&&detach(e1),n1[14](null),u1&&detach(t1),u1&&detach(r1),c1&&c1.d(),destroy_component(i1),s1=!1,l1()}}}const BYTES_IN_KB=1e3,BYTES_IN_MB$3=1e6;function instance$8n(n1,e1,t1){let r1,{value:o1=null}=e1,{title:i1="Upload file"}=e1,{disabled:a1=!1}=e1,{allowClear:s1=null}=e1,{extensions:l1=null}=e1,{handleFileTooLarge:c1=null}=e1,{fileSizeLimit:u1=BYTES_IN_MB$3*20}=e1,{id:f1=null}=e1,{previewUrl:d1=null}=e1;const p1=f1||uuid(),m1=createEventDispatcher();let _1;async function h1(v1){if(c1&&(v1==null?void 0:v1.size)>=u1){c1(v1);return}m1("change",v1)}function g1(v1){h1(v1.target.files[0])}function $1(){m1("change",null)}function y1(v1){binding_callbacks[v1?"unshift":"push"](()=>{_1=v1,t1(5,_1)})}return n1.$$set=v1=>{"value"in v1&&t1(0,o1=v1.value),"title"in v1&&t1(1,i1=v1.title),"disabled"in v1&&t1(2,a1=v1.disabled),"allowClear"in v1&&t1(3,s1=v1.allowClear),"extensions"in v1&&t1(10,l1=v1.extensions),"handleFileTooLarge"in v1&&t1(11,c1=v1.handleFileTooLarge),"fileSizeLimit"in v1&&t1(12,u1=v1.fileSizeLimit),"id"in v1&&t1(13,f1=v1.id),"previewUrl"in v1&&t1(4,d1=v1.previewUrl)},n1.$$.update=()=>{n1.$$.dirty&1024&&t1(6,r1=Array.isArray(l1)?l1.join(","):"*")},[o1,i1,a1,s1,d1,_1,r1,p1,g1,$1,l1,c1,u1,f1,y1]}let File$2=class extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8n,create_fragment$8c,safe_not_equal,{value:0,title:1,disabled:2,allowClear:3,extensions:10,handleFileTooLarge:11,fileSizeLimit:12,id:13,previewUrl:4})}};function create_default_slot$5b(n1){let e1,t1;return e1=new File$2({props:{error:n1[8],disabled:n1[3],allowClear:n1[4],title:n1[9],value:n1[0],previewUrl:n1[6],handleFileTooLarge:n1[5],extensions:n1[7]}}),e1.$on("change",n1[12]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&256&&(i1.error=r1[8]),o1&8&&(i1.disabled=r1[3]),o1&16&&(i1.allowClear=r1[4]),o1&512&&(i1.title=r1[9]),o1&1&&(i1.value=r1[0]),o1&64&&(i1.previewUrl=r1[6]),o1&32&&(i1.handleFileTooLarge=r1[5]),o1&128&&(i1.extensions=r1[7]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$8b(n1){let e1,t1;return e1=new Field({props:{helpText:n1[11],label:n1[1],labelPosition:n1[2],error:n1[8],tooltip:n1[10],$$slots:{default:[create_default_slot$5b]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&2048&&(i1.helpText=r1[11]),o1&2&&(i1.label=r1[1]),o1&4&&(i1.labelPosition=r1[2]),o1&256&&(i1.error=r1[8]),o1&1024&&(i1.tooltip=r1[10]),o1&17401&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8m(n1,e1,t1){let{label:r1=null}=e1,{labelPosition:o1="above"}=e1,{disabled:i1=!1}=e1,{allowClear:a1=null}=e1,{handleFileTooLarge:s1=()=>{}}=e1,{previewUrl:l1=null}=e1,{extensions:c1=null}=e1,{error:u1=null}=e1,{title:f1=null}=e1,{value:d1=null}=e1,{tooltip:p1=null}=e1,{helpText:m1=null}=e1;const _1=createEventDispatcher(),h1=g1=>{t1(0,d1=g1.detail),_1("change",g1.detail)};return n1.$$set=g1=>{"label"in g1&&t1(1,r1=g1.label),"labelPosition"in g1&&t1(2,o1=g1.labelPosition),"disabled"in g1&&t1(3,i1=g1.disabled),"allowClear"in g1&&t1(4,a1=g1.allowClear),"handleFileTooLarge"in g1&&t1(5,s1=g1.handleFileTooLarge),"previewUrl"in g1&&t1(6,l1=g1.previewUrl),"extensions"in g1&&t1(7,c1=g1.extensions),"error"in g1&&t1(8,u1=g1.error),"title"in g1&&t1(9,f1=g1.title),"value"in g1&&t1(0,d1=g1.value),"tooltip"in g1&&t1(10,p1=g1.tooltip),"helpText"in g1&&t1(11,m1=g1.helpText)},[d1,r1,o1,i1,a1,s1,l1,c1,u1,f1,p1,m1,h1]}let File$1=class extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8m,create_fragment$8b,safe_not_equal,{label:1,labelPosition:2,disabled:3,allowClear:4,handleFileTooLarge:5,previewUrl:6,extensions:7,error:8,title:9,value:0,tooltip:10,helpText:11})}};function flip(n1,{from:e1,to:t1},r1={}){const o1=getComputedStyle(n1),i1=o1.transform==="none"?"":o1.transform,[a1,s1]=o1.transformOrigin.split(" ").map(parseFloat),l1=e1.left+e1.width*a1/t1.width-(t1.left+a1),c1=e1.top+e1.height*s1/t1.height-(t1.top+s1),{delay:u1=0,duration:f1=p1=>Math.sqrt(p1)*120,easing:d1=cubicOut}=r1;return{delay:u1,duration:is_function(f1)?f1(Math.sqrt(l1*l1+c1*c1)):f1,easing:d1,css:(p1,m1)=>{const _1=m1*l1,h1=m1*c1,g1=p1+m1*e1.width/t1.width,$1=p1+m1*e1.height/t1.height;return`transform: ${i1} translate(${_1}px, ${h1}px) scale(${g1}, ${$1});`}}}const FINALIZE_EVENT_NAME="finalize",CONSIDER_EVENT_NAME="consider";function dispatchFinalizeEvent(n1,e1,t1){n1.dispatchEvent(new CustomEvent(FINALIZE_EVENT_NAME,{detail:{items:e1,info:t1}}))}function dispatchConsiderEvent(n1,e1,t1){n1.dispatchEvent(new CustomEvent(CONSIDER_EVENT_NAME,{detail:{items:e1,info:t1}}))}const DRAGGED_ENTERED_EVENT_NAME="draggedEntered",DRAGGED_LEFT_EVENT_NAME="draggedLeft",DRAGGED_OVER_INDEX_EVENT_NAME="draggedOverIndex",DRAGGED_LEFT_DOCUMENT_EVENT_NAME="draggedLeftDocument",DRAGGED_LEFT_TYPES={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function dispatchDraggedElementEnteredContainer(n1,e1,t1){n1.dispatchEvent(new CustomEvent(DRAGGED_ENTERED_EVENT_NAME,{detail:{indexObj:e1,draggedEl:t1}}))}function dispatchDraggedElementLeftContainerForAnother(n1,e1,t1){n1.dispatchEvent(new CustomEvent(DRAGGED_LEFT_EVENT_NAME,{detail:{draggedEl:e1,type:DRAGGED_LEFT_TYPES.LEFT_FOR_ANOTHER,theOtherDz:t1}}))}function dispatchDraggedElementLeftContainerForNone(n1,e1){n1.dispatchEvent(new CustomEvent(DRAGGED_LEFT_EVENT_NAME,{detail:{draggedEl:e1,type:DRAGGED_LEFT_TYPES.OUTSIDE_OF_ANY}}))}function dispatchDraggedElementIsOverIndex(n1,e1,t1){n1.dispatchEvent(new CustomEvent(DRAGGED_OVER_INDEX_EVENT_NAME,{detail:{indexObj:e1,draggedEl:t1}}))}function dispatchDraggedLeftDocument(n1){window.dispatchEvent(new CustomEvent(DRAGGED_LEFT_DOCUMENT_EVENT_NAME,{detail:{draggedEl:n1}}))}const TRIGGERS={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:DRAGGED_ENTERED_EVENT_NAME,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:DRAGGED_OVER_INDEX_EVENT_NAME,DRAGGED_LEFT:DRAGGED_LEFT_EVENT_NAME,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},SOURCES={POINTER:"pointer",KEYBOARD:"keyboard"},SHADOW_ITEM_MARKER_PROPERTY_NAME="isDndShadowItem",SHADOW_ELEMENT_ATTRIBUTE_NAME="data-is-dnd-shadow-item",SHADOW_PLACEHOLDER_ITEM_ID="id:dnd-shadow-placeholder-0000",DRAGGED_ELEMENT_ID="dnd-action-dragged-el";let ITEM_ID_KEY="id",activeDndZoneCount=0;function incrementActiveDropZoneCount(){activeDndZoneCount++}function decrementActiveDropZoneCount(){if(activeDndZoneCount===0)throw new Error("Bug! trying to decrement when there are no dropzones");activeDndZoneCount--}const isOnServer=typeof window>"u";function getBoundingRectNoTransforms(n1){let e1;const t1=n1.getBoundingClientRect(),r1=getComputedStyle(n1),o1=r1.transform;if(o1){let i1,a1,s1,l1;if(o1.startsWith("matrix3d("))e1=o1.slice(9,-1).split(/, /),i1=+e1[0],a1=+e1[5],s1=+e1[12],l1=+e1[13];else if(o1.startsWith("matrix("))e1=o1.slice(7,-1).split(/, /),i1=+e1[0],a1=+e1[3],s1=+e1[4],l1=+e1[5];else return t1;const c1=r1.transformOrigin,u1=t1.x-s1-(1-i1)*parseFloat(c1),f1=t1.y-l1-(1-a1)*parseFloat(c1.slice(c1.indexOf(" ")+1)),d1=i1?t1.width/i1:n1.offsetWidth,p1=a1?t1.height/a1:n1.offsetHeight;return{x:u1,y:f1,width:d1,height:p1,top:f1,right:u1+d1,bottom:f1+p1,left:u1}}else return t1}function getAbsoluteRectNoTransforms(n1){const e1=getBoundingRectNoTransforms(n1);return{top:e1.top+window.scrollY,bottom:e1.bottom+window.scrollY,left:e1.left+window.scrollX,right:e1.right+window.scrollX}}function getAbsoluteRect(n1){const e1=n1.getBoundingClientRect();return{top:e1.top+window.scrollY,bottom:e1.bottom+window.scrollY,left:e1.left+window.scrollX,right:e1.right+window.scrollX}}function findCenter(n1){return{x:(n1.left+n1.right)/2,y:(n1.top+n1.bottom)/2}}function calcDistance(n1,e1){return Math.sqrt(Math.pow(n1.x-e1.x,2)+Math.pow(n1.y-e1.y,2))}function isPointInsideRect(n1,e1){return n1.y<=e1.bottom&&n1.y>=e1.top&&n1.x>=e1.left&&n1.x<=e1.right}function findCenterOfElement(n1){return findCenter(getAbsoluteRect(n1))}function isCenterOfAInsideB(n1,e1){const t1=findCenterOfElement(n1),r1=getAbsoluteRectNoTransforms(e1);return isPointInsideRect(t1,r1)}function calcDistanceBetweenCenters(n1,e1){const t1=findCenterOfElement(n1),r1=findCenterOfElement(e1);return calcDistance(t1,r1)}function isElementOffDocument(n1){const e1=getAbsoluteRect(n1);return e1.right<0||e1.left>document.documentElement.scrollWidth||e1.bottom<0||e1.top>document.documentElement.scrollHeight}function calcInnerDistancesBetweenPointAndSidesOfElement(n1,e1){const t1=getAbsoluteRect(e1);return isPointInsideRect(n1,t1)?{top:n1.y-t1.top,bottom:t1.bottom-n1.y,left:n1.x-t1.left,right:Math.min(t1.right,document.documentElement.clientWidth)-n1.x}:null}let dzToShadowIndexToRect;function resetIndexesCache(){dzToShadowIndexToRect=new Map}resetIndexesCache();function resetIndexesCacheForDz(n1){dzToShadowIndexToRect.delete(n1)}function cacheShadowRect(n1){const e1=Array.from(n1.children).findIndex(t1=>t1.getAttribute(SHADOW_ELEMENT_ATTRIBUTE_NAME));if(e1>=0)return dzToShadowIndexToRect.has(n1)||dzToShadowIndexToRect.set(n1,new Map),dzToShadowIndexToRect.get(n1).set(e1,getAbsoluteRectNoTransforms(n1.children[e1])),e1}function findWouldBeIndex(n1,e1){if(!isCenterOfAInsideB(n1,e1))return null;const t1=e1.children;if(t1.length===0)return{index:0,isProximityBased:!0};const r1=cacheShadowRect(e1);for(let a1=0;a1<t1.length;a1++)if(isCenterOfAInsideB(n1,t1[a1])){const s1=dzToShadowIndexToRect.has(e1)&&dzToShadowIndexToRect.get(e1).get(a1);return s1&&!isPointInsideRect(findCenterOfElement(n1),s1)?{index:r1,isProximityBased:!1}:{index:a1,isProximityBased:!1}}let o1=Number.MAX_VALUE,i1;for(let a1=0;a1<t1.length;a1++){const s1=calcDistanceBetweenCenters(n1,t1[a1]);s1<o1&&(o1=s1,i1=a1)}return{index:i1,isProximityBased:!0}}const SCROLL_ZONE_PX=25;function makeScroller(){let n1;function e1(){n1={directionObj:void 0,stepPx:0}}e1();function t1(i1){const{directionObj:a1,stepPx:s1}=n1;a1&&(i1.scrollBy(a1.x*s1,a1.y*s1),window.requestAnimationFrame(()=>t1(i1)))}function r1(i1){return SCROLL_ZONE_PX-i1}function o1(i1,a1){if(!a1)return!1;const s1=calcInnerDistancesBetweenPointAndSidesOfElement(i1,a1);if(s1===null)return e1(),!1;const l1=!!n1.directionObj;let[c1,u1]=[!1,!1];return a1.scrollHeight>a1.clientHeight&&(s1.bottom<SCROLL_ZONE_PX?(c1=!0,n1.directionObj={x:0,y:1},n1.stepPx=r1(s1.bottom)):s1.top<SCROLL_ZONE_PX&&(c1=!0,n1.directionObj={x:0,y:-1},n1.stepPx=r1(s1.top)),!l1&&c1)||a1.scrollWidth>a1.clientWidth&&(s1.right<SCROLL_ZONE_PX?(u1=!0,n1.directionObj={x:1,y:0},n1.stepPx=r1(s1.right)):s1.left<SCROLL_ZONE_PX&&(u1=!0,n1.directionObj={x:-1,y:0},n1.stepPx=r1(s1.left)),!l1&&u1)?(t1(a1),!0):(e1(),!1)}return{scrollIfNeeded:o1,resetScrolling:e1}}function toString$6(n1){return JSON.stringify(n1,null,2)}function getDepth(n1){if(!n1)throw new Error("cannot get depth of a falsy node");return _getDepth(n1,0)}function _getDepth(n1,e1=0){return n1.parentElement?_getDepth(n1.parentElement,e1+1):e1-1}function areObjectsShallowEqual(n1,e1){if(Object.keys(n1).length!==Object.keys(e1).length)return!1;for(const t1 in n1)if(!{}.hasOwnProperty.call(e1,t1)||e1[t1]!==n1[t1])return!1;return!0}function areArraysShallowEqualSameOrder(n1,e1){if(n1.length!==e1.length)return!1;for(let t1=0;t1<n1.length;t1++)if(n1[t1]!==e1[t1])return!1;return!0}const INTERVAL_MS$1=200,TOLERANCE_PX=10,{scrollIfNeeded:scrollIfNeeded$1,resetScrolling:resetScrolling$1}=makeScroller();let next$1;function observe$2(n1,e1,t1=INTERVAL_MS$1){let r1,o1,i1=!1,a1;const s1=Array.from(e1).sort((c1,u1)=>getDepth(u1)-getDepth(c1));function l1(){const c1=findCenterOfElement(n1),u1=scrollIfNeeded$1(c1,r1);if(!u1&&a1&&Math.abs(a1.x-c1.x)<TOLERANCE_PX&&Math.abs(a1.y-c1.y)<TOLERANCE_PX){next$1=window.setTimeout(l1,t1);return}if(isElementOffDocument(n1)){dispatchDraggedLeftDocument(n1);return}a1=c1;let f1=!1;for(const d1 of s1){u1&&resetIndexesCacheForDz(r1);const p1=findWouldBeIndex(n1,d1);if(p1===null)continue;const{index:m1}=p1;f1=!0,d1!==r1?(r1&&dispatchDraggedElementLeftContainerForAnother(r1,n1,d1),dispatchDraggedElementEnteredContainer(d1,p1,n1),r1=d1):m1!==o1&&(dispatchDraggedElementIsOverIndex(d1,p1,n1),o1=m1);break}!f1&&i1&&r1?(dispatchDraggedElementLeftContainerForNone(r1,n1),r1=void 0,o1=void 0,i1=!1):i1=!0,next$1=window.setTimeout(l1,t1)}l1()}function unobserve$1(){clearTimeout(next$1),resetScrolling$1(),resetIndexesCache()}const INTERVAL_MS=300;let mousePosition;function updateMousePosition(n1){const e1=n1.touches?n1.touches[0]:n1;mousePosition={x:e1.clientX,y:e1.clientY}}const{scrollIfNeeded,resetScrolling}=makeScroller();let next;function loop(){mousePosition&&scrollIfNeeded(mousePosition,document.documentElement)&&resetIndexesCache(),next=window.setTimeout(loop,INTERVAL_MS)}function armWindowScroller(){window.addEventListener("mousemove",updateMousePosition),window.addEventListener("touchmove",updateMousePosition),loop()}function disarmWindowScroller(){window.removeEventListener("mousemove",updateMousePosition),window.removeEventListener("touchmove",updateMousePosition),mousePosition=void 0,window.clearTimeout(next),resetScrolling()}function svelteNodeClone(n1){const e1=n1.cloneNode(!0),t1=[],r1=n1.tagName==="SELECT",o1=r1?[n1]:[...n1.querySelectorAll("select")];for(const a1 of o1)t1.push(a1.value);if(o1.length<=0)return e1;const i1=r1?[e1]:[...e1.querySelectorAll("select")];for(let a1=0;a1<i1.length;a1++){const s1=i1[a1],l1=t1[a1],c1=s1.querySelector(`option[value="${l1}"`);c1&&c1.setAttribute("selected",!0)}return e1}const TRANSITION_DURATION_SECONDS=.2;function trs(n1){return`${n1} ${TRANSITION_DURATION_SECONDS}s ease`}function createDraggedElementFrom(n1,e1){const t1=n1.getBoundingClientRect(),r1=svelteNodeClone(n1);copyStylesFromTo(n1,r1),r1.id=DRAGGED_ELEMENT_ID,r1.style.position="fixed";let o1=t1.top,i1=t1.left;if(r1.style.top=`${o1}px`,r1.style.left=`${i1}px`,e1){const a1=findCenter(t1);o1-=a1.y-e1.y,i1-=a1.x-e1.x,window.setTimeout(()=>{r1.style.top=`${o1}px`,r1.style.left=`${i1}px`},0)}return r1.style.margin="0",r1.style.boxSizing="border-box",r1.style.height=`${t1.height}px`,r1.style.width=`${t1.width}px`,r1.style.transition=`${trs("top")}, ${trs("left")}, ${trs("background-color")}, ${trs("opacity")}, ${trs("color")} `,window.setTimeout(()=>r1.style.transition+=`, ${trs("width")}, ${trs("height")}`,0),r1.style.zIndex="9999",r1.style.cursor="grabbing",r1}function moveDraggedElementToWasDroppedState(n1){n1.style.cursor="grab"}function morphDraggedElementToBeLike(n1,e1,t1,r1){copyStylesFromTo(e1,n1);const o1=e1.getBoundingClientRect(),i1=n1.getBoundingClientRect(),a1=o1.width-i1.width,s1=o1.height-i1.height;if(a1||s1){const l1={left:(t1-i1.left)/i1.width,top:(r1-i1.top)/i1.height};n1.style.height=`${o1.height}px`,n1.style.width=`${o1.width}px`,n1.style.left=`${parseFloat(n1.style.left)-l1.left*a1}px`,n1.style.top=`${parseFloat(n1.style.top)-l1.top*s1}px`}}function copyStylesFromTo(n1,e1){const t1=window.getComputedStyle(n1);Array.from(t1).filter(r1=>r1.startsWith("background")||r1.startsWith("padding")||r1.startsWith("font")||r1.startsWith("text")||r1.startsWith("align")||r1.startsWith("justify")||r1.startsWith("display")||r1.startsWith("flex")||r1.startsWith("border")||r1==="opacity"||r1==="color"||r1==="list-style-type").forEach(r1=>e1.style.setProperty(r1,t1.getPropertyValue(r1),t1.getPropertyPriority(r1)))}function styleDraggable(n1,e1){n1.draggable=!1,n1.ondragstart=()=>!1,e1?(n1.style.userSelect="",n1.style.WebkitUserSelect="",n1.style.cursor=""):(n1.style.userSelect="none",n1.style.WebkitUserSelect="none",n1.style.cursor="grab")}function hideElement(n1){n1.style.display="none",n1.style.position="fixed",n1.style.zIndex="-5"}function decorateShadowEl(n1){n1.style.visibility="hidden",n1.setAttribute(SHADOW_ELEMENT_ATTRIBUTE_NAME,"true")}function unDecorateShadowElement(n1){n1.style.visibility="",n1.removeAttribute(SHADOW_ELEMENT_ATTRIBUTE_NAME)}function styleActiveDropZones(n1,e1=()=>{},t1=()=>[]){n1.forEach(r1=>{const o1=e1(r1);Object.keys(o1).forEach(i1=>{r1.style[i1]=o1[i1]}),t1(r1).forEach(i1=>r1.classList.add(i1))})}function styleInactiveDropZones(n1,e1=()=>{},t1=()=>[]){n1.forEach(r1=>{const o1=e1(r1);Object.keys(o1).forEach(i1=>{r1.style[i1]=""}),t1(r1).forEach(i1=>r1.classList.contains(i1)&&r1.classList.remove(i1))})}function preventShrinking(n1){const e1=n1.style.minHeight;n1.style.minHeight=window.getComputedStyle(n1).getPropertyValue("height");const t1=n1.style.minWidth;return n1.style.minWidth=window.getComputedStyle(n1).getPropertyValue("width"),function(){n1.style.minHeight=e1,n1.style.minWidth=t1}}const DEFAULT_DROP_ZONE_TYPE$1="--any--",MIN_OBSERVATION_INTERVAL_MS=100,MIN_MOVEMENT_BEFORE_DRAG_START_PX=3,DEFAULT_DROP_TARGET_STYLE$1={outline:"rgba(255, 255, 102, 0.7) solid 2px"};let originalDragTarget,draggedEl,draggedElData,draggedElType,originDropZone,originIndex,shadowElData,shadowElDropZone,dragStartMousePosition,currentMousePosition,isWorkingOnPreviousDrag=!1,finalizingPreviousDrag=!1,unlockOriginDzMinDimensions,isDraggedOutsideOfAnyDz=!1,scheduledForRemovalAfterDrop=[];const typeToDropZones$1=new Map,dzToConfig$1=new Map,elToMouseDownListener=new WeakMap;function registerDropZone$1(n1,e1){typeToDropZones$1.has(e1)||typeToDropZones$1.set(e1,new Set),typeToDropZones$1.get(e1).has(n1)||(typeToDropZones$1.get(e1).add(n1),incrementActiveDropZoneCount())}function unregisterDropZone$1(n1,e1){typeToDropZones$1.get(e1).delete(n1),decrementActiveDropZoneCount(),typeToDropZones$1.get(e1).size===0&&typeToDropZones$1.delete(e1)}function watchDraggedElement(){armWindowScroller();const n1=typeToDropZones$1.get(draggedElType);for(const t1 of n1)t1.addEventListener(DRAGGED_ENTERED_EVENT_NAME,handleDraggedEntered),t1.addEventListener(DRAGGED_LEFT_EVENT_NAME,handleDraggedLeft),t1.addEventListener(DRAGGED_OVER_INDEX_EVENT_NAME,handleDraggedIsOverIndex);window.addEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME,handleDrop$1);const e1=Math.max(MIN_OBSERVATION_INTERVAL_MS,...Array.from(n1.keys()).map(t1=>dzToConfig$1.get(t1).dropAnimationDurationMs));observe$2(draggedEl,n1,e1*1.07)}function unWatchDraggedElement(){disarmWindowScroller();const n1=typeToDropZones$1.get(draggedElType);for(const e1 of n1)e1.removeEventListener(DRAGGED_ENTERED_EVENT_NAME,handleDraggedEntered),e1.removeEventListener(DRAGGED_LEFT_EVENT_NAME,handleDraggedLeft),e1.removeEventListener(DRAGGED_OVER_INDEX_EVENT_NAME,handleDraggedIsOverIndex);window.removeEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME,handleDrop$1),unobserve$1()}function findShadowPlaceHolderIdx(n1){return n1.findIndex(e1=>e1[ITEM_ID_KEY]===SHADOW_PLACEHOLDER_ITEM_ID)}function findShadowElementIdx(n1){return n1.findIndex(e1=>!!e1[SHADOW_ITEM_MARKER_PROPERTY_NAME]&&e1[ITEM_ID_KEY]!==SHADOW_PLACEHOLDER_ITEM_ID)}function handleDraggedEntered(n1){let{items:e1,dropFromOthersDisabled:t1}=dzToConfig$1.get(n1.currentTarget);if(t1&&n1.currentTarget!==originDropZone)return;if(isDraggedOutsideOfAnyDz=!1,e1=e1.filter(a1=>a1[ITEM_ID_KEY]!==shadowElData[ITEM_ID_KEY]),originDropZone!==n1.currentTarget){const s1=dzToConfig$1.get(originDropZone).items.filter(l1=>!l1[SHADOW_ITEM_MARKER_PROPERTY_NAME]);dispatchConsiderEvent(originDropZone,s1,{trigger:TRIGGERS.DRAGGED_ENTERED_ANOTHER,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}else{const a1=findShadowPlaceHolderIdx(e1);a1!==-1&&e1.splice(a1,1)}const{index:r1,isProximityBased:o1}=n1.detail.indexObj,i1=o1&&r1===n1.currentTarget.children.length-1?r1+1:r1;shadowElDropZone=n1.currentTarget,e1.splice(i1,0,shadowElData),dispatchConsiderEvent(n1.currentTarget,e1,{trigger:TRIGGERS.DRAGGED_ENTERED,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}function handleDraggedLeft(n1){if(!isWorkingOnPreviousDrag)return;const{items:e1,dropFromOthersDisabled:t1}=dzToConfig$1.get(n1.currentTarget);if(t1&&n1.currentTarget!==originDropZone&&n1.currentTarget!==shadowElDropZone)return;const r1=findShadowElementIdx(e1),o1=e1.splice(r1,1)[0];shadowElDropZone=void 0;const{type:i1,theOtherDz:a1}=n1.detail;if(i1===DRAGGED_LEFT_TYPES.OUTSIDE_OF_ANY||i1===DRAGGED_LEFT_TYPES.LEFT_FOR_ANOTHER&&a1!==originDropZone&&dzToConfig$1.get(a1).dropFromOthersDisabled){isDraggedOutsideOfAnyDz=!0,shadowElDropZone=originDropZone;const s1=dzToConfig$1.get(originDropZone).items;s1.splice(originIndex,0,o1),dispatchConsiderEvent(originDropZone,s1,{trigger:TRIGGERS.DRAGGED_LEFT_ALL,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}dispatchConsiderEvent(n1.currentTarget,e1,{trigger:TRIGGERS.DRAGGED_LEFT,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}function handleDraggedIsOverIndex(n1){const{items:e1,dropFromOthersDisabled:t1}=dzToConfig$1.get(n1.currentTarget);if(t1&&n1.currentTarget!==originDropZone)return;isDraggedOutsideOfAnyDz=!1;const{index:r1}=n1.detail.indexObj,o1=findShadowElementIdx(e1);e1.splice(o1,1),e1.splice(r1,0,shadowElData),dispatchConsiderEvent(n1.currentTarget,e1,{trigger:TRIGGERS.DRAGGED_OVER_INDEX,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}function handleMouseMove(n1){n1.preventDefault();const e1=n1.touches?n1.touches[0]:n1;currentMousePosition={x:e1.clientX,y:e1.clientY},draggedEl.style.transform=`translate3d(${currentMousePosition.x-dragStartMousePosition.x}px, ${currentMousePosition.y-dragStartMousePosition.y}px, 0)`}function handleDrop$1(){finalizingPreviousDrag=!0,window.removeEventListener("mousemove",handleMouseMove),window.removeEventListener("touchmove",handleMouseMove),window.removeEventListener("mouseup",handleDrop$1),window.removeEventListener("touchend",handleDrop$1),unWatchDraggedElement(),moveDraggedElementToWasDroppedState(draggedEl),shadowElDropZone||(shadowElDropZone=originDropZone);let{items:n1,type:e1}=dzToConfig$1.get(shadowElDropZone);styleInactiveDropZones(typeToDropZones$1.get(e1),o1=>dzToConfig$1.get(o1).dropTargetStyle,o1=>dzToConfig$1.get(o1).dropTargetClasses);let t1=findShadowElementIdx(n1);t1===-1&&(t1=originIndex),n1=n1.map(o1=>o1[SHADOW_ITEM_MARKER_PROPERTY_NAME]?draggedElData:o1);function r1(){unlockOriginDzMinDimensions(),dispatchFinalizeEvent(shadowElDropZone,n1,{trigger:isDraggedOutsideOfAnyDz?TRIGGERS.DROPPED_OUTSIDE_OF_ANY:TRIGGERS.DROPPED_INTO_ZONE,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER}),shadowElDropZone!==originDropZone&&dispatchFinalizeEvent(originDropZone,dzToConfig$1.get(originDropZone).items,{trigger:TRIGGERS.DROPPED_INTO_ANOTHER,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER}),unDecorateShadowElement(shadowElDropZone.children[t1]),cleanupPostDrop()}animateDraggedToFinalPosition(t1,r1)}function animateDraggedToFinalPosition(n1,e1){const t1=getBoundingRectNoTransforms(shadowElDropZone.children[n1]),r1={x:t1.left-parseFloat(draggedEl.style.left),y:t1.top-parseFloat(draggedEl.style.top)},{dropAnimationDurationMs:o1}=dzToConfig$1.get(shadowElDropZone),i1=`transform ${o1}ms ease`;draggedEl.style.transition=draggedEl.style.transition?draggedEl.style.transition+","+i1:i1,draggedEl.style.transform=`translate3d(${r1.x}px, ${r1.y}px, 0)`,window.setTimeout(e1,o1)}function scheduleDZForRemovalAfterDrop(n1,e1){scheduledForRemovalAfterDrop.push({dz:n1,destroy:e1}),window.requestAnimationFrame(()=>{hideElement(n1),document.body.appendChild(n1)})}function cleanupPostDrop(){draggedEl.remove(),originalDragTarget.remove(),scheduledForRemovalAfterDrop.length&&(scheduledForRemovalAfterDrop.forEach(({dz:n1,destroy:e1})=>{e1(),n1.remove()}),scheduledForRemovalAfterDrop=[]),draggedEl=void 0,originalDragTarget=void 0,draggedElData=void 0,draggedElType=void 0,originDropZone=void 0,originIndex=void 0,shadowElData=void 0,shadowElDropZone=void 0,dragStartMousePosition=void 0,currentMousePosition=void 0,isWorkingOnPreviousDrag=!1,finalizingPreviousDrag=!1,unlockOriginDzMinDimensions=void 0,isDraggedOutsideOfAnyDz=!1}function dndzone$2(n1,e1){let t1=!1;const r1={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:DEFAULT_DROP_TARGET_STYLE$1,dropTargetClasses:[],transformDraggedElement:()=>{},centreDraggedOnCursor:!1};let o1=new Map;function i1(){window.addEventListener("mousemove",l1,{passive:!1}),window.addEventListener("touchmove",l1,{passive:!1,capture:!1}),window.addEventListener("mouseup",s1,{passive:!1}),window.addEventListener("touchend",s1,{passive:!1})}function a1(){window.removeEventListener("mousemove",l1),window.removeEventListener("touchmove",l1),window.removeEventListener("mouseup",s1),window.removeEventListener("touchend",s1)}function s1(){a1(),originalDragTarget=void 0,dragStartMousePosition=void 0,currentMousePosition=void 0}function l1(d1){d1.preventDefault();const p1=d1.touches?d1.touches[0]:d1;currentMousePosition={x:p1.clientX,y:p1.clientY},(Math.abs(currentMousePosition.x-dragStartMousePosition.x)>=MIN_MOVEMENT_BEFORE_DRAG_START_PX||Math.abs(currentMousePosition.y-dragStartMousePosition.y)>=MIN_MOVEMENT_BEFORE_DRAG_START_PX)&&(a1(),u1())}function c1(d1){if(d1.target!==d1.currentTarget&&(d1.target.value!==void 0||d1.target.isContentEditable)||d1.button||isWorkingOnPreviousDrag)return;d1.stopPropagation();const p1=d1.touches?d1.touches[0]:d1;dragStartMousePosition={x:p1.clientX,y:p1.clientY},currentMousePosition={...dragStartMousePosition},originalDragTarget=d1.currentTarget,i1()}function u1(){isWorkingOnPreviousDrag=!0;const d1=o1.get(originalDragTarget);originIndex=d1,originDropZone=originalDragTarget.parentElement;const p1=originDropZone.getRootNode(),m1=p1.body||p1,{items:_1,type:h1,centreDraggedOnCursor:g1}=r1;draggedElData={..._1[d1]},draggedElType=h1,shadowElData={...draggedElData,[SHADOW_ITEM_MARKER_PROPERTY_NAME]:!0};const $1={...shadowElData,[ITEM_ID_KEY]:SHADOW_PLACEHOLDER_ITEM_ID};draggedEl=createDraggedElementFrom(originalDragTarget,g1&&currentMousePosition);function y1(){draggedEl.parentElement?window.requestAnimationFrame(y1):(m1.appendChild(draggedEl),draggedEl.focus(),watchDraggedElement(),hideElement(originalDragTarget),m1.appendChild(originalDragTarget))}window.requestAnimationFrame(y1),styleActiveDropZones(Array.from(typeToDropZones$1.get(r1.type)).filter(v1=>v1===originDropZone||!dzToConfig$1.get(v1).dropFromOthersDisabled),v1=>dzToConfig$1.get(v1).dropTargetStyle,v1=>dzToConfig$1.get(v1).dropTargetClasses),_1.splice(d1,1,$1),unlockOriginDzMinDimensions=preventShrinking(originDropZone),dispatchConsiderEvent(originDropZone,_1,{trigger:TRIGGERS.DRAG_STARTED,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER}),window.addEventListener("mousemove",handleMouseMove,{passive:!1}),window.addEventListener("touchmove",handleMouseMove,{passive:!1,capture:!1}),window.addEventListener("mouseup",handleDrop$1,{passive:!1}),window.addEventListener("touchend",handleDrop$1,{passive:!1})}function f1({items:d1=void 0,flipDurationMs:p1=0,type:m1=DEFAULT_DROP_ZONE_TYPE$1,dragDisabled:_1=!1,morphDisabled:h1=!1,dropFromOthersDisabled:g1=!1,dropTargetStyle:$1=DEFAULT_DROP_TARGET_STYLE$1,dropTargetClasses:y1=[],transformDraggedElement:v1=()=>{},centreDraggedOnCursor:S1=!1}){r1.dropAnimationDurationMs=p1,r1.type&&m1!==r1.type&&unregisterDropZone$1(n1,r1.type),r1.type=m1,registerDropZone$1(n1,m1),r1.items=[...d1],r1.dragDisabled=_1,r1.morphDisabled=h1,r1.transformDraggedElement=v1,r1.centreDraggedOnCursor=S1,t1&&isWorkingOnPreviousDrag&&!finalizingPreviousDrag&&(!areObjectsShallowEqual($1,r1.dropTargetStyle)||!areArraysShallowEqualSameOrder(y1,r1.dropTargetClasses))&&(styleInactiveDropZones([n1],()=>r1.dropTargetStyle,()=>y1),styleActiveDropZones([n1],()=>$1,()=>y1)),r1.dropTargetStyle=$1,r1.dropTargetClasses=[...y1];function O1(M1,z1){return dzToConfig$1.get(M1)?dzToConfig$1.get(M1)[z1]:r1[z1]}t1&&isWorkingOnPreviousDrag&&r1.dropFromOthersDisabled!==g1&&(g1?styleInactiveDropZones([n1],M1=>O1(M1,"dropTargetStyle"),M1=>O1(M1,"dropTargetClasses")):styleActiveDropZones([n1],M1=>O1(M1,"dropTargetStyle"),M1=>O1(M1,"dropTargetClasses"))),r1.dropFromOthersDisabled=g1,dzToConfig$1.set(n1,r1);const C1=findShadowElementIdx(r1.items);for(let M1=0;M1<n1.children.length;M1++){const z1=n1.children[M1];if(styleDraggable(z1,_1),M1===C1){r1.transformDraggedElement(draggedEl,draggedElData,M1),h1||morphDraggedElementToBeLike(draggedEl,z1,currentMousePosition.x,currentMousePosition.y),decorateShadowEl(z1);continue}z1.removeEventListener("mousedown",elToMouseDownListener.get(z1)),z1.removeEventListener("touchstart",elToMouseDownListener.get(z1)),_1||(z1.addEventListener("mousedown",c1),z1.addEventListener("touchstart",c1),elToMouseDownListener.set(z1,c1)),o1.set(z1,M1),t1||(t1=!0)}}return f1(e1),{update:d1=>{f1(d1)},destroy:()=>{function d1(){unregisterDropZone$1(n1,dzToConfig$1.get(n1).type),dzToConfig$1.delete(n1)}isWorkingOnPreviousDrag?scheduleDZForRemovalAfterDrop(n1,d1):d1()}}}const INSTRUCTION_IDs$1={DND_ZONE_ACTIVE:"dnd-zone-active",DND_ZONE_DRAG_DISABLED:"dnd-zone-drag-disabled"},ID_TO_INSTRUCTION={[INSTRUCTION_IDs$1.DND_ZONE_ACTIVE]:"Tab to one the items and press space-bar or enter to start dragging it",[INSTRUCTION_IDs$1.DND_ZONE_DRAG_DISABLED]:"This is a disabled drag and drop list"},ALERT_DIV_ID="dnd-action-aria-alert";let alertsDiv;function initAriaOnBrowser(){alertsDiv||(alertsDiv=document.createElement("div"),function(){alertsDiv.id=ALERT_DIV_ID,alertsDiv.style.position="fixed",alertsDiv.style.bottom="0",alertsDiv.style.left="0",alertsDiv.style.zIndex="-5",alertsDiv.style.opacity="0",alertsDiv.style.height="0",alertsDiv.style.width="0",alertsDiv.setAttribute("role","alert")}(),document.body.prepend(alertsDiv),Object.entries(ID_TO_INSTRUCTION).forEach(([n1,e1])=>document.body.prepend(instructionToHiddenDiv(n1,e1))))}function initAria(){return isOnServer?null:(document.readyState==="complete"?initAriaOnBrowser():window.addEventListener("DOMContentLoaded",initAriaOnBrowser),{...INSTRUCTION_IDs$1})}function destroyAria(){isOnServer||!alertsDiv||(Object.keys(ID_TO_INSTRUCTION).forEach(n1=>{var e1;return(e1=document.getElementById(n1))==null?void 0:e1.remove()}),alertsDiv.remove(),alertsDiv=void 0)}function instructionToHiddenDiv(n1,e1){const t1=document.createElement("div");return t1.id=n1,t1.innerHTML=`<p>${e1}</p>`,t1.style.display="none",t1.style.position="fixed",t1.style.zIndex="-5",t1}function alertToScreenReader(n1){if(isOnServer)return;alertsDiv||initAriaOnBrowser(),alertsDiv.innerHTML="";const e1=document.createTextNode(n1);alertsDiv.appendChild(e1),alertsDiv.style.display="none",alertsDiv.style.display="inline"}const DEFAULT_DROP_ZONE_TYPE="--any--",DEFAULT_DROP_TARGET_STYLE={outline:"rgba(255, 255, 102, 0.7) solid 2px"};let isDragging=!1,draggedItemType,focusedDz,focusedDzLabel="",focusedItem,focusedItemId,focusedItemLabel="";const allDragTargets=new WeakSet,elToKeyDownListeners=new WeakMap,elToFocusListeners=new WeakMap,dzToHandles=new Map,dzToConfig=new Map,typeToDropZones=new Map;let INSTRUCTION_IDs;function registerDropZone(n1,e1){typeToDropZones.size===0&&(INSTRUCTION_IDs=initAria(),window.addEventListener("keydown",globalKeyDownHandler),window.addEventListener("click",globalClickHandler)),typeToDropZones.has(e1)||typeToDropZones.set(e1,new Set),typeToDropZones.get(e1).has(n1)||(typeToDropZones.get(e1).add(n1),incrementActiveDropZoneCount())}function unregisterDropZone(n1,e1){focusedDz===n1&&handleDrop(),typeToDropZones.get(e1).delete(n1),decrementActiveDropZoneCount(),typeToDropZones.get(e1).size===0&&typeToDropZones.delete(e1),typeToDropZones.size===0&&(window.removeEventListener("keydown",globalKeyDownHandler),window.removeEventListener("click",globalClickHandler),INSTRUCTION_IDs=void 0,destroyAria())}function globalKeyDownHandler(n1){if(isDragging)switch(n1.key){case"Escape":{handleDrop();break}}}function globalClickHandler(){isDragging&&(allDragTargets.has(document.activeElement)||handleDrop())}function handleZoneFocus(n1){if(!isDragging)return;const e1=n1.currentTarget;if(e1===focusedDz)return;focusedDzLabel=e1.getAttribute("aria-label")||"";const{items:t1}=dzToConfig.get(focusedDz),r1=t1.find(c1=>c1[ITEM_ID_KEY]===focusedItemId),o1=t1.indexOf(r1),i1=t1.splice(o1,1)[0],{items:a1,autoAriaDisabled:s1}=dzToConfig.get(e1);e1.getBoundingClientRect().top<focusedDz.getBoundingClientRect().top||e1.getBoundingClientRect().left<focusedDz.getBoundingClientRect().left?(a1.push(i1),s1||alertToScreenReader(`Moved item ${focusedItemLabel} to the end of the list ${focusedDzLabel}`)):(a1.unshift(i1),s1||alertToScreenReader(`Moved item ${focusedItemLabel} to the beginning of the list ${focusedDzLabel}`)),dispatchFinalizeEvent(focusedDz,t1,{trigger:TRIGGERS.DROPPED_INTO_ANOTHER,id:focusedItemId,source:SOURCES.KEYBOARD}),dispatchFinalizeEvent(e1,a1,{trigger:TRIGGERS.DROPPED_INTO_ZONE,id:focusedItemId,source:SOURCES.KEYBOARD}),focusedDz=e1}function triggerAllDzsUpdate(){dzToHandles.forEach(({update:n1},e1)=>n1(dzToConfig.get(e1)))}function handleDrop(n1=!0){dzToConfig.get(focusedDz).autoAriaDisabled||alertToScreenReader(`Stopped dragging item ${focusedItemLabel}`),allDragTargets.has(document.activeElement)&&document.activeElement.blur(),n1&&dispatchConsiderEvent(focusedDz,dzToConfig.get(focusedDz).items,{trigger:TRIGGERS.DRAG_STOPPED,id:focusedItemId,source:SOURCES.KEYBOARD}),styleInactiveDropZones(typeToDropZones.get(draggedItemType),e1=>dzToConfig.get(e1).dropTargetStyle,e1=>dzToConfig.get(e1).dropTargetClasses),focusedItem=null,focusedItemId=null,focusedItemLabel="",draggedItemType=null,focusedDz=null,focusedDzLabel="",isDragging=!1,triggerAllDzsUpdate()}function dndzone$1(n1,e1){const t1={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:DEFAULT_DROP_TARGET_STYLE,dropTargetClasses:[],autoAriaDisabled:!1};function r1(u1,f1,d1){u1.length<=1||u1.splice(d1,1,u1.splice(f1,1,u1[d1])[0])}function o1(u1){switch(u1.key){case"Enter":case" ":{if((u1.target.disabled!==void 0||u1.target.href||u1.target.isContentEditable)&&!allDragTargets.has(u1.target))return;u1.preventDefault(),u1.stopPropagation(),isDragging?handleDrop():i1(u1);break}case"ArrowDown":case"ArrowRight":{if(!isDragging)return;u1.preventDefault(),u1.stopPropagation();const{items:f1}=dzToConfig.get(n1),d1=Array.from(n1.children),p1=d1.indexOf(u1.currentTarget);p1<d1.length-1&&(t1.autoAriaDisabled||alertToScreenReader(`Moved item ${focusedItemLabel} to position ${p1+2} in the list ${focusedDzLabel}`),r1(f1,p1,p1+1),dispatchFinalizeEvent(n1,f1,{trigger:TRIGGERS.DROPPED_INTO_ZONE,id:focusedItemId,source:SOURCES.KEYBOARD}));break}case"ArrowUp":case"ArrowLeft":{if(!isDragging)return;u1.preventDefault(),u1.stopPropagation();const{items:f1}=dzToConfig.get(n1),p1=Array.from(n1.children).indexOf(u1.currentTarget);p1>0&&(t1.autoAriaDisabled||alertToScreenReader(`Moved item ${focusedItemLabel} to position ${p1} in the list ${focusedDzLabel}`),r1(f1,p1,p1-1),dispatchFinalizeEvent(n1,f1,{trigger:TRIGGERS.DROPPED_INTO_ZONE,id:focusedItemId,source:SOURCES.KEYBOARD}));break}}}function i1(u1){s1(u1.currentTarget),focusedDz=n1,draggedItemType=t1.type,isDragging=!0;const f1=Array.from(typeToDropZones.get(t1.type)).filter(d1=>d1===focusedDz||!dzToConfig.get(d1).dropFromOthersDisabled);if(styleActiveDropZones(f1,d1=>dzToConfig.get(d1).dropTargetStyle,d1=>dzToConfig.get(d1).dropTargetClasses),!t1.autoAriaDisabled){let d1=`Started dragging item ${focusedItemLabel}. Use the arrow keys to move it within its list ${focusedDzLabel}`;f1.length>1&&(d1+=", or tab to another list in order to move the item into it"),alertToScreenReader(d1)}dispatchConsiderEvent(n1,dzToConfig.get(n1).items,{trigger:TRIGGERS.DRAG_STARTED,id:focusedItemId,source:SOURCES.KEYBOARD}),triggerAllDzsUpdate()}function a1(u1){isDragging&&u1.currentTarget!==focusedItem&&(u1.stopPropagation(),handleDrop(!1),i1(u1))}function s1(u1){const{items:f1}=dzToConfig.get(n1),d1=Array.from(n1.children),p1=d1.indexOf(u1);focusedItem=u1,focusedItem.tabIndex=0,focusedItemId=f1[p1][ITEM_ID_KEY],focusedItemLabel=d1[p1].getAttribute("aria-label")||""}function l1({items:u1=[],type:f1=DEFAULT_DROP_ZONE_TYPE,dragDisabled:d1=!1,zoneTabIndex:p1=0,dropFromOthersDisabled:m1=!1,dropTargetStyle:_1=DEFAULT_DROP_TARGET_STYLE,dropTargetClasses:h1=[],autoAriaDisabled:g1=!1}){t1.items=[...u1],t1.dragDisabled=d1,t1.dropFromOthersDisabled=m1,t1.zoneTabIndex=p1,t1.dropTargetStyle=_1,t1.dropTargetClasses=h1,t1.autoAriaDisabled=g1,t1.type&&f1!==t1.type&&unregisterDropZone(n1,t1.type),t1.type=f1,registerDropZone(n1,f1),g1||(n1.setAttribute("aria-disabled",d1),n1.setAttribute("role","list"),n1.setAttribute("aria-describedby",d1?INSTRUCTION_IDs.DND_ZONE_DRAG_DISABLED:INSTRUCTION_IDs.DND_ZONE_ACTIVE)),dzToConfig.set(n1,t1),isDragging?n1.tabIndex=n1===focusedDz||focusedItem.contains(n1)||t1.dropFromOthersDisabled||focusedDz&&t1.type!==dzToConfig.get(focusedDz).type?-1:0:n1.tabIndex=t1.zoneTabIndex,n1.addEventListener("focus",handleZoneFocus);for(let $1=0;$1<n1.children.length;$1++){const y1=n1.children[$1];allDragTargets.add(y1),y1.tabIndex=isDragging?-1:0,g1||y1.setAttribute("role","listitem"),y1.removeEventListener("keydown",elToKeyDownListeners.get(y1)),y1.removeEventListener("click",elToFocusListeners.get(y1)),d1||(y1.addEventListener("keydown",o1),elToKeyDownListeners.set(y1,o1),y1.addEventListener("click",a1),elToFocusListeners.set(y1,a1)),isDragging&&t1.items[$1][ITEM_ID_KEY]===focusedItemId&&(focusedItem=y1,focusedItem.tabIndex=0,y1.focus())}}l1(e1);const c1={update:u1=>{l1(u1)},destroy:()=>{unregisterDropZone(n1,t1.type),dzToConfig.delete(n1),dzToHandles.delete(n1)}};return dzToHandles.set(n1,c1),c1}function dndzone(n1,e1){validateOptions(e1);const t1=dndzone$2(n1,e1),r1=dndzone$1(n1,e1);return{update:o1=>{validateOptions(o1),t1.update(o1),r1.update(o1)},destroy:()=>{t1.destroy(),r1.destroy()}}}function validateOptions(n1){const{items:e1,flipDurationMs:t1,type:r1,dragDisabled:o1,morphDisabled:i1,dropFromOthersDisabled:a1,zoneTabIndex:s1,dropTargetStyle:l1,dropTargetClasses:c1,transformDraggedElement:u1,autoAriaDisabled:f1,centreDraggedOnCursor:d1,...p1}=n1;if(Object.keys(p1).length>0&&console.warn("dndzone will ignore unknown options",p1),!e1)throw new Error("no 'items' key provided to dndzone");const m1=e1.find(_1=>!{}.hasOwnProperty.call(_1,ITEM_ID_KEY));if(m1)throw new Error(`missing '${ITEM_ID_KEY}' property for item ${toString$6(m1)}`);if(c1&&!Array.isArray(c1))throw new Error(`dropTargetClasses should be an array but instead it is a ${typeof c1}, ${toString$6(c1)}`);if(s1&&!isInt(s1))throw new Error(`zoneTabIndex should be a number but instead it is a ${typeof s1}, ${toString$6(s1)}`)}function isInt(n1){return!isNaN(n1)&&function(e1){return(e1|0)===e1}(parseFloat(n1))}const OptionSelectDnD_svelte_svelte_type_style_lang="";function get_each_context$1z(n1,e1,t1){const r1=n1.slice();return r1[18]=e1[t1],r1[19]=e1,r1[20]=t1,r1}function get_each_context_1$o(n1,e1,t1){const r1=n1.slice();return r1[21]=e1[t1],r1}function create_each_block_1$o(n1){let e1,t1,r1;function o1(){return n1[13](n1[18],n1[21],n1[20])}return{c(){e1=element("div"),set_style(e1,"--color",n1[21]),attr(e1,"class","circle circle-hover svelte-1e17jzv")},m(i1,a1){insert$1(i1,e1,a1),t1||(r1=listen(e1,"click",o1),t1=!0)},p(i1,a1){n1=i1},d(i1){i1&&detach(e1),t1=!1,r1()}}}function create_default_slot$5a(n1){let e1,t1=n1[4],r1=[];for(let o1=0;o1<t1.length;o1+=1)r1[o1]=create_each_block_1$o(get_each_context_1$o(n1,t1,o1));return{c(){e1=element("div");for(let o1=0;o1<r1.length;o1+=1)r1[o1].c();attr(e1,"class","colors svelte-1e17jzv")},m(o1,i1){insert$1(o1,e1,i1);for(let a1=0;a1<r1.length;a1+=1)r1[a1].m(e1,null)},p(o1,i1){if(i1&530){t1=o1[4];let a1;for(a1=0;a1<t1.length;a1+=1){const s1=get_each_context_1$o(o1,t1,a1);r1[a1]?r1[a1].p(s1,i1):(r1[a1]=create_each_block_1$o(s1),r1[a1].c(),r1[a1].m(e1,null))}for(;a1<r1.length;a1+=1)r1[a1].d(1);r1.length=t1.length}},d(o1){o1&&detach(e1),destroy_each(r1,o1)}}}function create_each_block$1z(n1,e1){let t1,r1,o1,i1,a1,s1,l1,c1=e1[20],u1,f1,d1,p1,m1,_1,h1,g1,$1,y1=noop$5,v1,S1,O1;o1=new Icon({props:{name:"DragHandle",size:"L"}});const C1=()=>e1[14](l1,c1),M1=()=>e1[14](null,c1);let z1={anchor:e1[3][e1[20]],align:"left",offset:0,style:"",popoverTarget:document.getElementById("color-picker"),animate:!1,$$slots:{default:[create_default_slot$5a]},$$scope:{ctx:e1}};l1=new Popover({props:z1}),C1();const P1=()=>e1[15](s1,c1),R1=()=>e1[15](null,c1);function N1(...B1){return e1[16](e1[20],...B1)}function F1(...B1){return e1[17](e1[18],e1[20],...B1)}return h1=new Icon({props:{name:"Close",hoverable:!0,size:"S"}}),h1.$on("click",function(){is_function(e1[5](e1[20]))&&e1[5](e1[20]).apply(this,arguments)}),{key:n1,first:null,c(){var B1;t1=element("div"),r1=element("div"),create_component(o1.$$.fragment),i1=space$1(),a1=element("div"),s1=element("div"),create_component(l1.$$.fragment),u1=space$1(),f1=element("div"),d1=element("input"),m1=space$1(),_1=element("div"),create_component(h1.$$.fragment),g1=space$1(),attr(r1,"class","child drag-handle-spacing svelte-1e17jzv"),attr(s1,"id","color-picker"),set_style(s1,"--color",((B1=e1[0])==null?void 0:B1[e1[18].name])||"hsla(0, 1%, 50%, 0.3)"),attr(s1,"class","circle svelte-1e17jzv"),attr(a1,"class","child color-picker svelte-1e17jzv"),attr(d1,"class","input-field svelte-1e17jzv"),attr(d1,"type","text"),d1.value=p1=e1[18].name,attr(d1,"placeholder","Option name"),attr(f1,"class","child svelte-1e17jzv"),attr(_1,"class","child svelte-1e17jzv"),attr(t1,"class","no-border action-container svelte-1e17jzv"),this.first=t1},m(B1,L1){insert$1(B1,t1,L1),append$1(t1,r1),mount_component(o1,r1,null),append$1(t1,i1),append$1(t1,a1),append$1(a1,s1),mount_component(l1,s1,null),P1(),append$1(t1,u1),append$1(t1,f1),append$1(f1,d1),append$1(t1,m1),append$1(t1,_1),mount_component(h1,_1,null),append$1(t1,g1),v1=!0,S1||(O1=[listen(s1,"click",N1),listen(d1,"change",F1)],S1=!0)},p(B1,L1){var j1;e1=B1,c1!==e1[20]&&(M1(),c1=e1[20],C1());const U1={};L1&10&&(U1.anchor=e1[3][e1[20]]),L1&16777218&&(U1.$$scope={dirty:L1,ctx:e1}),l1.$set(U1),(!v1||L1&3)&&set_style(s1,"--color",((j1=e1[0])==null?void 0:j1[e1[18].name])||"hsla(0, 1%, 50%, 0.3)"),c1!==e1[20]&&(R1(),c1=e1[20],P1()),(!v1||L1&2&&p1!==(p1=e1[18].name)&&d1.value!==p1)&&(d1.value=p1)},r(){$1=t1.getBoundingClientRect()},f(){fix_position(t1),y1()},a(){y1(),y1=create_animation(t1,$1,flip,{duration:flipDurationMs$4})},i(B1){v1||(transition_in(o1.$$.fragment,B1),transition_in(l1.$$.fragment,B1),transition_in(h1.$$.fragment,B1),v1=!0)},o(B1){transition_out(o1.$$.fragment,B1),transition_out(l1.$$.fragment,B1),transition_out(h1.$$.fragment,B1),v1=!1},d(B1){B1&&detach(t1),destroy_component(o1),M1(),destroy_component(l1),R1(),destroy_component(h1),S1=!1,run_all(O1)}}}function create_fragment$8a(n1){let e1,t1,r1=[],o1=new Map,i1,a1,s1,l1,c1,u1,f1,d1,p1,m1=n1[1];const _1=h1=>h1[18].id;for(let h1=0;h1<m1.length;h1+=1){let g1=get_each_context$1z(n1,m1,h1),$1=_1(g1);o1.set($1,r1[h1]=create_each_block$1z($1,g1))}return l1=new Icon({props:{hoverable:!0,name:"Add"}}),{c(){e1=element("div"),t1=element("div");for(let h1=0;h1<r1.length;h1+=1)r1[h1].c();a1=space$1(),s1=element("div"),create_component(l1.$$.fragment),c1=space$1(),u1=element("div"),u1.textContent="Add option",attr(t1,"class","actions"),attr(s1,"class","add-option svelte-1e17jzv")},m(h1,g1){insert$1(h1,e1,g1),append$1(e1,t1);for(let $1=0;$1<r1.length;$1+=1)r1[$1].m(t1,null);append$1(e1,a1),append$1(e1,s1),mount_component(l1,s1,null),append$1(s1,c1),append$1(s1,u1),f1=!0,d1||(p1=[action_destroyer(i1=dndzone.call(null,t1,{items:n1[1],flipDurationMs:flipDurationMs$4,dropTargetStyle:{outline:"none"}})),listen(t1,"consider",n1[7]),listen(t1,"finalize",n1[8]),listen(s1,"click",n1[6])],d1=!0)},p(h1,[g1]){if(g1&3647){m1=h1[1],group_outros();for(let $1=0;$1<r1.length;$1+=1)r1[$1].r();r1=update_keyed_each(r1,g1,_1,1,h1,m1,o1,t1,fix_and_outro_and_destroy_block,create_each_block$1z,null,get_each_context$1z);for(let $1=0;$1<r1.length;$1+=1)r1[$1].a();check_outros()}i1&&is_function(i1.update)&&g1&2&&i1.update.call(null,{items:h1[1],flipDurationMs:flipDurationMs$4,dropTargetStyle:{outline:"none"}})},i(h1){if(!f1){for(let g1=0;g1<m1.length;g1+=1)transition_in(r1[g1]);transition_in(l1.$$.fragment,h1),f1=!0}},o(h1){for(let g1=0;g1<r1.length;g1+=1)transition_out(r1[g1]);transition_out(l1.$$.fragment,h1),f1=!1},d(h1){h1&&detach(e1);for(let g1=0;g1<r1.length;g1+=1)r1[g1].d();destroy_component(l1),d1=!1,run_all(p1)}}}const flipDurationMs$4=150;function instance$8l(n1,e1,t1){let{constraints:r1}=e1,{optionColors:o1={}}=e1,i1=[],a1=[],s1=[],l1=["hsla(0, 90%, 75%, 0.3)","hsla(50, 80%, 75%, 0.3)","hsla(120, 90%, 75%, 0.3)","hsla(200, 90%, 75%, 0.3)","hsla(240, 90%, 75%, 0.3)","hsla(320, 90%, 75%, 0.3)"];const c1=S1=>{delete o1[i1[S1].name],t1(12,r1.inclusion=r1.inclusion.filter((O1,C1)=>C1!==S1),r1),t1(1,i1=i1.filter((O1,C1)=>C1!==S1)),a1.pop(void 0),s1.pop(void 0)},u1=()=>{t1(1,i1=[...i1,{name:`Option ${r1.inclusion.length+1}`,id:Math.random()}]),t1(12,r1.inclusion=[...r1.inclusion,`Option ${r1.inclusion.length+1}`],r1),a1.push(void 0),s1.push(void 0)},f1=S1=>{t1(1,i1=S1.detail.items)},d1=S1=>{t1(1,i1=S1.detail.items),t1(12,r1.inclusion=i1.map(O1=>O1.name),r1)},p1=(S1,O1,C1)=>{t1(0,o1[S1]=O1,o1),a1[C1].hide()},m1=(S1,O1,C1)=>{t1(12,r1.inclusion[O1]=C1,r1),t1(1,i1[O1].name=C1,i1),t1(0,o1[C1]=o1[S1],o1),delete o1[S1]},_1=(S1,O1)=>{a1[S1].show(),t1(3,s1[S1]=O1,s1)};onMount(()=>{t1(2,a1=r1.inclusion.map(()=>{})),t1(3,s1=r1.inclusion.map(()=>{})),t1(1,i1=r1.inclusion.map(S1=>({name:S1,id:Math.random()})))});const h1=(S1,O1,C1)=>p1(S1.name,O1,C1);function g1(S1,O1){binding_callbacks[S1?"unshift":"push"](()=>{a1[O1]=S1,t1(2,a1)})}function $1(S1,O1){binding_callbacks[S1?"unshift":"push"](()=>{s1[O1]=S1,t1(3,s1)})}const y1=(S1,O1)=>_1(S1,O1.target),v1=(S1,O1,C1)=>m1(S1.name,O1,C1.target.value);return n1.$$set=S1=>{"constraints"in S1&&t1(12,r1=S1.constraints),"optionColors"in S1&&t1(0,o1=S1.optionColors)},[o1,i1,a1,s1,l1,c1,u1,f1,d1,p1,m1,_1,r1,h1,g1,$1,y1,v1]}class OptionSelectDnD extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8l,create_fragment$8a,safe_not_equal,{constraints:12,optionColors:0})}}const BoldRenderer_svelte_svelte_type_style_lang="";function create_fragment$89(n1){let e1,t1;return{c(){e1=element("div"),t1=text(n1[0]),attr(e1,"class","bold svelte-9amtlb")},m(r1,o1){insert$1(r1,e1,o1),append$1(e1,t1)},p(r1,[o1]){o1&1&&set_data(t1,r1[0])},i:noop$5,o:noop$5,d(r1){r1&&detach(e1)}}}function instance$8k(n1,e1,t1){let{value:r1}=e1;return n1.$$set=o1=>{"value"in o1&&t1(0,r1=o1.value)},[r1]}class BoldRenderer extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8k,create_fragment$89,safe_not_equal,{value:0})}}const CodeRenderer_svelte_svelte_type_style_lang="";function create_fragment$88(n1){let e1,t1;return{c(){e1=element("code"),t1=text(n1[0]),attr(e1,"class","svelte-e82i3")},m(r1,o1){insert$1(r1,e1,o1),append$1(e1,t1)},p(r1,[o1]){o1&1&&set_data(t1,r1[0])},i:noop$5,o:noop$5,d(r1){r1&&detach(e1)}}}function instance$8j(n1,e1,t1){let{value:r1}=e1;return n1.$$set=o1=>{"value"in o1&&t1(0,r1=o1.value)},[r1]}class CodeRenderer extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8j,create_fragment$88,safe_not_equal,{value:0})}}const ErrorMessage_svelte_svelte_type_style_lang="";function create_fragment$87(n1){let e1,t1,r1,o1;return{c(){e1=element("div"),t1=text(n1[0]),attr(e1,"class","error-message svelte-wciay3")},m(i1,a1){insert$1(i1,e1,a1),append$1(e1,t1),o1=!0},p(i1,[a1]){(!o1||a1&1)&&set_data(t1,i1[0])},i(i1){o1||(i1&&add_render_callback(()=>{r1||(r1=create_bidirectional_transition(e1,slide,{duration:130},!0)),r1.run(1)}),o1=!0)},o(i1){i1&&(r1||(r1=create_bidirectional_transition(e1,slide,{duration:130},!1)),r1.run(0)),o1=!1},d(i1){i1&&detach(e1),i1&&r1&&r1.end()}}}function instance$8i(n1,e1,t1){let{error:r1=null}=e1;return n1.$$set=o1=>{"error"in o1&&t1(0,r1=o1.error)},[r1]}class ErrorMessage extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8i,create_fragment$87,safe_not_equal,{error:0})}}const FancyField_svelte_svelte_type_style_lang="";function create_if_block_1$27(n1){let e1,t1,r1;return t1=new Icon({props:{name:"Alert"}}),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","error-icon svelte-17ywq9")},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function create_if_block$3O(n1){let e1,t1;return e1=new ErrorMessage({props:{error:n1[0]}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&1&&(i1.error=r1[0]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$86(n1){let e1,t1,r1,o1,i1,a1,s1,l1;const c1=n1[10].default,u1=create_slot(c1,n1,n1[9],null);let f1=n1[0]&&create_if_block_1$27(),d1=n1[0]&&create_if_block$3O(n1);return{c(){e1=element("div"),t1=element("div"),r1=element("div"),u1&&u1.c(),o1=space$1(),f1&&f1.c(),i1=space$1(),d1&&d1.c(),attr(r1,"class","field svelte-17ywq9"),attr(t1,"class","content svelte-17ywq9"),attr(e1,"class","fancy-field svelte-17ywq9"),toggle_class(e1,"error",n1[0]),toggle_class(e1,"disabled",n1[2]),toggle_class(e1,"focused",n1[3]),toggle_class(e1,"clickable",n1[4]),toggle_class(e1,"compact",n1[6]),toggle_class(e1,"auto-height",n1[5])},m(p1,m1){insert$1(p1,e1,m1),append$1(e1,t1),append$1(t1,r1),u1&&u1.m(r1,null),append$1(t1,o1),f1&&f1.m(t1,null),append$1(e1,i1),d1&&d1.m(e1,null),n1[12](e1),a1=!0,s1||(l1=listen(t1,"click",n1[11]),s1=!0)},p(p1,[m1]){u1&&u1.p&&(!a1||m1&512)&&update_slot_base(u1,c1,p1,p1[9],a1?get_slot_changes(c1,p1[9],m1,null):get_all_dirty_from_scope(p1[9]),null),p1[0]?f1?m1&1&&transition_in(f1,1):(f1=create_if_block_1$27(),f1.c(),transition_in(f1,1),f1.m(t1,null)):f1&&(group_outros(),transition_out(f1,1,1,()=>{f1=null}),check_outros()),p1[0]?d1?(d1.p(p1,m1),m1&1&&transition_in(d1,1)):(d1=create_if_block$3O(p1),d1.c(),transition_in(d1,1),d1.m(e1,null)):d1&&(group_outros(),transition_out(d1,1,1,()=>{d1=null}),check_outros()),(!a1||m1&1)&&toggle_class(e1,"error",p1[0]),(!a1||m1&4)&&toggle_class(e1,"disabled",p1[2]),(!a1||m1&8)&&toggle_class(e1,"focused",p1[3]),(!a1||m1&16)&&toggle_class(e1,"clickable",p1[4]),(!a1||m1&64)&&toggle_class(e1,"compact",p1[6]),(!a1||m1&32)&&toggle_class(e1,"auto-height",p1[5])},i(p1){a1||(transition_in(u1,p1),transition_in(f1),transition_in(d1),a1=!0)},o(p1){transition_out(u1,p1),transition_out(f1),transition_out(d1),a1=!1},d(p1){p1&&detach(e1),u1&&u1.d(p1),f1&&f1.d(),d1&&d1.d(),n1[12](null),s1=!1,l1()}}}function instance$8h(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{disabled:i1=!1}=e1,{error:a1=null}=e1,{focused:s1=!1}=e1,{clickable:l1=!1}=e1,{validate:c1}=e1,{value:u1}=e1,{ref:f1}=e1,{autoHeight:d1}=e1,{compact:p1=!1}=e1;const m1=getContext("fancy-form"),_1=Math.random(),h1={validate:()=>(c1&&t1(0,a1=c1(u1)),!a1)};onMount(()=>(m1&&m1.registerField(_1,h1),()=>{m1&&m1.unregisterField(_1)}));function g1(y1){bubble.call(this,n1,y1)}function $1(y1){binding_callbacks[y1?"unshift":"push"](()=>{f1=y1,t1(1,f1)})}return n1.$$set=y1=>{"disabled"in y1&&t1(2,i1=y1.disabled),"error"in y1&&t1(0,a1=y1.error),"focused"in y1&&t1(3,s1=y1.focused),"clickable"in y1&&t1(4,l1=y1.clickable),"validate"in y1&&t1(7,c1=y1.validate),"value"in y1&&t1(8,u1=y1.value),"ref"in y1&&t1(1,f1=y1.ref),"autoHeight"in y1&&t1(5,d1=y1.autoHeight),"compact"in y1&&t1(6,p1=y1.compact),"$$scope"in y1&&t1(9,o1=y1.$$scope)},[a1,f1,i1,s1,l1,d1,p1,c1,u1,o1,r1,g1,$1]}class FancyField extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8h,create_fragment$86,safe_not_equal,{disabled:2,error:0,focused:3,clickable:4,validate:7,value:8,ref:1,autoHeight:5,compact:6})}}const FancyFieldLabel_svelte_svelte_type_style_lang="";function create_fragment$85(n1){let e1,t1;const r1=n1[2].default,o1=create_slot(r1,n1,n1[1],null);return{c(){e1=element("div"),o1&&o1.c(),attr(e1,"class","svelte-1yrw3p"),toggle_class(e1,"placeholder",n1[0])},m(i1,a1){insert$1(i1,e1,a1),o1&&o1.m(e1,null),t1=!0},p(i1,[a1]){o1&&o1.p&&(!t1||a1&2)&&update_slot_base(o1,r1,i1,i1[1],t1?get_slot_changes(r1,i1[1],a1,null):get_all_dirty_from_scope(i1[1]),null),(!t1||a1&1)&&toggle_class(e1,"placeholder",i1[0])},i(i1){t1||(transition_in(o1,i1),t1=!0)},o(i1){transition_out(o1,i1),t1=!1},d(i1){i1&&detach(e1),o1&&o1.d(i1)}}}function instance$8g(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{placeholder:i1=!0}=e1;return n1.$$set=a1=>{"placeholder"in a1&&t1(0,i1=a1.placeholder),"$$scope"in a1&&t1(1,o1=a1.$$scope)},[i1,o1,r1]}class FancyFieldLabel extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8g,create_fragment$85,safe_not_equal,{placeholder:0})}}const FancyInput_svelte_svelte_type_style_lang="";function create_if_block_1$26(n1){let e1,t1;return e1=new FancyFieldLabel({props:{placeholder:n1[9],$$slots:{default:[create_default_slot_1$3J]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&512&&(i1.placeholder=r1[9]),o1&65540&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_default_slot_1$3J(n1){let e1;return{c(){e1=text(n1[2])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&4&&set_data(e1,t1[2])},d(t1){t1&&detach(e1)}}}function create_if_block$3N(n1){let e1,t1,r1;return{c(){e1=element("div"),t1=text(n1[6]),attr(e1,"class","suffix svelte-1xkimai")},m(o1,i1){insert$1(o1,e1,i1),append$1(e1,t1)},p(o1,i1){i1&64&&set_data(t1,o1[6])},i(o1){o1&&(r1||add_render_callback(()=>{r1=create_in_transition(e1,fade,{duration:130}),r1.start()}))},o:noop$5,d(o1){o1&&detach(e1)}}}function create_default_slot$59(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1,u1=n1[2]&&create_if_block_1$26(n1),f1=n1[6]&&!n1[9]&&create_if_block$3N(n1);return{c(){u1&&u1.c(),e1=space$1(),t1=element("input"),i1=space$1(),f1&&f1.c(),a1=empty$1(),t1.disabled=n1[4],t1.value=r1=n1[0]||"",attr(t1,"type",o1=n1[3]||"text"),attr(t1,"class","svelte-1xkimai"),toggle_class(t1,"placeholder",n1[9])},m(d1,p1){u1&&u1.m(d1,p1),insert$1(d1,e1,p1),insert$1(d1,t1,p1),n1[14](t1),insert$1(d1,i1,p1),f1&&f1.m(d1,p1),insert$1(d1,a1,p1),s1=!0,l1||(c1=[listen(t1,"input",n1[10]),listen(t1,"focus",n1[12]),listen(t1,"blur",n1[13])],l1=!0)},p(d1,p1){d1[2]?u1?(u1.p(d1,p1),p1&4&&transition_in(u1,1)):(u1=create_if_block_1$26(d1),u1.c(),transition_in(u1,1),u1.m(e1.parentNode,e1)):u1&&(group_outros(),transition_out(u1,1,1,()=>{u1=null}),check_outros()),(!s1||p1&16)&&(t1.disabled=d1[4]),(!s1||p1&1&&r1!==(r1=d1[0]||"")&&t1.value!==r1)&&(t1.value=r1),(!s1||p1&8&&o1!==(o1=d1[3]||"text"))&&attr(t1,"type",o1),(!s1||p1&512)&&toggle_class(t1,"placeholder",d1[9]),d1[6]&&!d1[9]?f1?(f1.p(d1,p1),p1&576&&transition_in(f1,1)):(f1=create_if_block$3N(d1),f1.c(),transition_in(f1,1),f1.m(a1.parentNode,a1)):f1&&(f1.d(1),f1=null)},i(d1){s1||(transition_in(u1),transition_in(f1),s1=!0)},o(d1){transition_out(u1),s1=!1},d(d1){u1&&u1.d(d1),d1&&detach(e1),d1&&detach(t1),n1[14](null),d1&&detach(i1),f1&&f1.d(d1),d1&&detach(a1),l1=!1,run_all(c1)}}}function create_fragment$84(n1){let e1,t1;return e1=new FancyField({props:{error:n1[1],value:n1[0],validate:n1[5],disabled:n1[4],focused:n1[7],$$slots:{default:[create_default_slot$59]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&2&&(i1.error=r1[1]),o1&1&&(i1.value=r1[0]),o1&32&&(i1.validate=r1[5]),o1&16&&(i1.disabled=r1[4]),o1&128&&(i1.focused=r1[7]),o1&66525&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8f(n1,e1,t1){let r1,{label:o1}=e1,{value:i1}=e1,{type:a1="text"}=e1,{disabled:s1=!1}=e1,{error:l1=null}=e1,{validate:c1=null}=e1,{suffix:u1=null}=e1;const f1=createEventDispatcher();let d1,p1=!1,m1=!1;const _1=y1=>{const v1=y1.target.value;f1("change",v1),t1(0,i1=v1),c1&&t1(1,l1=c1(v1))};onMount(()=>{const y1=setInterval(()=>{t1(11,m1=d1==null?void 0:d1.matches(":-webkit-autofill")),m1&&clearInterval(y1)},100),v1=setTimeout(()=>{clearInterval(y1)},2e3);return()=>{clearInterval(y1),clearTimeout(v1)}});const h1=()=>t1(7,p1=!0),g1=()=>t1(7,p1=!1);function $1(y1){binding_callbacks[y1?"unshift":"push"](()=>{d1=y1,t1(8,d1)})}return n1.$$set=y1=>{"label"in y1&&t1(2,o1=y1.label),"value"in y1&&t1(0,i1=y1.value),"type"in y1&&t1(3,a1=y1.type),"disabled"in y1&&t1(4,s1=y1.disabled),"error"in y1&&t1(1,l1=y1.error),"validate"in y1&&t1(5,c1=y1.validate),"suffix"in y1&&t1(6,u1=y1.suffix)},n1.$$.update=()=>{n1.$$.dirty&2177&&t1(9,r1=!m1&&!p1&&!i1)},[i1,l1,o1,a1,s1,c1,u1,p1,d1,r1,_1,m1,h1,g1,$1]}class FancyInput extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8f,create_fragment$84,safe_not_equal,{label:2,value:0,type:3,disabled:4,error:1,validate:5,suffix:6})}}const FancyCheckbox_svelte_svelte_type_style_lang="";function create_if_block$3M(n1){let e1;return{c(){e1=text(n1[2])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&4&&set_data(e1,t1[2])},d(t1){t1&&detach(e1)}}}function create_default_slot$58(n1){let e1,t1,r1,o1,i1,a1;t1=new Checkbox({props:{disabled:n1[3],value:n1[0],indeterminate:n1[5]}});let s1=n1[2]&&create_if_block$3M(n1);const l1=n1[8].default,c1=create_slot(l1,n1,n1[9],null);return{c(){e1=element("span"),create_component(t1.$$.fragment),r1=space$1(),o1=element("div"),s1&&s1.c(),i1=space$1(),c1&&c1.c(),attr(e1,"class","svelte-14uwzyc"),attr(o1,"class","text svelte-14uwzyc"),toggle_class(o1,"compact",n1[6])},m(u1,f1){insert$1(u1,e1,f1),mount_component(t1,e1,null),insert$1(u1,r1,f1),insert$1(u1,o1,f1),s1&&s1.m(o1,null),append$1(o1,i1),c1&&c1.m(o1,null),a1=!0},p(u1,f1){const d1={};f1&8&&(d1.disabled=u1[3]),f1&1&&(d1.value=u1[0]),f1&32&&(d1.indeterminate=u1[5]),t1.$set(d1),u1[2]?s1?s1.p(u1,f1):(s1=create_if_block$3M(u1),s1.c(),s1.m(o1,i1)):s1&&(s1.d(1),s1=null),c1&&c1.p&&(!a1||f1&512)&&update_slot_base(c1,l1,u1,u1[9],a1?get_slot_changes(l1,u1[9],f1,null):get_all_dirty_from_scope(u1[9]),null),(!a1||f1&64)&&toggle_class(o1,"compact",u1[6])},i(u1){a1||(transition_in(t1.$$.fragment,u1),transition_in(c1,u1),a1=!0)},o(u1){transition_out(t1.$$.fragment,u1),transition_out(c1,u1),a1=!1},d(u1){u1&&detach(e1),destroy_component(t1),u1&&detach(r1),u1&&detach(o1),s1&&s1.d(),c1&&c1.d(u1)}}}function create_fragment$83(n1){let e1,t1;return e1=new FancyField({props:{error:n1[1],value:n1[0],validate:n1[4],disabled:n1[3],compact:n1[6],clickable:!0,$$slots:{default:[create_default_slot$58]},$$scope:{ctx:n1}}}),e1.$on("click",n1[7]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&2&&(i1.error=r1[1]),o1&1&&(i1.value=r1[0]),o1&16&&(i1.validate=r1[4]),o1&8&&(i1.disabled=r1[3]),o1&64&&(i1.compact=r1[6]),o1&621&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8e(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{value:i1}=e1,{text:a1}=e1,{disabled:s1=!1}=e1,{error:l1=null}=e1,{validate:c1=null}=e1,{indeterminate:u1=!1}=e1,{compact:f1=!1}=e1;const d1=createEventDispatcher(),p1=()=>{const m1=!i1;d1("change",m1),t1(0,i1=m1),c1&&t1(1,l1=c1(m1))};return n1.$$set=m1=>{"value"in m1&&t1(0,i1=m1.value),"text"in m1&&t1(2,a1=m1.text),"disabled"in m1&&t1(3,s1=m1.disabled),"error"in m1&&t1(1,l1=m1.error),"validate"in m1&&t1(4,c1=m1.validate),"indeterminate"in m1&&t1(5,u1=m1.indeterminate),"compact"in m1&&t1(6,f1=m1.compact),"$$scope"in m1&&t1(9,o1=m1.$$scope)},[i1,l1,a1,s1,c1,u1,f1,p1,r1,o1]}class FancyCheckbox extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8e,create_fragment$83,safe_not_equal,{value:0,text:2,disabled:3,error:1,validate:4,indeterminate:5,compact:6})}}const FancySelect_svelte_svelte_type_style_lang="";function create_if_block_1$25(n1){let e1,t1;return e1=new FancyFieldLabel({props:{placeholder:n1[16],$$slots:{default:[create_default_slot_1$3I]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&65536&&(i1.placeholder=r1[16]),o1&67108868&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_default_slot_1$3I(n1){let e1;return{c(){e1=text(n1[2])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&4&&set_data(e1,t1[2])},d(t1){t1&&detach(e1)}}}function create_if_block$3L(n1){let e1,t1,r1;return t1=new StatusLight({props:{square:!0,color:n1[14]}}),{c(){e1=element("span"),create_component(t1.$$.fragment),attr(e1,"class","align svelte-18t7xb4")},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,i1){const a1={};i1&16384&&(a1.color=o1[14]),t1.$set(a1)},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function create_default_slot$57(n1){let e1,t1,r1,o1=(n1[15]||"")+"",i1,a1,s1,l1,c1,u1=n1[2]&&create_if_block_1$25(n1),f1=n1[14]&&create_if_block$3L(n1);return l1=new Icon({props:{name:"ChevronDown"}}),{c(){u1&&u1.c(),e1=space$1(),f1&&f1.c(),t1=space$1(),r1=element("div"),i1=text(o1),a1=space$1(),s1=element("div"),create_component(l1.$$.fragment),attr(r1,"class","value svelte-18t7xb4"),toggle_class(r1,"placeholder",n1[16]),attr(s1,"class","align arrow-alignment svelte-18t7xb4")},m(d1,p1){u1&&u1.m(d1,p1),insert$1(d1,e1,p1),f1&&f1.m(d1,p1),insert$1(d1,t1,p1),insert$1(d1,r1,p1),append$1(r1,i1),insert$1(d1,a1,p1),insert$1(d1,s1,p1),mount_component(l1,s1,null),c1=!0},p(d1,p1){d1[2]?u1?(u1.p(d1,p1),p1&4&&transition_in(u1,1)):(u1=create_if_block_1$25(d1),u1.c(),transition_in(u1,1),u1.m(e1.parentNode,e1)):u1&&(group_outros(),transition_out(u1,1,1,()=>{u1=null}),check_outros()),d1[14]?f1?(f1.p(d1,p1),p1&16384&&transition_in(f1,1)):(f1=create_if_block$3L(d1),f1.c(),transition_in(f1,1),f1.m(t1.parentNode,t1)):f1&&(group_outros(),transition_out(f1,1,1,()=>{f1=null}),check_outros()),(!c1||p1&32768)&&o1!==(o1=(d1[15]||"")+"")&&set_data(i1,o1),(!c1||p1&65536)&&toggle_class(r1,"placeholder",d1[16])},i(d1){c1||(transition_in(u1),transition_in(f1),transition_in(l1.$$.fragment,d1),c1=!0)},o(d1){transition_out(u1),transition_out(f1),transition_out(l1.$$.fragment,d1),c1=!1},d(d1){u1&&u1.d(d1),d1&&detach(e1),f1&&f1.d(d1),d1&&detach(t1),d1&&detach(r1),d1&&detach(a1),d1&&detach(s1),destroy_component(l1)}}}function create_fragment$82(n1){let e1,t1,r1,o1,i1,a1,s1;function l1(d1){n1[18](d1)}let c1={error:n1[1],value:n1[0],validate:n1[4],disabled:n1[3],clickable:!0,$$slots:{default:[create_default_slot$57]},$$scope:{ctx:n1}};n1[13]!==void 0&&(c1.ref=n1[13]),e1=new FancyField({props:c1}),binding_callbacks.push(()=>bind$2(e1,"ref",l1)),e1.$on("click",n1[19]);function u1(d1){n1[21](d1)}let f1={customAnchor:n1[13],onlyPopover:!0,error:n1[1],disabled:n1[3],options:n1[5],footer:n1[6],getOptionLabel:n1[8],getOptionValue:n1[9],getOptionSubtitle:n1[10],getOptionColour:n1[11],isOptionEnabled:n1[7],isPlaceholder:n1[0]==null||n1[0]==="",placeholderOption:n1[16]===!1?null:n1[16],onSelectOption:n1[17],isOptionSelected:n1[20]};return n1[12]!==void 0&&(f1.open=n1[12]),i1=new Picker({props:f1}),binding_callbacks.push(()=>bind$2(i1,"open",u1)),{c(){create_component(e1.$$.fragment),r1=space$1(),o1=element("div"),create_component(i1.$$.fragment),attr(o1,"id","picker-wrapper"),attr(o1,"class","svelte-18t7xb4")},m(d1,p1){mount_component(e1,d1,p1),insert$1(d1,r1,p1),insert$1(d1,o1,p1),mount_component(i1,o1,null),s1=!0},p(d1,[p1]){const m1={};p1&2&&(m1.error=d1[1]),p1&1&&(m1.value=d1[0]),p1&16&&(m1.validate=d1[4]),p1&8&&(m1.disabled=d1[3]),p1&67223556&&(m1.$$scope={dirty:p1,ctx:d1}),!t1&&p1&8192&&(t1=!0,m1.ref=d1[13],add_flush_callback(()=>t1=!1)),e1.$set(m1);const _1={};p1&8192&&(_1.customAnchor=d1[13]),p1&2&&(_1.error=d1[1]),p1&8&&(_1.disabled=d1[3]),p1&32&&(_1.options=d1[5]),p1&64&&(_1.footer=d1[6]),p1&256&&(_1.getOptionLabel=d1[8]),p1&512&&(_1.getOptionValue=d1[9]),p1&1024&&(_1.getOptionSubtitle=d1[10]),p1&2048&&(_1.getOptionColour=d1[11]),p1&128&&(_1.isOptionEnabled=d1[7]),p1&1&&(_1.isPlaceholder=d1[0]==null||d1[0]===""),p1&65536&&(_1.placeholderOption=d1[16]===!1?null:d1[16]),p1&1&&(_1.isOptionSelected=d1[20]),!a1&&p1&4096&&(a1=!0,_1.open=d1[12],add_flush_callback(()=>a1=!1)),i1.$set(_1)},i(d1){s1||(transition_in(e1.$$.fragment,d1),transition_in(i1.$$.fragment,d1),s1=!0)},o(d1){transition_out(e1.$$.fragment,d1),transition_out(i1.$$.fragment,d1),s1=!1},d(d1){destroy_component(e1,d1),d1&&detach(r1),d1&&detach(o1),destroy_component(i1)}}}function instance$8d(n1,e1,t1){let r1,o1,i1,{label:a1}=e1,{value:s1}=e1,{disabled:l1=!1}=e1,{error:c1=null}=e1,{validate:u1=null}=e1,{options:f1=[]}=e1,{footer:d1=null}=e1,{isOptionEnabled:p1=()=>!0}=e1,{getOptionLabel:m1=F1=>O1(F1,"label")}=e1,{getOptionValue:_1=F1=>O1(F1,"value")}=e1,{getOptionSubtitle:h1=F1=>O1(F1,"subtitle")}=e1,{getOptionColour:g1=()=>null}=e1;const $1=createEventDispatcher();let y1=!1,v1;const S1=(F1,B1,L1)=>{if(!(L1!=null&&L1.length))return"";const U1=L1.findIndex((j1,Q1)=>_1(j1,Q1)===B1);return U1!==-1?F1(L1[U1],U1):null},O1=(F1,B1)=>F1&&typeof F1=="object"?F1[B1]:F1,C1=F1=>{$1("change",F1),t1(0,s1=F1),u1&&t1(1,c1=u1(F1)),t1(12,y1=!1)},M1=F1=>{if(!F1||!(f1!=null&&f1.length))return"";const B1=f1.find(L1=>_1(L1)===F1);return B1?m1(B1):F1};function z1(F1){v1=F1,t1(13,v1)}const P1=()=>t1(12,y1=!0),R1=F1=>F1===s1;function N1(F1){y1=F1,t1(12,y1)}return n1.$$set=F1=>{"label"in F1&&t1(2,a1=F1.label),"value"in F1&&t1(0,s1=F1.value),"disabled"in F1&&t1(3,l1=F1.disabled),"error"in F1&&t1(1,c1=F1.error),"validate"in F1&&t1(4,u1=F1.validate),"options"in F1&&t1(5,f1=F1.options),"footer"in F1&&t1(6,d1=F1.footer),"isOptionEnabled"in F1&&t1(7,p1=F1.isOptionEnabled),"getOptionLabel"in F1&&t1(8,m1=F1.getOptionLabel),"getOptionValue"in F1&&t1(9,_1=F1.getOptionValue),"getOptionSubtitle"in F1&&t1(10,h1=F1.getOptionSubtitle),"getOptionColour"in F1&&t1(11,g1=F1.getOptionColour)},n1.$$.update=()=>{n1.$$.dirty&1&&t1(16,r1=!s1),n1.$$.dirty&1&&t1(15,o1=M1(s1)),n1.$$.dirty&2081&&t1(14,i1=S1(g1,s1,f1))},[s1,c1,a1,l1,u1,f1,d1,p1,m1,_1,h1,g1,y1,v1,i1,o1,r1,C1,z1,P1,R1,N1]}class FancySelect extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8d,create_fragment$82,safe_not_equal,{label:2,value:0,disabled:3,error:1,validate:4,options:5,footer:6,isOptionEnabled:7,getOptionLabel:8,getOptionValue:9,getOptionSubtitle:10,getOptionColour:11})}}const FancyButton_svelte_svelte_type_style_lang="",get_icon_slot_changes$2=n1=>({}),get_icon_slot_context$2=n1=>({});function create_if_block$3K(n1){let e1,t1,r1,o1,i1;const a1=[create_if_block_1$24,create_else_block$1o],s1=[];function l1(c1,u1){return u1&1&&(e1=null),e1==null&&(e1=!!c1[0].includes("/")),e1?0:1}return t1=l1(n1,-1),r1=s1[t1]=a1[t1](n1),{c(){r1.c(),o1=empty$1()},m(c1,u1){s1[t1].m(c1,u1),insert$1(c1,o1,u1),i1=!0},p(c1,u1){let f1=t1;t1=l1(c1,u1),t1===f1?s1[t1].p(c1,u1):(group_outros(),transition_out(s1[f1],1,1,()=>{s1[f1]=null}),check_outros(),r1=s1[t1],r1?r1.p(c1,u1):(r1=s1[t1]=a1[t1](c1),r1.c()),transition_in(r1,1),r1.m(o1.parentNode,o1))},i(c1){i1||(transition_in(r1),i1=!0)},o(c1){transition_out(r1),i1=!1},d(c1){s1[t1].d(c1),c1&&detach(o1)}}}function create_else_block$1o(n1){let e1,t1;return e1=new Icon({props:{name:n1[0]}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&1&&(i1.name=r1[0]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_if_block_1$24(n1){let e1,t1;return{c(){e1=element("img"),src_url_equal(e1.src,t1=n1[0])||attr(e1,"src",t1),attr(e1,"alt","button"),attr(e1,"class","svelte-14pbp5s")},m(r1,o1){insert$1(r1,e1,o1)},p(r1,o1){o1&1&&!src_url_equal(e1.src,t1=r1[0])&&attr(e1,"src",t1)},i:noop$5,o:noop$5,d(r1){r1&&detach(e1)}}}function create_default_slot$56(n1){let e1,t1,r1,o1,i1=n1[0]&&create_if_block$3K(n1);const a1=n1[2].icon,s1=create_slot(a1,n1,n1[4],get_icon_slot_context$2),l1=n1[2].default,c1=create_slot(l1,n1,n1[4],null);return{c(){i1&&i1.c(),e1=space$1(),s1&&s1.c(),t1=space$1(),r1=element("div"),c1&&c1.c(),attr(r1,"class","svelte-14pbp5s")},m(u1,f1){i1&&i1.m(u1,f1),insert$1(u1,e1,f1),s1&&s1.m(u1,f1),insert$1(u1,t1,f1),insert$1(u1,r1,f1),c1&&c1.m(r1,null),o1=!0},p(u1,f1){u1[0]?i1?(i1.p(u1,f1),f1&1&&transition_in(i1,1)):(i1=create_if_block$3K(u1),i1.c(),transition_in(i1,1),i1.m(e1.parentNode,e1)):i1&&(group_outros(),transition_out(i1,1,1,()=>{i1=null}),check_outros()),s1&&s1.p&&(!o1||f1&16)&&update_slot_base(s1,a1,u1,u1[4],o1?get_slot_changes(a1,u1[4],f1,get_icon_slot_changes$2):get_all_dirty_from_scope(u1[4]),get_icon_slot_context$2),c1&&c1.p&&(!o1||f1&16)&&update_slot_base(c1,l1,u1,u1[4],o1?get_slot_changes(l1,u1[4],f1,null):get_all_dirty_from_scope(u1[4]),null)},i(u1){o1||(transition_in(i1),transition_in(s1,u1),transition_in(c1,u1),o1=!0)},o(u1){transition_out(i1),transition_out(s1,u1),transition_out(c1,u1),o1=!1},d(u1){i1&&i1.d(u1),u1&&detach(e1),s1&&s1.d(u1),u1&&detach(t1),u1&&detach(r1),c1&&c1.d(u1)}}}function create_fragment$81(n1){let e1,t1;return e1=new FancyField({props:{clickable:!0,disabled:n1[1],$$slots:{default:[create_default_slot$56]},$$scope:{ctx:n1}}}),e1.$on("click",n1[3]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&2&&(i1.disabled=r1[1]),o1&17&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8c(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{icon:i1}=e1,{disabled:a1}=e1;function s1(l1){bubble.call(this,n1,l1)}return n1.$$set=l1=>{"icon"in l1&&t1(0,i1=l1.icon),"disabled"in l1&&t1(1,a1=l1.disabled),"$$scope"in l1&&t1(4,o1=l1.$$scope)},[i1,a1,r1,s1,o1]}class FancyButton extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8c,create_fragment$81,safe_not_equal,{icon:0,disabled:1})}}const FancyForm_svelte_svelte_type_style_lang="";function create_fragment$80(n1){let e1,t1;const r1=n1[2].default,o1=create_slot(r1,n1,n1[1],null);return{c(){e1=element("div"),o1&&o1.c(),attr(e1,"class","fancy-form svelte-1wjd4hl")},m(i1,a1){insert$1(i1,e1,a1),o1&&o1.m(e1,null),t1=!0},p(i1,[a1]){o1&&o1.p&&(!t1||a1&2)&&update_slot_base(o1,r1,i1,i1[1],t1?get_slot_changes(r1,i1[1],a1,null):get_all_dirty_from_scope(i1[1]),null)},i(i1){t1||(transition_in(o1,i1),t1=!0)},o(i1){transition_out(o1,i1),t1=!1},d(i1){i1&&detach(e1),o1&&o1.d(i1)}}}function instance$8b(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,i1={};setContext("fancy-form",{registerField:(s1,l1)=>{i1={...i1,[s1]:l1}},unregisterField:s1=>{delete i1[s1],i1=i1}});const a1=()=>{let s1=!0;return Object.values(i1).forEach(l1=>{l1.validate()||(s1=!1)}),s1};return n1.$$set=s1=>{"$$scope"in s1&&t1(1,o1=s1.$$scope)},[a1,o1,r1]}class FancyForm extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8b,create_fragment$80,safe_not_equal,{validate:0})}get validate(){return this.$$.ctx[0]}}const FancyButtonRadio_svelte_svelte_type_style_lang="",FancyCheckboxGroup_svelte_svelte_type_style_lang="";function get_each_context$1y(n1,e1,t1){const r1=n1.slice();return r1[14]=e1[t1],r1[15]=e1,r1[16]=t1,r1}function create_if_block$3J(n1){let e1,t1,r1;return t1=new FancyForm({props:{$$slots:{default:[create_default_slot$55]},$$scope:{ctx:n1}}}),t1.$on("change",n1[10]),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","checkbox-group svelte-2g5wlw"),toggle_class(e1,"has-select-all",n1[1])},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,i1){const a1={};i1&131135&&(a1.$$scope={dirty:i1,ctx:o1}),t1.$set(a1),(!r1||i1&2)&&toggle_class(e1,"has-select-all",o1[1])},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function create_if_block_1$23(n1){let e1,t1,r1;function o1(a1){n1[8](a1)}let i1={text:n1[2],indeterminate:!n1[4]&&!n1[5],compact:!0};return n1[4]!==void 0&&(i1.value=n1[4]),e1=new FancyCheckbox({props:i1}),binding_callbacks.push(()=>bind$2(e1,"value",o1)),e1.$on("change",n1[6]),{c(){create_component(e1.$$.fragment)},m(a1,s1){mount_component(e1,a1,s1),r1=!0},p(a1,s1){const l1={};s1&4&&(l1.text=a1[2]),s1&48&&(l1.indeterminate=!a1[4]&&!a1[5]),!t1&&s1&16&&(t1=!0,l1.value=a1[4],add_flush_callback(()=>t1=!1)),e1.$set(l1)},i(a1){r1||(transition_in(e1.$$.fragment,a1),r1=!0)},o(a1){transition_out(e1.$$.fragment,a1),r1=!1},d(a1){destroy_component(e1,a1)}}}function create_each_block$1y(n1){let e1,t1,r1;function o1(a1){n1[9](a1,n1[16])}let i1={text:n1[14],compact:!0};return n1[3][n1[16]]!==void 0&&(i1.value=n1[3][n1[16]]),e1=new FancyCheckbox({props:i1}),binding_callbacks.push(()=>bind$2(e1,"value",o1)),{c(){create_component(e1.$$.fragment)},m(a1,s1){mount_component(e1,a1,s1),r1=!0},p(a1,s1){n1=a1;const l1={};s1&1&&(l1.text=n1[14]),!t1&&s1&8&&(t1=!0,l1.value=n1[3][n1[16]],add_flush_callback(()=>t1=!1)),e1.$set(l1)},i(a1){r1||(transition_in(e1.$$.fragment,a1),r1=!0)},o(a1){transition_out(e1.$$.fragment,a1),r1=!1},d(a1){destroy_component(e1,a1)}}}function create_default_slot$55(n1){let e1,t1,r1,o1=n1[1]&&create_if_block_1$23(n1),i1=n1[0],a1=[];for(let l1=0;l1<i1.length;l1+=1)a1[l1]=create_each_block$1y(get_each_context$1y(n1,i1,l1));const s1=l1=>transition_out(a1[l1],1,1,()=>{a1[l1]=null});return{c(){o1&&o1.c(),e1=space$1();for(let l1=0;l1<a1.length;l1+=1)a1[l1].c();t1=empty$1()},m(l1,c1){o1&&o1.m(l1,c1),insert$1(l1,e1,c1);for(let u1=0;u1<a1.length;u1+=1)a1[u1].m(l1,c1);insert$1(l1,t1,c1),r1=!0},p(l1,c1){if(l1[1]?o1?(o1.p(l1,c1),c1&2&&transition_in(o1,1)):(o1=create_if_block_1$23(l1),o1.c(),transition_in(o1,1),o1.m(e1.parentNode,e1)):o1&&(group_outros(),transition_out(o1,1,1,()=>{o1=null}),check_outros()),c1&9){i1=l1[0];let u1;for(u1=0;u1<i1.length;u1+=1){const f1=get_each_context$1y(l1,i1,u1);a1[u1]?(a1[u1].p(f1,c1),transition_in(a1[u1],1)):(a1[u1]=create_each_block$1y(f1),a1[u1].c(),transition_in(a1[u1],1),a1[u1].m(t1.parentNode,t1))}for(group_outros(),u1=i1.length;u1<a1.length;u1+=1)s1(u1);check_outros()}},i(l1){if(!r1){transition_in(o1);for(let c1=0;c1<i1.length;c1+=1)transition_in(a1[c1]);r1=!0}},o(l1){transition_out(o1),a1=a1.filter(Boolean);for(let c1=0;c1<a1.length;c1+=1)transition_out(a1[c1]);r1=!1},d(l1){o1&&o1.d(l1),l1&&detach(e1),destroy_each(a1,l1),l1&&detach(t1)}}}function create_fragment$7$(n1){let e1=n1[0]&&Array.isArray(n1[0]),t1,r1,o1=e1&&create_if_block$3J(n1);return{c(){o1&&o1.c(),t1=empty$1()},m(i1,a1){o1&&o1.m(i1,a1),insert$1(i1,t1,a1),r1=!0},p(i1,[a1]){a1&1&&(e1=i1[0]&&Array.isArray(i1[0])),e1?o1?(o1.p(i1,a1),a1&1&&transition_in(o1,1)):(o1=create_if_block$3J(i1),o1.c(),transition_in(o1,1),o1.m(t1.parentNode,t1)):o1&&(group_outros(),transition_out(o1,1,1,()=>{o1=null}),check_outros())},i(i1){r1||(transition_in(o1),r1=!0)},o(i1){transition_out(o1),r1=!1},d(i1){o1&&o1.d(i1),i1&&detach(t1)}}}function instance$8a(n1,e1,t1){let r1,o1,{options:i1=[]}=e1,{selected:a1=[]}=e1,{showSelectAll:s1=!0}=e1,{selectAllText:l1="Select all"}=e1,c1=i1.map(g1=>a1.indexOf(g1)>-1);const u1=createEventDispatcher();function f1(){return Array(i1.length).fill(!0)}function d1(g1){const $1=[];for(let[y1,v1]of Object.entries(g1))v1&&$1.push(i1[y1]);t1(7,a1=$1),u1("change",a1)}function p1(){r1===!0?t1(3,c1=[]):t1(3,c1=f1()),u1("change",a1)}function m1(g1){r1=g1,t1(4,r1),t1(7,a1),t1(0,i1)}function _1(g1,$1){n1.$$.not_equal(c1[$1],g1)&&(c1[$1]=g1,t1(3,c1))}function h1(g1){bubble.call(this,n1,g1)}return n1.$$set=g1=>{"options"in g1&&t1(0,i1=g1.options),"selected"in g1&&t1(7,a1=g1.selected),"showSelectAll"in g1&&t1(1,s1=g1.showSelectAll),"selectAllText"in g1&&t1(2,l1=g1.selectAllText)},n1.$$.update=()=>{n1.$$.dirty&8&&d1(c1),n1.$$.dirty&129&&t1(4,r1=(a1==null?void 0:a1.length)===i1.length),n1.$$.dirty&128&&t1(5,o1=!(a1!=null&&a1.length))},[i1,s1,l1,c1,r1,o1,p1,a1,m1,_1,h1]}class FancyCheckboxGroup extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8a,create_fragment$7$,safe_not_equal,{options:0,selected:7,showSelectAll:1,selectAllText:2})}}const Cookies={Auth:"budibase:auth",CurrentApp:"budibase:currentapp",ReturnUrl:"budibase:returnurl",AccountReturnUrl:"budibase:account:returnurl"},TableNames$1={USERS:"ta_users"},BudibaseRoles={AppUser:"appUser",Developer:"developer",Creator:"creator",Admin:"admin"},BudibaseRoleOptionsOld=[{label:"Developer",value:BudibaseRoles.Developer}],BudibaseRoleOptions=[{label:"Account admin",value:BudibaseRoles.Admin,subtitle:"Has full access to all apps and settings in your account"},{label:"Creator",value:BudibaseRoles.Creator,subtitle:"Can create and edit apps they have access to"},{label:"App user",value:BudibaseRoles.AppUser,subtitle:"Can only use published apps they have access to"}],PlanType={FREE:"free",TEAM:"team",PRO:"pro",BUSINESS:"business",ENTERPRISE:"enterprise"},ApiVersion="1",Roles$1={ADMIN:"ADMIN",POWER:"POWER",BASIC:"BASIC",PUBLIC:"PUBLIC",BUILDER:"BUILDER",CREATOR:"CREATOR"},Themes=[{class:"lightest",name:"Lightest"},{class:"light",name:"Light"},{class:"dark",name:"Dark"},{class:"darkest",name:"Darkest"},{class:"nord",name:"Nord",base:"darkest"},{class:"midnight",name:"Midnight",base:"darkest"}],EventPublishType={ENV_VAR_UPGRADE_PANEL_OPENED:"environment_variable_upgrade_panel_opened"},Constants=Object.freeze(Object.defineProperty({__proto__:null,ApiVersion,BudibaseRoleOptions,BudibaseRoleOptionsOld,BudibaseRoles,Cookies,EventPublishType,Features:Feature,OperatorOptions,PlanType,Roles:Roles$1,SqlNumberTypeRangeMap,TableNames:TableNames$1,Themes},Symbol.toStringTag,{value:"Module"})),buildAnalyticsEndpoints=n1=>({getAnalyticsStatus:async()=>await n1.get({url:"/api/bbtel"}),analyticsPing:async({source:e1,embedded:t1})=>{const r1=Intl.DateTimeFormat().resolvedOptions().timeZone;return await n1.post({url:"/api/bbtel/ping",body:{source:e1,timezone:r1,embedded:t1}})}}),buildAppEndpoints=n1=>({fetchAppPackage:async e1=>await n1.get({url:`/api/applications/${e1}/appPackage`}),saveAppMetadata:async({appId:e1,metadata:t1})=>await n1.put({url:`/api/applications/${e1}`,body:t1}),publishAppChanges:async e1=>await n1.post({url:`/api/applications/${e1}/publish`}),revertAppChanges:async e1=>await n1.post({url:`/api/dev/${e1}/revert`}),updateAppClientVersion:async e1=>await n1.post({url:`/api/applications/${e1}/client/update`}),revertAppClientVersion:async e1=>await n1.post({url:`/api/applications/${e1}/client/revert`}),getAppDeployments:async()=>await n1.get({url:"/api/deployments"}),createApp:async e1=>await n1.post({url:"/api/applications",body:e1,json:!1}),updateAppFromExport:async(e1,t1)=>{const r1=getDevAppID(e1);return await n1.post({url:`/api/applications/${r1}/import`,body:t1,json:!1})},importApps:async e1=>await n1.post({url:"/api/cloud/import",body:e1,json:!1}),unpublishApp:async e1=>await n1.post({url:`/api/applications/${e1}/unpublish`}),deleteApp:async e1=>await n1.delete({url:`/api/applications/${e1}`}),releaseAppLock:async e1=>await n1.delete({url:`/api/dev/${e1}/lock`}),fetchSystemDebugInfo:async()=>await n1.get({url:"/api/debug/diagnostics"}),syncApp:async e1=>await n1.post({url:`/api/applications/${e1}/sync`}),getApps:async()=>await n1.get({url:"/api/applications?status=all"}),fetchComponentLibDefinitions:async e1=>await n1.get({url:`/api/${e1}/components/definitions`}),addSampleData:async e1=>await n1.post({url:`/api/applications/${e1}/sample`})}),buildAttachmentEndpoints=n1=>{const e1=async({datasourceId:t1,bucket:r1,key:o1})=>await n1.post({url:`/api/attachments/${t1}/url`,body:{bucket:r1,key:o1}});return{getSignedDatasourceURL:e1,uploadAttachment:async({data:t1,tableId:r1})=>await n1.post({url:`/api/attachments/${r1}/upload`,body:t1,json:!1}),uploadBuilderAttachment:async t1=>await n1.post({url:"/api/attachments/process",body:t1,json:!1}),externalUpload:async({datasourceId:t1,bucket:r1,key:o1,data:i1})=>{const{signedUrl:a1,publicUrl:s1}=await e1({datasourceId:t1,bucket:r1,key:o1});return await n1.put({url:a1,body:i1,json:!1,external:!0}),{publicUrl:s1}},deleteAttachments:async({keys:t1,tableId:r1})=>await n1.post({url:`/api/attachments/${r1}/delete`,body:{keys:t1}}),deleteBuilderAttachments:async t1=>await n1.post({url:"/api/attachments/delete",body:{keys:t1}})}},buildAuthEndpoints=n1=>({logIn:async({tenantId:e1,username:t1,password:r1})=>await n1.post({url:`/api/global/auth/${e1}/login`,body:{username:t1,password:r1}}),logOut:async()=>await n1.post({url:"/api/global/auth/logout"}),setInitInfo:async e1=>await n1.post({url:"/api/global/auth/init",body:e1}),getInitInfo:async()=>await n1.get({url:"/api/global/auth/init"}),requestForgotPassword:async({tenantId:e1,email:t1})=>await n1.post({url:`/api/global/auth/${e1}/reset`,body:{email:t1}}),resetPassword:async({tenantId:e1,password:t1,resetCode:r1})=>await n1.post({url:`/api/global/auth/${e1}/reset/update`,body:{password:t1,resetCode:r1}})}),buildAutomationEndpoints=n1=>({triggerAutomation:async({automationId:e1,fields:t1,timeout:r1})=>await n1.post({url:`/api/automations/${e1}/trigger`,body:{fields:t1,timeout:r1}}),testAutomation:async({automationId:e1,testData:t1})=>await n1.post({url:`/api/automations/${e1}/test`,body:t1}),getAutomations:async()=>await n1.get({url:"/api/automations"}),getAutomationDefinitions:async()=>await n1.get({url:"/api/automations/definitions/list"}),createAutomation:async e1=>await n1.post({url:"/api/automations",body:e1}),updateAutomation:async e1=>await n1.put({url:"/api/automations",body:e1}),deleteAutomation:async({automationId:e1,automationRev:t1})=>await n1.delete({url:`/api/automations/${e1}/${t1}`}),getAutomationLogs:async({automationId:e1,startDate:t1,status:r1,page:o1})=>await n1.post({url:"/api/automations/logs/search",body:{automationId:e1,startDate:t1,status:r1,page:o1}}),clearAutomationLogErrors:async({automationId:e1,appId:t1})=>await n1.delete({url:"/api/automations/logs",body:{appId:t1,automationId:e1}})}),buildConfigEndpoints=n1=>({saveConfig:async e1=>await n1.post({url:"/api/global/configs",body:e1}),getConfig:async e1=>await n1.get({url:`/api/global/configs/${e1}`}),deleteConfig:async({id:e1,rev:t1})=>await n1.delete({url:`/api/global/configs/${e1}/${t1}`}),getTenantConfig:async e1=>await n1.get({url:`/api/global/configs/public?tenantId=${e1}`}),getOIDCConfig:async e1=>await n1.get({url:`/api/global/configs/public/oidc?tenantId=${e1}`}),getChecklist:async e1=>await n1.get({url:`/api/global/configs/checklist?tenantId=${e1}`}),uploadLogo:async e1=>await n1.post({url:"/api/global/configs/upload/settings/logoUrl",body:e1,json:!1}),uploadFavicon:async e1=>await n1.post({url:"/api/global/configs/upload/settings/faviconUrl",body:e1,json:!1}),uploadOIDCLogo:async({name:e1,data:t1})=>await n1.post({url:`/api/global/configs/upload/logos_oidc/${e1}`,body:t1,json:!1}),getOIDCLogos:async()=>await n1.get({url:"/api/global/configs/logos_oidc"})}),buildDatasourceEndpoints=n1=>({getDatasources:async()=>await n1.get({url:"/api/datasources"}),buildDatasourceSchema:async({datasourceId:e1,tablesFilter:t1})=>await n1.post({url:`/api/datasources/${e1}/schema`,body:{tablesFilter:t1}}),createDatasource:async({datasource:e1,fetchSchema:t1,tablesFilter:r1})=>await n1.post({url:"/api/datasources",body:{datasource:e1,fetchSchema:t1,tablesFilter:r1}}),updateDatasource:async e1=>await n1.put({url:`/api/datasources/${e1._id}`,body:e1}),deleteDatasource:async({datasourceId:e1,datasourceRev:t1})=>await n1.delete({url:`/api/datasources/${e1}/${t1}`}),validateDatasource:async e1=>await n1.post({url:"/api/datasources/verify",body:{datasource:e1}}),fetchInfoForDatasource:async e1=>await n1.post({url:"/api/datasources/info",body:{datasource:e1}}),fetchExternalSchema:async e1=>await n1.get({url:`/api/datasources/${e1}/schema/external`})}),buildFlagEndpoints=n1=>({getFlags:async()=>await n1.get({url:"/api/users/flags"}),updateFlag:async({flag:e1,value:t1})=>await n1.post({url:"/api/users/flags",body:{flag:e1,value:t1}}),toggleUiFeature:async({value:e1})=>await n1.post({url:`/api/beta/${e1}`})}),buildHostingEndpoints=n1=>({getHostingURLs:async()=>await n1.get({url:"/api/hosting/urls"}),getDeployedApps:async()=>await n1.get({url:"/api/hosting/apps"})}),buildLayoutEndpoints=n1=>({saveLayout:async e1=>await n1.post({url:"/api/layouts",body:e1}),deleteLayout:async({layoutId:e1,layoutRev:t1})=>await n1.delete({url:`/api/layouts/${e1}/${t1}`})}),buildOtherEndpoints=n1=>({getEnvironment:async()=>await n1.get({url:"/api/system/environment"}),getSystemStatus:async()=>await n1.get({url:"/api/system/status"}),getIntegrations:async()=>await n1.get({url:"/api/integrations"}),getBudibaseVersion:async()=>(await n1.get({url:"/api/dev/version"})).version,getBasePermissions:async()=>await n1.get({url:"/api/permission/builtin"}),checkBetaAccess:async e1=>await n1.get({url:`/api/beta/access?email=${e1}`,external:!0})}),buildPermissionsEndpoints=n1=>({getPermissionForResource:async e1=>await n1.get({url:`/api/permission/${e1}`}),updatePermissionForResource:async({resourceId:e1,roleId:t1,level:r1})=>await n1.post({url:`/api/permission/${t1}/${e1}/${r1}`}),removePermissionFromResource:async({resourceId:e1,roleId:t1,level:r1})=>await n1.delete({url:`/api/permission/${t1}/${e1}/${r1}`}),getDependants:async e1=>await n1.get({url:`/api/permission/${e1}/dependants`})}),buildQueryEndpoints=n1=>({executeQuery:async({queryId:e1,pagination:t1,parameters:r1})=>await n1.post({url:`/api/v2/queries/${e1}`,body:{parameters:r1,pagination:t1}}),fetchQueryDefinition:async e1=>await n1.get({url:`/api/queries/${e1}`,cache:!0}),getQueries:async()=>await n1.get({url:"/api/queries"}),saveQuery:async e1=>await n1.post({url:"/api/queries",body:e1}),deleteQuery:async({queryId:e1,queryRev:t1})=>await n1.delete({url:`/api/queries/${e1}/${t1}`}),importQueries:async({datasourceId:e1,data:t1})=>await n1.post({url:"/api/queries/import",body:{datasourceId:e1,data:t1}}),previewQuery:async e1=>await n1.post({url:"/api/queries/preview",body:e1})}),buildRelationshipEndpoints=n1=>({fetchRelationshipData:async({tableId:e1,rowId:t1,fieldName:r1})=>{if(!e1||!t1)return[];const o1=await n1.get({url:`/api/${e1}/${t1}/enrich?field=${r1}`});return r1?o1[r1]||[]:o1||[]}}),buildRoleEndpoints=n1=>({deleteRole:async({roleId:e1,roleRev:t1})=>await n1.delete({url:`/api/roles/${e1}/${t1}`}),saveRole:async e1=>await n1.post({url:"/api/roles",body:e1}),getRoles:async()=>await n1.get({url:"/api/roles"}),getRolesForApp:async e1=>await n1.get({url:`/api/global/roles/${e1}`}),getAccessibleRoles:async()=>await n1.get({url:"/api/roles/accessible"})}),buildRouteEndpoints=n1=>({fetchClientAppRoutes:async()=>await n1.get({url:"/api/routing/client"}),fetchAppRoutes:async()=>await n1.get({url:"/api/routing"})}),buildRowEndpoints=n1=>({fetchRow:async({tableId:e1,rowId:t1})=>!e1||!t1?null:await n1.get({url:`/api/${e1}/rows/${t1}`}),saveRow:async(e1,t1=!1)=>{if(e1!=null&&e1.tableId)return await n1.post({url:`/api/${e1._viewId||e1.tableId}/rows`,body:e1,suppressErrors:t1})},patchRow:async(e1,t1=!1)=>{if(!(!(e1!=null&&e1.tableId)&&!(e1!=null&&e1._viewId)))return await n1.patch({url:`/api/${e1._viewId||e1.tableId}/rows`,body:e1,suppressErrors:t1})},deleteRow:async({tableId:e1,rowId:t1,revId:r1})=>{if(!(!e1||!t1))return await n1.delete({url:`/api/${e1}/rows`,body:{_id:t1,_rev:r1}})},deleteRows:async({tableId:e1,rows:t1})=>(t1==null||t1.forEach(r1=>{r1==null||delete r1._viewId}),await n1.delete({url:`/api/${e1}/rows`,body:{rows:t1}})),exportRows:async({tableId:e1,rows:t1,format:r1,columns:o1,search:i1})=>await n1.post({url:`/api/${e1}/rows/exportRows?format=${r1}`,body:{rows:t1,columns:o1,...i1},parseResponse:async a1=>await a1.text()})}),buildScreenEndpoints=n1=>({saveScreen:async e1=>await n1.post({url:"/api/screens",body:e1}),deleteScreen:async({screenId:e1,screenRev:t1})=>await n1.delete({url:`/api/screens/${e1}/${t1}`})}),buildTableEndpoints=n1=>({fetchTableDefinition:async e1=>await n1.get({url:`/api/tables/${e1}`,cache:!0}),fetchTableData:async e1=>await n1.get({url:`/api/${e1}/rows`}),searchTable:async({tableId:e1,query:t1,bookmark:r1,limit:o1,sort:i1,sortOrder:a1,sortType:s1,paginate:l1})=>!e1||!t1?{rows:[]}:await n1.post({url:`/api/${e1}/search`,body:{query:t1,bookmark:r1,limit:o1,sort:i1,sortOrder:a1,sortType:s1,paginate:l1}}),importTableData:async({tableId:e1,rows:t1,identifierFields:r1})=>await n1.post({url:`/api/tables/${e1}/import`,body:{rows:t1,identifierFields:r1}}),csvToJson:async e1=>await n1.post({url:"/api/convert/csvToJson",body:{csvString:e1}}),getTables:async()=>await n1.get({url:"/api/tables"}),getTable:async e1=>await n1.get({url:`/api/tables/${e1}`}),saveTable:async e1=>await n1.post({url:"/api/tables",body:e1}),deleteTable:async({tableId:e1,tableRev:t1})=>await n1.delete({url:`/api/tables/${e1}/${t1}`}),validateNewTableImport:async({rows:e1,schema:t1})=>await n1.post({url:"/api/tables/validateNewTableImport",body:{rows:e1,schema:t1}}),validateExistingTableImport:async({rows:e1,tableId:t1})=>await n1.post({url:"/api/tables/validateExistingTableImport",body:{rows:e1,tableId:t1}}),migrateColumn:async({tableId:e1,oldColumn:t1,newColumn:r1})=>await n1.post({url:`/api/tables/${e1}/migrate`,body:{oldColumn:t1,newColumn:r1}})}),buildTemplateEndpoints=n1=>({getEmailTemplateDefinitions:async()=>await n1.get({url:"/api/global/template/definitions"}),getEmailTemplates:async()=>await n1.get({url:"/api/global/template/email"}),saveEmailTemplate:async e1=>await n1.post({url:"/api/global/template",body:e1}),getAppTemplates:async()=>await n1.get({url:"/api/templates"})}),buildUserEndpoints=n1=>({getUsers:async()=>await n1.get({url:"/api/global/users"}),searchUsers:async({paginate:e1,bookmark:t1,query:r1,appId:o1,limit:i1}={})=>{const a1={};return t1&&(a1.bookmark=t1),r1&&(a1.query=r1),o1&&(a1.appId=o1),typeof e1=="boolean"&&(a1.paginate=e1),i1&&(a1.limit=i1),await n1.post({url:"/api/global/users/search",body:a1})},getUser:async e1=>await n1.get({url:`/api/global/users/${e1}`}),createAppUser:async e1=>await n1.post({url:"/api/users/metadata",body:e1}),updateOwnMetadata:async e1=>await n1.post({url:"/api/users/metadata/self",body:e1}),createAdminUser:async e1=>await n1.post({url:"/api/global/users/init",body:e1}),saveUser:async e1=>await n1.post({url:"/api/global/users",body:e1}),createUsers:async({users:e1,groups:t1})=>(await n1.post({url:"/api/global/users/bulk",body:{create:{users:e1,groups:t1}}})).created,deleteUser:async e1=>await n1.delete({url:`/api/global/users/${e1}`}),deleteUsers:async e1=>(await n1.post({url:"/api/global/users/bulk",body:{delete:{userIds:e1}}})).deleted,inviteUser:async({email:e1,builder:t1,admin:r1,apps:o1})=>await n1.post({url:"/api/global/users/invite",body:{email:e1,userInfo:{admin:r1!=null&&r1.global?{global:!0}:void 0,builder:t1!=null&&t1.global?{global:!0}:void 0,apps:o1||void 0}}}),onboardUsers:async e1=>await n1.post({url:"/api/global/users/onboard",body:e1.map(t1=>{const{email:r1,admin:o1,builder:i1,apps:a1}=t1;return{email:r1,userInfo:{admin:o1,builder:i1,apps:a1||void 0}}})}),updateUserInvite:async e1=>{await n1.post({url:`/api/global/users/invite/update/${e1.code}`,body:{apps:e1.apps,builder:e1.builder}})},getUserInvite:async e1=>await n1.get({url:`/api/global/users/invite/${e1}`}),getUserInvites:async()=>await n1.get({url:"/api/global/users/invites"}),inviteUsers:async e1=>await n1.post({url:"/api/global/users/multi/invite",body:e1.map(t1=>{let r1;return t1.admin||t1.builder?r1={global:!0}:t1.creator&&(r1={creator:!0}),{email:t1.email,userInfo:{admin:t1.admin?{global:!0}:void 0,builder:r1,userGroups:t1.groups,roles:t1.apps?t1.apps:void 0}}})}),acceptInvite:async({inviteCode:e1,password:t1,firstName:r1,lastName:o1})=>await n1.post({url:"/api/global/users/invite/accept",body:{inviteCode:e1,password:t1,firstName:r1,lastName:o1}}),getUserCountByApp:async({appId:e1})=>await n1.get({url:`/api/global/users/count/${e1}`}),addAppBuilder:async({userId:e1,appId:t1})=>await n1.post({url:`/api/global/users/${e1}/app/${t1}/builder`}),removeAppBuilder:async({userId:e1,appId:t1})=>await n1.delete({url:`/api/global/users/${e1}/app/${t1}/builder`})}),buildSelfEndpoints=n1=>({generateAPIKey:async()=>{const e1=await n1.post({url:"/api/global/self/api_key"});return e1==null?void 0:e1.apiKey},fetchDeveloperInfo:async()=>n1.get({url:"/api/global/self/api_key"}),fetchSelf:async()=>await n1.get({url:"/api/self"}),fetchBuilderSelf:async()=>await n1.get({url:"/api/global/self"}),updateSelf:async e1=>await n1.post({url:"/api/global/self",body:e1})}),buildViewEndpoints=n1=>({fetchViewData:async({name:e1,field:t1,groupBy:r1,calculation:o1})=>{const i1=new URLSearchParams;o1&&(i1.set("field",t1),i1.set("calculation",o1)),r1&&i1.set("group",r1);const a1=t1?`/api/views/${encodeURIComponent(e1)}?${i1}`:`/api/views/${encodeURIComponent(e1)}`;return await n1.get({url:a1})},exportView:async({viewName:e1,format:t1})=>{const r1=encodeURIComponent(e1);return await n1.get({url:`/api/views/export?view=${r1}&format=${t1}`,parseResponse:async o1=>await o1.text()})},saveView:async e1=>await n1.post({url:"/api/views",body:e1}),deleteView:async e1=>await n1.delete({url:`/api/views/${encodeURIComponent(e1)}`})}),buildViewV2Endpoints=n1=>({fetchDefinition:async e1=>await n1.get({url:`/api/v2/views/${encodeURIComponent(e1)}`}),create:async e1=>await n1.post({url:"/api/v2/views",body:e1}),update:async e1=>await n1.put({url:`/api/v2/views/${encodeURIComponent(e1.id)}`,body:e1}),fetch:async({viewId:e1,query:t1,paginate:r1,limit:o1,bookmark:i1,sort:a1,sortOrder:s1,sortType:l1})=>await n1.post({url:`/api/v2/views/${encodeURIComponent(e1)}/search`,body:{query:t1,paginate:r1,limit:o1,bookmark:i1,sort:a1,sortOrder:s1,sortType:l1}}),delete:async e1=>await n1.delete({url:`/api/v2/views/${encodeURIComponent(e1)}`})}),buildLicensingEndpoints=n1=>({activateLicenseKey:async e1=>n1.post({url:"/api/global/license/key",body:e1}),deleteLicenseKey:async()=>n1.delete({url:"/api/global/license/key"}),getLicenseKey:async()=>{try{return await n1.get({url:"/api/global/license/key"})}catch(e1){if(e1.status!==404)throw e1}},activateOfflineLicense:async({offlineLicenseToken:e1})=>n1.post({url:"/api/global/license/offline",body:{offlineLicenseToken:e1}}),deleteOfflineLicense:async()=>n1.delete({url:"/api/global/license/offline"}),getOfflineLicense:async()=>{try{return await n1.get({url:"/api/global/license/offline"})}catch(e1){if(e1.status!==404)throw e1}},getOfflineLicenseIdentifier:async()=>await n1.get({url:"/api/global/license/offline/identifier"}),refreshLicense:async()=>n1.post({url:"/api/global/license/refresh"}),getQuotaUsage:async()=>n1.get({url:"/api/global/license/usage"})}),buildGroupsEndpoints=n1=>{async function e1(t1,r1,o1,i1){return Array.isArray(i1)||(i1=[i1]),await n1.post({url:`/api/global/groups/${t1}/${r1}`,body:{[o1]:i1}})}return{saveGroup:async t1=>await n1.post({url:"/api/global/groups",body:t1}),getGroups:async()=>await n1.get({url:"/api/global/groups"}),getGroup:async t1=>await n1.get({url:`/api/global/groups/${t1}`}),deleteGroup:async({id:t1,rev:r1})=>await n1.delete({url:`/api/global/groups/${t1}/${r1}`}),getGroupUsers:async({id:t1,bookmark:r1,emailSearch:o1})=>{let i1=`/api/global/groups/${t1}/users?`;return r1&&(i1+=`bookmark=${r1}&`),o1&&(i1+=`emailSearch=${o1}&`),await n1.get({url:i1})},addUsersToGroup:async(t1,r1)=>e1(t1,"users","add",r1),removeUsersFromGroup:async(t1,r1)=>e1(t1,"users","remove",r1),addAppsToGroup:async(t1,r1)=>e1(t1,"apps","add",r1),removeAppsFromGroup:async(t1,r1)=>e1(t1,"apps","remove",r1),addGroupAppBuilder:async({groupId:t1,appId:r1})=>await n1.post({url:`/api/global/groups/${t1}/app/${r1}/builder`}),removeGroupAppBuilder:async({groupId:t1,appId:r1})=>await n1.delete({url:`/api/global/groups/${t1}/app/${r1}/builder`})}},buildPluginEndpoints=n1=>({uploadPlugin:async e1=>await n1.post({url:"/api/plugin/upload",body:e1,json:!1}),createPlugin:async e1=>await n1.post({url:"/api/plugin",body:e1}),getPlugins:async()=>await n1.get({url:"/api/plugin"}),deletePlugin:async e1=>await n1.delete({url:`/api/plugin/${e1}`})}),buildBackupsEndpoints=n1=>({searchBackups:async({appId:e1,trigger:t1,type:r1,page:o1,startDate:i1,endDate:a1})=>{const s1={};return o1&&(s1.page=o1),t1&&r1&&(s1.trigger=t1.toLowerCase(),s1.type=r1.toLowerCase()),i1&&a1&&(s1.startDate=i1,s1.endDate=a1),await n1.post({url:`/api/apps/${e1}/backups/search`,body:s1})},createManualBackup:async({appId:e1})=>await n1.post({url:`/api/apps/${e1}/backups`}),deleteBackup:async({appId:e1,backupId:t1})=>await n1.delete({url:`/api/apps/${e1}/backups/${t1}`}),updateBackup:async({appId:e1,backupId:t1,name:r1})=>await n1.patch({url:`/api/apps/${e1}/backups/${t1}`,body:{name:r1}}),restoreBackup:async({appId:e1,backupId:t1,name:r1})=>await n1.post({url:`/api/apps/${e1}/backups/${t1}/import`,body:{name:r1}})}),buildEnvironmentVariableEndpoints=n1=>({checkEnvironmentVariableStatus:async()=>await n1.get({url:"/api/env/variables/status"}),fetchEnvironmentVariables:async()=>await n1.get({url:"/api/env/variables",json:!1}),createEnvironmentVariable:async e1=>await n1.post({url:"/api/env/variables",body:e1}),deleteEnvironmentVariable:async e1=>await n1.delete({url:`/api/env/variables/${e1}`}),updateEnvironmentVariable:async e1=>await n1.patch({url:`/api/env/variables/${e1.name}`,body:e1})}),buildEventEndpoints=n1=>({publishEvent:async e1=>await n1.post({url:"/api/global/event/publish",body:{type:e1}})}),buildOpts=({bookmark:n1,userIds:e1,appIds:t1,startDate:r1,endDate:o1,fullSearch:i1,events:a1})=>{const s1={};return n1&&(s1.bookmark=n1),r1&&o1?(s1.startDate=r1,s1.endDate=o1):r1&&!o1&&(s1.startDate=r1),i1&&(s1.fullSearch=i1),a1.length&&(s1.events=a1),e1.length&&(s1.userIds=e1),t1.length&&(s1.appIds=t1),s1},buildAuditLogsEndpoints=n1=>({searchAuditLogs:async e1=>await n1.post({url:"/api/global/auditlogs/search",body:buildOpts(e1)}),getEventDefinitions:async()=>await n1.get({url:"/api/global/auditlogs/definitions"}),getDownloadUrl:e1=>`/api/global/auditlogs/download?query=${encodeURIComponent(JSON.stringify(e1))}`}),buildLogsEndpoints=n1=>({getSystemLogs:async()=>await n1.get({url:"/api/system/logs",json:!1,parseResponse:async e1=>e1})}),APISessionID=uuid(),defaultAPIClientConfig={enableCaching:!1,attachHeaders:null,onError:null},createAPIClient=n1=>{n1={...defaultAPIClientConfig,...n1};let e1={};const t1=async(l1,c1,u1=!1)=>{let f1=l1.statusText,d1=null;try{d1=await l1.json(),d1!=null&&d1.message?f1=d1.message:d1!=null&&d1.error&&(f1=d1.error)}catch{}return{message:f1,json:d1,status:l1.status,url:l1.url,method:c1,handled:!0,suppressErrors:u1}},r1=(l1,c1)=>({message:l1,json:null,status:400,url:c1==null?void 0:c1.url,method:c1==null?void 0:c1.method,handled:!0}),o1=async({method:l1,url:c1,body:u1,json:f1=!0,external:d1=!1,parseResponse:p1,suppressErrors:m1=!1})=>{f1=f1&&l1!=="GET";let _1={Accept:"application/json"};_1["x-budibase-session-id"]=APISessionID,d1||(_1["x-budibase-api-version"]=ApiVersion),f1&&(_1["Content-Type"]="application/json"),n1!=null&&n1.attachHeaders&&n1.attachHeaders(_1);let h1=u1;if(f1)try{h1=JSON.stringify(u1)}catch{throw r1("Invalid JSON body",{url:c1,method:l1})}let g1;try{g1=await fetch(c1,{method:l1,headers:_1,body:h1,credentials:"same-origin"})}catch{throw delete e1[c1],r1("Failed to send request",{url:c1,method:l1})}if(g1.status>=200&&g1.status<400)try{return p1?await p1(g1):await g1.json()}catch{return delete e1[c1],null}else throw delete e1[c1],await t1(g1,l1,m1)},i1=async l1=>{const c1=l1.url;return c1?(e1[c1]||(e1[c1]=o1(l1),e1[c1]=await e1[c1]),await e1[c1]):null},a1=l1=>async c1=>{try{let{url:u1,cache:f1=!1,external:d1=!1}=c1;d1||(u1=`/${u1}`.replace("//","/"));const m1=f1&&(n1==null?void 0:n1.enableCaching)?i1:o1,_1={...c1,method:l1,url:u1};return await m1(_1)}catch(u1){throw n1!=null&&n1.onError&&n1.onError(u1),u1}};let s1={post:a1("POST"),get:a1("GET"),patch:a1("PATCH"),delete:a1("DELETE"),put:a1("PUT"),error:l1=>{throw r1(l1)},invalidateCache:()=>{e1={}},getAppID:()=>{let l1={};return n1==null||n1.attachHeaders(l1),l1==null?void 0:l1["x-budibase-app-id"]}};return{...s1,...buildAnalyticsEndpoints(s1),...buildAppEndpoints(s1),...buildAttachmentEndpoints(s1),...buildAuthEndpoints(s1),...buildAutomationEndpoints(s1),...buildConfigEndpoints(s1),...buildDatasourceEndpoints(s1),...buildFlagEndpoints(s1),...buildHostingEndpoints(s1),...buildLayoutEndpoints(s1),...buildOtherEndpoints(s1),...buildPermissionsEndpoints(s1),...buildQueryEndpoints(s1),...buildRelationshipEndpoints(s1),...buildRoleEndpoints(s1),...buildRouteEndpoints(s1),...buildRowEndpoints(s1),...buildScreenEndpoints(s1),...buildTableEndpoints(s1),...buildTemplateEndpoints(s1),...buildUserEndpoints(s1),...buildViewEndpoints(s1),...buildSelfEndpoints(s1),...buildLicensingEndpoints(s1),...buildGroupsEndpoints(s1),...buildPluginEndpoints(s1),...buildBackupsEndpoints(s1),...buildEnvironmentVariableEndpoints(s1),...buildEventEndpoints(s1),...buildAuditLogsEndpoints(s1),...buildLogsEndpoints(s1),viewV2:buildViewV2Endpoints(s1)}},getJSONArrayDatasourceSchema=(n1,e1)=>{let t1=n1,r1=[];e1.prefixKeys&&(r1=e1.prefixKeys.concat(["schema"])),r1=r1.concat(e1.label.split(".").slice(2));for(let o1=0;o1<r1.length;o1++)t1=t1==null?void 0:t1[r1[o1]],t1!=null&&t1.schema&&(t1=t1.schema);return convertJSONSchemaToTableSchema(t1,{squashObjects:!0,prefixKeys:r1})},convertJSONSchemaToTableSchema=(n1,e1)=>{if(!n1)return null;e1={squashObjects:!1,prefixKeys:null,...e1},n1.schema?n1=n1.schema:n1={value:n1};const t1=extractJSONSchemaKeys(n1,e1.squashObjects);let r1={};return t1.forEach(({key:o1,type:i1})=>{r1[o1]={type:i1,name:o1,prefixKeys:e1.prefixKeys}}),r1},extractJSONSchemaKeys=(n1,e1=!1)=>{if(!n1||!Object.keys(n1).length)return[];let t1=[];return Object.keys(n1).forEach(r1=>{const o1=n1[r1].type;if(o1==="json"&&e1){const i1=extractJSONSchemaKeys(n1[r1].schema,e1);t1=t1.concat(i1.map(a1=>({key:`${r1}.${a1.key}`,type:a1.type})))}else t1.push({key:r1,type:o1==="array"?"jsonarray":o1})}),t1};function setCookie(n1,e1){getCookie(n1)&&removeCookie(n1),window.document.cookie=`${n1}=${e1}; Path=/;`}function getCookie(n1){const t1=`; ${document.cookie}`.split(`; ${n1}=`);if(t1.length===2)return t1[1].split(";").shift()}function removeCookie(n1){getCookie(n1)&&(document.cookie=`${n1}=; Max-Age=-99999999; Path=/;`)}const RolePriorities={[Roles$1.ADMIN]:5,[Roles$1.CREATOR]:4,[Roles$1.POWER]:3,[Roles$1.BASIC]:2,[Roles$1.PUBLIC]:1},RoleColours={[Roles$1.ADMIN]:"var(--spectrum-global-color-static-red-400)",[Roles$1.CREATOR]:"var(--spectrum-global-color-static-magenta-600)",[Roles$1.POWER]:"var(--spectrum-global-color-static-orange-400)",[Roles$1.BASIC]:"var(--spectrum-global-color-static-green-400)",[Roles$1.PUBLIC]:"var(--spectrum-global-color-static-blue-400)"},getRolePriority=n1=>RolePriorities[n1]??0,getRoleColour=n1=>RoleColours[n1]??"var(--spectrum-global-color-static-magenta-400)",sequential=n1=>{let e1=[];return(...t1)=>new Promise((r1,o1)=>{e1.push(async()=>{let i1,a1;try{i1=await n1(...t1)}catch(s1){a1=s1}e1.shift(),e1.length&&e1[0](),a1?o1(a1):r1(i1)}),e1.length===1&&e1[0]()})},debounce=(n1,e1=1e3)=>{let t1;return async(...r1)=>new Promise(o1=>{t1&&clearTimeout(t1),t1=setTimeout(async()=>{o1(await n1(...r1))},e1)})},domDebounce=n1=>{let e1=!1,t1;return(...r1)=>{t1=r1,e1||(e1=!0,requestAnimationFrame(()=>{n1(...t1),e1=!1}))}},buildDynamicButtonConfig=n1=>{const{_id:e1,actionType:t1,dataSource:r1,notificationOverride:o1,actionUrl:i1,showDeleteButton:a1,deleteButtonLabel:s1,showSaveButton:l1,saveButtonLabel:c1}=n1||{};if(!e1){console.log("MISSING ID");return}const u1=`${e1}-form`,f1=`${e1}-repeater`,d1=r1==null?void 0:r1.resourceId,p1=a1===!1?"":s1==null?void 0:s1.trim(),m1=l1===!1?"":c1==null?void 0:c1.trim(),_1=[{"##eventHandlerType":"Validate Form",parameters:{componentId:u1}},{"##eventHandlerType":"Save Row",parameters:{providerId:u1,tableId:d1,notificationOverride:o1}},{"##eventHandlerType":"Close Screen Modal"},{"##eventHandlerType":"Close Side Panel"},...t1!=="Create"?[]:[{"##eventHandlerType":"Clear Form",parameters:{componentId:u1}}],...i1?[{"##eventHandlerType":"Navigate To",parameters:{url:i1}}]:[]],h1=[{"##eventHandlerType":"Delete Row",parameters:{confirm:!0,tableId:d1,rowId:`{{ ${jh(f1)}.${jh("_id")} }}`,revId:`{{ ${jh(f1)}.${jh("_rev")} }}`,notificationOverride:o1}},{"##eventHandlerType":"Close Screen Modal"},{"##eventHandlerType":"Close Side Panel"},...i1?[{"##eventHandlerType":"Navigate To",parameters:{url:i1}}]:[]],g1=[];return["Update","Create"].includes(t1)&&l1!==!1&&g1.push({text:m1||"Save",_id:uuid(),_component:"@budibase/standard-components/button",onClick:_1,type:"cta"}),t1=="Update"&&a1!==!1&&g1.push({text:p1||"Delete",_id:uuid(),_component:"@budibase/standard-components/button",onClick:h1,quiet:!0,type:"secondary"}),g1},memo=n1=>{const e1=writable(n1),t1=(r1,o1)=>{if(o1===r1)return;const i1=JSON.stringify(o1),a1=JSON.stringify(r1);i1!==a1&&e1.set(r1)};return{subscribe:e1.subscribe,set:r1=>{const o1=get_store_value(e1);t1(r1,o1)},update:r1=>{const o1=get_store_value(e1);let i1=JSON.parse(JSON.stringify(o1));const a1=r1(i1);t1(a1,o1)}}},derivedMemo=(n1,e1)=>{const t1=derived(n1,e1),r1=memo(get_store_value(t1));return t1.subscribe(r1.set),r1},PACKET_TYPES=Object.create(null);PACKET_TYPES.open="0";PACKET_TYPES.close="1";PACKET_TYPES.ping="2";PACKET_TYPES.pong="3";PACKET_TYPES.message="4";PACKET_TYPES.upgrade="5";PACKET_TYPES.noop="6";const PACKET_TYPES_REVERSE=Object.create(null);Object.keys(PACKET_TYPES).forEach(n1=>{PACKET_TYPES_REVERSE[PACKET_TYPES[n1]]=n1});const ERROR_PACKET={type:"error",data:"parser error"},withNativeBlob$1=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",withNativeArrayBuffer$2=typeof ArrayBuffer=="function",isView$1=n1=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n1):n1&&n1.buffer instanceof ArrayBuffer,encodePacket=({type:n1,data:e1},t1,r1)=>withNativeBlob$1&&e1 instanceof Blob?t1?r1(e1):encodeBlobAsBase64(e1,r1):withNativeArrayBuffer$2&&(e1 instanceof ArrayBuffer||isView$1(e1))?t1?r1(e1):encodeBlobAsBase64(new Blob([e1]),r1):r1(PACKET_TYPES[n1]+(e1||"")),encodeBlobAsBase64=(n1,e1)=>{const t1=new FileReader;return t1.onload=function(){const r1=t1.result.split(",")[1];e1("b"+(r1||""))},t1.readAsDataURL(n1)},chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lookup$1=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n1=0;n1<chars.length;n1++)lookup$1[chars.charCodeAt(n1)]=n1;const decode$3=n1=>{let e1=n1.length*.75,t1=n1.length,r1,o1=0,i1,a1,s1,l1;n1[n1.length-1]==="="&&(e1--,n1[n1.length-2]==="="&&e1--);const c1=new ArrayBuffer(e1),u1=new Uint8Array(c1);for(r1=0;r1<t1;r1+=4)i1=lookup$1[n1.charCodeAt(r1)],a1=lookup$1[n1.charCodeAt(r1+1)],s1=lookup$1[n1.charCodeAt(r1+2)],l1=lookup$1[n1.charCodeAt(r1+3)],u1[o1++]=i1<<2|a1>>4,u1[o1++]=(a1&15)<<4|s1>>2,u1[o1++]=(s1&3)<<6|l1&63;return c1},withNativeArrayBuffer$1=typeof ArrayBuffer=="function",decodePacket=(n1,e1)=>{if(typeof n1!="string")return{type:"message",data:mapBinary(n1,e1)};const t1=n1.charAt(0);return t1==="b"?{type:"message",data:decodeBase64Packet(n1.substring(1),e1)}:PACKET_TYPES_REVERSE[t1]?n1.length>1?{type:PACKET_TYPES_REVERSE[t1],data:n1.substring(1)}:{type:PACKET_TYPES_REVERSE[t1]}:ERROR_PACKET},decodeBase64Packet=(n1,e1)=>{if(withNativeArrayBuffer$1){const t1=decode$3(n1);return mapBinary(t1,e1)}else return{base64:!0,data:n1}},mapBinary=(n1,e1)=>{switch(e1){case"blob":return n1 instanceof ArrayBuffer?new Blob([n1]):n1;case"arraybuffer":default:return n1}},SEPARATOR=String.fromCharCode(30),encodePayload=(n1,e1)=>{const t1=n1.length,r1=new Array(t1);let o1=0;n1.forEach((i1,a1)=>{encodePacket(i1,!1,s1=>{r1[a1]=s1,++o1===t1&&e1(r1.join(SEPARATOR))})})},decodePayload=(n1,e1)=>{const t1=n1.split(SEPARATOR),r1=[];for(let o1=0;o1<t1.length;o1++){const i1=decodePacket(t1[o1],e1);if(r1.push(i1),i1.type==="error")break}return r1},protocol$1=4;function Emitter(n1){if(n1)return mixin(n1)}function mixin(n1){for(var e1 in Emitter.prototype)n1[e1]=Emitter.prototype[e1];return n1}Emitter.prototype.on=Emitter.prototype.addEventListener=function(n1,e1){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n1]=this._callbacks["$"+n1]||[]).push(e1),this};Emitter.prototype.once=function(n1,e1){function t1(){this.off(n1,t1),e1.apply(this,arguments)}return t1.fn=e1,this.on(n1,t1),this};Emitter.prototype.off=Emitter.prototype.removeListener=Emitter.prototype.removeAllListeners=Emitter.prototype.removeEventListener=function(n1,e1){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t1=this._callbacks["$"+n1];if(!t1)return this;if(arguments.length==1)return delete this._callbacks["$"+n1],this;for(var r1,o1=0;o1<t1.length;o1++)if(r1=t1[o1],r1===e1||r1.fn===e1){t1.splice(o1,1);break}return t1.length===0&&delete this._callbacks["$"+n1],this};Emitter.prototype.emit=function(n1){this._callbacks=this._callbacks||{};for(var e1=new Array(arguments.length-1),t1=this._callbacks["$"+n1],r1=1;r1<arguments.length;r1++)e1[r1-1]=arguments[r1];if(t1){t1=t1.slice(0);for(var r1=0,o1=t1.length;r1<o1;++r1)t1[r1].apply(this,e1)}return this};Emitter.prototype.emitReserved=Emitter.prototype.emit;Emitter.prototype.listeners=function(n1){return this._callbacks=this._callbacks||{},this._callbacks["$"+n1]||[]};Emitter.prototype.hasListeners=function(n1){return!!this.listeners(n1).length};const globalThisShim=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function pick(n1,...e1){return e1.reduce((t1,r1)=>(n1.hasOwnProperty(r1)&&(t1[r1]=n1[r1]),t1),{})}const NATIVE_SET_TIMEOUT=globalThisShim.setTimeout,NATIVE_CLEAR_TIMEOUT=globalThisShim.clearTimeout;function installTimerFunctions(n1,e1){e1.useNativeTimers?(n1.setTimeoutFn=NATIVE_SET_TIMEOUT.bind(globalThisShim),n1.clearTimeoutFn=NATIVE_CLEAR_TIMEOUT.bind(globalThisShim)):(n1.setTimeoutFn=globalThisShim.setTimeout.bind(globalThisShim),n1.clearTimeoutFn=globalThisShim.clearTimeout.bind(globalThisShim))}const BASE64_OVERHEAD=1.33;function byteLength(n1){return typeof n1=="string"?utf8Length(n1):Math.ceil((n1.byteLength||n1.size)*BASE64_OVERHEAD)}function utf8Length(n1){let e1=0,t1=0;for(let r1=0,o1=n1.length;r1<o1;r1++)e1=n1.charCodeAt(r1),e1<128?t1+=1:e1<2048?t1+=2:e1<55296||e1>=57344?t1+=3:(r1++,t1+=4);return t1}class TransportError extends Error{constructor(e1,t1,r1){super(e1),this.description=t1,this.context=r1,this.type="TransportError"}}class Transport extends Emitter{constructor(e1){super(),this.writable=!1,installTimerFunctions(this,e1),this.opts=e1,this.query=e1.query,this.socket=e1.socket}onError(e1,t1,r1){return super.emitReserved("error",new TransportError(e1,t1,r1)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e1){this.readyState==="open"&&this.write(e1)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e1){const t1=decodePacket(e1,this.socket.binaryType);this.onPacket(t1)}onPacket(e1){super.emitReserved("packet",e1)}onClose(e1){this.readyState="closed",super.emitReserved("close",e1)}pause(e1){}}const alphabet="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),length=64,map={};let seed=0,i$2=0,prev;function encode$3(n1){let e1="";do e1=alphabet[n1%length]+e1,n1=Math.floor(n1/length);while(n1>0);return e1}function yeast(){const n1=encode$3(+new Date);return n1!==prev?(seed=0,prev=n1):n1+"."+encode$3(seed++)}for(;i$2<length;i$2++)map[alphabet[i$2]]=i$2;function encode$2(n1){let e1="";for(let t1 in n1)n1.hasOwnProperty(t1)&&(e1.length&&(e1+="&"),e1+=encodeURIComponent(t1)+"="+encodeURIComponent(n1[t1]));return e1}function decode$2(n1){let e1={},t1=n1.split("&");for(let r1=0,o1=t1.length;r1<o1;r1++){let i1=t1[r1].split("=");e1[decodeURIComponent(i1[0])]=decodeURIComponent(i1[1])}return e1}let value$1=!1;try{value$1=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const hasCORS=value$1;function XHR(n1){const e1=n1.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e1||hasCORS))return new XMLHttpRequest}catch{}if(!e1)try{return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function empty(){}const hasXHR2=function(){return new XHR({xdomain:!1}).responseType!=null}();class Polling extends Transport{constructor(e1){if(super(e1),this.polling=!1,typeof location<"u"){const r1=location.protocol==="https:";let o1=location.port;o1||(o1=r1?"443":"80"),this.xd=typeof location<"u"&&e1.hostname!==location.hostname||o1!==e1.port,this.xs=e1.secure!==r1}const t1=e1&&e1.forceBase64;this.supportsBinary=hasXHR2&&!t1}get name(){return"polling"}doOpen(){this.poll()}pause(e1){this.readyState="pausing";const t1=()=>{this.readyState="paused",e1()};if(this.polling||!this.writable){let r1=0;this.polling&&(r1++,this.once("pollComplete",function(){--r1||t1()})),this.writable||(r1++,this.once("drain",function(){--r1||t1()}))}else t1()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e1){const t1=r1=>{if(this.readyState==="opening"&&r1.type==="open"&&this.onOpen(),r1.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r1)};decodePayload(e1,this.socket.binaryType).forEach(t1),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e1=()=>{this.write([{type:"close"}])};this.readyState==="open"?e1():this.once("open",e1)}write(e1){this.writable=!1,encodePayload(e1,t1=>{this.doWrite(t1,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e1=this.query||{};const t1=this.opts.secure?"https":"http";let r1="";this.opts.timestampRequests!==!1&&(e1[this.opts.timestampParam]=yeast()),!this.supportsBinary&&!e1.sid&&(e1.b64=1),this.opts.port&&(t1==="https"&&Number(this.opts.port)!==443||t1==="http"&&Number(this.opts.port)!==80)&&(r1=":"+this.opts.port);const o1=encode$2(e1),i1=this.opts.hostname.indexOf(":")!==-1;return t1+"://"+(i1?"["+this.opts.hostname+"]":this.opts.hostname)+r1+this.opts.path+(o1.length?"?"+o1:"")}request(e1={}){return Object.assign(e1,{xd:this.xd,xs:this.xs},this.opts),new Request(this.uri(),e1)}doWrite(e1,t1){const r1=this.request({method:"POST",data:e1});r1.on("success",t1),r1.on("error",(o1,i1)=>{this.onError("xhr post error",o1,i1)})}doPoll(){const e1=this.request();e1.on("data",this.onData.bind(this)),e1.on("error",(t1,r1)=>{this.onError("xhr poll error",t1,r1)}),this.pollXhr=e1}}class Request extends Emitter{constructor(e1,t1){super(),installTimerFunctions(this,t1),this.opts=t1,this.method=t1.method||"GET",this.uri=e1,this.async=t1.async!==!1,this.data=t1.data!==void 0?t1.data:null,this.create()}create(){const e1=pick(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e1.xdomain=!!this.opts.xd,e1.xscheme=!!this.opts.xs;const t1=this.xhr=new XHR(e1);try{t1.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t1.setDisableHeaderCheck&&t1.setDisableHeaderCheck(!0);for(let r1 in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r1)&&t1.setRequestHeader(r1,this.opts.extraHeaders[r1])}}catch{}if(this.method==="POST")try{t1.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{t1.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in t1&&(t1.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t1.timeout=this.opts.requestTimeout),t1.onreadystatechange=()=>{t1.readyState===4&&(t1.status===200||t1.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof t1.status=="number"?t1.status:0)},0))},t1.send(this.data)}catch(r1){this.setTimeoutFn(()=>{this.onError(r1)},0);return}typeof document<"u"&&(this.index=Request.requestsCount++,Request.requests[this.index]=this)}onError(e1){this.emitReserved("error",e1,this.xhr),this.cleanup(!0)}cleanup(e1){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=empty,e1)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Request.requests[this.index],this.xhr=null}}onLoad(){const e1=this.xhr.responseText;e1!==null&&(this.emitReserved("data",e1),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}Request.requestsCount=0;Request.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",unloadHandler);else if(typeof addEventListener=="function"){const n1="onpagehide"in globalThisShim?"pagehide":"unload";addEventListener(n1,unloadHandler,!1)}}function unloadHandler(){for(let n1 in Request.requests)Request.requests.hasOwnProperty(n1)&&Request.requests[n1].abort()}const nextTick=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e1=>Promise.resolve().then(e1):(e1,t1)=>t1(e1,0))(),WebSocket=globalThisShim.WebSocket||globalThisShim.MozWebSocket,usingBrowserWebSocket=!0,defaultBinaryType="arraybuffer",isReactNative=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class WS extends Transport{constructor(e1){super(e1),this.supportsBinary=!e1.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e1=this.uri(),t1=this.opts.protocols,r1=isReactNative?{}:pick(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r1.headers=this.opts.extraHeaders);try{this.ws=usingBrowserWebSocket&&!isReactNative?t1?new WebSocket(e1,t1):new WebSocket(e1):new WebSocket(e1,t1,r1)}catch(o1){return this.emitReserved("error",o1)}this.ws.binaryType=this.socket.binaryType||defaultBinaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e1=>this.onClose({description:"websocket connection closed",context:e1}),this.ws.onmessage=e1=>this.onData(e1.data),this.ws.onerror=e1=>this.onError("websocket error",e1)}write(e1){this.writable=!1;for(let t1=0;t1<e1.length;t1++){const r1=e1[t1],o1=t1===e1.length-1;encodePacket(r1,this.supportsBinary,i1=>{const a1={};try{usingBrowserWebSocket&&this.ws.send(i1)}catch{}o1&&nextTick(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e1=this.query||{};const t1=this.opts.secure?"wss":"ws";let r1="";this.opts.port&&(t1==="wss"&&Number(this.opts.port)!==443||t1==="ws"&&Number(this.opts.port)!==80)&&(r1=":"+this.opts.port),this.opts.timestampRequests&&(e1[this.opts.timestampParam]=yeast()),this.supportsBinary||(e1.b64=1);const o1=encode$2(e1),i1=this.opts.hostname.indexOf(":")!==-1;return t1+"://"+(i1?"["+this.opts.hostname+"]":this.opts.hostname)+r1+this.opts.path+(o1.length?"?"+o1:"")}check(){return!!WebSocket}}const transports={websocket:WS,polling:Polling},re$1=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,parts=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function parse$8(n1){const e1=n1,t1=n1.indexOf("["),r1=n1.indexOf("]");t1!=-1&&r1!=-1&&(n1=n1.substring(0,t1)+n1.substring(t1,r1).replace(/:/g,";")+n1.substring(r1,n1.length));let o1=re$1.exec(n1||""),i1={},a1=14;for(;a1--;)i1[parts[a1]]=o1[a1]||"";return t1!=-1&&r1!=-1&&(i1.source=e1,i1.host=i1.host.substring(1,i1.host.length-1).replace(/;/g,":"),i1.authority=i1.authority.replace("[","").replace("]","").replace(/;/g,":"),i1.ipv6uri=!0),i1.pathNames=pathNames(i1,i1.path),i1.queryKey=queryKey(i1,i1.query),i1}function pathNames(n1,e1){const t1=/\/{2,9}/g,r1=e1.replace(t1,"/").split("/");return(e1.slice(0,1)=="/"||e1.length===0)&&r1.splice(0,1),e1.slice(-1)=="/"&&r1.splice(r1.length-1,1),r1}function queryKey(n1,e1){const t1={};return e1.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r1,o1,i1){o1&&(t1[o1]=i1)}),t1}let Socket$1=class wb extends Emitter{constructor(e1,t1={}){super(),this.writeBuffer=[],e1&&typeof e1=="object"&&(t1=e1,e1=null),e1?(e1=parse$8(e1),t1.hostname=e1.host,t1.secure=e1.protocol==="https"||e1.protocol==="wss",t1.port=e1.port,e1.query&&(t1.query=e1.query)):t1.host&&(t1.hostname=parse$8(t1.host).host),installTimerFunctions(this,t1),this.secure=t1.secure!=null?t1.secure:typeof location<"u"&&location.protocol==="https:",t1.hostname&&!t1.port&&(t1.port=this.secure?"443":"80"),this.hostname=t1.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t1.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=t1.transports||["polling","websocket"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},t1),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=decode$2(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e1){const t1=Object.assign({},this.opts.query);t1.EIO=protocol$1,t1.transport=e1,this.id&&(t1.sid=this.id);const r1=Object.assign({},this.opts.transportOptions[e1],this.opts,{query:t1,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new transports[e1](r1)}open(){let e1;if(this.opts.rememberUpgrade&&wb.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e1="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e1=this.transports[0];this.readyState="opening";try{e1=this.createTransport(e1)}catch{this.transports.shift(),this.open();return}e1.open(),this.setTransport(e1)}setTransport(e1){this.transport&&this.transport.removeAllListeners(),this.transport=e1,e1.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t1=>this.onClose("transport close",t1))}probe(e1){let t1=this.createTransport(e1),r1=!1;wb.priorWebsocketSuccess=!1;const o1=()=>{r1||(t1.send([{type:"ping",data:"probe"}]),t1.once("packet",f1=>{if(!r1)if(f1.type==="pong"&&f1.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t1),!t1)return;wb.priorWebsocketSuccess=t1.name==="websocket",this.transport.pause(()=>{r1||this.readyState!=="closed"&&(u1(),this.setTransport(t1),t1.send([{type:"upgrade"}]),this.emitReserved("upgrade",t1),t1=null,this.upgrading=!1,this.flush())})}else{const d1=new Error("probe error");d1.transport=t1.name,this.emitReserved("upgradeError",d1)}}))};function i1(){r1||(r1=!0,u1(),t1.close(),t1=null)}const a1=f1=>{const d1=new Error("probe error: "+f1);d1.transport=t1.name,i1(),this.emitReserved("upgradeError",d1)};function s1(){a1("transport closed")}function l1(){a1("socket closed")}function c1(f1){t1&&f1.name!==t1.name&&i1()}const u1=()=>{t1.removeListener("open",o1),t1.removeListener("error",a1),t1.removeListener("close",s1),this.off("close",l1),this.off("upgrading",c1)};t1.once("open",o1),t1.once("error",a1),t1.once("close",s1),this.once("close",l1),this.once("upgrading",c1),t1.open()}onOpen(){if(this.readyState="open",wb.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e1=0;const t1=this.upgrades.length;for(;e1<t1;e1++)this.probe(this.upgrades[e1])}}onPacket(e1){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e1),this.emitReserved("heartbeat"),e1.type){case"open":this.onHandshake(JSON.parse(e1.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t1=new Error("server error");t1.code=e1.data,this.onError(t1);break;case"message":this.emitReserved("data",e1.data),this.emitReserved("message",e1.data);break}}onHandshake(e1){this.emitReserved("handshake",e1),this.id=e1.sid,this.transport.query.sid=e1.sid,this.upgrades=this.filterUpgrades(e1.upgrades),this.pingInterval=e1.pingInterval,this.pingTimeout=e1.pingTimeout,this.maxPayload=e1.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e1=this.getWritablePackets();this.transport.send(e1),this.prevBufferLen=e1.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t1=1;for(let r1=0;r1<this.writeBuffer.length;r1++){const o1=this.writeBuffer[r1].data;if(o1&&(t1+=byteLength(o1)),r1>0&&t1>this.maxPayload)return this.writeBuffer.slice(0,r1);t1+=2}return this.writeBuffer}write(e1,t1,r1){return this.sendPacket("message",e1,t1,r1),this}send(e1,t1,r1){return this.sendPacket("message",e1,t1,r1),this}sendPacket(e1,t1,r1,o1){if(typeof t1=="function"&&(o1=t1,t1=void 0),typeof r1=="function"&&(o1=r1,r1=null),this.readyState==="closing"||this.readyState==="closed")return;r1=r1||{},r1.compress=r1.compress!==!1;const i1={type:e1,data:t1,options:r1};this.emitReserved("packetCreate",i1),this.writeBuffer.push(i1),o1&&this.once("flush",o1),this.flush()}close(){const e1=()=>{this.onClose("forced close"),this.transport.close()},t1=()=>{this.off("upgrade",t1),this.off("upgradeError",t1),e1()},r1=()=>{this.once("upgrade",t1),this.once("upgradeError",t1)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r1():e1()}):this.upgrading?r1():e1()),this}onError(e1){wb.priorWebsocketSuccess=!1,this.emitReserved("error",e1),this.onClose("transport error",e1)}onClose(e1,t1){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e1,t1),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e1){const t1=[];let r1=0;const o1=e1.length;for(;r1<o1;r1++)~this.transports.indexOf(e1[r1])&&t1.push(e1[r1]);return t1}};Socket$1.protocol=protocol$1;function url$1(n1,e1="",t1){let r1=n1;t1=t1||typeof location<"u"&&location,n1==null&&(n1=t1.protocol+"//"+t1.host),typeof n1=="string"&&(n1.charAt(0)==="/"&&(n1.charAt(1)==="/"?n1=t1.protocol+n1:n1=t1.host+n1),/^(https?|wss?):\/\//.test(n1)||(typeof t1<"u"?n1=t1.protocol+"//"+n1:n1="https://"+n1),r1=parse$8(n1)),r1.port||(/^(http|ws)$/.test(r1.protocol)?r1.port="80":/^(http|ws)s$/.test(r1.protocol)&&(r1.port="443")),r1.path=r1.path||"/";const i1=r1.host.indexOf(":")!==-1?"["+r1.host+"]":r1.host;return r1.id=r1.protocol+"://"+i1+":"+r1.port+e1,r1.href=r1.protocol+"://"+i1+(t1&&t1.port===r1.port?"":":"+r1.port),r1}const withNativeArrayBuffer=typeof ArrayBuffer=="function",isView=n1=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n1):n1.buffer instanceof ArrayBuffer,toString$5=Object.prototype.toString,withNativeBlob=typeof Blob=="function"||typeof Blob<"u"&&toString$5.call(Blob)==="[object BlobConstructor]",withNativeFile=typeof File=="function"||typeof File<"u"&&toString$5.call(File)==="[object FileConstructor]";function isBinary(n1){return withNativeArrayBuffer&&(n1 instanceof ArrayBuffer||isView(n1))||withNativeBlob&&n1 instanceof Blob||withNativeFile&&n1 instanceof File}function hasBinary(n1,e1){if(!n1||typeof n1!="object")return!1;if(Array.isArray(n1)){for(let t1=0,r1=n1.length;t1<r1;t1++)if(hasBinary(n1[t1]))return!0;return!1}if(isBinary(n1))return!0;if(n1.toJSON&&typeof n1.toJSON=="function"&&arguments.length===1)return hasBinary(n1.toJSON(),!0);for(const t1 in n1)if(Object.prototype.hasOwnProperty.call(n1,t1)&&hasBinary(n1[t1]))return!0;return!1}function deconstructPacket(n1){const e1=[],t1=n1.data,r1=n1;return r1.data=_deconstructPacket(t1,e1),r1.attachments=e1.length,{packet:r1,buffers:e1}}function _deconstructPacket(n1,e1){if(!n1)return n1;if(isBinary(n1)){const t1={_placeholder:!0,num:e1.length};return e1.push(n1),t1}else if(Array.isArray(n1)){const t1=new Array(n1.length);for(let r1=0;r1<n1.length;r1++)t1[r1]=_deconstructPacket(n1[r1],e1);return t1}else if(typeof n1=="object"&&!(n1 instanceof Date)){const t1={};for(const r1 in n1)Object.prototype.hasOwnProperty.call(n1,r1)&&(t1[r1]=_deconstructPacket(n1[r1],e1));return t1}return n1}function reconstructPacket(n1,e1){return n1.data=_reconstructPacket(n1.data,e1),delete n1.attachments,n1}function _reconstructPacket(n1,e1){if(!n1)return n1;if(n1&&n1._placeholder===!0){if(typeof n1.num=="number"&&n1.num>=0&&n1.num<e1.length)return e1[n1.num];throw new Error("illegal attachments")}else if(Array.isArray(n1))for(let t1=0;t1<n1.length;t1++)n1[t1]=_reconstructPacket(n1[t1],e1);else if(typeof n1=="object")for(const t1 in n1)Object.prototype.hasOwnProperty.call(n1,t1)&&(n1[t1]=_reconstructPacket(n1[t1],e1));return n1}const protocol=5;var PacketType;(function(n1){n1[n1.CONNECT=0]="CONNECT",n1[n1.DISCONNECT=1]="DISCONNECT",n1[n1.EVENT=2]="EVENT",n1[n1.ACK=3]="ACK",n1[n1.CONNECT_ERROR=4]="CONNECT_ERROR",n1[n1.BINARY_EVENT=5]="BINARY_EVENT",n1[n1.BINARY_ACK=6]="BINARY_ACK"})(PacketType||(PacketType={}));class Encoder{constructor(e1){this.replacer=e1}encode(e1){return(e1.type===PacketType.EVENT||e1.type===PacketType.ACK)&&hasBinary(e1)?this.encodeAsBinary({type:e1.type===PacketType.EVENT?PacketType.BINARY_EVENT:PacketType.BINARY_ACK,nsp:e1.nsp,data:e1.data,id:e1.id}):[this.encodeAsString(e1)]}encodeAsString(e1){let t1=""+e1.type;return(e1.type===PacketType.BINARY_EVENT||e1.type===PacketType.BINARY_ACK)&&(t1+=e1.attachments+"-"),e1.nsp&&e1.nsp!=="/"&&(t1+=e1.nsp+","),e1.id!=null&&(t1+=e1.id),e1.data!=null&&(t1+=JSON.stringify(e1.data,this.replacer)),t1}encodeAsBinary(e1){const t1=deconstructPacket(e1),r1=this.encodeAsString(t1.packet),o1=t1.buffers;return o1.unshift(r1),o1}}class Decoder extends Emitter{constructor(e1){super(),this.reviver=e1}add(e1){let t1;if(typeof e1=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t1=this.decodeString(e1);const r1=t1.type===PacketType.BINARY_EVENT;r1||t1.type===PacketType.BINARY_ACK?(t1.type=r1?PacketType.EVENT:PacketType.ACK,this.reconstructor=new BinaryReconstructor(t1),t1.attachments===0&&super.emitReserved("decoded",t1)):super.emitReserved("decoded",t1)}else if(isBinary(e1)||e1.base64)if(this.reconstructor)t1=this.reconstructor.takeBinaryData(e1),t1&&(this.reconstructor=null,super.emitReserved("decoded",t1));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e1)}decodeString(e1){let t1=0;const r1={type:Number(e1.charAt(0))};if(PacketType[r1.type]===void 0)throw new Error("unknown packet type "+r1.type);if(r1.type===PacketType.BINARY_EVENT||r1.type===PacketType.BINARY_ACK){const i1=t1+1;for(;e1.charAt(++t1)!=="-"&&t1!=e1.length;);const a1=e1.substring(i1,t1);if(a1!=Number(a1)||e1.charAt(t1)!=="-")throw new Error("Illegal attachments");r1.attachments=Number(a1)}if(e1.charAt(t1+1)==="/"){const i1=t1+1;for(;++t1&&!(e1.charAt(t1)===","||t1===e1.length););r1.nsp=e1.substring(i1,t1)}else r1.nsp="/";const o1=e1.charAt(t1+1);if(o1!==""&&Number(o1)==o1){const i1=t1+1;for(;++t1;){const a1=e1.charAt(t1);if(a1==null||Number(a1)!=a1){--t1;break}if(t1===e1.length)break}r1.id=Number(e1.substring(i1,t1+1))}if(e1.charAt(++t1)){const i1=this.tryParse(e1.substr(t1));if(Decoder.isPayloadValid(r1.type,i1))r1.data=i1;else throw new Error("invalid payload")}return r1}tryParse(e1){try{return JSON.parse(e1,this.reviver)}catch{return!1}}static isPayloadValid(e1,t1){switch(e1){case PacketType.CONNECT:return typeof t1=="object";case PacketType.DISCONNECT:return t1===void 0;case PacketType.CONNECT_ERROR:return typeof t1=="string"||typeof t1=="object";case PacketType.EVENT:case PacketType.BINARY_EVENT:return Array.isArray(t1)&&(typeof t1[0]=="string"||typeof t1[0]=="number");case PacketType.ACK:case PacketType.BINARY_ACK:return Array.isArray(t1)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class BinaryReconstructor{constructor(e1){this.packet=e1,this.buffers=[],this.reconPack=e1}takeBinaryData(e1){if(this.buffers.push(e1),this.buffers.length===this.reconPack.attachments){const t1=reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t1}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const parser$2=Object.freeze(Object.defineProperty({__proto__:null,Decoder,Encoder,get PacketType(){return PacketType},protocol},Symbol.toStringTag,{value:"Module"}));function on$1(n1,e1,t1){return n1.on(e1,t1),function(){n1.off(e1,t1)}}const RESERVED_EVENTS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Socket extends Emitter{constructor(e1,t1,r1){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e1,this.nsp=t1,r1&&r1.auth&&(this.auth=r1.auth),this._opts=Object.assign({},r1),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e1=this.io;this.subs=[on$1(e1,"open",this.onopen.bind(this)),on$1(e1,"packet",this.onpacket.bind(this)),on$1(e1,"error",this.onerror.bind(this)),on$1(e1,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e1){return e1.unshift("message"),this.emit.apply(this,e1),this}emit(e1,...t1){if(RESERVED_EVENTS.hasOwnProperty(e1))throw new Error('"'+e1.toString()+'" is a reserved event name');if(t1.unshift(e1),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t1),this;const r1={type:PacketType.EVENT,data:t1};if(r1.options={},r1.options.compress=this.flags.compress!==!1,typeof t1[t1.length-1]=="function"){const a1=this.ids++,s1=t1.pop();this._registerAckCallback(a1,s1),r1.id=a1}const o1=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!o1||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r1),this.packet(r1)):this.sendBuffer.push(r1)),this.flags={},this}_registerAckCallback(e1,t1){var r1;const o1=(r1=this.flags.timeout)!==null&&r1!==void 0?r1:this._opts.ackTimeout;if(o1===void 0){this.acks[e1]=t1;return}const i1=this.io.setTimeoutFn(()=>{delete this.acks[e1];for(let a1=0;a1<this.sendBuffer.length;a1++)this.sendBuffer[a1].id===e1&&this.sendBuffer.splice(a1,1);t1.call(this,new Error("operation has timed out"))},o1);this.acks[e1]=(...a1)=>{this.io.clearTimeoutFn(i1),t1.apply(this,[null,...a1])}}emitWithAck(e1,...t1){const r1=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((o1,i1)=>{t1.push((a1,s1)=>r1?a1?i1(a1):o1(s1):o1(a1)),this.emit(e1,...t1)})}_addToQueue(e1){let t1;typeof e1[e1.length-1]=="function"&&(t1=e1.pop());const r1={id:this._queueSeq++,tryCount:0,pending:!1,args:e1,flags:Object.assign({fromQueue:!0},this.flags)};e1.push((o1,...i1)=>r1!==this._queue[0]?void 0:(o1!==null?r1.tryCount>this._opts.retries&&(this._queue.shift(),t1&&t1(o1)):(this._queue.shift(),t1&&t1(null,...i1)),r1.pending=!1,this._drainQueue())),this._queue.push(r1),this._drainQueue()}_drainQueue(e1=!1){if(!this.connected||this._queue.length===0)return;const t1=this._queue[0];t1.pending&&!e1||(t1.pending=!0,t1.tryCount++,this.flags=t1.flags,this.emit.apply(this,t1.args))}packet(e1){e1.nsp=this.nsp,this.io._packet(e1)}onopen(){typeof this.auth=="function"?this.auth(e1=>{this._sendConnectPacket(e1)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e1){this.packet({type:PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e1):e1})}onerror(e1){this.connected||this.emitReserved("connect_error",e1)}onclose(e1,t1){this.connected=!1,delete this.id,this.emitReserved("disconnect",e1,t1)}onpacket(e1){if(e1.nsp===this.nsp)switch(e1.type){case PacketType.CONNECT:e1.data&&e1.data.sid?this.onconnect(e1.data.sid,e1.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case PacketType.EVENT:case PacketType.BINARY_EVENT:this.onevent(e1);break;case PacketType.ACK:case PacketType.BINARY_ACK:this.onack(e1);break;case PacketType.DISCONNECT:this.ondisconnect();break;case PacketType.CONNECT_ERROR:this.destroy();const r1=new Error(e1.data.message);r1.data=e1.data.data,this.emitReserved("connect_error",r1);break}}onevent(e1){const t1=e1.data||[];e1.id!=null&&t1.push(this.ack(e1.id)),this.connected?this.emitEvent(t1):this.receiveBuffer.push(Object.freeze(t1))}emitEvent(e1){if(this._anyListeners&&this._anyListeners.length){const t1=this._anyListeners.slice();for(const r1 of t1)r1.apply(this,e1)}super.emit.apply(this,e1),this._pid&&e1.length&&typeof e1[e1.length-1]=="string"&&(this._lastOffset=e1[e1.length-1])}ack(e1){const t1=this;let r1=!1;return function(...o1){r1||(r1=!0,t1.packet({type:PacketType.ACK,id:e1,data:o1}))}}onack(e1){const t1=this.acks[e1.id];typeof t1=="function"&&(t1.apply(this,e1.data),delete this.acks[e1.id])}onconnect(e1,t1){this.id=e1,this.recovered=t1&&this._pid===t1,this._pid=t1,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e1=>this.emitEvent(e1)),this.receiveBuffer=[],this.sendBuffer.forEach(e1=>{this.notifyOutgoingListeners(e1),this.packet(e1)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e1=>e1()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:PacketType.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e1){return this.flags.compress=e1,this}get volatile(){return this.flags.volatile=!0,this}timeout(e1){return this.flags.timeout=e1,this}onAny(e1){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e1),this}prependAny(e1){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e1),this}offAny(e1){if(!this._anyListeners)return this;if(e1){const t1=this._anyListeners;for(let r1=0;r1<t1.length;r1++)if(e1===t1[r1])return t1.splice(r1,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e1){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e1),this}prependAnyOutgoing(e1){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e1),this}offAnyOutgoing(e1){if(!this._anyOutgoingListeners)return this;if(e1){const t1=this._anyOutgoingListeners;for(let r1=0;r1<t1.length;r1++)if(e1===t1[r1])return t1.splice(r1,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e1){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t1=this._anyOutgoingListeners.slice();for(const r1 of t1)r1.apply(this,e1.data)}}}function Backoff(n1){n1=n1||{},this.ms=n1.min||100,this.max=n1.max||1e4,this.factor=n1.factor||2,this.jitter=n1.jitter>0&&n1.jitter<=1?n1.jitter:0,this.attempts=0}Backoff.prototype.duration=function(){var n1=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e1=Math.random(),t1=Math.floor(e1*this.jitter*n1);n1=Math.floor(e1*10)&1?n1+t1:n1-t1}return Math.min(n1,this.max)|0};Backoff.prototype.reset=function(){this.attempts=0};Backoff.prototype.setMin=function(n1){this.ms=n1};Backoff.prototype.setMax=function(n1){this.max=n1};Backoff.prototype.setJitter=function(n1){this.jitter=n1};class Manager extends Emitter{constructor(e1,t1){var r1;super(),this.nsps={},this.subs=[],e1&&typeof e1=="object"&&(t1=e1,e1=void 0),t1=t1||{},t1.path=t1.path||"/socket.io",this.opts=t1,installTimerFunctions(this,t1),this.reconnection(t1.reconnection!==!1),this.reconnectionAttempts(t1.reconnectionAttempts||1/0),this.reconnectionDelay(t1.reconnectionDelay||1e3),this.reconnectionDelayMax(t1.reconnectionDelayMax||5e3),this.randomizationFactor((r1=t1.randomizationFactor)!==null&&r1!==void 0?r1:.5),this.backoff=new Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t1.timeout==null?2e4:t1.timeout),this._readyState="closed",this.uri=e1;const o1=t1.parser||parser$2;this.encoder=new o1.Encoder,this.decoder=new o1.Decoder,this._autoConnect=t1.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e1){return arguments.length?(this._reconnection=!!e1,this):this._reconnection}reconnectionAttempts(e1){return e1===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e1,this)}reconnectionDelay(e1){var t1;return e1===void 0?this._reconnectionDelay:(this._reconnectionDelay=e1,(t1=this.backoff)===null||t1===void 0||t1.setMin(e1),this)}randomizationFactor(e1){var t1;return e1===void 0?this._randomizationFactor:(this._randomizationFactor=e1,(t1=this.backoff)===null||t1===void 0||t1.setJitter(e1),this)}reconnectionDelayMax(e1){var t1;return e1===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e1,(t1=this.backoff)===null||t1===void 0||t1.setMax(e1),this)}timeout(e1){return arguments.length?(this._timeout=e1,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e1){if(~this._readyState.indexOf("open"))return this;this.engine=new Socket$1(this.uri,this.opts);const t1=this.engine,r1=this;this._readyState="opening",this.skipReconnect=!1;const o1=on$1(t1,"open",function(){r1.onopen(),e1&&e1()}),i1=on$1(t1,"error",a1=>{r1.cleanup(),r1._readyState="closed",this.emitReserved("error",a1),e1?e1(a1):r1.maybeReconnectOnOpen()});if(this._timeout!==!1){const a1=this._timeout;a1===0&&o1();const s1=this.setTimeoutFn(()=>{o1(),t1.close(),t1.emit("error",new Error("timeout"))},a1);this.opts.autoUnref&&s1.unref(),this.subs.push(function(){clearTimeout(s1)})}return this.subs.push(o1),this.subs.push(i1),this}connect(e1){return this.open(e1)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e1=this.engine;this.subs.push(on$1(e1,"ping",this.onping.bind(this)),on$1(e1,"data",this.ondata.bind(this)),on$1(e1,"error",this.onerror.bind(this)),on$1(e1,"close",this.onclose.bind(this)),on$1(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e1){try{this.decoder.add(e1)}catch(t1){this.onclose("parse error",t1)}}ondecoded(e1){nextTick(()=>{this.emitReserved("packet",e1)},this.setTimeoutFn)}onerror(e1){this.emitReserved("error",e1)}socket(e1,t1){let r1=this.nsps[e1];return r1?this._autoConnect&&!r1.active&&r1.connect():(r1=new Socket(this,e1,t1),this.nsps[e1]=r1),r1}_destroy(e1){const t1=Object.keys(this.nsps);for(const r1 of t1)if(this.nsps[r1].active)return;this._close()}_packet(e1){const t1=this.encoder.encode(e1);for(let r1=0;r1<t1.length;r1++)this.engine.write(t1[r1],e1.options)}cleanup(){this.subs.forEach(e1=>e1()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e1,t1){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e1,t1),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e1=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t1=this.backoff.duration();this._reconnecting=!0;const r1=this.setTimeoutFn(()=>{e1.skipReconnect||(this.emitReserved("reconnect_attempt",e1.backoff.attempts),!e1.skipReconnect&&e1.open(o1=>{o1?(e1._reconnecting=!1,e1.reconnect(),this.emitReserved("reconnect_error",o1)):e1.onreconnect()}))},t1);this.opts.autoUnref&&r1.unref(),this.subs.push(function(){clearTimeout(r1)})}}onreconnect(){const e1=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e1)}}const cache$1={};function lookup(n1,e1){typeof n1=="object"&&(e1=n1,n1=void 0),e1=e1||{};const t1=url$1(n1,e1.path||"/socket.io"),r1=t1.source,o1=t1.id,i1=t1.path,a1=cache$1[o1]&&i1 in cache$1[o1].nsps,s1=e1.forceNew||e1["force new connection"]||e1.multiplex===!1||a1;let l1;return s1?l1=new Manager(r1,e1):(cache$1[o1]||(cache$1[o1]=new Manager(r1,e1)),l1=cache$1[o1]),t1.query&&!e1.query&&(e1.query=t1.queryKey),l1.socket(t1.path,e1)}Object.assign(lookup,{Manager,Socket,io:lookup,connect:lookup});const DefaultOptions={heartbeat:!0},createWebsocket=(n1,e1=DefaultOptions)=>{if(!n1)throw"A websocket path must be provided";const{heartbeat:t1}={...DefaultOptions,...e1},r1=location.protocol==="https:",o1=r1?"wss:":"ws:",i1=location.hostname,a1=location.port||(r1?443:80);let s1=lookup(`${o1}//${i1}:${a1}`,{path:n1,reconnectionAttempts:3,reconnectionDelay:5e3,reconnectionDelayMax:5e3,timeout:4e3,transports:["websocket"]}),l1;return t1&&(l1=setInterval(()=>{s1.emit(SocketEvent.Heartbeat)},SocketSessionTTL*500)),s1.on("disconnect",()=>{clearInterval(l1)}),s1.onOther=(c1,u1)=>{s1.on(c1,f1=>{(f1==null?void 0:f1.apiSessionId)!==APISessionID&&u1(f1)})},s1};function downloadText(n1,e1){typeof e1=="object"&&(e1=JSON.stringify(e1));const t1=new Blob([e1],{type:"plain/text"}),r1=URL.createObjectURL(t1),o1=document.createElement("a");o1.href=r1,o1.download=n1,o1.click(),URL.revokeObjectURL(r1)}async function downloadStream(n1){const e1=await n1.blob(),t1=n1.headers.get("Content-Disposition"),o1=/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(t1)[1].replace(/['"]/g,""),i1=new Blob([e1]),a1=URL.createObjectURL(i1),s1=document.createElement("a");s1.href=a1,s1.download=o1,s1.click(),URL.revokeObjectURL(a1)}const{buildLuceneQuery,luceneLimit,runLuceneQuery,luceneSort}=LuceneUtils;class DataFetch{constructor(e1){if(this.API=null,this.features={supportsSearch:!1,supportsSort:!1,supportsPagination:!1},this.options={datasource:null,limit:10,filter:null,query:null,sortColumn:null,sortOrder:"ascending",sortType:null,paginate:!0,clientSideSearching:!0,clientSideSorting:!0,clientSideLimiting:!0},this.store=writable({rows:[],info:null,schema:null,loading:!1,loaded:!1,query:null,pageNumber:0,cursor:null,cursors:[],resetKey:Math.random(),error:null}),this.API=e1==null?void 0:e1.API,this.options={...this.options,...e1},!this.API)throw"An API client is required for fetching data";if(this.getData=this.getData.bind(this),this.getPage=this.getPage.bind(this),this.getInitialData=this.getInitialData.bind(this),this.determineFeatureFlags=this.determineFeatureFlags.bind(this),this.refresh=this.refresh.bind(this),this.update=this.update.bind(this),this.hasNextPage=this.hasNextPage.bind(this),this.hasPrevPage=this.hasPrevPage.bind(this),this.nextPage=this.nextPage.bind(this),this.prevPage=this.prevPage.bind(this),this.derivedStore=derived(this.store,t1=>({...t1,...this.features,hasNextPage:this.hasNextPage(t1),hasPrevPage:this.hasPrevPage(t1)})),!this.options.datasource){this.store.update(t1=>({...t1,loaded:!0}));return}this.getInitialData()}get subscribe(){return this.derivedStore.subscribe}getDefaultSortColumn(e1,t1){return e1!=null&&e1.primaryDisplay&&t1[e1.primaryDisplay]?e1.primaryDisplay:Object.keys(t1)[0]}async getInitialData(){var c1;const{datasource:e1,filter:t1,paginate:r1}=this.options,o1=await this.getDefinition(e1),i1=this.determineFeatureFlags(o1);this.features={supportsSearch:!!(i1!=null&&i1.supportsSearch),supportsSort:!!(i1!=null&&i1.supportsSort),supportsPagination:r1&&!!(i1!=null&&i1.supportsPagination)};let a1=this.getSchema(e1,o1);if(a1=this.enrichSchema(a1),!a1)return;if(this.options.sortColumn&&!a1[this.options.sortColumn]&&(this.options.sortColumn=null),this.options.sortColumn||(this.options.sortColumn=this.getDefaultSortColumn(o1,a1)),!this.options.sortColumn)this.options.sortOrder="ascending",this.options.sortType=null;else{const u1=(c1=a1==null?void 0:a1[this.options.sortColumn])==null?void 0:c1.type;this.options.sortType=u1==="number"||u1==="bigint"?"number":"string",this.options.sortOrder||(this.options.sortOrder="ascending")}let s1=this.options.query;s1||(s1=buildLuceneQuery(t1)),this.store.update(u1=>({...u1,definition:o1,schema:a1,query:s1,loading:!0,cursors:[],cursor:null}));const l1=await this.getPage();this.store.update(u1=>({...u1,loading:!1,loaded:!0,pageNumber:0,rows:l1.rows,info:l1.info,cursors:r1&&l1.hasNextPage?[null,l1.cursor]:[null],error:l1.error,resetKey:Math.random()}))}async getPage(){const{sortColumn:e1,sortOrder:t1,sortType:r1,limit:o1,clientSideSearching:i1,clientSideSorting:a1,clientSideLimiting:s1}=this.options,{query:l1}=get_store_value(this.store);let{rows:c1,info:u1,hasNextPage:f1,cursor:d1,error:p1}=await this.getData();return!this.features.supportsSearch&&i1&&(c1=runLuceneQuery(c1,l1)),!this.features.supportsSort&&a1&&(c1=luceneSort(c1,e1,t1,r1)),!this.features.supportsPagination&&s1&&(c1=luceneLimit(c1,o1)),{rows:c1,info:u1,hasNextPage:f1,cursor:d1,error:p1}}async getData(){return{rows:[],info:null,hasNextPage:!1,cursor:null}}async getDefinition(e1){if(!(e1!=null&&e1.tableId))return null;try{return await this.API.fetchTableDefinition(e1.tableId)}catch(t1){return this.store.update(r1=>({...r1,error:t1})),null}}getSchema(e1,t1){return t1==null?void 0:t1.schema}enrichSchema(e1){if(e1==null)return null;let t1={};Object.keys(e1).forEach(o1=>{const i1=e1[o1];if((i1==null?void 0:i1.type)==="json"){const a1=convertJSONSchemaToTableSchema(i1,{squashObjects:!0});Object.keys(a1).forEach(s1=>{t1[`${o1}.${s1}`]={type:a1[s1].type,nestedJSON:!0}})}}),e1={...e1,...t1};let r1={};return Object.entries(e1).forEach(([o1,i1])=>{typeof i1=="string"?r1[o1]={type:i1,name:o1}:r1[o1]={...i1,name:o1}}),r1}determineFeatureFlags(e1){return{supportsSearch:!1,supportsSort:!1,supportsPagination:!1}}async update(e1){let t1=!1;const r1=Object.entries(e1||{});for(let[o1,i1]of r1)if(JSON.stringify(i1)!==JSON.stringify(this.options[o1])){t1=!0;break}t1&&(this.options={...this.options,...fp$1.cloneDeep(e1)},await this.getInitialData())}async refresh(){if(get_store_value(this.store).loading)return;this.store.update(l1=>({...l1,loading:!0}));const{rows:e1,info:t1,error:r1,cursor:o1}=await this.getPage();let{cursors:i1}=get_store_value(this.store);const{pageNumber:a1}=get_store_value(this.store);if(!e1.length&&a1>0)return this.store.update(l1=>({...l1,loading:!1,cursors:i1.slice(0,a1)})),await this.prevPage();i1[a1+1]!=o1&&(i1=i1.slice(0,a1+1),i1[a1+1]=o1),this.store.update(l1=>({...l1,rows:e1,info:t1,loading:!1,error:r1,cursors:i1}))}hasNextPage(e1){return e1.cursors[e1.pageNumber+1]!=null}hasPrevPage(e1){return e1.pageNumber>0}async nextPage(){const e1=get_store_value(this.derivedStore);if(e1.loading||!this.options.paginate||!e1.hasNextPage)return;const t1=e1.cursors[e1.pageNumber+1];this.store.update(l1=>({...l1,loading:!0,cursor:t1,pageNumber:l1.pageNumber+1}));const{rows:r1,info:o1,hasNextPage:i1,cursor:a1,error:s1}=await this.getPage();this.store.update(l1=>{let{cursors:c1,pageNumber:u1}=l1;return i1&&(c1[u1+1]=a1),{...l1,rows:r1,info:o1,cursors:c1,loading:!1,error:s1}})}async prevPage(){const e1=get_store_value(this.derivedStore);if(e1.loading||!this.options.paginate||!e1.hasPrevPage)return;const t1=e1.cursors[e1.pageNumber-1];this.store.update(a1=>({...a1,loading:!0,cursor:t1,pageNumber:a1.pageNumber-1}));const{rows:r1,info:o1,error:i1}=await this.getPage();this.store.update(a1=>({...a1,rows:r1,info:o1,loading:!1,error:i1}))}}class TableFetch extends DataFetch{determineFeatureFlags(){return{supportsSearch:!0,supportsSort:!0,supportsPagination:!0}}async getData(){const{datasource:e1,limit:t1,sortColumn:r1,sortOrder:o1,sortType:i1,paginate:a1}=this.options,{tableId:s1}=e1,{cursor:l1,query:c1}=get_store_value(this.store);try{const u1=await this.API.searchTable({tableId:s1,query:c1,limit:t1,sort:r1,sortOrder:(o1==null?void 0:o1.toLowerCase())??"ascending",sortType:i1,paginate:a1,bookmark:l1});return{rows:(u1==null?void 0:u1.rows)||[],hasNextPage:(u1==null?void 0:u1.hasNextPage)||!1,cursor:(u1==null?void 0:u1.bookmark)||null}}catch(u1){return{rows:[],hasNextPage:!1,error:u1}}}}class ViewFetch extends DataFetch{getSchema(e1,t1){var r1,o1;return(o1=(r1=t1==null?void 0:t1.views)==null?void 0:r1[e1.name])==null?void 0:o1.schema}async getData(){const{datasource:e1}=this.options;try{return{rows:await this.API.fetchViewData(e1)||[]}}catch{return{rows:[]}}}}class ViewV2Fetch extends DataFetch{determineFeatureFlags(){return{supportsSearch:!0,supportsSort:!0,supportsPagination:!0}}getSchema(e1,t1){return t1==null?void 0:t1.schema}async getDefinition(e1){if(!(e1!=null&&e1.id))return null;try{const t1=await this.API.viewV2.fetchDefinition(e1.id);return t1==null?void 0:t1.data}catch(t1){return this.store.update(r1=>({...r1,error:t1})),null}}getDefaultSortColumn(){return null}async getData(){var f1,d1;const{datasource:e1,limit:t1,sortColumn:r1,sortOrder:o1,sortType:i1,paginate:a1,filter:s1}=this.options,{cursor:l1,query:c1,definition:u1}=get_store_value(this.store);!r1&&((f1=u1.sort)!=null&&f1.field)&&(this.options.sortColumn=u1.sort.field,this.options.sortOrder=u1.sort.order),!(s1!=null&&s1.length)&&((d1=u1.query)!=null&&d1.length)&&(this.options.filter=u1.query);try{const p1=await this.API.viewV2.fetch({viewId:e1.id,query:c1,paginate:a1,limit:t1,bookmark:l1,sort:r1,sortOrder:o1==null?void 0:o1.toLowerCase(),sortType:i1});return{rows:(p1==null?void 0:p1.rows)||[],hasNextPage:(p1==null?void 0:p1.hasNextPage)||!1,cursor:(p1==null?void 0:p1.bookmark)||null}}catch(p1){return{rows:[],hasNextPage:!1,error:p1}}}}class QueryFetch extends DataFetch{determineFeatureFlags(e1){var r1,o1,i1,a1,s1,l1;return{supportsPagination:!!((o1=(r1=e1==null?void 0:e1.fields)==null?void 0:r1.pagination)!=null&&o1.type)&&!!((a1=(i1=e1==null?void 0:e1.fields)==null?void 0:i1.pagination)!=null&&a1.location)&&!!((l1=(s1=e1==null?void 0:e1.fields)==null?void 0:s1.pagination)!=null&&l1.pageParam)}}async getDefinition(e1){if(!(e1!=null&&e1._id))return null;try{const t1=await this.API.fetchQueryDefinition(e1._id);return t1.fields||(t1.fields=e1.fields),t1}catch{return null}}getDefaultSortColumn(){return null}async getData(){var u1,f1;const{datasource:e1,limit:t1,paginate:r1}=this.options,{supportsPagination:o1}=this.features,{cursor:i1,definition:a1}=get_store_value(this.store),s1=(f1=(u1=a1==null?void 0:a1.fields)==null?void 0:u1.pagination)==null?void 0:f1.type;let l1=cloneDeep((e1==null?void 0:e1.queryParams)||{});for(let d1 of(e1==null?void 0:e1.parameters)||{})l1[d1.name]||(l1[d1.name]=d1.default);let c1={queryId:e1==null?void 0:e1._id,parameters:l1};if(r1&&o1){const d1=s1==="page"?parseInt(i1||1):i1;c1.pagination={page:d1,limit:t1}}try{const d1=await this.API.executeQuery(c1),{data:p1,pagination:m1,..._1}=d1;let h1=null,g1=!1;return r1&&o1&&(s1==="page"?(h1=c1.pagination.page+1,g1=(p1==null?void 0:p1.length)===t1&&t1>0):(h1=m1==null?void 0:m1.cursor,g1=h1!=null)),{rows:p1||[],info:_1,cursor:h1,hasNextPage:g1}}catch{return{rows:[],hasNextPage:!1}}}}class RelationshipFetch extends DataFetch{async getData(){const{datasource:e1}=this.options;try{return{rows:await this.API.fetchRelationshipData({rowId:e1==null?void 0:e1.rowId,tableId:e1==null?void 0:e1.rowTableId,fieldName:e1==null?void 0:e1.fieldName})||[]}}catch{return{rows:[]}}}}class NestedProviderFetch extends DataFetch{async getDefinition(e1){var t1;return{schema:(t1=e1==null?void 0:e1.value)==null?void 0:t1.schema}}async getData(){var t1;const{datasource:e1}=this.options;return{rows:((t1=e1==null?void 0:e1.value)==null?void 0:t1.rows)||[],hasNextPage:!1,cursor:null}}}class FieldFetch extends DataFetch{async getDefinition(e1){let t1;return e1.fieldType==="attachment"?t1={url:{type:"string"},name:{type:"string"}}:e1.fieldType==="array"&&(t1={value:{type:"string"}}),{schema:t1}}async getData(){const{datasource:e1}=this.options,t1=(e1==null?void 0:e1.value)||[];let r1;return Array.isArray(t1)&&t1[0]&&typeof t1[0]!="object"?r1=t1.map(o1=>({value:o1})):r1=t1,{rows:r1||[],hasNextPage:!1,cursor:null}}}class JSONArrayFetch extends FieldFetch{async getDefinition(e1){try{const t1=await this.API.fetchTableDefinition(e1.tableId);return{schema:getJSONArrayDatasourceSchema(t1==null?void 0:t1.schema,e1)}}catch{return null}}}class UserFetch extends DataFetch{constructor(e1){super({...e1,datasource:{tableId:TableNames$1.USERS}})}determineFeatureFlags(){return{supportsSearch:!0,supportsSort:!1,supportsPagination:!0}}async getDefinition(){return{schema:{}}}async getData(){const{limit:e1,paginate:t1}=this.options,{cursor:r1,query:o1}=get_store_value(this.store);let i1;const{appId:a1,paginated:s1,...l1}=o1;!hasFilters(o1)&&l1.email!=null?i1={string:{email:l1.email}}:i1=l1;try{const c1={bookmark:r1,query:i1,appId:a1,paginate:s1||t1,limit:e1},u1=await this.API.searchUsers(c1);return{rows:(u1==null?void 0:u1.data)||[],hasNextPage:(u1==null?void 0:u1.hasNextPage)||!1,cursor:(u1==null?void 0:u1.nextPage)||null}}catch(c1){return{rows:[],hasNextPage:!1,error:c1}}}}class GroupUserFetch extends DataFetch{constructor(e1){super({...e1,datasource:{tableId:TableNames$1.USERS}})}determineFeatureFlags(){return{supportsSearch:!0,supportsSort:!1,supportsPagination:!0}}async getDefinition(){return{schema:{}}}async getData(){const{query:e1,cursor:t1}=get_store_value(this.store);try{const r1=await this.API.getGroupUsers({id:e1.groupId,emailSearch:e1.emailSearch,bookmark:t1});return{rows:(r1==null?void 0:r1.users)||[],hasNextPage:(r1==null?void 0:r1.hasNextPage)||!1,cursor:(r1==null?void 0:r1.bookmark)||null}}catch(r1){return{rows:[],hasNextPage:!1,error:r1}}}}class CustomFetch extends DataFetch{getType(e1){return e1==null?"string":typeof e1==="object"?Array.isArray(e1)?"array":"json":isNaN(e1)?"string":"number"}parseCustomData(e1){if(!e1)return[];if(Array.isArray(e1))return e1;if(typeof e1=="string"){try{const t1=JSON.parse(e1);return Array.isArray(t1)?t1:[t1]}catch{}return e1.includes(`
376
+ Maximum file size is #image_max_size#.`,importError:"Something went wrong when uploading the image #image_name#."};function EasyMDE(n1){n1=n1||{},n1.parent=this;var e1=!0;if(n1.autoDownloadFontAwesome===!1&&(e1=!1),n1.autoDownloadFontAwesome!==!0)for(var t1=document.styleSheets,r1=0;r1<t1.length;r1++)t1[r1].href&&t1[r1].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/")>-1&&(e1=!1);if(e1){var o1=document.createElement("link");o1.rel="stylesheet",o1.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(o1)}if(n1.element)this.element=n1.element;else if(n1.element===null){console.log("EasyMDE: Error. No element was found.");return}if(n1.toolbar===void 0){n1.toolbar=[];for(var i1 in toolbarBuiltInButtons)Object.prototype.hasOwnProperty.call(toolbarBuiltInButtons,i1)&&(i1.indexOf("separator-")!=-1&&n1.toolbar.push("|"),(toolbarBuiltInButtons[i1].default===!0||n1.showIcons&&n1.showIcons.constructor===Array&&n1.showIcons.indexOf(i1)!=-1)&&n1.toolbar.push(i1))}if(Object.prototype.hasOwnProperty.call(n1,"previewClass")||(n1.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(n1,"status")||(n1.status=["autosave","lines","words","cursor"],n1.uploadImage&&n1.status.unshift("upload-image")),n1.previewRender||(n1.previewRender=function(s1){return this.parent.markdown(s1)}),n1.parsingConfig=extend$1({highlightFormatting:!0},n1.parsingConfig||{}),n1.insertTexts=extend$1({},insertTexts,n1.insertTexts||{}),n1.promptTexts=extend$1({},promptTexts,n1.promptTexts||{}),n1.blockStyles=extend$1({},blockStyles,n1.blockStyles||{}),n1.autosave!=null&&(n1.autosave.timeFormat=extend$1({},timeFormat,n1.autosave.timeFormat||{})),n1.iconClassMap=extend$1({},iconClassMap,n1.iconClassMap||{}),n1.shortcuts=extend$1({},shortcuts,n1.shortcuts||{}),n1.maxHeight=n1.maxHeight||void 0,n1.direction=n1.direction||"ltr",typeof n1.maxHeight<"u"?n1.minHeight=n1.maxHeight:n1.minHeight=n1.minHeight||"300px",n1.errorCallback=n1.errorCallback||function(s1){alert(s1)},n1.uploadImage=n1.uploadImage||!1,n1.imageMaxSize=n1.imageMaxSize||2097152,n1.imageAccept=n1.imageAccept||"image/png, image/jpeg, image/gif, image/avif",n1.imageTexts=extend$1({},imageTexts,n1.imageTexts||{}),n1.errorMessages=extend$1({},errorMessages,n1.errorMessages||{}),n1.imagePathAbsolute=n1.imagePathAbsolute||!1,n1.imageCSRFName=n1.imageCSRFName||"csrfmiddlewaretoken",n1.imageCSRFHeader=n1.imageCSRFHeader||!1,n1.autosave!=null&&n1.autosave.unique_id!=null&&n1.autosave.unique_id!=""&&(n1.autosave.uniqueId=n1.autosave.unique_id),n1.overlayMode&&n1.overlayMode.combine===void 0&&(n1.overlayMode.combine=!0),this.options=n1,this.render(),n1.initialValue&&(!this.options.autosave||this.options.autosave.foundSavedValue!==!0)&&this.value(n1.initialValue),n1.uploadImage){var a1=this;this.codemirror.on("dragenter",function(s1,l1){a1.updateStatusBar("upload-image",a1.options.imageTexts.sbOnDragEnter),l1.stopPropagation(),l1.preventDefault()}),this.codemirror.on("dragend",function(s1,l1){a1.updateStatusBar("upload-image",a1.options.imageTexts.sbInit),l1.stopPropagation(),l1.preventDefault()}),this.codemirror.on("dragleave",function(s1,l1){a1.updateStatusBar("upload-image",a1.options.imageTexts.sbInit),l1.stopPropagation(),l1.preventDefault()}),this.codemirror.on("dragover",function(s1,l1){a1.updateStatusBar("upload-image",a1.options.imageTexts.sbOnDragEnter),l1.stopPropagation(),l1.preventDefault()}),this.codemirror.on("drop",function(s1,l1){l1.stopPropagation(),l1.preventDefault(),n1.imageUploadFunction?a1.uploadImagesUsingCustomFunction(n1.imageUploadFunction,l1.dataTransfer.files):a1.uploadImages(l1.dataTransfer.files)}),this.codemirror.on("paste",function(s1,l1){n1.imageUploadFunction?a1.uploadImagesUsingCustomFunction(n1.imageUploadFunction,l1.clipboardData.files):a1.uploadImages(l1.clipboardData.files)})}}EasyMDE.prototype.uploadImages=function(n1,e1,t1){if(n1.length!==0){for(var r1=[],o1=0;o1<n1.length;o1++)r1.push(n1[o1].name),this.uploadImage(n1[o1],e1,t1);this.updateStatusBar("upload-image",this.options.imageTexts.sbOnDrop.replace("#images_names#",r1.join(", ")))}};EasyMDE.prototype.uploadImagesUsingCustomFunction=function(n1,e1){if(e1.length!==0){for(var t1=[],r1=0;r1<e1.length;r1++)t1.push(e1[r1].name),this.uploadImageUsingCustomFunction(n1,e1[r1]);this.updateStatusBar("upload-image",this.options.imageTexts.sbOnDrop.replace("#images_names#",t1.join(", ")))}};EasyMDE.prototype.updateStatusBar=function(n1,e1){if(this.gui.statusbar){var t1=this.gui.statusbar.getElementsByClassName(n1);t1.length===1?this.gui.statusbar.getElementsByClassName(n1)[0].textContent=e1:t1.length===0?console.log("EasyMDE: status bar item "+n1+" was not found."):console.log("EasyMDE: Several status bar items named "+n1+" was found.")}};EasyMDE.prototype.markdown=function(n1){if(marked){var e1;if(this.options&&this.options.renderingConfig&&this.options.renderingConfig.markedOptions?e1=this.options.renderingConfig.markedOptions:e1={},this.options&&this.options.renderingConfig&&this.options.renderingConfig.singleLineBreaks===!1?e1.breaks=!1:e1.breaks=!0,this.options&&this.options.renderingConfig&&this.options.renderingConfig.codeSyntaxHighlighting===!0){var t1=this.options.renderingConfig.hljs||window.hljs;t1&&(e1.highlight=function(o1,i1){return i1&&t1.getLanguage(i1)?t1.highlight(i1,o1).value:t1.highlightAuto(o1).value})}marked.setOptions(e1);var r1=marked.parse(n1);return this.options.renderingConfig&&typeof this.options.renderingConfig.sanitizerFunction=="function"&&(r1=this.options.renderingConfig.sanitizerFunction.call(this,r1)),r1=addAnchorTargetBlank(r1),r1=removeListStyleWhenCheckbox(r1),r1}};EasyMDE.prototype.render=function(n1){if(n1||(n1=this.element||document.getElementsByTagName("textarea")[0]),this._rendered&&this._rendered===n1)return;this.element=n1;var e1=this.options,t1=this,r1={};for(var o1 in e1.shortcuts)e1.shortcuts[o1]!==null&&bindings[o1]!==null&&function(h1){r1[fixShortcut(e1.shortcuts[h1])]=function(){var g1=bindings[h1];typeof g1=="function"?g1(t1):typeof g1=="string"&&window.open(g1,"_blank")}}(o1);r1.Enter="newlineAndIndentContinueMarkdownList",r1.Tab="tabAndIndentMarkdownList",r1["Shift-Tab"]="shiftTabAndUnindentMarkdownList",r1.Esc=function(h1){h1.getOption("fullScreen")&&toggleFullScreen(t1)},this.documentOnKeyDown=function(h1){h1=h1||window.event,h1.keyCode==27&&t1.codemirror.getOption("fullScreen")&&toggleFullScreen(t1)},document.addEventListener("keydown",this.documentOnKeyDown,!1);var i1,a1;e1.overlayMode?(CodeMirror.defineMode("overlay-mode",function(h1){return CodeMirror.overlayMode(CodeMirror.getMode(h1,e1.spellChecker!==!1?"spell-checker":"gfm"),e1.overlayMode.mode,e1.overlayMode.combine)}),i1="overlay-mode",a1=e1.parsingConfig,a1.gitHubSpice=!1):(i1=e1.parsingConfig,i1.name="gfm",i1.gitHubSpice=!1),e1.spellChecker!==!1&&(i1="spell-checker",a1=e1.parsingConfig,a1.name="gfm",a1.gitHubSpice=!1,typeof e1.spellChecker=="function"?e1.spellChecker({codeMirrorInstance:CodeMirror}):CodeMirrorSpellChecker({codeMirrorInstance:CodeMirror}));function s1(h1,g1,$1){return{addNew:!1}}if(this.codemirror=CodeMirror.fromTextArea(n1,{mode:i1,backdrop:a1,theme:e1.theme!=null?e1.theme:"easymde",tabSize:e1.tabSize!=null?e1.tabSize:2,indentUnit:e1.tabSize!=null?e1.tabSize:2,indentWithTabs:e1.indentWithTabs!==!1,lineNumbers:e1.lineNumbers===!0,autofocus:e1.autofocus===!0,extraKeys:r1,direction:e1.direction,lineWrapping:e1.lineWrapping!==!1,allowDropFileTypes:["text/plain"],placeholder:e1.placeholder||n1.getAttribute("placeholder")||"",styleSelectedText:e1.styleSelectedText!=null?e1.styleSelectedText:!isMobile(),scrollbarStyle:e1.scrollbarStyle!=null?e1.scrollbarStyle:"native",configureMouse:s1,inputStyle:e1.inputStyle!=null?e1.inputStyle:isMobile()?"contenteditable":"textarea",spellcheck:e1.nativeSpellcheck!=null?e1.nativeSpellcheck:!0,autoRefresh:e1.autoRefresh!=null?e1.autoRefresh:!1}),this.codemirror.getScrollerElement().style.minHeight=e1.minHeight,typeof e1.maxHeight<"u"&&(this.codemirror.getScrollerElement().style.height=e1.maxHeight),e1.forceSync===!0){var l1=this.codemirror;l1.on("change",function(){l1.save()})}this.gui={};var c1=document.createElement("div");c1.classList.add("EasyMDEContainer"),c1.setAttribute("role","application");var u1=this.codemirror.getWrapperElement();u1.parentNode.insertBefore(c1,u1),c1.appendChild(u1),e1.toolbar!==!1&&(this.gui.toolbar=this.createToolbar()),e1.status!==!1&&(this.gui.statusbar=this.createStatusbar()),e1.autosave!=null&&e1.autosave.enabled===!0&&(this.autosave(),this.codemirror.on("change",function(){clearTimeout(t1._autosave_timeout),t1._autosave_timeout=setTimeout(function(){t1.autosave()},t1.options.autosave.submit_delay||t1.options.autosave.delay||1e3)}));function f1(h1,g1){var $1,y1=window.getComputedStyle(document.querySelector(".CodeMirror-sizer")).width.replace("px","");return h1<y1?$1=g1+"px":$1=g1/h1*100+"%",$1}var d1=this;function p1(h1,g1){h1.setAttribute("data-img-src",g1.url),h1.setAttribute("style","--bg-image:url("+g1.url+");--width:"+g1.naturalWidth+"px;--height:"+f1(g1.naturalWidth,g1.naturalHeight)),d1.codemirror.setSize()}function m1(){e1.previewImagesInEditor&&c1.querySelectorAll(".cm-image-marker").forEach(function(h1){var g1=h1.parentElement;if(g1.innerText.match(/^!\[.*?\]\(.*\)/g)&&!g1.hasAttribute("data-img-src")){var $1=g1.innerText.match("\\((.*)\\)");if(window.EMDEimagesCache||(window.EMDEimagesCache={}),$1&&$1.length>=2){var y1=$1[1];if(e1.imagesPreviewHandler){var v1=e1.imagesPreviewHandler($1[1]);typeof v1=="string"&&(y1=v1)}if(window.EMDEimagesCache[y1])p1(g1,window.EMDEimagesCache[y1]);else{var S1=document.createElement("img");S1.onload=function(){window.EMDEimagesCache[y1]={naturalWidth:S1.naturalWidth,naturalHeight:S1.naturalHeight,url:y1},p1(g1,window.EMDEimagesCache[y1])},S1.src=y1}}}})}this.codemirror.on("update",function(){m1()}),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element,(e1.autofocus===!0||n1.autofocus)&&this.codemirror.focus();var _1=this.codemirror;setTimeout((function(){_1.refresh()}).bind(_1),0)};EasyMDE.prototype.cleanup=function(){document.removeEventListener("keydown",this.documentOnKeyDown)};function isLocalStorageAvailable(){if(typeof localStorage=="object")try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch{return!1}else return!1;return!0}EasyMDE.prototype.autosave=function(){if(isLocalStorageAvailable()){var n1=this;if(this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to use the autosave feature");return}this.options.autosave.binded!==!0&&(n1.element.form!=null&&n1.element.form!=null&&n1.element.form.addEventListener("submit",function(){clearTimeout(n1.autosaveTimeoutId),n1.autosaveTimeoutId=void 0,localStorage.removeItem("smde_"+n1.options.autosave.uniqueId)}),this.options.autosave.binded=!0),this.options.autosave.loaded!==!0&&(typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)=="string"&&localStorage.getItem("smde_"+this.options.autosave.uniqueId)!=""&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0);var e1=n1.value();e1!==""?localStorage.setItem("smde_"+this.options.autosave.uniqueId,e1):localStorage.removeItem("smde_"+this.options.autosave.uniqueId);var t1=document.getElementById("autosaved");if(t1!=null&&t1!=null&&t1!=""){var r1=new Date,o1=new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale,"en-US"],this.options.autosave.timeFormat.format).format(r1),i1=this.options.autosave.text==null?"Autosaved: ":this.options.autosave.text;t1.innerHTML=i1+o1}}else console.log("EasyMDE: localStorage not available, cannot autosave")};EasyMDE.prototype.clearAutosavedValue=function(){if(isLocalStorageAvailable()){if(this.options.autosave==null||this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to clear the autosave value");return}localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("EasyMDE: localStorage not available, cannot autosave")};EasyMDE.prototype.openBrowseFileWindow=function(n1,e1){var t1=this,r1=this.gui.toolbar.getElementsByClassName("imageInput")[0];r1.click();function o1(i1){t1.options.imageUploadFunction?t1.uploadImagesUsingCustomFunction(t1.options.imageUploadFunction,i1.target.files):t1.uploadImages(i1.target.files,n1,e1),r1.removeEventListener("change",o1)}r1.addEventListener("change",o1)};EasyMDE.prototype.uploadImage=function(n1,e1,t1){var r1=this;e1=e1||function(c1){afterImageUploaded(r1,c1)};function o1(l1){r1.updateStatusBar("upload-image",l1),setTimeout(function(){r1.updateStatusBar("upload-image",r1.options.imageTexts.sbInit)},1e4),t1&&typeof t1=="function"&&t1(l1),r1.options.errorCallback(l1)}function i1(l1){var c1=r1.options.imageTexts.sizeUnits.split(",");return l1.replace("#image_name#",n1.name).replace("#image_size#",humanFileSize(n1.size,c1)).replace("#image_max_size#",humanFileSize(r1.options.imageMaxSize,c1))}if(n1.size>this.options.imageMaxSize){o1(i1(this.options.errorMessages.fileTooLarge));return}var a1=new FormData;a1.append("image",n1),r1.options.imageCSRFToken&&!r1.options.imageCSRFHeader&&a1.append(r1.options.imageCSRFName,r1.options.imageCSRFToken);var s1=new XMLHttpRequest;s1.upload.onprogress=function(l1){if(l1.lengthComputable){var c1=""+Math.round(l1.loaded*100/l1.total);r1.updateStatusBar("upload-image",r1.options.imageTexts.sbProgress.replace("#file_name#",n1.name).replace("#progress#",c1))}},s1.open("POST",this.options.imageUploadEndpoint),r1.options.imageCSRFToken&&r1.options.imageCSRFHeader&&s1.setRequestHeader(r1.options.imageCSRFName,r1.options.imageCSRFToken),s1.onload=function(){try{var l1=JSON.parse(this.responseText)}catch{console.error("EasyMDE: The server did not return a valid json."),o1(i1(r1.options.errorMessages.importError));return}this.status===200&&l1&&!l1.error&&l1.data&&l1.data.filePath?e1((r1.options.imagePathAbsolute?"":window.location.origin+"/")+l1.data.filePath):l1.error&&l1.error in r1.options.errorMessages?o1(i1(r1.options.errorMessages[l1.error])):l1.error?o1(i1(l1.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),o1(i1(r1.options.errorMessages.importError)))},s1.onerror=function(l1){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+l1.target.status+" ("+l1.target.statusText+")"),o1(r1.options.errorMessages.importError)},s1.send(a1)};EasyMDE.prototype.uploadImageUsingCustomFunction=function(n1,e1){var t1=this;function r1(a1){afterImageUploaded(t1,a1)}function o1(a1){var s1=i1(a1);t1.updateStatusBar("upload-image",s1),setTimeout(function(){t1.updateStatusBar("upload-image",t1.options.imageTexts.sbInit)},1e4),t1.options.errorCallback(s1)}function i1(a1){var s1=t1.options.imageTexts.sizeUnits.split(",");return a1.replace("#image_name#",e1.name).replace("#image_size#",humanFileSize(e1.size,s1)).replace("#image_max_size#",humanFileSize(t1.options.imageMaxSize,s1))}n1.apply(this,[e1,r1,o1])};EasyMDE.prototype.setPreviewMaxHeight=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.nextSibling,r1=parseInt(window.getComputedStyle(e1).paddingTop),o1=parseInt(window.getComputedStyle(e1).borderTopWidth),i1=parseInt(this.options.maxHeight),a1=i1+r1*2+o1*2,s1=a1.toString()+"px";t1.style.height=s1};EasyMDE.prototype.createSideBySide=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.nextSibling;if(!t1||!t1.classList.contains("editor-preview-side")){if(t1=document.createElement("div"),t1.className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var r1=0;r1<this.options.previewClass.length;r1++)t1.classList.add(this.options.previewClass[r1]);else typeof this.options.previewClass=="string"&&t1.classList.add(this.options.previewClass);e1.parentNode.insertBefore(t1,e1.nextSibling)}if(typeof this.options.maxHeight<"u"&&this.setPreviewMaxHeight(),this.options.syncSideBySidePreviewScroll===!1)return t1;var o1=!1,i1=!1;return n1.on("scroll",function(a1){if(o1){o1=!1;return}i1=!0;var s1=a1.getScrollInfo().height-a1.getScrollInfo().clientHeight,l1=parseFloat(a1.getScrollInfo().top)/s1,c1=(t1.scrollHeight-t1.clientHeight)*l1;t1.scrollTop=c1}),t1.onscroll=function(){if(i1){i1=!1;return}o1=!0;var a1=t1.scrollHeight-t1.clientHeight,s1=parseFloat(t1.scrollTop)/a1,l1=(n1.getScrollInfo().height-n1.getScrollInfo().clientHeight)*s1;n1.scrollTo(0,l1)},t1};EasyMDE.prototype.createToolbar=function(n1){if(n1=n1||this.options.toolbar,!(!n1||n1.length===0)){var e1;for(e1=0;e1<n1.length;e1++)toolbarBuiltInButtons[n1[e1]]!=null&&(n1[e1]=toolbarBuiltInButtons[n1[e1]]);var t1=document.createElement("div");t1.className="editor-toolbar",t1.setAttribute("role","toolbar");var r1=this,o1={};for(r1.toolbar=n1,e1=0;e1<n1.length;e1++)if(!(n1[e1].name=="guide"&&r1.options.toolbarGuideIcon===!1)&&!(r1.options.hideIcons&&r1.options.hideIcons.indexOf(n1[e1].name)!=-1)&&!((n1[e1].name=="fullscreen"||n1[e1].name=="side-by-side")&&isMobile())){if(n1[e1]==="|"){for(var i1=!1,a1=e1+1;a1<n1.length;a1++)n1[a1]!=="|"&&(!r1.options.hideIcons||r1.options.hideIcons.indexOf(n1[a1].name)==-1)&&(i1=!0);if(!i1)continue}(function(c1){var u1;if(c1==="|"?u1=createSep():c1.children?u1=createToolbarDropdown(c1,r1.options.toolbarTips,r1.options.shortcuts,r1):u1=createToolbarButton(c1,!0,r1.options.toolbarTips,r1.options.shortcuts,"button",r1),o1[c1.name||c1]=u1,t1.appendChild(u1),c1.name==="upload-image"){var f1=document.createElement("input");f1.className="imageInput",f1.type="file",f1.multiple=!0,f1.name="image",f1.accept=r1.options.imageAccept,f1.style.display="none",f1.style.opacity=0,t1.appendChild(f1)}})(n1[e1])}r1.toolbar_div=t1,r1.toolbarElements=o1;var s1=this.codemirror;s1.on("cursorActivity",function(){var c1=getState(s1);for(var u1 in o1)(function(f1){var d1=o1[f1];c1[f1]?d1.classList.add("active"):f1!="fullscreen"&&f1!="side-by-side"&&d1.classList.remove("active")})(u1)});var l1=s1.getWrapperElement();return l1.parentNode.insertBefore(t1,l1),t1}};EasyMDE.prototype.createStatusbar=function(n1){n1=n1||this.options.status;var e1=this.options,t1=this.codemirror;if(!(!n1||n1.length===0)){var r1=[],o1,i1,a1,s1;for(o1=0;o1<n1.length;o1++)if(i1=void 0,a1=void 0,s1=void 0,typeof n1[o1]=="object")r1.push({className:n1[o1].className,defaultValue:n1[o1].defaultValue,onUpdate:n1[o1].onUpdate,onActivity:n1[o1].onActivity});else{var l1=n1[o1];l1==="words"?(s1=function(p1){p1.innerHTML=wordCount(t1.getValue())},i1=function(p1){p1.innerHTML=wordCount(t1.getValue())}):l1==="lines"?(s1=function(p1){p1.innerHTML=t1.lineCount()},i1=function(p1){p1.innerHTML=t1.lineCount()}):l1==="cursor"?(s1=function(p1){p1.innerHTML="1:1"},a1=function(p1){var m1=t1.getCursor(),_1=m1.line+1,h1=m1.ch+1;p1.innerHTML=_1+":"+h1}):l1==="autosave"?s1=function(p1){e1.autosave!=null&&e1.autosave.enabled===!0&&p1.setAttribute("id","autosaved")}:l1==="upload-image"&&(s1=function(p1){p1.innerHTML=e1.imageTexts.sbInit}),r1.push({className:l1,defaultValue:s1,onUpdate:i1,onActivity:a1})}var c1=document.createElement("div");for(c1.className="editor-statusbar",o1=0;o1<r1.length;o1++){var u1=r1[o1],f1=document.createElement("span");f1.className=u1.className,typeof u1.defaultValue=="function"&&u1.defaultValue(f1),typeof u1.onUpdate=="function"&&this.codemirror.on("update",function(p1,m1){return function(){m1.onUpdate(p1)}}(f1,u1)),typeof u1.onActivity=="function"&&this.codemirror.on("cursorActivity",function(p1,m1){return function(){m1.onActivity(p1)}}(f1,u1)),c1.appendChild(f1)}var d1=this.codemirror.getWrapperElement();return d1.parentNode.insertBefore(c1,d1.nextSibling),c1}};EasyMDE.prototype.value=function(n1){var e1=this.codemirror;if(n1===void 0)return e1.getValue();if(e1.getDoc().setValue(n1),this.isPreviewActive()){var t1=e1.getWrapperElement(),r1=t1.lastChild,o1=this.options.previewRender(n1,r1);o1!==null&&(r1.innerHTML=o1)}return this};EasyMDE.toggleBold=toggleBold;EasyMDE.toggleItalic=toggleItalic;EasyMDE.toggleStrikethrough=toggleStrikethrough;EasyMDE.toggleBlockquote=toggleBlockquote;EasyMDE.toggleHeadingSmaller=toggleHeadingSmaller;EasyMDE.toggleHeadingBigger=toggleHeadingBigger;EasyMDE.toggleHeading1=toggleHeading1;EasyMDE.toggleHeading2=toggleHeading2;EasyMDE.toggleHeading3=toggleHeading3;EasyMDE.toggleHeading4=toggleHeading4;EasyMDE.toggleHeading5=toggleHeading5;EasyMDE.toggleHeading6=toggleHeading6;EasyMDE.toggleCodeBlock=toggleCodeBlock;EasyMDE.toggleUnorderedList=toggleUnorderedList;EasyMDE.toggleOrderedList=toggleOrderedList;EasyMDE.cleanBlock=cleanBlock;EasyMDE.drawLink=drawLink;EasyMDE.drawImage=drawImage;EasyMDE.drawUploadedImage=drawUploadedImage;EasyMDE.drawTable=drawTable;EasyMDE.drawHorizontalRule=drawHorizontalRule;EasyMDE.undo=undo$1;EasyMDE.redo=redo$1;EasyMDE.togglePreview=togglePreview;EasyMDE.toggleSideBySide=toggleSideBySide;EasyMDE.toggleFullScreen=toggleFullScreen;EasyMDE.prototype.toggleBold=function(){toggleBold(this)};EasyMDE.prototype.toggleItalic=function(){toggleItalic(this)};EasyMDE.prototype.toggleStrikethrough=function(){toggleStrikethrough(this)};EasyMDE.prototype.toggleBlockquote=function(){toggleBlockquote(this)};EasyMDE.prototype.toggleHeadingSmaller=function(){toggleHeadingSmaller(this)};EasyMDE.prototype.toggleHeadingBigger=function(){toggleHeadingBigger(this)};EasyMDE.prototype.toggleHeading1=function(){toggleHeading1(this)};EasyMDE.prototype.toggleHeading2=function(){toggleHeading2(this)};EasyMDE.prototype.toggleHeading3=function(){toggleHeading3(this)};EasyMDE.prototype.toggleHeading4=function(){toggleHeading4(this)};EasyMDE.prototype.toggleHeading5=function(){toggleHeading5(this)};EasyMDE.prototype.toggleHeading6=function(){toggleHeading6(this)};EasyMDE.prototype.toggleCodeBlock=function(){toggleCodeBlock(this)};EasyMDE.prototype.toggleUnorderedList=function(){toggleUnorderedList(this)};EasyMDE.prototype.toggleOrderedList=function(){toggleOrderedList(this)};EasyMDE.prototype.cleanBlock=function(){cleanBlock(this)};EasyMDE.prototype.drawLink=function(){drawLink(this)};EasyMDE.prototype.drawImage=function(){drawImage(this)};EasyMDE.prototype.drawUploadedImage=function(){drawUploadedImage(this)};EasyMDE.prototype.drawTable=function(){drawTable(this)};EasyMDE.prototype.drawHorizontalRule=function(){drawHorizontalRule(this)};EasyMDE.prototype.undo=function(){undo$1(this)};EasyMDE.prototype.redo=function(){redo$1(this)};EasyMDE.prototype.togglePreview=function(){togglePreview(this)};EasyMDE.prototype.toggleSideBySide=function(){toggleSideBySide(this)};EasyMDE.prototype.toggleFullScreen=function(){toggleFullScreen(this)};EasyMDE.prototype.isPreviewActive=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.lastChild;return t1.classList.contains("editor-preview-active")};EasyMDE.prototype.isSideBySideActive=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.nextSibling;return t1.classList.contains("editor-preview-active-side")};EasyMDE.prototype.isFullscreenActive=function(){var n1=this.codemirror;return n1.getOption("fullScreen")};EasyMDE.prototype.getState=function(){var n1=this.codemirror;return getState(n1)};EasyMDE.prototype.toTextArea=function(){var n1=this.codemirror,e1=n1.getWrapperElement(),t1=e1.parentNode;t1&&(this.gui.toolbar&&t1.removeChild(this.gui.toolbar),this.gui.statusbar&&t1.removeChild(this.gui.statusbar),this.gui.sideBySide&&t1.removeChild(this.gui.sideBySide)),t1.parentNode.insertBefore(e1,t1),t1.remove(),n1.toTextArea(),this.autosaveTimeoutId&&(clearTimeout(this.autosaveTimeoutId),this.autosaveTimeoutId=void 0,this.clearAutosavedValue())};var easymde=EasyMDE;const EasyMDE$1=getDefaultExportFromCjs(easymde),easymde_min="",SpectrumMDE_svelte_svelte_type_style_lang="";function create_fragment$8j(n1){let e1,t1;return{c(){e1=element("div"),t1=element("textarea"),t1.disabled=!0,attr(t1,"id",n1[0]),attr(e1,"style",n1[3]),attr(e1,"class","svelte-1888jbe"),toggle_class(e1,"disabled",n1[1])},m(r1,o1){insert$1(r1,e1,o1),append$1(e1,t1),n1[9](t1)},p(r1,[o1]){o1&1&&attr(t1,"id",r1[0]),o1&8&&attr(e1,"style",r1[3]),o1&2&&toggle_class(e1,"disabled",r1[1])},i:noop$5,o:noop$5,d(r1){r1&&detach(e1),n1[9](null)}}}function instance$8u(n1,e1,t1){let r1,{height:o1=null}=e1,{scroll:i1=!0}=e1,{easyMDEOptions:a1=null}=e1,{mde:s1=null}=e1,{id:l1=null}=e1,{fullScreenOffset:c1=null}=e1,{disabled:u1=!1}=e1,f1;onMount(()=>(t1(4,o1=o1||"200px"),t1(5,s1=new EasyMDE$1({element:f1,spellChecker:!1,status:!1,unorderedListStyle:"-",maxHeight:i1?o1:void 0,minHeight:i1?void 0:o1,...a1})),()=>{s1.toTextArea()}));const d1=m1=>{let _1="";return _1+=`--fullscreen-offset-x:${(m1==null?void 0:m1.x)||"0px"};`,_1+=`--fullscreen-offset-y:${(m1==null?void 0:m1.y)||"0px"};`,_1};function p1(m1){binding_callbacks[m1?"unshift":"push"](()=>{f1=m1,t1(2,f1)})}return n1.$$set=m1=>{"height"in m1&&t1(4,o1=m1.height),"scroll"in m1&&t1(6,i1=m1.scroll),"easyMDEOptions"in m1&&t1(7,a1=m1.easyMDEOptions),"mde"in m1&&t1(5,s1=m1.mde),"id"in m1&&t1(0,l1=m1.id),"fullScreenOffset"in m1&&t1(8,c1=m1.fullScreenOffset),"disabled"in m1&&t1(1,u1=m1.disabled)},n1.$$.update=()=>{n1.$$.dirty&256&&t1(3,r1=d1(c1))},[l1,u1,f1,r1,o1,s1,i1,a1,c1,p1]}class SpectrumMDE extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8u,create_fragment$8j,safe_not_equal,{height:4,scroll:6,easyMDEOptions:7,mde:5,id:0,fullScreenOffset:8,disabled:1})}}function create_key_block$g(n1){let e1,t1,r1;function o1(a1){n1[9](a1)}let i1={scroll:!0,height:n1[1],id:n1[3],fullScreenOffset:n1[4],disabled:n1[5],easyMDEOptions:{initialValue:n1[0],placeholder:n1[2],toolbar:n1[5]||n1[6]?!1:void 0,...n1[7]}};return n1[8]!==void 0&&(i1.mde=n1[8]),e1=new SpectrumMDE({props:i1}),binding_callbacks.push(()=>bind$2(e1,"mde",o1)),{c(){create_component(e1.$$.fragment)},m(a1,s1){mount_component(e1,a1,s1),r1=!0},p(a1,s1){const l1={};s1&2&&(l1.height=a1[1]),s1&8&&(l1.id=a1[3]),s1&16&&(l1.fullScreenOffset=a1[4]),s1&32&&(l1.disabled=a1[5]),s1&229&&(l1.easyMDEOptions={initialValue:a1[0],placeholder:a1[2],toolbar:a1[5]||a1[6]?!1:void 0,...a1[7]}),!t1&&s1&256&&(t1=!0,l1.mde=a1[8],add_flush_callback(()=>t1=!1)),e1.$set(l1)},i(a1){r1||(transition_in(e1.$$.fragment,a1),r1=!0)},o(a1){transition_out(e1.$$.fragment,a1),r1=!1},d(a1){destroy_component(e1,a1)}}}function create_fragment$8i(n1){let e1=n1[1],t1,r1,o1=create_key_block$g(n1);return{c(){o1.c(),t1=empty$1()},m(i1,a1){o1.m(i1,a1),insert$1(i1,t1,a1),r1=!0},p(i1,[a1]){a1&2&&safe_not_equal(e1,e1=i1[1])?(group_outros(),transition_out(o1,1,1,noop$5),check_outros(),o1=create_key_block$g(i1),o1.c(),transition_in(o1,1),o1.m(t1.parentNode,t1)):o1.p(i1,a1)},i(i1){r1||(transition_in(o1),r1=!0)},o(i1){transition_out(o1),r1=!1},d(i1){i1&&detach(t1),o1.d(i1)}}}function instance$8t(n1,e1,t1){let{value:r1=null}=e1,{height:o1=null}=e1,{placeholder:i1=null}=e1,{id:a1=null}=e1,{fullScreenOffset:s1=0}=e1,{disabled:l1=!1}=e1,{readonly:c1=!1}=e1,{easyMDEOptions:u1}=e1;const f1=createEventDispatcher();let d1,p1;const m1=y1=>{p1&&y1!==d1&&p1.value(y1)},g1=((y1,v1)=>{let S1;return()=>{clearTimeout(S1),S1=setTimeout(y1,v1)}})(()=>{d1=p1.value(),f1("change",d1)},250);function $1(y1){p1=y1,t1(8,p1)}return n1.$$set=y1=>{"value"in y1&&t1(0,r1=y1.value),"height"in y1&&t1(1,o1=y1.height),"placeholder"in y1&&t1(2,i1=y1.placeholder),"id"in y1&&t1(3,a1=y1.id),"fullScreenOffset"in y1&&t1(4,s1=y1.fullScreenOffset),"disabled"in y1&&t1(5,l1=y1.disabled),"readonly"in y1&&t1(6,c1=y1.readonly),"easyMDEOptions"in y1&&t1(7,u1=y1.easyMDEOptions)},n1.$$.update=()=>{n1.$$.dirty&1&&m1(r1),n1.$$.dirty&256&&(p1==null||p1.codemirror.on("change",g1)),n1.$$.dirty&352&&(c1||l1)&&(p1==null||p1.togglePreview())},[r1,o1,i1,a1,s1,l1,c1,u1,p1,$1]}class MarkdownEditor extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8t,create_fragment$8i,safe_not_equal,{value:0,height:1,placeholder:2,id:3,fullScreenOffset:4,disabled:5,readonly:6,easyMDEOptions:7})}}const MarkdownViewer_svelte_svelte_type_style_lang="";function create_fragment$8h(n1){let e1,t1,r1;return t1=new MarkdownEditor({props:{value:n1[0],placeholder:n1[1],height:n1[4],id:n1[5],fullScreenOffset:n1[6],disabled:n1[2],easyMDEOptions:n1[7],readonly:n1[3]}}),t1.$on("change",n1[8]),{c(){e1=element("div"),create_component(t1.$$.fragment)},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,[i1]){const a1={};i1&1&&(a1.value=o1[0]),i1&2&&(a1.placeholder=o1[1]),i1&16&&(a1.height=o1[4]),i1&32&&(a1.id=o1[5]),i1&64&&(a1.fullScreenOffset=o1[6]),i1&4&&(a1.disabled=o1[2]),i1&128&&(a1.easyMDEOptions=o1[7]),i1&8&&(a1.readonly=o1[3]),t1.$set(a1)},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function instance$8s(n1,e1,t1){let{value:r1=""}=e1,{placeholder:o1=null}=e1,{disabled:i1=!1}=e1,{readonly:a1=!1}=e1,{height:s1=null}=e1,{id:l1=null}=e1,{fullScreenOffset:c1=null}=e1,{easyMDEOptions:u1=null}=e1;function f1(d1){bubble.call(this,n1,d1)}return n1.$$set=d1=>{"value"in d1&&t1(0,r1=d1.value),"placeholder"in d1&&t1(1,o1=d1.placeholder),"disabled"in d1&&t1(2,i1=d1.disabled),"readonly"in d1&&t1(3,a1=d1.readonly),"height"in d1&&t1(4,s1=d1.height),"id"in d1&&t1(5,l1=d1.id),"fullScreenOffset"in d1&&t1(6,c1=d1.fullScreenOffset),"easyMDEOptions"in d1&&t1(7,u1=d1.easyMDEOptions)},[r1,o1,i1,a1,s1,l1,c1,u1,f1]}class RichTextField extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8s,create_fragment$8h,safe_not_equal,{value:0,placeholder:1,disabled:2,readonly:3,height:4,id:5,fullScreenOffset:6,easyMDEOptions:7})}}function create_default_slot$5e(n1){let e1,t1;return e1=new RichTextField({props:{error:n1[5],disabled:n1[4],value:n1[0],placeholder:n1[3],height:n1[6],id:n1[7],fullScreenOffset:n1[8],easyMDEOptions:n1[9]}}),e1.$on("change",n1[11]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&32&&(i1.error=r1[5]),o1&16&&(i1.disabled=r1[4]),o1&1&&(i1.value=r1[0]),o1&8&&(i1.placeholder=r1[3]),o1&64&&(i1.height=r1[6]),o1&128&&(i1.id=r1[7]),o1&256&&(i1.fullScreenOffset=r1[8]),o1&512&&(i1.easyMDEOptions=r1[9]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$8g(n1){let e1,t1;return e1=new Field({props:{helpText:n1[10],label:n1[1],labelPosition:n1[2],error:n1[5],$$slots:{default:[create_default_slot$5e]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&1024&&(i1.helpText=r1[10]),o1&2&&(i1.label=r1[1]),o1&4&&(i1.labelPosition=r1[2]),o1&32&&(i1.error=r1[5]),o1&9209&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8r(n1,e1,t1){let{value:r1=null}=e1,{label:o1=null}=e1,{labelPosition:i1="above"}=e1,{placeholder:a1=null}=e1,{disabled:s1=!1}=e1,{error:l1=null}=e1,{height:c1=null}=e1,{id:u1=null}=e1,{fullScreenOffset:f1=null}=e1,{easyMDEOptions:d1=null}=e1,{helpText:p1=null}=e1;const m1=createEventDispatcher(),_1=h1=>{t1(0,r1=h1.detail),m1("change",h1.detail)};return n1.$$set=h1=>{"value"in h1&&t1(0,r1=h1.value),"label"in h1&&t1(1,o1=h1.label),"labelPosition"in h1&&t1(2,i1=h1.labelPosition),"placeholder"in h1&&t1(3,a1=h1.placeholder),"disabled"in h1&&t1(4,s1=h1.disabled),"error"in h1&&t1(5,l1=h1.error),"height"in h1&&t1(6,c1=h1.height),"id"in h1&&t1(7,u1=h1.id),"fullScreenOffset"in h1&&t1(8,f1=h1.fullScreenOffset),"easyMDEOptions"in h1&&t1(9,d1=h1.easyMDEOptions),"helpText"in h1&&t1(10,p1=h1.helpText)},[r1,o1,i1,a1,s1,l1,c1,u1,f1,d1,p1,_1]}class RichTextField_1 extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8r,create_fragment$8g,safe_not_equal,{value:0,label:1,labelPosition:2,placeholder:3,disabled:4,error:5,height:6,id:7,fullScreenOffset:8,easyMDEOptions:9,helpText:10})}}const List_svelte_svelte_type_style_lang="",ListItem_svelte_svelte_type_style_lang="",IconSideNav_svelte_svelte_type_style_lang="",IconSideNavItem_svelte_svelte_type_style_lang="",indexVars$1="",Slider_svelte_svelte_type_style_lang="";function create_fragment$8f(n1){let e1,t1,r1,o1;return{c(){e1=element("div"),t1=element("input"),attr(t1,"type","range"),attr(t1,"min",n1[3]),attr(t1,"max",n1[4]),attr(t1,"step",n1[5]),t1.value=n1[0],t1.disabled=n1[2],attr(t1,"id",n1[1]),attr(t1,"class","svelte-13v9q49"),attr(e1,"class","svelte-13v9q49")},m(i1,a1){insert$1(i1,e1,a1),append$1(e1,t1),r1||(o1=listen(t1,"change",n1[6]),r1=!0)},p(i1,[a1]){a1&8&&attr(t1,"min",i1[3]),a1&16&&attr(t1,"max",i1[4]),a1&32&&attr(t1,"step",i1[5]),a1&1&&(t1.value=i1[0]),a1&4&&(t1.disabled=i1[2]),a1&2&&attr(t1,"id",i1[1])},i:noop$5,o:noop$5,d(i1){i1&&detach(e1),r1=!1,o1()}}}function instance$8q(n1,e1,t1){let{value:r1=!1}=e1,{id:o1=null}=e1,{disabled:i1=!1}=e1,{min:a1=0}=e1,{max:s1=100}=e1,{step:l1=1}=e1;const c1=createEventDispatcher(),u1=f1=>{c1("change",f1.target.value)};return n1.$$set=f1=>{"value"in f1&&t1(0,r1=f1.value),"id"in f1&&t1(1,o1=f1.id),"disabled"in f1&&t1(2,i1=f1.disabled),"min"in f1&&t1(3,a1=f1.min),"max"in f1&&t1(4,s1=f1.max),"step"in f1&&t1(5,l1=f1.step)},[r1,o1,i1,a1,s1,l1,u1]}class Slider extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8q,create_fragment$8f,safe_not_equal,{value:0,id:1,disabled:2,min:3,max:4,step:5})}}function create_default_slot$5d(n1){let e1,t1;return e1=new Slider({props:{disabled:n1[6],value:n1[0],min:n1[3],max:n1[4],step:n1[5]}}),e1.$on("change",n1[9]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&64&&(i1.disabled=r1[6]),o1&1&&(i1.value=r1[0]),o1&8&&(i1.min=r1[3]),o1&16&&(i1.max=r1[4]),o1&32&&(i1.step=r1[5]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$8e(n1){let e1,t1;return e1=new Field({props:{helpText:n1[8],label:n1[1],labelPosition:n1[2],error:n1[7],$$slots:{default:[create_default_slot$5d]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&256&&(i1.helpText=r1[8]),o1&2&&(i1.label=r1[1]),o1&4&&(i1.labelPosition=r1[2]),o1&128&&(i1.error=r1[7]),o1&2169&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8p(n1,e1,t1){let{value:r1=null}=e1,{label:o1=null}=e1,{labelPosition:i1="above"}=e1,{min:a1=0}=e1,{max:s1=100}=e1,{step:l1=1}=e1,{disabled:c1=!1}=e1,{error:u1=null}=e1,{helpText:f1=null}=e1;const d1=createEventDispatcher(),p1=m1=>{t1(0,r1=m1.detail),d1("change",m1.detail)};return n1.$$set=m1=>{"value"in m1&&t1(0,r1=m1.value),"label"in m1&&t1(1,o1=m1.label),"labelPosition"in m1&&t1(2,i1=m1.labelPosition),"min"in m1&&t1(3,a1=m1.min),"max"in m1&&t1(4,s1=m1.max),"step"in m1&&t1(5,l1=m1.step),"disabled"in m1&&t1(6,c1=m1.disabled),"error"in m1&&t1(7,u1=m1.error),"helpText"in m1&&t1(8,f1=m1.helpText)},[r1,o1,i1,a1,s1,l1,c1,u1,f1,p1]}class Slider_1 extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8p,create_fragment$8e,safe_not_equal,{value:0,label:1,labelPosition:2,min:3,max:4,step:5,disabled:6,error:7,helpText:8})}}const indexVars="",Accordion_svelte_svelte_type_style_lang="";function create_fragment$8d(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1,u1,f1,d1,p1,m1;const _1=n1[6].default,h1=create_slot(_1,n1,n1[5],null);return{c(){e1=element("div"),t1=element("div"),r1=element("h3"),o1=element("button"),i1=text(n1[1]),a1=space$1(),s1=svg_element("svg"),l1=svg_element("use"),c1=space$1(),u1=element("div"),h1&&h1.c(),attr(o1,"class","spectrum-Accordion-itemHeader svelte-11prom"),attr(o1,"type","button"),xlink_attr(l1,"xlink:href","#spectrum-css-icon-Chevron100"),attr(s1,"class","spectrum-Icon spectrum-UIIcon-ChevronRight100 spectrum-Accordion-itemIndicator"),attr(s1,"focusable","false"),attr(s1,"aria-hidden","true"),attr(r1,"class","spectrum-Accordion-itemHeading"),attr(u1,"class","spectrum-Accordion-itemContent svelte-11prom"),attr(u1,"role",n1[0]),attr(t1,"class",f1="spectrum-Accordion-item "+n1[3](n1[2])+" svelte-11prom"),attr(e1,"class","spectrum-Accordion svelte-11prom"),attr(e1,"role",n1[0])},m(g1,$1){insert$1(g1,e1,$1),append$1(e1,t1),append$1(t1,r1),append$1(r1,o1),append$1(o1,i1),append$1(r1,a1),append$1(r1,s1),append$1(s1,l1),append$1(t1,c1),append$1(t1,u1),h1&&h1.m(u1,null),d1=!0,p1||(m1=listen(o1,"click",n1[7]),p1=!0)},p(g1,[$1]){(!d1||$1&2)&&set_data(i1,g1[1]),h1&&h1.p&&(!d1||$1&32)&&update_slot_base(h1,_1,g1,g1[5],d1?get_slot_changes(_1,g1[5],$1,null):get_all_dirty_from_scope(g1[5]),null),(!d1||$1&1)&&attr(u1,"role",g1[0]),(!d1||$1&4&&f1!==(f1="spectrum-Accordion-item "+g1[3](g1[2])+" svelte-11prom"))&&attr(t1,"class",f1),(!d1||$1&1)&&attr(e1,"role",g1[0])},i(g1){d1||(transition_in(h1,g1),d1=!0)},o(g1){transition_out(h1,g1),d1=!1},d(g1){g1&&detach(e1),h1&&h1.d(g1),p1=!1,m1()}}}function instance$8o(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{itemName:i1}=e1,{initialOpen:a1}=e1,{header:s1}=e1,l1;function c1(f1){return f1===void 0&&(f1=a1),f1?"is-open":""}const u1=()=>t1(2,l1=!l1);return n1.$$set=f1=>{"itemName"in f1&&t1(0,i1=f1.itemName),"initialOpen"in f1&&t1(4,a1=f1.initialOpen),"header"in f1&&t1(1,s1=f1.header),"$$scope"in f1&&t1(5,o1=f1.$$scope)},[i1,s1,l1,c1,a1,o1,r1,u1]}class Accordion extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8o,create_fragment$8d,safe_not_equal,{itemName:0,initialOpen:4,header:1})}}const CheckboxGroup_svelte_svelte_type_style_lang="",File_svelte_svelte_type_style_lang="";function create_if_block$3P(n1){let e1,t1,r1,o1=n1[0].name+"",i1,a1,s1,l1,c1=n1[4]&&create_if_block_4$F(n1),u1=n1[0].size&&create_if_block_2$1d(n1),f1=(!n1[2]||n1[3]===!0&&n1[2])&&create_if_block_1$28(n1);return{c(){e1=element("div"),c1&&c1.c(),t1=space$1(),r1=element("div"),i1=text(o1),a1=space$1(),u1&&u1.c(),s1=space$1(),f1&&f1.c(),attr(r1,"class","filename svelte-hy829z"),attr(e1,"class","file-view svelte-hy829z")},m(d1,p1){insert$1(d1,e1,p1),c1&&c1.m(e1,null),append$1(e1,t1),append$1(e1,r1),append$1(r1,i1),append$1(e1,a1),u1&&u1.m(e1,null),append$1(e1,s1),f1&&f1.m(e1,null),l1=!0},p(d1,p1){d1[4]?c1?c1.p(d1,p1):(c1=create_if_block_4$F(d1),c1.c(),c1.m(e1,t1)):c1&&(c1.d(1),c1=null),(!l1||p1&1)&&o1!==(o1=d1[0].name+"")&&set_data(i1,o1),d1[0].size?u1?u1.p(d1,p1):(u1=create_if_block_2$1d(d1),u1.c(),u1.m(e1,s1)):u1&&(u1.d(1),u1=null),!d1[2]||d1[3]===!0&&d1[2]?f1?(f1.p(d1,p1),p1&12&&transition_in(f1,1)):(f1=create_if_block_1$28(d1),f1.c(),transition_in(f1,1),f1.m(e1,null)):f1&&(group_outros(),transition_out(f1,1,1,()=>{f1=null}),check_outros())},i(d1){l1||(transition_in(f1),l1=!0)},o(d1){transition_out(f1),l1=!1},d(d1){d1&&detach(e1),c1&&c1.d(),u1&&u1.d(),f1&&f1.d()}}}function create_if_block_4$F(n1){let e1,t1;return{c(){e1=element("img"),attr(e1,"class","preview svelte-hy829z"),attr(e1,"alt",""),src_url_equal(e1.src,t1=n1[4])||attr(e1,"src",t1)},m(r1,o1){insert$1(r1,e1,o1)},p(r1,o1){o1&16&&!src_url_equal(e1.src,t1=r1[4])&&attr(e1,"src",t1)},d(r1){r1&&detach(e1)}}}function create_if_block_2$1d(n1){let e1;function t1(i1,a1){return i1[0].size<=BYTES_IN_MB$3?create_if_block_3$T:create_else_block$1p}let r1=t1(n1),o1=r1(n1);return{c(){e1=element("div"),o1.c(),attr(e1,"class","filesize svelte-hy829z")},m(i1,a1){insert$1(i1,e1,a1),o1.m(e1,null)},p(i1,a1){r1===(r1=t1(i1))&&o1?o1.p(i1,a1):(o1.d(1),o1=r1(i1),o1&&(o1.c(),o1.m(e1,null)))},d(i1){i1&&detach(e1),o1.d()}}}function create_else_block$1p(n1){let e1=`${n1[0].size/BYTES_IN_MB$3} MB`,t1;return{c(){t1=text(e1)},m(r1,o1){insert$1(r1,t1,o1)},p(r1,o1){o1&1&&e1!==(e1=`${r1[0].size/BYTES_IN_MB$3} MB`)&&set_data(t1,e1)},d(r1){r1&&detach(t1)}}}function create_if_block_3$T(n1){let e1=`${n1[0].size/BYTES_IN_KB} KB`,t1;return{c(){t1=text(e1)},m(r1,o1){insert$1(r1,t1,o1)},p(r1,o1){o1&1&&e1!==(e1=`${r1[0].size/BYTES_IN_KB} KB`)&&set_data(t1,e1)},d(r1){r1&&detach(t1)}}}function create_if_block_1$28(n1){let e1,t1,r1,o1,i1;return t1=new Icon({props:{name:"Close",size:"XS"}}),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","delete-button svelte-hy829z")},m(a1,s1){insert$1(a1,e1,s1),mount_component(t1,e1,null),r1=!0,o1||(i1=listen(e1,"click",n1[9]),o1=!0)},p:noop$5,i(a1){r1||(transition_in(t1.$$.fragment,a1),r1=!0)},o(a1){transition_out(t1.$$.fragment,a1),r1=!1},d(a1){a1&&detach(e1),destroy_component(t1),o1=!1,i1()}}}function create_default_slot$5c(n1){let e1;return{c(){e1=text(n1[1])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&2&&set_data(e1,t1[1])},d(t1){t1&&detach(e1)}}}function create_fragment$8c(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1=n1[0]&&create_if_block$3P(n1);return i1=new ActionButton({props:{disabled:n1[2],$$slots:{default:[create_default_slot$5c]},$$scope:{ctx:n1}}}),i1.$on("click",function(){is_function(n1[5].click())&&n1[5].click().apply(this,arguments)}),{c(){e1=element("input"),t1=space$1(),r1=element("div"),c1&&c1.c(),o1=space$1(),create_component(i1.$$.fragment),attr(e1,"id",n1[7]),e1.disabled=n1[2],attr(e1,"type","file"),attr(e1,"accept",n1[6]),attr(e1,"class","svelte-hy829z"),attr(r1,"class","field svelte-hy829z")},m(u1,f1){insert$1(u1,e1,f1),n1[14](e1),insert$1(u1,t1,f1),insert$1(u1,r1,f1),c1&&c1.m(r1,null),append$1(r1,o1),mount_component(i1,r1,null),a1=!0,s1||(l1=listen(e1,"change",n1[8]),s1=!0)},p(u1,[f1]){n1=u1,(!a1||f1&4)&&(e1.disabled=n1[2]),(!a1||f1&64)&&attr(e1,"accept",n1[6]),n1[0]?c1?(c1.p(n1,f1),f1&1&&transition_in(c1,1)):(c1=create_if_block$3P(n1),c1.c(),transition_in(c1,1),c1.m(r1,o1)):c1&&(group_outros(),transition_out(c1,1,1,()=>{c1=null}),check_outros());const d1={};f1&4&&(d1.disabled=n1[2]),f1&131074&&(d1.$$scope={dirty:f1,ctx:n1}),i1.$set(d1)},i(u1){a1||(transition_in(c1),transition_in(i1.$$.fragment,u1),a1=!0)},o(u1){transition_out(c1),transition_out(i1.$$.fragment,u1),a1=!1},d(u1){u1&&detach(e1),n1[14](null),u1&&detach(t1),u1&&detach(r1),c1&&c1.d(),destroy_component(i1),s1=!1,l1()}}}const BYTES_IN_KB=1e3,BYTES_IN_MB$3=1e6;function instance$8n(n1,e1,t1){let r1,{value:o1=null}=e1,{title:i1="Upload file"}=e1,{disabled:a1=!1}=e1,{allowClear:s1=null}=e1,{extensions:l1=null}=e1,{handleFileTooLarge:c1=null}=e1,{fileSizeLimit:u1=BYTES_IN_MB$3*20}=e1,{id:f1=null}=e1,{previewUrl:d1=null}=e1;const p1=f1||uuid(),m1=createEventDispatcher();let _1;async function h1(v1){if(c1&&(v1==null?void 0:v1.size)>=u1){c1(v1);return}m1("change",v1)}function g1(v1){h1(v1.target.files[0])}function $1(){m1("change",null)}function y1(v1){binding_callbacks[v1?"unshift":"push"](()=>{_1=v1,t1(5,_1)})}return n1.$$set=v1=>{"value"in v1&&t1(0,o1=v1.value),"title"in v1&&t1(1,i1=v1.title),"disabled"in v1&&t1(2,a1=v1.disabled),"allowClear"in v1&&t1(3,s1=v1.allowClear),"extensions"in v1&&t1(10,l1=v1.extensions),"handleFileTooLarge"in v1&&t1(11,c1=v1.handleFileTooLarge),"fileSizeLimit"in v1&&t1(12,u1=v1.fileSizeLimit),"id"in v1&&t1(13,f1=v1.id),"previewUrl"in v1&&t1(4,d1=v1.previewUrl)},n1.$$.update=()=>{n1.$$.dirty&1024&&t1(6,r1=Array.isArray(l1)?l1.join(","):"*")},[o1,i1,a1,s1,d1,_1,r1,p1,g1,$1,l1,c1,u1,f1,y1]}let File$2=class extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8n,create_fragment$8c,safe_not_equal,{value:0,title:1,disabled:2,allowClear:3,extensions:10,handleFileTooLarge:11,fileSizeLimit:12,id:13,previewUrl:4})}};function create_default_slot$5b(n1){let e1,t1;return e1=new File$2({props:{error:n1[8],disabled:n1[3],allowClear:n1[4],title:n1[9],value:n1[0],previewUrl:n1[6],handleFileTooLarge:n1[5],extensions:n1[7]}}),e1.$on("change",n1[12]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&256&&(i1.error=r1[8]),o1&8&&(i1.disabled=r1[3]),o1&16&&(i1.allowClear=r1[4]),o1&512&&(i1.title=r1[9]),o1&1&&(i1.value=r1[0]),o1&64&&(i1.previewUrl=r1[6]),o1&32&&(i1.handleFileTooLarge=r1[5]),o1&128&&(i1.extensions=r1[7]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$8b(n1){let e1,t1;return e1=new Field({props:{helpText:n1[11],label:n1[1],labelPosition:n1[2],error:n1[8],tooltip:n1[10],$$slots:{default:[create_default_slot$5b]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&2048&&(i1.helpText=r1[11]),o1&2&&(i1.label=r1[1]),o1&4&&(i1.labelPosition=r1[2]),o1&256&&(i1.error=r1[8]),o1&1024&&(i1.tooltip=r1[10]),o1&17401&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8m(n1,e1,t1){let{label:r1=null}=e1,{labelPosition:o1="above"}=e1,{disabled:i1=!1}=e1,{allowClear:a1=null}=e1,{handleFileTooLarge:s1=()=>{}}=e1,{previewUrl:l1=null}=e1,{extensions:c1=null}=e1,{error:u1=null}=e1,{title:f1=null}=e1,{value:d1=null}=e1,{tooltip:p1=null}=e1,{helpText:m1=null}=e1;const _1=createEventDispatcher(),h1=g1=>{t1(0,d1=g1.detail),_1("change",g1.detail)};return n1.$$set=g1=>{"label"in g1&&t1(1,r1=g1.label),"labelPosition"in g1&&t1(2,o1=g1.labelPosition),"disabled"in g1&&t1(3,i1=g1.disabled),"allowClear"in g1&&t1(4,a1=g1.allowClear),"handleFileTooLarge"in g1&&t1(5,s1=g1.handleFileTooLarge),"previewUrl"in g1&&t1(6,l1=g1.previewUrl),"extensions"in g1&&t1(7,c1=g1.extensions),"error"in g1&&t1(8,u1=g1.error),"title"in g1&&t1(9,f1=g1.title),"value"in g1&&t1(0,d1=g1.value),"tooltip"in g1&&t1(10,p1=g1.tooltip),"helpText"in g1&&t1(11,m1=g1.helpText)},[d1,r1,o1,i1,a1,s1,l1,c1,u1,f1,p1,m1,h1]}let File$1=class extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8m,create_fragment$8b,safe_not_equal,{label:1,labelPosition:2,disabled:3,allowClear:4,handleFileTooLarge:5,previewUrl:6,extensions:7,error:8,title:9,value:0,tooltip:10,helpText:11})}};function flip(n1,{from:e1,to:t1},r1={}){const o1=getComputedStyle(n1),i1=o1.transform==="none"?"":o1.transform,[a1,s1]=o1.transformOrigin.split(" ").map(parseFloat),l1=e1.left+e1.width*a1/t1.width-(t1.left+a1),c1=e1.top+e1.height*s1/t1.height-(t1.top+s1),{delay:u1=0,duration:f1=p1=>Math.sqrt(p1)*120,easing:d1=cubicOut}=r1;return{delay:u1,duration:is_function(f1)?f1(Math.sqrt(l1*l1+c1*c1)):f1,easing:d1,css:(p1,m1)=>{const _1=m1*l1,h1=m1*c1,g1=p1+m1*e1.width/t1.width,$1=p1+m1*e1.height/t1.height;return`transform: ${i1} translate(${_1}px, ${h1}px) scale(${g1}, ${$1});`}}}const FINALIZE_EVENT_NAME="finalize",CONSIDER_EVENT_NAME="consider";function dispatchFinalizeEvent(n1,e1,t1){n1.dispatchEvent(new CustomEvent(FINALIZE_EVENT_NAME,{detail:{items:e1,info:t1}}))}function dispatchConsiderEvent(n1,e1,t1){n1.dispatchEvent(new CustomEvent(CONSIDER_EVENT_NAME,{detail:{items:e1,info:t1}}))}const DRAGGED_ENTERED_EVENT_NAME="draggedEntered",DRAGGED_LEFT_EVENT_NAME="draggedLeft",DRAGGED_OVER_INDEX_EVENT_NAME="draggedOverIndex",DRAGGED_LEFT_DOCUMENT_EVENT_NAME="draggedLeftDocument",DRAGGED_LEFT_TYPES={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function dispatchDraggedElementEnteredContainer(n1,e1,t1){n1.dispatchEvent(new CustomEvent(DRAGGED_ENTERED_EVENT_NAME,{detail:{indexObj:e1,draggedEl:t1}}))}function dispatchDraggedElementLeftContainerForAnother(n1,e1,t1){n1.dispatchEvent(new CustomEvent(DRAGGED_LEFT_EVENT_NAME,{detail:{draggedEl:e1,type:DRAGGED_LEFT_TYPES.LEFT_FOR_ANOTHER,theOtherDz:t1}}))}function dispatchDraggedElementLeftContainerForNone(n1,e1){n1.dispatchEvent(new CustomEvent(DRAGGED_LEFT_EVENT_NAME,{detail:{draggedEl:e1,type:DRAGGED_LEFT_TYPES.OUTSIDE_OF_ANY}}))}function dispatchDraggedElementIsOverIndex(n1,e1,t1){n1.dispatchEvent(new CustomEvent(DRAGGED_OVER_INDEX_EVENT_NAME,{detail:{indexObj:e1,draggedEl:t1}}))}function dispatchDraggedLeftDocument(n1){window.dispatchEvent(new CustomEvent(DRAGGED_LEFT_DOCUMENT_EVENT_NAME,{detail:{draggedEl:n1}}))}const TRIGGERS={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:DRAGGED_ENTERED_EVENT_NAME,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:DRAGGED_OVER_INDEX_EVENT_NAME,DRAGGED_LEFT:DRAGGED_LEFT_EVENT_NAME,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},SOURCES={POINTER:"pointer",KEYBOARD:"keyboard"},SHADOW_ITEM_MARKER_PROPERTY_NAME="isDndShadowItem",SHADOW_ELEMENT_ATTRIBUTE_NAME="data-is-dnd-shadow-item",SHADOW_PLACEHOLDER_ITEM_ID="id:dnd-shadow-placeholder-0000",DRAGGED_ELEMENT_ID="dnd-action-dragged-el";let ITEM_ID_KEY="id",activeDndZoneCount=0;function incrementActiveDropZoneCount(){activeDndZoneCount++}function decrementActiveDropZoneCount(){if(activeDndZoneCount===0)throw new Error("Bug! trying to decrement when there are no dropzones");activeDndZoneCount--}const isOnServer=typeof window>"u";function getBoundingRectNoTransforms(n1){let e1;const t1=n1.getBoundingClientRect(),r1=getComputedStyle(n1),o1=r1.transform;if(o1){let i1,a1,s1,l1;if(o1.startsWith("matrix3d("))e1=o1.slice(9,-1).split(/, /),i1=+e1[0],a1=+e1[5],s1=+e1[12],l1=+e1[13];else if(o1.startsWith("matrix("))e1=o1.slice(7,-1).split(/, /),i1=+e1[0],a1=+e1[3],s1=+e1[4],l1=+e1[5];else return t1;const c1=r1.transformOrigin,u1=t1.x-s1-(1-i1)*parseFloat(c1),f1=t1.y-l1-(1-a1)*parseFloat(c1.slice(c1.indexOf(" ")+1)),d1=i1?t1.width/i1:n1.offsetWidth,p1=a1?t1.height/a1:n1.offsetHeight;return{x:u1,y:f1,width:d1,height:p1,top:f1,right:u1+d1,bottom:f1+p1,left:u1}}else return t1}function getAbsoluteRectNoTransforms(n1){const e1=getBoundingRectNoTransforms(n1);return{top:e1.top+window.scrollY,bottom:e1.bottom+window.scrollY,left:e1.left+window.scrollX,right:e1.right+window.scrollX}}function getAbsoluteRect(n1){const e1=n1.getBoundingClientRect();return{top:e1.top+window.scrollY,bottom:e1.bottom+window.scrollY,left:e1.left+window.scrollX,right:e1.right+window.scrollX}}function findCenter(n1){return{x:(n1.left+n1.right)/2,y:(n1.top+n1.bottom)/2}}function calcDistance(n1,e1){return Math.sqrt(Math.pow(n1.x-e1.x,2)+Math.pow(n1.y-e1.y,2))}function isPointInsideRect(n1,e1){return n1.y<=e1.bottom&&n1.y>=e1.top&&n1.x>=e1.left&&n1.x<=e1.right}function findCenterOfElement(n1){return findCenter(getAbsoluteRect(n1))}function isCenterOfAInsideB(n1,e1){const t1=findCenterOfElement(n1),r1=getAbsoluteRectNoTransforms(e1);return isPointInsideRect(t1,r1)}function calcDistanceBetweenCenters(n1,e1){const t1=findCenterOfElement(n1),r1=findCenterOfElement(e1);return calcDistance(t1,r1)}function isElementOffDocument(n1){const e1=getAbsoluteRect(n1);return e1.right<0||e1.left>document.documentElement.scrollWidth||e1.bottom<0||e1.top>document.documentElement.scrollHeight}function calcInnerDistancesBetweenPointAndSidesOfElement(n1,e1){const t1=getAbsoluteRect(e1);return isPointInsideRect(n1,t1)?{top:n1.y-t1.top,bottom:t1.bottom-n1.y,left:n1.x-t1.left,right:Math.min(t1.right,document.documentElement.clientWidth)-n1.x}:null}let dzToShadowIndexToRect;function resetIndexesCache(){dzToShadowIndexToRect=new Map}resetIndexesCache();function resetIndexesCacheForDz(n1){dzToShadowIndexToRect.delete(n1)}function cacheShadowRect(n1){const e1=Array.from(n1.children).findIndex(t1=>t1.getAttribute(SHADOW_ELEMENT_ATTRIBUTE_NAME));if(e1>=0)return dzToShadowIndexToRect.has(n1)||dzToShadowIndexToRect.set(n1,new Map),dzToShadowIndexToRect.get(n1).set(e1,getAbsoluteRectNoTransforms(n1.children[e1])),e1}function findWouldBeIndex(n1,e1){if(!isCenterOfAInsideB(n1,e1))return null;const t1=e1.children;if(t1.length===0)return{index:0,isProximityBased:!0};const r1=cacheShadowRect(e1);for(let a1=0;a1<t1.length;a1++)if(isCenterOfAInsideB(n1,t1[a1])){const s1=dzToShadowIndexToRect.has(e1)&&dzToShadowIndexToRect.get(e1).get(a1);return s1&&!isPointInsideRect(findCenterOfElement(n1),s1)?{index:r1,isProximityBased:!1}:{index:a1,isProximityBased:!1}}let o1=Number.MAX_VALUE,i1;for(let a1=0;a1<t1.length;a1++){const s1=calcDistanceBetweenCenters(n1,t1[a1]);s1<o1&&(o1=s1,i1=a1)}return{index:i1,isProximityBased:!0}}const SCROLL_ZONE_PX=25;function makeScroller(){let n1;function e1(){n1={directionObj:void 0,stepPx:0}}e1();function t1(i1){const{directionObj:a1,stepPx:s1}=n1;a1&&(i1.scrollBy(a1.x*s1,a1.y*s1),window.requestAnimationFrame(()=>t1(i1)))}function r1(i1){return SCROLL_ZONE_PX-i1}function o1(i1,a1){if(!a1)return!1;const s1=calcInnerDistancesBetweenPointAndSidesOfElement(i1,a1);if(s1===null)return e1(),!1;const l1=!!n1.directionObj;let[c1,u1]=[!1,!1];return a1.scrollHeight>a1.clientHeight&&(s1.bottom<SCROLL_ZONE_PX?(c1=!0,n1.directionObj={x:0,y:1},n1.stepPx=r1(s1.bottom)):s1.top<SCROLL_ZONE_PX&&(c1=!0,n1.directionObj={x:0,y:-1},n1.stepPx=r1(s1.top)),!l1&&c1)||a1.scrollWidth>a1.clientWidth&&(s1.right<SCROLL_ZONE_PX?(u1=!0,n1.directionObj={x:1,y:0},n1.stepPx=r1(s1.right)):s1.left<SCROLL_ZONE_PX&&(u1=!0,n1.directionObj={x:-1,y:0},n1.stepPx=r1(s1.left)),!l1&&u1)?(t1(a1),!0):(e1(),!1)}return{scrollIfNeeded:o1,resetScrolling:e1}}function toString$6(n1){return JSON.stringify(n1,null,2)}function getDepth(n1){if(!n1)throw new Error("cannot get depth of a falsy node");return _getDepth(n1,0)}function _getDepth(n1,e1=0){return n1.parentElement?_getDepth(n1.parentElement,e1+1):e1-1}function areObjectsShallowEqual(n1,e1){if(Object.keys(n1).length!==Object.keys(e1).length)return!1;for(const t1 in n1)if(!{}.hasOwnProperty.call(e1,t1)||e1[t1]!==n1[t1])return!1;return!0}function areArraysShallowEqualSameOrder(n1,e1){if(n1.length!==e1.length)return!1;for(let t1=0;t1<n1.length;t1++)if(n1[t1]!==e1[t1])return!1;return!0}const INTERVAL_MS$1=200,TOLERANCE_PX=10,{scrollIfNeeded:scrollIfNeeded$1,resetScrolling:resetScrolling$1}=makeScroller();let next$1;function observe$2(n1,e1,t1=INTERVAL_MS$1){let r1,o1,i1=!1,a1;const s1=Array.from(e1).sort((c1,u1)=>getDepth(u1)-getDepth(c1));function l1(){const c1=findCenterOfElement(n1),u1=scrollIfNeeded$1(c1,r1);if(!u1&&a1&&Math.abs(a1.x-c1.x)<TOLERANCE_PX&&Math.abs(a1.y-c1.y)<TOLERANCE_PX){next$1=window.setTimeout(l1,t1);return}if(isElementOffDocument(n1)){dispatchDraggedLeftDocument(n1);return}a1=c1;let f1=!1;for(const d1 of s1){u1&&resetIndexesCacheForDz(r1);const p1=findWouldBeIndex(n1,d1);if(p1===null)continue;const{index:m1}=p1;f1=!0,d1!==r1?(r1&&dispatchDraggedElementLeftContainerForAnother(r1,n1,d1),dispatchDraggedElementEnteredContainer(d1,p1,n1),r1=d1):m1!==o1&&(dispatchDraggedElementIsOverIndex(d1,p1,n1),o1=m1);break}!f1&&i1&&r1?(dispatchDraggedElementLeftContainerForNone(r1,n1),r1=void 0,o1=void 0,i1=!1):i1=!0,next$1=window.setTimeout(l1,t1)}l1()}function unobserve$1(){clearTimeout(next$1),resetScrolling$1(),resetIndexesCache()}const INTERVAL_MS=300;let mousePosition;function updateMousePosition(n1){const e1=n1.touches?n1.touches[0]:n1;mousePosition={x:e1.clientX,y:e1.clientY}}const{scrollIfNeeded,resetScrolling}=makeScroller();let next;function loop(){mousePosition&&scrollIfNeeded(mousePosition,document.documentElement)&&resetIndexesCache(),next=window.setTimeout(loop,INTERVAL_MS)}function armWindowScroller(){window.addEventListener("mousemove",updateMousePosition),window.addEventListener("touchmove",updateMousePosition),loop()}function disarmWindowScroller(){window.removeEventListener("mousemove",updateMousePosition),window.removeEventListener("touchmove",updateMousePosition),mousePosition=void 0,window.clearTimeout(next),resetScrolling()}function svelteNodeClone(n1){const e1=n1.cloneNode(!0),t1=[],r1=n1.tagName==="SELECT",o1=r1?[n1]:[...n1.querySelectorAll("select")];for(const a1 of o1)t1.push(a1.value);if(o1.length<=0)return e1;const i1=r1?[e1]:[...e1.querySelectorAll("select")];for(let a1=0;a1<i1.length;a1++){const s1=i1[a1],l1=t1[a1],c1=s1.querySelector(`option[value="${l1}"`);c1&&c1.setAttribute("selected",!0)}return e1}const TRANSITION_DURATION_SECONDS=.2;function trs(n1){return`${n1} ${TRANSITION_DURATION_SECONDS}s ease`}function createDraggedElementFrom(n1,e1){const t1=n1.getBoundingClientRect(),r1=svelteNodeClone(n1);copyStylesFromTo(n1,r1),r1.id=DRAGGED_ELEMENT_ID,r1.style.position="fixed";let o1=t1.top,i1=t1.left;if(r1.style.top=`${o1}px`,r1.style.left=`${i1}px`,e1){const a1=findCenter(t1);o1-=a1.y-e1.y,i1-=a1.x-e1.x,window.setTimeout(()=>{r1.style.top=`${o1}px`,r1.style.left=`${i1}px`},0)}return r1.style.margin="0",r1.style.boxSizing="border-box",r1.style.height=`${t1.height}px`,r1.style.width=`${t1.width}px`,r1.style.transition=`${trs("top")}, ${trs("left")}, ${trs("background-color")}, ${trs("opacity")}, ${trs("color")} `,window.setTimeout(()=>r1.style.transition+=`, ${trs("width")}, ${trs("height")}`,0),r1.style.zIndex="9999",r1.style.cursor="grabbing",r1}function moveDraggedElementToWasDroppedState(n1){n1.style.cursor="grab"}function morphDraggedElementToBeLike(n1,e1,t1,r1){copyStylesFromTo(e1,n1);const o1=e1.getBoundingClientRect(),i1=n1.getBoundingClientRect(),a1=o1.width-i1.width,s1=o1.height-i1.height;if(a1||s1){const l1={left:(t1-i1.left)/i1.width,top:(r1-i1.top)/i1.height};n1.style.height=`${o1.height}px`,n1.style.width=`${o1.width}px`,n1.style.left=`${parseFloat(n1.style.left)-l1.left*a1}px`,n1.style.top=`${parseFloat(n1.style.top)-l1.top*s1}px`}}function copyStylesFromTo(n1,e1){const t1=window.getComputedStyle(n1);Array.from(t1).filter(r1=>r1.startsWith("background")||r1.startsWith("padding")||r1.startsWith("font")||r1.startsWith("text")||r1.startsWith("align")||r1.startsWith("justify")||r1.startsWith("display")||r1.startsWith("flex")||r1.startsWith("border")||r1==="opacity"||r1==="color"||r1==="list-style-type").forEach(r1=>e1.style.setProperty(r1,t1.getPropertyValue(r1),t1.getPropertyPriority(r1)))}function styleDraggable(n1,e1){n1.draggable=!1,n1.ondragstart=()=>!1,e1?(n1.style.userSelect="",n1.style.WebkitUserSelect="",n1.style.cursor=""):(n1.style.userSelect="none",n1.style.WebkitUserSelect="none",n1.style.cursor="grab")}function hideElement(n1){n1.style.display="none",n1.style.position="fixed",n1.style.zIndex="-5"}function decorateShadowEl(n1){n1.style.visibility="hidden",n1.setAttribute(SHADOW_ELEMENT_ATTRIBUTE_NAME,"true")}function unDecorateShadowElement(n1){n1.style.visibility="",n1.removeAttribute(SHADOW_ELEMENT_ATTRIBUTE_NAME)}function styleActiveDropZones(n1,e1=()=>{},t1=()=>[]){n1.forEach(r1=>{const o1=e1(r1);Object.keys(o1).forEach(i1=>{r1.style[i1]=o1[i1]}),t1(r1).forEach(i1=>r1.classList.add(i1))})}function styleInactiveDropZones(n1,e1=()=>{},t1=()=>[]){n1.forEach(r1=>{const o1=e1(r1);Object.keys(o1).forEach(i1=>{r1.style[i1]=""}),t1(r1).forEach(i1=>r1.classList.contains(i1)&&r1.classList.remove(i1))})}function preventShrinking(n1){const e1=n1.style.minHeight;n1.style.minHeight=window.getComputedStyle(n1).getPropertyValue("height");const t1=n1.style.minWidth;return n1.style.minWidth=window.getComputedStyle(n1).getPropertyValue("width"),function(){n1.style.minHeight=e1,n1.style.minWidth=t1}}const DEFAULT_DROP_ZONE_TYPE$1="--any--",MIN_OBSERVATION_INTERVAL_MS=100,MIN_MOVEMENT_BEFORE_DRAG_START_PX=3,DEFAULT_DROP_TARGET_STYLE$1={outline:"rgba(255, 255, 102, 0.7) solid 2px"};let originalDragTarget,draggedEl,draggedElData,draggedElType,originDropZone,originIndex,shadowElData,shadowElDropZone,dragStartMousePosition,currentMousePosition,isWorkingOnPreviousDrag=!1,finalizingPreviousDrag=!1,unlockOriginDzMinDimensions,isDraggedOutsideOfAnyDz=!1,scheduledForRemovalAfterDrop=[];const typeToDropZones$1=new Map,dzToConfig$1=new Map,elToMouseDownListener=new WeakMap;function registerDropZone$1(n1,e1){typeToDropZones$1.has(e1)||typeToDropZones$1.set(e1,new Set),typeToDropZones$1.get(e1).has(n1)||(typeToDropZones$1.get(e1).add(n1),incrementActiveDropZoneCount())}function unregisterDropZone$1(n1,e1){typeToDropZones$1.get(e1).delete(n1),decrementActiveDropZoneCount(),typeToDropZones$1.get(e1).size===0&&typeToDropZones$1.delete(e1)}function watchDraggedElement(){armWindowScroller();const n1=typeToDropZones$1.get(draggedElType);for(const t1 of n1)t1.addEventListener(DRAGGED_ENTERED_EVENT_NAME,handleDraggedEntered),t1.addEventListener(DRAGGED_LEFT_EVENT_NAME,handleDraggedLeft),t1.addEventListener(DRAGGED_OVER_INDEX_EVENT_NAME,handleDraggedIsOverIndex);window.addEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME,handleDrop$1);const e1=Math.max(MIN_OBSERVATION_INTERVAL_MS,...Array.from(n1.keys()).map(t1=>dzToConfig$1.get(t1).dropAnimationDurationMs));observe$2(draggedEl,n1,e1*1.07)}function unWatchDraggedElement(){disarmWindowScroller();const n1=typeToDropZones$1.get(draggedElType);for(const e1 of n1)e1.removeEventListener(DRAGGED_ENTERED_EVENT_NAME,handleDraggedEntered),e1.removeEventListener(DRAGGED_LEFT_EVENT_NAME,handleDraggedLeft),e1.removeEventListener(DRAGGED_OVER_INDEX_EVENT_NAME,handleDraggedIsOverIndex);window.removeEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME,handleDrop$1),unobserve$1()}function findShadowPlaceHolderIdx(n1){return n1.findIndex(e1=>e1[ITEM_ID_KEY]===SHADOW_PLACEHOLDER_ITEM_ID)}function findShadowElementIdx(n1){return n1.findIndex(e1=>!!e1[SHADOW_ITEM_MARKER_PROPERTY_NAME]&&e1[ITEM_ID_KEY]!==SHADOW_PLACEHOLDER_ITEM_ID)}function handleDraggedEntered(n1){let{items:e1,dropFromOthersDisabled:t1}=dzToConfig$1.get(n1.currentTarget);if(t1&&n1.currentTarget!==originDropZone)return;if(isDraggedOutsideOfAnyDz=!1,e1=e1.filter(a1=>a1[ITEM_ID_KEY]!==shadowElData[ITEM_ID_KEY]),originDropZone!==n1.currentTarget){const s1=dzToConfig$1.get(originDropZone).items.filter(l1=>!l1[SHADOW_ITEM_MARKER_PROPERTY_NAME]);dispatchConsiderEvent(originDropZone,s1,{trigger:TRIGGERS.DRAGGED_ENTERED_ANOTHER,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}else{const a1=findShadowPlaceHolderIdx(e1);a1!==-1&&e1.splice(a1,1)}const{index:r1,isProximityBased:o1}=n1.detail.indexObj,i1=o1&&r1===n1.currentTarget.children.length-1?r1+1:r1;shadowElDropZone=n1.currentTarget,e1.splice(i1,0,shadowElData),dispatchConsiderEvent(n1.currentTarget,e1,{trigger:TRIGGERS.DRAGGED_ENTERED,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}function handleDraggedLeft(n1){if(!isWorkingOnPreviousDrag)return;const{items:e1,dropFromOthersDisabled:t1}=dzToConfig$1.get(n1.currentTarget);if(t1&&n1.currentTarget!==originDropZone&&n1.currentTarget!==shadowElDropZone)return;const r1=findShadowElementIdx(e1),o1=e1.splice(r1,1)[0];shadowElDropZone=void 0;const{type:i1,theOtherDz:a1}=n1.detail;if(i1===DRAGGED_LEFT_TYPES.OUTSIDE_OF_ANY||i1===DRAGGED_LEFT_TYPES.LEFT_FOR_ANOTHER&&a1!==originDropZone&&dzToConfig$1.get(a1).dropFromOthersDisabled){isDraggedOutsideOfAnyDz=!0,shadowElDropZone=originDropZone;const s1=dzToConfig$1.get(originDropZone).items;s1.splice(originIndex,0,o1),dispatchConsiderEvent(originDropZone,s1,{trigger:TRIGGERS.DRAGGED_LEFT_ALL,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}dispatchConsiderEvent(n1.currentTarget,e1,{trigger:TRIGGERS.DRAGGED_LEFT,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}function handleDraggedIsOverIndex(n1){const{items:e1,dropFromOthersDisabled:t1}=dzToConfig$1.get(n1.currentTarget);if(t1&&n1.currentTarget!==originDropZone)return;isDraggedOutsideOfAnyDz=!1;const{index:r1}=n1.detail.indexObj,o1=findShadowElementIdx(e1);e1.splice(o1,1),e1.splice(r1,0,shadowElData),dispatchConsiderEvent(n1.currentTarget,e1,{trigger:TRIGGERS.DRAGGED_OVER_INDEX,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER})}function handleMouseMove(n1){n1.preventDefault();const e1=n1.touches?n1.touches[0]:n1;currentMousePosition={x:e1.clientX,y:e1.clientY},draggedEl.style.transform=`translate3d(${currentMousePosition.x-dragStartMousePosition.x}px, ${currentMousePosition.y-dragStartMousePosition.y}px, 0)`}function handleDrop$1(){finalizingPreviousDrag=!0,window.removeEventListener("mousemove",handleMouseMove),window.removeEventListener("touchmove",handleMouseMove),window.removeEventListener("mouseup",handleDrop$1),window.removeEventListener("touchend",handleDrop$1),unWatchDraggedElement(),moveDraggedElementToWasDroppedState(draggedEl),shadowElDropZone||(shadowElDropZone=originDropZone);let{items:n1,type:e1}=dzToConfig$1.get(shadowElDropZone);styleInactiveDropZones(typeToDropZones$1.get(e1),o1=>dzToConfig$1.get(o1).dropTargetStyle,o1=>dzToConfig$1.get(o1).dropTargetClasses);let t1=findShadowElementIdx(n1);t1===-1&&(t1=originIndex),n1=n1.map(o1=>o1[SHADOW_ITEM_MARKER_PROPERTY_NAME]?draggedElData:o1);function r1(){unlockOriginDzMinDimensions(),dispatchFinalizeEvent(shadowElDropZone,n1,{trigger:isDraggedOutsideOfAnyDz?TRIGGERS.DROPPED_OUTSIDE_OF_ANY:TRIGGERS.DROPPED_INTO_ZONE,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER}),shadowElDropZone!==originDropZone&&dispatchFinalizeEvent(originDropZone,dzToConfig$1.get(originDropZone).items,{trigger:TRIGGERS.DROPPED_INTO_ANOTHER,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER}),unDecorateShadowElement(shadowElDropZone.children[t1]),cleanupPostDrop()}animateDraggedToFinalPosition(t1,r1)}function animateDraggedToFinalPosition(n1,e1){const t1=getBoundingRectNoTransforms(shadowElDropZone.children[n1]),r1={x:t1.left-parseFloat(draggedEl.style.left),y:t1.top-parseFloat(draggedEl.style.top)},{dropAnimationDurationMs:o1}=dzToConfig$1.get(shadowElDropZone),i1=`transform ${o1}ms ease`;draggedEl.style.transition=draggedEl.style.transition?draggedEl.style.transition+","+i1:i1,draggedEl.style.transform=`translate3d(${r1.x}px, ${r1.y}px, 0)`,window.setTimeout(e1,o1)}function scheduleDZForRemovalAfterDrop(n1,e1){scheduledForRemovalAfterDrop.push({dz:n1,destroy:e1}),window.requestAnimationFrame(()=>{hideElement(n1),document.body.appendChild(n1)})}function cleanupPostDrop(){draggedEl.remove(),originalDragTarget.remove(),scheduledForRemovalAfterDrop.length&&(scheduledForRemovalAfterDrop.forEach(({dz:n1,destroy:e1})=>{e1(),n1.remove()}),scheduledForRemovalAfterDrop=[]),draggedEl=void 0,originalDragTarget=void 0,draggedElData=void 0,draggedElType=void 0,originDropZone=void 0,originIndex=void 0,shadowElData=void 0,shadowElDropZone=void 0,dragStartMousePosition=void 0,currentMousePosition=void 0,isWorkingOnPreviousDrag=!1,finalizingPreviousDrag=!1,unlockOriginDzMinDimensions=void 0,isDraggedOutsideOfAnyDz=!1}function dndzone$2(n1,e1){let t1=!1;const r1={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:DEFAULT_DROP_TARGET_STYLE$1,dropTargetClasses:[],transformDraggedElement:()=>{},centreDraggedOnCursor:!1};let o1=new Map;function i1(){window.addEventListener("mousemove",l1,{passive:!1}),window.addEventListener("touchmove",l1,{passive:!1,capture:!1}),window.addEventListener("mouseup",s1,{passive:!1}),window.addEventListener("touchend",s1,{passive:!1})}function a1(){window.removeEventListener("mousemove",l1),window.removeEventListener("touchmove",l1),window.removeEventListener("mouseup",s1),window.removeEventListener("touchend",s1)}function s1(){a1(),originalDragTarget=void 0,dragStartMousePosition=void 0,currentMousePosition=void 0}function l1(d1){d1.preventDefault();const p1=d1.touches?d1.touches[0]:d1;currentMousePosition={x:p1.clientX,y:p1.clientY},(Math.abs(currentMousePosition.x-dragStartMousePosition.x)>=MIN_MOVEMENT_BEFORE_DRAG_START_PX||Math.abs(currentMousePosition.y-dragStartMousePosition.y)>=MIN_MOVEMENT_BEFORE_DRAG_START_PX)&&(a1(),u1())}function c1(d1){if(d1.target!==d1.currentTarget&&(d1.target.value!==void 0||d1.target.isContentEditable)||d1.button||isWorkingOnPreviousDrag)return;d1.stopPropagation();const p1=d1.touches?d1.touches[0]:d1;dragStartMousePosition={x:p1.clientX,y:p1.clientY},currentMousePosition={...dragStartMousePosition},originalDragTarget=d1.currentTarget,i1()}function u1(){isWorkingOnPreviousDrag=!0;const d1=o1.get(originalDragTarget);originIndex=d1,originDropZone=originalDragTarget.parentElement;const p1=originDropZone.getRootNode(),m1=p1.body||p1,{items:_1,type:h1,centreDraggedOnCursor:g1}=r1;draggedElData={..._1[d1]},draggedElType=h1,shadowElData={...draggedElData,[SHADOW_ITEM_MARKER_PROPERTY_NAME]:!0};const $1={...shadowElData,[ITEM_ID_KEY]:SHADOW_PLACEHOLDER_ITEM_ID};draggedEl=createDraggedElementFrom(originalDragTarget,g1&&currentMousePosition);function y1(){draggedEl.parentElement?window.requestAnimationFrame(y1):(m1.appendChild(draggedEl),draggedEl.focus(),watchDraggedElement(),hideElement(originalDragTarget),m1.appendChild(originalDragTarget))}window.requestAnimationFrame(y1),styleActiveDropZones(Array.from(typeToDropZones$1.get(r1.type)).filter(v1=>v1===originDropZone||!dzToConfig$1.get(v1).dropFromOthersDisabled),v1=>dzToConfig$1.get(v1).dropTargetStyle,v1=>dzToConfig$1.get(v1).dropTargetClasses),_1.splice(d1,1,$1),unlockOriginDzMinDimensions=preventShrinking(originDropZone),dispatchConsiderEvent(originDropZone,_1,{trigger:TRIGGERS.DRAG_STARTED,id:draggedElData[ITEM_ID_KEY],source:SOURCES.POINTER}),window.addEventListener("mousemove",handleMouseMove,{passive:!1}),window.addEventListener("touchmove",handleMouseMove,{passive:!1,capture:!1}),window.addEventListener("mouseup",handleDrop$1,{passive:!1}),window.addEventListener("touchend",handleDrop$1,{passive:!1})}function f1({items:d1=void 0,flipDurationMs:p1=0,type:m1=DEFAULT_DROP_ZONE_TYPE$1,dragDisabled:_1=!1,morphDisabled:h1=!1,dropFromOthersDisabled:g1=!1,dropTargetStyle:$1=DEFAULT_DROP_TARGET_STYLE$1,dropTargetClasses:y1=[],transformDraggedElement:v1=()=>{},centreDraggedOnCursor:S1=!1}){r1.dropAnimationDurationMs=p1,r1.type&&m1!==r1.type&&unregisterDropZone$1(n1,r1.type),r1.type=m1,registerDropZone$1(n1,m1),r1.items=[...d1],r1.dragDisabled=_1,r1.morphDisabled=h1,r1.transformDraggedElement=v1,r1.centreDraggedOnCursor=S1,t1&&isWorkingOnPreviousDrag&&!finalizingPreviousDrag&&(!areObjectsShallowEqual($1,r1.dropTargetStyle)||!areArraysShallowEqualSameOrder(y1,r1.dropTargetClasses))&&(styleInactiveDropZones([n1],()=>r1.dropTargetStyle,()=>y1),styleActiveDropZones([n1],()=>$1,()=>y1)),r1.dropTargetStyle=$1,r1.dropTargetClasses=[...y1];function O1(M1,z1){return dzToConfig$1.get(M1)?dzToConfig$1.get(M1)[z1]:r1[z1]}t1&&isWorkingOnPreviousDrag&&r1.dropFromOthersDisabled!==g1&&(g1?styleInactiveDropZones([n1],M1=>O1(M1,"dropTargetStyle"),M1=>O1(M1,"dropTargetClasses")):styleActiveDropZones([n1],M1=>O1(M1,"dropTargetStyle"),M1=>O1(M1,"dropTargetClasses"))),r1.dropFromOthersDisabled=g1,dzToConfig$1.set(n1,r1);const C1=findShadowElementIdx(r1.items);for(let M1=0;M1<n1.children.length;M1++){const z1=n1.children[M1];if(styleDraggable(z1,_1),M1===C1){r1.transformDraggedElement(draggedEl,draggedElData,M1),h1||morphDraggedElementToBeLike(draggedEl,z1,currentMousePosition.x,currentMousePosition.y),decorateShadowEl(z1);continue}z1.removeEventListener("mousedown",elToMouseDownListener.get(z1)),z1.removeEventListener("touchstart",elToMouseDownListener.get(z1)),_1||(z1.addEventListener("mousedown",c1),z1.addEventListener("touchstart",c1),elToMouseDownListener.set(z1,c1)),o1.set(z1,M1),t1||(t1=!0)}}return f1(e1),{update:d1=>{f1(d1)},destroy:()=>{function d1(){unregisterDropZone$1(n1,dzToConfig$1.get(n1).type),dzToConfig$1.delete(n1)}isWorkingOnPreviousDrag?scheduleDZForRemovalAfterDrop(n1,d1):d1()}}}const INSTRUCTION_IDs$1={DND_ZONE_ACTIVE:"dnd-zone-active",DND_ZONE_DRAG_DISABLED:"dnd-zone-drag-disabled"},ID_TO_INSTRUCTION={[INSTRUCTION_IDs$1.DND_ZONE_ACTIVE]:"Tab to one the items and press space-bar or enter to start dragging it",[INSTRUCTION_IDs$1.DND_ZONE_DRAG_DISABLED]:"This is a disabled drag and drop list"},ALERT_DIV_ID="dnd-action-aria-alert";let alertsDiv;function initAriaOnBrowser(){alertsDiv||(alertsDiv=document.createElement("div"),function(){alertsDiv.id=ALERT_DIV_ID,alertsDiv.style.position="fixed",alertsDiv.style.bottom="0",alertsDiv.style.left="0",alertsDiv.style.zIndex="-5",alertsDiv.style.opacity="0",alertsDiv.style.height="0",alertsDiv.style.width="0",alertsDiv.setAttribute("role","alert")}(),document.body.prepend(alertsDiv),Object.entries(ID_TO_INSTRUCTION).forEach(([n1,e1])=>document.body.prepend(instructionToHiddenDiv(n1,e1))))}function initAria(){return isOnServer?null:(document.readyState==="complete"?initAriaOnBrowser():window.addEventListener("DOMContentLoaded",initAriaOnBrowser),{...INSTRUCTION_IDs$1})}function destroyAria(){isOnServer||!alertsDiv||(Object.keys(ID_TO_INSTRUCTION).forEach(n1=>{var e1;return(e1=document.getElementById(n1))==null?void 0:e1.remove()}),alertsDiv.remove(),alertsDiv=void 0)}function instructionToHiddenDiv(n1,e1){const t1=document.createElement("div");return t1.id=n1,t1.innerHTML=`<p>${e1}</p>`,t1.style.display="none",t1.style.position="fixed",t1.style.zIndex="-5",t1}function alertToScreenReader(n1){if(isOnServer)return;alertsDiv||initAriaOnBrowser(),alertsDiv.innerHTML="";const e1=document.createTextNode(n1);alertsDiv.appendChild(e1),alertsDiv.style.display="none",alertsDiv.style.display="inline"}const DEFAULT_DROP_ZONE_TYPE="--any--",DEFAULT_DROP_TARGET_STYLE={outline:"rgba(255, 255, 102, 0.7) solid 2px"};let isDragging=!1,draggedItemType,focusedDz,focusedDzLabel="",focusedItem,focusedItemId,focusedItemLabel="";const allDragTargets=new WeakSet,elToKeyDownListeners=new WeakMap,elToFocusListeners=new WeakMap,dzToHandles=new Map,dzToConfig=new Map,typeToDropZones=new Map;let INSTRUCTION_IDs;function registerDropZone(n1,e1){typeToDropZones.size===0&&(INSTRUCTION_IDs=initAria(),window.addEventListener("keydown",globalKeyDownHandler),window.addEventListener("click",globalClickHandler)),typeToDropZones.has(e1)||typeToDropZones.set(e1,new Set),typeToDropZones.get(e1).has(n1)||(typeToDropZones.get(e1).add(n1),incrementActiveDropZoneCount())}function unregisterDropZone(n1,e1){focusedDz===n1&&handleDrop(),typeToDropZones.get(e1).delete(n1),decrementActiveDropZoneCount(),typeToDropZones.get(e1).size===0&&typeToDropZones.delete(e1),typeToDropZones.size===0&&(window.removeEventListener("keydown",globalKeyDownHandler),window.removeEventListener("click",globalClickHandler),INSTRUCTION_IDs=void 0,destroyAria())}function globalKeyDownHandler(n1){if(isDragging)switch(n1.key){case"Escape":{handleDrop();break}}}function globalClickHandler(){isDragging&&(allDragTargets.has(document.activeElement)||handleDrop())}function handleZoneFocus(n1){if(!isDragging)return;const e1=n1.currentTarget;if(e1===focusedDz)return;focusedDzLabel=e1.getAttribute("aria-label")||"";const{items:t1}=dzToConfig.get(focusedDz),r1=t1.find(c1=>c1[ITEM_ID_KEY]===focusedItemId),o1=t1.indexOf(r1),i1=t1.splice(o1,1)[0],{items:a1,autoAriaDisabled:s1}=dzToConfig.get(e1);e1.getBoundingClientRect().top<focusedDz.getBoundingClientRect().top||e1.getBoundingClientRect().left<focusedDz.getBoundingClientRect().left?(a1.push(i1),s1||alertToScreenReader(`Moved item ${focusedItemLabel} to the end of the list ${focusedDzLabel}`)):(a1.unshift(i1),s1||alertToScreenReader(`Moved item ${focusedItemLabel} to the beginning of the list ${focusedDzLabel}`)),dispatchFinalizeEvent(focusedDz,t1,{trigger:TRIGGERS.DROPPED_INTO_ANOTHER,id:focusedItemId,source:SOURCES.KEYBOARD}),dispatchFinalizeEvent(e1,a1,{trigger:TRIGGERS.DROPPED_INTO_ZONE,id:focusedItemId,source:SOURCES.KEYBOARD}),focusedDz=e1}function triggerAllDzsUpdate(){dzToHandles.forEach(({update:n1},e1)=>n1(dzToConfig.get(e1)))}function handleDrop(n1=!0){dzToConfig.get(focusedDz).autoAriaDisabled||alertToScreenReader(`Stopped dragging item ${focusedItemLabel}`),allDragTargets.has(document.activeElement)&&document.activeElement.blur(),n1&&dispatchConsiderEvent(focusedDz,dzToConfig.get(focusedDz).items,{trigger:TRIGGERS.DRAG_STOPPED,id:focusedItemId,source:SOURCES.KEYBOARD}),styleInactiveDropZones(typeToDropZones.get(draggedItemType),e1=>dzToConfig.get(e1).dropTargetStyle,e1=>dzToConfig.get(e1).dropTargetClasses),focusedItem=null,focusedItemId=null,focusedItemLabel="",draggedItemType=null,focusedDz=null,focusedDzLabel="",isDragging=!1,triggerAllDzsUpdate()}function dndzone$1(n1,e1){const t1={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:DEFAULT_DROP_TARGET_STYLE,dropTargetClasses:[],autoAriaDisabled:!1};function r1(u1,f1,d1){u1.length<=1||u1.splice(d1,1,u1.splice(f1,1,u1[d1])[0])}function o1(u1){switch(u1.key){case"Enter":case" ":{if((u1.target.disabled!==void 0||u1.target.href||u1.target.isContentEditable)&&!allDragTargets.has(u1.target))return;u1.preventDefault(),u1.stopPropagation(),isDragging?handleDrop():i1(u1);break}case"ArrowDown":case"ArrowRight":{if(!isDragging)return;u1.preventDefault(),u1.stopPropagation();const{items:f1}=dzToConfig.get(n1),d1=Array.from(n1.children),p1=d1.indexOf(u1.currentTarget);p1<d1.length-1&&(t1.autoAriaDisabled||alertToScreenReader(`Moved item ${focusedItemLabel} to position ${p1+2} in the list ${focusedDzLabel}`),r1(f1,p1,p1+1),dispatchFinalizeEvent(n1,f1,{trigger:TRIGGERS.DROPPED_INTO_ZONE,id:focusedItemId,source:SOURCES.KEYBOARD}));break}case"ArrowUp":case"ArrowLeft":{if(!isDragging)return;u1.preventDefault(),u1.stopPropagation();const{items:f1}=dzToConfig.get(n1),p1=Array.from(n1.children).indexOf(u1.currentTarget);p1>0&&(t1.autoAriaDisabled||alertToScreenReader(`Moved item ${focusedItemLabel} to position ${p1} in the list ${focusedDzLabel}`),r1(f1,p1,p1-1),dispatchFinalizeEvent(n1,f1,{trigger:TRIGGERS.DROPPED_INTO_ZONE,id:focusedItemId,source:SOURCES.KEYBOARD}));break}}}function i1(u1){s1(u1.currentTarget),focusedDz=n1,draggedItemType=t1.type,isDragging=!0;const f1=Array.from(typeToDropZones.get(t1.type)).filter(d1=>d1===focusedDz||!dzToConfig.get(d1).dropFromOthersDisabled);if(styleActiveDropZones(f1,d1=>dzToConfig.get(d1).dropTargetStyle,d1=>dzToConfig.get(d1).dropTargetClasses),!t1.autoAriaDisabled){let d1=`Started dragging item ${focusedItemLabel}. Use the arrow keys to move it within its list ${focusedDzLabel}`;f1.length>1&&(d1+=", or tab to another list in order to move the item into it"),alertToScreenReader(d1)}dispatchConsiderEvent(n1,dzToConfig.get(n1).items,{trigger:TRIGGERS.DRAG_STARTED,id:focusedItemId,source:SOURCES.KEYBOARD}),triggerAllDzsUpdate()}function a1(u1){isDragging&&u1.currentTarget!==focusedItem&&(u1.stopPropagation(),handleDrop(!1),i1(u1))}function s1(u1){const{items:f1}=dzToConfig.get(n1),d1=Array.from(n1.children),p1=d1.indexOf(u1);focusedItem=u1,focusedItem.tabIndex=0,focusedItemId=f1[p1][ITEM_ID_KEY],focusedItemLabel=d1[p1].getAttribute("aria-label")||""}function l1({items:u1=[],type:f1=DEFAULT_DROP_ZONE_TYPE,dragDisabled:d1=!1,zoneTabIndex:p1=0,dropFromOthersDisabled:m1=!1,dropTargetStyle:_1=DEFAULT_DROP_TARGET_STYLE,dropTargetClasses:h1=[],autoAriaDisabled:g1=!1}){t1.items=[...u1],t1.dragDisabled=d1,t1.dropFromOthersDisabled=m1,t1.zoneTabIndex=p1,t1.dropTargetStyle=_1,t1.dropTargetClasses=h1,t1.autoAriaDisabled=g1,t1.type&&f1!==t1.type&&unregisterDropZone(n1,t1.type),t1.type=f1,registerDropZone(n1,f1),g1||(n1.setAttribute("aria-disabled",d1),n1.setAttribute("role","list"),n1.setAttribute("aria-describedby",d1?INSTRUCTION_IDs.DND_ZONE_DRAG_DISABLED:INSTRUCTION_IDs.DND_ZONE_ACTIVE)),dzToConfig.set(n1,t1),isDragging?n1.tabIndex=n1===focusedDz||focusedItem.contains(n1)||t1.dropFromOthersDisabled||focusedDz&&t1.type!==dzToConfig.get(focusedDz).type?-1:0:n1.tabIndex=t1.zoneTabIndex,n1.addEventListener("focus",handleZoneFocus);for(let $1=0;$1<n1.children.length;$1++){const y1=n1.children[$1];allDragTargets.add(y1),y1.tabIndex=isDragging?-1:0,g1||y1.setAttribute("role","listitem"),y1.removeEventListener("keydown",elToKeyDownListeners.get(y1)),y1.removeEventListener("click",elToFocusListeners.get(y1)),d1||(y1.addEventListener("keydown",o1),elToKeyDownListeners.set(y1,o1),y1.addEventListener("click",a1),elToFocusListeners.set(y1,a1)),isDragging&&t1.items[$1][ITEM_ID_KEY]===focusedItemId&&(focusedItem=y1,focusedItem.tabIndex=0,y1.focus())}}l1(e1);const c1={update:u1=>{l1(u1)},destroy:()=>{unregisterDropZone(n1,t1.type),dzToConfig.delete(n1),dzToHandles.delete(n1)}};return dzToHandles.set(n1,c1),c1}function dndzone(n1,e1){validateOptions(e1);const t1=dndzone$2(n1,e1),r1=dndzone$1(n1,e1);return{update:o1=>{validateOptions(o1),t1.update(o1),r1.update(o1)},destroy:()=>{t1.destroy(),r1.destroy()}}}function validateOptions(n1){const{items:e1,flipDurationMs:t1,type:r1,dragDisabled:o1,morphDisabled:i1,dropFromOthersDisabled:a1,zoneTabIndex:s1,dropTargetStyle:l1,dropTargetClasses:c1,transformDraggedElement:u1,autoAriaDisabled:f1,centreDraggedOnCursor:d1,...p1}=n1;if(Object.keys(p1).length>0&&console.warn("dndzone will ignore unknown options",p1),!e1)throw new Error("no 'items' key provided to dndzone");const m1=e1.find(_1=>!{}.hasOwnProperty.call(_1,ITEM_ID_KEY));if(m1)throw new Error(`missing '${ITEM_ID_KEY}' property for item ${toString$6(m1)}`);if(c1&&!Array.isArray(c1))throw new Error(`dropTargetClasses should be an array but instead it is a ${typeof c1}, ${toString$6(c1)}`);if(s1&&!isInt(s1))throw new Error(`zoneTabIndex should be a number but instead it is a ${typeof s1}, ${toString$6(s1)}`)}function isInt(n1){return!isNaN(n1)&&function(e1){return(e1|0)===e1}(parseFloat(n1))}const OptionSelectDnD_svelte_svelte_type_style_lang="";function get_each_context$1z(n1,e1,t1){const r1=n1.slice();return r1[18]=e1[t1],r1[19]=e1,r1[20]=t1,r1}function get_each_context_1$o(n1,e1,t1){const r1=n1.slice();return r1[21]=e1[t1],r1}function create_each_block_1$o(n1){let e1,t1,r1;function o1(){return n1[13](n1[18],n1[21],n1[20])}return{c(){e1=element("div"),set_style(e1,"--color",n1[21]),attr(e1,"class","circle circle-hover svelte-1e17jzv")},m(i1,a1){insert$1(i1,e1,a1),t1||(r1=listen(e1,"click",o1),t1=!0)},p(i1,a1){n1=i1},d(i1){i1&&detach(e1),t1=!1,r1()}}}function create_default_slot$5a(n1){let e1,t1=n1[4],r1=[];for(let o1=0;o1<t1.length;o1+=1)r1[o1]=create_each_block_1$o(get_each_context_1$o(n1,t1,o1));return{c(){e1=element("div");for(let o1=0;o1<r1.length;o1+=1)r1[o1].c();attr(e1,"class","colors svelte-1e17jzv")},m(o1,i1){insert$1(o1,e1,i1);for(let a1=0;a1<r1.length;a1+=1)r1[a1].m(e1,null)},p(o1,i1){if(i1&530){t1=o1[4];let a1;for(a1=0;a1<t1.length;a1+=1){const s1=get_each_context_1$o(o1,t1,a1);r1[a1]?r1[a1].p(s1,i1):(r1[a1]=create_each_block_1$o(s1),r1[a1].c(),r1[a1].m(e1,null))}for(;a1<r1.length;a1+=1)r1[a1].d(1);r1.length=t1.length}},d(o1){o1&&detach(e1),destroy_each(r1,o1)}}}function create_each_block$1z(n1,e1){let t1,r1,o1,i1,a1,s1,l1,c1=e1[20],u1,f1,d1,p1,m1,_1,h1,g1,$1,y1=noop$5,v1,S1,O1;o1=new Icon({props:{name:"DragHandle",size:"L"}});const C1=()=>e1[14](l1,c1),M1=()=>e1[14](null,c1);let z1={anchor:e1[3][e1[20]],align:"left",offset:0,style:"",popoverTarget:document.getElementById("color-picker"),animate:!1,$$slots:{default:[create_default_slot$5a]},$$scope:{ctx:e1}};l1=new Popover({props:z1}),C1();const P1=()=>e1[15](s1,c1),R1=()=>e1[15](null,c1);function N1(...B1){return e1[16](e1[20],...B1)}function F1(...B1){return e1[17](e1[18],e1[20],...B1)}return h1=new Icon({props:{name:"Close",hoverable:!0,size:"S"}}),h1.$on("click",function(){is_function(e1[5](e1[20]))&&e1[5](e1[20]).apply(this,arguments)}),{key:n1,first:null,c(){var B1;t1=element("div"),r1=element("div"),create_component(o1.$$.fragment),i1=space$1(),a1=element("div"),s1=element("div"),create_component(l1.$$.fragment),u1=space$1(),f1=element("div"),d1=element("input"),m1=space$1(),_1=element("div"),create_component(h1.$$.fragment),g1=space$1(),attr(r1,"class","child drag-handle-spacing svelte-1e17jzv"),attr(s1,"id","color-picker"),set_style(s1,"--color",((B1=e1[0])==null?void 0:B1[e1[18].name])||"hsla(0, 1%, 50%, 0.3)"),attr(s1,"class","circle svelte-1e17jzv"),attr(a1,"class","child color-picker svelte-1e17jzv"),attr(d1,"class","input-field svelte-1e17jzv"),attr(d1,"type","text"),d1.value=p1=e1[18].name,attr(d1,"placeholder","Option name"),attr(f1,"class","child svelte-1e17jzv"),attr(_1,"class","child svelte-1e17jzv"),attr(t1,"class","no-border action-container svelte-1e17jzv"),this.first=t1},m(B1,L1){insert$1(B1,t1,L1),append$1(t1,r1),mount_component(o1,r1,null),append$1(t1,i1),append$1(t1,a1),append$1(a1,s1),mount_component(l1,s1,null),P1(),append$1(t1,u1),append$1(t1,f1),append$1(f1,d1),append$1(t1,m1),append$1(t1,_1),mount_component(h1,_1,null),append$1(t1,g1),v1=!0,S1||(O1=[listen(s1,"click",N1),listen(d1,"change",F1)],S1=!0)},p(B1,L1){var j1;e1=B1,c1!==e1[20]&&(M1(),c1=e1[20],C1());const U1={};L1&10&&(U1.anchor=e1[3][e1[20]]),L1&16777218&&(U1.$$scope={dirty:L1,ctx:e1}),l1.$set(U1),(!v1||L1&3)&&set_style(s1,"--color",((j1=e1[0])==null?void 0:j1[e1[18].name])||"hsla(0, 1%, 50%, 0.3)"),c1!==e1[20]&&(R1(),c1=e1[20],P1()),(!v1||L1&2&&p1!==(p1=e1[18].name)&&d1.value!==p1)&&(d1.value=p1)},r(){$1=t1.getBoundingClientRect()},f(){fix_position(t1),y1()},a(){y1(),y1=create_animation(t1,$1,flip,{duration:flipDurationMs$4})},i(B1){v1||(transition_in(o1.$$.fragment,B1),transition_in(l1.$$.fragment,B1),transition_in(h1.$$.fragment,B1),v1=!0)},o(B1){transition_out(o1.$$.fragment,B1),transition_out(l1.$$.fragment,B1),transition_out(h1.$$.fragment,B1),v1=!1},d(B1){B1&&detach(t1),destroy_component(o1),M1(),destroy_component(l1),R1(),destroy_component(h1),S1=!1,run_all(O1)}}}function create_fragment$8a(n1){let e1,t1,r1=[],o1=new Map,i1,a1,s1,l1,c1,u1,f1,d1,p1,m1=n1[1];const _1=h1=>h1[18].id;for(let h1=0;h1<m1.length;h1+=1){let g1=get_each_context$1z(n1,m1,h1),$1=_1(g1);o1.set($1,r1[h1]=create_each_block$1z($1,g1))}return l1=new Icon({props:{hoverable:!0,name:"Add"}}),{c(){e1=element("div"),t1=element("div");for(let h1=0;h1<r1.length;h1+=1)r1[h1].c();a1=space$1(),s1=element("div"),create_component(l1.$$.fragment),c1=space$1(),u1=element("div"),u1.textContent="Add option",attr(t1,"class","actions"),attr(s1,"class","add-option svelte-1e17jzv")},m(h1,g1){insert$1(h1,e1,g1),append$1(e1,t1);for(let $1=0;$1<r1.length;$1+=1)r1[$1].m(t1,null);append$1(e1,a1),append$1(e1,s1),mount_component(l1,s1,null),append$1(s1,c1),append$1(s1,u1),f1=!0,d1||(p1=[action_destroyer(i1=dndzone.call(null,t1,{items:n1[1],flipDurationMs:flipDurationMs$4,dropTargetStyle:{outline:"none"}})),listen(t1,"consider",n1[7]),listen(t1,"finalize",n1[8]),listen(s1,"click",n1[6])],d1=!0)},p(h1,[g1]){if(g1&3647){m1=h1[1],group_outros();for(let $1=0;$1<r1.length;$1+=1)r1[$1].r();r1=update_keyed_each(r1,g1,_1,1,h1,m1,o1,t1,fix_and_outro_and_destroy_block,create_each_block$1z,null,get_each_context$1z);for(let $1=0;$1<r1.length;$1+=1)r1[$1].a();check_outros()}i1&&is_function(i1.update)&&g1&2&&i1.update.call(null,{items:h1[1],flipDurationMs:flipDurationMs$4,dropTargetStyle:{outline:"none"}})},i(h1){if(!f1){for(let g1=0;g1<m1.length;g1+=1)transition_in(r1[g1]);transition_in(l1.$$.fragment,h1),f1=!0}},o(h1){for(let g1=0;g1<r1.length;g1+=1)transition_out(r1[g1]);transition_out(l1.$$.fragment,h1),f1=!1},d(h1){h1&&detach(e1);for(let g1=0;g1<r1.length;g1+=1)r1[g1].d();destroy_component(l1),d1=!1,run_all(p1)}}}const flipDurationMs$4=150;function instance$8l(n1,e1,t1){let{constraints:r1}=e1,{optionColors:o1={}}=e1,i1=[],a1=[],s1=[],l1=["hsla(0, 90%, 75%, 0.3)","hsla(50, 80%, 75%, 0.3)","hsla(120, 90%, 75%, 0.3)","hsla(200, 90%, 75%, 0.3)","hsla(240, 90%, 75%, 0.3)","hsla(320, 90%, 75%, 0.3)"];const c1=S1=>{delete o1[i1[S1].name],t1(12,r1.inclusion=r1.inclusion.filter((O1,C1)=>C1!==S1),r1),t1(1,i1=i1.filter((O1,C1)=>C1!==S1)),a1.pop(void 0),s1.pop(void 0)},u1=()=>{t1(1,i1=[...i1,{name:`Option ${r1.inclusion.length+1}`,id:Math.random()}]),t1(12,r1.inclusion=[...r1.inclusion,`Option ${r1.inclusion.length+1}`],r1),a1.push(void 0),s1.push(void 0)},f1=S1=>{t1(1,i1=S1.detail.items)},d1=S1=>{t1(1,i1=S1.detail.items),t1(12,r1.inclusion=i1.map(O1=>O1.name),r1)},p1=(S1,O1,C1)=>{t1(0,o1[S1]=O1,o1),a1[C1].hide()},m1=(S1,O1,C1)=>{t1(12,r1.inclusion[O1]=C1,r1),t1(1,i1[O1].name=C1,i1),t1(0,o1[C1]=o1[S1],o1),delete o1[S1]},_1=(S1,O1)=>{a1[S1].show(),t1(3,s1[S1]=O1,s1)};onMount(()=>{t1(2,a1=r1.inclusion.map(()=>{})),t1(3,s1=r1.inclusion.map(()=>{})),t1(1,i1=r1.inclusion.map(S1=>({name:S1,id:Math.random()})))});const h1=(S1,O1,C1)=>p1(S1.name,O1,C1);function g1(S1,O1){binding_callbacks[S1?"unshift":"push"](()=>{a1[O1]=S1,t1(2,a1)})}function $1(S1,O1){binding_callbacks[S1?"unshift":"push"](()=>{s1[O1]=S1,t1(3,s1)})}const y1=(S1,O1)=>_1(S1,O1.target),v1=(S1,O1,C1)=>m1(S1.name,O1,C1.target.value);return n1.$$set=S1=>{"constraints"in S1&&t1(12,r1=S1.constraints),"optionColors"in S1&&t1(0,o1=S1.optionColors)},[o1,i1,a1,s1,l1,c1,u1,f1,d1,p1,m1,_1,r1,h1,g1,$1,y1,v1]}class OptionSelectDnD extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8l,create_fragment$8a,safe_not_equal,{constraints:12,optionColors:0})}}const BoldRenderer_svelte_svelte_type_style_lang="";function create_fragment$89(n1){let e1,t1;return{c(){e1=element("div"),t1=text(n1[0]),attr(e1,"class","bold svelte-9amtlb")},m(r1,o1){insert$1(r1,e1,o1),append$1(e1,t1)},p(r1,[o1]){o1&1&&set_data(t1,r1[0])},i:noop$5,o:noop$5,d(r1){r1&&detach(e1)}}}function instance$8k(n1,e1,t1){let{value:r1}=e1;return n1.$$set=o1=>{"value"in o1&&t1(0,r1=o1.value)},[r1]}class BoldRenderer extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8k,create_fragment$89,safe_not_equal,{value:0})}}const CodeRenderer_svelte_svelte_type_style_lang="";function create_fragment$88(n1){let e1,t1;return{c(){e1=element("code"),t1=text(n1[0]),attr(e1,"class","svelte-e82i3")},m(r1,o1){insert$1(r1,e1,o1),append$1(e1,t1)},p(r1,[o1]){o1&1&&set_data(t1,r1[0])},i:noop$5,o:noop$5,d(r1){r1&&detach(e1)}}}function instance$8j(n1,e1,t1){let{value:r1}=e1;return n1.$$set=o1=>{"value"in o1&&t1(0,r1=o1.value)},[r1]}class CodeRenderer extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8j,create_fragment$88,safe_not_equal,{value:0})}}const ErrorMessage_svelte_svelte_type_style_lang="";function create_fragment$87(n1){let e1,t1,r1,o1;return{c(){e1=element("div"),t1=text(n1[0]),attr(e1,"class","error-message svelte-wciay3")},m(i1,a1){insert$1(i1,e1,a1),append$1(e1,t1),o1=!0},p(i1,[a1]){(!o1||a1&1)&&set_data(t1,i1[0])},i(i1){o1||(i1&&add_render_callback(()=>{r1||(r1=create_bidirectional_transition(e1,slide,{duration:130},!0)),r1.run(1)}),o1=!0)},o(i1){i1&&(r1||(r1=create_bidirectional_transition(e1,slide,{duration:130},!1)),r1.run(0)),o1=!1},d(i1){i1&&detach(e1),i1&&r1&&r1.end()}}}function instance$8i(n1,e1,t1){let{error:r1=null}=e1;return n1.$$set=o1=>{"error"in o1&&t1(0,r1=o1.error)},[r1]}class ErrorMessage extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8i,create_fragment$87,safe_not_equal,{error:0})}}const FancyField_svelte_svelte_type_style_lang="";function create_if_block_1$27(n1){let e1,t1,r1;return t1=new Icon({props:{name:"Alert"}}),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","error-icon svelte-17ywq9")},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function create_if_block$3O(n1){let e1,t1;return e1=new ErrorMessage({props:{error:n1[0]}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&1&&(i1.error=r1[0]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$86(n1){let e1,t1,r1,o1,i1,a1,s1,l1;const c1=n1[10].default,u1=create_slot(c1,n1,n1[9],null);let f1=n1[0]&&create_if_block_1$27(),d1=n1[0]&&create_if_block$3O(n1);return{c(){e1=element("div"),t1=element("div"),r1=element("div"),u1&&u1.c(),o1=space$1(),f1&&f1.c(),i1=space$1(),d1&&d1.c(),attr(r1,"class","field svelte-17ywq9"),attr(t1,"class","content svelte-17ywq9"),attr(e1,"class","fancy-field svelte-17ywq9"),toggle_class(e1,"error",n1[0]),toggle_class(e1,"disabled",n1[2]),toggle_class(e1,"focused",n1[3]),toggle_class(e1,"clickable",n1[4]),toggle_class(e1,"compact",n1[6]),toggle_class(e1,"auto-height",n1[5])},m(p1,m1){insert$1(p1,e1,m1),append$1(e1,t1),append$1(t1,r1),u1&&u1.m(r1,null),append$1(t1,o1),f1&&f1.m(t1,null),append$1(e1,i1),d1&&d1.m(e1,null),n1[12](e1),a1=!0,s1||(l1=listen(t1,"click",n1[11]),s1=!0)},p(p1,[m1]){u1&&u1.p&&(!a1||m1&512)&&update_slot_base(u1,c1,p1,p1[9],a1?get_slot_changes(c1,p1[9],m1,null):get_all_dirty_from_scope(p1[9]),null),p1[0]?f1?m1&1&&transition_in(f1,1):(f1=create_if_block_1$27(),f1.c(),transition_in(f1,1),f1.m(t1,null)):f1&&(group_outros(),transition_out(f1,1,1,()=>{f1=null}),check_outros()),p1[0]?d1?(d1.p(p1,m1),m1&1&&transition_in(d1,1)):(d1=create_if_block$3O(p1),d1.c(),transition_in(d1,1),d1.m(e1,null)):d1&&(group_outros(),transition_out(d1,1,1,()=>{d1=null}),check_outros()),(!a1||m1&1)&&toggle_class(e1,"error",p1[0]),(!a1||m1&4)&&toggle_class(e1,"disabled",p1[2]),(!a1||m1&8)&&toggle_class(e1,"focused",p1[3]),(!a1||m1&16)&&toggle_class(e1,"clickable",p1[4]),(!a1||m1&64)&&toggle_class(e1,"compact",p1[6]),(!a1||m1&32)&&toggle_class(e1,"auto-height",p1[5])},i(p1){a1||(transition_in(u1,p1),transition_in(f1),transition_in(d1),a1=!0)},o(p1){transition_out(u1,p1),transition_out(f1),transition_out(d1),a1=!1},d(p1){p1&&detach(e1),u1&&u1.d(p1),f1&&f1.d(),d1&&d1.d(),n1[12](null),s1=!1,l1()}}}function instance$8h(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{disabled:i1=!1}=e1,{error:a1=null}=e1,{focused:s1=!1}=e1,{clickable:l1=!1}=e1,{validate:c1}=e1,{value:u1}=e1,{ref:f1}=e1,{autoHeight:d1}=e1,{compact:p1=!1}=e1;const m1=getContext("fancy-form"),_1=Math.random(),h1={validate:()=>(c1&&t1(0,a1=c1(u1)),!a1)};onMount(()=>(m1&&m1.registerField(_1,h1),()=>{m1&&m1.unregisterField(_1)}));function g1(y1){bubble.call(this,n1,y1)}function $1(y1){binding_callbacks[y1?"unshift":"push"](()=>{f1=y1,t1(1,f1)})}return n1.$$set=y1=>{"disabled"in y1&&t1(2,i1=y1.disabled),"error"in y1&&t1(0,a1=y1.error),"focused"in y1&&t1(3,s1=y1.focused),"clickable"in y1&&t1(4,l1=y1.clickable),"validate"in y1&&t1(7,c1=y1.validate),"value"in y1&&t1(8,u1=y1.value),"ref"in y1&&t1(1,f1=y1.ref),"autoHeight"in y1&&t1(5,d1=y1.autoHeight),"compact"in y1&&t1(6,p1=y1.compact),"$$scope"in y1&&t1(9,o1=y1.$$scope)},[a1,f1,i1,s1,l1,d1,p1,c1,u1,o1,r1,g1,$1]}class FancyField extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8h,create_fragment$86,safe_not_equal,{disabled:2,error:0,focused:3,clickable:4,validate:7,value:8,ref:1,autoHeight:5,compact:6})}}const FancyFieldLabel_svelte_svelte_type_style_lang="";function create_fragment$85(n1){let e1,t1;const r1=n1[2].default,o1=create_slot(r1,n1,n1[1],null);return{c(){e1=element("div"),o1&&o1.c(),attr(e1,"class","svelte-1yrw3p"),toggle_class(e1,"placeholder",n1[0])},m(i1,a1){insert$1(i1,e1,a1),o1&&o1.m(e1,null),t1=!0},p(i1,[a1]){o1&&o1.p&&(!t1||a1&2)&&update_slot_base(o1,r1,i1,i1[1],t1?get_slot_changes(r1,i1[1],a1,null):get_all_dirty_from_scope(i1[1]),null),(!t1||a1&1)&&toggle_class(e1,"placeholder",i1[0])},i(i1){t1||(transition_in(o1,i1),t1=!0)},o(i1){transition_out(o1,i1),t1=!1},d(i1){i1&&detach(e1),o1&&o1.d(i1)}}}function instance$8g(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{placeholder:i1=!0}=e1;return n1.$$set=a1=>{"placeholder"in a1&&t1(0,i1=a1.placeholder),"$$scope"in a1&&t1(1,o1=a1.$$scope)},[i1,o1,r1]}class FancyFieldLabel extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8g,create_fragment$85,safe_not_equal,{placeholder:0})}}const FancyInput_svelte_svelte_type_style_lang="";function create_if_block_1$26(n1){let e1,t1;return e1=new FancyFieldLabel({props:{placeholder:n1[9],$$slots:{default:[create_default_slot_1$3J]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&512&&(i1.placeholder=r1[9]),o1&65540&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_default_slot_1$3J(n1){let e1;return{c(){e1=text(n1[2])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&4&&set_data(e1,t1[2])},d(t1){t1&&detach(e1)}}}function create_if_block$3N(n1){let e1,t1,r1;return{c(){e1=element("div"),t1=text(n1[6]),attr(e1,"class","suffix svelte-1xkimai")},m(o1,i1){insert$1(o1,e1,i1),append$1(e1,t1)},p(o1,i1){i1&64&&set_data(t1,o1[6])},i(o1){o1&&(r1||add_render_callback(()=>{r1=create_in_transition(e1,fade,{duration:130}),r1.start()}))},o:noop$5,d(o1){o1&&detach(e1)}}}function create_default_slot$59(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1,u1=n1[2]&&create_if_block_1$26(n1),f1=n1[6]&&!n1[9]&&create_if_block$3N(n1);return{c(){u1&&u1.c(),e1=space$1(),t1=element("input"),i1=space$1(),f1&&f1.c(),a1=empty$1(),t1.disabled=n1[4],t1.value=r1=n1[0]||"",attr(t1,"type",o1=n1[3]||"text"),attr(t1,"class","svelte-1xkimai"),toggle_class(t1,"placeholder",n1[9])},m(d1,p1){u1&&u1.m(d1,p1),insert$1(d1,e1,p1),insert$1(d1,t1,p1),n1[14](t1),insert$1(d1,i1,p1),f1&&f1.m(d1,p1),insert$1(d1,a1,p1),s1=!0,l1||(c1=[listen(t1,"input",n1[10]),listen(t1,"focus",n1[12]),listen(t1,"blur",n1[13])],l1=!0)},p(d1,p1){d1[2]?u1?(u1.p(d1,p1),p1&4&&transition_in(u1,1)):(u1=create_if_block_1$26(d1),u1.c(),transition_in(u1,1),u1.m(e1.parentNode,e1)):u1&&(group_outros(),transition_out(u1,1,1,()=>{u1=null}),check_outros()),(!s1||p1&16)&&(t1.disabled=d1[4]),(!s1||p1&1&&r1!==(r1=d1[0]||"")&&t1.value!==r1)&&(t1.value=r1),(!s1||p1&8&&o1!==(o1=d1[3]||"text"))&&attr(t1,"type",o1),(!s1||p1&512)&&toggle_class(t1,"placeholder",d1[9]),d1[6]&&!d1[9]?f1?(f1.p(d1,p1),p1&576&&transition_in(f1,1)):(f1=create_if_block$3N(d1),f1.c(),transition_in(f1,1),f1.m(a1.parentNode,a1)):f1&&(f1.d(1),f1=null)},i(d1){s1||(transition_in(u1),transition_in(f1),s1=!0)},o(d1){transition_out(u1),s1=!1},d(d1){u1&&u1.d(d1),d1&&detach(e1),d1&&detach(t1),n1[14](null),d1&&detach(i1),f1&&f1.d(d1),d1&&detach(a1),l1=!1,run_all(c1)}}}function create_fragment$84(n1){let e1,t1;return e1=new FancyField({props:{error:n1[1],value:n1[0],validate:n1[5],disabled:n1[4],focused:n1[7],$$slots:{default:[create_default_slot$59]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&2&&(i1.error=r1[1]),o1&1&&(i1.value=r1[0]),o1&32&&(i1.validate=r1[5]),o1&16&&(i1.disabled=r1[4]),o1&128&&(i1.focused=r1[7]),o1&66525&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8f(n1,e1,t1){let r1,{label:o1}=e1,{value:i1}=e1,{type:a1="text"}=e1,{disabled:s1=!1}=e1,{error:l1=null}=e1,{validate:c1=null}=e1,{suffix:u1=null}=e1;const f1=createEventDispatcher();let d1,p1=!1,m1=!1;const _1=y1=>{const v1=y1.target.value;f1("change",v1),t1(0,i1=v1),c1&&t1(1,l1=c1(v1))};onMount(()=>{const y1=setInterval(()=>{t1(11,m1=d1==null?void 0:d1.matches(":-webkit-autofill")),m1&&clearInterval(y1)},100),v1=setTimeout(()=>{clearInterval(y1)},2e3);return()=>{clearInterval(y1),clearTimeout(v1)}});const h1=()=>t1(7,p1=!0),g1=()=>t1(7,p1=!1);function $1(y1){binding_callbacks[y1?"unshift":"push"](()=>{d1=y1,t1(8,d1)})}return n1.$$set=y1=>{"label"in y1&&t1(2,o1=y1.label),"value"in y1&&t1(0,i1=y1.value),"type"in y1&&t1(3,a1=y1.type),"disabled"in y1&&t1(4,s1=y1.disabled),"error"in y1&&t1(1,l1=y1.error),"validate"in y1&&t1(5,c1=y1.validate),"suffix"in y1&&t1(6,u1=y1.suffix)},n1.$$.update=()=>{n1.$$.dirty&2177&&t1(9,r1=!m1&&!p1&&!i1)},[i1,l1,o1,a1,s1,c1,u1,p1,d1,r1,_1,m1,h1,g1,$1]}class FancyInput extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8f,create_fragment$84,safe_not_equal,{label:2,value:0,type:3,disabled:4,error:1,validate:5,suffix:6})}}const FancyCheckbox_svelte_svelte_type_style_lang="";function create_if_block$3M(n1){let e1;return{c(){e1=text(n1[2])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&4&&set_data(e1,t1[2])},d(t1){t1&&detach(e1)}}}function create_default_slot$58(n1){let e1,t1,r1,o1,i1,a1;t1=new Checkbox({props:{disabled:n1[3],value:n1[0],indeterminate:n1[5]}});let s1=n1[2]&&create_if_block$3M(n1);const l1=n1[8].default,c1=create_slot(l1,n1,n1[9],null);return{c(){e1=element("span"),create_component(t1.$$.fragment),r1=space$1(),o1=element("div"),s1&&s1.c(),i1=space$1(),c1&&c1.c(),attr(e1,"class","svelte-14uwzyc"),attr(o1,"class","text svelte-14uwzyc"),toggle_class(o1,"compact",n1[6])},m(u1,f1){insert$1(u1,e1,f1),mount_component(t1,e1,null),insert$1(u1,r1,f1),insert$1(u1,o1,f1),s1&&s1.m(o1,null),append$1(o1,i1),c1&&c1.m(o1,null),a1=!0},p(u1,f1){const d1={};f1&8&&(d1.disabled=u1[3]),f1&1&&(d1.value=u1[0]),f1&32&&(d1.indeterminate=u1[5]),t1.$set(d1),u1[2]?s1?s1.p(u1,f1):(s1=create_if_block$3M(u1),s1.c(),s1.m(o1,i1)):s1&&(s1.d(1),s1=null),c1&&c1.p&&(!a1||f1&512)&&update_slot_base(c1,l1,u1,u1[9],a1?get_slot_changes(l1,u1[9],f1,null):get_all_dirty_from_scope(u1[9]),null),(!a1||f1&64)&&toggle_class(o1,"compact",u1[6])},i(u1){a1||(transition_in(t1.$$.fragment,u1),transition_in(c1,u1),a1=!0)},o(u1){transition_out(t1.$$.fragment,u1),transition_out(c1,u1),a1=!1},d(u1){u1&&detach(e1),destroy_component(t1),u1&&detach(r1),u1&&detach(o1),s1&&s1.d(),c1&&c1.d(u1)}}}function create_fragment$83(n1){let e1,t1;return e1=new FancyField({props:{error:n1[1],value:n1[0],validate:n1[4],disabled:n1[3],compact:n1[6],clickable:!0,$$slots:{default:[create_default_slot$58]},$$scope:{ctx:n1}}}),e1.$on("click",n1[7]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&2&&(i1.error=r1[1]),o1&1&&(i1.value=r1[0]),o1&16&&(i1.validate=r1[4]),o1&8&&(i1.disabled=r1[3]),o1&64&&(i1.compact=r1[6]),o1&621&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8e(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{value:i1}=e1,{text:a1}=e1,{disabled:s1=!1}=e1,{error:l1=null}=e1,{validate:c1=null}=e1,{indeterminate:u1=!1}=e1,{compact:f1=!1}=e1;const d1=createEventDispatcher(),p1=()=>{const m1=!i1;d1("change",m1),t1(0,i1=m1),c1&&t1(1,l1=c1(m1))};return n1.$$set=m1=>{"value"in m1&&t1(0,i1=m1.value),"text"in m1&&t1(2,a1=m1.text),"disabled"in m1&&t1(3,s1=m1.disabled),"error"in m1&&t1(1,l1=m1.error),"validate"in m1&&t1(4,c1=m1.validate),"indeterminate"in m1&&t1(5,u1=m1.indeterminate),"compact"in m1&&t1(6,f1=m1.compact),"$$scope"in m1&&t1(9,o1=m1.$$scope)},[i1,l1,a1,s1,c1,u1,f1,p1,r1,o1]}class FancyCheckbox extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8e,create_fragment$83,safe_not_equal,{value:0,text:2,disabled:3,error:1,validate:4,indeterminate:5,compact:6})}}const FancySelect_svelte_svelte_type_style_lang="";function create_if_block_1$25(n1){let e1,t1;return e1=new FancyFieldLabel({props:{placeholder:n1[16],$$slots:{default:[create_default_slot_1$3I]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&65536&&(i1.placeholder=r1[16]),o1&67108868&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_default_slot_1$3I(n1){let e1;return{c(){e1=text(n1[2])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&4&&set_data(e1,t1[2])},d(t1){t1&&detach(e1)}}}function create_if_block$3L(n1){let e1,t1,r1;return t1=new StatusLight({props:{square:!0,color:n1[14]}}),{c(){e1=element("span"),create_component(t1.$$.fragment),attr(e1,"class","align svelte-18t7xb4")},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,i1){const a1={};i1&16384&&(a1.color=o1[14]),t1.$set(a1)},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function create_default_slot$57(n1){let e1,t1,r1,o1=(n1[15]||"")+"",i1,a1,s1,l1,c1,u1=n1[2]&&create_if_block_1$25(n1),f1=n1[14]&&create_if_block$3L(n1);return l1=new Icon({props:{name:"ChevronDown"}}),{c(){u1&&u1.c(),e1=space$1(),f1&&f1.c(),t1=space$1(),r1=element("div"),i1=text(o1),a1=space$1(),s1=element("div"),create_component(l1.$$.fragment),attr(r1,"class","value svelte-18t7xb4"),toggle_class(r1,"placeholder",n1[16]),attr(s1,"class","align arrow-alignment svelte-18t7xb4")},m(d1,p1){u1&&u1.m(d1,p1),insert$1(d1,e1,p1),f1&&f1.m(d1,p1),insert$1(d1,t1,p1),insert$1(d1,r1,p1),append$1(r1,i1),insert$1(d1,a1,p1),insert$1(d1,s1,p1),mount_component(l1,s1,null),c1=!0},p(d1,p1){d1[2]?u1?(u1.p(d1,p1),p1&4&&transition_in(u1,1)):(u1=create_if_block_1$25(d1),u1.c(),transition_in(u1,1),u1.m(e1.parentNode,e1)):u1&&(group_outros(),transition_out(u1,1,1,()=>{u1=null}),check_outros()),d1[14]?f1?(f1.p(d1,p1),p1&16384&&transition_in(f1,1)):(f1=create_if_block$3L(d1),f1.c(),transition_in(f1,1),f1.m(t1.parentNode,t1)):f1&&(group_outros(),transition_out(f1,1,1,()=>{f1=null}),check_outros()),(!c1||p1&32768)&&o1!==(o1=(d1[15]||"")+"")&&set_data(i1,o1),(!c1||p1&65536)&&toggle_class(r1,"placeholder",d1[16])},i(d1){c1||(transition_in(u1),transition_in(f1),transition_in(l1.$$.fragment,d1),c1=!0)},o(d1){transition_out(u1),transition_out(f1),transition_out(l1.$$.fragment,d1),c1=!1},d(d1){u1&&u1.d(d1),d1&&detach(e1),f1&&f1.d(d1),d1&&detach(t1),d1&&detach(r1),d1&&detach(a1),d1&&detach(s1),destroy_component(l1)}}}function create_fragment$82(n1){let e1,t1,r1,o1,i1,a1,s1;function l1(d1){n1[18](d1)}let c1={error:n1[1],value:n1[0],validate:n1[4],disabled:n1[3],clickable:!0,$$slots:{default:[create_default_slot$57]},$$scope:{ctx:n1}};n1[13]!==void 0&&(c1.ref=n1[13]),e1=new FancyField({props:c1}),binding_callbacks.push(()=>bind$2(e1,"ref",l1)),e1.$on("click",n1[19]);function u1(d1){n1[21](d1)}let f1={customAnchor:n1[13],onlyPopover:!0,error:n1[1],disabled:n1[3],options:n1[5],footer:n1[6],getOptionLabel:n1[8],getOptionValue:n1[9],getOptionSubtitle:n1[10],getOptionColour:n1[11],isOptionEnabled:n1[7],isPlaceholder:n1[0]==null||n1[0]==="",placeholderOption:n1[16]===!1?null:n1[16],onSelectOption:n1[17],isOptionSelected:n1[20]};return n1[12]!==void 0&&(f1.open=n1[12]),i1=new Picker({props:f1}),binding_callbacks.push(()=>bind$2(i1,"open",u1)),{c(){create_component(e1.$$.fragment),r1=space$1(),o1=element("div"),create_component(i1.$$.fragment),attr(o1,"id","picker-wrapper"),attr(o1,"class","svelte-18t7xb4")},m(d1,p1){mount_component(e1,d1,p1),insert$1(d1,r1,p1),insert$1(d1,o1,p1),mount_component(i1,o1,null),s1=!0},p(d1,[p1]){const m1={};p1&2&&(m1.error=d1[1]),p1&1&&(m1.value=d1[0]),p1&16&&(m1.validate=d1[4]),p1&8&&(m1.disabled=d1[3]),p1&67223556&&(m1.$$scope={dirty:p1,ctx:d1}),!t1&&p1&8192&&(t1=!0,m1.ref=d1[13],add_flush_callback(()=>t1=!1)),e1.$set(m1);const _1={};p1&8192&&(_1.customAnchor=d1[13]),p1&2&&(_1.error=d1[1]),p1&8&&(_1.disabled=d1[3]),p1&32&&(_1.options=d1[5]),p1&64&&(_1.footer=d1[6]),p1&256&&(_1.getOptionLabel=d1[8]),p1&512&&(_1.getOptionValue=d1[9]),p1&1024&&(_1.getOptionSubtitle=d1[10]),p1&2048&&(_1.getOptionColour=d1[11]),p1&128&&(_1.isOptionEnabled=d1[7]),p1&1&&(_1.isPlaceholder=d1[0]==null||d1[0]===""),p1&65536&&(_1.placeholderOption=d1[16]===!1?null:d1[16]),p1&1&&(_1.isOptionSelected=d1[20]),!a1&&p1&4096&&(a1=!0,_1.open=d1[12],add_flush_callback(()=>a1=!1)),i1.$set(_1)},i(d1){s1||(transition_in(e1.$$.fragment,d1),transition_in(i1.$$.fragment,d1),s1=!0)},o(d1){transition_out(e1.$$.fragment,d1),transition_out(i1.$$.fragment,d1),s1=!1},d(d1){destroy_component(e1,d1),d1&&detach(r1),d1&&detach(o1),destroy_component(i1)}}}function instance$8d(n1,e1,t1){let r1,o1,i1,{label:a1}=e1,{value:s1}=e1,{disabled:l1=!1}=e1,{error:c1=null}=e1,{validate:u1=null}=e1,{options:f1=[]}=e1,{footer:d1=null}=e1,{isOptionEnabled:p1=()=>!0}=e1,{getOptionLabel:m1=F1=>O1(F1,"label")}=e1,{getOptionValue:_1=F1=>O1(F1,"value")}=e1,{getOptionSubtitle:h1=F1=>O1(F1,"subtitle")}=e1,{getOptionColour:g1=()=>null}=e1;const $1=createEventDispatcher();let y1=!1,v1;const S1=(F1,B1,L1)=>{if(!(L1!=null&&L1.length))return"";const U1=L1.findIndex((j1,Q1)=>_1(j1,Q1)===B1);return U1!==-1?F1(L1[U1],U1):null},O1=(F1,B1)=>F1&&typeof F1=="object"?F1[B1]:F1,C1=F1=>{$1("change",F1),t1(0,s1=F1),u1&&t1(1,c1=u1(F1)),t1(12,y1=!1)},M1=F1=>{if(!F1||!(f1!=null&&f1.length))return"";const B1=f1.find(L1=>_1(L1)===F1);return B1?m1(B1):F1};function z1(F1){v1=F1,t1(13,v1)}const P1=()=>t1(12,y1=!0),R1=F1=>F1===s1;function N1(F1){y1=F1,t1(12,y1)}return n1.$$set=F1=>{"label"in F1&&t1(2,a1=F1.label),"value"in F1&&t1(0,s1=F1.value),"disabled"in F1&&t1(3,l1=F1.disabled),"error"in F1&&t1(1,c1=F1.error),"validate"in F1&&t1(4,u1=F1.validate),"options"in F1&&t1(5,f1=F1.options),"footer"in F1&&t1(6,d1=F1.footer),"isOptionEnabled"in F1&&t1(7,p1=F1.isOptionEnabled),"getOptionLabel"in F1&&t1(8,m1=F1.getOptionLabel),"getOptionValue"in F1&&t1(9,_1=F1.getOptionValue),"getOptionSubtitle"in F1&&t1(10,h1=F1.getOptionSubtitle),"getOptionColour"in F1&&t1(11,g1=F1.getOptionColour)},n1.$$.update=()=>{n1.$$.dirty&1&&t1(16,r1=!s1),n1.$$.dirty&1&&t1(15,o1=M1(s1)),n1.$$.dirty&2081&&t1(14,i1=S1(g1,s1,f1))},[s1,c1,a1,l1,u1,f1,d1,p1,m1,_1,h1,g1,y1,v1,i1,o1,r1,C1,z1,P1,R1,N1]}class FancySelect extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8d,create_fragment$82,safe_not_equal,{label:2,value:0,disabled:3,error:1,validate:4,options:5,footer:6,isOptionEnabled:7,getOptionLabel:8,getOptionValue:9,getOptionSubtitle:10,getOptionColour:11})}}const FancyButton_svelte_svelte_type_style_lang="",get_icon_slot_changes$2=n1=>({}),get_icon_slot_context$2=n1=>({});function create_if_block$3K(n1){let e1,t1,r1,o1,i1;const a1=[create_if_block_1$24,create_else_block$1o],s1=[];function l1(c1,u1){return u1&1&&(e1=null),e1==null&&(e1=!!c1[0].includes("/")),e1?0:1}return t1=l1(n1,-1),r1=s1[t1]=a1[t1](n1),{c(){r1.c(),o1=empty$1()},m(c1,u1){s1[t1].m(c1,u1),insert$1(c1,o1,u1),i1=!0},p(c1,u1){let f1=t1;t1=l1(c1,u1),t1===f1?s1[t1].p(c1,u1):(group_outros(),transition_out(s1[f1],1,1,()=>{s1[f1]=null}),check_outros(),r1=s1[t1],r1?r1.p(c1,u1):(r1=s1[t1]=a1[t1](c1),r1.c()),transition_in(r1,1),r1.m(o1.parentNode,o1))},i(c1){i1||(transition_in(r1),i1=!0)},o(c1){transition_out(r1),i1=!1},d(c1){s1[t1].d(c1),c1&&detach(o1)}}}function create_else_block$1o(n1){let e1,t1;return e1=new Icon({props:{name:n1[0]}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&1&&(i1.name=r1[0]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_if_block_1$24(n1){let e1,t1;return{c(){e1=element("img"),src_url_equal(e1.src,t1=n1[0])||attr(e1,"src",t1),attr(e1,"alt","button"),attr(e1,"class","svelte-14pbp5s")},m(r1,o1){insert$1(r1,e1,o1)},p(r1,o1){o1&1&&!src_url_equal(e1.src,t1=r1[0])&&attr(e1,"src",t1)},i:noop$5,o:noop$5,d(r1){r1&&detach(e1)}}}function create_default_slot$56(n1){let e1,t1,r1,o1,i1=n1[0]&&create_if_block$3K(n1);const a1=n1[2].icon,s1=create_slot(a1,n1,n1[4],get_icon_slot_context$2),l1=n1[2].default,c1=create_slot(l1,n1,n1[4],null);return{c(){i1&&i1.c(),e1=space$1(),s1&&s1.c(),t1=space$1(),r1=element("div"),c1&&c1.c(),attr(r1,"class","svelte-14pbp5s")},m(u1,f1){i1&&i1.m(u1,f1),insert$1(u1,e1,f1),s1&&s1.m(u1,f1),insert$1(u1,t1,f1),insert$1(u1,r1,f1),c1&&c1.m(r1,null),o1=!0},p(u1,f1){u1[0]?i1?(i1.p(u1,f1),f1&1&&transition_in(i1,1)):(i1=create_if_block$3K(u1),i1.c(),transition_in(i1,1),i1.m(e1.parentNode,e1)):i1&&(group_outros(),transition_out(i1,1,1,()=>{i1=null}),check_outros()),s1&&s1.p&&(!o1||f1&16)&&update_slot_base(s1,a1,u1,u1[4],o1?get_slot_changes(a1,u1[4],f1,get_icon_slot_changes$2):get_all_dirty_from_scope(u1[4]),get_icon_slot_context$2),c1&&c1.p&&(!o1||f1&16)&&update_slot_base(c1,l1,u1,u1[4],o1?get_slot_changes(l1,u1[4],f1,null):get_all_dirty_from_scope(u1[4]),null)},i(u1){o1||(transition_in(i1),transition_in(s1,u1),transition_in(c1,u1),o1=!0)},o(u1){transition_out(i1),transition_out(s1,u1),transition_out(c1,u1),o1=!1},d(u1){i1&&i1.d(u1),u1&&detach(e1),s1&&s1.d(u1),u1&&detach(t1),u1&&detach(r1),c1&&c1.d(u1)}}}function create_fragment$81(n1){let e1,t1;return e1=new FancyField({props:{clickable:!0,disabled:n1[1],$$slots:{default:[create_default_slot$56]},$$scope:{ctx:n1}}}),e1.$on("click",n1[3]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&2&&(i1.disabled=r1[1]),o1&17&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$8c(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{icon:i1}=e1,{disabled:a1}=e1;function s1(l1){bubble.call(this,n1,l1)}return n1.$$set=l1=>{"icon"in l1&&t1(0,i1=l1.icon),"disabled"in l1&&t1(1,a1=l1.disabled),"$$scope"in l1&&t1(4,o1=l1.$$scope)},[i1,a1,r1,s1,o1]}class FancyButton extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8c,create_fragment$81,safe_not_equal,{icon:0,disabled:1})}}const FancyForm_svelte_svelte_type_style_lang="";function create_fragment$80(n1){let e1,t1;const r1=n1[2].default,o1=create_slot(r1,n1,n1[1],null);return{c(){e1=element("div"),o1&&o1.c(),attr(e1,"class","fancy-form svelte-1wjd4hl")},m(i1,a1){insert$1(i1,e1,a1),o1&&o1.m(e1,null),t1=!0},p(i1,[a1]){o1&&o1.p&&(!t1||a1&2)&&update_slot_base(o1,r1,i1,i1[1],t1?get_slot_changes(r1,i1[1],a1,null):get_all_dirty_from_scope(i1[1]),null)},i(i1){t1||(transition_in(o1,i1),t1=!0)},o(i1){transition_out(o1,i1),t1=!1},d(i1){i1&&detach(e1),o1&&o1.d(i1)}}}function instance$8b(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,i1={};setContext("fancy-form",{registerField:(s1,l1)=>{i1={...i1,[s1]:l1}},unregisterField:s1=>{delete i1[s1],i1=i1}});const a1=()=>{let s1=!0;return Object.values(i1).forEach(l1=>{l1.validate()||(s1=!1)}),s1};return n1.$$set=s1=>{"$$scope"in s1&&t1(1,o1=s1.$$scope)},[a1,o1,r1]}class FancyForm extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8b,create_fragment$80,safe_not_equal,{validate:0})}get validate(){return this.$$.ctx[0]}}const FancyButtonRadio_svelte_svelte_type_style_lang="",FancyCheckboxGroup_svelte_svelte_type_style_lang="";function get_each_context$1y(n1,e1,t1){const r1=n1.slice();return r1[14]=e1[t1],r1[15]=e1,r1[16]=t1,r1}function create_if_block$3J(n1){let e1,t1,r1;return t1=new FancyForm({props:{$$slots:{default:[create_default_slot$55]},$$scope:{ctx:n1}}}),t1.$on("change",n1[10]),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","checkbox-group svelte-2g5wlw"),toggle_class(e1,"has-select-all",n1[1])},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,i1){const a1={};i1&131135&&(a1.$$scope={dirty:i1,ctx:o1}),t1.$set(a1),(!r1||i1&2)&&toggle_class(e1,"has-select-all",o1[1])},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function create_if_block_1$23(n1){let e1,t1,r1;function o1(a1){n1[8](a1)}let i1={text:n1[2],indeterminate:!n1[4]&&!n1[5],compact:!0};return n1[4]!==void 0&&(i1.value=n1[4]),e1=new FancyCheckbox({props:i1}),binding_callbacks.push(()=>bind$2(e1,"value",o1)),e1.$on("change",n1[6]),{c(){create_component(e1.$$.fragment)},m(a1,s1){mount_component(e1,a1,s1),r1=!0},p(a1,s1){const l1={};s1&4&&(l1.text=a1[2]),s1&48&&(l1.indeterminate=!a1[4]&&!a1[5]),!t1&&s1&16&&(t1=!0,l1.value=a1[4],add_flush_callback(()=>t1=!1)),e1.$set(l1)},i(a1){r1||(transition_in(e1.$$.fragment,a1),r1=!0)},o(a1){transition_out(e1.$$.fragment,a1),r1=!1},d(a1){destroy_component(e1,a1)}}}function create_each_block$1y(n1){let e1,t1,r1;function o1(a1){n1[9](a1,n1[16])}let i1={text:n1[14],compact:!0};return n1[3][n1[16]]!==void 0&&(i1.value=n1[3][n1[16]]),e1=new FancyCheckbox({props:i1}),binding_callbacks.push(()=>bind$2(e1,"value",o1)),{c(){create_component(e1.$$.fragment)},m(a1,s1){mount_component(e1,a1,s1),r1=!0},p(a1,s1){n1=a1;const l1={};s1&1&&(l1.text=n1[14]),!t1&&s1&8&&(t1=!0,l1.value=n1[3][n1[16]],add_flush_callback(()=>t1=!1)),e1.$set(l1)},i(a1){r1||(transition_in(e1.$$.fragment,a1),r1=!0)},o(a1){transition_out(e1.$$.fragment,a1),r1=!1},d(a1){destroy_component(e1,a1)}}}function create_default_slot$55(n1){let e1,t1,r1,o1=n1[1]&&create_if_block_1$23(n1),i1=n1[0],a1=[];for(let l1=0;l1<i1.length;l1+=1)a1[l1]=create_each_block$1y(get_each_context$1y(n1,i1,l1));const s1=l1=>transition_out(a1[l1],1,1,()=>{a1[l1]=null});return{c(){o1&&o1.c(),e1=space$1();for(let l1=0;l1<a1.length;l1+=1)a1[l1].c();t1=empty$1()},m(l1,c1){o1&&o1.m(l1,c1),insert$1(l1,e1,c1);for(let u1=0;u1<a1.length;u1+=1)a1[u1].m(l1,c1);insert$1(l1,t1,c1),r1=!0},p(l1,c1){if(l1[1]?o1?(o1.p(l1,c1),c1&2&&transition_in(o1,1)):(o1=create_if_block_1$23(l1),o1.c(),transition_in(o1,1),o1.m(e1.parentNode,e1)):o1&&(group_outros(),transition_out(o1,1,1,()=>{o1=null}),check_outros()),c1&9){i1=l1[0];let u1;for(u1=0;u1<i1.length;u1+=1){const f1=get_each_context$1y(l1,i1,u1);a1[u1]?(a1[u1].p(f1,c1),transition_in(a1[u1],1)):(a1[u1]=create_each_block$1y(f1),a1[u1].c(),transition_in(a1[u1],1),a1[u1].m(t1.parentNode,t1))}for(group_outros(),u1=i1.length;u1<a1.length;u1+=1)s1(u1);check_outros()}},i(l1){if(!r1){transition_in(o1);for(let c1=0;c1<i1.length;c1+=1)transition_in(a1[c1]);r1=!0}},o(l1){transition_out(o1),a1=a1.filter(Boolean);for(let c1=0;c1<a1.length;c1+=1)transition_out(a1[c1]);r1=!1},d(l1){o1&&o1.d(l1),l1&&detach(e1),destroy_each(a1,l1),l1&&detach(t1)}}}function create_fragment$7$(n1){let e1=n1[0]&&Array.isArray(n1[0]),t1,r1,o1=e1&&create_if_block$3J(n1);return{c(){o1&&o1.c(),t1=empty$1()},m(i1,a1){o1&&o1.m(i1,a1),insert$1(i1,t1,a1),r1=!0},p(i1,[a1]){a1&1&&(e1=i1[0]&&Array.isArray(i1[0])),e1?o1?(o1.p(i1,a1),a1&1&&transition_in(o1,1)):(o1=create_if_block$3J(i1),o1.c(),transition_in(o1,1),o1.m(t1.parentNode,t1)):o1&&(group_outros(),transition_out(o1,1,1,()=>{o1=null}),check_outros())},i(i1){r1||(transition_in(o1),r1=!0)},o(i1){transition_out(o1),r1=!1},d(i1){o1&&o1.d(i1),i1&&detach(t1)}}}function instance$8a(n1,e1,t1){let r1,o1,{options:i1=[]}=e1,{selected:a1=[]}=e1,{showSelectAll:s1=!0}=e1,{selectAllText:l1="Select all"}=e1,c1=i1.map(g1=>a1.indexOf(g1)>-1);const u1=createEventDispatcher();function f1(){return Array(i1.length).fill(!0)}function d1(g1){const $1=[];for(let[y1,v1]of Object.entries(g1))v1&&$1.push(i1[y1]);t1(7,a1=$1),u1("change",a1)}function p1(){r1===!0?t1(3,c1=[]):t1(3,c1=f1()),u1("change",a1)}function m1(g1){r1=g1,t1(4,r1),t1(7,a1),t1(0,i1)}function _1(g1,$1){n1.$$.not_equal(c1[$1],g1)&&(c1[$1]=g1,t1(3,c1))}function h1(g1){bubble.call(this,n1,g1)}return n1.$$set=g1=>{"options"in g1&&t1(0,i1=g1.options),"selected"in g1&&t1(7,a1=g1.selected),"showSelectAll"in g1&&t1(1,s1=g1.showSelectAll),"selectAllText"in g1&&t1(2,l1=g1.selectAllText)},n1.$$.update=()=>{n1.$$.dirty&8&&d1(c1),n1.$$.dirty&129&&t1(4,r1=(a1==null?void 0:a1.length)===i1.length),n1.$$.dirty&128&&t1(5,o1=!(a1!=null&&a1.length))},[i1,s1,l1,c1,r1,o1,p1,a1,m1,_1,h1]}class FancyCheckboxGroup extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$8a,create_fragment$7$,safe_not_equal,{options:0,selected:7,showSelectAll:1,selectAllText:2})}}const Cookies={Auth:"budibase:auth",CurrentApp:"budibase:currentapp",ReturnUrl:"budibase:returnurl",AccountReturnUrl:"budibase:account:returnurl"},TableNames$1={USERS:"ta_users"},BudibaseRoles={AppUser:"appUser",Developer:"developer",Creator:"creator",Admin:"admin"},BudibaseRoleOptionsOld=[{label:"Developer",value:BudibaseRoles.Developer}],BudibaseRoleOptions=[{label:"Account admin",value:BudibaseRoles.Admin,subtitle:"Has full access to all apps and settings in your account"},{label:"Creator",value:BudibaseRoles.Creator,subtitle:"Can create and edit apps they have access to"},{label:"App user",value:BudibaseRoles.AppUser,subtitle:"Can only use published apps they have access to"}],PlanType={FREE:"free",TEAM:"team",PRO:"pro",BUSINESS:"business",ENTERPRISE:"enterprise"},ApiVersion="1",Roles$1={ADMIN:"ADMIN",POWER:"POWER",BASIC:"BASIC",PUBLIC:"PUBLIC",BUILDER:"BUILDER",CREATOR:"CREATOR"},Themes=[{class:"lightest",name:"Lightest"},{class:"light",name:"Light"},{class:"dark",name:"Dark"},{class:"darkest",name:"Darkest"},{class:"nord",name:"Nord",base:"darkest"},{class:"midnight",name:"Midnight",base:"darkest"}],EventPublishType={ENV_VAR_UPGRADE_PANEL_OPENED:"environment_variable_upgrade_panel_opened"},Constants=Object.freeze(Object.defineProperty({__proto__:null,ApiVersion,BudibaseRoleOptions,BudibaseRoleOptionsOld,BudibaseRoles,Cookies,EventPublishType,Features:Feature,OperatorOptions,PlanType,Roles:Roles$1,SqlNumberTypeRangeMap,TableNames:TableNames$1,Themes},Symbol.toStringTag,{value:"Module"})),buildAnalyticsEndpoints=n1=>({getAnalyticsStatus:async()=>await n1.get({url:"/api/bbtel"}),analyticsPing:async({source:e1,embedded:t1})=>{const r1=Intl.DateTimeFormat().resolvedOptions().timeZone;return await n1.post({url:"/api/bbtel/ping",body:{source:e1,timezone:r1,embedded:t1}})}}),buildAppEndpoints=n1=>({fetchAppPackage:async e1=>await n1.get({url:`/api/applications/${e1}/appPackage`}),saveAppMetadata:async({appId:e1,metadata:t1})=>await n1.put({url:`/api/applications/${e1}`,body:t1}),publishAppChanges:async e1=>await n1.post({url:`/api/applications/${e1}/publish`}),revertAppChanges:async e1=>await n1.post({url:`/api/dev/${e1}/revert`}),updateAppClientVersion:async e1=>await n1.post({url:`/api/applications/${e1}/client/update`}),revertAppClientVersion:async e1=>await n1.post({url:`/api/applications/${e1}/client/revert`}),getAppDeployments:async()=>await n1.get({url:"/api/deployments"}),createApp:async e1=>await n1.post({url:"/api/applications",body:e1,json:!1}),updateAppFromExport:async(e1,t1)=>{const r1=getDevAppID(e1);return await n1.post({url:`/api/applications/${r1}/import`,body:t1,json:!1})},importApps:async e1=>await n1.post({url:"/api/cloud/import",body:e1,json:!1}),unpublishApp:async e1=>await n1.post({url:`/api/applications/${e1}/unpublish`}),deleteApp:async e1=>await n1.delete({url:`/api/applications/${e1}`}),releaseAppLock:async e1=>await n1.delete({url:`/api/dev/${e1}/lock`}),fetchSystemDebugInfo:async()=>await n1.get({url:"/api/debug/diagnostics"}),syncApp:async e1=>await n1.post({url:`/api/applications/${e1}/sync`}),getApps:async()=>await n1.get({url:"/api/applications?status=all"}),fetchComponentLibDefinitions:async e1=>await n1.get({url:`/api/${e1}/components/definitions`}),addSampleData:async e1=>await n1.post({url:`/api/applications/${e1}/sample`})}),buildAttachmentEndpoints=n1=>{const e1=async({datasourceId:t1,bucket:r1,key:o1})=>await n1.post({url:`/api/attachments/${t1}/url`,body:{bucket:r1,key:o1}});return{getSignedDatasourceURL:e1,uploadAttachment:async({data:t1,tableId:r1})=>await n1.post({url:`/api/attachments/${r1}/upload`,body:t1,json:!1}),uploadBuilderAttachment:async t1=>await n1.post({url:"/api/attachments/process",body:t1,json:!1}),externalUpload:async({datasourceId:t1,bucket:r1,key:o1,data:i1})=>{const{signedUrl:a1,publicUrl:s1}=await e1({datasourceId:t1,bucket:r1,key:o1});return await n1.put({url:a1,body:i1,json:!1,external:!0}),{publicUrl:s1}},deleteAttachments:async({keys:t1,tableId:r1})=>await n1.post({url:`/api/attachments/${r1}/delete`,body:{keys:t1}}),deleteBuilderAttachments:async t1=>await n1.post({url:"/api/attachments/delete",body:{keys:t1}})}},buildAuthEndpoints=n1=>({logIn:async({tenantId:e1,username:t1,password:r1})=>await n1.post({url:`/api/global/auth/${e1}/login`,body:{username:t1,password:r1}}),logOut:async()=>await n1.post({url:"/api/global/auth/logout"}),setInitInfo:async e1=>await n1.post({url:"/api/global/auth/init",body:e1}),getInitInfo:async()=>await n1.get({url:"/api/global/auth/init"}),requestForgotPassword:async({tenantId:e1,email:t1})=>await n1.post({url:`/api/global/auth/${e1}/reset`,body:{email:t1}}),resetPassword:async({tenantId:e1,password:t1,resetCode:r1})=>await n1.post({url:`/api/global/auth/${e1}/reset/update`,body:{password:t1,resetCode:r1}})}),buildAutomationEndpoints=n1=>({triggerAutomation:async({automationId:e1,fields:t1,timeout:r1})=>await n1.post({url:`/api/automations/${e1}/trigger`,body:{fields:t1,timeout:r1}}),testAutomation:async({automationId:e1,testData:t1})=>await n1.post({url:`/api/automations/${e1}/test`,body:t1}),getAutomations:async()=>await n1.get({url:"/api/automations"}),getAutomationDefinitions:async()=>await n1.get({url:"/api/automations/definitions/list"}),createAutomation:async e1=>await n1.post({url:"/api/automations",body:e1}),updateAutomation:async e1=>await n1.put({url:"/api/automations",body:e1}),deleteAutomation:async({automationId:e1,automationRev:t1})=>await n1.delete({url:`/api/automations/${e1}/${t1}`}),getAutomationLogs:async({automationId:e1,startDate:t1,status:r1,page:o1})=>await n1.post({url:"/api/automations/logs/search",body:{automationId:e1,startDate:t1,status:r1,page:o1}}),clearAutomationLogErrors:async({automationId:e1,appId:t1})=>await n1.delete({url:"/api/automations/logs",body:{appId:t1,automationId:e1}})}),buildConfigEndpoints=n1=>({saveConfig:async e1=>await n1.post({url:"/api/global/configs",body:e1}),getConfig:async e1=>await n1.get({url:`/api/global/configs/${e1}`}),deleteConfig:async({id:e1,rev:t1})=>await n1.delete({url:`/api/global/configs/${e1}/${t1}`}),getTenantConfig:async e1=>await n1.get({url:`/api/global/configs/public?tenantId=${e1}`}),getOIDCConfig:async e1=>await n1.get({url:`/api/global/configs/public/oidc?tenantId=${e1}`}),getChecklist:async e1=>await n1.get({url:`/api/global/configs/checklist?tenantId=${e1}`}),uploadLogo:async e1=>await n1.post({url:"/api/global/configs/upload/settings/logoUrl",body:e1,json:!1}),uploadFavicon:async e1=>await n1.post({url:"/api/global/configs/upload/settings/faviconUrl",body:e1,json:!1}),uploadOIDCLogo:async({name:e1,data:t1})=>await n1.post({url:`/api/global/configs/upload/logos_oidc/${e1}`,body:t1,json:!1}),getOIDCLogos:async()=>await n1.get({url:"/api/global/configs/logos_oidc"})}),buildDatasourceEndpoints=n1=>({getDatasources:async()=>await n1.get({url:"/api/datasources"}),buildDatasourceSchema:async({datasourceId:e1,tablesFilter:t1})=>await n1.post({url:`/api/datasources/${e1}/schema`,body:{tablesFilter:t1}}),createDatasource:async({datasource:e1,fetchSchema:t1,tablesFilter:r1})=>await n1.post({url:"/api/datasources",body:{datasource:e1,fetchSchema:t1,tablesFilter:r1}}),updateDatasource:async e1=>await n1.put({url:`/api/datasources/${e1._id}`,body:e1}),deleteDatasource:async({datasourceId:e1,datasourceRev:t1})=>await n1.delete({url:`/api/datasources/${e1}/${t1}`}),validateDatasource:async e1=>await n1.post({url:"/api/datasources/verify",body:{datasource:e1}}),fetchInfoForDatasource:async e1=>await n1.post({url:"/api/datasources/info",body:{datasource:e1}}),fetchExternalSchema:async e1=>await n1.get({url:`/api/datasources/${e1}/schema/external`})}),buildFlagEndpoints=n1=>({getFlags:async()=>await n1.get({url:"/api/users/flags"}),updateFlag:async({flag:e1,value:t1})=>await n1.post({url:"/api/users/flags",body:{flag:e1,value:t1}}),toggleUiFeature:async({value:e1})=>await n1.post({url:`/api/beta/${e1}`})}),buildHostingEndpoints=n1=>({getHostingURLs:async()=>await n1.get({url:"/api/hosting/urls"}),getDeployedApps:async()=>await n1.get({url:"/api/hosting/apps"})}),buildLayoutEndpoints=n1=>({saveLayout:async e1=>await n1.post({url:"/api/layouts",body:e1}),deleteLayout:async({layoutId:e1,layoutRev:t1})=>await n1.delete({url:`/api/layouts/${e1}/${t1}`})}),buildOtherEndpoints=n1=>({getEnvironment:async()=>await n1.get({url:"/api/system/environment"}),getSystemStatus:async()=>await n1.get({url:"/api/system/status"}),getIntegrations:async()=>await n1.get({url:"/api/integrations"}),getBudibaseVersion:async()=>(await n1.get({url:"/api/dev/version"})).version,getBasePermissions:async()=>await n1.get({url:"/api/permission/builtin"}),checkBetaAccess:async e1=>await n1.get({url:`/api/beta/access?email=${e1}`,external:!0})}),buildPermissionsEndpoints=n1=>({getPermissionForResource:async e1=>await n1.get({url:`/api/permission/${e1}`}),updatePermissionForResource:async({resourceId:e1,roleId:t1,level:r1})=>await n1.post({url:`/api/permission/${t1}/${e1}/${r1}`}),removePermissionFromResource:async({resourceId:e1,roleId:t1,level:r1})=>await n1.delete({url:`/api/permission/${t1}/${e1}/${r1}`}),getDependants:async e1=>await n1.get({url:`/api/permission/${e1}/dependants`})}),buildQueryEndpoints=n1=>({executeQuery:async({queryId:e1,pagination:t1,parameters:r1})=>await n1.post({url:`/api/v2/queries/${e1}`,body:{parameters:r1,pagination:t1}}),fetchQueryDefinition:async e1=>await n1.get({url:`/api/queries/${e1}`,cache:!0}),getQueries:async()=>await n1.get({url:"/api/queries"}),saveQuery:async e1=>await n1.post({url:"/api/queries",body:e1}),deleteQuery:async({queryId:e1,queryRev:t1})=>await n1.delete({url:`/api/queries/${e1}/${t1}`}),importQueries:async({datasourceId:e1,data:t1})=>await n1.post({url:"/api/queries/import",body:{datasourceId:e1,data:t1}}),previewQuery:async e1=>await n1.post({url:"/api/queries/preview",body:e1})}),buildRelationshipEndpoints=n1=>({fetchRelationshipData:async({tableId:e1,rowId:t1,fieldName:r1})=>{if(!e1||!t1)return[];const o1=await n1.get({url:`/api/${e1}/${t1}/enrich?field=${r1}`});return r1?o1[r1]||[]:o1||[]}}),buildRoleEndpoints=n1=>({deleteRole:async({roleId:e1,roleRev:t1})=>await n1.delete({url:`/api/roles/${e1}/${t1}`}),saveRole:async e1=>await n1.post({url:"/api/roles",body:e1}),getRoles:async()=>await n1.get({url:"/api/roles"}),getRolesForApp:async e1=>await n1.get({url:`/api/global/roles/${e1}`}),getAccessibleRoles:async()=>await n1.get({url:"/api/roles/accessible"})}),buildRouteEndpoints=n1=>({fetchClientAppRoutes:async()=>await n1.get({url:"/api/routing/client"}),fetchAppRoutes:async()=>await n1.get({url:"/api/routing"})}),buildRowEndpoints=n1=>({fetchRow:async({tableId:e1,rowId:t1})=>!e1||!t1?null:await n1.get({url:`/api/${e1}/rows/${t1}`}),saveRow:async(e1,t1=!1)=>{if(e1!=null&&e1.tableId)return await n1.post({url:`/api/${e1._viewId||e1.tableId}/rows`,body:e1,suppressErrors:t1})},patchRow:async(e1,t1=!1)=>{if(!(!(e1!=null&&e1.tableId)&&!(e1!=null&&e1._viewId)))return await n1.patch({url:`/api/${e1._viewId||e1.tableId}/rows`,body:e1,suppressErrors:t1})},deleteRow:async({tableId:e1,rowId:t1,revId:r1})=>{if(!(!e1||!t1))return await n1.delete({url:`/api/${e1}/rows`,body:{_id:t1,_rev:r1}})},deleteRows:async({tableId:e1,rows:t1})=>(t1==null||t1.forEach(r1=>{r1==null||delete r1._viewId}),await n1.delete({url:`/api/${e1}/rows`,body:{rows:t1}})),exportRows:async({tableId:e1,rows:t1,format:r1,columns:o1,search:i1})=>await n1.post({url:`/api/${e1}/rows/exportRows?format=${r1}`,body:{rows:t1,columns:o1,...i1},parseResponse:async a1=>await a1.text()})}),buildScreenEndpoints=n1=>({saveScreen:async e1=>await n1.post({url:"/api/screens",body:e1}),deleteScreen:async({screenId:e1,screenRev:t1})=>await n1.delete({url:`/api/screens/${e1}/${t1}`})}),buildTableEndpoints=n1=>({fetchTableDefinition:async e1=>await n1.get({url:`/api/tables/${e1}`,cache:!0}),fetchTableData:async e1=>await n1.get({url:`/api/${e1}/rows`}),searchTable:async({tableId:e1,query:t1,bookmark:r1,limit:o1,sort:i1,sortOrder:a1,sortType:s1,paginate:l1})=>!e1||!t1?{rows:[]}:await n1.post({url:`/api/${e1}/search`,body:{query:t1,bookmark:r1,limit:o1,sort:i1,sortOrder:a1,sortType:s1,paginate:l1}}),importTableData:async({tableId:e1,rows:t1,identifierFields:r1})=>await n1.post({url:`/api/tables/${e1}/import`,body:{rows:t1,identifierFields:r1}}),csvToJson:async e1=>await n1.post({url:"/api/convert/csvToJson",body:{csvString:e1}}),getTables:async()=>await n1.get({url:"/api/tables"}),getTable:async e1=>await n1.get({url:`/api/tables/${e1}`}),saveTable:async e1=>await n1.post({url:"/api/tables",body:e1}),deleteTable:async({tableId:e1,tableRev:t1})=>await n1.delete({url:`/api/tables/${e1}/${t1}`}),validateNewTableImport:async({rows:e1,schema:t1})=>await n1.post({url:"/api/tables/validateNewTableImport",body:{rows:e1,schema:t1}}),validateExistingTableImport:async({rows:e1,tableId:t1})=>await n1.post({url:"/api/tables/validateExistingTableImport",body:{rows:e1,tableId:t1}}),migrateColumn:async({tableId:e1,oldColumn:t1,newColumn:r1})=>await n1.post({url:`/api/tables/${e1}/migrate`,body:{oldColumn:t1,newColumn:r1}})}),buildTemplateEndpoints=n1=>({getEmailTemplateDefinitions:async()=>await n1.get({url:"/api/global/template/definitions"}),getEmailTemplates:async()=>await n1.get({url:"/api/global/template/email"}),saveEmailTemplate:async e1=>await n1.post({url:"/api/global/template",body:e1}),getAppTemplates:async()=>await n1.get({url:"/api/templates"})}),buildUserEndpoints=n1=>({getUsers:async()=>await n1.get({url:"/api/global/users"}),searchUsers:async({paginate:e1,bookmark:t1,query:r1,appId:o1,limit:i1}={})=>{const a1={};return t1&&(a1.bookmark=t1),r1&&(a1.query=r1),o1&&(a1.appId=o1),typeof e1=="boolean"&&(a1.paginate=e1),i1&&(a1.limit=i1),await n1.post({url:"/api/global/users/search",body:a1})},getUser:async e1=>await n1.get({url:`/api/global/users/${e1}`}),createAppUser:async e1=>await n1.post({url:"/api/users/metadata",body:e1}),updateOwnMetadata:async e1=>await n1.post({url:"/api/users/metadata/self",body:e1}),createAdminUser:async e1=>await n1.post({url:"/api/global/users/init",body:e1}),saveUser:async e1=>await n1.post({url:"/api/global/users",body:e1}),createUsers:async({users:e1,groups:t1})=>(await n1.post({url:"/api/global/users/bulk",body:{create:{users:e1,groups:t1}}})).created,deleteUser:async e1=>await n1.delete({url:`/api/global/users/${e1}`}),deleteUsers:async e1=>(await n1.post({url:"/api/global/users/bulk",body:{delete:{userIds:e1}}})).deleted,inviteUser:async({email:e1,builder:t1,admin:r1,apps:o1})=>await n1.post({url:"/api/global/users/invite",body:{email:e1,userInfo:{admin:r1!=null&&r1.global?{global:!0}:void 0,builder:t1!=null&&t1.global?{global:!0}:void 0,apps:o1||void 0}}}),onboardUsers:async e1=>await n1.post({url:"/api/global/users/onboard",body:e1.map(t1=>{const{email:r1,admin:o1,builder:i1,apps:a1}=t1;return{email:r1,userInfo:{admin:o1,builder:i1,apps:a1||void 0}}})}),updateUserInvite:async e1=>{await n1.post({url:`/api/global/users/invite/update/${e1.code}`,body:{apps:e1.apps,builder:e1.builder}})},getUserInvite:async e1=>await n1.get({url:`/api/global/users/invite/${e1}`}),getUserInvites:async()=>await n1.get({url:"/api/global/users/invites"}),inviteUsers:async e1=>await n1.post({url:"/api/global/users/multi/invite",body:e1.map(t1=>{let r1;return t1.admin||t1.builder?r1={global:!0}:t1.creator&&(r1={creator:!0}),{email:t1.email,userInfo:{admin:t1.admin?{global:!0}:void 0,builder:r1,userGroups:t1.groups,roles:t1.apps?t1.apps:void 0}}})}),acceptInvite:async({inviteCode:e1,password:t1,firstName:r1,lastName:o1})=>await n1.post({url:"/api/global/users/invite/accept",body:{inviteCode:e1,password:t1,firstName:r1,lastName:o1}}),getUserCountByApp:async({appId:e1})=>await n1.get({url:`/api/global/users/count/${e1}`}),addAppBuilder:async({userId:e1,appId:t1})=>await n1.post({url:`/api/global/users/${e1}/app/${t1}/builder`}),removeAppBuilder:async({userId:e1,appId:t1})=>await n1.delete({url:`/api/global/users/${e1}/app/${t1}/builder`})}),buildSelfEndpoints=n1=>({generateAPIKey:async()=>{const e1=await n1.post({url:"/api/global/self/api_key"});return e1==null?void 0:e1.apiKey},fetchDeveloperInfo:async()=>n1.get({url:"/api/global/self/api_key"}),fetchSelf:async()=>await n1.get({url:"/api/self"}),fetchBuilderSelf:async()=>await n1.get({url:"/api/global/self"}),updateSelf:async e1=>await n1.post({url:"/api/global/self",body:e1})}),buildViewEndpoints=n1=>({fetchViewData:async({name:e1,field:t1,groupBy:r1,calculation:o1})=>{const i1=new URLSearchParams;o1&&(i1.set("field",t1),i1.set("calculation",o1)),r1&&i1.set("group",r1);const a1=t1?`/api/views/${encodeURIComponent(e1)}?${i1}`:`/api/views/${encodeURIComponent(e1)}`;return await n1.get({url:a1})},exportView:async({viewName:e1,format:t1})=>{const r1=encodeURIComponent(e1);return await n1.get({url:`/api/views/export?view=${r1}&format=${t1}`,parseResponse:async o1=>await o1.text()})},saveView:async e1=>await n1.post({url:"/api/views",body:e1}),deleteView:async e1=>await n1.delete({url:`/api/views/${encodeURIComponent(e1)}`})}),buildViewV2Endpoints=n1=>({fetchDefinition:async e1=>await n1.get({url:`/api/v2/views/${encodeURIComponent(e1)}`}),create:async e1=>await n1.post({url:"/api/v2/views",body:e1}),update:async e1=>await n1.put({url:`/api/v2/views/${encodeURIComponent(e1.id)}`,body:e1}),fetch:async({viewId:e1,query:t1,paginate:r1,limit:o1,bookmark:i1,sort:a1,sortOrder:s1,sortType:l1})=>await n1.post({url:`/api/v2/views/${encodeURIComponent(e1)}/search`,body:{query:t1,paginate:r1,limit:o1,bookmark:i1,sort:a1,sortOrder:s1,sortType:l1}}),delete:async e1=>await n1.delete({url:`/api/v2/views/${encodeURIComponent(e1)}`})}),buildLicensingEndpoints=n1=>({activateLicenseKey:async e1=>n1.post({url:"/api/global/license/key",body:e1}),deleteLicenseKey:async()=>n1.delete({url:"/api/global/license/key"}),getLicenseKey:async()=>{try{return await n1.get({url:"/api/global/license/key"})}catch(e1){if(e1.status!==404)throw e1}},activateOfflineLicense:async({offlineLicenseToken:e1})=>n1.post({url:"/api/global/license/offline",body:{offlineLicenseToken:e1}}),deleteOfflineLicense:async()=>n1.delete({url:"/api/global/license/offline"}),getOfflineLicense:async()=>{try{return await n1.get({url:"/api/global/license/offline"})}catch(e1){if(e1.status!==404)throw e1}},getOfflineLicenseIdentifier:async()=>await n1.get({url:"/api/global/license/offline/identifier"}),refreshLicense:async()=>n1.post({url:"/api/global/license/refresh"}),getQuotaUsage:async()=>n1.get({url:"/api/global/license/usage"})}),buildGroupsEndpoints=n1=>{async function e1(t1,r1,o1,i1){return Array.isArray(i1)||(i1=[i1]),await n1.post({url:`/api/global/groups/${t1}/${r1}`,body:{[o1]:i1}})}return{saveGroup:async t1=>await n1.post({url:"/api/global/groups",body:t1}),getGroups:async()=>await n1.get({url:"/api/global/groups"}),getGroup:async t1=>await n1.get({url:`/api/global/groups/${t1}`}),deleteGroup:async({id:t1,rev:r1})=>await n1.delete({url:`/api/global/groups/${t1}/${r1}`}),getGroupUsers:async({id:t1,bookmark:r1,emailSearch:o1})=>{let i1=`/api/global/groups/${t1}/users?`;return r1&&(i1+=`bookmark=${r1}&`),o1&&(i1+=`emailSearch=${o1}&`),await n1.get({url:i1})},addUsersToGroup:async(t1,r1)=>e1(t1,"users","add",r1),removeUsersFromGroup:async(t1,r1)=>e1(t1,"users","remove",r1),addAppsToGroup:async(t1,r1)=>e1(t1,"apps","add",r1),removeAppsFromGroup:async(t1,r1)=>e1(t1,"apps","remove",r1),addGroupAppBuilder:async({groupId:t1,appId:r1})=>await n1.post({url:`/api/global/groups/${t1}/app/${r1}/builder`}),removeGroupAppBuilder:async({groupId:t1,appId:r1})=>await n1.delete({url:`/api/global/groups/${t1}/app/${r1}/builder`})}},buildPluginEndpoints=n1=>({uploadPlugin:async e1=>await n1.post({url:"/api/plugin/upload",body:e1,json:!1}),createPlugin:async e1=>await n1.post({url:"/api/plugin",body:e1}),getPlugins:async()=>await n1.get({url:"/api/plugin"}),deletePlugin:async e1=>await n1.delete({url:`/api/plugin/${e1}`})}),buildBackupsEndpoints=n1=>({searchBackups:async({appId:e1,trigger:t1,type:r1,page:o1,startDate:i1,endDate:a1})=>{const s1={};return o1&&(s1.page=o1),t1&&r1&&(s1.trigger=t1.toLowerCase(),s1.type=r1.toLowerCase()),i1&&a1&&(s1.startDate=i1,s1.endDate=a1),await n1.post({url:`/api/apps/${e1}/backups/search`,body:s1})},createManualBackup:async({appId:e1})=>await n1.post({url:`/api/apps/${e1}/backups`}),deleteBackup:async({appId:e1,backupId:t1})=>await n1.delete({url:`/api/apps/${e1}/backups/${t1}`}),updateBackup:async({appId:e1,backupId:t1,name:r1})=>await n1.patch({url:`/api/apps/${e1}/backups/${t1}`,body:{name:r1}}),restoreBackup:async({appId:e1,backupId:t1,name:r1})=>await n1.post({url:`/api/apps/${e1}/backups/${t1}/import`,body:{name:r1}})}),buildEnvironmentVariableEndpoints=n1=>({checkEnvironmentVariableStatus:async()=>await n1.get({url:"/api/env/variables/status"}),fetchEnvironmentVariables:async()=>await n1.get({url:"/api/env/variables",json:!1}),createEnvironmentVariable:async e1=>await n1.post({url:"/api/env/variables",body:e1}),deleteEnvironmentVariable:async e1=>await n1.delete({url:`/api/env/variables/${e1}`}),updateEnvironmentVariable:async e1=>await n1.patch({url:`/api/env/variables/${e1.name}`,body:e1})}),buildEventEndpoints=n1=>({publishEvent:async e1=>await n1.post({url:"/api/global/event/publish",body:{type:e1}})}),buildOpts=({bookmark:n1,userIds:e1,appIds:t1,startDate:r1,endDate:o1,fullSearch:i1,events:a1})=>{const s1={};return n1&&(s1.bookmark=n1),r1&&o1?(s1.startDate=r1,s1.endDate=o1):r1&&!o1&&(s1.startDate=r1),i1&&(s1.fullSearch=i1),a1.length&&(s1.events=a1),e1.length&&(s1.userIds=e1),t1.length&&(s1.appIds=t1),s1},buildAuditLogsEndpoints=n1=>({searchAuditLogs:async e1=>await n1.post({url:"/api/global/auditlogs/search",body:buildOpts(e1)}),getEventDefinitions:async()=>await n1.get({url:"/api/global/auditlogs/definitions"}),getDownloadUrl:e1=>`/api/global/auditlogs/download?query=${encodeURIComponent(JSON.stringify(e1))}`}),buildLogsEndpoints=n1=>({getSystemLogs:async()=>await n1.get({url:"/api/system/logs",json:!1,parseResponse:async e1=>e1})}),APISessionID=uuid(),defaultAPIClientConfig={enableCaching:!1,attachHeaders:null,onError:null},createAPIClient=n1=>{n1={...defaultAPIClientConfig,...n1};let e1={};const t1=async(l1,c1,u1=!1)=>{let f1=l1.statusText,d1=null;try{d1=await l1.json(),d1!=null&&d1.message?f1=d1.message:d1!=null&&d1.error&&(f1=d1.error)}catch{}return{message:f1,json:d1,status:l1.status,url:l1.url,method:c1,handled:!0,suppressErrors:u1}},r1=(l1,c1)=>({message:l1,json:null,status:400,url:c1==null?void 0:c1.url,method:c1==null?void 0:c1.method,handled:!0}),o1=async({method:l1,url:c1,body:u1,json:f1=!0,external:d1=!1,parseResponse:p1,suppressErrors:m1=!1})=>{f1=f1&&l1!=="GET";let _1={Accept:"application/json"};_1["x-budibase-session-id"]=APISessionID,d1||(_1["x-budibase-api-version"]=ApiVersion),f1&&(_1["Content-Type"]="application/json"),n1!=null&&n1.attachHeaders&&n1.attachHeaders(_1);let h1=u1;if(f1)try{h1=JSON.stringify(u1)}catch{throw r1("Invalid JSON body",{url:c1,method:l1})}let g1;try{g1=await fetch(c1,{method:l1,headers:_1,body:h1,credentials:"same-origin"})}catch{throw delete e1[c1],r1("Failed to send request",{url:c1,method:l1})}if(g1.status>=200&&g1.status<400)try{return p1?await p1(g1):await g1.json()}catch{return delete e1[c1],null}else throw delete e1[c1],await t1(g1,l1,m1)},i1=async l1=>{const c1=l1.url;return c1?(e1[c1]||(e1[c1]=o1(l1),e1[c1]=await e1[c1]),await e1[c1]):null},a1=l1=>async c1=>{try{let{url:u1,cache:f1=!1,external:d1=!1}=c1;d1||(u1=`/${u1}`.replace("//","/"));const m1=f1&&(n1==null?void 0:n1.enableCaching)?i1:o1,_1={...c1,method:l1,url:u1};return await m1(_1)}catch(u1){throw n1!=null&&n1.onError&&n1.onError(u1),u1}};let s1={post:a1("POST"),get:a1("GET"),patch:a1("PATCH"),delete:a1("DELETE"),put:a1("PUT"),error:l1=>{throw r1(l1)},invalidateCache:()=>{e1={}},getAppID:()=>{let l1={};return n1==null||n1.attachHeaders(l1),l1==null?void 0:l1["x-budibase-app-id"]}};return{...s1,...buildAnalyticsEndpoints(s1),...buildAppEndpoints(s1),...buildAttachmentEndpoints(s1),...buildAuthEndpoints(s1),...buildAutomationEndpoints(s1),...buildConfigEndpoints(s1),...buildDatasourceEndpoints(s1),...buildFlagEndpoints(s1),...buildHostingEndpoints(s1),...buildLayoutEndpoints(s1),...buildOtherEndpoints(s1),...buildPermissionsEndpoints(s1),...buildQueryEndpoints(s1),...buildRelationshipEndpoints(s1),...buildRoleEndpoints(s1),...buildRouteEndpoints(s1),...buildRowEndpoints(s1),...buildScreenEndpoints(s1),...buildTableEndpoints(s1),...buildTemplateEndpoints(s1),...buildUserEndpoints(s1),...buildViewEndpoints(s1),...buildSelfEndpoints(s1),...buildLicensingEndpoints(s1),...buildGroupsEndpoints(s1),...buildPluginEndpoints(s1),...buildBackupsEndpoints(s1),...buildEnvironmentVariableEndpoints(s1),...buildEventEndpoints(s1),...buildAuditLogsEndpoints(s1),...buildLogsEndpoints(s1),viewV2:buildViewV2Endpoints(s1)}},getJSONArrayDatasourceSchema=(n1,e1)=>{let t1=n1,r1=[];e1.prefixKeys&&(r1=e1.prefixKeys.concat(["schema"])),r1=r1.concat(e1.label.split(".").slice(2));for(let o1=0;o1<r1.length;o1++)t1=t1==null?void 0:t1[r1[o1]],t1!=null&&t1.schema&&(t1=t1.schema);return convertJSONSchemaToTableSchema(t1,{squashObjects:!0,prefixKeys:r1})},convertJSONSchemaToTableSchema=(n1,e1)=>{if(!n1)return null;e1={squashObjects:!1,prefixKeys:null,...e1},n1.schema?n1=n1.schema:n1={value:n1};const t1=extractJSONSchemaKeys(n1,e1.squashObjects);let r1={};return t1.forEach(({key:o1,type:i1})=>{r1[o1]={type:i1,name:o1,prefixKeys:e1.prefixKeys}}),r1},extractJSONSchemaKeys=(n1,e1=!1)=>{if(!n1||!Object.keys(n1).length)return[];let t1=[];return Object.keys(n1).forEach(r1=>{const o1=n1[r1].type;if(o1==="json"&&e1){const i1=extractJSONSchemaKeys(n1[r1].schema,e1);t1=t1.concat(i1.map(a1=>({key:`${r1}.${a1.key}`,type:a1.type})))}else t1.push({key:r1,type:o1==="array"?"jsonarray":o1})}),t1};function setCookie(n1,e1){getCookie(n1)&&removeCookie(n1),window.document.cookie=`${n1}=${e1}; Path=/;`}function getCookie(n1){const t1=`; ${document.cookie}`.split(`; ${n1}=`);if(t1.length===2)return t1[1].split(";").shift()}function removeCookie(n1){getCookie(n1)&&(document.cookie=`${n1}=; Max-Age=-99999999; Path=/;`)}const RolePriorities={[Roles$1.ADMIN]:5,[Roles$1.CREATOR]:4,[Roles$1.POWER]:3,[Roles$1.BASIC]:2,[Roles$1.PUBLIC]:1},RoleColours={[Roles$1.ADMIN]:"var(--spectrum-global-color-static-red-400)",[Roles$1.CREATOR]:"var(--spectrum-global-color-static-magenta-600)",[Roles$1.POWER]:"var(--spectrum-global-color-static-orange-400)",[Roles$1.BASIC]:"var(--spectrum-global-color-static-green-400)",[Roles$1.PUBLIC]:"var(--spectrum-global-color-static-blue-400)"},getRolePriority=n1=>RolePriorities[n1]??0,getRoleColour=n1=>RoleColours[n1]??"var(--spectrum-global-color-static-magenta-400)",sequential=n1=>{let e1=[];return(...t1)=>new Promise((r1,o1)=>{e1.push(async()=>{let i1,a1;try{i1=await n1(...t1)}catch(s1){a1=s1}e1.shift(),e1.length&&e1[0](),a1?o1(a1):r1(i1)}),e1.length===1&&e1[0]()})},debounce=(n1,e1=1e3)=>{let t1;return async(...r1)=>new Promise(o1=>{t1&&clearTimeout(t1),t1=setTimeout(async()=>{o1(await n1(...r1))},e1)})},domDebounce=n1=>{let e1=!1,t1;return(...r1)=>{t1=r1,e1||(e1=!0,requestAnimationFrame(()=>{n1(...t1),e1=!1}))}},memo=n1=>{const e1=writable(n1),t1=(r1,o1)=>{if(o1===r1)return;const i1=JSON.stringify(o1),a1=JSON.stringify(r1);i1!==a1&&e1.set(r1)};return{subscribe:e1.subscribe,set:r1=>{const o1=get_store_value(e1);t1(r1,o1)},update:r1=>{const o1=get_store_value(e1);let i1=JSON.parse(JSON.stringify(o1));const a1=r1(i1);t1(a1,o1)}}},derivedMemo=(n1,e1)=>{const t1=derived(n1,e1),r1=memo(get_store_value(t1));return t1.subscribe(r1.set),r1},PACKET_TYPES=Object.create(null);PACKET_TYPES.open="0";PACKET_TYPES.close="1";PACKET_TYPES.ping="2";PACKET_TYPES.pong="3";PACKET_TYPES.message="4";PACKET_TYPES.upgrade="5";PACKET_TYPES.noop="6";const PACKET_TYPES_REVERSE=Object.create(null);Object.keys(PACKET_TYPES).forEach(n1=>{PACKET_TYPES_REVERSE[PACKET_TYPES[n1]]=n1});const ERROR_PACKET={type:"error",data:"parser error"},withNativeBlob$1=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",withNativeArrayBuffer$2=typeof ArrayBuffer=="function",isView$1=n1=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n1):n1&&n1.buffer instanceof ArrayBuffer,encodePacket=({type:n1,data:e1},t1,r1)=>withNativeBlob$1&&e1 instanceof Blob?t1?r1(e1):encodeBlobAsBase64(e1,r1):withNativeArrayBuffer$2&&(e1 instanceof ArrayBuffer||isView$1(e1))?t1?r1(e1):encodeBlobAsBase64(new Blob([e1]),r1):r1(PACKET_TYPES[n1]+(e1||"")),encodeBlobAsBase64=(n1,e1)=>{const t1=new FileReader;return t1.onload=function(){const r1=t1.result.split(",")[1];e1("b"+(r1||""))},t1.readAsDataURL(n1)},chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lookup$1=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n1=0;n1<chars.length;n1++)lookup$1[chars.charCodeAt(n1)]=n1;const decode$3=n1=>{let e1=n1.length*.75,t1=n1.length,r1,o1=0,i1,a1,s1,l1;n1[n1.length-1]==="="&&(e1--,n1[n1.length-2]==="="&&e1--);const c1=new ArrayBuffer(e1),u1=new Uint8Array(c1);for(r1=0;r1<t1;r1+=4)i1=lookup$1[n1.charCodeAt(r1)],a1=lookup$1[n1.charCodeAt(r1+1)],s1=lookup$1[n1.charCodeAt(r1+2)],l1=lookup$1[n1.charCodeAt(r1+3)],u1[o1++]=i1<<2|a1>>4,u1[o1++]=(a1&15)<<4|s1>>2,u1[o1++]=(s1&3)<<6|l1&63;return c1},withNativeArrayBuffer$1=typeof ArrayBuffer=="function",decodePacket=(n1,e1)=>{if(typeof n1!="string")return{type:"message",data:mapBinary(n1,e1)};const t1=n1.charAt(0);return t1==="b"?{type:"message",data:decodeBase64Packet(n1.substring(1),e1)}:PACKET_TYPES_REVERSE[t1]?n1.length>1?{type:PACKET_TYPES_REVERSE[t1],data:n1.substring(1)}:{type:PACKET_TYPES_REVERSE[t1]}:ERROR_PACKET},decodeBase64Packet=(n1,e1)=>{if(withNativeArrayBuffer$1){const t1=decode$3(n1);return mapBinary(t1,e1)}else return{base64:!0,data:n1}},mapBinary=(n1,e1)=>{switch(e1){case"blob":return n1 instanceof ArrayBuffer?new Blob([n1]):n1;case"arraybuffer":default:return n1}},SEPARATOR=String.fromCharCode(30),encodePayload=(n1,e1)=>{const t1=n1.length,r1=new Array(t1);let o1=0;n1.forEach((i1,a1)=>{encodePacket(i1,!1,s1=>{r1[a1]=s1,++o1===t1&&e1(r1.join(SEPARATOR))})})},decodePayload=(n1,e1)=>{const t1=n1.split(SEPARATOR),r1=[];for(let o1=0;o1<t1.length;o1++){const i1=decodePacket(t1[o1],e1);if(r1.push(i1),i1.type==="error")break}return r1},protocol$1=4;function Emitter(n1){if(n1)return mixin(n1)}function mixin(n1){for(var e1 in Emitter.prototype)n1[e1]=Emitter.prototype[e1];return n1}Emitter.prototype.on=Emitter.prototype.addEventListener=function(n1,e1){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n1]=this._callbacks["$"+n1]||[]).push(e1),this};Emitter.prototype.once=function(n1,e1){function t1(){this.off(n1,t1),e1.apply(this,arguments)}return t1.fn=e1,this.on(n1,t1),this};Emitter.prototype.off=Emitter.prototype.removeListener=Emitter.prototype.removeAllListeners=Emitter.prototype.removeEventListener=function(n1,e1){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t1=this._callbacks["$"+n1];if(!t1)return this;if(arguments.length==1)return delete this._callbacks["$"+n1],this;for(var r1,o1=0;o1<t1.length;o1++)if(r1=t1[o1],r1===e1||r1.fn===e1){t1.splice(o1,1);break}return t1.length===0&&delete this._callbacks["$"+n1],this};Emitter.prototype.emit=function(n1){this._callbacks=this._callbacks||{};for(var e1=new Array(arguments.length-1),t1=this._callbacks["$"+n1],r1=1;r1<arguments.length;r1++)e1[r1-1]=arguments[r1];if(t1){t1=t1.slice(0);for(var r1=0,o1=t1.length;r1<o1;++r1)t1[r1].apply(this,e1)}return this};Emitter.prototype.emitReserved=Emitter.prototype.emit;Emitter.prototype.listeners=function(n1){return this._callbacks=this._callbacks||{},this._callbacks["$"+n1]||[]};Emitter.prototype.hasListeners=function(n1){return!!this.listeners(n1).length};const globalThisShim=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function pick(n1,...e1){return e1.reduce((t1,r1)=>(n1.hasOwnProperty(r1)&&(t1[r1]=n1[r1]),t1),{})}const NATIVE_SET_TIMEOUT=globalThisShim.setTimeout,NATIVE_CLEAR_TIMEOUT=globalThisShim.clearTimeout;function installTimerFunctions(n1,e1){e1.useNativeTimers?(n1.setTimeoutFn=NATIVE_SET_TIMEOUT.bind(globalThisShim),n1.clearTimeoutFn=NATIVE_CLEAR_TIMEOUT.bind(globalThisShim)):(n1.setTimeoutFn=globalThisShim.setTimeout.bind(globalThisShim),n1.clearTimeoutFn=globalThisShim.clearTimeout.bind(globalThisShim))}const BASE64_OVERHEAD=1.33;function byteLength(n1){return typeof n1=="string"?utf8Length(n1):Math.ceil((n1.byteLength||n1.size)*BASE64_OVERHEAD)}function utf8Length(n1){let e1=0,t1=0;for(let r1=0,o1=n1.length;r1<o1;r1++)e1=n1.charCodeAt(r1),e1<128?t1+=1:e1<2048?t1+=2:e1<55296||e1>=57344?t1+=3:(r1++,t1+=4);return t1}class TransportError extends Error{constructor(e1,t1,r1){super(e1),this.description=t1,this.context=r1,this.type="TransportError"}}class Transport extends Emitter{constructor(e1){super(),this.writable=!1,installTimerFunctions(this,e1),this.opts=e1,this.query=e1.query,this.socket=e1.socket}onError(e1,t1,r1){return super.emitReserved("error",new TransportError(e1,t1,r1)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e1){this.readyState==="open"&&this.write(e1)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e1){const t1=decodePacket(e1,this.socket.binaryType);this.onPacket(t1)}onPacket(e1){super.emitReserved("packet",e1)}onClose(e1){this.readyState="closed",super.emitReserved("close",e1)}pause(e1){}}const alphabet="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),length=64,map={};let seed=0,i$2=0,prev;function encode$3(n1){let e1="";do e1=alphabet[n1%length]+e1,n1=Math.floor(n1/length);while(n1>0);return e1}function yeast(){const n1=encode$3(+new Date);return n1!==prev?(seed=0,prev=n1):n1+"."+encode$3(seed++)}for(;i$2<length;i$2++)map[alphabet[i$2]]=i$2;function encode$2(n1){let e1="";for(let t1 in n1)n1.hasOwnProperty(t1)&&(e1.length&&(e1+="&"),e1+=encodeURIComponent(t1)+"="+encodeURIComponent(n1[t1]));return e1}function decode$2(n1){let e1={},t1=n1.split("&");for(let r1=0,o1=t1.length;r1<o1;r1++){let i1=t1[r1].split("=");e1[decodeURIComponent(i1[0])]=decodeURIComponent(i1[1])}return e1}let value$1=!1;try{value$1=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const hasCORS=value$1;function XHR(n1){const e1=n1.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e1||hasCORS))return new XMLHttpRequest}catch{}if(!e1)try{return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function empty(){}const hasXHR2=function(){return new XHR({xdomain:!1}).responseType!=null}();class Polling extends Transport{constructor(e1){if(super(e1),this.polling=!1,typeof location<"u"){const r1=location.protocol==="https:";let o1=location.port;o1||(o1=r1?"443":"80"),this.xd=typeof location<"u"&&e1.hostname!==location.hostname||o1!==e1.port,this.xs=e1.secure!==r1}const t1=e1&&e1.forceBase64;this.supportsBinary=hasXHR2&&!t1}get name(){return"polling"}doOpen(){this.poll()}pause(e1){this.readyState="pausing";const t1=()=>{this.readyState="paused",e1()};if(this.polling||!this.writable){let r1=0;this.polling&&(r1++,this.once("pollComplete",function(){--r1||t1()})),this.writable||(r1++,this.once("drain",function(){--r1||t1()}))}else t1()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e1){const t1=r1=>{if(this.readyState==="opening"&&r1.type==="open"&&this.onOpen(),r1.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r1)};decodePayload(e1,this.socket.binaryType).forEach(t1),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e1=()=>{this.write([{type:"close"}])};this.readyState==="open"?e1():this.once("open",e1)}write(e1){this.writable=!1,encodePayload(e1,t1=>{this.doWrite(t1,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e1=this.query||{};const t1=this.opts.secure?"https":"http";let r1="";this.opts.timestampRequests!==!1&&(e1[this.opts.timestampParam]=yeast()),!this.supportsBinary&&!e1.sid&&(e1.b64=1),this.opts.port&&(t1==="https"&&Number(this.opts.port)!==443||t1==="http"&&Number(this.opts.port)!==80)&&(r1=":"+this.opts.port);const o1=encode$2(e1),i1=this.opts.hostname.indexOf(":")!==-1;return t1+"://"+(i1?"["+this.opts.hostname+"]":this.opts.hostname)+r1+this.opts.path+(o1.length?"?"+o1:"")}request(e1={}){return Object.assign(e1,{xd:this.xd,xs:this.xs},this.opts),new Request(this.uri(),e1)}doWrite(e1,t1){const r1=this.request({method:"POST",data:e1});r1.on("success",t1),r1.on("error",(o1,i1)=>{this.onError("xhr post error",o1,i1)})}doPoll(){const e1=this.request();e1.on("data",this.onData.bind(this)),e1.on("error",(t1,r1)=>{this.onError("xhr poll error",t1,r1)}),this.pollXhr=e1}}class Request extends Emitter{constructor(e1,t1){super(),installTimerFunctions(this,t1),this.opts=t1,this.method=t1.method||"GET",this.uri=e1,this.async=t1.async!==!1,this.data=t1.data!==void 0?t1.data:null,this.create()}create(){const e1=pick(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e1.xdomain=!!this.opts.xd,e1.xscheme=!!this.opts.xs;const t1=this.xhr=new XHR(e1);try{t1.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t1.setDisableHeaderCheck&&t1.setDisableHeaderCheck(!0);for(let r1 in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r1)&&t1.setRequestHeader(r1,this.opts.extraHeaders[r1])}}catch{}if(this.method==="POST")try{t1.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{t1.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in t1&&(t1.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t1.timeout=this.opts.requestTimeout),t1.onreadystatechange=()=>{t1.readyState===4&&(t1.status===200||t1.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof t1.status=="number"?t1.status:0)},0))},t1.send(this.data)}catch(r1){this.setTimeoutFn(()=>{this.onError(r1)},0);return}typeof document<"u"&&(this.index=Request.requestsCount++,Request.requests[this.index]=this)}onError(e1){this.emitReserved("error",e1,this.xhr),this.cleanup(!0)}cleanup(e1){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=empty,e1)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Request.requests[this.index],this.xhr=null}}onLoad(){const e1=this.xhr.responseText;e1!==null&&(this.emitReserved("data",e1),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}Request.requestsCount=0;Request.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",unloadHandler);else if(typeof addEventListener=="function"){const n1="onpagehide"in globalThisShim?"pagehide":"unload";addEventListener(n1,unloadHandler,!1)}}function unloadHandler(){for(let n1 in Request.requests)Request.requests.hasOwnProperty(n1)&&Request.requests[n1].abort()}const nextTick=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e1=>Promise.resolve().then(e1):(e1,t1)=>t1(e1,0))(),WebSocket=globalThisShim.WebSocket||globalThisShim.MozWebSocket,usingBrowserWebSocket=!0,defaultBinaryType="arraybuffer",isReactNative=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class WS extends Transport{constructor(e1){super(e1),this.supportsBinary=!e1.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e1=this.uri(),t1=this.opts.protocols,r1=isReactNative?{}:pick(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r1.headers=this.opts.extraHeaders);try{this.ws=usingBrowserWebSocket&&!isReactNative?t1?new WebSocket(e1,t1):new WebSocket(e1):new WebSocket(e1,t1,r1)}catch(o1){return this.emitReserved("error",o1)}this.ws.binaryType=this.socket.binaryType||defaultBinaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e1=>this.onClose({description:"websocket connection closed",context:e1}),this.ws.onmessage=e1=>this.onData(e1.data),this.ws.onerror=e1=>this.onError("websocket error",e1)}write(e1){this.writable=!1;for(let t1=0;t1<e1.length;t1++){const r1=e1[t1],o1=t1===e1.length-1;encodePacket(r1,this.supportsBinary,i1=>{const a1={};try{usingBrowserWebSocket&&this.ws.send(i1)}catch{}o1&&nextTick(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e1=this.query||{};const t1=this.opts.secure?"wss":"ws";let r1="";this.opts.port&&(t1==="wss"&&Number(this.opts.port)!==443||t1==="ws"&&Number(this.opts.port)!==80)&&(r1=":"+this.opts.port),this.opts.timestampRequests&&(e1[this.opts.timestampParam]=yeast()),this.supportsBinary||(e1.b64=1);const o1=encode$2(e1),i1=this.opts.hostname.indexOf(":")!==-1;return t1+"://"+(i1?"["+this.opts.hostname+"]":this.opts.hostname)+r1+this.opts.path+(o1.length?"?"+o1:"")}check(){return!!WebSocket}}const transports={websocket:WS,polling:Polling},re$1=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,parts=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function parse$8(n1){const e1=n1,t1=n1.indexOf("["),r1=n1.indexOf("]");t1!=-1&&r1!=-1&&(n1=n1.substring(0,t1)+n1.substring(t1,r1).replace(/:/g,";")+n1.substring(r1,n1.length));let o1=re$1.exec(n1||""),i1={},a1=14;for(;a1--;)i1[parts[a1]]=o1[a1]||"";return t1!=-1&&r1!=-1&&(i1.source=e1,i1.host=i1.host.substring(1,i1.host.length-1).replace(/;/g,":"),i1.authority=i1.authority.replace("[","").replace("]","").replace(/;/g,":"),i1.ipv6uri=!0),i1.pathNames=pathNames(i1,i1.path),i1.queryKey=queryKey(i1,i1.query),i1}function pathNames(n1,e1){const t1=/\/{2,9}/g,r1=e1.replace(t1,"/").split("/");return(e1.slice(0,1)=="/"||e1.length===0)&&r1.splice(0,1),e1.slice(-1)=="/"&&r1.splice(r1.length-1,1),r1}function queryKey(n1,e1){const t1={};return e1.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r1,o1,i1){o1&&(t1[o1]=i1)}),t1}let Socket$1=class wb extends Emitter{constructor(e1,t1={}){super(),this.writeBuffer=[],e1&&typeof e1=="object"&&(t1=e1,e1=null),e1?(e1=parse$8(e1),t1.hostname=e1.host,t1.secure=e1.protocol==="https"||e1.protocol==="wss",t1.port=e1.port,e1.query&&(t1.query=e1.query)):t1.host&&(t1.hostname=parse$8(t1.host).host),installTimerFunctions(this,t1),this.secure=t1.secure!=null?t1.secure:typeof location<"u"&&location.protocol==="https:",t1.hostname&&!t1.port&&(t1.port=this.secure?"443":"80"),this.hostname=t1.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t1.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=t1.transports||["polling","websocket"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},t1),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=decode$2(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e1){const t1=Object.assign({},this.opts.query);t1.EIO=protocol$1,t1.transport=e1,this.id&&(t1.sid=this.id);const r1=Object.assign({},this.opts.transportOptions[e1],this.opts,{query:t1,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new transports[e1](r1)}open(){let e1;if(this.opts.rememberUpgrade&&wb.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e1="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e1=this.transports[0];this.readyState="opening";try{e1=this.createTransport(e1)}catch{this.transports.shift(),this.open();return}e1.open(),this.setTransport(e1)}setTransport(e1){this.transport&&this.transport.removeAllListeners(),this.transport=e1,e1.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t1=>this.onClose("transport close",t1))}probe(e1){let t1=this.createTransport(e1),r1=!1;wb.priorWebsocketSuccess=!1;const o1=()=>{r1||(t1.send([{type:"ping",data:"probe"}]),t1.once("packet",f1=>{if(!r1)if(f1.type==="pong"&&f1.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t1),!t1)return;wb.priorWebsocketSuccess=t1.name==="websocket",this.transport.pause(()=>{r1||this.readyState!=="closed"&&(u1(),this.setTransport(t1),t1.send([{type:"upgrade"}]),this.emitReserved("upgrade",t1),t1=null,this.upgrading=!1,this.flush())})}else{const d1=new Error("probe error");d1.transport=t1.name,this.emitReserved("upgradeError",d1)}}))};function i1(){r1||(r1=!0,u1(),t1.close(),t1=null)}const a1=f1=>{const d1=new Error("probe error: "+f1);d1.transport=t1.name,i1(),this.emitReserved("upgradeError",d1)};function s1(){a1("transport closed")}function l1(){a1("socket closed")}function c1(f1){t1&&f1.name!==t1.name&&i1()}const u1=()=>{t1.removeListener("open",o1),t1.removeListener("error",a1),t1.removeListener("close",s1),this.off("close",l1),this.off("upgrading",c1)};t1.once("open",o1),t1.once("error",a1),t1.once("close",s1),this.once("close",l1),this.once("upgrading",c1),t1.open()}onOpen(){if(this.readyState="open",wb.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e1=0;const t1=this.upgrades.length;for(;e1<t1;e1++)this.probe(this.upgrades[e1])}}onPacket(e1){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e1),this.emitReserved("heartbeat"),e1.type){case"open":this.onHandshake(JSON.parse(e1.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t1=new Error("server error");t1.code=e1.data,this.onError(t1);break;case"message":this.emitReserved("data",e1.data),this.emitReserved("message",e1.data);break}}onHandshake(e1){this.emitReserved("handshake",e1),this.id=e1.sid,this.transport.query.sid=e1.sid,this.upgrades=this.filterUpgrades(e1.upgrades),this.pingInterval=e1.pingInterval,this.pingTimeout=e1.pingTimeout,this.maxPayload=e1.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e1=this.getWritablePackets();this.transport.send(e1),this.prevBufferLen=e1.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t1=1;for(let r1=0;r1<this.writeBuffer.length;r1++){const o1=this.writeBuffer[r1].data;if(o1&&(t1+=byteLength(o1)),r1>0&&t1>this.maxPayload)return this.writeBuffer.slice(0,r1);t1+=2}return this.writeBuffer}write(e1,t1,r1){return this.sendPacket("message",e1,t1,r1),this}send(e1,t1,r1){return this.sendPacket("message",e1,t1,r1),this}sendPacket(e1,t1,r1,o1){if(typeof t1=="function"&&(o1=t1,t1=void 0),typeof r1=="function"&&(o1=r1,r1=null),this.readyState==="closing"||this.readyState==="closed")return;r1=r1||{},r1.compress=r1.compress!==!1;const i1={type:e1,data:t1,options:r1};this.emitReserved("packetCreate",i1),this.writeBuffer.push(i1),o1&&this.once("flush",o1),this.flush()}close(){const e1=()=>{this.onClose("forced close"),this.transport.close()},t1=()=>{this.off("upgrade",t1),this.off("upgradeError",t1),e1()},r1=()=>{this.once("upgrade",t1),this.once("upgradeError",t1)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r1():e1()}):this.upgrading?r1():e1()),this}onError(e1){wb.priorWebsocketSuccess=!1,this.emitReserved("error",e1),this.onClose("transport error",e1)}onClose(e1,t1){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e1,t1),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e1){const t1=[];let r1=0;const o1=e1.length;for(;r1<o1;r1++)~this.transports.indexOf(e1[r1])&&t1.push(e1[r1]);return t1}};Socket$1.protocol=protocol$1;function url$1(n1,e1="",t1){let r1=n1;t1=t1||typeof location<"u"&&location,n1==null&&(n1=t1.protocol+"//"+t1.host),typeof n1=="string"&&(n1.charAt(0)==="/"&&(n1.charAt(1)==="/"?n1=t1.protocol+n1:n1=t1.host+n1),/^(https?|wss?):\/\//.test(n1)||(typeof t1<"u"?n1=t1.protocol+"//"+n1:n1="https://"+n1),r1=parse$8(n1)),r1.port||(/^(http|ws)$/.test(r1.protocol)?r1.port="80":/^(http|ws)s$/.test(r1.protocol)&&(r1.port="443")),r1.path=r1.path||"/";const i1=r1.host.indexOf(":")!==-1?"["+r1.host+"]":r1.host;return r1.id=r1.protocol+"://"+i1+":"+r1.port+e1,r1.href=r1.protocol+"://"+i1+(t1&&t1.port===r1.port?"":":"+r1.port),r1}const withNativeArrayBuffer=typeof ArrayBuffer=="function",isView=n1=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n1):n1.buffer instanceof ArrayBuffer,toString$5=Object.prototype.toString,withNativeBlob=typeof Blob=="function"||typeof Blob<"u"&&toString$5.call(Blob)==="[object BlobConstructor]",withNativeFile=typeof File=="function"||typeof File<"u"&&toString$5.call(File)==="[object FileConstructor]";function isBinary(n1){return withNativeArrayBuffer&&(n1 instanceof ArrayBuffer||isView(n1))||withNativeBlob&&n1 instanceof Blob||withNativeFile&&n1 instanceof File}function hasBinary(n1,e1){if(!n1||typeof n1!="object")return!1;if(Array.isArray(n1)){for(let t1=0,r1=n1.length;t1<r1;t1++)if(hasBinary(n1[t1]))return!0;return!1}if(isBinary(n1))return!0;if(n1.toJSON&&typeof n1.toJSON=="function"&&arguments.length===1)return hasBinary(n1.toJSON(),!0);for(const t1 in n1)if(Object.prototype.hasOwnProperty.call(n1,t1)&&hasBinary(n1[t1]))return!0;return!1}function deconstructPacket(n1){const e1=[],t1=n1.data,r1=n1;return r1.data=_deconstructPacket(t1,e1),r1.attachments=e1.length,{packet:r1,buffers:e1}}function _deconstructPacket(n1,e1){if(!n1)return n1;if(isBinary(n1)){const t1={_placeholder:!0,num:e1.length};return e1.push(n1),t1}else if(Array.isArray(n1)){const t1=new Array(n1.length);for(let r1=0;r1<n1.length;r1++)t1[r1]=_deconstructPacket(n1[r1],e1);return t1}else if(typeof n1=="object"&&!(n1 instanceof Date)){const t1={};for(const r1 in n1)Object.prototype.hasOwnProperty.call(n1,r1)&&(t1[r1]=_deconstructPacket(n1[r1],e1));return t1}return n1}function reconstructPacket(n1,e1){return n1.data=_reconstructPacket(n1.data,e1),delete n1.attachments,n1}function _reconstructPacket(n1,e1){if(!n1)return n1;if(n1&&n1._placeholder===!0){if(typeof n1.num=="number"&&n1.num>=0&&n1.num<e1.length)return e1[n1.num];throw new Error("illegal attachments")}else if(Array.isArray(n1))for(let t1=0;t1<n1.length;t1++)n1[t1]=_reconstructPacket(n1[t1],e1);else if(typeof n1=="object")for(const t1 in n1)Object.prototype.hasOwnProperty.call(n1,t1)&&(n1[t1]=_reconstructPacket(n1[t1],e1));return n1}const protocol=5;var PacketType;(function(n1){n1[n1.CONNECT=0]="CONNECT",n1[n1.DISCONNECT=1]="DISCONNECT",n1[n1.EVENT=2]="EVENT",n1[n1.ACK=3]="ACK",n1[n1.CONNECT_ERROR=4]="CONNECT_ERROR",n1[n1.BINARY_EVENT=5]="BINARY_EVENT",n1[n1.BINARY_ACK=6]="BINARY_ACK"})(PacketType||(PacketType={}));class Encoder{constructor(e1){this.replacer=e1}encode(e1){return(e1.type===PacketType.EVENT||e1.type===PacketType.ACK)&&hasBinary(e1)?this.encodeAsBinary({type:e1.type===PacketType.EVENT?PacketType.BINARY_EVENT:PacketType.BINARY_ACK,nsp:e1.nsp,data:e1.data,id:e1.id}):[this.encodeAsString(e1)]}encodeAsString(e1){let t1=""+e1.type;return(e1.type===PacketType.BINARY_EVENT||e1.type===PacketType.BINARY_ACK)&&(t1+=e1.attachments+"-"),e1.nsp&&e1.nsp!=="/"&&(t1+=e1.nsp+","),e1.id!=null&&(t1+=e1.id),e1.data!=null&&(t1+=JSON.stringify(e1.data,this.replacer)),t1}encodeAsBinary(e1){const t1=deconstructPacket(e1),r1=this.encodeAsString(t1.packet),o1=t1.buffers;return o1.unshift(r1),o1}}class Decoder extends Emitter{constructor(e1){super(),this.reviver=e1}add(e1){let t1;if(typeof e1=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t1=this.decodeString(e1);const r1=t1.type===PacketType.BINARY_EVENT;r1||t1.type===PacketType.BINARY_ACK?(t1.type=r1?PacketType.EVENT:PacketType.ACK,this.reconstructor=new BinaryReconstructor(t1),t1.attachments===0&&super.emitReserved("decoded",t1)):super.emitReserved("decoded",t1)}else if(isBinary(e1)||e1.base64)if(this.reconstructor)t1=this.reconstructor.takeBinaryData(e1),t1&&(this.reconstructor=null,super.emitReserved("decoded",t1));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e1)}decodeString(e1){let t1=0;const r1={type:Number(e1.charAt(0))};if(PacketType[r1.type]===void 0)throw new Error("unknown packet type "+r1.type);if(r1.type===PacketType.BINARY_EVENT||r1.type===PacketType.BINARY_ACK){const i1=t1+1;for(;e1.charAt(++t1)!=="-"&&t1!=e1.length;);const a1=e1.substring(i1,t1);if(a1!=Number(a1)||e1.charAt(t1)!=="-")throw new Error("Illegal attachments");r1.attachments=Number(a1)}if(e1.charAt(t1+1)==="/"){const i1=t1+1;for(;++t1&&!(e1.charAt(t1)===","||t1===e1.length););r1.nsp=e1.substring(i1,t1)}else r1.nsp="/";const o1=e1.charAt(t1+1);if(o1!==""&&Number(o1)==o1){const i1=t1+1;for(;++t1;){const a1=e1.charAt(t1);if(a1==null||Number(a1)!=a1){--t1;break}if(t1===e1.length)break}r1.id=Number(e1.substring(i1,t1+1))}if(e1.charAt(++t1)){const i1=this.tryParse(e1.substr(t1));if(Decoder.isPayloadValid(r1.type,i1))r1.data=i1;else throw new Error("invalid payload")}return r1}tryParse(e1){try{return JSON.parse(e1,this.reviver)}catch{return!1}}static isPayloadValid(e1,t1){switch(e1){case PacketType.CONNECT:return typeof t1=="object";case PacketType.DISCONNECT:return t1===void 0;case PacketType.CONNECT_ERROR:return typeof t1=="string"||typeof t1=="object";case PacketType.EVENT:case PacketType.BINARY_EVENT:return Array.isArray(t1)&&(typeof t1[0]=="string"||typeof t1[0]=="number");case PacketType.ACK:case PacketType.BINARY_ACK:return Array.isArray(t1)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class BinaryReconstructor{constructor(e1){this.packet=e1,this.buffers=[],this.reconPack=e1}takeBinaryData(e1){if(this.buffers.push(e1),this.buffers.length===this.reconPack.attachments){const t1=reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t1}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const parser$2=Object.freeze(Object.defineProperty({__proto__:null,Decoder,Encoder,get PacketType(){return PacketType},protocol},Symbol.toStringTag,{value:"Module"}));function on$1(n1,e1,t1){return n1.on(e1,t1),function(){n1.off(e1,t1)}}const RESERVED_EVENTS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Socket extends Emitter{constructor(e1,t1,r1){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e1,this.nsp=t1,r1&&r1.auth&&(this.auth=r1.auth),this._opts=Object.assign({},r1),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e1=this.io;this.subs=[on$1(e1,"open",this.onopen.bind(this)),on$1(e1,"packet",this.onpacket.bind(this)),on$1(e1,"error",this.onerror.bind(this)),on$1(e1,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e1){return e1.unshift("message"),this.emit.apply(this,e1),this}emit(e1,...t1){if(RESERVED_EVENTS.hasOwnProperty(e1))throw new Error('"'+e1.toString()+'" is a reserved event name');if(t1.unshift(e1),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t1),this;const r1={type:PacketType.EVENT,data:t1};if(r1.options={},r1.options.compress=this.flags.compress!==!1,typeof t1[t1.length-1]=="function"){const a1=this.ids++,s1=t1.pop();this._registerAckCallback(a1,s1),r1.id=a1}const o1=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!o1||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r1),this.packet(r1)):this.sendBuffer.push(r1)),this.flags={},this}_registerAckCallback(e1,t1){var r1;const o1=(r1=this.flags.timeout)!==null&&r1!==void 0?r1:this._opts.ackTimeout;if(o1===void 0){this.acks[e1]=t1;return}const i1=this.io.setTimeoutFn(()=>{delete this.acks[e1];for(let a1=0;a1<this.sendBuffer.length;a1++)this.sendBuffer[a1].id===e1&&this.sendBuffer.splice(a1,1);t1.call(this,new Error("operation has timed out"))},o1);this.acks[e1]=(...a1)=>{this.io.clearTimeoutFn(i1),t1.apply(this,[null,...a1])}}emitWithAck(e1,...t1){const r1=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((o1,i1)=>{t1.push((a1,s1)=>r1?a1?i1(a1):o1(s1):o1(a1)),this.emit(e1,...t1)})}_addToQueue(e1){let t1;typeof e1[e1.length-1]=="function"&&(t1=e1.pop());const r1={id:this._queueSeq++,tryCount:0,pending:!1,args:e1,flags:Object.assign({fromQueue:!0},this.flags)};e1.push((o1,...i1)=>r1!==this._queue[0]?void 0:(o1!==null?r1.tryCount>this._opts.retries&&(this._queue.shift(),t1&&t1(o1)):(this._queue.shift(),t1&&t1(null,...i1)),r1.pending=!1,this._drainQueue())),this._queue.push(r1),this._drainQueue()}_drainQueue(e1=!1){if(!this.connected||this._queue.length===0)return;const t1=this._queue[0];t1.pending&&!e1||(t1.pending=!0,t1.tryCount++,this.flags=t1.flags,this.emit.apply(this,t1.args))}packet(e1){e1.nsp=this.nsp,this.io._packet(e1)}onopen(){typeof this.auth=="function"?this.auth(e1=>{this._sendConnectPacket(e1)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e1){this.packet({type:PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e1):e1})}onerror(e1){this.connected||this.emitReserved("connect_error",e1)}onclose(e1,t1){this.connected=!1,delete this.id,this.emitReserved("disconnect",e1,t1)}onpacket(e1){if(e1.nsp===this.nsp)switch(e1.type){case PacketType.CONNECT:e1.data&&e1.data.sid?this.onconnect(e1.data.sid,e1.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case PacketType.EVENT:case PacketType.BINARY_EVENT:this.onevent(e1);break;case PacketType.ACK:case PacketType.BINARY_ACK:this.onack(e1);break;case PacketType.DISCONNECT:this.ondisconnect();break;case PacketType.CONNECT_ERROR:this.destroy();const r1=new Error(e1.data.message);r1.data=e1.data.data,this.emitReserved("connect_error",r1);break}}onevent(e1){const t1=e1.data||[];e1.id!=null&&t1.push(this.ack(e1.id)),this.connected?this.emitEvent(t1):this.receiveBuffer.push(Object.freeze(t1))}emitEvent(e1){if(this._anyListeners&&this._anyListeners.length){const t1=this._anyListeners.slice();for(const r1 of t1)r1.apply(this,e1)}super.emit.apply(this,e1),this._pid&&e1.length&&typeof e1[e1.length-1]=="string"&&(this._lastOffset=e1[e1.length-1])}ack(e1){const t1=this;let r1=!1;return function(...o1){r1||(r1=!0,t1.packet({type:PacketType.ACK,id:e1,data:o1}))}}onack(e1){const t1=this.acks[e1.id];typeof t1=="function"&&(t1.apply(this,e1.data),delete this.acks[e1.id])}onconnect(e1,t1){this.id=e1,this.recovered=t1&&this._pid===t1,this._pid=t1,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e1=>this.emitEvent(e1)),this.receiveBuffer=[],this.sendBuffer.forEach(e1=>{this.notifyOutgoingListeners(e1),this.packet(e1)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e1=>e1()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:PacketType.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e1){return this.flags.compress=e1,this}get volatile(){return this.flags.volatile=!0,this}timeout(e1){return this.flags.timeout=e1,this}onAny(e1){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e1),this}prependAny(e1){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e1),this}offAny(e1){if(!this._anyListeners)return this;if(e1){const t1=this._anyListeners;for(let r1=0;r1<t1.length;r1++)if(e1===t1[r1])return t1.splice(r1,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e1){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e1),this}prependAnyOutgoing(e1){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e1),this}offAnyOutgoing(e1){if(!this._anyOutgoingListeners)return this;if(e1){const t1=this._anyOutgoingListeners;for(let r1=0;r1<t1.length;r1++)if(e1===t1[r1])return t1.splice(r1,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e1){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t1=this._anyOutgoingListeners.slice();for(const r1 of t1)r1.apply(this,e1.data)}}}function Backoff(n1){n1=n1||{},this.ms=n1.min||100,this.max=n1.max||1e4,this.factor=n1.factor||2,this.jitter=n1.jitter>0&&n1.jitter<=1?n1.jitter:0,this.attempts=0}Backoff.prototype.duration=function(){var n1=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e1=Math.random(),t1=Math.floor(e1*this.jitter*n1);n1=Math.floor(e1*10)&1?n1+t1:n1-t1}return Math.min(n1,this.max)|0};Backoff.prototype.reset=function(){this.attempts=0};Backoff.prototype.setMin=function(n1){this.ms=n1};Backoff.prototype.setMax=function(n1){this.max=n1};Backoff.prototype.setJitter=function(n1){this.jitter=n1};class Manager extends Emitter{constructor(e1,t1){var r1;super(),this.nsps={},this.subs=[],e1&&typeof e1=="object"&&(t1=e1,e1=void 0),t1=t1||{},t1.path=t1.path||"/socket.io",this.opts=t1,installTimerFunctions(this,t1),this.reconnection(t1.reconnection!==!1),this.reconnectionAttempts(t1.reconnectionAttempts||1/0),this.reconnectionDelay(t1.reconnectionDelay||1e3),this.reconnectionDelayMax(t1.reconnectionDelayMax||5e3),this.randomizationFactor((r1=t1.randomizationFactor)!==null&&r1!==void 0?r1:.5),this.backoff=new Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t1.timeout==null?2e4:t1.timeout),this._readyState="closed",this.uri=e1;const o1=t1.parser||parser$2;this.encoder=new o1.Encoder,this.decoder=new o1.Decoder,this._autoConnect=t1.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e1){return arguments.length?(this._reconnection=!!e1,this):this._reconnection}reconnectionAttempts(e1){return e1===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e1,this)}reconnectionDelay(e1){var t1;return e1===void 0?this._reconnectionDelay:(this._reconnectionDelay=e1,(t1=this.backoff)===null||t1===void 0||t1.setMin(e1),this)}randomizationFactor(e1){var t1;return e1===void 0?this._randomizationFactor:(this._randomizationFactor=e1,(t1=this.backoff)===null||t1===void 0||t1.setJitter(e1),this)}reconnectionDelayMax(e1){var t1;return e1===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e1,(t1=this.backoff)===null||t1===void 0||t1.setMax(e1),this)}timeout(e1){return arguments.length?(this._timeout=e1,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e1){if(~this._readyState.indexOf("open"))return this;this.engine=new Socket$1(this.uri,this.opts);const t1=this.engine,r1=this;this._readyState="opening",this.skipReconnect=!1;const o1=on$1(t1,"open",function(){r1.onopen(),e1&&e1()}),i1=on$1(t1,"error",a1=>{r1.cleanup(),r1._readyState="closed",this.emitReserved("error",a1),e1?e1(a1):r1.maybeReconnectOnOpen()});if(this._timeout!==!1){const a1=this._timeout;a1===0&&o1();const s1=this.setTimeoutFn(()=>{o1(),t1.close(),t1.emit("error",new Error("timeout"))},a1);this.opts.autoUnref&&s1.unref(),this.subs.push(function(){clearTimeout(s1)})}return this.subs.push(o1),this.subs.push(i1),this}connect(e1){return this.open(e1)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e1=this.engine;this.subs.push(on$1(e1,"ping",this.onping.bind(this)),on$1(e1,"data",this.ondata.bind(this)),on$1(e1,"error",this.onerror.bind(this)),on$1(e1,"close",this.onclose.bind(this)),on$1(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e1){try{this.decoder.add(e1)}catch(t1){this.onclose("parse error",t1)}}ondecoded(e1){nextTick(()=>{this.emitReserved("packet",e1)},this.setTimeoutFn)}onerror(e1){this.emitReserved("error",e1)}socket(e1,t1){let r1=this.nsps[e1];return r1?this._autoConnect&&!r1.active&&r1.connect():(r1=new Socket(this,e1,t1),this.nsps[e1]=r1),r1}_destroy(e1){const t1=Object.keys(this.nsps);for(const r1 of t1)if(this.nsps[r1].active)return;this._close()}_packet(e1){const t1=this.encoder.encode(e1);for(let r1=0;r1<t1.length;r1++)this.engine.write(t1[r1],e1.options)}cleanup(){this.subs.forEach(e1=>e1()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e1,t1){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e1,t1),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e1=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t1=this.backoff.duration();this._reconnecting=!0;const r1=this.setTimeoutFn(()=>{e1.skipReconnect||(this.emitReserved("reconnect_attempt",e1.backoff.attempts),!e1.skipReconnect&&e1.open(o1=>{o1?(e1._reconnecting=!1,e1.reconnect(),this.emitReserved("reconnect_error",o1)):e1.onreconnect()}))},t1);this.opts.autoUnref&&r1.unref(),this.subs.push(function(){clearTimeout(r1)})}}onreconnect(){const e1=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e1)}}const cache$1={};function lookup(n1,e1){typeof n1=="object"&&(e1=n1,n1=void 0),e1=e1||{};const t1=url$1(n1,e1.path||"/socket.io"),r1=t1.source,o1=t1.id,i1=t1.path,a1=cache$1[o1]&&i1 in cache$1[o1].nsps,s1=e1.forceNew||e1["force new connection"]||e1.multiplex===!1||a1;let l1;return s1?l1=new Manager(r1,e1):(cache$1[o1]||(cache$1[o1]=new Manager(r1,e1)),l1=cache$1[o1]),t1.query&&!e1.query&&(e1.query=t1.queryKey),l1.socket(t1.path,e1)}Object.assign(lookup,{Manager,Socket,io:lookup,connect:lookup});const DefaultOptions={heartbeat:!0},createWebsocket=(n1,e1=DefaultOptions)=>{if(!n1)throw"A websocket path must be provided";const{heartbeat:t1}={...DefaultOptions,...e1},r1=location.protocol==="https:",o1=r1?"wss:":"ws:",i1=location.hostname,a1=location.port||(r1?443:80);let s1=lookup(`${o1}//${i1}:${a1}`,{path:n1,reconnectionAttempts:3,reconnectionDelay:5e3,reconnectionDelayMax:5e3,timeout:4e3,transports:["websocket"]}),l1;return t1&&(l1=setInterval(()=>{s1.emit(SocketEvent.Heartbeat)},SocketSessionTTL*500)),s1.on("disconnect",()=>{clearInterval(l1)}),s1.onOther=(c1,u1)=>{s1.on(c1,f1=>{(f1==null?void 0:f1.apiSessionId)!==APISessionID&&u1(f1)})},s1};function downloadText(n1,e1){typeof e1=="object"&&(e1=JSON.stringify(e1));const t1=new Blob([e1],{type:"plain/text"}),r1=URL.createObjectURL(t1),o1=document.createElement("a");o1.href=r1,o1.download=n1,o1.click(),URL.revokeObjectURL(r1)}async function downloadStream(n1){const e1=await n1.blob(),t1=n1.headers.get("Content-Disposition"),o1=/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(t1)[1].replace(/['"]/g,""),i1=new Blob([e1]),a1=URL.createObjectURL(i1),s1=document.createElement("a");s1.href=a1,s1.download=o1,s1.click(),URL.revokeObjectURL(a1)}const{buildLuceneQuery,luceneLimit,runLuceneQuery,luceneSort}=LuceneUtils;class DataFetch{constructor(e1){if(this.API=null,this.features={supportsSearch:!1,supportsSort:!1,supportsPagination:!1},this.options={datasource:null,limit:10,filter:null,query:null,sortColumn:null,sortOrder:"ascending",sortType:null,paginate:!0,clientSideSearching:!0,clientSideSorting:!0,clientSideLimiting:!0},this.store=writable({rows:[],info:null,schema:null,loading:!1,loaded:!1,query:null,pageNumber:0,cursor:null,cursors:[],resetKey:Math.random(),error:null}),this.API=e1==null?void 0:e1.API,this.options={...this.options,...e1},!this.API)throw"An API client is required for fetching data";if(this.getData=this.getData.bind(this),this.getPage=this.getPage.bind(this),this.getInitialData=this.getInitialData.bind(this),this.determineFeatureFlags=this.determineFeatureFlags.bind(this),this.refresh=this.refresh.bind(this),this.update=this.update.bind(this),this.hasNextPage=this.hasNextPage.bind(this),this.hasPrevPage=this.hasPrevPage.bind(this),this.nextPage=this.nextPage.bind(this),this.prevPage=this.prevPage.bind(this),this.derivedStore=derived(this.store,t1=>({...t1,...this.features,hasNextPage:this.hasNextPage(t1),hasPrevPage:this.hasPrevPage(t1)})),!this.options.datasource){this.store.update(t1=>({...t1,loaded:!0}));return}this.getInitialData()}get subscribe(){return this.derivedStore.subscribe}getDefaultSortColumn(e1,t1){return e1!=null&&e1.primaryDisplay&&t1[e1.primaryDisplay]?e1.primaryDisplay:Object.keys(t1)[0]}async getInitialData(){var c1;const{datasource:e1,filter:t1,paginate:r1}=this.options,o1=await this.getDefinition(e1),i1=this.determineFeatureFlags(o1);this.features={supportsSearch:!!(i1!=null&&i1.supportsSearch),supportsSort:!!(i1!=null&&i1.supportsSort),supportsPagination:r1&&!!(i1!=null&&i1.supportsPagination)};let a1=this.getSchema(e1,o1);if(a1=this.enrichSchema(a1),!a1)return;if(this.options.sortColumn&&!a1[this.options.sortColumn]&&(this.options.sortColumn=null),this.options.sortColumn||(this.options.sortColumn=this.getDefaultSortColumn(o1,a1)),!this.options.sortColumn)this.options.sortOrder="ascending",this.options.sortType=null;else{const u1=(c1=a1==null?void 0:a1[this.options.sortColumn])==null?void 0:c1.type;this.options.sortType=u1==="number"||u1==="bigint"?"number":"string",this.options.sortOrder||(this.options.sortOrder="ascending")}let s1=this.options.query;s1||(s1=buildLuceneQuery(t1)),this.store.update(u1=>({...u1,definition:o1,schema:a1,query:s1,loading:!0,cursors:[],cursor:null}));const l1=await this.getPage();this.store.update(u1=>({...u1,loading:!1,loaded:!0,pageNumber:0,rows:l1.rows,info:l1.info,cursors:r1&&l1.hasNextPage?[null,l1.cursor]:[null],error:l1.error,resetKey:Math.random()}))}async getPage(){const{sortColumn:e1,sortOrder:t1,sortType:r1,limit:o1,clientSideSearching:i1,clientSideSorting:a1,clientSideLimiting:s1}=this.options,{query:l1}=get_store_value(this.store);let{rows:c1,info:u1,hasNextPage:f1,cursor:d1,error:p1}=await this.getData();return!this.features.supportsSearch&&i1&&(c1=runLuceneQuery(c1,l1)),!this.features.supportsSort&&a1&&(c1=luceneSort(c1,e1,t1,r1)),!this.features.supportsPagination&&s1&&(c1=luceneLimit(c1,o1)),{rows:c1,info:u1,hasNextPage:f1,cursor:d1,error:p1}}async getData(){return{rows:[],info:null,hasNextPage:!1,cursor:null}}async getDefinition(e1){if(!(e1!=null&&e1.tableId))return null;try{return await this.API.fetchTableDefinition(e1.tableId)}catch(t1){return this.store.update(r1=>({...r1,error:t1})),null}}getSchema(e1,t1){return t1==null?void 0:t1.schema}enrichSchema(e1){if(e1==null)return null;let t1={};Object.keys(e1).forEach(o1=>{const i1=e1[o1];if((i1==null?void 0:i1.type)==="json"){const a1=convertJSONSchemaToTableSchema(i1,{squashObjects:!0});Object.keys(a1).forEach(s1=>{t1[`${o1}.${s1}`]={type:a1[s1].type,nestedJSON:!0}})}}),e1={...e1,...t1};let r1={};return Object.entries(e1).forEach(([o1,i1])=>{typeof i1=="string"?r1[o1]={type:i1,name:o1}:r1[o1]={...i1,name:o1}}),r1}determineFeatureFlags(e1){return{supportsSearch:!1,supportsSort:!1,supportsPagination:!1}}async update(e1){let t1=!1;const r1=Object.entries(e1||{});for(let[o1,i1]of r1)if(JSON.stringify(i1)!==JSON.stringify(this.options[o1])){t1=!0;break}t1&&(this.options={...this.options,...fp$1.cloneDeep(e1)},await this.getInitialData())}async refresh(){if(get_store_value(this.store).loading)return;this.store.update(l1=>({...l1,loading:!0}));const{rows:e1,info:t1,error:r1,cursor:o1}=await this.getPage();let{cursors:i1}=get_store_value(this.store);const{pageNumber:a1}=get_store_value(this.store);if(!e1.length&&a1>0)return this.store.update(l1=>({...l1,loading:!1,cursors:i1.slice(0,a1)})),await this.prevPage();i1[a1+1]!=o1&&(i1=i1.slice(0,a1+1),i1[a1+1]=o1),this.store.update(l1=>({...l1,rows:e1,info:t1,loading:!1,error:r1,cursors:i1}))}hasNextPage(e1){return e1.cursors[e1.pageNumber+1]!=null}hasPrevPage(e1){return e1.pageNumber>0}async nextPage(){const e1=get_store_value(this.derivedStore);if(e1.loading||!this.options.paginate||!e1.hasNextPage)return;const t1=e1.cursors[e1.pageNumber+1];this.store.update(l1=>({...l1,loading:!0,cursor:t1,pageNumber:l1.pageNumber+1}));const{rows:r1,info:o1,hasNextPage:i1,cursor:a1,error:s1}=await this.getPage();this.store.update(l1=>{let{cursors:c1,pageNumber:u1}=l1;return i1&&(c1[u1+1]=a1),{...l1,rows:r1,info:o1,cursors:c1,loading:!1,error:s1}})}async prevPage(){const e1=get_store_value(this.derivedStore);if(e1.loading||!this.options.paginate||!e1.hasPrevPage)return;const t1=e1.cursors[e1.pageNumber-1];this.store.update(a1=>({...a1,loading:!0,cursor:t1,pageNumber:a1.pageNumber-1}));const{rows:r1,info:o1,error:i1}=await this.getPage();this.store.update(a1=>({...a1,rows:r1,info:o1,loading:!1,error:i1}))}}class TableFetch extends DataFetch{determineFeatureFlags(){return{supportsSearch:!0,supportsSort:!0,supportsPagination:!0}}async getData(){const{datasource:e1,limit:t1,sortColumn:r1,sortOrder:o1,sortType:i1,paginate:a1}=this.options,{tableId:s1}=e1,{cursor:l1,query:c1}=get_store_value(this.store);try{const u1=await this.API.searchTable({tableId:s1,query:c1,limit:t1,sort:r1,sortOrder:(o1==null?void 0:o1.toLowerCase())??"ascending",sortType:i1,paginate:a1,bookmark:l1});return{rows:(u1==null?void 0:u1.rows)||[],hasNextPage:(u1==null?void 0:u1.hasNextPage)||!1,cursor:(u1==null?void 0:u1.bookmark)||null}}catch(u1){return{rows:[],hasNextPage:!1,error:u1}}}}class ViewFetch extends DataFetch{getSchema(e1,t1){var r1,o1;return(o1=(r1=t1==null?void 0:t1.views)==null?void 0:r1[e1.name])==null?void 0:o1.schema}async getData(){const{datasource:e1}=this.options;try{return{rows:await this.API.fetchViewData(e1)||[]}}catch{return{rows:[]}}}}class ViewV2Fetch extends DataFetch{determineFeatureFlags(){return{supportsSearch:!0,supportsSort:!0,supportsPagination:!0}}getSchema(e1,t1){return t1==null?void 0:t1.schema}async getDefinition(e1){if(!(e1!=null&&e1.id))return null;try{const t1=await this.API.viewV2.fetchDefinition(e1.id);return t1==null?void 0:t1.data}catch(t1){return this.store.update(r1=>({...r1,error:t1})),null}}getDefaultSortColumn(){return null}async getData(){var f1,d1;const{datasource:e1,limit:t1,sortColumn:r1,sortOrder:o1,sortType:i1,paginate:a1,filter:s1}=this.options,{cursor:l1,query:c1,definition:u1}=get_store_value(this.store);!r1&&((f1=u1.sort)!=null&&f1.field)&&(this.options.sortColumn=u1.sort.field,this.options.sortOrder=u1.sort.order),!(s1!=null&&s1.length)&&((d1=u1.query)!=null&&d1.length)&&(this.options.filter=u1.query);try{const p1=await this.API.viewV2.fetch({viewId:e1.id,query:c1,paginate:a1,limit:t1,bookmark:l1,sort:r1,sortOrder:o1==null?void 0:o1.toLowerCase(),sortType:i1});return{rows:(p1==null?void 0:p1.rows)||[],hasNextPage:(p1==null?void 0:p1.hasNextPage)||!1,cursor:(p1==null?void 0:p1.bookmark)||null}}catch(p1){return{rows:[],hasNextPage:!1,error:p1}}}}class QueryFetch extends DataFetch{determineFeatureFlags(e1){var r1,o1,i1,a1,s1,l1;return{supportsPagination:!!((o1=(r1=e1==null?void 0:e1.fields)==null?void 0:r1.pagination)!=null&&o1.type)&&!!((a1=(i1=e1==null?void 0:e1.fields)==null?void 0:i1.pagination)!=null&&a1.location)&&!!((l1=(s1=e1==null?void 0:e1.fields)==null?void 0:s1.pagination)!=null&&l1.pageParam)}}async getDefinition(e1){if(!(e1!=null&&e1._id))return null;try{const t1=await this.API.fetchQueryDefinition(e1._id);return t1.fields||(t1.fields=e1.fields),t1}catch{return null}}getDefaultSortColumn(){return null}async getData(){var u1,f1;const{datasource:e1,limit:t1,paginate:r1}=this.options,{supportsPagination:o1}=this.features,{cursor:i1,definition:a1}=get_store_value(this.store),s1=(f1=(u1=a1==null?void 0:a1.fields)==null?void 0:u1.pagination)==null?void 0:f1.type;let l1=cloneDeep((e1==null?void 0:e1.queryParams)||{});for(let d1 of(e1==null?void 0:e1.parameters)||{})l1[d1.name]||(l1[d1.name]=d1.default);let c1={queryId:e1==null?void 0:e1._id,parameters:l1};if(r1&&o1){const d1=s1==="page"?parseInt(i1||1):i1;c1.pagination={page:d1,limit:t1}}try{const d1=await this.API.executeQuery(c1),{data:p1,pagination:m1,..._1}=d1;let h1=null,g1=!1;return r1&&o1&&(s1==="page"?(h1=c1.pagination.page+1,g1=(p1==null?void 0:p1.length)===t1&&t1>0):(h1=m1==null?void 0:m1.cursor,g1=h1!=null)),{rows:p1||[],info:_1,cursor:h1,hasNextPage:g1}}catch{return{rows:[],hasNextPage:!1}}}}class RelationshipFetch extends DataFetch{async getData(){const{datasource:e1}=this.options;try{return{rows:await this.API.fetchRelationshipData({rowId:e1==null?void 0:e1.rowId,tableId:e1==null?void 0:e1.rowTableId,fieldName:e1==null?void 0:e1.fieldName})||[]}}catch{return{rows:[]}}}}class NestedProviderFetch extends DataFetch{async getDefinition(e1){var t1;return{schema:(t1=e1==null?void 0:e1.value)==null?void 0:t1.schema}}async getData(){var t1;const{datasource:e1}=this.options;return{rows:((t1=e1==null?void 0:e1.value)==null?void 0:t1.rows)||[],hasNextPage:!1,cursor:null}}}class FieldFetch extends DataFetch{async getDefinition(e1){let t1;return e1.fieldType==="attachment"?t1={url:{type:"string"},name:{type:"string"}}:e1.fieldType==="array"&&(t1={value:{type:"string"}}),{schema:t1}}async getData(){const{datasource:e1}=this.options,t1=(e1==null?void 0:e1.value)||[];let r1;return Array.isArray(t1)&&t1[0]&&typeof t1[0]!="object"?r1=t1.map(o1=>({value:o1})):r1=t1,{rows:r1||[],hasNextPage:!1,cursor:null}}}class JSONArrayFetch extends FieldFetch{async getDefinition(e1){try{const t1=await this.API.fetchTableDefinition(e1.tableId);return{schema:getJSONArrayDatasourceSchema(t1==null?void 0:t1.schema,e1)}}catch{return null}}}class UserFetch extends DataFetch{constructor(e1){super({...e1,datasource:{tableId:TableNames$1.USERS}})}determineFeatureFlags(){return{supportsSearch:!0,supportsSort:!1,supportsPagination:!0}}async getDefinition(){return{schema:{}}}async getData(){const{limit:e1,paginate:t1}=this.options,{cursor:r1,query:o1}=get_store_value(this.store);let i1;const{appId:a1,paginated:s1,...l1}=o1;!hasFilters(o1)&&l1.email!=null?i1={string:{email:l1.email}}:i1=l1;try{const c1={bookmark:r1,query:i1,appId:a1,paginate:s1||t1,limit:e1},u1=await this.API.searchUsers(c1);return{rows:(u1==null?void 0:u1.data)||[],hasNextPage:(u1==null?void 0:u1.hasNextPage)||!1,cursor:(u1==null?void 0:u1.nextPage)||null}}catch(c1){return{rows:[],hasNextPage:!1,error:c1}}}}class GroupUserFetch extends DataFetch{constructor(e1){super({...e1,datasource:{tableId:TableNames$1.USERS}})}determineFeatureFlags(){return{supportsSearch:!0,supportsSort:!1,supportsPagination:!0}}async getDefinition(){return{schema:{}}}async getData(){const{query:e1,cursor:t1}=get_store_value(this.store);try{const r1=await this.API.getGroupUsers({id:e1.groupId,emailSearch:e1.emailSearch,bookmark:t1});return{rows:(r1==null?void 0:r1.users)||[],hasNextPage:(r1==null?void 0:r1.hasNextPage)||!1,cursor:(r1==null?void 0:r1.bookmark)||null}}catch(r1){return{rows:[],hasNextPage:!1,error:r1}}}}class CustomFetch extends DataFetch{getType(e1){return e1==null?"string":typeof e1==="object"?Array.isArray(e1)?"array":"json":isNaN(e1)?"string":"number"}parseCustomData(e1){if(!e1)return[];if(Array.isArray(e1))return e1;if(typeof e1=="string"){try{const t1=JSON.parse(e1);return Array.isArray(t1)?t1:[t1]}catch{}return e1.includes(`
377
377
  `)?e1.split(`
378
378
  `).map(t1=>t1.trim()):e1.split(",").map(t1=>t1.trim())}return[e1]}enrichCustomData(e1){return e1!=null&&e1.length?(e1=e1.filter(t1=>t1!=null&&t1!==""&&!Array.isArray(t1)),e1.map(t1=>{if(typeof t1=="object")return t1;if(typeof t1=="string"){const r1=t1.split(",").map(i1=>i1.trim());let o1={};for(let i1=0;i1<r1.length;i1++){const s1=`Value${i1===0?"":` ${i1+1}`}`;o1[s1]=r1[i1]}return o1}return{Value:t1}})):[]}getCustomData(e1){return this.enrichCustomData(this.parseCustomData(e1==null?void 0:e1.data))}async getDefinition(e1){let t1={};const r1=this.getCustomData(e1);if(!(r1!=null&&r1.length))return{schema:t1};for(let o1 of r1)for(let i1 of Object.keys(o1))if(i1!=="_id"&&!t1[i1]){let a1=this.getType(o1[i1]),s1={};if(a1==="string"){const l1=[...new Set(r1.map(u1=>u1[i1]))];l1.length/r1.length<=.8&&l1.length>1&&(a1="options",s1.inclusion=l1)}else a1==="array"&&(s1.inclusion=[...new Set(r1.map(l1=>l1[i1]).flat())]);t1[i1]={type:a1,constraints:s1}}return{schema:t1}}async getData(){const{datasource:e1}=this.options;return{rows:this.getCustomData(e1),hasNextPage:!1,cursor:null}}}const DataFetchMap={table:TableFetch,view:ViewFetch,viewV2:ViewV2Fetch,query:QueryFetch,link:RelationshipFetch,user:UserFetch,groupUser:GroupUserFetch,custom:CustomFetch,provider:NestedProviderFetch,field:FieldFetch,jsonarray:JSONArrayFetch},fetchData=({API:n1,datasource:e1,options:t1})=>{const r1=DataFetchMap[e1==null?void 0:e1.type]||TableFetch;return new r1({API:n1,datasource:e1,...t1})},createEmptyFetchInstance=({API:n1,datasource:e1})=>{const t1=DataFetchMap[e1==null?void 0:e1.type];return t1?new t1({API:n1}):null},getDatasourceDefinition=async({API:n1,datasource:e1})=>{const t1=createEmptyFetchInstance({API:n1,datasource:e1});return await(t1==null?void 0:t1.getDefinition(e1))},getDatasourceSchema=({API:n1,datasource:e1,definition:t1})=>{const r1=createEmptyFetchInstance({API:n1,datasource:e1});return r1==null?void 0:r1.getSchema(e1,t1)},createLocalStorageStore=(n1,e1)=>{const t1=writable(e1,()=>{i1();const a1=({key:s1})=>s1===n1&&i1();return window.addEventListener("storage",a1),()=>window.removeEventListener("storage",a1)}),r1=a1=>{t1.set(a1),localStorage.setItem(n1,JSON.stringify(a1))},o1=a1=>r1(a1(get_store_value(t1))),i1=()=>{const a1=localStorage.getItem(n1);if(a1==null)r1(e1);else try{t1.set(JSON.parse(a1))}catch{r1(e1)}};return{...t1,set:r1,update:o1}},BG="/builder/assets/bg-29e85dd5.png",SplitPage_svelte_svelte_type_style_lang="",get_right_slot_changes$1=n1=>({}),get_right_slot_context$1=n1=>({});function create_fragment$7_(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1;const u1=n1[1].default,f1=create_slot(u1,n1,n1[0],null),d1=n1[1].right,p1=create_slot(d1,n1,n1[0],get_right_slot_context$1);return{c(){e1=element("div"),t1=element("div"),r1=element("div"),f1&&f1.c(),o1=space$1(),i1=element("div"),a1=element("img"),l1=space$1(),p1&&p1.c(),attr(r1,"class","content svelte-63esek"),attr(t1,"class","left svelte-63esek"),src_url_equal(a1.src,s1=BG)||attr(a1,"src",s1),attr(a1,"alt"," "),attr(a1,"class","svelte-63esek"),attr(i1,"class","right spectrum spectrum--darkest svelte-63esek"),attr(e1,"class","split-page svelte-63esek")},m(m1,_1){insert$1(m1,e1,_1),append$1(e1,t1),append$1(t1,r1),f1&&f1.m(r1,null),append$1(e1,o1),append$1(e1,i1),append$1(i1,a1),append$1(i1,l1),p1&&p1.m(i1,null),c1=!0},p(m1,[_1]){f1&&f1.p&&(!c1||_1&1)&&update_slot_base(f1,u1,m1,m1[0],c1?get_slot_changes(u1,m1[0],_1,null):get_all_dirty_from_scope(m1[0]),null),p1&&p1.p&&(!c1||_1&1)&&update_slot_base(p1,d1,m1,m1[0],c1?get_slot_changes(d1,m1[0],_1,get_right_slot_changes$1):get_all_dirty_from_scope(m1[0]),get_right_slot_context$1)},i(m1){c1||(transition_in(f1,m1),transition_in(p1,m1),c1=!0)},o(m1){transition_out(f1,m1),transition_out(p1,m1),c1=!1},d(m1){m1&&detach(e1),f1&&f1.d(m1),p1&&p1.d(m1)}}}function instance$89(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1;return n1.$$set=i1=>{"$$scope"in i1&&t1(0,o1=i1.$$scope)},[o1,r1]}class SplitPage extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$89,create_fragment$7_,safe_not_equal,{})}}const Bulgaria="/builder/assets/bulgaria-bd68393d.png",Covanta="/builder/assets/covanta-72c46c1e.png",Schnellecke="/builder/assets/schnellecke-cf1837a8.png",Testimonial_svelte_svelte_type_style_lang="";function create_default_slot$54(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1;return{c(){e1=element("img"),r1=space$1(),o1=element("div"),o1.textContent=`"${n1[0].text}"`,i1=space$1(),a1=element("div"),s1=element("div"),s1.textContent=`${n1[0].name}`,l1=space$1(),c1=element("div"),c1.textContent=`${n1[0].role}`,attr(e1,"width",n1[0].imageSize),attr(e1,"alt","a-happy-budibase-user"),src_url_equal(e1.src,t1=n1[0].image)||attr(e1,"src",t1),attr(o1,"class","text svelte-1rdu21t"),attr(s1,"class","name svelte-1rdu21t"),attr(c1,"class","company svelte-1rdu21t"),attr(a1,"class","author")},m(u1,f1){insert$1(u1,e1,f1),insert$1(u1,r1,f1),insert$1(u1,o1,f1),insert$1(u1,i1,f1),insert$1(u1,a1,f1),append$1(a1,s1),append$1(a1,l1),append$1(a1,c1)},p:noop$5,d(u1){u1&&detach(e1),u1&&detach(r1),u1&&detach(o1),u1&&detach(i1),u1&&detach(a1)}}}function create_fragment$7Z(n1){let e1,t1,r1;return t1=new Layout$n({props:{noPadding:!0,gap:"S",$$slots:{default:[create_default_slot$54]},$$scope:{ctx:n1}}}),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","testimonial svelte-1rdu21t")},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,[i1]){const a1={};i1&4&&(a1.$$scope={dirty:i1,ctx:o1}),t1.$set(a1)},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function instance$88(n1){return[[{text:"Budibase was the only solution that checked all the boxes for Covanta. Covanta expects to realize $3.2MM in savings due to the elimination of redundant data entry.",name:"Charles Link",role:"Senior Director, Data and Analytics",image:Covanta,imageSize:105},{text:"Budibase was mission-critical for us and went a long way in preventing what could have become a humanitarian crisis here in Bulgaria.",name:"Bozhidar Bozhanov",role:"Government of Bulgaria",image:Bulgaria,imageSize:49},{text:"Centralization of authentication, quick turnaround time for requests, integration with different database systems has given it the edge and it’s now used daily for internal development for those apps that you know you need but don’t feel value in losing days of development to reinvent the wheel.",name:"Davide Lenzarini",role:"IT manager",image:Schnellecke,imageSize:141}][Math.floor(Math.random()*3)]]}class Testimonial extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$88,create_fragment$7Z,safe_not_equal,{})}}const TestimonialPage_svelte_svelte_type_style_lang="";function create_default_slot$53(n1){let e1;const t1=n1[1].default,r1=create_slot(t1,n1,n1[2],null);return{c(){r1&&r1.c()},m(o1,i1){r1&&r1.m(o1,i1),e1=!0},p(o1,i1){r1&&r1.p&&(!e1||i1&4)&&update_slot_base(r1,t1,o1,o1[2],e1?get_slot_changes(t1,o1[2],i1,null):get_all_dirty_from_scope(o1[2]),null)},i(o1){e1||(transition_in(r1,o1),e1=!0)},o(o1){transition_out(r1,o1),e1=!1},d(o1){r1&&r1.d(o1)}}}function create_if_block$3I(n1){let e1,t1;return e1=new Testimonial({}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_right_slot$1(n1){let e1,t1,r1=n1[0]&&create_if_block$3I();return{c(){e1=element("div"),r1&&r1.c(),attr(e1,"slot","right"),attr(e1,"class","svelte-1ow1lgm"),toggle_class(e1,"wrapper",n1[0])},m(o1,i1){insert$1(o1,e1,i1),r1&&r1.m(e1,null),t1=!0},p(o1,i1){o1[0]?r1?i1&1&&transition_in(r1,1):(r1=create_if_block$3I(),r1.c(),transition_in(r1,1),r1.m(e1,null)):r1&&(group_outros(),transition_out(r1,1,1,()=>{r1=null}),check_outros()),(!t1||i1&1)&&toggle_class(e1,"wrapper",o1[0])},i(o1){t1||(transition_in(r1),t1=!0)},o(o1){transition_out(r1),t1=!1},d(o1){o1&&detach(e1),r1&&r1.d()}}}function create_fragment$7Y(n1){let e1,t1;return e1=new SplitPage({props:{$$slots:{right:[create_right_slot$1],default:[create_default_slot$53]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&5&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$87(n1,e1,t1){let{$$slots:r1={},$$scope:o1}=e1,{enabled:i1=!0}=e1;return n1.$$set=a1=>{"enabled"in a1&&t1(0,i1=a1.enabled),"$$scope"in a1&&t1(2,o1=a1.$$scope)},[i1,r1,o1]}class TestimonialPage extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$87,create_fragment$7Y,safe_not_equal,{enabled:0})}}function create_if_block$3H(n1){let e1,t1;return e1=new AbsTooltip({props:{text:n1[3]?getUserLabel(n1[0]):null,position:n1[2],color:getUserColor(n1[0]),$$slots:{default:[create_default_slot$52]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&9&&(i1.text=r1[3]?getUserLabel(r1[0]):null),o1&4&&(i1.position=r1[2]),o1&1&&(i1.color=getUserColor(r1[0])),o1&19&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_default_slot$52(n1){let e1,t1;return e1=new Avatar({props:{size:n1[1],initials:getUserInitials(n1[0]),color:getUserColor(n1[0])}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&2&&(i1.size=r1[1]),o1&1&&(i1.initials=getUserInitials(r1[0])),o1&1&&(i1.color=getUserColor(r1[0])),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$7X(n1){let e1,t1,r1=n1[0]&&create_if_block$3H(n1);return{c(){r1&&r1.c(),e1=empty$1()},m(o1,i1){r1&&r1.m(o1,i1),insert$1(o1,e1,i1),t1=!0},p(o1,[i1]){o1[0]?r1?(r1.p(o1,i1),i1&1&&transition_in(r1,1)):(r1=create_if_block$3H(o1),r1.c(),transition_in(r1,1),r1.m(e1.parentNode,e1)):r1&&(group_outros(),transition_out(r1,1,1,()=>{r1=null}),check_outros())},i(o1){t1||(transition_in(r1),t1=!0)},o(o1){transition_out(r1),t1=!1},d(o1){r1&&r1.d(o1),o1&&detach(e1)}}}function instance$86(n1,e1,t1){let{user:r1}=e1,{size:o1="S"}=e1,{tooltipPosition:i1=TooltipPosition.Top}=e1,{showTooltip:a1=!0}=e1;return n1.$$set=s1=>{"user"in s1&&t1(0,r1=s1.user),"size"in s1&&t1(1,o1=s1.size),"tooltipPosition"in s1&&t1(2,i1=s1.tooltipPosition),"showTooltip"in s1&&t1(3,a1=s1.showTooltip)},[r1,o1,i1,a1]}class UserAvatar extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$86,create_fragment$7X,safe_not_equal,{user:0,size:1,tooltipPosition:2,showTooltip:3})}}const UserAvatars_svelte_svelte_type_style_lang$1="";function get_each_context$1x(n1,e1,t1){const r1=n1.slice();return r1[8]=e1[t1],r1}function create_else_block$1n(n1){let e1,t1;return e1=new UserAvatar({props:{size:n1[0],user:n1[8],tooltipPosition:n1[1]}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&1&&(i1.size=r1[0]),o1&4&&(i1.user=r1[8]),o1&2&&(i1.tooltipPosition=r1[1]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_if_block$3G(n1){let e1,t1;return e1=new Avatar({props:{size:n1[0],initials:n1[8].label,color:"var(--spectrum-global-color-gray-500)"}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&1&&(i1.size=r1[0]),o1&4&&(i1.initials=r1[8].label),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_each_block$1x(n1){let e1,t1,r1,o1,i1;const a1=[create_if_block$3G,create_else_block$1n],s1=[];function l1(c1,u1){return c1[8]._id==="overflow"?0:1}return t1=l1(n1),r1=s1[t1]=a1[t1](n1),{c(){e1=element("span"),r1.c(),o1=space$1(),set_style(e1,"z-index",n1[8].zIndex),attr(e1,"class","svelte-1wnz660")},m(c1,u1){insert$1(c1,e1,u1),s1[t1].m(e1,null),append$1(e1,o1),i1=!0},p(c1,u1){let f1=t1;t1=l1(c1),t1===f1?s1[t1].p(c1,u1):(group_outros(),transition_out(s1[f1],1,1,()=>{s1[f1]=null}),check_outros(),r1=s1[t1],r1?r1.p(c1,u1):(r1=s1[t1]=a1[t1](c1),r1.c()),transition_in(r1,1),r1.m(e1,o1)),(!i1||u1&4)&&set_style(e1,"z-index",c1[8].zIndex)},i(c1){i1||(transition_in(r1),i1=!0)},o(c1){transition_out(r1),i1=!1},d(c1){c1&&detach(e1),s1[t1].d()}}}function create_fragment$7W(n1){let e1,t1,r1=n1[2],o1=[];for(let a1=0;a1<r1.length;a1+=1)o1[a1]=create_each_block$1x(get_each_context$1x(n1,r1,a1));const i1=a1=>transition_out(o1[a1],1,1,()=>{o1[a1]=null});return{c(){e1=element("div");for(let a1=0;a1<o1.length;a1+=1)o1[a1].c();attr(e1,"class","avatars svelte-1wnz660")},m(a1,s1){insert$1(a1,e1,s1);for(let l1=0;l1<o1.length;l1+=1)o1[l1].m(e1,null);t1=!0},p(a1,[s1]){if(s1&7){r1=a1[2];let l1;for(l1=0;l1<r1.length;l1+=1){const c1=get_each_context$1x(a1,r1,l1);o1[l1]?(o1[l1].p(c1,s1),transition_in(o1[l1],1)):(o1[l1]=create_each_block$1x(c1),o1[l1].c(),transition_in(o1[l1],1),o1[l1].m(e1,null))}for(group_outros(),l1=r1.length;l1<o1.length;l1+=1)i1(l1);check_outros()}},i(a1){if(!t1){for(let s1=0;s1<r1.length;s1+=1)transition_in(o1[s1]);t1=!0}},o(a1){o1=o1.filter(Boolean);for(let s1=0;s1<o1.length;s1+=1)transition_out(o1[s1]);t1=!1},d(a1){a1&&detach(e1),destroy_each(o1,a1)}}}function instance$85(n1,e1,t1){let r1,o1,{users:i1=[]}=e1,{order:a1="ltr"}=e1,{size:s1="S"}=e1,{tooltipPosition:l1=TooltipPosition.Top}=e1;const c1=f1=>{let d1={};return f1==null||f1.forEach(p1=>{d1[p1.email]=p1}),Object.values(d1)},u1=(f1,d1)=>{const p1=f1.slice(0,3);if(f1.length>3){const m1={_id:"overflow",label:`+${f1.length-3}`};d1==="ltr"?p1.push(m1):p1.unshift(m1)}return p1.map((m1,_1)=>({...m1,zIndex:d1==="ltr"?_1:r1.length-_1}))};return n1.$$set=f1=>{"users"in f1&&t1(3,i1=f1.users),"order"in f1&&t1(4,a1=f1.order),"size"in f1&&t1(0,s1=f1.size),"tooltipPosition"in f1&&t1(1,l1=f1.tooltipPosition)},n1.$$.update=()=>{n1.$$.dirty&24&&t1(5,r1=c1(i1)),n1.$$.dirty&48&&t1(2,o1=u1(r1,a1))},[s1,l1,o1,i1,a1,r1]}let UserAvatars$1=class extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$85,create_fragment$7W,safe_not_equal,{users:3,order:4,size:0,tooltipPosition:1})}};const createEventManagers=()=>{const n1=createEventDispatcher();let e1={};return{dispatch:(o1,i1)=>{n1(o1,i1);const a1=e1[o1]||[];for(let s1=0;s1<a1.length;s1++)a1[s1](i1)},subscribe:(o1,i1)=>{const a1=e1[o1]||[];return e1[o1]=[...a1,i1],()=>{e1[o1]=e1[o1].filter(s1=>s1!==i1)}}}},createStores$f=()=>{const n1=writable({left:0,top:0,width:0,height:0}),e1=derived(n1,r1=>r1.width,0),t1=derived(n1,r1=>r1.height,0);return{bounds:n1,height:t1,width:e1}},Bounds=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$f},Symbol.toStringTag,{value:"Module"})),Padding=246,MaxCellRenderHeight=222,ScrollBarSize=8,GutterWidth=72,DefaultColumnWidth=200,MinColumnWidth=80,SmallRowHeight=36,MediumRowHeight=64,LargeRowHeight=92,DefaultRowHeight=SmallRowHeight,NewRowID="new",BlankRowID="blank",RowPageSize=100,FocusedCellMinOffset=48,MaxCellRenderWidthOverflow=Padding-3*ScrollBarSize,createStores$e=()=>{const n1=writable([]),e1=writable(null),t1=derived(n1,o1=>{let i1=0;return o1.map(a1=>{const s1={...a1,left:i1};return a1.visible&&(i1+=a1.width),s1})},[]),r1=derived(t1,o1=>o1.filter(i1=>i1.visible),[]);return{columns:{...n1,subscribe:t1.subscribe},stickyColumn:e1,visibleColumns:r1}},deriveStores$7=n1=>{const{columns:e1,stickyColumn:t1}=n1;return{hasNonAutoColumn:derived([e1,t1],([o1,i1])=>{let a1=o1||[];return i1&&(a1=[...a1,i1]),a1.filter(l1=>{var c1;return!((c1=l1.schema)!=null&&c1.autocolumn)}).length>0})}},createActions$d=n1=>{const{columns:e1,stickyColumn:t1,datasource:r1,definition:o1,schema:i1}=n1,a1=async c1=>await r1.actions.saveDefinition({...get_store_value(o1),primaryDisplay:c1}),s1=async c1=>{e1.update(u1=>u1.map(f1=>({...f1,width:c1}))),get_store_value(t1)&&t1.update(u1=>({...u1,width:c1})),await l1()},l1=async()=>{const c1=get_store_value(e1),u1=get_store_value(o1),f1=get_store_value(t1);let d1=fp$1.cloneDeep(get_store_value(i1))||{};Object.keys(d1).forEach(p1=>{var _1,h1;const m1=c1.findIndex(g1=>g1.name===p1);m1!==-1?d1[p1].order=m1:delete d1[p1].order,p1===(f1==null?void 0:f1.name)?(d1[p1].visible=!0,d1[p1].width=f1.width||DefaultColumnWidth):(d1[p1].visible=((_1=c1[m1])==null?void 0:_1.visible)??!0,d1[p1].width=((h1=c1[m1])==null?void 0:h1.width)||DefaultColumnWidth)}),await r1.actions.saveDefinition({...u1,schema:d1})};return{columns:{...e1,actions:{saveChanges:l1,changePrimaryDisplay:a1,changeAllColumnWidths:s1}}}},initialise$b=n1=>{const{definition:e1,columns:t1,stickyColumn:r1,enrichedSchema:o1}=n1;o1.subscribe(i1=>{if(!i1){t1.set([]),r1.set(null);return}const a1=get_store_value(e1),s1=get_store_value(t1),l1=get_store_value(r1);let c1=s1||[];l1&&c1.push(l1);let u1;const f1=a1.primaryDisplay||(l1==null?void 0:l1.name);f1&&i1[f1]&&(u1=f1);let d1=[];if(Object.keys(i1).forEach(_1=>{_1!==u1&&d1.push(_1)}),t1.set(d1.map(_1=>{const h1=i1[_1],g1=c1==null?void 0:c1.find($1=>$1.name===_1);return{name:_1,label:h1.displayName||_1,schema:h1,width:h1.width||(g1==null?void 0:g1.width)||DefaultColumnWidth,visible:h1.visible??!0,order:h1.order??(g1==null?void 0:g1.order)}}).sort((_1,h1)=>{var S1,O1;const g1=_1.order,$1=h1.order;if(g1!=null&&$1!=null)return g1<$1?-1:1;if(g1!=null)return-1;if($1!=null)return 1;const y1=(S1=_1.schema)==null?void 0:S1.autocolumn,v1=(O1=h1.schema)==null?void 0:O1.autocolumn;return y1===v1?0:y1?1:-1})),!u1){r1.set(null);return}const p1=i1[u1],m1=c1==null?void 0:c1.find(_1=>_1.name===u1);r1.set({name:u1,label:p1.displayName||u1,schema:p1,width:p1.width||(m1==null?void 0:m1.width)||DefaultColumnWidth,visible:!0,order:0,left:GutterWidth})})},Columns=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$d,createStores:createStores$e,deriveStores:deriveStores$7,initialise:initialise$b},Symbol.toStringTag,{value:"Module"})),createStores$d=()=>({menu:writable({x:0,y:0,visible:!1,selectedRow:null})}),createActions$c=n1=>{const{menu:e1,focusedCellId:t1,rand:r1}=n1;return{menu:{...e1,actions:{open:(a1,s1)=>{var d1;s1.preventDefault();const l1=document.getElementById(`grid-${r1}`),c1=(d1=l1==null?void 0:l1.getElementsByClassName("grid-data-outer"))==null?void 0:d1[0];if(!c1)return;const u1=s1.target.getBoundingClientRect(),f1=c1.getBoundingClientRect();t1.set(a1),e1.set({left:u1.left-f1.left+s1.offsetX,top:u1.top-f1.top+s1.offsetY,visible:!0})},close:()=>{e1.update(a1=>({...a1,visible:!1}))}}}}},Menu=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$c,createStores:createStores$d},Symbol.toStringTag,{value:"Module"})),initialise$a=n1=>{const{scrolledRowCount:e1,rows:t1,visualRowCapacity:r1}=n1,o1=derived(t1,a1=>a1.length,0);derived([e1,o1,r1],([a1,s1,l1])=>Math.max(0,s1-a1-l1)).subscribe(a1=>{a1<25&&get_store_value(o1)&&t1.actions.loadNextPage()})},Pagination=Object.freeze(Object.defineProperty({__proto__:null,initialise:initialise$a},Symbol.toStringTag,{value:"Module"})),reorderInitialState={sourceColumn:null,targetColumn:null,breakpoints:[],gridLeft:0,width:0,latestX:0,increment:0},createStores$c=()=>{const n1=writable(reorderInitialState),e1=derived(n1,t1=>!!t1.sourceColumn,!1);return{reorder:n1,isReordering:e1}},createActions$b=n1=>{const{reorder:e1,columns:t1,visibleColumns:r1,scroll:o1,bounds:i1,stickyColumn:a1,ui:s1,maxScrollLeft:l1}=n1;let c1,u1;const f1=(v1,S1)=>{const O1=get_store_value(r1),C1=get_store_value(i1),M1=get_store_value(a1);s1.actions.blur();let z1=O1.map(P1=>({x:P1.left+P1.width,column:P1.name}));M1&&z1.unshift({x:0,column:M1.name}),e1.set({sourceColumn:v1,targetColumn:null,breakpoints:z1,gridLeft:C1.left,width:C1.width}),document.addEventListener("mousemove",d1),document.addEventListener("mouseup",h1),d1(S1)},d1=v1=>{const S1=v1.clientX;e1.update(R1=>({...R1,latestX:S1})),p1();const O1=get_store_value(e1),C1=140,M1=8,z1=Math.max(0,O1.gridLeft+O1.width-S1),P1=Math.max(0,S1-O1.gridLeft);if(z1<C1){const N1=(C1-z1)/C1*M1;e1.update(F1=>({...F1,increment:N1})),m1()}else if(P1<C1){const N1=-1*(C1-P1)/C1*M1;e1.update(F1=>({...F1,increment:N1})),m1()}else _1()},p1=()=>{const v1=get_store_value(e1),S1=get_store_value(o1);let O1,C1=Number.MAX_SAFE_INTEGER;const M1=v1.latestX-v1.gridLeft+S1.left;v1.breakpoints.forEach(z1=>{const P1=Math.abs(z1.x-M1);P1<C1&&(C1=P1,O1=z1.column)}),O1!==v1.targetColumn&&e1.update(z1=>({...z1,targetColumn:O1}))},m1=()=>{u1||(u1=!0,c1=setInterval(()=>{const v1=get_store_value(l1),{increment:S1}=get_store_value(e1);o1.update(O1=>({...O1,left:Math.max(0,Math.min(v1,O1.left+S1))})),p1()},10))},_1=()=>{u1=!1,clearInterval(c1)},h1=async()=>{_1();let{sourceColumn:v1,targetColumn:S1}=get_store_value(e1);g1(v1,S1),e1.set(reorderInitialState),document.removeEventListener("mousemove",d1),document.removeEventListener("mouseup",h1),await t1.actions.saveChanges()},g1=(v1,S1)=>{let O1=get_store_value(t1),C1=O1.findIndex(z1=>z1.name===v1),M1=O1.findIndex(z1=>z1.name===S1);M1++,t1.update(z1=>{const P1=z1.splice(C1,1);return--M1<C1&&M1++,z1.splice(M1,0,P1[0]),z1.slice()})};return{reorder:{...e1,actions:{startReordering:f1,stopReordering:h1,moveColumnLeft:async v1=>{var C1;const S1=get_store_value(r1),O1=S1.findIndex(M1=>M1.name===v1);g1(v1,(C1=S1[O1-2])==null?void 0:C1.name),await t1.actions.saveChanges()},moveColumnRight:async v1=>{var C1;const S1=get_store_value(r1),O1=S1.findIndex(M1=>M1.name===v1);O1!==S1.length-1&&(g1(v1,(C1=S1[O1+1])==null?void 0:C1.name),await t1.actions.saveChanges())}}}}},Reorder=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$b,createStores:createStores$c},Symbol.toStringTag,{value:"Module"})),initialState$2={initialMouseX:null,initialWidth:null,column:null,columnIdx:null,width:0,left:0},createStores$b=()=>{const n1=writable(initialState$2),e1=derived(n1,t1=>t1.column!=null,!1);return{resize:n1,isResizing:e1}},createActions$a=n1=>{const{resize:e1,columns:t1,stickyColumn:r1,ui:o1}=n1,i1=(c1,u1)=>{u1.stopPropagation(),o1.actions.blur();let f1=get_store_value(t1).findIndex(d1=>d1.name===c1.name);f1===-1&&(f1="sticky"),e1.set({width:c1.width,left:c1.left,initialWidth:c1.width,initialMouseX:u1.clientX,column:c1.name,columnIdx:f1}),document.addEventListener("mousemove",a1),document.addEventListener("mouseup",s1)},a1=c1=>{const{initialMouseX:u1,initialWidth:f1,width:d1,columnIdx:p1}=get_store_value(e1),m1=c1.clientX-u1,_1=Math.round(Math.max(MinColumnWidth,f1+m1));Math.abs(d1-_1)<5||(p1==="sticky"?r1.update(h1=>({...h1,width:_1})):t1.update(h1=>(h1[p1].width=_1,[...h1])),e1.update(h1=>({...h1,width:_1})))},s1=async()=>{const c1=get_store_value(e1);e1.set(initialState$2),document.removeEventListener("mousemove",a1),document.removeEventListener("mouseup",s1),c1.width!==c1.initialWidth&&await t1.actions.saveChanges()};return{resize:{...e1,actions:{startResizing:i1,resetSize:async c1=>{const u1=get_store_value(r1);c1.name===(u1==null?void 0:u1.name)?r1.update(f1=>({...f1,width:DefaultColumnWidth})):t1.update(f1=>{const d1=f1.findIndex(p1=>p1.name===c1.name);return f1[d1].width=DefaultColumnWidth,[...f1]}),await t1.actions.saveChanges()}}}}},Resize=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$a,createStores:createStores$b},Symbol.toStringTag,{value:"Module"})),createStores$a=()=>{const n1=writable([]),e1=writable(!1),t1=writable(!1),r1=writable(!1),o1=writable({}),i1=writable({}),a1=writable(!1),s1=writable(null),l1=writable(null),c1=derived(n1,d1=>{let p1={};for(let m1=0;m1<d1.length;m1++)p1[d1[m1]._id]=m1;return p1});let u1=!1;e1.subscribe(d1=>{d1?u1=!0:u1&&t1.set(!0)});const f1=derived([n1,o1],([d1,p1])=>d1.map((m1,_1)=>({...m1,...p1[m1._id],__idx:_1})));return{rows:{...n1,subscribe:f1.subscribe},fetch:l1,rowLookupMap:c1,loaded:t1,refreshing:r1,loading:e1,rowChangeCache:o1,inProgressChanges:i1,hasNextPage:a1,error:s1}},createActions$9=n1=>{const{rows:e1,rowLookupMap:t1,definition:r1,allFilters:o1,loading:i1,sort:a1,datasource:s1,API:l1,scroll:c1,validation:u1,focusedCellId:f1,columns:d1,rowChangeCache:p1,inProgressChanges:m1,hasNextPage:_1,error:h1,notifications:g1,fetch:$1,isDatasourcePlus:y1,refreshing:v1}=n1,S1=writable(!1);let O1={},C1=null,M1=null;s1.subscribe(async n0=>{if(C1==null||C1(),C1=null,$1.set(null),S1.set(!1),i1.set(!0),!s1.actions.isDatasourceValid(n0)){h1.set("Datasource is invalid");return}await tick();const s0=get_store_value(o1),l0=get_store_value(a1),f0=fetchData({API:l1,datasource:n0,options:{filter:s0,sortColumn:l0.column,sortOrder:l0.order,limit:RowPageSize,paginate:!0,clientSideLimiting:!1}});C1=f0.subscribe(async e0=>{if(e0.error){let h0="An unknown error occurred";e0.error.status===403?h0="You don't have access to this data":e0.error.message&&(h0=e0.error.message),h1.set(h0)}else if(e0.loaded&&!e0.loading){h1.set(null),_1.set(e0.hasNextPage);const h0=get_store_value(S1),F0=e0.resetKey!==M1,z0=M1;M1=e0.resetKey,!h0&&z0&&(e1.set([]),await tick()),(!h0||F0)&&r1.set(e0.definition),h0?F0&&c1.update(T0=>({...T0,top:0})):(S1.set(!0),c1.set({top:0,left:0})),G1(e0.rows,F0),i1.set(!1)}v1.set(e0.loading)}),$1.set(f0)});const z1=n0=>{const s0=get_store_value(t1)[n0];return s0>=0?get_store_value(e1)[s0]:null},P1=(n0,s0)=>{var l0;if((l0=s0==null?void 0:s0.json)!=null&&l0.validationErrors){const f0=Object.keys(s0.json.validationErrors),e0=get_store_value(d1);let h0=[],F0=[];for(let z0 of f0)s1.actions.canUseColumn(z0)?h0.push(z0):F0.push(z0);for(let z0 of h0){u1.actions.setError(`${n0}-${z0}`,`${z0} ${s0.json.validationErrors[z0]}`);const T0=e0.findIndex(V0=>V0.name===z0);T0!==-1&&!e0[T0].visible&&d1.update(V0=>(V0[T0].visible=!0,V0.slice()))}for(let z0 of F0)get_store_value(g1).error(`${z0} is required but is missing`);h0.length&&f1.set(`${n0}-${h0[0]}`)}else get_store_value(g1).error((s0==null?void 0:s0.message)||"An unknown error occurred")},R1=async(n0,s0,l0=!1)=>{try{let f0={...n0};return f0=await s1.actions.addRow(f0),s0!=null?(O1[f0._id]=!0,e1.update(e0=>(e0.splice(s0,0,f0),e0.slice()))):G1([f0]),get_store_value(g1).success("Row created successfully"),f0}catch(f0){if(l0)throw f0;P1(NewRowID,f0)}},N1=async n0=>{let s0={...n0};delete s0._id,delete s0._rev,delete s0.__idx;try{return await R1(s0,n0.__idx+1,!0)}catch(l0){P1(n0._id,l0)}},F1=(n0,s0)=>{const l0=get_store_value(e1),e0=get_store_value(t1)[n0];s0?e0!=null?e1.update(h0=>(h0[e0]={...s0},h0)):G1([s0]):e0!=null&&Z1([l0[e0]])},B1=async n0=>{try{const s0=await s1.actions.getRow(n0);F1(n0,s0)}catch{}},L1=()=>{var n0;(n0=get_store_value($1))==null||n0.getInitialData()},U1=async(n0,s0,l0={save:!0})=>{const f0=get_store_value(e1),h0=get_store_value(t1)[n0],F0=f0[h0];if(h0==null||!Object.keys(s0||{}).length)return;let z0=!0;for(let T0 of Object.keys(s0))if(F0[T0]!==s0[T0]){z0=!1;break}if(!z0&&(p1.update(T0=>({...T0,[n0]:{...T0[n0],...s0}})),!!(l0!=null&&l0.save))){try{m1.update(V0=>({...V0,[n0]:!0}));const T0=await s1.actions.updateRow({...W1(F0),...get_store_value(p1)[n0]});T0!=null&&T0._id?e1.update(V0=>(V0[h0]=T0,V0.slice())):T0!=null&&T0.id&&await B1(T0.id),p1.update(V0=>(delete V0[n0],V0))}catch(T0){P1(n0,T0)}m1.update(T0=>({...T0,[n0]:!1}))}},j1=async({rowId:n0,column:s0,value:l0,save:f0=!0})=>await U1(n0,{[s0]:l0},{save:f0}),Q1=async n0=>{n0!=null&&n0.length&&(n0.forEach(s0=>{delete s0.__idx}),await s1.actions.deleteRows(n0),Z1(n0))},G1=(n0,s0)=>{s0&&(O1={});let l0=[],f0;const e0=get_store_value(y1);for(let h0=0;h0<n0.length;h0++)f0=n0[h0],e0||(f0._id=uuid()),O1[f0._id]||(O1[f0._id]=!0,l0.push(f0));s0?e1.set(l0):l0.length&&e1.update(h0=>[...h0,...l0])},Z1=n0=>{const s0=n0.map(l0=>l0._id);e1.update(l0=>l0.filter(f0=>!s0.includes(f0._id)))},t0=()=>{var n0;(n0=get_store_value($1))==null||n0.nextPage()},X1=n0=>n0===NewRowID?!0:get_store_value(t1)[n0]!=null,W1=n0=>{let s0={...n0};return delete s0.__idx,get_store_value(y1)||delete s0._id,s0};return{rows:{...e1,actions:{addRow:R1,duplicateRow:N1,getRow:z1,updateValue:j1,updateRow:U1,deleteRows:Q1,hasRow:X1,loadNextPage:t0,refreshRow:B1,replaceRow:F1,refreshData:L1,cleanRow:W1}}}},initialise$9=n1=>{const{rowChangeCache:e1,inProgressChanges:t1,previousFocusedRowId:r1}=n1;r1.subscribe(o1=>{o1&&!get_store_value(t1)[o1]&&e1.update(i1=>(delete i1[o1],i1))})},Rows=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$9,createStores:createStores$a,initialise:initialise$9},Symbol.toStringTag,{value:"Module"})),createStores$9=()=>{const n1=writable({left:0,top:0}),e1=derived(n1,r1=>r1.top,0),t1=derived(n1,r1=>r1.left,0);return{scroll:n1,scrollTop:e1,scrollLeft:t1}},deriveStores$6=n1=>{const{rows:e1,visibleColumns:t1,stickyColumn:r1,rowHeight:o1,width:i1,height:a1,buttonColumnWidth:s1}=n1,l1=derived(r1,h1=>(h1==null?void 0:h1.width)||0,0),c1=derived([e1,o1],([h1,g1])=>(h1.length+1)*g1+Padding,0),u1=derived([a1,c1],([h1,g1])=>Math.max(g1-h1,0),0),f1=derived([t1,l1,s1],([h1,g1,$1])=>{const y1=Math.max(Padding,$1-1);let v1=GutterWidth+y1+g1;return h1.forEach(S1=>{v1+=S1.width}),v1},0),d1=derived([i1,l1],([h1,g1])=>h1+GutterWidth+g1,0),p1=derived([f1,d1],([h1,g1])=>Math.max(h1-g1,0),0),m1=derived([c1,a1],([h1,g1])=>h1>g1),_1=derived([f1,d1],([h1,g1])=>h1>g1);return{contentHeight:c1,contentWidth:f1,screenWidth:d1,maxScrollTop:u1,maxScrollLeft:p1,showHScrollbar:_1,showVScrollbar:m1}},initialise$8=n1=>{const{focusedCellId:e1,focusedRow:t1,scroll:r1,bounds:o1,rowHeight:i1,visibleColumns:a1,scrollTop:s1,maxScrollTop:l1,scrollLeft:c1,maxScrollLeft:u1}=n1,f1=derived([s1,l1],([p1,m1])=>p1>m1,!1),d1=derived([c1,u1],([p1,m1])=>p1>m1,!1);f1.subscribe(p1=>{p1&&r1.update(m1=>({...m1,top:get_store_value(l1)}))}),d1.subscribe(p1=>{p1&&r1.update(m1=>({...m1,left:get_store_value(u1)}))}),e1.subscribe(async p1=>{await tick();const m1=get_store_value(t1),_1=get_store_value(r1),h1=get_store_value(o1),g1=get_store_value(i1);if(m1){const O1=m1.__idx*g1,C1=_1.top+h1.height-g1-FocusedCellMinOffset;let M1=O1-C1;if(M1>0)r1.update(z1=>({...z1,top:z1.top+M1}));else{const z1=_1.top-O1+FocusedCellMinOffset;z1>0&&r1.update(P1=>({...P1,top:Math.max(0,P1.top-z1)}))}}const $1=get_store_value(a1),y1=p1==null?void 0:p1.split("-")[1],v1=$1.find(O1=>O1.name===y1);if(!v1)return;let S1=_1.left-v1.left+FocusedCellMinOffset;if(S1>0)r1.update(O1=>({...O1,left:Math.max(0,O1.left-S1)}));else{const O1=v1.left+v1.width,C1=h1.width+_1.left-FocusedCellMinOffset;S1=O1-C1,S1>0&&r1.update(M1=>({...M1,left:M1.left+S1}))}})},Scroll=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$9,deriveStores:deriveStores$6,initialise:initialise$8},Symbol.toStringTag,{value:"Module"})),createStores$8=n1=>{const{props:e1}=n1,t1=writable(null),r1=writable(null),o1=writable({}),i1=writable(null),a1=writable(get_store_value(e1).fixedRowHeight||DefaultRowHeight),s1=writable(null),l1=writable(!1),c1=writable(!1),u1=writable(0),f1=derived(t1,p1=>p1==null?void 0:p1.split("-")[0],null);return{focusedCellId:t1,focusedCellAPI:r1,focusedRowId:f1,previousFocusedRowId:s1,hoveredRowId:i1,rowHeight:a1,gridFocused:l1,isDragging:c1,buttonColumnWidth:u1,selectedRows:{...o1,actions:{toggleRow:p1=>{o1.update(m1=>{let _1={...m1,[p1]:!m1[p1]};return _1[p1]||delete _1[p1],_1})}}}}},deriveStores$5=n1=>{const{focusedCellId:e1,rows:t1,rowLookupMap:r1,rowHeight:o1,stickyColumn:i1,width:a1}=n1,s1=derived([e1,r1,t1],([u1,f1,d1])=>{const p1=u1==null?void 0:u1.split("-")[0];if(p1===NewRowID)return{_id:NewRowID};const m1=f1[p1];return d1[m1]},null),l1=derived(o1,u1=>u1>=LargeRowHeight?3:u1>=MediumRowHeight?2:1),c1=derived([i1,a1],([u1,f1])=>((u1==null?void 0:u1.width)||0)+f1+GutterWidth<1100);return{focusedRow:s1,contentLines:l1,compact:c1}},createActions$8=n1=>{const{focusedCellId:e1,selectedRows:t1,hoveredRowId:r1}=n1;return{ui:{actions:{blur:()=>{e1.set(null),t1.set({}),r1.set(null)}}}}},initialise$7=n1=>{const{focusedRowId:e1,previousFocusedRowId:t1,rows:r1,focusedCellId:o1,selectedRows:i1,hoveredRowId:a1,definition:s1,rowHeight:l1,fixedRowHeight:c1}=n1;r1.subscribe(async()=>{await tick();const f1=get_store_value(o1),d1=get_store_value(i1),p1=get_store_value(a1),m1=r1.actions.hasRow,_1=f1==null?void 0:f1.split("-")[0];_1&&!m1(_1)&&o1.set(null),p1&&!m1(p1)&&a1.set(null);let h1={...d1},g1=!1;const $1=Object.keys(d1);for(let y1=0;y1<$1.length;y1++)m1($1[y1])||(delete h1[$1[y1]],g1=!0);g1&&i1.set(h1)});let u1=null;e1.subscribe(f1=>{t1.set(u1),u1=f1}),o1.subscribe(f1=>{f1&&get_store_value(a1)&&a1.set(null)}),s1.subscribe(f1=>{get_store_value(c1)||l1.set((f1==null?void 0:f1.rowHeight)||DefaultRowHeight)}),c1.subscribe(f1=>{var d1;f1?l1.set(f1):l1.set(((d1=get_store_value(s1))==null?void 0:d1.rowHeight)||DefaultRowHeight)})},UI=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$8,createStores:createStores$8,deriveStores:deriveStores$5,initialise:initialise$7},Symbol.toStringTag,{value:"Module"})),createStores$7=()=>{const n1=writable([]),e1=derived(n1,t1=>t1.map(r1=>({...r1,color:getUserColor(r1),label:getUserLabel(r1)})));return{users:{...n1,subscribe:e1.subscribe}}},deriveStores$4=n1=>{const{users:e1,focusedCellId:t1}=n1;return{selectedCellMap:derived([e1,t1],([o1,i1])=>{let a1={};return o1.forEach(s1=>{var c1;const l1=(c1=s1.gridMetadata)==null?void 0:c1.focusedCellId;l1&&l1!==i1&&(a1[l1]=s1)}),a1})}},createActions$7=n1=>{const{users:e1}=n1;return{users:{...e1,actions:{updateUser:o1=>{const i1=get_store_value(e1);i1.some(a1=>a1.sessionId===o1.sessionId)?e1.update(a1=>{const s1=a1.findIndex(l1=>l1.sessionId===o1.sessionId);return a1[s1]=o1,a1.slice()}):e1.set([...i1,o1])},removeUser:o1=>{e1.update(i1=>i1.filter(a1=>a1.sessionId!==o1))}}}}},Users$2=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$7,createStores:createStores$7,deriveStores:deriveStores$4},Symbol.toStringTag,{value:"Module"})),createStores$6=()=>{const n1=writable({});return{validation:{...n1,actions:{setError:(t1,r1)=>{t1&&n1.update(o1=>({...o1,[t1]:r1}))}}}}},initialise$6=n1=>{const{validation:e1,previousFocusedRowId:t1,columns:r1,stickyColumn:o1}=n1;t1.subscribe(i1=>{if(i1){const a1=get_store_value(r1),s1=get_store_value(o1);e1.update(l1=>(a1.forEach(c1=>{l1[`${i1}-${c1.name}`]=null}),s1&&(l1[`${i1}-${s1.name}`]=null),l1))}})},Validation=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$6,initialise:initialise$6},Symbol.toStringTag,{value:"Module"})),deriveStores$3=n1=>{const{rowHeight:e1,visibleColumns:t1,rows:r1,scrollTop:o1,scrollLeft:i1,width:a1,height:s1}=n1,l1=derived([o1,e1],([_1,h1])=>Math.floor(_1/h1),0),c1=derived([s1,e1],([_1,h1])=>Math.ceil(_1/h1)+1,0),u1=derived([r1,l1,c1],([_1,h1,g1])=>_1.slice(h1,h1+g1),[]),f1=derived(i1,_1=>{const h1=MinColumnWidth;return Math.round(_1/h1)*h1}),d1=derived([t1,f1,a1],([_1,h1,g1])=>{if(!_1.length)return{};let $1=0,y1=_1[0].width;for(;y1<h1&&$1<_1.length-1;)$1++,y1+=_1[$1].width;let v1=$1+1,S1=y1;for(;S1<g1+h1&&v1<_1.length;)S1+=_1[v1].width,v1++;let O1={};return _1.slice(Math.max(0,$1),v1).forEach(C1=>{O1[C1.name]=!0}),O1}),p1=derived([s1,e1,o1],([_1,h1,g1])=>{const $1=g1%h1,y1=_1-ScrollBarSize*3-MaxCellRenderHeight+$1,v1=Math.floor(y1/h1),S1=MaxCellRenderHeight+$1,O1=Math.ceil(S1/h1);return Math.max(v1,O1)}),m1=derived([t1,i1,a1],([_1,h1,g1])=>{const $1=g1+h1-ScrollBarSize*3;let y1=_1.length;for(let v1=_1.length-1;v1>=0&&!(_1[v1].left+_1[v1].width+MaxCellRenderWidthOverflow<=$1);v1--,y1--);return y1});return{scrolledRowCount:l1,visualRowCapacity:c1,renderedRows:u1,columnRenderMap:d1,rowVerticalInversionIndex:p1,columnHorizontalInversionIndex:m1}},Viewport$1=Object.freeze(Object.defineProperty({__proto__:null,deriveStores:deriveStores$3},Symbol.toStringTag,{value:"Module"})),createStores$5=()=>({copiedCell:writable(null)}),createActions$6=n1=>{const{copiedCell:e1,focusedCellAPI:t1}=n1;return{clipboard:{actions:{copy:()=>{var s1;const i1=(s1=get_store_value(t1))==null?void 0:s1.getValue();e1.set(i1);let a1="";i1!=null&&i1!==""&&(a1=typeof i1=="object"?JSON.stringify(i1):i1),copyToClipboard(a1)},paste:()=>{const i1=get_store_value(e1),a1=get_store_value(t1);i1!=null&&a1&&a1.setValue(i1)}}}}},Clipboard=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$6,createStores:createStores$5},Symbol.toStringTag,{value:"Module"})),createStores$4=n1=>{const{props:e1}=n1,t1=d1=>derivedMemo(e1,p1=>p1[d1]),r1=t1("datasource"),o1=t1("initialSortColumn"),i1=t1("initialSortOrder"),a1=t1("initialFilter"),s1=t1("fixedRowHeight"),l1=t1("schemaOverrides"),c1=t1("columnWhitelist"),u1=t1("notifySuccess"),f1=t1("notifyError");return{datasource:r1,initialSortColumn:o1,initialSortOrder:i1,initialFilter:a1,fixedRowHeight:s1,schemaOverrides:l1,columnWhitelist:c1,notifySuccess:u1,notifyError:f1}},deriveStores$2=n1=>{const{props:e1,hasNonAutoColumn:t1}=n1;return{config:derived([e1,t1],([o1,i1])=>{var l1;let a1={...o1};const s1=(l1=o1.datasource)==null?void 0:l1.type;return s1==="viewV2"&&(a1.canEditColumns=!1),i1||(a1.canAddRows=!1),["table","viewV2"].includes(s1)||(a1.canAddRows=!1,a1.canEditRows=!1,a1.canDeleteRows=!1,a1.canExpandRows=!1,a1.canSaveSchema=!1,a1.canEditColumns=!1),a1})}},Config=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$4,deriveStores:deriveStores$2},Symbol.toStringTag,{value:"Module"})),createStores$3=n1=>{const{props:e1}=n1,t1=get_store_value(e1);return{sort:memo({column:t1.initialSortColumn,order:t1.initialSortOrder||"ascending"})}},initialise$5=n1=>{const{sort:e1,initialSortColumn:t1,initialSortOrder:r1,schema:o1}=n1;t1.subscribe(a1=>{e1.update(s1=>({...s1,column:a1}))}),r1.subscribe(a1=>{e1.update(s1=>({...s1,order:a1||"ascending"}))}),derived([e1,o1],([a1,s1])=>!(a1!=null&&a1.column)||!s1?!0:s1[a1.column]!=null).subscribe(a1=>{a1||e1.set({column:null,order:"ascending"})})},Sort=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$3,initialise:initialise$5},Symbol.toStringTag,{value:"Module"})),createStores$2=n1=>{const{props:e1}=n1,t1=writable(get_store_value(e1).initialFilter),r1=writable([]);return{filter:t1,inlineFilters:r1}},deriveStores$1=n1=>{const{filter:e1,inlineFilters:t1}=n1;return{allFilters:derived([e1,t1],([o1,i1])=>[...o1||[],...i1])}},createActions$5=n1=>{const{filter:e1,inlineFilters:t1}=n1;return{filter:{...e1,actions:{addInlineFilter:(o1,i1)=>{const a1=`inline-${o1.name}`,s1=o1.schema.type;let l1={field:o1.name,id:a1,operator:"string",valueType:"value",type:s1,value:i1};s1===FieldType.NUMBER?(l1.value=parseFloat(i1),l1.operator="equal"):s1===FieldType.BIGINT?l1.operator="equal":s1===FieldType.ARRAY&&(l1.operator="contains"),t1.update(c1=>(c1=c1==null?void 0:c1.filter(u1=>u1.id!==a1),i1&&c1.push(l1),c1))}}}}},initialise$4=n1=>{const{filter:e1,initialFilter:t1}=n1;t1.subscribe(e1.set)},Filter=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$5,createStores:createStores$2,deriveStores:deriveStores$1,initialise:initialise$4},Symbol.toStringTag,{value:"Module"})),createStores$1=n1=>{const{notifySuccess:e1,notifyError:t1}=n1;return{notifications:derived([e1,t1],([o1,i1])=>({success:o1||notifications.success,error:i1||notifications.error}))}},Notifications=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$1},Symbol.toStringTag,{value:"Module"})),createStores=()=>({definition:memo(null)}),deriveStores=n1=>{const{API:e1,definition:t1,schemaOverrides:r1,columnWhitelist:o1,datasource:i1}=n1,a1=derived(t1,c1=>{let u1=getDatasourceSchema({API:e1,datasource:get_store_value(i1),definition:c1});return u1?(Object.keys(u1||{}).forEach(f1=>{typeof u1[f1]!="object"&&(u1[f1]={type:u1[f1]})}),u1):null}),s1=derived([a1,r1,o1],([c1,u1,f1])=>{if(!c1)return null;let d1={...c1};if(Object.keys(u1||{}).forEach(p1=>{d1[p1]&&(d1[p1]={...d1[p1],...u1[p1]})}),f1!=null&&f1.length){const p1={};return f1.forEach((m1,_1)=>{const h1=d1[m1];h1&&(p1[m1]={...h1,order:_1,visible:!0})}),p1}return d1}),l1=derived(i1,c1=>["table","viewV2"].includes(c1==null?void 0:c1.type));return{schema:a1,enrichedSchema:s1,isDatasourcePlus:l1}},createActions$4=n1=>{const{API:e1,datasource:t1,definition:r1,config:o1,dispatch:i1,table:a1,viewV2:s1,nonPlus:l1}=n1,c1=()=>{const $1=get_store_value(t1),y1=$1==null?void 0:$1.type;if(!y1)return null;switch(y1){case"table":return a1;case"viewV2":return s1;default:return l1}};return{datasource:{...t1,actions:{refreshDefinition:async()=>{const $1=await getDatasourceDefinition({API:e1,datasource:get_store_value(t1)});r1.set($1)},saveDefinition:async $1=>{var y1;r1.set($1),get_store_value(o1).canSaveSchema&&await((y1=c1())==null?void 0:y1.actions.saveDefinition($1)),i1("updatedatasource",$1)},addRow:async $1=>{var y1;return await((y1=c1())==null?void 0:y1.actions.addRow($1))},updateRow:async $1=>{var y1;return await((y1=c1())==null?void 0:y1.actions.updateRow($1))},deleteRows:async $1=>{var y1;return await((y1=c1())==null?void 0:y1.actions.deleteRows($1))},getRow:async $1=>{var y1;return await((y1=c1())==null?void 0:y1.actions.getRow($1))},isDatasourceValid:$1=>{var y1;return(y1=c1())==null?void 0:y1.actions.isDatasourceValid($1)},canUseColumn:$1=>{var y1;return(y1=c1())==null?void 0:y1.actions.canUseColumn($1)}}}}},Datasource$1=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$4,createStores,deriveStores},Symbol.toStringTag,{value:"Module"})),SuppressErrors$1=!0,createActions$3=n1=>{const{API:e1,datasource:t1,columns:r1,stickyColumn:o1}=n1,i1=async f1=>{await e1.saveTable(f1)},a1=async f1=>{var d1;return f1.tableId=(d1=get_store_value(t1))==null?void 0:d1.tableId,await e1.saveRow(f1,SuppressErrors$1)};return{table:{actions:{saveDefinition:i1,addRow:a1,updateRow:a1,deleteRows:async f1=>{await e1.deleteRows({tableId:get_store_value(t1).tableId,rows:f1})},getRow:async f1=>{var p1;const d1=await e1.searchTable({tableId:get_store_value(t1).tableId,limit:1,query:{equal:{_id:f1}},paginate:!1});return(p1=d1==null?void 0:d1.rows)==null?void 0:p1[0]},isDatasourceValid:f1=>(f1==null?void 0:f1.type)==="table"&&(f1==null?void 0:f1.tableId),canUseColumn:f1=>{const d1=get_store_value(r1),p1=get_store_value(o1);return d1.some(m1=>m1.name===f1)||(p1==null?void 0:p1.name)===f1}}}}},initialise$3=n1=>{const{datasource:e1,fetch:t1,filter:r1,inlineFilters:o1,allFilters:i1,sort:a1,table:s1,initialFilter:l1,initialSortColumn:c1,initialSortOrder:u1}=n1;let f1=[];e1.subscribe(d1=>{f1==null||f1.forEach(p1=>p1()),f1=[],s1.actions.isDatasourceValid(d1)&&(r1.set(get_store_value(l1)),o1.set([]),a1.set({column:get_store_value(c1),order:get_store_value(u1)||"ascending"}),f1.push(i1.subscribe(p1=>{var _1,h1;const m1=get_store_value(t1);((h1=(_1=m1==null?void 0:m1.options)==null?void 0:_1.datasource)==null?void 0:h1.tableId)===d1.tableId&&m1.update({filter:p1})})),f1.push(a1.subscribe(p1=>{var _1,h1;const m1=get_store_value(t1);((h1=(_1=m1==null?void 0:m1.options)==null?void 0:_1.datasource)==null?void 0:h1.tableId)===d1.tableId&&m1.update({sortOrder:p1.order||"ascending",sortColumn:p1.column})})))})},Table$1=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$3,initialise:initialise$3},Symbol.toStringTag,{value:"Module"})),SuppressErrors=!0,createActions$2=n1=>{const{API:e1,datasource:t1,columns:r1,stickyColumn:o1}=n1,i1=async f1=>{await e1.viewV2.update(f1)},a1=async f1=>{const d1=get_store_value(t1);return f1.tableId=d1==null?void 0:d1.tableId,f1._viewId=d1==null?void 0:d1.id,{...await e1.saveRow(f1,SuppressErrors),_viewId:f1._viewId}};return{viewV2:{actions:{saveDefinition:i1,addRow:a1,updateRow:a1,deleteRows:async f1=>{await e1.deleteRows({tableId:get_store_value(t1).id,rows:f1})},getRow:()=>{throw"Views don't support fetching individual rows"},isDatasourceValid:f1=>(f1==null?void 0:f1.type)==="viewV2"&&(f1==null?void 0:f1.id)&&(f1==null?void 0:f1.tableId),canUseColumn:f1=>{const d1=get_store_value(r1),p1=get_store_value(o1);return d1.some(m1=>m1.name===f1&&m1.visible)||(p1==null?void 0:p1.name)===f1}}}}},initialise$2=n1=>{const{definition:e1,datasource:t1,sort:r1,rows:o1,filter:i1,inlineFilters:a1,allFilters:s1,subscribe:l1,viewV2:c1,initialFilter:u1,initialSortColumn:f1,initialSortOrder:d1,config:p1,fetch:m1}=n1;let _1=[];t1.subscribe(h1=>{_1==null||_1.forEach(g1=>g1()),_1=[],c1.actions.isDatasourceValid(h1)&&(i1.set(get_store_value(u1)),a1.set([]),r1.set({column:get_store_value(f1),order:get_store_value(d1)||"ascending"}),_1.push(e1.subscribe(g1=>{var $1,y1;(g1==null?void 0:g1.id)===h1.id&&(get_store_value(f1)||r1.set({column:($1=g1.sort)==null?void 0:$1.field,order:((y1=g1.sort)==null?void 0:y1.order)||"ascending"}),get_store_value(u1)||i1.set(g1.query))})),_1.push(r1.subscribe(async g1=>{var y1,v1,S1,O1;if(get_store_value(p1).canSaveSchema){const C1=get_store_value(e1);if((C1==null?void 0:C1.id)!==h1.id)return;((g1==null?void 0:g1.column)!==((y1=C1.sort)==null?void 0:y1.field)||(g1==null?void 0:g1.order)!==((v1=C1.sort)==null?void 0:v1.order))&&await t1.actions.saveDefinition({...C1,sort:{field:g1.column,order:g1.order||"ascending"}})}const $1=get_store_value(m1);((O1=(S1=$1==null?void 0:$1.options)==null?void 0:S1.datasource)==null?void 0:O1.tableId)===h1.tableId&&$1.update({sortOrder:g1.order,sortColumn:g1.column})})),_1==null||_1.push(i1.subscribe(async g1=>{if(get_store_value(p1).canSaveSchema){const $1=get_store_value(e1);if(($1==null?void 0:$1.id)!==h1.id)return;JSON.stringify(g1)!==JSON.stringify($1.query)&&await t1.actions.saveDefinition({...$1,query:g1})}})),_1.push(s1.subscribe(g1=>{var y1,v1;const $1=get_store_value(m1);((v1=(y1=$1==null?void 0:$1.options)==null?void 0:y1.datasource)==null?void 0:v1.tableId)===h1.tableId&&$1.update({filter:g1})})),_1.push(l1("show-column",async()=>{await o1.actions.refreshData()})))})},ViewV2=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$2,initialise:initialise$2},Symbol.toStringTag,{value:"Module"})),createActions$1=n1=>{const{columns:e1,stickyColumn:t1,table:r1,viewV2:o1}=n1,i1=async()=>{throw"This datasource does not support updating the definition"},a1=async()=>{throw"This datasource does not support saving rows"};return{nonPlus:{actions:{saveDefinition:i1,addRow:a1,updateRow:a1,deleteRows:async()=>{throw"This datasource does not support deleting rows"},getRow:()=>{throw"This datasource does not support fetching individual rows"},isDatasourceValid:f1=>!r1.actions.isDatasourceValid(f1)&&!o1.actions.isDatasourceValid(f1)&&(f1==null?void 0:f1.type)!=null,canUseColumn:f1=>{const d1=get_store_value(e1),p1=get_store_value(t1);return d1.some(m1=>m1.name===f1)||(p1==null?void 0:p1.name)===f1}}}}},isSameDatasource=(n1,e1)=>JSON.stringify(n1)===JSON.stringify(e1),initialise$1=n1=>{const{datasource:e1,sort:t1,filter:r1,inlineFilters:o1,allFilters:i1,nonPlus:a1,initialFilter:s1,initialSortColumn:l1,initialSortOrder:c1,fetch:u1}=n1;let f1=[];e1.subscribe(d1=>{f1==null||f1.forEach(p1=>p1()),f1=[],a1.actions.isDatasourceValid(d1)&&(r1.set(get_store_value(s1)),o1.set([]),t1.set({column:get_store_value(l1),order:get_store_value(c1)||"ascending"}),f1.push(i1.subscribe(p1=>{var _1;const m1=get_store_value(u1);isSameDatasource((_1=m1==null?void 0:m1.options)==null?void 0:_1.datasource,d1)&&m1.update({filter:p1})})),f1.push(t1.subscribe(p1=>{var _1;const m1=get_store_value(u1);isSameDatasource((_1=m1==null?void 0:m1.options)==null?void 0:_1.datasource,d1)&&m1.update({sortOrder:p1.order||"ascending",sortColumn:p1.column})})))})},NonPlus=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$1,initialise:initialise$1},Symbol.toStringTag,{value:"Module"})),createActions=n1=>{const{API:e1}=n1;let t1={};return{cache:{actions:{getPrimaryDisplayForTableId:async i1=>(t1[i1]||(t1[i1]=new Promise(a1=>{e1.fetchTableDefinition(i1).then(s1=>{var c1,u1;const l1=(s1==null?void 0:s1.primaryDisplay)||((u1=(c1=s1==null?void 0:s1.schema)==null?void 0:c1[0])==null?void 0:u1.name);t1[i1]=l1,a1(l1)})})),await t1[i1]),resetPrimaryDisplayCache:()=>{t1={}}}}}},initialise=n1=>{const{datasource:e1,cache:t1}=n1;e1.subscribe(t1.actions.resetPrimaryDisplayCache)},Cache$1=Object.freeze(Object.defineProperty({__proto__:null,createActions,initialise},Symbol.toStringTag,{value:"Module"})),DependencyOrderedStores=[Sort,Filter,Bounds,Scroll,Table$1,ViewV2,NonPlus,Datasource$1,Columns,Rows,UI,Validation,Resize,Viewport$1,Reorder,Users$2,Menu,Pagination,Clipboard,Config,Notifications,Cache$1],attachStores=n1=>{var e1,t1,r1,o1;for(let i1 of DependencyOrderedStores)n1={...n1,...(e1=i1.createStores)==null?void 0:e1.call(i1,n1)};for(let i1 of DependencyOrderedStores)n1={...n1,...(t1=i1.deriveStores)==null?void 0:t1.call(i1,n1)};for(let i1 of DependencyOrderedStores)n1={...n1,...(r1=i1.createActions)==null?void 0:r1.call(i1,n1)};for(let i1 of DependencyOrderedStores)(o1=i1.initialise)==null||o1.call(i1,n1);return n1};function create_default_slot_1$3H(n1){let e1,t1,r1,o1=n1[1]===1?"":"s",i1,a1;return{c(){e1=text("Are you sure you want to delete "),t1=text(n1[1]),r1=text(`
379
379
  row`),i1=text(o1),a1=text("?")},m(s1,l1){insert$1(s1,e1,l1),insert$1(s1,t1,l1),insert$1(s1,r1,l1),insert$1(s1,i1,l1),insert$1(s1,a1,l1)},p(s1,l1){l1&2&&set_data(t1,s1[1]),l1&2&&o1!==(o1=s1[1]===1?"":"s")&&set_data(i1,o1)},d(s1){s1&&detach(e1),s1&&detach(t1),s1&&detach(r1),s1&&detach(i1),s1&&detach(a1)}}}function create_default_slot$51(n1){let e1,t1;return e1=new ModalContent({props:{title:"Delete rows",confirmText:"Continue",cancelText:"Cancel",onConfirm:n1[5],size:"M",$$slots:{default:[create_default_slot_1$3H]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&4098&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$7V(n1){let e1,t1,r1={$$slots:{default:[create_default_slot$51]},$$scope:{ctx:n1}};return e1=new Modal({props:r1}),n1[8](e1),{c(){create_component(e1.$$.fragment)},m(o1,i1){mount_component(e1,o1,i1),t1=!0},p(o1,[i1]){const a1={};i1&4098&&(a1.$$scope={dirty:i1,ctx:o1}),e1.$set(a1)},i(o1){t1||(transition_in(e1.$$.fragment,o1),t1=!0)},o(o1){transition_out(e1.$$.fragment,o1),t1=!1},d(o1){n1[8](null),destroy_component(e1,o1)}}}function instance$84(n1,e1,t1){let r1,o1,i1,a1,s1;const{selectedRows:l1,rows:c1,subscribe:u1,notifications:f1}=getContext("grid");component_subscribe(n1,l1,_1=>t1(7,s1=_1)),component_subscribe(n1,c1,_1=>t1(6,a1=_1)),component_subscribe(n1,f1,_1=>t1(10,i1=_1));let d1;const p1=async()=>{const _1=o1.length;await c1.actions.deleteRows(o1),i1.success(`Deleted ${_1} row${_1===1?"":"s"}`)};onMount(()=>u1("request-bulk-delete",()=>d1==null?void 0:d1.show()));function m1(_1){binding_callbacks[_1?"unshift":"push"](()=>{d1=_1,t1(0,d1)})}return n1.$$.update=()=>{n1.$$.dirty&128&&t1(1,r1=Object.values(s1).length),n1.$$.dirty&192&&(o1=Object.entries(s1).map(_1=>a1.find(h1=>h1._id===_1[0])).filter(_1=>_1!=null))},[d1,r1,l1,c1,f1,p1,a1,s1,m1]}class BulkDeleteHandler extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$84,create_fragment$7V,safe_not_equal,{})}}const GridScrollWrapper_svelte_svelte_type_style_lang="";function create_fragment$7U(n1){let e1,t1,r1,o1,i1;const a1=n1[19].default,s1=create_slot(a1,n1,n1[18],null);return{c(){e1=element("div"),t1=element("div"),s1&&s1.c(),attr(t1,"style",n1[1]),attr(t1,"class","inner svelte-i68dpr"),attr(e1,"class","outer svelte-i68dpr")},m(l1,c1){insert$1(l1,e1,c1),append$1(e1,t1),s1&&s1.m(t1,null),r1=!0,o1||(i1=[listen(e1,"wheel",function(){is_function(n1[0]?n1[11]:null)&&(n1[0]?n1[11]:null).apply(this,arguments)}),listen(e1,"touchstart",function(){is_function(n1[0]?n1[12]:null)&&(n1[0]?n1[12]:null).apply(this,arguments)}),listen(e1,"touchmove",function(){is_function(n1[0]?n1[13]:null)&&(n1[0]?n1[13]:null).apply(this,arguments)}),listen(e1,"click",self$1(n1[20]))],o1=!0)},p(l1,[c1]){n1=l1,s1&&s1.p&&(!r1||c1&262144)&&update_slot_base(s1,a1,n1,n1[18],r1?get_slot_changes(a1,n1[18],c1,null):get_all_dirty_from_scope(n1[18]),null),(!r1||c1&2)&&attr(t1,"style",n1[1])},i(l1){r1||(transition_in(s1,l1),r1=!0)},o(l1){transition_out(s1,l1),r1=!1},d(l1){l1&&detach(e1),s1&&s1.d(l1),o1=!1,run_all(i1)}}}function instance$83(n1,e1,t1){let r1,o1,i1,a1,s1,l1,c1,u1,f1,{$$slots:d1={},$$scope:p1}=e1;const{rowHeight:m1,scroll:_1,focusedCellId:h1,renderedRows:g1,maxScrollTop:$1,maxScrollLeft:y1,bounds:v1,hoveredRowId:S1,menu:O1}=getContext("grid");component_subscribe(n1,m1,Q1=>t1(16,o1=Q1)),component_subscribe(n1,_1,Q1=>t1(17,c1=Q1)),component_subscribe(n1,h1,Q1=>t1(2,f1=Q1)),component_subscribe(n1,g1,Q1=>t1(23,i1=Q1)),component_subscribe(n1,$1,Q1=>t1(26,l1=Q1)),component_subscribe(n1,y1,Q1=>t1(25,s1=Q1)),component_subscribe(n1,v1,Q1=>t1(24,a1=Q1)),component_subscribe(n1,O1,Q1=>t1(27,u1=Q1));let{scrollVertically:C1=!1}=e1,{scrollHorizontally:M1=!1}=e1,{attachHandlers:z1=!1}=e1,P1,R1;const N1=(Q1,G1)=>{const Z1=M1?-1*Q1.left:0,t0=C1?-1*(Q1.top%G1):0;return`transform: translate3d(${Z1}px, ${t0}px, 0);`},F1=Q1=>{Q1.preventDefault(),U1(Q1.deltaX,Q1.deltaY,Q1.clientY),u1.visible&&O1.actions.close()},B1=Q1=>{var G1;(G1=Q1.touches)!=null&&G1[0]&&(P1=Q1.touches[0].clientX,R1=Q1.touches[0].clientY)},L1=Q1=>{var t0;if(!((t0=Q1.touches)!=null&&t0[0]))return;Q1.preventDefault();const G1=P1-Q1.touches[0].clientX,Z1=R1-Q1.touches[0].clientY;U1(G1,Z1),P1=Q1.touches[0].clientX,R1=Q1.touches[0].clientY,u1.visible&&O1.actions.close()},U1=domDebounce((Q1,G1,Z1)=>{const{top:t0,left:X1}=c1;let W1=t0+G1;W1=Math.max(0,Math.min(W1,l1));let n0=X1+Q1;if(n0=Math.max(0,Math.min(n0,s1)),_1.set({left:M1?n0:X1,top:C1?W1:t0}),Z1!=null){const s0=Z1-a1.top+W1%o1,l0=i1[Math.floor(s0/o1)];S1.set(l0==null?void 0:l0._id)}}),j1=()=>set_store_value(h1,f1=null,f1);return n1.$$set=Q1=>{"scrollVertically"in Q1&&t1(14,C1=Q1.scrollVertically),"scrollHorizontally"in Q1&&t1(15,M1=Q1.scrollHorizontally),"attachHandlers"in Q1&&t1(0,z1=Q1.attachHandlers),"$$scope"in Q1&&t1(18,p1=Q1.$$scope)},n1.$$.update=()=>{n1.$$.dirty&196608&&t1(1,r1=N1(c1,o1))},[z1,r1,f1,m1,_1,h1,g1,$1,y1,v1,O1,F1,B1,L1,C1,M1,o1,c1,p1,d1,j1]}class GridScrollWrapper extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$83,create_fragment$7U,safe_not_equal,{scrollVertically:14,scrollHorizontally:15,attachHandlers:0})}}const GridCell_svelte_svelte_type_style_lang="";function create_if_block_1$22(n1){let e1,t1;return{c(){e1=element("div"),t1=text(n1[4]),attr(e1,"class","label svelte-xqyo1h")},m(r1,o1){insert$1(r1,e1,o1),append$1(e1,t1)},p(r1,o1){o1&16&&set_data(t1,r1[4])},d(r1){r1&&detach(e1)}}}function create_if_block$3F(n1){let e1,t1=n1[3].label+"",r1;return{c(){e1=element("div"),r1=text(t1),attr(e1,"class","label svelte-xqyo1h")},m(o1,i1){insert$1(o1,e1,i1),append$1(e1,r1)},p(o1,i1){i1&8&&t1!==(t1=o1[3].label+"")&&set_data(r1,t1)},d(o1){o1&&detach(e1)}}}function create_fragment$7T(n1){let e1,t1,r1,o1,i1,a1,s1=n1[4]&&create_if_block_1$22(n1);const l1=n1[14].default,c1=create_slot(l1,n1,n1[13],null);let u1=n1[3]&&!n1[0]&&create_if_block$3F(n1);return{c(){e1=element("div"),s1&&s1.c(),t1=space$1(),c1&&c1.c(),r1=space$1(),u1&&u1.c(),attr(e1,"class","cell svelte-xqyo1h"),attr(e1,"style",n1[11]),toggle_class(e1,"selected",n1[1]),toggle_class(e1,"highlighted",n1[2]),toggle_class(e1,"focused",n1[0]),toggle_class(e1,"error",n1[4]),toggle_class(e1,"center",n1[8]),toggle_class(e1,"readonly",n1[9]),toggle_class(e1,"hidden",n1[10]),toggle_class(e1,"default-height",n1[7]),toggle_class(e1,"selected-other",n1[3]!=null),toggle_class(e1,"alt",n1[5]%2===1),toggle_class(e1,"top",n1[6])},m(f1,d1){insert$1(f1,e1,d1),s1&&s1.m(e1,null),append$1(e1,t1),c1&&c1.m(e1,null),append$1(e1,r1),u1&&u1.m(e1,null),o1=!0,i1||(a1=[listen(e1,"focus",n1[15]),listen(e1,"mousedown",n1[16]),listen(e1,"mouseup",n1[17]),listen(e1,"click",n1[18]),listen(e1,"contextmenu",n1[19])],i1=!0)},p(f1,[d1]){f1[4]?s1?s1.p(f1,d1):(s1=create_if_block_1$22(f1),s1.c(),s1.m(e1,t1)):s1&&(s1.d(1),s1=null),c1&&c1.p&&(!o1||d1&8192)&&update_slot_base(c1,l1,f1,f1[13],o1?get_slot_changes(l1,f1[13],d1,null):get_all_dirty_from_scope(f1[13]),null),f1[3]&&!f1[0]?u1?u1.p(f1,d1):(u1=create_if_block$3F(f1),u1.c(),u1.m(e1,null)):u1&&(u1.d(1),u1=null),(!o1||d1&2048)&&attr(e1,"style",f1[11]),(!o1||d1&2)&&toggle_class(e1,"selected",f1[1]),(!o1||d1&4)&&toggle_class(e1,"highlighted",f1[2]),(!o1||d1&1)&&toggle_class(e1,"focused",f1[0]),(!o1||d1&16)&&toggle_class(e1,"error",f1[4]),(!o1||d1&256)&&toggle_class(e1,"center",f1[8]),(!o1||d1&512)&&toggle_class(e1,"readonly",f1[9]),(!o1||d1&1024)&&toggle_class(e1,"hidden",f1[10]),(!o1||d1&128)&&toggle_class(e1,"default-height",f1[7]),(!o1||d1&8)&&toggle_class(e1,"selected-other",f1[3]!=null),(!o1||d1&32)&&toggle_class(e1,"alt",f1[5]%2===1),(!o1||d1&64)&&toggle_class(e1,"top",f1[6])},i(f1){o1||(transition_in(c1,f1),o1=!0)},o(f1){transition_out(c1,f1),o1=!1},d(f1){f1&&detach(e1),s1&&s1.d(),c1&&c1.d(f1),u1&&u1.d(),i1=!1,run_all(a1)}}}function instance$82(n1,e1,t1){let r1,{$$slots:o1={},$$scope:i1}=e1,{focused:a1=!1}=e1,{selected:s1=!1}=e1,{highlighted:l1=!1}=e1,{width:c1=""}=e1,{selectedUser:u1=null}=e1,{error:f1=null}=e1,{rowIdx:d1}=e1,{topRow:p1=!1}=e1,{defaultHeight:m1=!1}=e1,{center:_1=!1}=e1,{readonly:h1=!1}=e1,{hidden:g1=!1}=e1;const $1=(M1,z1)=>{let P1=M1==="auto"?"width: auto;":`flex: 0 0 ${M1}px;`;return z1&&(P1+=`--user-color:${z1.color};`),P1};function y1(M1){bubble.call(this,n1,M1)}function v1(M1){bubble.call(this,n1,M1)}function S1(M1){bubble.call(this,n1,M1)}function O1(M1){bubble.call(this,n1,M1)}function C1(M1){bubble.call(this,n1,M1)}return n1.$$set=M1=>{"focused"in M1&&t1(0,a1=M1.focused),"selected"in M1&&t1(1,s1=M1.selected),"highlighted"in M1&&t1(2,l1=M1.highlighted),"width"in M1&&t1(12,c1=M1.width),"selectedUser"in M1&&t1(3,u1=M1.selectedUser),"error"in M1&&t1(4,f1=M1.error),"rowIdx"in M1&&t1(5,d1=M1.rowIdx),"topRow"in M1&&t1(6,p1=M1.topRow),"defaultHeight"in M1&&t1(7,m1=M1.defaultHeight),"center"in M1&&t1(8,_1=M1.center),"readonly"in M1&&t1(9,h1=M1.readonly),"hidden"in M1&&t1(10,g1=M1.hidden),"$$scope"in M1&&t1(13,i1=M1.$$scope)},n1.$$.update=()=>{n1.$$.dirty&4104&&t1(11,r1=$1(c1,u1))},[a1,s1,l1,u1,f1,d1,p1,m1,_1,h1,g1,r1,c1,i1,o1,y1,v1,S1,O1,C1]}class GridCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$82,create_fragment$7T,safe_not_equal,{focused:0,selected:1,highlighted:2,width:12,selectedUser:3,error:4,rowIdx:5,topRow:6,defaultHeight:7,center:8,readonly:9,hidden:10})}}const getColor=(n1,e1=.3)=>((n1==null||n1===-1)&&(n1=0),`hsla(${(n1+1)*222%360}, 90%, 75%, ${e1})`),TypeIconMap={text:"Text",options:"Dropdown",datetime:"Date",barcodeqr:"Camera",longform:"TextAlignLeft",array:"Dropdown",number:"123",boolean:"Boolean",attachment:"AppleFiles",link:"DataCorrelated",formula:"Calculator",json:"Brackets",bigint:"TagBold",bb_reference:{user:"User",users:"UserGroup"}},getColumnIcon=n1=>{if(n1.schema.autocolumn)return"MagicWand";const{type:e1,subtype:t1}=n1.schema;return(typeof TypeIconMap[e1]=="object"&&t1?TypeIconMap[e1][t1]:TypeIconMap[e1])||"Text"},OptionsCell_svelte_svelte_type_style_lang="";function get_each_context$1w(n1,e1,t1){const r1=n1.slice();r1[23]=e1[t1],r1[26]=t1;const o1=r1[9][r1[23]]||r1[12](r1[23]);return r1[24]=o1,r1}function get_each_context_1$n(n1,e1,t1){const r1=n1.slice();r1[27]=e1[t1];const o1=r1[9][r1[27]]||r1[12](r1[27]);return r1[24]=o1,r1}function create_else_block$1m(n1){let e1,t1=(n1[27]||"")+"",r1,o1;return{c(){e1=element("div"),r1=text(t1),o1=space$1(),attr(e1,"class","text svelte-11w9cfl")},m(i1,a1){insert$1(i1,e1,a1),append$1(e1,r1),append$1(e1,o1)},p(i1,a1){a1&128&&t1!==(t1=(i1[27]||"")+"")&&set_data(r1,t1)},d(i1){i1&&detach(e1)}}}function create_if_block_3$S(n1){let e1,t1,r1=n1[27]+"",o1,i1;return{c(){e1=element("div"),t1=element("span"),o1=text(r1),i1=space$1(),attr(t1,"class","svelte-11w9cfl"),attr(e1,"class","badge text svelte-11w9cfl"),set_style(e1,"--color",n1[24])},m(a1,s1){insert$1(a1,e1,s1),append$1(e1,t1),append$1(t1,o1),append$1(e1,i1)},p(a1,s1){s1&128&&r1!==(r1=a1[27]+"")&&set_data(o1,r1),s1&640&&set_style(e1,"--color",a1[24])},d(a1){a1&&detach(e1)}}}function create_each_block_1$n(n1){let e1;function t1(i1,a1){return i1[24]?create_if_block_3$S:create_else_block$1m}let r1=t1(n1),o1=r1(n1);return{c(){o1.c(),e1=empty$1()},m(i1,a1){o1.m(i1,a1),insert$1(i1,e1,a1)},p(i1,a1){r1===(r1=t1(i1))&&o1?o1.p(i1,a1):(o1.d(1),o1=r1(i1),o1&&(o1.c(),o1.m(e1.parentNode,e1)))},d(i1){o1.d(i1),i1&&detach(e1)}}}function create_if_block_2$1c(n1){let e1,t1,r1,o1,i1;return t1=new Icon({props:{name:"ChevronDown"}}),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","arrow svelte-11w9cfl")},m(a1,s1){insert$1(a1,e1,s1),mount_component(t1,e1,null),r1=!0,o1||(i1=listen(e1,"click",n1[10]),o1=!0)},p:noop$5,i(a1){r1||(transition_in(t1.$$.fragment,a1),r1=!0)},o(a1){transition_out(t1.$$.fragment,a1),r1=!1},d(a1){a1&&detach(e1),destroy_component(t1),o1=!1,i1()}}}function create_if_block$3E(n1){let e1,t1,r1,o1,i1=n1[6],a1=[];for(let l1=0;l1<i1.length;l1+=1)a1[l1]=create_each_block$1w(get_each_context$1w(n1,i1,l1));const s1=l1=>transition_out(a1[l1],1,1,()=>{a1[l1]=null});return{c(){e1=element("div");for(let l1=0;l1<a1.length;l1+=1)a1[l1].c();attr(e1,"class","options svelte-11w9cfl"),toggle_class(e1,"invertX",n1[1]),toggle_class(e1,"invertY",n1[2])},m(l1,c1){insert$1(l1,e1,c1);for(let u1=0;u1<a1.length;u1+=1)a1[u1].m(e1,null);t1=!0,r1||(o1=[listen(e1,"wheel",wheel_handler),action_destroyer(clickOutside.call(null,e1,n1[11]))],r1=!0)},p(l1,c1){if(c1&13024){i1=l1[6];let u1;for(u1=0;u1<i1.length;u1+=1){const f1=get_each_context$1w(l1,i1,u1);a1[u1]?(a1[u1].p(f1,c1),transition_in(a1[u1],1)):(a1[u1]=create_each_block$1w(f1),a1[u1].c(),transition_in(a1[u1],1),a1[u1].m(e1,null))}for(group_outros(),u1=i1.length;u1<a1.length;u1+=1)s1(u1);check_outros()}(!t1||c1&2)&&toggle_class(e1,"invertX",l1[1]),(!t1||c1&4)&&toggle_class(e1,"invertY",l1[2])},i(l1){if(!t1){for(let c1=0;c1<i1.length;c1+=1)transition_in(a1[c1]);t1=!0}},o(l1){a1=a1.filter(Boolean);for(let c1=0;c1<a1.length;c1+=1)transition_out(a1[c1]);t1=!1},d(l1){l1&&detach(e1),destroy_each(a1,l1),r1=!1,run_all(o1)}}}function create_if_block_1$21(n1){let e1,t1;return e1=new Icon({props:{name:"Checkmark",color:"var(--accent-color)"}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_each_block$1w(n1){let e1,t1,r1=n1[23]+"",o1,i1,a1=n1[7].includes(n1[23]),s1,l1,c1,u1,f1=a1&&create_if_block_1$21();function d1(){return n1[20](n1[23])}function p1(){return n1[21](n1[26])}return{c(){e1=element("div"),t1=element("div"),o1=text(r1),i1=space$1(),f1&&f1.c(),s1=space$1(),attr(t1,"class","badge text svelte-11w9cfl"),set_style(t1,"--color",n1[24]),attr(e1,"class","option svelte-11w9cfl"),toggle_class(e1,"focused",n1[5]===n1[26])},m(m1,_1){insert$1(m1,e1,_1),append$1(e1,t1),append$1(t1,o1),append$1(e1,i1),f1&&f1.m(e1,null),append$1(e1,s1),l1=!0,c1||(u1=[listen(e1,"click",d1),listen(e1,"mouseenter",p1)],c1=!0)},p(m1,_1){n1=m1,(!l1||_1&64)&&r1!==(r1=n1[23]+"")&&set_data(o1,r1),(!l1||_1&576)&&set_style(t1,"--color",n1[24]),_1&192&&(a1=n1[7].includes(n1[23])),a1?f1?_1&192&&transition_in(f1,1):(f1=create_if_block_1$21(),f1.c(),transition_in(f1,1),f1.m(e1,s1)):f1&&(group_outros(),transition_out(f1,1,1,()=>{f1=null}),check_outros()),(!l1||_1&32)&&toggle_class(e1,"focused",n1[5]===n1[26])},i(m1){l1||(transition_in(f1),l1=!0)},o(m1){transition_out(f1),l1=!1},d(m1){m1&&detach(e1),f1&&f1.d(),c1=!1,run_all(u1)}}}function create_fragment$7S(n1){let e1,t1,r1,o1,i1,a1,s1,l1=n1[7],c1=[];for(let d1=0;d1<l1.length;d1+=1)c1[d1]=create_each_block_1$n(get_each_context_1$n(n1,l1,d1));let u1=n1[8]&&create_if_block_2$1c(n1),f1=n1[4]&&create_if_block$3E(n1);return{c(){e1=element("div"),t1=element("div");for(let d1=0;d1<c1.length;d1+=1)c1[d1].c();r1=space$1(),u1&&u1.c(),o1=space$1(),f1&&f1.c(),attr(t1,"class","values svelte-11w9cfl"),toggle_class(t1,"wrap",n1[3]>1),attr(e1,"class","container svelte-11w9cfl"),toggle_class(e1,"multi",n1[0]),toggle_class(e1,"editable",n1[8]),toggle_class(e1,"open",n1[10])},m(d1,p1){insert$1(d1,e1,p1),append$1(e1,t1);for(let m1=0;m1<c1.length;m1+=1)c1[m1].m(t1,null);append$1(e1,r1),u1&&u1.m(e1,null),append$1(e1,o1),f1&&f1.m(e1,null),i1=!0,a1||(s1=[listen(t1,"click",function(){is_function(n1[8]?n1[10]:null)&&(n1[8]?n1[10]:null).apply(this,arguments)}),listen(e1,"click",self$1(function(){is_function(n1[8]?n1[10]:null)&&(n1[8]?n1[10]:null).apply(this,arguments)}))],a1=!0)},p(d1,[p1]){if(n1=d1,p1&4736){l1=n1[7];let m1;for(m1=0;m1<l1.length;m1+=1){const _1=get_each_context_1$n(n1,l1,m1);c1[m1]?c1[m1].p(_1,p1):(c1[m1]=create_each_block_1$n(_1),c1[m1].c(),c1[m1].m(t1,null))}for(;m1<c1.length;m1+=1)c1[m1].d(1);c1.length=l1.length}(!i1||p1&8)&&toggle_class(t1,"wrap",n1[3]>1),n1[8]?u1?(u1.p(n1,p1),p1&256&&transition_in(u1,1)):(u1=create_if_block_2$1c(n1),u1.c(),transition_in(u1,1),u1.m(e1,o1)):u1&&(group_outros(),transition_out(u1,1,1,()=>{u1=null}),check_outros()),n1[4]?f1?(f1.p(n1,p1),p1&16&&transition_in(f1,1)):(f1=create_if_block$3E(n1),f1.c(),transition_in(f1,1),f1.m(e1,null)):f1&&(group_outros(),transition_out(f1,1,1,()=>{f1=null}),check_outros()),(!i1||p1&1)&&toggle_class(e1,"multi",n1[0]),(!i1||p1&256)&&toggle_class(e1,"editable",n1[8])},i(d1){i1||(transition_in(u1),transition_in(f1),i1=!0)},o(d1){transition_out(u1),transition_out(f1),i1=!1},d(d1){d1&&detach(e1),destroy_each(c1,d1),u1&&u1.d(),f1&&f1.d(),a1=!1,run_all(s1)}}}const wheel_handler=n1=>n1.stopPropagation();function instance$81(n1,e1,t1){let r1,o1,i1,a1,{value:s1}=e1,{schema:l1}=e1,{onChange:c1}=e1,{focused:u1=!1}=e1,{multi:f1=!1}=e1,{readonly:d1=!1}=e1,{api:p1}=e1,{invertX:m1=!1}=e1,{invertY:_1=!1}=e1,{contentLines:h1=1}=e1,g1=!1,$1=null;const y1=()=>{t1(4,g1=!0),t1(5,$1=0)},v1=()=>{t1(4,g1=!1)},S1=P1=>{const R1=P1?r1.indexOf(P1):null;return getColor(R1)},O1=P1=>{if(!f1)c1(P1===s1?null:P1),v1();else{const R1=a1.filter(N1=>r1.includes(N1));R1.includes(P1)?c1(R1.filter(N1=>N1!==P1)):c1([...R1,P1])}},C1=P1=>g1?(P1.preventDefault(),P1.key==="ArrowDown"?t1(5,$1=Math.min($1+1,r1.length-1)):P1.key==="ArrowUp"?t1(5,$1=Math.max($1-1,0)):P1.key==="Enter"&&O1(r1[$1]),!0):!1;onMount(()=>{t1(14,p1={focus:y1,blur:v1,isActive:()=>g1,onKeyDown:C1})});const M1=P1=>O1(P1),z1=P1=>t1(5,$1=P1);return n1.$$set=P1=>{"value"in P1&&t1(15,s1=P1.value),"schema"in P1&&t1(16,l1=P1.schema),"onChange"in P1&&t1(17,c1=P1.onChange),"focused"in P1&&t1(18,u1=P1.focused),"multi"in P1&&t1(0,f1=P1.multi),"readonly"in P1&&t1(19,d1=P1.readonly),"api"in P1&&t1(14,p1=P1.api),"invertX"in P1&&t1(1,m1=P1.invertX),"invertY"in P1&&t1(2,_1=P1.invertY),"contentLines"in P1&&t1(3,h1=P1.contentLines)},n1.$$.update=()=>{var P1;n1.$$.dirty&65536&&t1(6,r1=((P1=l1==null?void 0:l1.constraints)==null?void 0:P1.inclusion)||[]),n1.$$.dirty&65536&&t1(9,o1=(l1==null?void 0:l1.optionColors)||{}),n1.$$.dirty&786432&&t1(8,i1=u1&&!d1),n1.$$.dirty&32768&&t1(7,a1=Array.isArray(s1)?s1:[s1].filter(R1=>R1!=null)),n1.$$.dirty&262144&&(u1||v1())},[f1,m1,_1,h1,g1,$1,r1,a1,i1,o1,y1,v1,S1,O1,p1,s1,l1,c1,u1,d1,M1,z1]}class OptionsCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$81,create_fragment$7S,safe_not_equal,{value:15,schema:16,onChange:17,focused:18,multi:0,readonly:19,api:14,invertX:1,invertY:2,contentLines:3})}}const DateCell_svelte_svelte_type_style_lang="";function create_if_block_2$1b(n1){let e1;return{c(){e1=text(n1[7])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&128&&set_data(e1,t1[7])},d(t1){t1&&detach(e1)}}}function create_if_block_1$20(n1){let e1,t1;return e1=new Icon({props:{name:"Calendar"}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_if_block$3D(n1){let e1,t1,r1,o1;function i1(s1){n1[14](s1)}let a1={value:n1[0],appendTo:document.documentElement,enableTime:!n1[5],timeOnly:n1[4],time24hr:!0,ignoreTimezones:n1[1].ignoreTimezones,useKeyboardShortcuts:!1};return n1[3]!==void 0&&(a1.flatpickr=n1[3]),t1=new DatePicker({props:a1}),binding_callbacks.push(()=>bind$2(t1,"flatpickr",i1)),t1.$on("change",n1[15]),t1.$on("open",n1[16]),t1.$on("close",n1[17]),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","picker svelte-pa6vhv")},m(s1,l1){insert$1(s1,e1,l1),mount_component(t1,e1,null),o1=!0},p(s1,l1){const c1={};l1&1&&(c1.value=s1[0]),l1&32&&(c1.enableTime=!s1[5]),l1&16&&(c1.timeOnly=s1[4]),l1&2&&(c1.ignoreTimezones=s1[1].ignoreTimezones),!r1&&l1&8&&(r1=!0,c1.flatpickr=s1[3],add_flush_callback(()=>r1=!1)),t1.$set(c1)},i(s1){o1||(transition_in(t1.$$.fragment,s1),o1=!0)},o(s1){transition_out(t1.$$.fragment,s1),o1=!1},d(s1){s1&&detach(e1),destroy_component(t1)}}}function create_fragment$7R(n1){let e1,t1,r1,o1,i1,a1,s1=n1[0]&&create_if_block_2$1b(n1),l1=n1[8]&&create_if_block_1$20(),c1=n1[8]&&create_if_block$3D(n1);return{c(){e1=element("div"),t1=element("div"),s1&&s1.c(),r1=space$1(),l1&&l1.c(),o1=space$1(),c1&&c1.c(),i1=empty$1(),attr(t1,"class","value svelte-pa6vhv"),attr(e1,"class","container svelte-pa6vhv")},m(u1,f1){insert$1(u1,e1,f1),append$1(e1,t1),s1&&s1.m(t1,null),append$1(e1,r1),l1&&l1.m(e1,null),insert$1(u1,o1,f1),c1&&c1.m(u1,f1),insert$1(u1,i1,f1),a1=!0},p(u1,[f1]){u1[0]?s1?s1.p(u1,f1):(s1=create_if_block_2$1b(u1),s1.c(),s1.m(t1,null)):s1&&(s1.d(1),s1=null),u1[8]?l1?f1&256&&transition_in(l1,1):(l1=create_if_block_1$20(),l1.c(),transition_in(l1,1),l1.m(e1,null)):l1&&(group_outros(),transition_out(l1,1,1,()=>{l1=null}),check_outros()),u1[8]?c1?(c1.p(u1,f1),f1&256&&transition_in(c1,1)):(c1=create_if_block$3D(u1),c1.c(),transition_in(c1,1),c1.m(i1.parentNode,i1)):c1&&(group_outros(),transition_out(c1,1,1,()=>{c1=null}),check_outros())},i(u1){a1||(transition_in(l1),transition_in(c1),a1=!0)},o(u1){transition_out(l1),transition_out(c1),a1=!1},d(u1){u1&&detach(e1),s1&&s1.d(),l1&&l1.d(),u1&&detach(o1),c1&&c1.d(u1),u1&&detach(i1)}}}function instance$80(n1,e1,t1){let r1,o1,i1,a1,s1,l1,{value:c1}=e1,{schema:u1}=e1,{onChange:f1}=e1,{focused:d1=!1}=e1,{readonly:p1=!1}=e1,{api:m1}=e1,_1,h1;const g1=(C1,M1,z1,P1)=>C1?!z1||!P1?dayjs(C1).format(M1):dayjs(`0-${C1}`).format(M1):"",$1=()=>h1;onMount(()=>{t1(9,m1={onKeyDown:$1,focus:()=>_1==null?void 0:_1.open(),blur:()=>_1==null?void 0:_1.close(),isActive:()=>h1})});function y1(C1){_1=C1,t1(3,_1)}const v1=C1=>f1(C1.detail),S1=()=>t1(6,h1=!0),O1=()=>t1(6,h1=!1);return n1.$$set=C1=>{"value"in C1&&t1(0,c1=C1.value),"schema"in C1&&t1(1,u1=C1.schema),"onChange"in C1&&t1(2,f1=C1.onChange),"focused"in C1&&t1(10,d1=C1.focused),"readonly"in C1&&t1(11,p1=C1.readonly),"api"in C1&&t1(9,m1=C1.api)},n1.$$.update=()=>{n1.$$.dirty&1&&t1(12,r1=!isNaN(new Date(`0-${c1}`))),n1.$$.dirty&4098&&t1(4,o1=r1||(u1==null?void 0:u1.timeOnly)),n1.$$.dirty&2&&t1(5,i1=u1==null?void 0:u1.dateOnly),n1.$$.dirty&48&&t1(13,a1=o1?"HH:mm:ss":i1?"MMM D YYYY":"MMM D YYYY, HH:mm"),n1.$$.dirty&3072&&t1(8,s1=d1&&!p1),n1.$$.dirty&12305&&t1(7,l1=g1(c1,a1,o1,r1)),n1.$$.dirty&1032&&(d1||_1==null||_1.close())},[c1,u1,f1,_1,o1,i1,h1,l1,s1,m1,d1,p1,r1,a1,y1,v1,S1,O1]}class DateCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$80,create_fragment$7R,safe_not_equal,{value:0,schema:1,onChange:2,focused:10,readonly:11,api:9})}}function create_fragment$7Q(n1){let e1,t1,r1;const o1=[n1[1],{multi:!0}];function i1(s1){n1[2](s1)}let a1={};for(let s1=0;s1<o1.length;s1+=1)a1=assign$1(a1,o1[s1]);return n1[0]!==void 0&&(a1.api=n1[0]),e1=new OptionsCell({props:a1}),binding_callbacks.push(()=>bind$2(e1,"api",i1)),{c(){create_component(e1.$$.fragment)},m(s1,l1){mount_component(e1,s1,l1),r1=!0},p(s1,[l1]){const c1=l1&2?get_spread_update(o1,[get_spread_object(s1[1]),o1[1]]):{};!t1&&l1&1&&(t1=!0,c1.api=s1[0],add_flush_callback(()=>t1=!1)),e1.$set(c1)},i(s1){r1||(transition_in(e1.$$.fragment,s1),r1=!0)},o(s1){transition_out(e1.$$.fragment,s1),r1=!1},d(s1){destroy_component(e1,s1)}}}function instance$7$(n1,e1,t1){let{api:r1}=e1;function o1(i1){r1=i1,t1(0,r1)}return n1.$$set=i1=>{t1(1,e1=assign$1(assign$1({},e1),exclude_internal_props(i1))),"api"in i1&&t1(0,r1=i1.api)},e1=exclude_internal_props(e1),[r1,e1,o1]}class MultiSelectCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7$,create_fragment$7Q,safe_not_equal,{api:0})}}const TextCell_svelte_svelte_type_style_lang="";function create_else_block$1l(n1){let e1,t1,r1=(n1[0]??"")+"",o1;return{c(){e1=element("div"),t1=element("div"),o1=text(r1),attr(t1,"class","value svelte-69b1qv"),attr(e1,"class","text-cell svelte-69b1qv"),toggle_class(e1,"number",n1[1]==="number")},m(i1,a1){insert$1(i1,e1,a1),append$1(e1,t1),append$1(t1,o1)},p(i1,a1){a1&1&&r1!==(r1=(i1[0]??"")+"")&&set_data(o1,r1),a1&2&&toggle_class(e1,"number",i1[1]==="number")},d(i1){i1&&detach(e1)}}}function create_if_block$3C(n1){let e1,t1,r1,o1;return{c(){e1=element("input"),attr(e1,"type",n1[1]),e1.value=t1=n1[0]??"",attr(e1,"spellcheck","false"),attr(e1,"class","svelte-69b1qv")},m(i1,a1){insert$1(i1,e1,a1),n1[10](e1),r1||(o1=[listen(e1,"focus",n1[11]),listen(e1,"blur",n1[12]),listen(e1,"change",n1[5])],r1=!0)},p(i1,a1){a1&2&&attr(e1,"type",i1[1]),a1&1&&t1!==(t1=i1[0]??"")&&e1.value!==t1&&(e1.value=t1)},d(i1){i1&&detach(e1),n1[10](null),r1=!1,run_all(o1)}}}function create_fragment$7P(n1){let e1;function t1(i1,a1){return i1[4]?create_if_block$3C:create_else_block$1l}let r1=t1(n1),o1=r1(n1);return{c(){o1.c(),e1=empty$1()},m(i1,a1){o1.m(i1,a1),insert$1(i1,e1,a1)},p(i1,[a1]){r1===(r1=t1(i1))&&o1?o1.p(i1,a1):(o1.d(1),o1=r1(i1),o1&&(o1.c(),o1.m(e1.parentNode,e1)))},i:noop$5,o:noop$5,d(i1){o1.d(i1),i1&&detach(e1)}}}function instance$7_(n1,e1,t1){let r1,{value:o1}=e1,{focused:i1=!1}=e1,{onChange:a1}=e1,{type:s1="text"}=e1,{readonly:l1=!1}=e1,{api:c1}=e1,u1,f1=!1;const d1=g1=>{a1(g1.target.value)},p1=g1=>{if(!f1)return!1;if(g1.key==="Enter"){u1==null||u1.blur();const $1=new KeyboardEvent("keydown",{key:"ArrowDown"});document.dispatchEvent($1)}return!0};onMount(()=>{t1(6,c1={focus:()=>u1==null?void 0:u1.focus(),blur:()=>u1==null?void 0:u1.blur(),isActive:()=>f1,onKeyDown:p1})});function m1(g1){binding_callbacks[g1?"unshift":"push"](()=>{u1=g1,t1(2,u1)})}const _1=()=>t1(3,f1=!0),h1=()=>t1(3,f1=!1);return n1.$$set=g1=>{"value"in g1&&t1(0,o1=g1.value),"focused"in g1&&t1(7,i1=g1.focused),"onChange"in g1&&t1(8,a1=g1.onChange),"type"in g1&&t1(1,s1=g1.type),"readonly"in g1&&t1(9,l1=g1.readonly),"api"in g1&&t1(6,c1=g1.api)},n1.$$.update=()=>{n1.$$.dirty&640&&t1(4,r1=i1&&!l1)},[o1,s1,u1,f1,r1,d1,c1,i1,a1,l1,m1,_1,h1]}class TextCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7_,create_fragment$7P,safe_not_equal,{value:0,focused:7,onChange:8,type:1,readonly:9,api:6})}}function create_fragment$7O(n1){let e1,t1,r1;const o1=[n1[2],{onChange:n1[1]},{type:"number"}];function i1(s1){n1[4](s1)}let a1={};for(let s1=0;s1<o1.length;s1+=1)a1=assign$1(a1,o1[s1]);return n1[0]!==void 0&&(a1.api=n1[0]),e1=new TextCell({props:a1}),binding_callbacks.push(()=>bind$2(e1,"api",i1)),{c(){create_component(e1.$$.fragment)},m(s1,l1){mount_component(e1,s1,l1),r1=!0},p(s1,[l1]){const c1=l1&6?get_spread_update(o1,[l1&4&&get_spread_object(s1[2]),l1&2&&{onChange:s1[1]},o1[2]]):{};!t1&&l1&1&&(t1=!0,c1.api=s1[0],add_flush_callback(()=>t1=!1)),e1.$set(c1)},i(s1){r1||(transition_in(e1.$$.fragment,s1),r1=!0)},o(s1){transition_out(e1.$$.fragment,s1),r1=!1},d(s1){destroy_component(e1,s1)}}}function instance$7Z(n1,e1,t1){let{api:r1}=e1,{onChange:o1}=e1;const i1=s1=>{const l1=parseFloat(s1),c1=isNaN(l1)?null:l1;o1(c1)};function a1(s1){r1=s1,t1(0,r1)}return n1.$$set=s1=>{t1(2,e1=assign$1(assign$1({},e1),exclude_internal_props(s1))),"api"in s1&&t1(0,r1=s1.api),"onChange"in s1&&t1(3,o1=s1.onChange)},e1=exclude_internal_props(e1),[r1,i1,e1,o1,a1]}class NumberCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7Z,create_fragment$7O,safe_not_equal,{api:0,onChange:3})}}const RelationshipCell_svelte_svelte_type_style_lang="";function get_each_context$1v(n1,e1,t1){const r1=n1.slice();return r1[46]=e1[t1],r1[48]=t1,r1}function get_each_context_1$m(n1,e1,t1){const r1=n1.slice();return r1[49]=e1[t1],r1}function create_if_block_6$k(n1){let e1,t1,r1=n1[20](n1[49][n1[0]]||n1[49].primaryDisplay)+"",o1,i1,a1,s1,l1;function c1(){return n1[27](n1[49])}let u1=n1[13]&&create_if_block_7$i(n1);return{c(){e1=element("div"),t1=element("span"),o1=text(r1),i1=space$1(),u1&&u1.c(),attr(t1,"class","svelte-sn0two"),attr(e1,"class","badge svelte-sn0two")},m(f1,d1){insert$1(f1,e1,d1),append$1(e1,t1),append$1(t1,o1),append$1(e1,i1),u1&&u1.m(e1,null),a1=!0,s1||(l1=listen(t1,"click",function(){is_function(n1[13]?c1:null)&&(n1[13]?c1:null).apply(this,arguments)}),s1=!0)},p(f1,d1){n1=f1,(!a1||d1[0]&3)&&r1!==(r1=n1[20](n1[49][n1[0]]||n1[49].primaryDisplay)+"")&&set_data(o1,r1),n1[13]?u1?(u1.p(n1,d1),d1[0]&8192&&transition_in(u1,1)):(u1=create_if_block_7$i(n1),u1.c(),transition_in(u1,1),u1.m(e1,null)):u1&&(group_outros(),transition_out(u1,1,1,()=>{u1=null}),check_outros())},i(f1){a1||(transition_in(u1),a1=!0)},o(f1){transition_out(u1),a1=!1},d(f1){f1&&detach(e1),u1&&u1.d(),s1=!1,l1()}}}function create_if_block_7$i(n1){let e1,t1;function r1(){return n1[28](n1[49])}return e1=new Icon({props:{name:"Close",size:"XS",hoverable:!0}}),e1.$on("click",r1),{c(){create_component(e1.$$.fragment)},m(o1,i1){mount_component(e1,o1,i1),t1=!0},p(o1,i1){n1=o1},i(o1){t1||(transition_in(e1.$$.fragment,o1),t1=!0)},o(o1){transition_out(e1.$$.fragment,o1),t1=!1},d(o1){destroy_component(e1,o1)}}}function create_each_block_1$m(n1){let e1,t1,r1=(n1[49][n1[0]]||n1[49].primaryDisplay)&&create_if_block_6$k(n1);return{c(){r1&&r1.c(),e1=empty$1()},m(o1,i1){r1&&r1.m(o1,i1),insert$1(o1,e1,i1),t1=!0},p(o1,i1){o1[49][o1[0]]||o1[49].primaryDisplay?r1?(r1.p(o1,i1),i1[0]&3&&transition_in(r1,1)):(r1=create_if_block_6$k(o1),r1.c(),transition_in(r1,1),r1.m(e1.parentNode,e1)):r1&&(group_outros(),transition_out(r1,1,1,()=>{r1=null}),check_outros())},i(o1){t1||(transition_in(r1),t1=!0)},o(o1){transition_out(r1),t1=!1},d(o1){r1&&r1.d(o1),o1&&detach(e1)}}}function create_if_block_5$s(n1){let e1,t1,r1,o1,i1;return t1=new Icon({props:{name:"Add",size:"S"}}),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","add svelte-sn0two")},m(a1,s1){insert$1(a1,e1,s1),mount_component(t1,e1,null),r1=!0,o1||(i1=listen(e1,"click",n1[16]),o1=!0)},p:noop$5,i(a1){r1||(transition_in(t1.$$.fragment,a1),r1=!0)},o(a1){transition_out(t1.$$.fragment,a1),r1=!1},d(a1){a1&&detach(e1),destroy_component(t1),o1=!1,i1()}}}function create_if_block_4$E(n1){var o1;let e1,t1=(((o1=n1[1])==null?void 0:o1.length)||0)+"",r1;return{c(){e1=element("div"),r1=text(t1),attr(e1,"class","count svelte-sn0two")},m(i1,a1){insert$1(i1,e1,a1),append$1(e1,r1)},p(i1,a1){var s1;a1[0]&2&&t1!==(t1=(((s1=i1[1])==null?void 0:s1.length)||0)+"")&&set_data(r1,t1)},d(i1){i1&&detach(e1)}}}function create_if_block$3B(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1,u1;function f1(h1){n1[31](h1)}let d1={autofocus:!0,quiet:!0,type:"text",placeholder:n1[0]?`Search by ${n1[0]}`:null};n1[7]!==void 0&&(d1.value=n1[7]),r1=new Input$5({props:d1}),binding_callbacks.push(()=>bind$2(r1,"value",f1));const p1=[create_if_block_1$1$,create_if_block_2$1a],m1=[];function _1(h1,g1){var $1;return h1[10]?0:($1=h1[8])!=null&&$1.length?1:-1}return~(a1=_1(n1))&&(s1=m1[a1]=p1[a1](n1)),{c(){e1=element("div"),t1=element("div"),create_component(r1.$$.fragment),i1=space$1(),s1&&s1.c(),attr(t1,"class","search svelte-sn0two"),attr(e1,"class","dropdown svelte-sn0two"),set_style(e1,"--values-height",n1[11]+"px"),toggle_class(e1,"invertX",n1[3]),toggle_class(e1,"invertY",n1[4])},m(h1,g1){insert$1(h1,e1,g1),append$1(e1,t1),mount_component(r1,t1,null),append$1(e1,i1),~a1&&m1[a1].m(e1,null),l1=!0,c1||(u1=[listen(e1,"wheel",stop_propagation(n1[26])),action_destroyer(clickOutside.call(null,e1,n1[17]))],c1=!0)},p(h1,g1){const $1={};g1[0]&1&&($1.placeholder=h1[0]?`Search by ${h1[0]}`:null),!o1&&g1[0]&128&&(o1=!0,$1.value=h1[7],add_flush_callback(()=>o1=!1)),r1.$set($1);let y1=a1;a1=_1(h1),a1===y1?~a1&&m1[a1].p(h1,g1):(s1&&(group_outros(),transition_out(m1[y1],1,1,()=>{m1[y1]=null}),check_outros()),~a1?(s1=m1[a1],s1?s1.p(h1,g1):(s1=m1[a1]=p1[a1](h1),s1.c()),transition_in(s1,1),s1.m(e1,null)):s1=null),(!l1||g1[0]&2048)&&set_style(e1,"--values-height",h1[11]+"px"),(!l1||g1[0]&8)&&toggle_class(e1,"invertX",h1[3]),(!l1||g1[0]&16)&&toggle_class(e1,"invertY",h1[4])},i(h1){l1||(transition_in(r1.$$.fragment,h1),transition_in(s1),l1=!0)},o(h1){transition_out(r1.$$.fragment,h1),transition_out(s1),l1=!1},d(h1){h1&&detach(e1),destroy_component(r1),~a1&&m1[a1].d(),c1=!1,run_all(u1)}}}function create_if_block_2$1a(n1){let e1,t1,r1=n1[8],o1=[];for(let a1=0;a1<r1.length;a1+=1)o1[a1]=create_each_block$1v(get_each_context$1v(n1,r1,a1));const i1=a1=>transition_out(o1[a1],1,1,()=>{o1[a1]=null});return{c(){e1=element("div");for(let a1=0;a1<o1.length;a1+=1)o1[a1].c();attr(e1,"class","results svelte-sn0two")},m(a1,s1){insert$1(a1,e1,s1);for(let l1=0;l1<o1.length;l1+=1)o1[l1].m(e1,null);t1=!0},p(a1,s1){if(s1[0]&1344256){r1=a1[8];let l1;for(l1=0;l1<r1.length;l1+=1){const c1=get_each_context$1v(a1,r1,l1);o1[l1]?(o1[l1].p(c1,s1),transition_in(o1[l1],1)):(o1[l1]=create_each_block$1v(c1),o1[l1].c(),transition_in(o1[l1],1),o1[l1].m(e1,null))}for(group_outros(),l1=r1.length;l1<o1.length;l1+=1)i1(l1);check_outros()}},i(a1){if(!t1){for(let s1=0;s1<r1.length;s1+=1)transition_in(o1[s1]);t1=!0}},o(a1){o1=o1.filter(Boolean);for(let s1=0;s1<o1.length;s1+=1)transition_out(o1[s1]);t1=!1},d(a1){a1&&detach(e1),destroy_each(o1,a1)}}}function create_if_block_1$1$(n1){let e1,t1,r1;return t1=new ProgressCircle({props:{size:"S"}}),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","searching svelte-sn0two")},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p:noop$5,i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function create_if_block_3$R(n1){let e1,t1;return e1=new Icon({props:{size:"S",name:"Checkmark",color:"var(--accent-color)"}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_each_block$1v(n1){let e1,t1,r1,o1=n1[20](n1[46].primaryDisplay)+"",i1,a1,s1=n1[15](n1[46]),l1,c1,u1,f1,d1=s1&&create_if_block_3$R();function p1(){return n1[32](n1[46])}function m1(){return n1[33](n1[48])}return{c(){e1=element("div"),t1=element("div"),r1=element("span"),i1=text(o1),a1=space$1(),d1&&d1.c(),l1=space$1(),attr(r1,"class","svelte-sn0two"),attr(t1,"class","badge svelte-sn0two"),attr(e1,"class","result svelte-sn0two"),toggle_class(e1,"candidate",n1[48]===n1[9])},m(_1,h1){insert$1(_1,e1,h1),append$1(e1,t1),append$1(t1,r1),append$1(r1,i1),append$1(e1,a1),d1&&d1.m(e1,null),append$1(e1,l1),c1=!0,u1||(f1=[listen(e1,"click",p1),listen(e1,"mouseenter",m1)],u1=!0)},p(_1,h1){n1=_1,(!c1||h1[0]&256)&&o1!==(o1=n1[20](n1[46].primaryDisplay)+"")&&set_data(i1,o1),h1[0]&256&&(s1=n1[15](n1[46])),s1?d1?h1[0]&256&&transition_in(d1,1):(d1=create_if_block_3$R(),d1.c(),transition_in(d1,1),d1.m(e1,l1)):d1&&(group_outros(),transition_out(d1,1,1,()=>{d1=null}),check_outros()),(!c1||h1[0]&512)&&toggle_class(e1,"candidate",n1[48]===n1[9])},i(_1){c1||(transition_in(d1),c1=!0)},o(_1){transition_out(d1),c1=!1},d(_1){_1&&detach(e1),d1&&d1.d(),u1=!1,run_all(f1)}}}function create_fragment$7N(n1){var h1;let e1,t1,r1,o1,i1,a1,s1,l1,c1,u1=n1[1]||[],f1=[];for(let g1=0;g1<u1.length;g1+=1)f1[g1]=create_each_block_1$m(get_each_context_1$m(n1,u1,g1));const d1=g1=>transition_out(f1[g1],1,1,()=>{f1[g1]=null});let p1=n1[13]&&create_if_block_5$s(n1),m1=((h1=n1[1])==null?void 0:h1.length)&&create_if_block_4$E(n1),_1=n1[6]&&create_if_block$3B(n1);return{c(){e1=element("div"),t1=element("div"),r1=element("div");for(let g1=0;g1<f1.length;g1+=1)f1[g1].c();o1=space$1(),p1&&p1.c(),i1=space$1(),m1&&m1.c(),a1=space$1(),_1&&_1.c(),attr(r1,"class","values svelte-sn0two"),toggle_class(r1,"wrap",n1[13]||n1[5]>1),attr(t1,"class","container svelte-sn0two"),attr(e1,"class","wrapper svelte-sn0two"),set_style(e1,"--color",n1[14]),toggle_class(e1,"editable",n1[13]),toggle_class(e1,"focused",n1[2]),toggle_class(e1,"invertY",n1[4])},m(g1,$1){insert$1(g1,e1,$1),append$1(e1,t1),append$1(t1,r1);for(let y1=0;y1<f1.length;y1+=1)f1[y1].m(r1,null);append$1(r1,o1),p1&&p1.m(r1,null),append$1(t1,i1),m1&&m1.m(t1,null),n1[30](t1),append$1(e1,a1),_1&&_1.m(e1,null),s1=!0,l1||(c1=listen(r1,"wheel",n1[29]),l1=!0)},p(g1,$1){var y1;if($1[0]&1843203){u1=g1[1]||[];let v1;for(v1=0;v1<u1.length;v1+=1){const S1=get_each_context_1$m(g1,u1,v1);f1[v1]?(f1[v1].p(S1,$1),transition_in(f1[v1],1)):(f1[v1]=create_each_block_1$m(S1),f1[v1].c(),transition_in(f1[v1],1),f1[v1].m(r1,o1))}for(group_outros(),v1=u1.length;v1<f1.length;v1+=1)d1(v1);check_outros()}g1[13]?p1?(p1.p(g1,$1),$1[0]&8192&&transition_in(p1,1)):(p1=create_if_block_5$s(g1),p1.c(),transition_in(p1,1),p1.m(r1,null)):p1&&(group_outros(),transition_out(p1,1,1,()=>{p1=null}),check_outros()),(!s1||$1[0]&8224)&&toggle_class(r1,"wrap",g1[13]||g1[5]>1),(y1=g1[1])!=null&&y1.length?m1?m1.p(g1,$1):(m1=create_if_block_4$E(g1),m1.c(),m1.m(t1,null)):m1&&(m1.d(1),m1=null),g1[6]?_1?(_1.p(g1,$1),$1[0]&64&&transition_in(_1,1)):(_1=create_if_block$3B(g1),_1.c(),transition_in(_1,1),_1.m(e1,null)):_1&&(group_outros(),transition_out(_1,1,1,()=>{_1=null}),check_outros()),(!s1||$1[0]&8192)&&toggle_class(e1,"editable",g1[13]),(!s1||$1[0]&4)&&toggle_class(e1,"focused",g1[2]),(!s1||$1[0]&16)&&toggle_class(e1,"invertY",g1[4])},i(g1){if(!s1){for(let $1=0;$1<u1.length;$1+=1)transition_in(f1[$1]);transition_in(p1),transition_in(_1),s1=!0}},o(g1){f1=f1.filter(Boolean);for(let $1=0;$1<f1.length;$1+=1)transition_out(f1[$1]);transition_out(p1),transition_out(_1),s1=!1},d(g1){g1&&detach(e1),destroy_each(f1,g1),p1&&p1.d(),m1&&m1.d(),n1[30](null),_1&&_1.d(),l1=!1,c1()}}}function instance$7Y(n1,e1,t1){let r1,o1,i1;const{API:a1,dispatch:s1,cache:l1}=getContext("grid");let{value:c1}=e1,{api:u1}=e1,{readonly:f1}=e1,{focused:d1}=e1,{schema:p1}=e1,{onChange:m1}=e1,{invertX:_1=!1}=e1,{invertY:h1=!1}=e1,{contentLines:g1=1}=e1,{searchFunction:$1=a1.searchTable}=e1,{primaryDisplay:y1}=e1;const v1=getColor(0);let S1=!1,O1,C1,M1,z1,P1,R1=!1,N1=0,F1;const B1=(V0,A0)=>{let I0={};if(!A0||!(V0!=null&&V0.length))return I0;for(let B0=0;B0<V0.length;B0++)I0[V0[B0]._id]=!0;return I0},L1=V0=>V0!=null&&V0._id?(i1==null?void 0:i1[V0._id])===!0:!1,U1=async(V0,A0=!1)=>{var ed;if(!A0&&!V0&&!M1)return;if(!(p1!=null&&p1.tableId)||!S1){M1=null,t1(9,z1=null),t1(8,O1=[]);return}P1=Math.random(),t1(10,R1=!0);const I0=P1,B0=await $1({paginate:!1,tableId:p1.tableId,limit:20,query:{string:{[`1:${y1}`]:V0||""}}});t1(10,R1=!1),I0===P1&&(t1(8,O1=Q1((ed=B0.rows)==null?void 0:ed.map(sd=>({...sd,primaryDisplay:sd[y1]})))),t1(9,z1=O1!=null&&O1.length?0:null),M1=V0)},j1=debounce(U1,250),Q1=V0=>V0!=null&&V0.length?V0.slice().sort((A0,I0)=>A0.primaryDisplay<I0.primaryDisplay?-1:1):[],G1=async()=>{t1(6,S1=!0),t1(11,N1=F1.getBoundingClientRect().height),y1||(t1(10,R1=!0),t1(0,y1=await l1.actions.getPrimaryDisplayForTableId(p1.tableId))),await U1(null,!0)},Z1=()=>{t1(6,S1=!1),t1(8,O1=[]),t1(7,C1=null),M1=null,t1(9,z1=null)},t0=V0=>S1?(V0.key==="ArrowDown"?(V0.preventDefault(),z1==null?t1(9,z1=0):t1(9,z1=Math.min(O1.length-1,z1+1))):V0.key==="ArrowUp"?(V0.preventDefault(),z1===0?t1(9,z1=null):z1!=null&&t1(9,z1=Math.max(0,z1-1))):V0.key==="Enter"&&z1!=null&&O1[z1]!=null&&X1(O1[z1]),!0):!1,X1=async V0=>{if(c1!=null&&c1.some(A0=>A0._id===V0._id))if(r1)await m1([]);else{const A0=c1.filter(I0=>I0._id!==V0._id);A0.length?t1(9,z1=Math.min(z1,A0.length-1)):t1(9,z1=null),await m1(A0)}else r1?await m1([V0]):await m1(Q1([...c1||[],V0])),t1(9,z1=null);Z1()},W1=async V0=>{const A0=await a1.fetchRow({tableId:p1.tableId,rowId:V0});s1("edit-row",A0)},n0=V0=>V0==null?"":V0 instanceof Object?JSON.stringify(V0):V0;onMount(()=>{t1(21,u1={focus:G1,blur:Z1,isActive:()=>S1,onKeyDown:t0})});function s0(V0){bubble.call(this,n1,V0)}const l0=V0=>W1(V0._id),f0=V0=>X1(V0),e0=V0=>d1?V0.stopPropagation():null;function h0(V0){binding_callbacks[V0?"unshift":"push"](()=>{F1=V0,t1(12,F1)})}function F0(V0){C1=V0,t1(7,C1)}const z0=V0=>X1(V0),T0=V0=>t1(9,z1=V0);return n1.$$set=V0=>{"value"in V0&&t1(1,c1=V0.value),"api"in V0&&t1(21,u1=V0.api),"readonly"in V0&&t1(22,f1=V0.readonly),"focused"in V0&&t1(2,d1=V0.focused),"schema"in V0&&t1(23,p1=V0.schema),"onChange"in V0&&t1(24,m1=V0.onChange),"invertX"in V0&&t1(3,_1=V0.invertX),"invertY"in V0&&t1(4,h1=V0.invertY),"contentLines"in V0&&t1(5,g1=V0.contentLines),"searchFunction"in V0&&t1(25,$1=V0.searchFunction),"primaryDisplay"in V0&&t1(0,y1=V0.primaryDisplay)},n1.$$.update=()=>{n1.$$.dirty[0]&8388608&&(r1=(p1==null?void 0:p1.relationshipType)==="one-to-many"),n1.$$.dirty[0]&4194308&&t1(13,o1=d1&&!f1),n1.$$.dirty[0]&66&&(i1=B1(c1,S1)),n1.$$.dirty[0]&128&&j1(C1),n1.$$.dirty[0]&4&&(d1||Z1())},[y1,c1,d1,_1,h1,g1,S1,C1,O1,z1,R1,N1,F1,o1,v1,L1,G1,Z1,X1,W1,n0,u1,f1,p1,m1,$1,s0,l0,f0,e0,h0,F0,z0,T0]}class RelationshipCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7Y,create_fragment$7N,safe_not_equal,{value:1,api:21,readonly:22,focused:2,schema:23,onChange:24,invertX:3,invertY:4,contentLines:5,searchFunction:25,primaryDisplay:0},null,[-1,-1])}}const LongFormCell_svelte_svelte_type_style_lang="";function create_else_block$1k(n1){let e1,t1,r1=(n1[0]||"")+"",o1,i1,a1;return{c(){e1=element("div"),t1=element("div"),o1=text(r1),attr(t1,"class","value svelte-2btbvg"),attr(e1,"class","long-form-cell svelte-2btbvg"),toggle_class(e1,"editable",n1[5])},m(s1,l1){insert$1(s1,e1,l1),append$1(e1,t1),append$1(t1,o1),i1||(a1=listen(e1,"click",function(){is_function(n1[5]?n1[7]:null)&&(n1[5]?n1[7]:null).apply(this,arguments)}),i1=!0)},p(s1,l1){n1=s1,l1&1&&r1!==(r1=(n1[0]||"")+"")&&set_data(o1,r1),l1&32&&toggle_class(e1,"editable",n1[5])},d(s1){s1&&detach(e1),i1=!1,a1()}}}function create_if_block$3A(n1){let e1,t1,r1,o1;return{c(){e1=element("textarea"),e1.value=t1=n1[0]||"",attr(e1,"spellcheck","false"),attr(e1,"class","svelte-2btbvg"),toggle_class(e1,"invertX",n1[1]),toggle_class(e1,"invertY",n1[2])},m(i1,a1){insert$1(i1,e1,a1),n1[14](e1),r1||(o1=[listen(e1,"change",n1[6]),listen(e1,"wheel",stop_propagation(n1[13])),action_destroyer(clickOutside.call(null,e1,n1[8]))],r1=!0)},p(i1,a1){a1&1&&t1!==(t1=i1[0]||"")&&(e1.value=t1),a1&2&&toggle_class(e1,"invertX",i1[1]),a1&4&&toggle_class(e1,"invertY",i1[2])},d(i1){i1&&detach(e1),n1[14](null),r1=!1,run_all(o1)}}}function create_fragment$7M(n1){let e1;function t1(i1,a1){return i1[4]?create_if_block$3A:create_else_block$1k}let r1=t1(n1),o1=r1(n1);return{c(){o1.c(),e1=empty$1()},m(i1,a1){o1.m(i1,a1),insert$1(i1,e1,a1)},p(i1,[a1]){r1===(r1=t1(i1))&&o1?o1.p(i1,a1):(o1.d(1),o1=r1(i1),o1&&(o1.c(),o1.m(e1.parentNode,e1)))},i:noop$5,o:noop$5,d(i1){o1.d(i1),i1&&detach(e1)}}}function instance$7X(n1,e1,t1){let r1,{value:o1}=e1,{focused:i1=!1}=e1,{onChange:a1}=e1,{readonly:s1=!1}=e1,{api:l1}=e1,{invertX:c1=!1}=e1,{invertY:u1=!1}=e1,f1,d1=!1;const p1=y1=>{a1(y1.target.value)},m1=()=>d1,_1=async()=>{t1(4,d1=!0),await tick(),f1.focus(),(o1==null?void 0:o1.length)>100&&f1.setSelectionRange(0,0)},h1=()=>{f1==null||f1.blur(),t1(4,d1=!1)};onMount(()=>{t1(9,l1={focus:()=>_1(),blur:()=>h1(),isActive:()=>d1,onKeyDown:m1})});function g1(y1){bubble.call(this,n1,y1)}function $1(y1){binding_callbacks[y1?"unshift":"push"](()=>{f1=y1,t1(3,f1)})}return n1.$$set=y1=>{"value"in y1&&t1(0,o1=y1.value),"focused"in y1&&t1(10,i1=y1.focused),"onChange"in y1&&t1(11,a1=y1.onChange),"readonly"in y1&&t1(12,s1=y1.readonly),"api"in y1&&t1(9,l1=y1.api),"invertX"in y1&&t1(1,c1=y1.invertX),"invertY"in y1&&t1(2,u1=y1.invertY)},n1.$$.update=()=>{n1.$$.dirty&5120&&t1(5,r1=i1&&!s1),n1.$$.dirty&1024&&(i1||t1(4,d1=!1))},[o1,c1,u1,f1,d1,r1,p1,_1,h1,l1,i1,a1,s1,g1,$1]}class LongFormCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7X,create_fragment$7M,safe_not_equal,{value:0,focused:10,onChange:11,readonly:12,api:9,invertX:1,invertY:2})}}const BooleanCell_svelte_svelte_type_style_lang="";function create_fragment$7L(n1){let e1,t1,r1;return t1=new Checkbox_1({props:{value:n1[0]}}),t1.$on("change",n1[2]),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","boolean-cell svelte-1l7j6r7"),toggle_class(e1,"editable",n1[1])},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,[i1]){const a1={};i1&1&&(a1.value=o1[0]),t1.$set(a1),(!r1||i1&2)&&toggle_class(e1,"editable",o1[1])},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function instance$7W(n1,e1,t1){let r1,{value:o1}=e1,{focused:i1=!1}=e1,{onChange:a1}=e1,{readonly:s1=!1}=e1,{api:l1}=e1;const c1=f1=>{a1(f1.detail)},u1=f1=>f1.key==="Enter"?(a1(!o1),!0):!1;return onMount(()=>{t1(3,l1={onKeyDown:u1})}),n1.$$set=f1=>{"value"in f1&&t1(0,o1=f1.value),"focused"in f1&&t1(4,i1=f1.focused),"onChange"in f1&&t1(5,a1=f1.onChange),"readonly"in f1&&t1(6,s1=f1.readonly),"api"in f1&&t1(3,l1=f1.api)},n1.$$.update=()=>{n1.$$.dirty&80&&t1(1,r1=i1&&!s1)},[o1,r1,c1,l1,i1,a1,s1]}class BooleanCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7W,create_fragment$7L,safe_not_equal,{value:0,focused:4,onChange:5,readonly:6,api:3})}}function create_fragment$7K(n1){let e1,t1;const r1=[n1[0],{readonly:!0}];let o1={};for(let i1=0;i1<r1.length;i1+=1)o1=assign$1(o1,r1[i1]);return e1=new TextCell({props:o1}),{c(){create_component(e1.$$.fragment)},m(i1,a1){mount_component(e1,i1,a1),t1=!0},p(i1,[a1]){const s1=a1&1?get_spread_update(r1,[get_spread_object(i1[0]),r1[1]]):{};e1.$set(s1)},i(i1){t1||(transition_in(e1.$$.fragment,i1),t1=!0)},o(i1){transition_out(e1.$$.fragment,i1),t1=!1},d(i1){destroy_component(e1,i1)}}}function instance$7V(n1,e1,t1){return n1.$$set=r1=>{t1(0,e1=assign$1(assign$1({},e1),exclude_internal_props(r1)))},e1=exclude_internal_props(e1),[e1]}class FormulaCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7V,create_fragment$7K,safe_not_equal,{})}}function create_fragment$7J(n1){let e1,t1,r1;const o1=[n1[3],{value:n1[1]},{onChange:n1[2]}];function i1(s1){n1[6](s1)}let a1={};for(let s1=0;s1<o1.length;s1+=1)a1=assign$1(a1,o1[s1]);return n1[0]!==void 0&&(a1.api=n1[0]),e1=new LongFormCell({props:a1}),binding_callbacks.push(()=>bind$2(e1,"api",i1)),{c(){create_component(e1.$$.fragment)},m(s1,l1){mount_component(e1,s1,l1),r1=!0},p(s1,[l1]){const c1=l1&14?get_spread_update(o1,[l1&8&&get_spread_object(s1[3]),l1&2&&{value:s1[1]},l1&4&&{onChange:s1[2]}]):{};!t1&&l1&1&&(t1=!0,c1.api=s1[0],add_flush_callback(()=>t1=!1)),e1.$set(c1)},i(s1){r1||(transition_in(e1.$$.fragment,s1),r1=!0)},o(s1){transition_out(e1.$$.fragment,s1),r1=!1},d(s1){destroy_component(e1,s1)}}}function instance$7U(n1,e1,t1){let r1,{onChange:o1}=e1,{value:i1}=e1,{api:a1}=e1;const s1=u1=>{if(!u1)return u1;try{return JSON.stringify(u1,null,2)}catch{return null}},l1=u1=>{const f1=u1==null?void 0:u1.trim();if(!f1){o1(null);return}try{const d1=JSON.parse(f1);o1(d1)}catch{}};function c1(u1){a1=u1,t1(0,a1)}return n1.$$set=u1=>{t1(3,e1=assign$1(assign$1({},e1),exclude_internal_props(u1))),"onChange"in u1&&t1(4,o1=u1.onChange),"value"in u1&&t1(5,i1=u1.value),"api"in u1&&t1(0,a1=u1.api)},n1.$$.update=()=>{n1.$$.dirty&32&&t1(1,r1=s1(i1))},e1=exclude_internal_props(e1),[a1,r1,l1,e1,o1,i1,c1]}class JSONCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7U,create_fragment$7J,safe_not_equal,{onChange:4,value:5,api:0})}}const AttachmentCell_svelte_svelte_type_style_lang="";function get_each_context$1u(n1,e1,t1){const r1=n1.slice();return r1[21]=e1[t1],r1}function create_else_block$1j(n1){let e1,t1=n1[21].extension+"",r1,o1,i1;return{c(){e1=element("div"),r1=text(t1),o1=space$1(),attr(e1,"class","file svelte-fygtfp"),attr(e1,"title",i1=n1[21].name)},m(a1,s1){insert$1(a1,e1,s1),append$1(e1,r1),append$1(e1,o1)},p(a1,s1){s1&1&&t1!==(t1=a1[21].extension+"")&&set_data(r1,t1),s1&1&&i1!==(i1=a1[21].name)&&attr(e1,"title",i1)},d(a1){a1&&detach(e1)}}}function create_if_block_1$1_(n1){let e1,t1,r1;return{c(){e1=element("img"),src_url_equal(e1.src,t1=n1[21].url)||attr(e1,"src",t1),attr(e1,"alt",r1=n1[21].extension)},m(o1,i1){insert$1(o1,e1,i1)},p(o1,i1){i1&1&&!src_url_equal(e1.src,t1=o1[21].url)&&attr(e1,"src",t1),i1&1&&r1!==(r1=o1[21].extension)&&attr(e1,"alt",r1)},d(o1){o1&&detach(e1)}}}function create_each_block$1u(n1){let e1,t1;function r1(a1,s1){return s1&1&&(e1=null),e1==null&&(e1=!!a1[8](a1[21].extension)),e1?create_if_block_1$1_:create_else_block$1j}let o1=r1(n1,-1),i1=o1(n1);return{c(){i1.c(),t1=empty$1()},m(a1,s1){i1.m(a1,s1),insert$1(a1,t1,s1)},p(a1,s1){o1===(o1=r1(a1,s1))&&i1?i1.p(a1,s1):(i1.d(1),i1=o1(a1),i1&&(i1.c(),i1.m(t1.parentNode,t1)))},d(a1){i1.d(a1),a1&&detach(t1)}}}function create_if_block$3z(n1){let e1,t1,r1;return t1=new Dropzone({props:{value:n1[0],compact:!0,processFiles:n1[10],deleteAttachments:n1[11],handleFileTooLarge:n1[9]}}),t1.$on("change",n1[15]),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","dropzone svelte-fygtfp"),toggle_class(e1,"invertX",n1[2]),toggle_class(e1,"invertY",n1[3])},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,i1){const a1={};i1&1&&(a1.value=o1[0]),t1.$set(a1),(!r1||i1&4)&&toggle_class(e1,"invertX",o1[2]),(!r1||i1&8)&&toggle_class(e1,"invertY",o1[3])},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function create_fragment$7I(n1){let e1,t1,r1,o1,i1,a1,s1=n1[0]||[],l1=[];for(let u1=0;u1<s1.length;u1+=1)l1[u1]=create_each_block$1u(get_each_context$1u(n1,s1,u1));let c1=n1[4]&&create_if_block$3z(n1);return{c(){e1=element("div");for(let u1=0;u1<l1.length;u1+=1)l1[u1].c();t1=space$1(),c1&&c1.c(),r1=empty$1(),attr(e1,"class","attachment-cell svelte-fygtfp"),toggle_class(e1,"editable",n1[5])},m(u1,f1){insert$1(u1,e1,f1);for(let d1=0;d1<l1.length;d1+=1)l1[d1].m(e1,null);insert$1(u1,t1,f1),c1&&c1.m(u1,f1),insert$1(u1,r1,f1),o1=!0,i1||(a1=listen(e1,"click",function(){is_function(n1[5]?n1[7]:null)&&(n1[5]?n1[7]:null).apply(this,arguments)}),i1=!0)},p(u1,[f1]){if(n1=u1,f1&257){s1=n1[0]||[];let d1;for(d1=0;d1<s1.length;d1+=1){const p1=get_each_context$1u(n1,s1,d1);l1[d1]?l1[d1].p(p1,f1):(l1[d1]=create_each_block$1u(p1),l1[d1].c(),l1[d1].m(e1,null))}for(;d1<l1.length;d1+=1)l1[d1].d(1);l1.length=s1.length}(!o1||f1&32)&&toggle_class(e1,"editable",n1[5]),n1[4]?c1?(c1.p(n1,f1),f1&16&&transition_in(c1,1)):(c1=create_if_block$3z(n1),c1.c(),transition_in(c1,1),c1.m(r1.parentNode,r1)):c1&&(group_outros(),transition_out(c1,1,1,()=>{c1=null}),check_outros())},i(u1){o1||(transition_in(c1),o1=!0)},o(u1){transition_out(c1),o1=!1},d(u1){u1&&detach(e1),destroy_each(l1,u1),u1&&detach(t1),c1&&c1.d(u1),u1&&detach(r1),i1=!1,a1()}}}function instance$7T(n1,e1,t1){let r1,o1,{value:i1}=e1,{focused:a1=!1}=e1,{onChange:s1}=e1,{readonly:l1=!1}=e1,{api:c1}=e1,{invertX:u1=!1}=e1,{invertY:f1=!1}=e1;const{API:d1,notifications:p1}=getContext("grid");component_subscribe(n1,p1,M1=>t1(16,o1=M1));const m1=["png","tiff","gif","raw","jpg","jpeg"];let _1=!1;const h1=()=>_1,g1=()=>{t1(4,_1=!0)},$1=()=>{t1(4,_1=!1)},y1=M1=>m1.includes(M1==null?void 0:M1.toLowerCase()),v1=M1=>{o1.error(`Files cannot exceed ${M1/1e6}MB. Please try again with smaller files.`)},S1=async M1=>{let z1=new FormData;for(let P1=0;P1<M1.length;P1++)z1.append("file",M1[P1]);try{return await d1.uploadBuilderAttachment(z1)}catch(P1){return o1.error(P1.message||"Failed to upload attachment"),[]}},O1=async M1=>{try{return await d1.deleteBuilderAttachments(M1)}catch{return[]}};onMount(()=>{t1(12,c1={focus:()=>g1(),blur:()=>$1(),isActive:()=>_1,onKeyDown:h1})});const C1=M1=>s1(M1.detail);return n1.$$set=M1=>{"value"in M1&&t1(0,i1=M1.value),"focused"in M1&&t1(13,a1=M1.focused),"onChange"in M1&&t1(1,s1=M1.onChange),"readonly"in M1&&t1(14,l1=M1.readonly),"api"in M1&&t1(12,c1=M1.api),"invertX"in M1&&t1(2,u1=M1.invertX),"invertY"in M1&&t1(3,f1=M1.invertY)},n1.$$.update=()=>{n1.$$.dirty&24576&&t1(5,r1=a1&&!l1),n1.$$.dirty&8192&&(a1||$1())},[i1,s1,u1,f1,_1,r1,p1,g1,y1,v1,S1,O1,c1,a1,l1,C1]}class AttachmentCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7T,create_fragment$7I,safe_not_equal,{value:0,focused:13,onChange:1,readonly:14,api:12,invertX:2,invertY:3})}}function create_fragment$7H(n1){let e1,t1,r1;const o1=[n1[3],{schema:n1[1]},{searchFunction:n1[2]},{primaryDisplay:"email"}];function i1(s1){n1[4](s1)}let a1={};for(let s1=0;s1<o1.length;s1+=1)a1=assign$1(a1,o1[s1]);return n1[0]!==void 0&&(a1.api=n1[0]),e1=new RelationshipCell({props:a1}),binding_callbacks.push(()=>bind$2(e1,"api",i1)),{c(){create_component(e1.$$.fragment)},m(s1,l1){mount_component(e1,s1,l1),r1=!0},p(s1,[l1]){const c1=l1&14?get_spread_update(o1,[l1&8&&get_spread_object(s1[3]),l1&2&&{schema:s1[1]},l1&4&&{searchFunction:s1[2]},o1[3]]):{};!t1&&l1&1&&(t1=!0,c1.api=s1[0],add_flush_callback(()=>t1=!1)),e1.$set(c1)},i(s1){r1||(transition_in(e1.$$.fragment,s1),r1=!0)},o(s1){transition_out(e1.$$.fragment,s1),r1=!1},d(s1){destroy_component(e1,s1)}}}function instance$7S(n1,e1,t1){let{api:r1}=e1;const{API:o1}=getContext("grid"),{subtype:i1}=e1.schema,a1={...e1.schema,tableId:"external",relationshipType:i1===FieldSubtype.USER?RelationshipType$1.ONE_TO_MANY:RelationshipType$1.MANY_TO_MANY};async function s1(c1){if(i1!==FieldSubtype.USER&&i1!==FieldSubtype.USERS)throw`Search for '${i1}' not implemented`;const u1=Object.values(c1.query.string)[0],f1=await o1.searchUsers({query:{string:{email:u1}}});return{...f1,data:void 0,rows:f1.data}}function l1(c1){r1=c1,t1(0,r1)}return n1.$$set=c1=>{t1(3,e1=assign$1(assign$1({},e1),exclude_internal_props(c1))),"api"in c1&&t1(0,r1=c1.api)},e1=exclude_internal_props(e1),[r1,a1,s1,e1,l1]}class BBReferenceCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7S,create_fragment$7H,safe_not_equal,{api:0})}}const TypeComponentMap={text:TextCell,options:OptionsCell,datetime:DateCell,barcodeqr:TextCell,longform:LongFormCell,array:MultiSelectCell,number:NumberCell,boolean:BooleanCell,attachment:AttachmentCell,link:RelationshipCell,formula:FormulaCell,json:JSONCell,bb_reference:BBReferenceCell},getCellRenderer=n1=>{var e1;return TypeComponentMap[(e1=n1==null?void 0:n1.schema)==null?void 0:e1.type]||TextCell};function create_default_slot$50(n1){let e1,t1,r1,o1;function i1(u1){n1[25](u1)}var a1=getCellRenderer(n1[6]);function s1(u1){let f1={value:u1[7][u1[6].name],schema:u1[6].schema,onChange:u1[20].setValue,focused:u1[4],readonly:u1[14],invertY:u1[10],invertX:u1[9],contentLines:u1[11]};return u1[13]!==void 0&&(f1.api=u1[13]),{props:f1}}a1&&(e1=construct_svelte_component(a1,s1(n1)),binding_callbacks.push(()=>bind$2(e1,"api",i1)));const l1=n1[24].default,c1=create_slot(l1,n1,n1[28],null);return{c(){e1&&create_component(e1.$$.fragment),r1=space$1(),c1&&c1.c()},m(u1,f1){e1&&mount_component(e1,u1,f1),insert$1(u1,r1,f1),c1&&c1.m(u1,f1),o1=!0},p(u1,f1){const d1={};if(f1[0]&192&&(d1.value=u1[7][u1[6].name]),f1[0]&64&&(d1.schema=u1[6].schema),f1[0]&16&&(d1.focused=u1[4]),f1[0]&16384&&(d1.readonly=u1[14]),f1[0]&1024&&(d1.invertY=u1[10]),f1[0]&512&&(d1.invertX=u1[9]),f1[0]&2048&&(d1.contentLines=u1[11]),!t1&&f1[0]&8192&&(t1=!0,d1.api=u1[13],add_flush_callback(()=>t1=!1)),a1!==(a1=getCellRenderer(u1[6]))){if(e1){group_outros();const p1=e1;transition_out(p1.$$.fragment,1,0,()=>{destroy_component(p1,1)}),check_outros()}a1?(e1=construct_svelte_component(a1,s1(u1)),binding_callbacks.push(()=>bind$2(e1,"api",i1)),create_component(e1.$$.fragment),transition_in(e1.$$.fragment,1),mount_component(e1,r1.parentNode,r1)):e1=null}else a1&&e1.$set(d1);c1&&c1.p&&(!o1||f1[0]&268435456)&&update_slot_base(c1,l1,u1,u1[28],o1?get_slot_changes(l1,u1[28],f1,null):get_all_dirty_from_scope(u1[28]),null)},i(u1){o1||(e1&&transition_in(e1.$$.fragment,u1),transition_in(c1,u1),o1=!0)},o(u1){e1&&transition_out(e1.$$.fragment,u1),transition_out(c1,u1),o1=!1},d(u1){e1&&destroy_component(e1,u1),u1&&detach(r1),c1&&c1.d(u1)}}}function create_fragment$7G(n1){let e1,t1;return e1=new GridCell({props:{highlighted:n1[0],selected:n1[1],rowIdx:n1[2],topRow:n1[3],focused:n1[4],selectedUser:n1[5],readonly:n1[14],hidden:n1[12],error:n1[16],width:n1[6].width,$$slots:{default:[create_default_slot$50]},$$scope:{ctx:n1}}}),e1.$on("click",n1[26]),e1.$on("contextmenu",n1[27]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1[0]&1&&(i1.highlighted=r1[0]),o1[0]&2&&(i1.selected=r1[1]),o1[0]&4&&(i1.rowIdx=r1[2]),o1[0]&8&&(i1.topRow=r1[3]),o1[0]&16&&(i1.focused=r1[4]),o1[0]&32&&(i1.selectedUser=r1[5]),o1[0]&16384&&(i1.readonly=r1[14]),o1[0]&4096&&(i1.hidden=r1[12]),o1[0]&65536&&(i1.error=r1[16]),o1[0]&64&&(i1.width=r1[6].width),o1[0]&268463824&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$7R(n1,e1,t1){let r1,o1,i1,a1,s1=noop$5,l1=()=>(s1(),s1=subscribe(r1,W1=>t1(16,a1=W1)),r1);n1.$$.on_destroy.push(()=>s1());let{$$slots:c1={},$$scope:u1}=e1;const{rows:f1,focusedCellId:d1,focusedCellAPI:p1,menu:m1,config:_1,validation:h1}=getContext("grid");component_subscribe(n1,_1,W1=>t1(23,i1=W1));let{highlighted:g1}=e1,{selected:$1}=e1,{rowFocused:y1}=e1,{rowIdx:v1}=e1,{topRow:S1=!1}=e1,{focused:O1}=e1,{selectedUser:C1}=e1,{column:M1}=e1,{row:z1}=e1,{cellId:P1}=e1,{updateValue:R1=f1.actions.updateValue}=e1,{invertX:N1=!1}=e1,{invertY:F1=!1}=e1,{contentLines:B1=1}=e1,{hidden:L1=!1}=e1;const U1=writable(null);let j1;const Q1=(W1,n0)=>W1?derived(h1,s0=>s0[n0]):U1,G1={focus:()=>{var W1;return(W1=j1==null?void 0:j1.focus)==null?void 0:W1.call(j1)},blur:()=>{var W1;return(W1=j1==null?void 0:j1.blur)==null?void 0:W1.call(j1)},isActive:()=>{var W1;return((W1=j1==null?void 0:j1.isActive)==null?void 0:W1.call(j1))??!1},onKeyDown:(...W1)=>j1==null?void 0:j1.onKeyDown(...W1),isReadonly:()=>o1,getType:()=>M1.schema.type,getValue:()=>z1[M1.name],setValue:(W1,n0={save:!0})=>{h1.actions.setError(P1,null),R1({rowId:z1._id,column:M1.name,value:W1,save:n0==null?void 0:n0.save})}};function Z1(W1){j1=W1,t1(13,j1)}const t0=()=>d1.set(P1),X1=W1=>m1.actions.open(P1,W1);return n1.$$set=W1=>{"highlighted"in W1&&t1(0,g1=W1.highlighted),"selected"in W1&&t1(1,$1=W1.selected),"rowFocused"in W1&&t1(21,y1=W1.rowFocused),"rowIdx"in W1&&t1(2,v1=W1.rowIdx),"topRow"in W1&&t1(3,S1=W1.topRow),"focused"in W1&&t1(4,O1=W1.focused),"selectedUser"in W1&&t1(5,C1=W1.selectedUser),"column"in W1&&t1(6,M1=W1.column),"row"in W1&&t1(7,z1=W1.row),"cellId"in W1&&t1(8,P1=W1.cellId),"updateValue"in W1&&t1(22,R1=W1.updateValue),"invertX"in W1&&t1(9,N1=W1.invertX),"invertY"in W1&&t1(10,F1=W1.invertY),"contentLines"in W1&&t1(11,B1=W1.contentLines),"hidden"in W1&&t1(12,L1=W1.hidden),"$$scope"in W1&&t1(28,u1=W1.$$scope)},n1.$$.update=()=>{n1.$$.dirty[0]&2097408&&l1(t1(15,r1=Q1(y1,P1))),n1.$$.dirty[0]&8388800&&t1(14,o1=M1.schema.autocolumn||M1.schema.disabled||M1.schema.type==="formula"||!i1.canEditRows&&!z1._isNewRow),n1.$$.dirty[0]&16&&O1&&p1.set(G1)},[g1,$1,v1,S1,O1,C1,M1,z1,P1,N1,F1,B1,L1,j1,o1,r1,a1,d1,m1,_1,G1,y1,R1,i1,c1,Z1,t0,X1,u1]}class DataCell extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7R,create_fragment$7G,safe_not_equal,{highlighted:0,selected:1,rowFocused:21,rowIdx:2,topRow:3,focused:4,selectedUser:5,column:6,row:7,cellId:8,updateValue:22,invertX:9,invertY:10,contentLines:11,hidden:12},null,[-1,-1])}}const GridRow_svelte_svelte_type_style_lang="";function get_each_context$1t(n1,e1,t1){const r1=n1.slice();r1[35]=e1[t1],r1[38]=t1;const o1=`${r1[0]._id}-${r1[35].name}`;return r1[36]=o1,r1}function create_each_block$1t(n1){let e1,t1;return e1=new DataCell({props:{cellId:n1[36],column:n1[35],row:n1[0],invertY:n1[2],rowFocused:n1[5],invertX:n1[38]>=n1[10],highlighted:n1[6]||n1[5]||n1[4]===n1[35].name,selected:n1[7],rowIdx:n1[0].__idx,topRow:n1[1],focused:n1[11]===n1[36],selectedUser:n1[12][n1[36]],width:n1[35].width,contentLines:n1[13],hidden:!n1[14][n1[35].name]}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1[0]&513&&(i1.cellId=r1[36]),o1[0]&512&&(i1.column=r1[35]),o1[0]&1&&(i1.row=r1[0]),o1[0]&4&&(i1.invertY=r1[2]),o1[0]&32&&(i1.rowFocused=r1[5]),o1[0]&1024&&(i1.invertX=r1[38]>=r1[10]),o1[0]&624&&(i1.highlighted=r1[6]||r1[5]||r1[4]===r1[35].name),o1[0]&128&&(i1.selected=r1[7]),o1[0]&1&&(i1.rowIdx=r1[0].__idx),o1[0]&2&&(i1.topRow=r1[1]),o1[0]&2561&&(i1.focused=r1[11]===r1[36]),o1[0]&4609&&(i1.selectedUser=r1[12][r1[36]]),o1[0]&512&&(i1.width=r1[35].width),o1[0]&8192&&(i1.contentLines=r1[13]),o1[0]&16896&&(i1.hidden=!r1[14][r1[35].name]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$7F(n1){let e1,t1,r1,o1,i1=n1[9],a1=[];for(let l1=0;l1<i1.length;l1+=1)a1[l1]=create_each_block$1t(get_each_context$1t(n1,i1,l1));const s1=l1=>transition_out(a1[l1],1,1,()=>{a1[l1]=null});return{c(){e1=element("div");for(let l1=0;l1<a1.length;l1+=1)a1[l1].c();attr(e1,"class","row svelte-1507qm8")},m(l1,c1){insert$1(l1,e1,c1);for(let u1=0;u1<a1.length;u1+=1)a1[u1].m(e1,null);t1=!0,r1||(o1=[listen(e1,"focus",n1[31]),listen(e1,"mouseenter",function(){is_function(n1[8]?null:n1[32])&&(n1[8]?null:n1[32]).apply(this,arguments)}),listen(e1,"mouseleave",function(){is_function(n1[8]?null:n1[33])&&(n1[8]?null:n1[33]).apply(this,arguments)}),listen(e1,"click",n1[34])],r1=!0)},p(l1,c1){if(n1=l1,c1[0]&32503){i1=n1[9];let u1;for(u1=0;u1<i1.length;u1+=1){const f1=get_each_context$1t(n1,i1,u1);a1[u1]?(a1[u1].p(f1,c1),transition_in(a1[u1],1)):(a1[u1]=create_each_block$1t(f1),a1[u1].c(),transition_in(a1[u1],1),a1[u1].m(e1,null))}for(group_outros(),u1=i1.length;u1<a1.length;u1+=1)s1(u1);check_outros()}},i(l1){if(!t1){for(let c1=0;c1<i1.length;c1+=1)transition_in(a1[c1]);t1=!0}},o(l1){a1=a1.filter(Boolean);for(let c1=0;c1<a1.length;c1+=1)transition_out(a1[c1]);t1=!1},d(l1){l1&&detach(e1),destroy_each(a1,l1),r1=!1,run_all(o1)}}}function instance$7Q(n1,e1,t1){let r1,o1,i1,a1,s1,l1,c1,u1,f1,d1,p1,m1,_1,h1,g1,{row:$1}=e1,{top:y1=!1}=e1,{invertY:v1=!1}=e1;const{focusedCellId:S1,reorder:O1,selectedRows:C1,visibleColumns:M1,hoveredRowId:z1,selectedCellMap:P1,focusedRow:R1,columnHorizontalInversionIndex:N1,contentLines:F1,isDragging:B1,dispatch:L1,rows:U1,columnRenderMap:j1}=getContext("grid");component_subscribe(n1,S1,X1=>t1(11,m1=X1)),component_subscribe(n1,O1,X1=>t1(28,s1=X1)),component_subscribe(n1,C1,X1=>t1(30,u1=X1)),component_subscribe(n1,M1,X1=>t1(9,d1=X1)),component_subscribe(n1,z1,X1=>t1(3,c1=X1)),component_subscribe(n1,P1,X1=>t1(12,_1=X1)),component_subscribe(n1,R1,X1=>t1(29,l1=X1)),component_subscribe(n1,N1,X1=>t1(10,p1=X1)),component_subscribe(n1,F1,X1=>t1(13,h1=X1)),component_subscribe(n1,B1,X1=>t1(8,f1=X1)),component_subscribe(n1,j1,X1=>t1(14,g1=X1));function Q1(X1){bubble.call(this,n1,X1)}const G1=()=>set_store_value(z1,c1=$1._id,c1),Z1=()=>set_store_value(z1,c1=null,c1),t0=()=>L1("rowclick",U1.actions.cleanRow($1));return n1.$$set=X1=>{"row"in X1&&t1(0,$1=X1.row),"top"in X1&&t1(1,y1=X1.top),"invertY"in X1&&t1(2,v1=X1.invertY)},n1.$$.update=()=>{n1.$$.dirty[0]&1073741825&&t1(7,r1=!!u1[$1._id]),n1.$$.dirty[0]&9&&t1(6,o1=c1===$1._id),n1.$$.dirty[0]&536870913&&t1(5,i1=(l1==null?void 0:l1._id)===$1._id),n1.$$.dirty[0]&268435456&&t1(4,a1=s1.sourceColumn)},[$1,y1,v1,c1,a1,i1,o1,r1,f1,d1,p1,m1,_1,h1,g1,S1,O1,C1,M1,z1,P1,R1,N1,F1,B1,L1,U1,j1,s1,l1,u1,Q1,G1,Z1,t0]}class GridRow extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7Q,create_fragment$7F,safe_not_equal,{row:0,top:1,invertY:2},null,[-1,-1])}}const ButtonColumn_svelte_svelte_type_style_lang="";function get_each_context$1s(n1,e1,t1){var s1;const r1=n1.slice();r1[32]=e1[t1];const o1=!!r1[6][r1[32]._id];r1[33]=o1;const i1=r1[4]===r1[32]._id;r1[34]=i1;const a1=((s1=r1[7])==null?void 0:s1._id)===r1[32]._id;return r1[35]=a1,r1}function get_each_context_1$l(n1,e1,t1){const r1=n1.slice();return r1[38]=e1[t1],r1}function get_each_context_2$7(n1,e1,t1){const r1=n1.slice();return r1[38]=e1[t1],r1}function create_default_slot_4$1v(n1){let e1=(n1[38].text||"Button")+"",t1,r1;return{c(){t1=text(e1),r1=space$1()},m(o1,i1){insert$1(o1,t1,i1),insert$1(o1,r1,i1)},p(o1,i1){i1[0]&8&&e1!==(e1=(o1[38].text||"Button")+"")&&set_data(t1,e1)},d(o1){o1&&detach(t1),o1&&detach(r1)}}}function create_each_block_2$7(n1){let e1,t1;return e1=new Button({props:{size:"S",$$slots:{default:[create_default_slot_4$1v]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1[0]&8|o1[1]&4096&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_default_slot_3$20(n1){let e1,t1,r1=n1[3],o1=[];for(let a1=0;a1<r1.length;a1+=1)o1[a1]=create_each_block_2$7(get_each_context_2$7(n1,r1,a1));const i1=a1=>transition_out(o1[a1],1,1,()=>{o1[a1]=null});return{c(){e1=element("div");for(let a1=0;a1<o1.length;a1+=1)o1[a1].c();attr(e1,"class","buttons svelte-1ftrlsl")},m(a1,s1){insert$1(a1,e1,s1);for(let l1=0;l1<o1.length;l1+=1)o1[l1].m(e1,null);t1=!0},p(a1,s1){if(s1[0]&8){r1=a1[3];let l1;for(l1=0;l1<r1.length;l1+=1){const c1=get_each_context_2$7(a1,r1,l1);o1[l1]?(o1[l1].p(c1,s1),transition_in(o1[l1],1)):(o1[l1]=create_each_block_2$7(c1),o1[l1].c(),transition_in(o1[l1],1),o1[l1].m(e1,null))}for(group_outros(),l1=r1.length;l1<o1.length;l1+=1)i1(l1);check_outros()}},i(a1){if(!t1){for(let s1=0;s1<r1.length;s1+=1)transition_in(o1[s1]);t1=!0}},o(a1){o1=o1.filter(Boolean);for(let s1=0;s1<o1.length;s1+=1)transition_out(o1[s1]);t1=!1},d(a1){a1&&detach(e1),destroy_each(o1,a1)}}}function create_default_slot_2$2G(n1){let e1=(n1[38].text||"Button")+"",t1,r1;return{c(){t1=text(e1),r1=space$1()},m(o1,i1){insert$1(o1,t1,i1),insert$1(o1,r1,i1)},p(o1,i1){i1[0]&8&&e1!==(e1=(o1[38].text||"Button")+"")&&set_data(t1,e1)},d(o1){o1&&detach(t1),o1&&detach(r1)}}}function create_each_block_1$l(n1){let e1,t1;function r1(){return n1[27](n1[38],n1[32])}return e1=new Button({props:{newStyles:!0,size:"S",cta:n1[38].type==="cta",primary:n1[38].type==="primary",secondary:n1[38].type==="secondary",warning:n1[38].type==="warning",overBackground:n1[38].type==="overBackground",$$slots:{default:[create_default_slot_2$2G]},$$scope:{ctx:n1}}}),e1.$on("click",r1),{c(){create_component(e1.$$.fragment)},m(o1,i1){mount_component(e1,o1,i1),t1=!0},p(o1,i1){n1=o1;const a1={};i1[0]&8&&(a1.cta=n1[38].type==="cta"),i1[0]&8&&(a1.primary=n1[38].type==="primary"),i1[0]&8&&(a1.secondary=n1[38].type==="secondary"),i1[0]&8&&(a1.warning=n1[38].type==="warning"),i1[0]&8&&(a1.overBackground=n1[38].type==="overBackground"),i1[0]&8|i1[1]&4096&&(a1.$$scope={dirty:i1,ctx:n1}),e1.$set(a1)},i(o1){t1||(transition_in(e1.$$.fragment,o1),t1=!0)},o(o1){transition_out(e1.$$.fragment,o1),t1=!1},d(o1){destroy_component(e1,o1)}}}function create_default_slot_1$3G(n1){let e1,t1,r1=n1[3],o1=[];for(let a1=0;a1<r1.length;a1+=1)o1[a1]=create_each_block_1$l(get_each_context_1$l(n1,r1,a1));const i1=a1=>transition_out(o1[a1],1,1,()=>{o1[a1]=null});return{c(){e1=element("div");for(let a1=0;a1<o1.length;a1+=1)o1[a1].c();attr(e1,"class","buttons svelte-1ftrlsl")},m(a1,s1){insert$1(a1,e1,s1);for(let l1=0;l1<o1.length;l1+=1)o1[l1].m(e1,null);t1=!0},p(a1,s1){if(s1[0]&524328){r1=a1[3];let l1;for(l1=0;l1<r1.length;l1+=1){const c1=get_each_context_1$l(a1,r1,l1);o1[l1]?(o1[l1].p(c1,s1),transition_in(o1[l1],1)):(o1[l1]=create_each_block_1$l(c1),o1[l1].c(),transition_in(o1[l1],1),o1[l1].m(e1,null))}for(group_outros(),l1=r1.length;l1<o1.length;l1+=1)i1(l1);check_outros()}},i(a1){if(!t1){for(let s1=0;s1<r1.length;s1+=1)transition_in(o1[s1]);t1=!0}},o(a1){o1=o1.filter(Boolean);for(let s1=0;s1<o1.length;s1+=1)transition_out(o1[s1]);t1=!1},d(a1){a1&&detach(e1),destroy_each(o1,a1)}}}function create_each_block$1s(n1){let e1,t1,r1,o1,i1,a1;t1=new GridCell({props:{width:"auto",rowIdx:n1[32].__idx,selected:n1[33],highlighted:n1[34]||n1[35],$$slots:{default:[create_default_slot_1$3G]},$$scope:{ctx:n1}}});function s1(){return n1[28](n1[32])}return{c(){e1=element("div"),create_component(t1.$$.fragment),r1=space$1(),attr(e1,"class","row svelte-1ftrlsl")},m(l1,c1){insert$1(l1,e1,c1),mount_component(t1,e1,null),append$1(e1,r1),o1=!0,i1||(a1=[listen(e1,"mouseenter",function(){is_function(n1[8]?null:s1)&&(n1[8]?null:s1).apply(this,arguments)}),listen(e1,"mouseleave",function(){is_function(n1[8]?null:n1[29])&&(n1[8]?null:n1[29]).apply(this,arguments)})],i1=!0)},p(l1,c1){n1=l1;const u1={};c1[0]&32&&(u1.rowIdx=n1[32].__idx),c1[0]&96&&(u1.selected=n1[33]),c1[0]&176&&(u1.highlighted=n1[34]||n1[35]),c1[0]&40|c1[1]&4096&&(u1.$$scope={dirty:c1,ctx:n1}),t1.$set(u1)},i(l1){o1||(transition_in(t1.$$.fragment,l1),o1=!0)},o(l1){transition_out(t1.$$.fragment,l1),o1=!1},d(l1){l1&&detach(e1),destroy_component(t1),i1=!1,run_all(a1)}}}function create_default_slot$4$(n1){let e1,t1,r1=n1[5],o1=[];for(let a1=0;a1<r1.length;a1+=1)o1[a1]=create_each_block$1s(get_each_context$1s(n1,r1,a1));const i1=a1=>transition_out(o1[a1],1,1,()=>{o1[a1]=null});return{c(){for(let a1=0;a1<o1.length;a1+=1)o1[a1].c();e1=empty$1()},m(a1,s1){for(let l1=0;l1<o1.length;l1+=1)o1[l1].m(a1,s1);insert$1(a1,e1,s1),t1=!0},p(a1,s1){if(s1[0]&524792){r1=a1[5];let l1;for(l1=0;l1<r1.length;l1+=1){const c1=get_each_context$1s(a1,r1,l1);o1[l1]?(o1[l1].p(c1,s1),transition_in(o1[l1],1)):(o1[l1]=create_each_block$1s(c1),o1[l1].c(),transition_in(o1[l1],1),o1[l1].m(e1.parentNode,e1))}for(group_outros(),l1=r1.length;l1<o1.length;l1+=1)i1(l1);check_outros()}},i(a1){if(!t1){for(let s1=0;s1<r1.length;s1+=1)transition_in(o1[s1]);t1=!0}},o(a1){o1=o1.filter(Boolean);for(let s1=0;s1<o1.length;s1+=1)transition_out(o1[s1]);t1=!1},d(a1){destroy_each(o1,a1),a1&&detach(e1)}}}function create_fragment$7E(n1){let e1,t1,r1,o1,i1,a1,s1,l1,c1;return t1=new GridCell({props:{width:"auto",$$slots:{default:[create_default_slot_3$20]},$$scope:{ctx:n1}}}),a1=new GridScrollWrapper({props:{scrollVertically:!0,attachHandlers:!0,$$slots:{default:[create_default_slot$4$]},$$scope:{ctx:n1}}}),{c(){e1=element("div"),create_component(t1.$$.fragment),r1=space$1(),o1=element("div"),i1=element("div"),create_component(a1.$$.fragment),attr(e1,"class","measure svelte-1ftrlsl"),attr(i1,"class","content svelte-1ftrlsl"),attr(o1,"class","button-column svelte-1ftrlsl"),set_style(o1,"left",n1[2]+"px"),toggle_class(o1,"hidden",n1[0]===0)},m(u1,f1){insert$1(u1,e1,f1),mount_component(t1,e1,null),n1[26](e1),insert$1(u1,r1,f1),insert$1(u1,o1,f1),append$1(o1,i1),mount_component(a1,i1,null),s1=!0,l1||(c1=listen(i1,"mouseleave",n1[30]),l1=!0)},p(u1,f1){const d1={};f1[0]&8|f1[1]&4096&&(d1.$$scope={dirty:f1,ctx:u1}),t1.$set(d1);const p1={};f1[0]&504|f1[1]&4096&&(p1.$$scope={dirty:f1,ctx:u1}),a1.$set(p1),(!s1||f1[0]&4)&&set_style(o1,"left",u1[2]+"px"),(!s1||f1[0]&1)&&toggle_class(o1,"hidden",u1[0]===0)},i(u1){s1||(transition_in(t1.$$.fragment,u1),transition_in(a1.$$.fragment,u1),s1=!0)},o(u1){transition_out(t1.$$.fragment,u1),transition_out(a1.$$.fragment,u1),s1=!1},d(u1){u1&&detach(e1),destroy_component(t1),n1[26](null),u1&&detach(r1),u1&&detach(o1),destroy_component(a1),l1=!1,c1()}}}function instance$7P(n1,e1,t1){let r1,o1,i1,a1,s1,l1,c1,u1,f1,d1,p1,m1,_1,h1;const{renderedRows:g1,hoveredRowId:$1,props:y1,width:v1,rows:S1,focusedRow:O1,selectedRows:C1,visibleColumns:M1,scroll:z1,isDragging:P1,buttonColumnWidth:R1}=getContext("grid");component_subscribe(n1,g1,G1=>t1(5,p1=G1)),component_subscribe(n1,$1,G1=>t1(4,d1=G1)),component_subscribe(n1,y1,G1=>t1(25,f1=G1)),component_subscribe(n1,v1,G1=>t1(22,l1=G1)),component_subscribe(n1,O1,G1=>t1(7,_1=G1)),component_subscribe(n1,C1,G1=>t1(6,m1=G1)),component_subscribe(n1,M1,G1=>t1(24,u1=G1)),component_subscribe(n1,z1,G1=>t1(23,c1=G1)),component_subscribe(n1,P1,G1=>t1(8,h1=G1)),component_subscribe(n1,R1,G1=>t1(0,s1=G1));let N1;const F1=async(G1,Z1)=>{var t0;await((t0=G1.onClick)==null?void 0:t0.call(G1,S1.actions.cleanRow(Z1))),await S1.actions.refreshRow(Z1._id)};onMount(()=>{new ResizeObserver(Z1=>{var X1,W1;const t0=((W1=(X1=Z1==null?void 0:Z1[0])==null?void 0:X1.contentRect)==null?void 0:W1.width)??0;R1.set(t0)}).observe(N1)});function B1(G1){binding_callbacks[G1?"unshift":"push"](()=>{N1=G1,t1(1,N1)})}const L1=(G1,Z1)=>F1(G1,Z1),U1=G1=>set_store_value($1,d1=G1._id,d1),j1=()=>set_store_value($1,d1=null,d1),Q1=()=>set_store_value($1,d1=null,d1);return n1.$$.update=()=>{var G1;n1.$$.dirty[0]&33554432&&t1(3,r1=((G1=f1.buttons)==null?void 0:G1.slice(0,3))||[]),n1.$$.dirty[0]&16777216&&t1(21,o1=u1.reduce((Z1,t0)=>Z1+=t0.width,0)),n1.$$.dirty[0]&10485760&&t1(20,i1=o1-1-c1.left),n1.$$.dirty[0]&5242881&&t1(2,a1=Math.min(l1-s1,i1))},[s1,N1,a1,r1,d1,p1,m1,_1,h1,g1,$1,y1,v1,O1,C1,M1,z1,P1,R1,F1,i1,o1,l1,c1,u1,f1,B1,L1,U1,j1,Q1]}class ButtonColumn extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7P,create_fragment$7E,safe_not_equal,{},null,[-1,-1])}}const GridBody_svelte_svelte_type_style_lang="";function get_each_context$1r(n1,e1,t1){const r1=n1.slice();return r1[22]=e1[t1],r1[24]=t1,r1}function create_each_block$1r(n1){let e1,t1;return e1=new GridRow({props:{row:n1[22],top:n1[24]===0,invertY:n1[24]>=n1[3]}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&4&&(i1.row=r1[22]),o1&8&&(i1.invertY=r1[24]>=r1[3]),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_if_block_1$1Z(n1){let e1,t1,r1;return{c(){e1=element("div"),attr(e1,"class","blank svelte-46fi0c"),set_style(e1,"width",n1[1]+"px"),toggle_class(e1,"highlighted",n1[5]===BlankRowID)},m(o1,i1){insert$1(o1,e1,i1),t1||(r1=[listen(e1,"mouseenter",function(){is_function(n1[6]?null:n1[17])&&(n1[6]?null:n1[17]).apply(this,arguments)}),listen(e1,"mouseleave",function(){is_function(n1[6]?null:n1[18])&&(n1[6]?null:n1[18]).apply(this,arguments)}),listen(e1,"click",n1[19])],t1=!0)},p(o1,i1){n1=o1,i1&2&&set_style(e1,"width",n1[1]+"px"),i1&32&&toggle_class(e1,"highlighted",n1[5]===BlankRowID)},d(o1){o1&&detach(e1),t1=!1,run_all(r1)}}}function create_default_slot$4_(n1){let e1,t1,r1,o1=n1[2],i1=[];for(let l1=0;l1<o1.length;l1+=1)i1[l1]=create_each_block$1r(get_each_context$1r(n1,o1,l1));const a1=l1=>transition_out(i1[l1],1,1,()=>{i1[l1]=null});let s1=n1[4].canAddRows&&create_if_block_1$1Z(n1);return{c(){for(let l1=0;l1<i1.length;l1+=1)i1[l1].c();e1=space$1(),s1&&s1.c(),t1=empty$1()},m(l1,c1){for(let u1=0;u1<i1.length;u1+=1)i1[u1].m(l1,c1);insert$1(l1,e1,c1),s1&&s1.m(l1,c1),insert$1(l1,t1,c1),r1=!0},p(l1,c1){if(c1&12){o1=l1[2];let u1;for(u1=0;u1<o1.length;u1+=1){const f1=get_each_context$1r(l1,o1,u1);i1[u1]?(i1[u1].p(f1,c1),transition_in(i1[u1],1)):(i1[u1]=create_each_block$1r(f1),i1[u1].c(),transition_in(i1[u1],1),i1[u1].m(e1.parentNode,e1))}for(group_outros(),u1=o1.length;u1<i1.length;u1+=1)a1(u1);check_outros()}l1[4].canAddRows?s1?s1.p(l1,c1):(s1=create_if_block_1$1Z(l1),s1.c(),s1.m(t1.parentNode,t1)):s1&&(s1.d(1),s1=null)},i(l1){if(!r1){for(let c1=0;c1<o1.length;c1+=1)transition_in(i1[c1]);r1=!0}},o(l1){i1=i1.filter(Boolean);for(let c1=0;c1<i1.length;c1+=1)transition_out(i1[c1]);r1=!1},d(l1){destroy_each(i1,l1),l1&&detach(e1),s1&&s1.d(l1),l1&&detach(t1)}}}function create_if_block$3y(n1){let e1,t1;return e1=new ButtonColumn({}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$7D(n1){var a1;let e1,t1,r1,o1;t1=new GridScrollWrapper({props:{scrollHorizontally:!0,scrollVertically:!0,attachHandlers:!0,$$slots:{default:[create_default_slot$4_]},$$scope:{ctx:n1}}});let i1=((a1=n1[7].buttons)==null?void 0:a1.length)&&create_if_block$3y();return{c(){e1=element("div"),create_component(t1.$$.fragment),r1=space$1(),i1&&i1.c(),attr(e1,"class","grid-body svelte-46fi0c")},m(s1,l1){insert$1(s1,e1,l1),mount_component(t1,e1,null),append$1(e1,r1),i1&&i1.m(e1,null),n1[20](e1),o1=!0},p(s1,[l1]){var u1;const c1={};l1&33554558&&(c1.$$scope={dirty:l1,ctx:s1}),t1.$set(c1),(u1=s1[7].buttons)!=null&&u1.length?i1?l1&128&&transition_in(i1,1):(i1=create_if_block$3y(),i1.c(),transition_in(i1,1),i1.m(e1,null)):i1&&(group_outros(),transition_out(i1,1,1,()=>{i1=null}),check_outros())},i(s1){o1||(transition_in(t1.$$.fragment,s1),transition_in(i1),o1=!0)},o(s1){transition_out(t1.$$.fragment,s1),transition_out(i1),o1=!1},d(s1){s1&&detach(e1),destroy_component(t1),i1&&i1.d(),n1[20](null)}}}function instance$7O(n1,e1,t1){let r1,o1,i1,a1,s1,l1,c1,u1;const{bounds:f1,renderedRows:d1,visibleColumns:p1,rowVerticalInversionIndex:m1,hoveredRowId:_1,dispatch:h1,isDragging:g1,config:$1,props:y1}=getContext("grid");component_subscribe(n1,d1,z1=>t1(2,i1=z1)),component_subscribe(n1,p1,z1=>t1(16,o1=z1)),component_subscribe(n1,m1,z1=>t1(3,a1=z1)),component_subscribe(n1,_1,z1=>t1(5,l1=z1)),component_subscribe(n1,g1,z1=>t1(6,c1=z1)),component_subscribe(n1,$1,z1=>t1(4,s1=z1)),component_subscribe(n1,y1,z1=>t1(7,u1=z1));let v1;onMount(()=>{const z1=new ResizeObserver(()=>{f1.set(v1.getBoundingClientRect())});return z1.observe(v1),()=>{z1.disconnect()}});const S1=()=>set_store_value(_1,l1=BlankRowID,l1),O1=()=>set_store_value(_1,l1=null,l1),C1=()=>h1("add-row-inline");function M1(z1){binding_callbacks[z1?"unshift":"push"](()=>{v1=z1,t1(0,v1)})}return n1.$$.update=()=>{n1.$$.dirty&65536&&t1(1,r1=o1.reduce((z1,P1)=>z1+=P1.width,0))},[v1,r1,i1,a1,s1,l1,c1,u1,d1,p1,m1,_1,h1,g1,$1,y1,o1,S1,O1,C1,M1]}class GridBody extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7O,create_fragment$7D,safe_not_equal,{})}}const ResizeOverlay_svelte_svelte_type_style_lang="";function get_each_context$1q(n1,e1,t1){const r1=n1.slice();return r1[17]=e1[t1],r1}function create_if_block$3x(n1){let e1,t1,r1=n1[0]&&create_if_block_1$1Y(n1),o1=n1[4],i1=[];for(let a1=0;a1<o1.length;a1+=1)i1[a1]=create_each_block$1q(get_each_context$1q(n1,o1,a1));return{c(){r1&&r1.c(),e1=space$1();for(let a1=0;a1<i1.length;a1+=1)i1[a1].c();t1=empty$1()},m(a1,s1){r1&&r1.m(a1,s1),insert$1(a1,e1,s1);for(let l1=0;l1<i1.length;l1+=1)i1[l1].m(a1,s1);insert$1(a1,t1,s1)},p(a1,s1){if(a1[0]?r1?r1.p(a1,s1):(r1=create_if_block_1$1Y(a1),r1.c(),r1.m(e1.parentNode,e1)):r1&&(r1.d(1),r1=null),s1&2166){o1=a1[4];let l1;for(l1=0;l1<o1.length;l1+=1){const c1=get_each_context$1q(a1,o1,l1);i1[l1]?i1[l1].p(c1,s1):(i1[l1]=create_each_block$1q(c1),i1[l1].c(),i1[l1].m(t1.parentNode,t1))}for(;l1<i1.length;l1+=1)i1[l1].d(1);i1.length=o1.length}},d(a1){r1&&r1.d(a1),a1&&detach(e1),destroy_each(i1,a1),a1&&detach(t1)}}}function create_if_block_1$1Y(n1){let e1,t1,r1,o1;return{c(){e1=element("div"),t1=element("div"),attr(t1,"class","resize-indicator svelte-be62xg"),attr(e1,"class","resize-slider svelte-be62xg"),set_style(e1,"left",GutterWidth+n1[0].width+"px"),toggle_class(e1,"visible",n1[1]===n1[0].name)},m(i1,a1){insert$1(i1,e1,a1),append$1(e1,t1),r1||(o1=[listen(e1,"mousedown",n1[13]),listen(e1,"dblclick",n1[14])],r1=!0)},p(i1,a1){a1&1&&set_style(e1,"left",GutterWidth+i1[0].width+"px"),a1&3&&toggle_class(e1,"visible",i1[1]===i1[0].name)},d(i1){i1&&detach(e1),r1=!1,run_all(o1)}}}function create_each_block$1q(n1){let e1,t1,r1,o1,i1,a1;function s1(...c1){return n1[15](n1[17],...c1)}function l1(){return n1[16](n1[17])}return{c(){e1=element("div"),t1=element("div"),r1=space$1(),attr(t1,"class","resize-indicator svelte-be62xg"),attr(e1,"class","resize-slider svelte-be62xg"),attr(e1,"style",o1=n1[11](n1[17],n1[2],n1[5])),toggle_class(e1,"visible",n1[1]===n1[17].name)},m(c1,u1){insert$1(c1,e1,u1),append$1(e1,t1),append$1(e1,r1),i1||(a1=[listen(e1,"mousedown",s1),listen(e1,"dblclick",l1)],i1=!0)},p(c1,u1){n1=c1,u1&52&&o1!==(o1=n1[11](n1[17],n1[2],n1[5]))&&attr(e1,"style",o1),u1&18&&toggle_class(e1,"visible",n1[1]===n1[17].name)},d(c1){c1&&detach(e1),i1=!1,run_all(a1)}}}function create_fragment$7C(n1){let e1,t1=!n1[3]&&create_if_block$3x(n1);return{c(){t1&&t1.c(),e1=empty$1()},m(r1,o1){t1&&t1.m(r1,o1),insert$1(r1,e1,o1)},p(r1,[o1]){r1[3]?t1&&(t1.d(1),t1=null):t1?t1.p(r1,o1):(t1=create_if_block$3x(r1),t1.c(),t1.m(e1.parentNode,e1))},i:noop$5,o:noop$5,d(r1){t1&&t1.d(r1),r1&&detach(e1)}}}function instance$7N(n1,e1,t1){let r1,o1,i1,a1,s1,l1,c1;const{resize:u1,visibleColumns:f1,stickyColumn:d1,isReordering:p1,scrollLeft:m1}=getContext("grid");component_subscribe(n1,u1,v1=>t1(12,i1=v1)),component_subscribe(n1,f1,v1=>t1(4,l1=v1)),component_subscribe(n1,d1,v1=>t1(0,a1=v1)),component_subscribe(n1,p1,v1=>t1(3,s1=v1)),component_subscribe(n1,m1,v1=>t1(5,c1=v1));const _1=(v1,S1,O1)=>`left:${S1+v1.left+v1.width-O1}px;`,h1=v1=>u1.actions.startResizing(a1,v1),g1=()=>u1.actions.resetSize(a1),$1=(v1,S1)=>u1.actions.startResizing(v1,S1),y1=v1=>u1.actions.resetSize(v1);return n1.$$.update=()=>{n1.$$.dirty&1&&t1(2,r1=GutterWidth+((a1==null?void 0:a1.width)||0)),n1.$$.dirty&4096&&t1(1,o1=i1.column)},[a1,o1,r1,s1,l1,c1,u1,f1,d1,p1,m1,_1,i1,h1,g1,$1,y1]}class ResizeOverlay extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7N,create_fragment$7C,safe_not_equal,{})}}const ReorderOverlay_svelte_svelte_type_style_lang="";function create_if_block$3w(n1){let e1,t1,r1;return t1=new GridScrollWrapper({props:{scrollVertically:!0,$$slots:{default:[create_default_slot$4Z]},$$scope:{ctx:n1}}}),{c(){e1=element("div"),create_component(t1.$$.fragment),attr(e1,"class","reorder-wrapper svelte-1e4eaad")},m(o1,i1){insert$1(o1,e1,i1),mount_component(t1,e1,null),r1=!0},p(o1,i1){const a1={};i1&2097154&&(a1.$$scope={dirty:i1,ctx:o1}),t1.$set(a1)},i(o1){r1||(transition_in(t1.$$.fragment,o1),r1=!0)},o(o1){transition_out(t1.$$.fragment,o1),r1=!1},d(o1){o1&&detach(e1),destroy_component(t1)}}}function create_default_slot$4Z(n1){let e1;return{c(){e1=element("div"),attr(e1,"class","reorder-overlay svelte-1e4eaad"),attr(e1,"style",n1[1])},m(t1,r1){insert$1(t1,e1,r1)},p(t1,r1){r1&2&&attr(e1,"style",t1[1])},d(t1){t1&&detach(e1)}}}function create_fragment$7B(n1){let e1,t1,r1=n1[0]&&create_if_block$3w(n1);return{c(){r1&&r1.c(),e1=empty$1()},m(o1,i1){r1&&r1.m(o1,i1),insert$1(o1,e1,i1),t1=!0},p(o1,[i1]){o1[0]?r1?(r1.p(o1,i1),i1&1&&transition_in(r1,1)):(r1=create_if_block$3w(o1),r1.c(),transition_in(r1,1),r1.m(e1.parentNode,e1)):r1&&(group_outros(),transition_out(r1,1,1,()=>{r1=null}),check_outros())},i(o1){t1||(transition_in(r1),t1=!0)},o(o1){transition_out(r1),t1=!1},d(o1){r1&&r1.d(o1),o1&&detach(e1)}}}function instance$7M(n1,e1,t1){let r1,o1,i1,a1,s1,l1,c1,u1,f1,d1,p1,m1,_1;const{isReordering:h1,reorder:g1,visibleColumns:$1,stickyColumn:y1,rowHeight:v1,renderedRows:S1,scrollLeft:O1}=getContext("grid");component_subscribe(n1,h1,M1=>t1(13,c1=M1)),component_subscribe(n1,g1,M1=>t1(19,_1=M1)),component_subscribe(n1,$1,M1=>t1(17,p1=M1)),component_subscribe(n1,y1,M1=>t1(18,m1=M1)),component_subscribe(n1,v1,M1=>t1(15,f1=M1)),component_subscribe(n1,S1,M1=>t1(14,u1=M1)),component_subscribe(n1,O1,M1=>t1(16,d1=M1));const C1=(M1,z1,P1,R1)=>{let N1=GutterWidth+((z1==null?void 0:z1.width)||0)-R1;if(M1!==(z1==null?void 0:z1.name)){const F1=P1.find(B1=>B1.name===M1);if(!F1)return N1;N1+=F1.left+F1.width}return N1};return n1.$$.update=()=>{n1.$$.dirty&524288&&t1(12,r1=_1.targetColumn),n1.$$.dirty&262144&&t1(9,o1=GutterWidth+((m1==null?void 0:m1.width)||0)),n1.$$.dirty&462848&&t1(10,i1=C1(r1,m1,p1,d1)),n1.$$.dirty&49152&&t1(11,a1=f1*u1.length+DefaultRowHeight),n1.$$.dirty&3072&&t1(1,s1=`left:${i1}px; height:${a1}px;`),n1.$$.dirty&9728&&t1(0,l1=c1&&i1>=o1)},[l1,s1,h1,g1,$1,y1,v1,S1,O1,o1,i1,a1,r1,c1,u1,f1,d1,p1,m1,_1]}class ReorderOverlay extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7M,create_fragment$7B,safe_not_equal,{})}}const NewColumnButton_svelte_svelte_type_style_lang="";function create_default_slot$4Y(n1){let e1,t1,r1,o1,i1;const a1=n1[11].default,s1=create_slot(a1,n1,n1[16],null);return{c(){e1=element("div"),s1&&s1.c(),attr(e1,"class","content svelte-1mi3itc")},m(l1,c1){insert$1(l1,e1,c1),s1&&s1.m(e1,null),r1=!0,o1||(i1=action_destroyer(t1=clickOutside.call(null,e1,n1[14])),o1=!0)},p(l1,c1){s1&&s1.p&&(!r1||c1&65536)&&update_slot_base(s1,a1,l1,l1[16],r1?get_slot_changes(a1,l1[16],c1,null):get_all_dirty_from_scope(l1[16]),null),t1&&is_function(t1.update)&&c1&4&&t1.update.call(null,l1[14])},i(l1){r1||(transition_in(s1,l1),r1=!0)},o(l1){transition_out(s1,l1),r1=!1},d(l1){l1&&detach(e1),s1&&s1.d(l1),o1=!1,i1()}}}function create_fragment$7A(n1){let e1,t1,r1,o1,i1,a1,s1,l1;t1=new Icon({props:{name:"Add"}});function c1(f1){n1[15](f1)}let u1={anchor:n1[1],align:n1[0].length?"right":"left",offset:0,popoverTarget:document.getElementById("add-column-button"),customZindex:100,$$slots:{default:[create_default_slot$4Y]},$$scope:{ctx:n1}};return n1[2]!==void 0&&(u1.open=n1[2]),o1=new Popover({props:u1}),binding_callbacks.push(()=>bind$2(o1,"open",c1)),{c(){e1=element("div"),create_component(t1.$$.fragment),r1=space$1(),create_component(o1.$$.fragment),attr(e1,"id","add-column-button"),attr(e1,"class","add svelte-1mi3itc"),set_style(e1,"left",n1[3]+"px")},m(f1,d1){insert$1(f1,e1,d1),mount_component(t1,e1,null),n1[12](e1),insert$1(f1,r1,d1),mount_component(o1,f1,d1),a1=!0,s1||(l1=listen(e1,"click",n1[13]),s1=!0)},p(f1,[d1]){(!a1||d1&8)&&set_style(e1,"left",f1[3]+"px");const p1={};d1&2&&(p1.anchor=f1[1]),d1&1&&(p1.align=f1[0].length?"right":"left"),d1&65540&&(p1.$$scope={dirty:d1,ctx:f1}),!i1&&d1&4&&(i1=!0,p1.open=f1[2],add_flush_callback(()=>i1=!1)),o1.$set(p1)},i(f1){a1||(transition_in(t1.$$.fragment,f1),transition_in(o1.$$.fragment,f1),a1=!0)},o(f1){transition_out(t1.$$.fragment,f1),transition_out(o1.$$.fragment,f1),a1=!1},d(f1){f1&&detach(e1),destroy_component(t1),n1[12](null),f1&&detach(r1),destroy_component(o1,f1),s1=!1,l1()}}}function instance$7L(n1,e1,t1){let r1,o1,i1,a1,s1,l1,{$$slots:c1={},$$scope:u1}=e1;const{visibleColumns:f1,scroll:d1,width:p1,subscribe:m1}=getContext("grid");component_subscribe(n1,f1,O1=>t1(0,l1=O1)),component_subscribe(n1,d1,O1=>t1(10,s1=O1)),component_subscribe(n1,p1,O1=>t1(9,a1=O1));let _1,h1=!1;const g1=()=>{t1(2,h1=!1)};onMount(()=>m1("close-edit-column",g1));function $1(O1){binding_callbacks[O1?"unshift":"push"](()=>{_1=O1,t1(1,_1)})}const y1=()=>t1(2,h1=!0),v1=()=>{t1(2,h1=!1)};function S1(O1){h1=O1,t1(2,h1)}return n1.$$set=O1=>{"$$scope"in O1&&t1(16,u1=O1.$$scope)},n1.$$.update=()=>{n1.$$.dirty&1&&t1(8,r1=l1.reduce((O1,C1)=>O1+=C1.width,0)),n1.$$.dirty&1280&&t1(7,o1=r1-1-s1.left),n1.$$.dirty&640&&t1(3,i1=Math.min(a1-40,o1))},[l1,_1,h1,i1,f1,d1,p1,o1,r1,a1,s1,c1,$1,y1,v1,S1,u1]}class NewColumnButton extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7L,create_fragment$7A,safe_not_equal,{})}}function create_default_slot$4X(n1){let e1,t1=n1[0].schema.name+"",r1,o1,i1,a1,s1,l1,c1;i1=new InlineAlert({props:{type:"error",header:"Are you sure?",message:"This will leave bindings which utilised the user relationship column in a state where they will need to be updated to use the new column instead."}});function u1(d1){n1[5](d1)}let f1={label:"New column name",error:n1[2]};return n1[1]!==void 0&&(f1.value=n1[1]),s1=new Input$5({props:f1}),binding_callbacks.push(()=>bind$2(s1,"value",u1)),{c(){e1=text('This operation will kick off a migration of the column "'),r1=text(t1),o1=text(`"
@@ -423,7 +423,7 @@ __p += '`),o2&&(nd+=`' +
423
423
  function print() { __p += __j.call(arguments, '') }
424
424
  `:`;
425
425
  `)+nd+`return __p
426
- }`;var Xd=Ub(function(){return Nd(i0,Md+"return "+nd).apply(t1,g0)});if(Xd.source=nd,Pb(Xd))throw Xd;return Xd}function xb(b1){return lm(b1).toLowerCase()}function T7(b1){return lm(b1).toUpperCase()}function i9(b1,k1,T1){if(b1=lm(b1),b1&&(T1||k1===t1))return $8(b1);if(!b1||!(k1=Kh(k1)))return b1;var q1=K_(b1),J1=K_(k1),i0=r3(q1,J1),g0=Ag(q1,J1)+1;return G3(q1,i0,g0).join("")}function a9(b1,k1,T1){if(b1=lm(b1),b1&&(T1||k1===t1))return b1.slice(0,H4(b1)+1);if(!b1||!(k1=Kh(k1)))return b1;var q1=K_(b1),J1=Ag(q1,K_(k1))+1;return G3(q1,0,J1).join("")}function s9(b1,k1,T1){if(b1=lm(b1),b1&&(T1||k1===t1))return b1.replace(W0,"");if(!b1||!(k1=Kh(k1)))return b1;var q1=K_(b1),J1=r3(q1,K_(k1));return G3(q1,J1).join("")}function f8(b1,k1){var T1=P1,q1=R1;if(__(k1)){var J1="separator"in k1?k1.separator:J1;T1="length"in k1?w2(k1.length):T1,q1="omission"in k1?Kh(k1.omission):q1}b1=lm(b1);var i0=b1.length;if(K5(b1)){var g0=K_(b1);i0=g0.length}if(T1>=i0)return b1;var O0=T1-R4(q1);if(O0<1)return q1;var D0=g0?G3(g0,0,O0).join(""):b1.slice(0,O0);if(J1===t1)return D0+q1;if(g0&&(O0+=D0.length-O0),i6(J1)){if(b1.slice(O0).search(J1)){var K0,Y0=D0;for(J1.global||(J1=Q6(J1.source,lm(bm.exec(J1))+"g")),J1.lastIndex=0;K0=J1.exec(Y0);)var nd=K0.index;D0=D0.slice(0,nd===t1?O0:nd)}}else if(b1.indexOf(Kh(J1),O0)!=O0){var vd=D0.lastIndexOf(J1);vd>-1&&(D0=D0.slice(0,vd))}return D0+q1}function N2(b1){return b1=lm(b1),b1&&O2.test(b1)?b1.replace(Yd,U6):b1}var l9=e5(function(b1,k1,T1){return b1+(T1?" ":"")+k1.toUpperCase()}),gg=t8("toUpperCase");function E7(b1,k1,T1){return b1=lm(b1),k1=T1?t1:k1,k1===t1?$_(b1)?Mg(b1):Y5(b1):b1.match(k1)||[]}var Ub=T2(function(b1,k1){try{return Wh(b1,t1,k1)}catch(T1){return Pb(T1)?T1:new Sd(T1)}}),qb=d4(function(b1,k1){return ld(k1,function(T1){T1=nm(T1),Xh(b1,T1,R3(b1[T1],b1))}),b1});function z7(b1){var k1=b1==null?0:b1.length,T1=Qd();return b1=k1?C2(b1,function(q1){if(typeof q1[1]!="function")throw new k_(a1);return[T1(q1[0]),q1[1]]}):[],T2(function(q1){for(var J1=-1;++J1<k1;){var i0=b1[J1];if(Wh(i0[0],this,q1))return Wh(i0[1],this,q1)}})}function R8(b1){return Cm(A_(b1,f1))}function jb(b1){return function(){return b1}}function c9(b1,k1){return b1==null||b1!==b1?k1:b1}var u9=A6(),L7=A6(!0);function b3(b1){return b1}function Qb(b1){return U4(typeof b1=="function"?b1:A_(b1,f1))}function f9(b1){return m3(A_(b1,f1))}function d9(b1,k1){return z3(b1,A_(k1,f1))}var p9=T2(function(b1,k1){return function(T1){return p3(T1,b1,k1)}}),m9=T2(function(b1,k1){return function(T1){return p3(b1,T1,k1)}});function Wb(b1,k1,T1){var q1=e3(k1),J1=q2(k1,q1);T1==null&&!(__(k1)&&(J1.length||!q1.length))&&(T1=k1,k1=b1,b1=this,J1=q2(k1,e3(k1)));var i0=!(__(T1)&&"chain"in T1)||!!T1.chain,g0=i5(b1);return ld(J1,function(O0){var D0=k1[O0];b1[O0]=D0,g0&&(b1.prototype[O0]=function(){var K0=this.__chain__;if(i0||K0){var Y0=b1(this.__wrapped__),nd=Y0.__actions__=c_(this.__actions__);return nd.push({func:D0,args:arguments,thisArg:b1}),Y0.__chain__=K0,Y0}return D0.apply(b1,pm([this.value()],arguments))})}),b1}function _9(){return d_._===this&&(d_._=S_),this}function Gb(){}function P7(b1){return b1=w2(b1),T2(function(k1){return jg(k1,b1)})}var h9=t5(C2),g9=t5(y0),I7=t5(n3);function Yb(b1){return r0(b1)?U3(nm(b1)):Hh(b1)}function b9(b1){return function(k1){return b1==null?t1:Im(b1,k1)}}var $9=Zg(),v9=Zg(!0);function Xb(){return[]}function Zb(){return!1}function y9(){return{}}function w9(){return""}function Kb(){return!0}function D7(b1,k1){if(b1=w2(b1),b1<1||b1>Q1)return[];var T1=t0,q1=sm(b1,t0);k1=Qd(k1),b1-=t0;for(var J1=Og(q1,k1);++T1<b1;)k1(T1);return J1}function k9(b1){return L2(b1)?C2(b1,nm):L4(b1)?[b1]:c_(z_(lm(b1)))}function S9(b1){var k1=++$4;return lm(b1)+k1}var O9=Xg(function(b1,k1){return b1+k1},0),A9=i8("ceil"),C9=Xg(function(b1,k1){return b1/k1},1),M9=i8("floor");function T9(b1){return b1&&b1.length?Mm(b1,b3,C_):t1}function E9(b1,k1){return b1&&b1.length?Mm(b1,Qd(k1,2),C_):t1}function z9(b1){return m6(b1,b3)}function L9(b1,k1){return m6(b1,Qd(k1,2))}function P9(b1){return b1&&b1.length?Mm(b1,b3,w6):t1}function I9(b1,k1){return b1&&b1.length?Mm(b1,Qd(k1,2),w6):t1}var D9=Xg(function(b1,k1){return b1*k1},1),B9=i8("round"),R9=Xg(function(b1,k1){return b1-k1},0);function H9(b1){return b1&&b1.length?_6(b1,b3):0}function N9(b1,k1){return b1&&b1.length?_6(b1,Qd(k1,2)):0}return P0.after=l$,P0.ary=ob,P0.assign=W8,P0.assignIn=bb,P0.assignInWith=s6,P0.assignWith=G8,P0.at=Y8,P0.before=i7,P0.bind=R3,P0.bindAll=qb,P0.bindKey=ib,P0.castArray=g$,P0.chain=u8,P0.chunk=e_,P0.compact=Bm,P0.concat=Vh,P0.cond=z7,P0.conforms=R8,P0.constant=jb,P0.countBy=x7,P0.create=$b,P0.curry=a7,P0.curryRight=s7,P0.debounce=ab,P0.defaults=P8,P0.defaultsDeep=C$,P0.defer=c$,P0.delay=Mb,P0.difference=mg,P0.differenceBy=n5,P0.differenceWith=H_,P0.drop=p4,P0.dropRight=t_,P0.dropRightWhile=P6,P0.dropWhile=E4,P0.fill=H5,P0.filter=q7,P0.flatMap=t7,P0.flatMapDeep=Q7,P0.flatMapDepth=W7,P0.flatten=u_,P0.flattenDeep=Rm,P0.flattenDepth=kb,P0.flip=u$,P0.flow=u9,P0.flowRight=L7,P0.fromPairs=Sb,P0.functions=b7,P0.functionsIn=I8,P0.groupBy=G7,P0.initial=Ab,P0.intersection=j8,P0.intersectionBy=Cb,P0.intersectionWith=N5,P0.invert=v7,P0.invertBy=y7,P0.invokeMap=X7,P0.iteratee=Qb,P0.keyBy=Z7,P0.keys=e3,P0.keysIn=J3,P0.map=nb,P0.mapKeys=P$,P0.mapValues=Rb,P0.matches=f9,P0.matchesProperty=d9,P0.memoize=Q8,P0.merge=Hb,P0.mergeWith=Nb,P0.method=p9,P0.methodOf=m9,P0.mixin=Wb,P0.negate=sb,P0.nthArg=P7,P0.omit=N3,P0.omitBy=I$,P0.once=Tb,P0.orderBy=K7,P0.over=h9,P0.overArgs=Eb,P0.overEvery=g9,P0.overSome=I7,P0.partial=zb,P0.partialRight=l7,P0.partition=J7,P0.pick=w7,P0.pickBy=D8,P0.property=Yb,P0.propertyOf=b9,P0.pull=x1,P0.pullAll=K1,P0.pullAllBy=u0,P0.pullAllWith=w0,P0.pullAt=H0,P0.range=$9,P0.rangeRight=v9,P0.rearg=f$,P0.reject=n$,P0.remove=X0,P0.rest=d$,P0.reverse=od,P0.sampleSize=o$,P0.set=k7,P0.setWith=D$,P0.shuffle=i$,P0.slice=cd,P0.sortBy=o7,P0.sortedUniq=Hd,P0.sortedUniqBy=Fd,P0.split=M7,P0.spread=p$,P0.tail=qd,P0.take=t2,P0.takeRight=_2,P0.takeRightWhile=am,P0.takeWhile=Q_,P0.tap=tb,P0.throttle=m$,P0.thru=_g,P0.toArray=h7,P0.toPairs=S7,P0.toPairsIn=O7,P0.toPath=k9,P0.toPlainObject=Bb,P0.transform=B$,P0.unary=_$,P0.union=Gd,P0.unionBy=P2,P0.unionWith=h3,P0.uniq=g3,P0.uniqBy=m4,P0.uniqWith=Qm,P0.unset=R$,P0.unzip=K3,P0.unzipWith=_4,P0.update=H$,P0.updateWith=N$,P0.values=B8,P0.valuesIn=V$,P0.without=c8,P0.words=E7,P0.wrap=h$,P0.xor=n6,P0.xorBy=z4,P0.xorWith=eb,P0.zip=M8,P0.zipObject=m_,P0.zipObjectDeep=Jh,P0.zipWith=T8,P0.entries=S7,P0.entriesIn=O7,P0.extend=bb,P0.extendWith=s6,Wb(P0,P0),P0.add=O9,P0.attempt=Ub,P0.camelCase=q$,P0.capitalize=A7,P0.ceil=A9,P0.clamp=F$,P0.clone=b$,P0.cloneDeep=v$,P0.cloneDeepWith=y$,P0.cloneWith=$$,P0.conformsTo=w$,P0.deburr=C7,P0.defaultTo=c9,P0.divide=C9,P0.endsWith=j$,P0.eq=km,P0.escape=Q$,P0.escapeRegExp=W$,P0.every=U7,P0.find=j7,P0.findIndex=r5,P0.findKey=M$,P0.findLast=e7,P0.findLastIndex=fm,P0.findLastKey=T$,P0.floor=M9,P0.forEach=n7,P0.forEachRight=r7,P0.forIn=E$,P0.forInRight=z$,P0.forOwn=vb,P0.forOwnRight=X8,P0.get=hg,P0.gt=lb,P0.gte=Lb,P0.has=$7,P0.hasIn=Z8,P0.head=K8,P0.identity=b3,P0.includes=Y7,P0.indexOf=Ob,P0.inRange=x$,P0.invoke=L$,P0.isArguments=I6,P0.isArray=L2,P0.isArrayBuffer=r_,P0.isArrayLike=H3,P0.isArrayLikeObject=N_,P0.isBoolean=o5,P0.isBuffer=V5,P0.isDate=k$,P0.isElement=L8,P0.isEmpty=cb,P0.isEqual=ub,P0.isEqualWith=Sm,P0.isError=Pb,P0.isFinite=c7,P0.isFunction=i5,P0.isInteger=u7,P0.isLength=fb,P0.isMap=r6,P0.isMatch=db,P0.isMatchWith=f7,P0.isNaN=pb,P0.isNative=d7,P0.isNil=mb,P0.isNull=p7,P0.isNumber=Ib,P0.isObject=__,P0.isObjectLike=o_,P0.isPlainObject=o6,P0.isRegExp=i6,P0.isSafeInteger=_b,P0.isSet=m7,P0.isString=hb,P0.isSymbol=L4,P0.isTypedArray=a6,P0.isUndefined=gb,P0.isWeakMap=Db,P0.isWeakSet=S$,P0.join=J8,P0.kebabCase=G$,P0.last=_3,P0.lastIndexOf=n_,P0.lowerCase=Y$,P0.lowerFirst=X$,P0.lt=_7,P0.lte=O$,P0.max=T9,P0.maxBy=E9,P0.mean=z9,P0.meanBy=L9,P0.min=P9,P0.minBy=I9,P0.stubArray=Xb,P0.stubFalse=Zb,P0.stubObject=y9,P0.stubString=w9,P0.stubTrue=Kb,P0.multiply=D9,P0.nth=E1,P0.noConflict=_9,P0.noop=Gb,P0.now=rb,P0.pad=Z$,P0.padEnd=K$,P0.padStart=J$,P0.parseInt=e9,P0.random=U$,P0.reduce=e$,P0.reduceRight=t$,P0.repeat=t9,P0.replace=yb,P0.result=Vb,P0.round=B9,P0.runInContext=E0,P0.sample=r$,P0.size=a$,P0.snakeCase=Fb,P0.some=s$,P0.sortedIndex=Ad,P0.sortedIndexBy=Cd,P0.sortedIndexOf=Pd,P0.sortedLastIndex=Jd,P0.sortedLastIndexBy=i2,P0.sortedLastIndexOf=p2,P0.startCase=n9,P0.startsWith=r9,P0.subtract=R9,P0.sum=H9,P0.sumBy=N9,P0.template=o9,P0.times=D7,P0.toFinite=Hm,P0.toInteger=w2,P0.toLength=g7,P0.toLower=xb,P0.toNumber=a5,P0.toSafeInteger=A$,P0.toString=lm,P0.toUpper=T7,P0.trim=i9,P0.trimEnd=a9,P0.trimStart=s9,P0.truncate=f8,P0.unescape=N2,P0.uniqueId=S9,P0.upperCase=l9,P0.upperFirst=gg,P0.each=n7,P0.eachRight=r7,P0.first=K8,Wb(P0,function(){var b1={};return E3(P0,function(k1,T1){U2.call(P0.prototype,T1)||(b1[T1]=k1)}),b1}(),{chain:!1}),P0.VERSION=r1,ld(["bind","bindKey","curry","curryRight","partial","partialRight"],function(b1){P0[b1].placeholder=P0}),ld(["drop","take"],function(b1,k1){z2.prototype[b1]=function(T1){T1=T1===t1?1:Fm(w2(T1),0);var q1=this.__filtered__&&!k1?new z2(this):this.clone();return q1.__filtered__?q1.__takeCount__=sm(T1,q1.__takeCount__):q1.__views__.push({size:sm(T1,t0),type:b1+(q1.__dir__<0?"Right":"")}),q1},z2.prototype[b1+"Right"]=function(T1){return this.reverse()[b1](T1).reverse()}}),ld(["filter","map","takeWhile"],function(b1,k1){var T1=k1+1,q1=T1==B1||T1==U1;z2.prototype[b1]=function(J1){var i0=this.clone();return i0.__iteratees__.push({iteratee:Qd(J1,3),type:T1}),i0.__filtered__=i0.__filtered__||q1,i0}}),ld(["head","last"],function(b1,k1){var T1="take"+(k1?"Right":"");z2.prototype[b1]=function(){return this[T1](1).value()[0]}}),ld(["initial","tail"],function(b1,k1){var T1="drop"+(k1?"":"Right");z2.prototype[b1]=function(){return this.__filtered__?new z2(this):this[T1](1)}}),z2.prototype.compact=function(){return this.filter(b3)},z2.prototype.find=function(b1){return this.filter(b1).head()},z2.prototype.findLast=function(b1){return this.reverse().find(b1)},z2.prototype.invokeMap=T2(function(b1,k1){return typeof b1=="function"?new z2(this):this.map(function(T1){return p3(T1,b1,k1)})}),z2.prototype.reject=function(b1){return this.filter(sb(Qd(b1)))},z2.prototype.slice=function(b1,k1){b1=w2(b1);var T1=this;return T1.__filtered__&&(b1>0||k1<0)?new z2(T1):(b1<0?T1=T1.takeRight(-b1):b1&&(T1=T1.drop(b1)),k1!==t1&&(k1=w2(k1),T1=k1<0?T1.dropRight(-k1):T1.take(k1-b1)),T1)},z2.prototype.takeRightWhile=function(b1){return this.reverse().takeWhile(b1).reverse()},z2.prototype.toArray=function(){return this.take(t0)},E3(z2.prototype,function(b1,k1){var T1=/^(?:filter|find|map|reject)|While$/.test(k1),q1=/^(?:head|last)$/.test(k1),J1=P0[q1?"take"+(k1=="last"?"Right":""):k1],i0=q1||/^find/.test(k1);J1&&(P0.prototype[k1]=function(){var g0=this.__wrapped__,O0=q1?[1]:arguments,D0=g0 instanceof z2,K0=O0[0],Y0=D0||L2(g0),nd=function(r2){var o2=J1.apply(P0,pm([r2],O0));return q1&&vd?o2[0]:o2};Y0&&T1&&typeof K0=="function"&&K0.length!=1&&(D0=Y0=!1);var vd=this.__chain__,Md=!!this.__actions__.length,Dd=i0&&!vd,Xd=D0&&!Md;if(!i0&&Y0){g0=Xd?g0:new z2(this);var Bd=b1.apply(g0,O0);return Bd.__actions__.push({func:_g,args:[nd],thisArg:t1}),new em(Bd,vd)}return Dd&&Xd?b1.apply(this,O0):(Bd=this.thru(nd),Dd?q1?Bd.value()[0]:Bd.value():Bd)})}),ld(["pop","push","shift","sort","splice","unshift"],function(b1){var k1=v3[b1],T1=/^(?:push|sort|unshift)$/.test(b1)?"tap":"thru",q1=/^(?:pop|shift)$/.test(b1);P0.prototype[b1]=function(){var J1=arguments;if(q1&&!this.__chain__){var i0=this.value();return k1.apply(L2(i0)?i0:[],J1)}return this[T1](function(g0){return k1.apply(L2(g0)?g0:[],J1)})}}),E3(z2.prototype,function(b1,k1){var T1=P0[k1];if(T1){var q1=T1.name+"";U2.call(Lm,q1)||(Lm[q1]=[]),Lm[q1].push({name:k1,func:T1})}}),Lm[Um(t1,g1).name]=[{name:"wrapper",func:t1}],z2.prototype.clone=v8,z2.prototype.reverse=O3,z2.prototype.value=Lh,P0.prototype.at=E8,P0.prototype.chain=B7,P0.prototype.commit=R7,P0.prototype.next=H7,P0.prototype.plant=V7,P0.prototype.reverse=F7,P0.prototype.toJSON=P0.prototype.valueOf=P0.prototype.value=z8,P0.prototype.first=P0.prototype.head,V4&&(P0.prototype[V4]=N7),P0},J_=j6();p_?((p_.exports=J_)._=J_,l5._=J_):d_._=J_}).call(commonjsGlobal)})(lodash$2,lodash$2.exports);var lodashExports=lodash$2.exports;const _=getDefaultExportFromCjs(lodashExports),DEFAULT_CONFIG$1={platformUrl:"",logoUrl:void 0,faviconUrl:void 0,emailBrandingEnabled:!0,testimonialsEnabled:!0,platformTitle:"Budibase",loginHeading:void 0,loginButton:void 0,metaDescription:void 0,metaImageUrl:void 0,metaTitle:void 0,docsUrl:void 0,company:"Budibase",oidc:void 0,google:void 0,googleDatasourceConfigured:void 0,oidcCallbackUrl:"",googleCallbackUrl:"",isSSOEnforced:!1,loaded:!1};function createOrganisationStore(){const n1=writable(DEFAULT_CONFIG$1),{subscribe:e1,set:t1}=n1;async function r1(){const i1=get_store_value(auth).tenantId,a1=await API.getTenantConfig(i1);t1({...DEFAULT_CONFIG$1,...a1.config,loaded:!0})}async function o1(i1){const a1=_.cloneDeep(get_store_value(n1));delete a1.oidc,delete a1.google,delete a1.googleDatasourceConfigured,delete a1.oidcCallbackUrl,delete a1.googleCallbackUrl,delete a1.loaded,await API.saveConfig({type:"settings",config:{...a1,...i1}}),await r1()}return{subscribe:e1,set:t1,save:o1,init:r1}}const organisation=createOrganisationStore();function createUsersStore(){const{subscribe:n1,set:e1}=writable({});async function t1(v1={}){const S1=await API.searchUsers(v1);return e1({...S1,...v1}),S1}async function r1(v1){try{return await API.getUser(v1)}catch{return null}}const o1=async()=>await API.getUsers();async function i1(v1){return await API.onboardUsers(v1)}async function a1(v1){return API.inviteUsers(v1)}async function s1(v1,S1,O1,C1){return API.acceptInvite({inviteCode:v1,password:S1,firstName:O1,lastName:C1!=null&&C1.trim()?C1:void 0})}async function l1(v1){return API.getUserInvite(v1)}async function c1(){return API.getUserInvites()}async function u1(v1){return API.updateUserInvite(v1)}async function f1(v1){let S1=v1.users.map(C1=>{const M1={email:C1.email,password:C1.password,roles:{}};switch(C1.forceResetPassword&&(M1.forceResetPassword=C1.forceResetPassword),C1.role){case"appUser":M1.builder={global:!1},M1.admin={global:!1};break;case"developer":M1.builder={global:!0};break;case"creator":M1.builder={creator:!0,global:!1};break;case"admin":M1.admin={global:!0},M1.builder={global:!0};break}return M1});const O1=await API.createUsers({users:S1,groups:v1.groups});return await t1(),O1}async function d1(v1){await API.deleteUser(v1),lodashExports.update(S1=>S1.filter(O1=>O1._id!==v1))}async function p1({appId:v1}){return await API.getUserCountByApp({appId:v1})}async function m1(v1){return API.deleteUsers(v1)}async function _1(v1){return await API.saveUser(v1)}async function h1(v1,S1){return await API.addAppBuilder({userId:v1,appId:S1})}async function g1(v1,S1){return await API.removeAppBuilder({userId:v1,appId:S1})}const $1=v1=>isAdmin(v1)?BudibaseRoles.Admin:isBuilder(v1)?BudibaseRoles.Developer:hasCreatorPermissions(v1)?BudibaseRoles.Creator:BudibaseRoles.AppUser,y1=v1=>async(...S1)=>{const O1=await v1(...S1);return await licensing.setQuotaUsage(),O1};return{subscribe:n1,search:t1,get:r1,getUserRole:$1,fetch:o1,invite:a1,onboard:i1,fetchInvite:l1,getInvites:c1,updateInvite:u1,getUserCountByApp:p1,addAppBuilder:h1,removeAppBuilder:g1,acceptInvite:s1,create:y1(f1),save:y1(_1),bulkDelete:y1(m1),delete:y1(d1)}}const users=createUsersStore(),DEFAULT_CONFIG={loaded:!1,multiTenancy:!1,cloud:!1,isDev:!1,disableAccountPortal:!1,accountPortalUrl:"",importComplete:!1,checklist:{apps:{checked:!1},smtp:{checked:!1},adminUser:{checked:!1},sso:{checked:!1}},offlineMode:!1};function createAdminStore(){const n1=writable(DEFAULT_CONFIG);async function e1(){await i1(),await t1(),get_store_value(n1).cloud&&(await o1(),r1()),n1.update(s1=>(s1.loaded=!0,s1))}async function t1(){const s1=await API.getEnvironment();n1.update(l1=>(l1.multiTenancy=s1.multiTenancy,l1.cloud=s1.cloud,l1.disableAccountPortal=s1.disableAccountPortal,l1.accountPortalUrl=s1.accountPortalUrl,l1.isDev=s1.isDev,l1.baseUrl=s1.baseUrl,l1.offlineMode=s1.offlineMode,l1))}const r1=async()=>{var l1,c1;const s1=(c1=(l1=get_store_value(n1))==null?void 0:l1.status)==null?void 0:c1.health;s1!=null&&s1.passing||await banner.showStatus()};async function o1(){const s1=await API.getSystemStatus();n1.update(l1=>(l1.status=s1,l1))}async function i1(){const s1=get_store_value(auth).tenantId,l1=await API.getChecklist(s1);n1.update(c1=>(c1.checklist=l1,c1))}function a1(){n1.update(s1=>(s1.loaded=!1,s1))}return{subscribe:n1.subscribe,init:e1,unload:a1,getChecklist:i1}}const admin=createAdminStore(),DEV_PROPS=["updatedBy","updatedAt"],extractAppId=n1=>{const e1=(n1==null?void 0:n1.split("_"))||[];return e1.length?e1[e1.length-1]:null},getProdAppID=n1=>{if(!n1)return n1;let e1,t1="";if(n1.startsWith("app_dev")){const r1=n1.split("app_dev");r1.shift(),e1=r1.join("app_dev")}else if(!n1.startsWith("app"))e1=n1,t1="_";else return n1;return`app${t1}${e1}`};function createAppStore(){const n1=writable([]);async function e1(){const r1=await API.getApps();if(Array.isArray(r1)){let o1={},i1=r1.filter(l1=>l1.status===AppStatus.DEV),a1=r1.filter(l1=>l1.status===AppStatus.DEPLOYED);i1.forEach(l1=>{const c1=extractAppId(l1.appId);o1[c1]={...l1,devId:l1.appId,devRev:l1._rev}}),a1.forEach(l1=>{const c1=extractAppId(l1.appId);if(!o1[c1])return;let u1={};o1[c1]&&Object.entries(o1[c1]).filter(([d1])=>DEV_PROPS.indexOf(d1)!==-1).forEach(d1=>{u1[d1[0]]=d1[1]}),o1[c1]={...o1[c1],...l1,...u1,prodId:l1.appId,prodRev:l1._rev}});const s1=Object.values(o1);s1.forEach(l1=>{l1.appId=extractAppId(l1.devId),delete l1._id,delete l1._rev}),n1.set(s1)}else n1.set([])}async function t1(r1,o1){await API.saveAppMetadata({appId:r1,metadata:o1}),n1.update(i1=>{const a1=i1.findIndex(s1=>s1.instance._id===r1);if(a1!==-1){let s1=i1[a1];s1={...s1,...o1},i1.apps=i1.splice(a1,1,s1)}return i1})}return{subscribe:n1.subscribe,load:e1,update:t1,extractAppId,getProdAppID}}const apps=createAppStore();function createEmailStore(){const n1=writable({});return{subscribe:n1.subscribe,templates:{fetch:async()=>{const e1=await API.getEmailTemplateDefinitions(),t1=await API.getEmailTemplates();n1.set({definitions:e1,templates:t1})},save:async e1=>{const t1=await API.saveEmailTemplate(e1);e1._rev=t1._rev,e1._id=t1._id,n1.update(r1=>{const o1=r1.templates.findIndex(i1=>i1.purpose===t1.purpose);return r1.templates.splice(o1,1,e1),r1})}}}}const email=createEmailStore();function createAuthStore(){const n1=writable({user:null,accountPortalAccess:!1,tenantId:"default",tenantSet:!1,loaded:!1,postLogout:!1}),e1=derived(n1,l1=>{var c1;return{user:l1.user,accountPortalAccess:l1.accountPortalAccess,tenantId:l1.tenantId,tenantSet:l1.tenantSet,loaded:l1.loaded,postLogout:l1.postLogout,isSSO:!!((c1=l1.user)!=null&&c1.provider)}});function t1(l1){n1.update(c1=>(c1.loaded=!0,c1.user=l1,c1.accountPortalAccess=l1==null?void 0:l1.accountPortalAccess,l1&&(c1.tenantId=l1.tenantId||"default",c1.tenantSet=!0),c1)),l1&&analytics.activate().then(()=>{var c1,u1,f1;analytics.identify(l1._id),analytics.showChat({email:l1.email,created_at:(l1.createdAt||Date.now())/1e3,name:(c1=l1.account)==null?void 0:c1.name,user_id:l1._id,tenant:l1.tenantId,admin:isAdmin(l1),builder:isBuilder(l1),"Company size":(u1=l1.account)==null?void 0:u1.size,"Job role":(f1=l1.account)==null?void 0:f1.profession},!!(l1!=null&&l1.account))}).catch(()=>{})}async function r1(l1){const c1=get_store_value(e1).tenantId;n1.update(u1=>(u1.tenantId=l1,u1.tenantSet=!!l1,u1)),c1!==l1&&await admin.init()}async function o1(l1){return await API.setInitInfo(l1),n1.update(c1=>(c1.initInfo=l1,c1)),l1}function i1(){n1.update(l1=>(l1.postLogout=!0,l1))}async function a1(){const l1=await API.getInitInfo();return n1.update(c1=>(c1.initInfo=l1,c1)),l1}const s1={checkQueryString:async()=>{const l1=new URLSearchParams(window.location.search);if(l1.has("tenantId")){const c1=l1.get("tenantId");await r1(c1)}},setOrg:async l1=>{await r1(l1)},getSelf:async()=>{try{const l1=await API.fetchBuilderSelf();t1(l1)}catch{t1(null)}},login:async l1=>{const c1=get_store_value(e1).tenantId;await API.logIn({username:l1.username,password:l1.password,tenantId:c1}),await s1.getSelf()},logout:async()=>{await API.logOut(),i1(),t1(null),await o1({})},updateSelf:async l1=>{await API.updateSelf({...l1});try{const c1=await API.fetchBuilderSelf();t1(c1)}catch{t1(null)}},forgotPassword:async l1=>{const c1=get_store_value(e1).tenantId;await API.requestForgotPassword({tenantId:c1,email:l1})},resetPassword:async(l1,c1)=>{const u1=get_store_value(e1).tenantId;await API.resetPassword({tenantId:u1,password:l1,resetCode:c1})},generateAPIKey:async()=>API.generateAPIKey(),fetchAPIKey:async()=>{const l1=await API.fetchDeveloperInfo();return l1==null?void 0:l1.apiKey}};return{subscribe:e1.subscribe,setOrganisation:r1,getInitInfo:a1,setInitInfo:o1,...s1}}const auth=createAuthStore(),OIDC_CONFIG={logo:void 0,name:void 0,uuid:void 0};function createOidcStore(){const n1=writable(OIDC_CONFIG),{set:e1,subscribe:t1}=n1;return{subscribe:t1,set:e1,init:async()=>{const r1=get_store_value(auth).tenantId,o1=await API.getOIDCConfig(r1);Object.keys(o1||{}).length?e1(...o1):e1(OIDC_CONFIG)}}}const oidc=createOidcStore();function templatesStore(){const{subscribe:n1,set:e1}=writable([]);return{subscribe:n1,load:async()=>{const t1=await API.getAppTemplates();e1(t1)}}}const templates=templatesStore(),ExpiringKeys={LICENSING_DAYPASS_WARNING_MODAL:"licensing_daypass_warning_90_modal",LICENSING_DAYPASS_WARNING_BANNER:"licensing_daypass_warning_90_banner",LICENSING_PAYMENT_FAILED:"licensing_payment_failed",LICENSING_ACCOUNT_DOWNGRADED_MODAL:"licensing_account_downgraded_modal",LICENSING_APP_LIMIT_MODAL:"licensing_app_limit_modal",LICENSING_ROWS_WARNING_BANNER:"licensing_rows_warning_banner",LICENSING_AUTOMATIONS_WARNING_BANNER:"licensing_automations_warning_banner",LICENSING_QUERIES_WARNING_BANNER:"licensing_queries_warning_banner",LICENSING_USERS_ABOVE_LIMIT_BANNER:"licensing_users_above_limit_banner"},StripeStatus={PAST_DUE:"past_due",ACTIVE:"active"},TENANT_FEATURE_FLAGS={LICENSING:"LICENSING",USER_GROUPS:"USER_GROUPS",ONBOARDING_TOUR:"ONBOARDING_TOUR"},isEnabled=n1=>{var t1;const e1=get_store_value(auth).user;return!!((t1=e1==null?void 0:e1.featureFlags)!=null&&t1.includes(n1))},UNLIMITED=-1,createLicensingStore=()=>{const n1={goToUpgradePage:()=>{},goToPricingPage:()=>{},license:void 0,isFreePlan:!0,isEnterprisePlan:!0,isBusinessPlan:!0,groupsEnabled:!1,backupsEnabled:!1,brandingEnabled:!1,scimEnabled:!1,quotaUsage:void 0,usageMetrics:void 0,quotaResetDaysRemaining:void 0,quotaResetDate:void 0,accountPastDue:void 0,pastDueEndDate:void 0,pastDueDaysRemaining:void 0,accountDowngraded:void 0,userCount:void 0,userLimit:void 0,userLimitReached:!1,errUserLimit:!1},e1=864e5,t1=writable(n1);function r1(s1,l1){return l1===UNLIMITED?!1:s1>=l1}function o1(s1,l1){return l1===UNLIMITED?!1:s1>l1}async function i1(){let s1=get_store_value(admin);return s1.loaded||(await admin.init(),s1=get_store_value(admin)),s1.cloud}const a1={init:async()=>{a1.setNavigation(),a1.setLicense(),await a1.setQuotaUsage()},setNavigation:()=>{var d1;const s1=get_store_value(admin),l1=get_store_value(auth),c1=(d1=l1==null?void 0:l1.user)!=null&&d1.accountPortalAccess?`${s1.accountPortalUrl}/portal/upgrade`:"/builder/portal/account/upgrade",u1=()=>{window.location.href=c1},f1=()=>{window.open("https://budibase.com/pricing/","_blank")};t1.update(p1=>({...p1,goToUpgradePage:u1,goToPricingPage:f1}))},setLicense:()=>{const s1=get_store_value(auth).user.license,l1=s1==null?void 0:s1.plan.type,c1=l1===PlanType.ENTERPRISE,u1=l1===PlanType.FREE,f1=l1===PlanType.BUSINESS,d1=s1.features.includes(Feature.USER_GROUPS),p1=s1.features.includes(Feature.APP_BACKUPS),m1=s1.features.includes(Feature.SCIM),_1=s1.features.includes(Feature.ENVIRONMENT_VARIABLES),h1=s1.features.includes(Feature.ENFORCEABLE_SSO),g1=s1.features.includes(Feature.BRANDING),$1=s1.features.includes(Feature.AUDIT_LOGS),y1=s1.features.includes(Feature.SYNC_AUTOMATIONS),v1=s1.features.includes(Feature.APP_BUILDERS),S1=s1.features.includes(Feature.VIEW_PERMISSIONS);t1.update(O1=>({...O1,license:s1,isEnterprisePlan:c1,isFreePlan:u1,isBusinessPlan:f1,groupsEnabled:d1,backupsEnabled:p1,brandingEnabled:g1,scimEnabled:m1,environmentVariablesEnabled:_1,auditLogsEnabled:$1,enforceableSSO:h1,syncAutomationsEnabled:y1,isViewPermissionsEnabled:S1,perAppBuildersEnabled:v1}))},setQuotaUsage:async()=>{const s1=await API.getQuotaUsage();t1.update(l1=>({...l1,quotaUsage:s1})),await a1.setUsageMetrics()},usersLimitReached:s1=>r1(s1,get_store_value(t1).userLimit),usersLimitExceeded(s1){return o1(s1,get_store_value(t1).userLimit)},setUsageMetrics:async()=>{var s1,l1,c1,u1,f1,d1,p1,m1,_1,h1;if(isEnabled(TENANT_FEATURE_FLAGS.LICENSING)){const g1=get_store_value(t1).quotaUsage,$1=get_store_value(auth).user.license,y1=new Date,v1=(X1,W1,n0)=>!W1||!n0||!X1?{}:X1.reduce((s0,l0)=>{const f0=W1[l0].value,e0=n0[l0]/f0*100;return s0[l0]=f0>-1?Math.floor(e0):-1,s0},{}),S1=v1(["dayPasses","queries","automations"],$1.quotas.usage.monthly,g1.monthly.current),O1=v1(["apps","rows"],$1.quotas.usage.static,g1.usageQuota),C1=(X1,W1)=>W1>X1?Math.round((W1.getTime()-X1.getTime())/e1):0,M1=new Date(g1.quotaReset),z1=C1(y1,M1),P1=((l1=(s1=$1==null?void 0:$1.billing)==null?void 0:s1.subscription)==null?void 0:l1.downgradeAt)&&((u1=(c1=$1==null?void 0:$1.billing)==null?void 0:c1.subscription)==null?void 0:u1.downgradeAt)<=y1.getTime()&&((d1=(f1=$1==null?void 0:$1.billing)==null?void 0:f1.subscription)==null?void 0:d1.status)===StripeStatus.PAST_DUE&&($1==null?void 0:$1.plan.type)===PlanType.FREE,R1=(m1=(p1=$1==null?void 0:$1.billing)==null?void 0:p1.subscription)==null?void 0:m1.pastDueAt,N1=(h1=(_1=$1==null?void 0:$1.billing)==null?void 0:_1.subscription)==null?void 0:h1.downgradeAt;let F1,B1;R1&&N1&&(B1=new Date(N1),F1=C1(new Date(R1),B1));const L1=$1.quotas.usage.static.users,U1=L1==null?void 0:L1.value,j1=g1.usageQuota.users,Q1=r1(j1,U1),G1=o1(j1,U1),t0=await i1()&&$1.plan.model===PlanModel$1.PER_USER&&G1;t1.update(X1=>({...X1,usageMetrics:{...S1,...O1},quotaResetDaysRemaining:z1,quotaResetDate:M1,accountDowngraded:P1,accountPastDue:R1!=null,pastDueEndDate:B1,pastDueDaysRemaining:F1,userCount:j1,userLimit:U1,userLimitReached:Q1,errUserLimit:t0}))}}};return{subscribe:t1.subscribe,...a1}},licensing=createLicensingStore();function createGroupsStore(){const n1=writable([]),e1=o1=>{n1.update(i1=>{const a1=i1.findIndex(s1=>s1._id===o1._id);return a1>=0?i1.splice(a1,1,o1):i1.push(o1),i1})},t1=async o1=>{const i1=await API.getGroup(o1);e1(i1)},r1={init:async()=>{if(get_store_value(licensing).groupsEnabled){const o1=await API.getGroups();n1.set(o1.data)}},get:t1,save:async o1=>{const i1=await API.saveGroup(o1);return o1._id=i1._id,o1._rev=i1._rev,e1(o1),o1},delete:async o1=>{await API.deleteGroup({id:o1._id,rev:o1._rev}),n1.update(i1=>(i1=i1.filter(a1=>a1._id!==o1._id),i1))},addUser:async(o1,i1)=>{await API.addUsersToGroup(o1,i1),await t1(o1)},removeUser:async(o1,i1)=>{await API.removeUsersFromGroup(o1,i1),await t1(o1)},addApp:async(o1,i1,a1)=>{await API.addAppsToGroup(o1,[{appId:i1,roleId:a1}]),await t1(o1)},removeApp:async(o1,i1)=>{await API.removeAppsFromGroup(o1,[{appId:i1}]),await t1(o1)},getGroupAppIds:o1=>{var a1;let i1=Object.keys((o1==null?void 0:o1.roles)||{});return(a1=o1==null?void 0:o1.builder)!=null&&a1.apps&&(i1=i1.concat(o1.builder.apps)),i1},addGroupAppBuilder:async(o1,i1)=>await API.addGroupAppBuilder({groupId:o1,appId:i1}),removeGroupAppBuilder:async(o1,i1)=>await API.removeGroupAppBuilder({groupId:o1,appId:i1})};return{subscribe:n1.subscribe,actions:r1}}const groups=createGroupsStore();function createPluginsStore(){const{subscribe:n1,set:e1,update:t1}=writable([]);async function r1(){const s1=await API.getPlugins();e1(s1)}async function o1(s1){await API.deletePlugin(s1),t1(l1=>(l1=l1.filter(c1=>c1._id!==s1),l1))}async function i1(s1,l1,c1=null){let u1={source:s1,url:l1};switch(s1){case PluginSource.URL:u1.headers=c1;break;case PluginSource.GITHUB:u1.githubToken=c1;break}let d1=(await API.createPlugin(u1)).plugin;t1(p1=>{const m1=p1.findIndex(_1=>_1._id===d1._id);return m1>=0?p1.splice(m1,1,d1):p1.push(d1),p1})}async function a1(s1){if(!s1)return;let l1=new FormData;l1.append("file",s1);let u1=(await API.uploadPlugin(l1)).plugins[0];t1(f1=>{const d1=f1.findIndex(p1=>p1._id===u1._id);return d1>=0?f1.splice(d1,1,u1):f1.push(u1),f1})}return{subscribe:n1,load:r1,createPlugin:i1,deletePlugin:o1,uploadPlugin:a1}}const plugins$1=createPluginsStore();function createBackupsStore(){const n1=writable({});function e1(s1){n1.update(l1=>(l1.selectedBackup=s1,l1))}async function t1({appId:s1,trigger:l1,type:c1,page:u1,startDate:f1,endDate:d1}){return API.searchBackups({appId:s1,trigger:l1,type:c1,page:u1,startDate:f1,endDate:d1})}async function r1({appId:s1,backupId:l1,name:c1}){return API.restoreBackup({appId:s1,backupId:l1,name:c1})}async function o1({appId:s1,backupId:l1}){return API.deleteBackup({appId:s1,backupId:l1})}async function i1(s1){return API.createManualBackup(s1)}async function a1({appId:s1,backupId:l1,name:c1}){return API.updateBackup({appId:s1,backupId:l1,name:c1})}return{createManualBackup:i1,searchBackups:t1,selectBackup:e1,deleteBackup:o1,restoreBackup:r1,updateBackup:a1,subscribe:n1.subscribe}}const backups=createBackupsStore();function createEnvironmentStore(){const{subscribe:n1,update:e1}=writable({variables:[],status:{}});async function t1(){const l1=await API.checkEnvironmentVariableStatus();e1(c1=>(c1.status=l1,c1))}async function r1(){if(get_store_value(licensing).environmentVariablesEnabled){const c1=(await API.fetchEnvironmentVariables()).variables.map(u1=>({name:u1}));e1(u1=>(u1.variables=c1,u1))}}async function o1(l1){await API.createEnvironmentVariable(l1);let c1={name:l1.name};e1(u1=>(u1.variables=[c1,...u1.variables],u1))}async function i1(l1){await API.deleteEnvironmentVariable(l1),e1(c1=>(c1.variables=c1.variables.filter(u1=>u1.name!==l1),c1))}async function a1(l1){await API.updateEnvironmentVariable(l1)}async function s1(){await API.publishEvent(EventPublishType.ENV_VAR_UPGRADE_PANEL_OPENED)}return{subscribe:n1,checkStatus:t1,loadVariables:r1,createVariable:o1,deleteVariable:i1,updateVariable:a1,upgradePanelOpened:s1}}const environment=createEnvironmentStore(),menu=derived([admin,auth],([n1,e1])=>{const t1=e1==null?void 0:e1.user,r1=isAdmin(t1),o1=n1==null?void 0:n1.cloud;let i1=[{title:"Users",href:"/builder/portal/users/users"}];isEnabled(TENANT_FEATURE_FLAGS.USER_GROUPS)&&i1.push({title:"Groups",href:"/builder/portal/users/groups"});let a1=[{title:"Apps",href:"/builder/portal/apps"}];if(isGlobalBuilder(t1)&&(a1.push({title:"Users",href:"/builder/portal/users",subPages:i1}),a1.push({title:"Plugins",href:"/builder/portal/plugins"})),r1){let s1=[{title:"Auth",href:"/builder/portal/settings/auth"},{title:"Email",href:"/builder/portal/settings/email"},{title:"Organisation",href:"/builder/portal/settings/organisation"},{title:"Branding",href:"/builder/portal/settings/branding"},{title:"Environment",href:"/builder/portal/settings/environment"}];o1||(s1.push({title:"Version",href:"/builder/portal/settings/version"}),s1.push({title:"Diagnostics",href:"/builder/portal/settings/diagnostics"})),a1.push({title:"Settings",href:"/builder/portal/settings",subPages:s1})}if(isEnabled(TENANT_FEATURE_FLAGS.LICENSING)){let s1=[{title:"Usage",href:"/builder/portal/account/usage"}];r1&&(s1.push({title:"Audit Logs",href:"/builder/portal/account/auditLogs"}),o1||s1.push({title:"System Logs",href:"/builder/portal/account/systemLogs"})),o1&&(t1!=null&&t1.accountPortalAccess)?s1.push({title:"Upgrade",href:(n1==null?void 0:n1.accountPortalUrl)+"/portal/upgrade"}):!o1&&r1&&s1.push({title:"Upgrade",href:"/builder/portal/account/upgrade"}),t1!=null&&t1.accountPortalAccess&&t1.account.stripeCustomerId&&s1.push({title:"Billing",href:(n1==null?void 0:n1.accountPortalUrl)+"/portal/billing"}),a1.push({title:"Account",href:"/builder/portal/account",subPages:s1})}return a1});function createAuditLogsStore(){const{subscribe:n1,update:e1}=writable({events:{},logs:{}});async function t1(i1={}){if(get_store_value(licensing).auditLogsEnabled){const a1=await API.searchAuditLogs(i1);return e1(s1=>({...s1,logs:{...a1,opts:i1}})),a1}}async function r1(){const i1=await API.getEventDefinitions();e1(a1=>({...a1,...i1}))}function o1(i1={}){return API.getDownloadUrl(i1)}return{subscribe:n1,search:t1,getEventDefinitions:r1,getDownloadUrl:o1}}const auditLogs=createAuditLogsStore(),createFeatureStore=()=>{const n1=writable({scim:{isFeatureFlagEnabled:!1,isConfigFlagEnabled:!1}}),e1=writable({isScimEnabled:!1});n1.subscribe(r1=>{e1.update(o1=>({...o1,isScimEnabled:r1.scim.isFeatureFlagEnabled&&r1.scim.isConfigFlagEnabled}))}),licensing.subscribe(r1=>{n1.update(o1=>({...o1,scim:{...o1.scim,isFeatureFlagEnabled:r1.scimEnabled}}))});const t1={init:async()=>{const r1=await API.getConfig(ConfigType.SCIM);n1.update(o1=>{var i1;return{...o1,scim:{...o1.scim,isConfigFlagEnabled:(i1=r1==null?void 0:r1.config)==null?void 0:i1.enabled}}})}};return{subscribe:e1.subscribe,...t1}},features=createFeatureStore(),sideBarCollapsed=writable(!1),convertOldFieldFormat=n1=>n1?n1.map(t1=>typeof t1=="string"?{field:t1,active:!0}:typeof(t1==null?void 0:t1.active)!="boolean"?{field:t1.name,active:!0}:t1):[],getComponentForField=(n1,e1)=>{if(!n1||!(e1!=null&&e1[n1]))return null;const t1=e1[n1].type;return FieldTypeToComponentMap[t1]},FieldTypeToComponentMap={string:"stringfield",number:"numberfield",bigint:"bigintfield",options:"optionsfield",array:"multifieldselect",boolean:"booleanfield",longform:"longformfield",datetime:"datetimefield",attachment:"attachmentfield",link:"relationshipfield",json:"jsonfield",barcodeqr:"codescanner",bb_reference:"bbreferencefield"},CAPTURE_VAR_INSIDE_TEMPLATE=/{{([^}]+)}}/g,CAPTURE_VAR_INSIDE_JS=/\$\("([^")]+)"\)/g,UpdateReferenceAction={ADD:"add",DELETE:"delete",MOVE:"move"},getBindableProperties=(n1,e1)=>{const t1=getContextBindings(n1,e1),r1=getUserBindings(),o1=getUrlBindings(n1),i1=getDeviceBindings(),a1=getStateBindings(),s1=getSelectedRowsBindings(n1),l1=getRoleBindings();return[...t1,...o1,...a1,...r1,...i1,...s1,...l1]},getRestBindings=()=>{const n1=get_store_value(licensing).environmentVariablesEnabled;return[...getUserBindings(),...getAuthBindings(),...n1?getEnvironmentBindings():[]]},getAuthBindings=()=>{let n1=[];const e1=jh("user"),t1=jh("oauth2"),r1=jh("accessToken");return n1=[{runtime:`${e1}.${t1}.${r1}`,readable:"Current User.OAuthToken",key:"accessToken",display:{name:"OAuthToken",type:"text"}}].map(i1=>({type:"context",runtimeBinding:i1.runtime,readableBinding:i1.readable,fieldSchema:{type:"string",name:i1.key},providerId:"user",category:"Current User",display:i1.display})),n1},getEnvironmentBindings=()=>get_store_value(environment).variables.map(e1=>({type:"context",runtimeBinding:`env.${jh(e1.name)}`,readableBinding:`env.${e1.name}`,category:"Environment",icon:"Key",display:{type:"string",name:e1.name}})),toBindingsArray=(n1,e1,t1)=>n1?Object.keys(n1).reduce((r1,o1)=>{if(!o1)return r1;let i1={type:"context",runtimeBinding:o1,readableBinding:`${e1}.${o1}`,icon:"Brackets"};return t1&&(i1.category=t1),r1.push(i1),r1},[]):[],readableToRuntimeMap=(n1,e1)=>!n1||!e1?{}:Object.keys(e1).reduce((t1,r1)=>(t1[r1]=readableToRuntimeBinding(n1,e1[r1]),t1),{}),runtimeToReadableMap=(n1,e1)=>!n1||!e1?{}:Object.keys(e1).reduce((t1,r1)=>(t1[r1]=runtimeToReadableBinding(n1,e1[r1]),t1),{}),getComponentBindableProperties=(n1,e1)=>{if(!n1||!e1)return[];const t1=findComponent(n1.props,e1),r1=store.actions.components.getDefinition(t1==null?void 0:t1._component);return r1!=null&&r1.context?getProviderContextBindings(n1,t1):[]},getContextProviderComponents=(n1,e1,t1,r1={includeSelf:!1})=>{if(!n1||!e1)return[];const o1=findComponentPath(n1.props,e1);return r1!=null&&r1.includeSelf||o1.pop(),o1.filter(i1=>{const a1=store.actions.components.getDefinition(i1._component);return a1!=null&&a1.context?t1?(Array.isArray(a1.context)?a1.context:[a1.context]).find(l1=>l1.type===t1)!=null:!0:!1})},getActionProviders=(n1,e1,t1,r1={includeSelf:!1})=>{if(!n1||!e1)return[];const o1=findComponentPath(n1.props,e1);r1!=null&&r1.includeSelf||o1.pop();let i1=[];return o1.forEach(a1=>{const s1=store.actions.components.getDefinition(a1._component),c1=((s1==null?void 0:s1.actions)||[]).map(u1=>typeof u1=="string"?{type:u1}:u1).find(u1=>u1.type===t1);if(c1){let u1=a1._id;c1.suffix&&(u1+=`-${c1.suffix}`),i1.push({readableBinding:a1._instanceName,runtimeBinding:u1})}}),i1},getDatasourceForProvider=(n1,e1)=>{const t1=getComponentSettings(e1==null?void 0:e1._component),r1=t1.find(s1=>s1.type==="dataProvider");if(r1){const s1=e1[r1.key],l1=extractLiteralHandlebarsID(s1),c1=findComponent(n1==null?void 0:n1.props,l1);return getDatasourceForProvider(n1,c1)}const o1=["dataSource","table","schema"],i1=t1.find(s1=>o1.includes(s1.type));if(!i1)return null;const a1=e1[i1==null?void 0:i1.key];return typeof a1=="string"?{tableId:a1,type:"table"}:a1},getContextBindings=(n1,e1)=>{const t1=getContextProviderComponents(n1,e1);return getProviderContextBindings(n1,t1)},getProviderContextBindings=(n1,e1)=>{if(!n1||!e1)return[];Array.isArray(e1)||(e1=[e1]);let t1=[];return e1.forEach(r1=>{const o1=store.actions.components.getDefinition(r1._component);(Array.isArray(o1.context)?o1.context:[o1.context]).forEach(a1=>{var m1;if(!(a1!=null&&a1.type))return;let s1,l1,c1,u1=a1.suffix;if(a1.type==="form")s1=buildFormSchema(r1,n1),c1="Fields";else if(a1.type==="static")s1={},(a1.values||[]).forEach(h1=>{s1[h1.key]={name:h1.label,type:h1.type||"string"}});else if(a1.type==="schema"){const _1=getDatasourceForProvider(n1,r1);if(!_1)return;const h1=getSchemaForDatasource(n1,_1);if(s1=h1.schema,l1=h1.table,_1.type==="jsonarray"){const g1=_1.label.split(".");c1=g1[g1.length-1]}else if(_1.type==="viewV2"){const g1=Object.values((l1==null?void 0:l1.views)||{}).find($1=>$1.id===_1.id);c1=g1==null?void 0:g1.name}else c1=(m1=h1.table)==null?void 0:m1.name}if(!s1)return;const f1=Object.keys(s1).sort();let d1=r1._id;if(u1&&(d1+=`-${u1}`),!filterCategoryByContext(r1,a1))return;const p1=jh(d1);f1.forEach(_1=>{const h1=s1[_1],g1=_1.split(".").map(jh).join("."),$1=`${p1}.${g1}`;let y1=r1._instanceName;c1&&(y1+=`.${c1}`),y1+=`.${h1.name||_1}`;const v1=getComponentBindingCategory(r1,a1,o1);t1.push({type:"context",runtimeBinding:$1,readableBinding:y1,fieldSchema:h1,providerId:d1,tableId:l1==null?void 0:l1._id,component:r1._component,category:v1.category,icon:v1.icon,display:{name:h1.name||_1,type:h1.type}})})})}),t1},filterCategoryByContext=(n1,e1)=>{const{_component:t1}=n1;return!(t1.endsWith("formblock")&&(n1.actionType=="Create"&&e1.type==="schema"||n1.actionType=="View"&&e1.type==="form"))},getComponentBindingCategory=(n1,e1,t1)=>{let r1=t1.icon,o1=n1._instanceName;if(n1._component.endsWith("formblock")){let i1={form:"Fields",schema:"Row"};o1=`${n1._instanceName} - ${i1[e1.type]}`,r1=e1.type==="form"?"Form":"Data"}return{icon:r1,category:o1}},getUserBindings=()=>{let n1=[];const{schema:e1}=getSchemaForDatasourcePlus(TableNames.USERS),t1=Object.keys(e1).sort(),r1=jh("user");return n1=t1.reduce((o1,i1)=>{const a1=e1[i1];return o1.push({type:"context",runtimeBinding:`${r1}.${jh(i1)}`,readableBinding:`Current User.${i1}`,fieldSchema:a1,providerId:"user",category:"Current User",icon:"User",display:{name:i1}}),o1},[]),n1},getDeviceBindings=()=>{var e1;let n1=[];if((e1=get_store_value(store).clientFeatures)!=null&&e1.deviceAwareness){const t1=jh("device");n1=[{type:"context",runtimeBinding:`${t1}.${jh("mobile")}`,readableBinding:"Device.Mobile",category:"Device",icon:"DevicePhone",display:{type:"boolean",name:"mobile"}},{type:"context",runtimeBinding:`${t1}.${jh("tablet")}`,readableBinding:"Device.Tablet",category:"Device",icon:"DevicePhone",display:{type:"boolean",name:"tablet"}},{type:"context",runtimeBinding:`${t1}.${jh("theme")}`,readableBinding:"App.Theme",category:"Device",icon:"DevicePhone",display:{type:"string",name:"App Theme"}}]}return n1},getSelectedRowsBindings=n1=>{var t1;let e1=[];if((t1=get_store_value(store).clientFeatures)!=null&&t1.rowSelection){let r1=findAllMatchingComponents(n1==null?void 0:n1.props,a1=>a1._component.endsWith("table"));const o1=jh("rowSelection");e1=e1.concat(r1.map(a1=>({type:"context",runtimeBinding:`${o1}.${jh(a1._id)}.${jh("selectedRows")}`,readableBinding:`${a1._instanceName}.Selected rows`,category:"Selected rows",icon:"ViewRow",display:{name:a1._instanceName}})));let i1=findAllMatchingComponents(n1==null?void 0:n1.props,a1=>a1._component.endsWith("tableblock"));e1=e1.concat(i1.map(a1=>({type:"context",runtimeBinding:`${o1}.${jh(a1._id+"-table")}.${jh("selectedRows")}`,readableBinding:`${a1._instanceName}.Selected rows`,category:"Selected rows",icon:"ViewRow",display:{name:a1._instanceName}})))}return e1},makeStateBinding=n1=>({type:"context",runtimeBinding:`${jh("state")}.${jh(n1)}`,readableBinding:`State.${n1}`,category:"State",icon:"AutomatedSegment",display:{name:n1}}),getStateBindings=()=>{var e1;let n1=[];return(e1=get_store_value(store).clientFeatures)!=null&&e1.state&&(n1=getAllStateVariables().map(makeStateBinding)),n1},getUrlBindings=n1=>{var s1;const t1=(((s1=n1==null?void 0:n1.routing)==null?void 0:s1.route)??"").split("/");let r1=[];t1.forEach(l1=>{l1.startsWith(":")&&l1.length>1&&r1.push(l1.replace(/:/g,"").replace(/\?/g,""))});const o1=jh("url"),i1=r1.map(l1=>({type:"context",runtimeBinding:`${o1}.${jh(l1)}`,readableBinding:`URL.${l1}`,category:"URL",icon:"RailTop",display:{type:"string",name:l1}})),a1={type:"context",runtimeBinding:jh("query"),readableBinding:"Query params",category:"URL",icon:"RailTop",display:{type:"object",name:"Query params"}};return i1.concat([a1])},getRoleBindings=()=>(get_store_value(roles)||[]).map(n1=>({type:"context",runtimeBinding:`trim "${n1._id}"`,readableBinding:`Role.${n1.name}`,category:"Role",icon:"UserGroup",display:{type:"string",name:n1.name}})),getEventContextBindings=({settingKey:n1,componentInstance:e1,componentId:t1,componentDefinition:r1,asset:o1})=>{var f1;let i1=[];const a1=o1??get_store_value(currentAsset),s1=e1??findComponent(a1.props,t1);if(!s1)return i1;const l1=r1??store.actions.components.getDefinition(s1==null?void 0:s1._component),u1=getComponentSettings(s1==null?void 0:s1._component).find(d1=>d1.key===n1);return(f1=u1==null?void 0:u1.context)!=null&&f1.length&&u1.context.forEach(d1=>{i1.push({readableBinding:d1.label,runtimeBinding:`${jh("eventContext")}.${jh(d1.key)}`,category:s1._instanceName,icon:l1.icon,display:{name:d1.label}})}),i1},getActionBindings=(n1,e1)=>{let t1=[];const r1=n1==null?void 0:n1.findIndex(i1=>i1.id===e1);return r1==null||r1===-1||n1.slice(0,r1).forEach((i1,a1)=>{const s1=ActionDefinitions.actions.find(l1=>l1.name===i1["##eventHandlerType"]);s1.context&&s1.context.forEach(l1=>{t1.push({readableBinding:`Action ${a1+1}.${l1.label}`,runtimeBinding:`actions.${a1}.${l1.value}`,category:"Actions",icon:"JourneyAction",display:{name:l1.label}})})}),t1},getSchemaForDatasourcePlus=(n1,e1)=>{const r1=(n1==null?void 0:n1.includes("view_"))?{type:"viewV2",id:n1,tableId:n1.split("_").slice(1,3).join("_")}:{type:"table",tableId:n1};return getSchemaForDatasource(null,r1,e1)},getSchemaForDatasource=(n1,e1,t1)=>{var i1,a1;t1=t1||{};let r1,o1;if(e1){const{type:s1}=e1,l1=get_store_value(tables).list;if(s1==="provider"){const m1=findComponent(n1==null?void 0:n1.props,e1.providerId),_1=getDatasourceForProvider(n1,m1);return getSchemaForDatasource(n1,_1,t1)}else if(s1==="query")o1=get_store_value(queries).list.find(_1=>_1._id===e1._id);else if(s1==="field"){o1={name:e1.fieldName};const{fieldType:m1}=e1;m1==="attachment"?r1={url:{type:"string"},name:{type:"string"}}:m1==="array"&&(r1={value:{type:"string"}})}else if(s1==="jsonarray"){o1=l1.find(_1=>_1._id===e1.tableId);let m1=o1==null?void 0:o1.schema;r1=getJSONArrayDatasourceSchema(m1,e1)}else o1=l1.find(m1=>m1._id===e1.tableId);if(o1&&!r1)if(s1==="view")r1=fp$1.cloneDeep((a1=(i1=o1.views)==null?void 0:i1[e1.name])==null?void 0:a1.schema);else if(s1==="viewV2"){const m1=Object.values(o1.views||{}).find(_1=>_1.id===e1.id);r1=fp$1.cloneDeep(m1==null?void 0:m1.schema),Object.keys(r1||{}).forEach(_1=>{r1[_1].visible||delete r1[_1]})}else s1==="query"&&(t1.formSchema||t1.searchableSchema)?(r1={},(o1.parameters||[]).forEach(_1=>{_1!=null&&_1.name&&(r1[_1.name]={..._1,type:"string"})})):r1=fp$1.cloneDeep(o1.schema);if(r1){let m1={};Object.keys(r1).forEach(_1=>{const h1=r1[_1];if((h1==null?void 0:h1.type)==="json"){const g1=convertJSONSchemaToTableSchema(h1,{squashObjects:!0});Object.keys(g1).forEach($1=>{m1[`${_1}.${$1}`]={type:g1[$1].type,nestedJSON:!0}})}}),r1={...r1,...m1}}const c1=o1&&!o1.sql,u1=["table","link","viewV2"].includes(e1.type);let f1=u1,d1=u1&&c1;t1.formSchema?(f1=!1,d1=!1):t1.searchableSchema&&(f1=u1&&c1),r1&&(f1&&(r1._id={type:"string"}),d1&&(r1._rev={type:"string"}));let p1={};Object.entries(r1||{}).forEach(([m1,_1])=>{typeof _1=="string"?p1[m1]={type:_1,name:m1}:p1[m1]={..._1,name:m1}}),r1=p1}return{schema:r1,table:o1}},buildFormSchema=(n1,e1)=>{var i1;let t1={};if(!n1)return t1;if(n1._component.endsWith("formblock")){let a1={};const s1=getDatasourceForProvider(e1,n1),l1=getSchemaForDatasource(n1,s1);if(!(l1!=null&&l1.schema))return a1;if(!n1.fields)Object.values(l1.schema).filter(({autocolumn:c1,name:u1})=>!c1&&!["_rev","_id"].includes(u1)).forEach(({name:c1})=>{a1[c1]={type:l1==null?void 0:l1.schema[c1].type}});else{const c1=convertOldFieldFormat(n1.fields||[]);c1==null||c1.forEach(({field:u1,active:f1})=>{f1&&l1!=null&&l1.schema[u1]&&(a1[u1]={type:l1==null?void 0:l1.schema[u1].type})})}return a1}const o1=getComponentSettings(n1._component).find(a1=>a1.key==="field"&&a1.type.startsWith("field/"));if(o1&&n1.field){const a1=o1.type.split("field/")[1];a1&&(t1[n1.field]={type:a1})}return(i1=n1._children)==null||i1.forEach(a1=>{const s1=buildFormSchema(a1,e1);t1={...t1,...s1}}),t1},getAllStateVariables=()=>{let n1=[];getAllAssets().forEach(t1=>{findAllMatchingComponents(t1.props,r1=>{getComponentSettings(r1._component).filter(i1=>i1.type==="event").forEach(i1=>{n1.push(r1[i1.key])})})}),get_store_value(store).screens.forEach(t1=>{t1.onLoad&&n1.push(t1.onLoad)});let e1=new Set;return n1.forEach(t1=>{Array.isArray(t1)&&t1.forEach(r1=>{var o1,i1,a1;r1["##eventHandlerType"]==="Update State"&&((o1=r1.parameters)==null?void 0:o1.type)==="set"&&((i1=r1.parameters)!=null&&i1.key)&&((a1=r1.parameters)!=null&&a1.value)&&e1.add(r1.parameters.key)})}),Array.from(e1)},getAllAssets=()=>{let n1=[];return n1=n1.concat(get_store_value(store).layouts||[]),n1=n1.concat(get_store_value(store).screens||[]),n1},shouldReplaceBinding=(n1,e1,t1,r1)=>{if(!(n1!=null&&n1.includes(e1)))return!1;if(t1==="readableBinding")return n1.indexOf(r1.readableBinding)===-1;const o1=n1.replace(/\s+/g,""),i1=e1.replace(/\s+/g,"");return![`[${i1}]`,`"${i1}"`,`'${i1}'`].find(s1=>o1==null?void 0:o1.includes(s1))},replaceBetween=(n1,e1,t1,r1)=>n1.substring(0,e1)+r1+n1.substring(t1),bindingReplacement=(n1,e1,t1)=>{const r1=Rh(e1);r1&&(e1=Mh(e1));const o1=r1?CAPTURE_VAR_INSIDE_JS:CAPTURE_VAR_INSIDE_TEMPLATE,i1=t1==="runtimeBinding"?"readableBinding":"runtimeBinding";if(typeof e1!="string")return e1;const a1=n1.map(c1=>c1[i1]).sort((c1,u1)=>u1.length-c1.length),s1=e1.match(o1)||[];let l1=e1;for(let c1 of s1){let u1=c1,f1=u1;for(let d1 of a1){const p1=n1.find(m1=>m1[i1]===d1);if(r1||shouldReplaceBinding(u1,d1,t1,p1)){let m1;do if(m1=f1.indexOf(d1),m1!==-1){let _1=m1+d1.length,h1=Array(p1[t1].length+1).join("*");f1=replaceBetween(f1,m1,_1,h1),u1=replaceBetween(u1,m1,_1,p1[t1])}while(m1!==-1)}}l1=l1.replace(c1,u1)}return r1&&(l1=Ph(l1)),l1},extractLiteralHandlebarsID=n1=>{var e1;return!n1||typeof n1!="string"?null:(e1=n1.match(/{{\s*literal\s*\[+([^\]]+)].*}}/))==null?void 0:e1[1]},readableToRuntimeBinding=(n1,e1)=>bindingReplacement(n1,e1,"runtimeBinding"),runtimeToReadableBinding=(n1,e1)=>bindingReplacement(n1,e1,"readableBinding"),updateReferencesInObject=({obj:n1,modifiedIndex:e1,action:t1,label:r1,originalIndex:o1})=>{const i1=new RegExp(`{{\\s*${r1}\\.(\\d+)\\.`,"g"),a1=(s1,l1,c1)=>s1.replace(`{{ ${r1}.${l1}.`,`{{ ${r1}.${c1}.`);for(const s1 in n1)if(typeof n1[s1]=="string"){let l1;for(;(l1=i1.exec(n1[s1]))!==null;){const c1=parseInt(l1[1]);t1===UpdateReferenceAction.ADD&&c1>=e1?n1[s1]=a1(n1[s1],c1,c1+1):t1===UpdateReferenceAction.DELETE&&c1>e1?n1[s1]=a1(n1[s1],c1,c1-1):t1===UpdateReferenceAction.MOVE&&(c1===o1?n1[s1]=a1(n1[s1],c1,e1):e1<=c1&&e1<o1?n1[s1]=a1(n1[s1],c1,c1+1):e1>=c1&&e1>o1&&(n1[s1]=a1(n1[s1],c1,c1-1)))}}else typeof n1[s1]=="object"&&n1[s1]!==null&&updateReferencesInObject({obj:n1[s1],modifiedIndex:e1,action:t1,label:r1,originalIndex:o1})},getComponentFieldOptions=(n1,e1,t1,r1=!0)=>{const o1=findClosestMatchingComponent(n1,e1,l1=>l1._component==="@budibase/standard-components/form"),i1=getDatasourceForProvider(n1,o1),a1=getSchemaForDatasource(n1,i1,{formSchema:!0}).schema;let s1=[t1];return r1&&(t1==="field/options"||t1==="field/longform")&&(s1=[t1,"field/string"]),s1=s1.map(l1=>l1.slice(l1.indexOf("/")+1)),Object.entries(a1||{}).filter(l1=>s1.includes(l1[1].type)).map(l1=>l1[0])},createBuilderWebsocket=n1=>{const e1=createWebsocket("/socket/builder");return e1.on("connect",()=>{e1.emit(BuilderSocketEvent.SelectApp,{appId:n1},({users:t1})=>{userStore.actions.init(t1)})}),e1.on("connect_error",t1=>{console.log("Failed to connect to builder websocket:",t1.message)}),e1.on("disconnect",()=>{userStore.actions.reset()}),e1.onOther(SocketEvent.UserUpdate,({user:t1})=>{userStore.actions.updateUser(t1)}),e1.onOther(SocketEvent.UserDisconnect,({sessionId:t1})=>{userStore.actions.removeUser(t1)}),e1.onOther(BuilderSocketEvent.LockTransfer,({userId:t1})=>{var r1,o1;t1===((o1=(r1=get_store_value(auth))==null?void 0:r1.user)==null?void 0:o1._id)&&store.update(i1=>({...i1,hasLock:!0}))}),e1.onOther(BuilderSocketEvent.TableChange,({id:t1,table:r1})=>{tables.replaceTable(t1,r1)}),e1.onOther(BuilderSocketEvent.DatasourceChange,({id:t1,datasource:r1})=>{datasources.replaceDatasource(t1,r1)}),e1.onOther(BuilderSocketEvent.ScreenChange,({id:t1,screen:r1})=>{store.actions.screens.replace(t1,r1)}),e1.onOther(BuilderSocketEvent.AppMetadataChange,({metadata:t1})=>{store.actions.metadata.replace(t1)}),e1.onOther(BuilderSocketEvent.AppPublishChange,async({user:t1,published:r1})=>{await apps.load(),r1&&await deploymentStore.actions.load();const o1=r1?"published":"unpublished";notifications.success(`${getUserLabel(t1)} ${o1} this app`)}),e1.onOther(BuilderSocketEvent.AutomationChange,({id:t1,automation:r1})=>{automationStore.actions.replace(t1,r1)}),e1},INITIAL_FRONTEND_STATE={initialised:!1,apps:[],name:"",url:"",description:"",layouts:[],screens:[],components:[],clientFeatures:{spectrumThemes:!1,intelligentLoading:!1,deviceAwareness:!1,state:!1,rowSelection:!1,customThemes:!1,devicePreview:!1,messagePassing:!1,continueIfAction:!1,showNotificationAction:!1,sidePanel:!1},features:{componentValidation:!1,disableUserMetadata:!1},errors:[],hasAppPackage:!1,libraries:null,appId:"",routes:{},clientLibPath:"",theme:"",customTheme:{},previewDevice:"desktop",highlightedSettingKey:null,propertyFocus:null,builderSidePanel:!1,hasLock:!0,showPreview:!1,selectedScreenId:null,selectedComponentId:null,selectedLayoutId:null,selectedComponentInstance:null,onboarding:!1,tourNodes:null},getFrontendStore=()=>{const n1=writable({...INITIAL_FRONTEND_STATE});let e1;const t1=sequential(async(r1,o1)=>{const a1=get_store_value(n1).screens.find(c1=>c1._id===o1);if(!a1)return;let s1=fp$1.cloneDeep(a1);if(r1(s1)!==!1)return await n1.actions.screens.save(s1)});return n1.actions={reset:()=>{n1.set({...INITIAL_FRONTEND_STATE}),e1==null||e1.disconnect(),e1=null},initialise:async r1=>{const{layouts:o1,screens:i1,application:a1,clientLibPath:s1,hasLock:l1}=r1;e1||(e1=createBuilderWebsocket(a1.appId)),await n1.actions.components.refreshDefinitions(a1.appId),n1.update(c1=>({...c1,libraries:a1.componentLibraries,name:a1.name,description:a1.description,appId:a1.appId,url:a1.url,layouts:o1||[],screens:i1||[],theme:a1.theme||"spectrum--light",customTheme:a1.customTheme,hasAppPackage:!0,appInstance:a1.instance,clientLibPath:s1,previousTopNavPath:{},version:a1.version,revertableVersion:a1.revertableVersion,upgradableVersion:a1.upgradableVersion,navigation:a1.navigation||{},usedPlugins:a1.usedPlugins||[],hasLock:l1,features:{...INITIAL_FRONTEND_STATE.features,...a1.features},icon:a1.icon||{},initialised:!0})),screenHistoryStore.reset(),automationHistoryStore.reset(),database.set(a1.instance),await datasources.init(),await integrations.init(),await queries.init(),await tables.init()},theme:{save:async r1=>{const o1=get_store_value(n1).appId,i1=await API.saveAppMetadata({appId:o1,metadata:{theme:r1}});n1.update(a1=>(a1.theme=i1.theme,a1))}},customTheme:{save:async r1=>{const o1=get_store_value(n1).appId,i1=await API.saveAppMetadata({appId:o1,metadata:{customTheme:r1}});n1.update(a1=>(a1.customTheme=i1.customTheme,a1))}},navigation:{save:async r1=>{const o1=get_store_value(n1).appId,i1=await API.saveAppMetadata({appId:o1,metadata:{navigation:r1}});n1.update(a1=>(a1.navigation=i1.navigation,a1))}},screens:{select:r1=>{const o1=get_store_value(n1),i1=o1.screens.find(a1=>a1._id===r1);i1&&o1.selectedScreenId!==i1._id&&n1.update(a1=>(a1.selectedScreenId=i1._id,a1))},validate:r1=>{const o1=(a1,s1=[],l1=[])=>{var f1,d1,p1;const c1=a1._component;if(s1.includes(c1)||l1.length&&!l1.includes(c1))return c1;if(!((f1=a1==null?void 0:a1._children)!=null&&f1.length))return;c1==="@budibase/standard-components/sidepanel"&&(s1=[]);const u1=n1.actions.components.getDefinition(a1._component);if(l1=[],(d1=u1==null?void 0:u1.legalDirectChildren)!=null&&d1.length&&(l1=u1.legalDirectChildren.map(m1=>`@budibase/standard-components/${m1}`)),(p1=u1==null?void 0:u1.illegalChildren)!=null&&p1.length){const m1=u1.illegalChildren.map(_1=>`@budibase/standard-components/${_1}`);s1=[...new Set([...s1,...m1])]}for(let m1 of a1._children){const _1=o1(m1,s1,l1);if(_1)return _1}},i1=o1(r1.props);if(i1)throw`You can't place a ${n1.actions.components.getDefinition(i1).name} here`},save:async r1=>{var c1;const o1=get_store_value(n1);(c1=o1.features)!=null&&c1.componentValidation&&n1.actions.screens.validate(r1),n1.actions.screens.enrichEmptySettings(r1);const i1=r1._id===void 0,a1=await API.saveScreen(r1),s1=await API.fetchAppRoutes();let l1=o1.usedPlugins;if(a1.pluginAdded){const{application:u1}=await API.fetchAppPackage(o1.appId);l1=u1.usedPlugins||[]}return n1.update(u1=>{const f1=u1.screens.findIndex(d1=>d1._id===a1._id);return f1!==-1?u1.screens.splice(f1,1,a1):u1.screens.push(a1),i1&&(u1.selectedScreenId=a1._id,u1.selectedComponentId=a1.props._id),u1.routes=s1.routes,u1.usedPlugins=l1,u1}),a1},patch:async(r1,o1)=>{if(o1||(o1=get_store_value(n1).selectedScreenId),!(!o1||!r1))return await t1(r1,o1)},replace:async(r1,o1)=>{if(r1)if(!o1)n1.update(i1=>({...i1,screens:i1.screens.filter(a1=>a1._id!==r1)}));else{const i1=get_store_value(n1).screens.findIndex(a1=>a1._id===o1._id);i1===-1?n1.update(a1=>({...a1,screens:[...a1.screens,o1]})):n1.update(a1=>(a1.screens[i1]=o1,a1))}},delete:async r1=>{const o1=Array.isArray(r1)?r1:[r1];let i1=[],a1=[];o1.forEach(c1=>{i1.push(API.deleteScreen({screenId:c1._id,screenRev:c1._rev})),a1.push(c1.routing.route)}),await Promise.all(i1),await n1.actions.links.delete(a1);const s1=o1.map(c1=>c1._id),l1=await API.fetchAppRoutes();return n1.update(c1=>(c1.screens=c1.screens.filter(u1=>!s1.includes(u1._id)),s1.includes(c1.selectedScreenId)&&(c1.selectedScreenId=null,c1.selectedComponentId=null),c1.routes=l1.routes,c1)),null},updateSetting:async(r1,o1,i1)=>{if(!r1||!o1)return;const a1=u1=>{if(!u1||deepGet(u1,o1)===i1)return!1;deepSet(u1,o1,i1)};await n1.actions.screens.patch(a1,r1._id);const s1=get_store_value(n1),l1=s1.screens.find(u1=>u1._id===r1._id);if(!l1)return;const c1=s1.screens.filter(u1=>u1.routing.roleId===l1.routing.roleId&&u1.routing.homeScreen&&u1._id!==r1._id);if(c1.length&&l1.routing.homeScreen){const u1=f1=>{f1.routing.homeScreen=!1};for(let f1 of c1)await n1.actions.screens.patch(u1,f1._id)}},removeCustomLayout:async r1=>{const o1=get_store_value(n1).layouts.find(a1=>a1._id===r1.layoutId),i1=a1=>{a1.layoutId=null,a1.showNavigation=(o1==null?void 0:o1.props.navigation)!=="None",a1.width=(o1==null?void 0:o1.props.width)||"Large"};await n1.actions.screens.patch(i1,r1._id)},enrichEmptySettings:r1=>{findAllMatchingComponents(r1.props,i1=>i1).forEach(i1=>{n1.actions.components.enrichEmptySettings(i1,{screen:r1})})}},preview:{setDevice:r1=>{n1.update(o1=>(o1.previewDevice=r1,o1))},sendEvent:(r1,o1)=>{const{previewEventHandler:i1}=get_store_value(n1);i1==null||i1(r1,o1)},registerEventHandler:r1=>{n1.update(o1=>(o1.previewEventHandler=r1,o1))}},layouts:{select:r1=>{var a1;const o1=get_store_value(n1),i1=o1.layouts.find(s1=>s1._id===r1);i1&&(o1.selectedLayoutId===i1._id&&o1.selectedComponentId===((a1=i1.props)==null?void 0:a1._id)||n1.update(s1=>{var l1;return s1.selectedLayoutId=i1._id,s1.selectedComponentId=(l1=i1.props)==null?void 0:l1._id,s1}))},delete:async r1=>{r1!=null&&r1._id&&(await API.deleteLayout({layoutId:r1._id,layoutRev:r1._rev}),n1.update(o1=>(o1.layouts=o1.layouts.filter(i1=>i1._id!==r1._id),o1)))}},components:{refreshDefinitions:async r1=>{r1||(r1=get_store_value(n1).appId);const o1=await API.fetchComponentLibDefinitions(r1),i1=Object.keys(o1).filter(a1=>a1.startsWith("plugin/"));n1.update(a1=>({...a1,components:o1,customComponents:i1,clientFeatures:{...INITIAL_FRONTEND_STATE.clientFeatures,...o1.features}}))},getDefinition:r1=>r1?get_store_value(n1).components[r1]:null,getDefaultDatasource:()=>{const r1=get_store_value(tables).list.filter(i1=>i1._id!=="ta_users");let o1=r1.find(i1=>i1.sourceId!==BUDIBASE_INTERNAL_DB_ID&&i1.sourceType===DB_TYPE_INTERNAL);return o1||(o1=r1.find(i1=>i1.sourceId===BUDIBASE_INTERNAL_DB_ID&&i1.sourceType===DB_TYPE_INTERNAL),o1)?o1:r1.find(i1=>i1.sourceType===DB_TYPE_EXTERNAL)},migrateSettings:r1=>{const o1="@budibase/standard-components";let i1=!1;if((r1==null?void 0:r1._component)==`${o1}/formblock`){if(!("buttons"in r1))r1.buttons=buildDynamicButtonConfig(r1),i1=!0;else if(r1.buttons==null){const{_id:a1,actionType:s1,dataSource:l1}=r1;r1.buttons=buildDynamicButtonConfig({_id:a1,actionType:s1,dataSource:l1}),i1=!0}"buttonPosition"in r1||(r1.buttonPosition="top",i1=!0)}return i1},enrichEmptySettings:(r1,o1)=>{if(!(r1!=null&&r1._component))return;const i1=n1.actions.components.getDefaultDatasource(),a1=getComponentSettings(r1._component),{parent:s1,screen:l1,useDefaultValues:c1}=o1||{},u1=(s1==null?void 0:s1._id)||r1._id;l1&&a1.forEach(f1=>{var p1,m1;const d1=r1[f1.key];if(d1==null||d1==="")if(f1.type==="multifield"&&f1.selectAllFields)r1[f1.key]=Object.keys((i1==null?void 0:i1.schema)||{});else if((f1.type==="dataSource"||f1.type==="table")&&i1)r1[f1.key]={label:i1.name,tableId:i1._id,resourceId:i1._id,type:"table"};else if(f1.type==="dataProvider"){const h1=findComponentPath(l1.props,u1).filter(g1=>{var $1;return($1=g1._component)==null?void 0:$1.endsWith("/dataprovider")});if(h1.length){const g1=(p1=h1[h1.length-1])==null?void 0:p1._id;r1[f1.key]=`{{ literal ${jh(g1)} }}`}}else if(f1.type.startsWith("field/")){let _1=getComponentFieldOptions(l1.props,u1,f1.type,!1);const h1=findClosestMatchingComponent(l1.props,u1,$1=>$1._component==="@budibase/standard-components/form"),g1=Object.keys(buildFormSchema(h1)||{});_1=_1.filter($1=>!g1.includes($1)),_1[0]&&(r1[f1.key]=_1[0],r1.label=_1[0])}else c1&&f1.defaultValue!==void 0&&(r1[f1.key]=f1.defaultValue);else if(f1.type==="dataProvider"){const _1=(s1==null?void 0:s1._id)||r1._id,g1=findComponentPath(l1==null?void 0:l1.props,_1).filter(y1=>{var v1;return(v1=y1._component)==null?void 0:v1.endsWith("/dataprovider")});if(!(g1==null?void 0:g1.some(y1=>{var v1;return(v1=d1.includes)==null?void 0:v1.call(d1,y1._id)})))if(g1.length){const y1=(m1=g1[g1.length-1])==null?void 0:m1._id;r1[f1.key]=`{{ literal ${jh(y1)} }}`}else delete r1[f1.key]}})},createInstance:(r1,o1,i1)=>{const a1=n1.actions.components.getDefinition(r1);if(!a1)return null;let s1={_id:uuid(),_component:a1.component,_styles:{normal:{},hover:{},active:{}},_instanceName:`New ${a1.friendlyName||a1.name}`,...o1};n1.actions.components.enrichEmptySettings(s1,{parent:i1,screen:get_store_value(selectedScreen),useDefaultValues:!0}),n1.actions.components.migrateSettings(s1);let l1={};if(a1.hasChildren&&(l1._children=[]),r1.endsWith("/formstep")){const c1=findClosestMatchingComponent(get_store_value(selectedScreen).props,get_store_value(selectedComponent)._id,f1=>f1._component.endsWith("/form")),u1=findAllMatchingComponents(c1,f1=>f1._component.endsWith("/formstep"));l1.step=u1.length+1,l1._instanceName=`Step ${u1.length+1}`}return{...fp$1.cloneDeep(s1),...l1}},create:async(r1,o1,i1,a1)=>{const s1=get_store_value(n1),l1=n1.actions.components.createInstance(r1,o1,i1);if(l1)return i1&&a1!=null?await n1.actions.screens.patch(c1=>{var f1;let u1=findComponent(c1.props,i1);(f1=u1._children)!=null&&f1.length?u1._children.splice(a1,0,l1):u1._children=[l1]}):await n1.actions.screens.patch(c1=>{let u1=s1.selectedComponentId;u1.startsWith(`${c1._id}-`)&&(u1=c1==null?void 0:c1.props._id);const f1=findComponent(c1.props,u1);if(!f1)return!1;let d1;if(f1){const p1=n1.actions.components.getDefinition(f1._component);p1!=null&&p1.hasChildren?d1=f1:d1=findComponentParent(c1.props,f1._id)}else d1=c1.props;if(!d1)return!1;d1._children||(d1._children=[]),d1._children.push(l1)}),n1.update(c1=>(c1.selectedComponentId=l1._id,c1)),analytics.captureEvent(Events.COMPONENT_CREATED,{name:l1._component}),l1},patch:async(r1,o1,i1)=>{if(!o1||!i1){const s1=get_store_value(n1);o1=o1||s1.selectedComponentId,i1=i1||s1.selectedScreenId}if(!o1||!i1||!r1)return;const a1=s1=>{let l1=findComponent(s1.props,o1);if(!l1)return!1;const c1=r1(l1,s1),u1=n1.actions.components.migrateSettings(l1);return c1||u1};await n1.actions.screens.patch(a1,i1)},delete:async r1=>{if(!r1)return;const o1=get_store_value(n1);let i1;o1.selectedComponentId===r1._id&&(i1=n1.actions.components.getNext(),i1||(i1=n1.actions.components.getPrevious())),await n1.actions.screens.patch(a1=>{if(r1=findComponent(a1.props,r1._id),!r1)return!1;const s1=findComponentParent(a1.props,r1._id);if(!s1)return!1;s1._children=s1._children.filter(l1=>l1._id!==r1._id)}),i1&&n1.update(a1=>(a1.selectedComponentId=i1,a1))},copy:(r1,o1=!1,i1=!0)=>{if(n1.update(a1=>(a1.componentToPaste=fp$1.cloneDeep(r1),a1.componentToPaste.isCut=o1,a1)),o1&&i1){const a1=get_store_value(selectedScreen),s1=findComponentParent(a1==null?void 0:a1.props,r1._id);s1&&n1.update(l1=>(l1.selectedComponentId=s1._id,l1))}},paste:async(r1,o1,i1)=>{const a1=get_store_value(n1);if(!a1.componentToPaste)return;let s1,l1=fp$1.cloneDeep(a1.componentToPaste);l1.isCut&&n1.update(f1=>(delete f1.componentToPaste,f1));const c1=f1=>{if(r1=findComponent(f1.props,r1._id),!r1)return!1;const d1=l1.isCut,p1=l1._id;if(delete l1.isCut,d1||(l1=makeComponentUnique(l1)),s1=l1._id,d1){const m1=findComponentParent(f1.props,p1);m1!=null&&m1._children&&(m1._children=m1._children.filter(_1=>_1._id!==p1))}if(o1==="inside"&&(n1.actions.components.getDefinition(r1._component).hasChildren||(o1="below")),o1==="inside")r1._children||(r1._children=[]),r1._children.push(l1);else{const m1=findComponentParent(f1.props,r1._id);if(!(m1!=null&&m1._children))return!1;const _1=m1._children.findIndex(g1=>g1._id===r1._id),h1=o1==="above"?_1:_1+1;m1._children.splice(h1,0,l1)}},u1=(i1==null?void 0:i1._id)||a1.selectedScreenId;await n1.actions.screens.patch(c1,u1),n1.update(f1=>(f1.selectedScreenId=u1,f1.selectedComponentId=s1,f1))},getPrevious:()=>{var u1,f1;const o1=get_store_value(n1).selectedComponentId,i1=get_store_value(selectedScreen),a1=findComponentParent(i1.props,o1),s1=a1==null?void 0:a1._children.findIndex(d1=>d1._id===o1),l1=`${i1._id}-screen`,c1=`${i1._id}-navigation`;if(o1===l1)return null;if(o1===c1)return l1;if(a1._id===i1.props._id&&s1===0)return c1;if(s1>0){const d1=a1._children[s1-1];if((u1=d1._children)!=null&&u1.length){let p1=d1;for(;(f1=p1._children)!=null&&f1.length;)p1=p1._children[p1._children.length-1];return p1._id}return d1._id}return a1._id},getNext:()=>{var m1,_1;const r1=get_store_value(n1),o1=get_store_value(selectedComponent),i1=o1==null?void 0:o1._id,a1=get_store_value(selectedScreen),s1=findComponentParent(a1.props,i1),l1=s1==null?void 0:s1._children.findIndex(h1=>h1._id===i1),c1=`${a1._id}-screen`,u1=`${a1._id}-navigation`;if(r1.selectedComponentId===c1)return u1;if((m1=o1._children)!=null&&m1.length)return o1._children[0]._id;if(!s1)return null;if(l1<s1._children.length-1)return s1._children[l1+1]._id;let f1=s1,d1=findComponentParent(a1.props,f1._id),p1=d1==null?void 0:d1._children.findIndex(h1=>h1._id===f1._id);for(;d1!=null&&p1===((_1=d1._children)==null?void 0:_1.length)-1;)f1=d1,d1=findComponentParent(a1.props,f1._id),p1=d1==null?void 0:d1._children.findIndex(h1=>h1._id===f1._id);return d1?d1._children[p1+1]._id:null},selectPrevious:()=>{const r1=n1.actions.components.getPrevious();r1&&n1.update(o1=>(o1.selectedComponentId=r1,o1))},selectNext:()=>{const r1=n1.actions.components.getNext();r1&&n1.update(o1=>(o1.selectedComponentId=r1,o1))},moveUp:async r1=>{await n1.actions.screens.patch(o1=>{const i1=r1==null?void 0:r1._id,a1=findComponentParent(o1.props,i1),s1=a1==null?void 0:a1._children.findIndex(c1=>c1._id===i1);if(!a1||s1===0&&a1._id===o1.props._id)return;const l1=fp$1.cloneDeep(a1._children[s1]);if(a1._children=a1._children.filter(c1=>c1._id!==i1),s1>0){const c1=a1._children[s1-1];n1.actions.components.getDefinition(c1._component).hasChildren?c1._children.push(l1):a1._children.splice(s1-1,0,l1)}else if(a1._id!==o1.props._id){const c1=findComponentParent(o1.props,a1._id),u1=c1._children.findIndex(f1=>f1._id===a1._id);c1._children.splice(u1,0,l1)}})},moveDown:async r1=>{await n1.actions.screens.patch(o1=>{var c1;const i1=r1==null?void 0:r1._id,a1=findComponentParent(o1.props,i1);if(!((c1=a1==null?void 0:a1._children)!=null&&c1.length))return!1;const s1=a1._children.findIndex(u1=>u1._id===i1);if(s1===a1._children.length-1&&a1._id===o1.props._id)return;const l1=fp$1.cloneDeep(a1._children[s1]);if(a1._children=a1._children.filter(u1=>u1._id!==i1),s1<a1._children.length){const u1=a1._children[s1];n1.actions.components.getDefinition(u1._component).hasChildren?u1._children.splice(0,0,l1):a1._children.splice(s1+1,0,l1)}else{const u1=findComponentParent(o1.props,a1._id),f1=u1._children.findIndex(d1=>d1._id===a1._id);u1._children.splice(f1+1,0,l1)}})},updateStyle:async(r1,o1)=>{await n1.actions.components.patch(i1=>{o1==null||o1===""?delete i1._styles.normal[r1]:i1._styles.normal[r1]=o1})},updateStyles:async(r1,o1)=>{const i1=a1=>{a1._styles.normal={...a1._styles.normal,...r1}};await n1.actions.components.patch(i1,o1)},updateCustomStyle:async r1=>{await n1.actions.components.patch(o1=>{o1._styles.custom=r1})},updateConditions:async r1=>{await n1.actions.components.patch(o1=>{o1._conditions=r1})},updateSetting:async(r1,o1)=>{await n1.actions.components.patch(n1.actions.components.updateComponentSetting(r1,o1))},updateComponentSetting:(r1,o1)=>i1=>{if(!r1||!i1||i1[r1]===o1)return!1;const a1=getComponentSettings(i1._component),s1=a1.find(c1=>c1.key===r1),l1=a1.filter(c1=>r1===c1.resetOn||Array.isArray(c1.resetOn)&&c1.resetOn.includes(r1));if(l1==null||l1.forEach(c1=>{i1[c1.key]=null}),(s1==null?void 0:s1.type)==="dataSource"||(s1==null?void 0:s1.type)==="table"){const{schema:c1}=getSchemaForDatasource(null,o1),u1=Object.keys(c1||{});a1.filter(d1=>d1.type==="multifield"&&d1.selectAllFields).map(d1=>d1.key).forEach(d1=>{i1[d1]=u1})}return i1[r1]=o1,!0},requestEjectBlock:r1=>{n1.actions.preview.sendEvent("eject-block",r1)},handleEjectBlock:async(r1,o1)=>{let i1;await n1.actions.screens.patch(a1=>{var f1;const s1=findComponent(a1.props,r1),l1=findComponentParent(a1.props,r1);if(!s1||!((f1=l1==null?void 0:l1._children)!=null&&f1.length))return!1;analytics.captureEvent(Events.BLOCK_EJECTED,{block:s1._component});const c1=findAllMatchingComponents(o1,d1=>d1._containsSlot)[0];c1&&(delete c1._containsSlot,c1._children=[...c1._children||[],...s1._children||[]]),o1=makeComponentUnique(o1);const u1=l1._children.findIndex(d1=>d1._id===r1);l1._children[u1]=o1,i1=o1._id}),i1&&n1.update(a1=>(a1.selectedComponentId=i1,a1))},addParent:async(r1,o1)=>{if(!r1||!o1)return;const i1=n1.actions.components.createInstance(o1,null,parent);i1&&(await n1.actions.screens.patch(a1=>{let s1=findComponent(a1.props,r1),l1=findComponentParent(a1.props,r1);if(!s1||!l1)return!1;const c1=l1._children.findIndex(u1=>u1._id===r1);if(c1===-1)return!1;l1._children[c1]={...i1,_children:[s1]}}),n1.update(a1=>(a1.selectedComponentId=i1._id,a1)))}},links:{save:async(r1,o1)=>{const i1=get_store_value(n1).navigation;let a1=[...(i1==null?void 0:i1.links)??[]];a1.find(s1=>s1.url===r1&&s1.text===o1)||(a1.push({text:o1,url:r1}),await n1.actions.navigation.save({...i1,links:[...a1]}))},delete:async r1=>{const o1=get_store_value(n1).navigation;let i1=o1==null?void 0:o1.links;i1!=null&&i1.length&&(r1=Array.isArray(r1)?r1:[r1],i1=i1.filter(a1=>!r1.includes(a1.url)),await n1.actions.navigation.save({...o1,links:i1}))}},settings:{highlight:r1=>{n1.update(o1=>({...o1,highlightedSettingKey:r1}))},propertyFocus:r1=>{n1.update(o1=>({...o1,propertyFocus:r1}))}},dnd:{start:r1=>{n1.actions.preview.sendEvent("dragging-new-component",{dragging:!0,component:r1})},stop:()=>{n1.actions.preview.sendEvent("dragging-new-component",{dragging:!1})}},websocket:{selectResource:r1=>{e1.emit(BuilderSocketEvent.SelectResource,{resourceId:r1})}},metadata:{replace:r1=>{n1.update(o1=>({...o1,...r1}))}}},n1},initialAutomationState={automations:[],testResults:null,showTestPanel:!1,blockDefinitions:{TRIGGER:[],ACTION:[]},selectedAutomationId:null},getAutomationStore=()=>{const n1=writable(initialAutomationState);return n1.actions=automationActions(n1),n1},updateStepReferences=(n1,e1,t1)=>{n1.forEach(r1=>{updateReferencesInObject({obj:r1.inputs,modifiedIndex:e1,action:t1,label:"steps"})})},automationActions=n1=>({definitions:async()=>{const e1=await API.getAutomationDefinitions();return n1.update(t1=>(t1.blockDefinitions={TRIGGER:e1.trigger,ACTION:e1.action},t1)),e1},fetch:async()=>{const e1=await Promise.all([API.getAutomations(),API.getAutomationDefinitions()]);n1.update(t1=>(t1.automations=e1[0],t1.automations.sort((r1,o1)=>r1.name<o1.name?-1:1),t1.blockDefinitions={TRIGGER:e1[1].trigger,ACTION:e1[1].action},t1))},create:async(e1,t1)=>{const r1={name:e1,type:"automation",definition:{steps:[],trigger:t1}},o1=await n1.actions.save(r1);return await n1.actions.fetch(),n1.actions.select(o1._id),o1},duplicate:async e1=>{const t1=await n1.actions.save({...e1,name:`${e1.name} - copy`,_id:void 0,_ref:void 0});return await n1.actions.fetch(),n1.actions.select(t1._id),t1},save:async e1=>{const t1=await API.updateAutomation(e1);return n1.update(r1=>{const o1=t1.automation,i1=r1.automations.findIndex(a1=>a1._id===e1._id);return i1!==-1?(r1.automations.splice(i1,1,o1),r1):(r1.automations=[...r1.automations,o1],r1)}),t1.automation},delete:async e1=>{await API.deleteAutomation({automationId:e1==null?void 0:e1._id,automationRev:e1==null?void 0:e1._rev}),n1.update(t1=>{var r1;return t1.automations=t1.automations.filter(o1=>o1._id!==e1._id),e1._id===t1.selectedAutomationId&&n1.actions.select((r1=t1.automations[0])==null?void 0:r1._id),t1}),await n1.actions.fetch()},updateBlockInputs:async(e1,t1)=>{let r1={...e1,inputs:{...e1.inputs,...t1}};Object.keys(r1.inputs).forEach(a1=>{const s1=r1.inputs[a1];(s1==null||s1==="")&&delete r1.inputs[a1]});const o1=get_store_value(selectedAutomation),i1=n1.actions.getUpdatedDefinition(o1,r1);JSON.stringify(i1)!==JSON.stringify(o1)&&await n1.actions.save(i1)},test:async(e1,t1)=>{var o1,i1;const r1=await API.testAutomation({automationId:e1==null?void 0:e1._id,testData:t1});if(!(r1!=null&&r1.trigger)&&!((o1=r1==null?void 0:r1.steps)!=null&&o1.length))throw((i1=r1==null?void 0:r1.err)==null?void 0:i1.code)==="usage_limit_exceeded"?"You have exceeded your automation quota":"Something went wrong testing your automation";n1.update(a1=>(a1.testResults=r1,a1))},getDefinition:e1=>{var t1;return(t1=get_store_value(n1).automations)==null?void 0:t1.find(r1=>r1._id===e1)},getUpdatedDefinition:(e1,t1)=>{var o1;let r1=fp$1.cloneDeep(e1);if(((o1=e1.definition.trigger)==null?void 0:o1.id)===t1.id)r1.definition.trigger=t1;else{const i1=e1.definition.steps.findIndex(a1=>a1.id===t1.id);r1.definition.steps.splice(i1,1,t1)}return r1},select:e1=>{!e1||e1===get_store_value(n1).selectedAutomationId||n1.update(t1=>(t1.selectedAutomationId=e1,t1.testResults=null,t1.showTestPanel=!1,t1))},getLogs:async({automationId:e1,startDate:t1,status:r1,page:o1}={})=>await API.getAutomationLogs({automationId:e1,startDate:t1,status:r1,page:o1}),clearLogErrors:async({automationId:e1,appId:t1}={})=>await API.clearAutomationLogErrors({automationId:e1,appId:t1}),addTestDataToAutomation:async e1=>{let t1=fp$1.cloneDeep(get_store_value(selectedAutomation));t1.testData={...t1.testData,...e1},await n1.actions.save(t1)},constructBlock(e1,t1,r1){return{...r1,inputs:r1.inputs||{},stepId:t1,type:e1,id:shortid.generate()}},addBlockToAutomation:async(e1,t1)=>{const r1=get_store_value(selectedAutomation);let o1=fp$1.cloneDeep(r1);if(r1){try{updateStepReferences(o1.definition.steps,t1,"add")}catch{notifications.error("Error adding automation block")}o1.definition.steps.splice(t1,0,e1),await n1.actions.save(o1)}},saveAutomationName:async(e1,t1)=>{const r1=get_store_value(selectedAutomation);let o1=fp$1.cloneDeep(r1);r1&&(o1.definition.stepNames={...o1.definition.stepNames,[e1]:t1.trim()},await n1.actions.save(o1))},deleteAutomationName:async e1=>{const t1=get_store_value(selectedAutomation);let r1=fp$1.cloneDeep(t1);t1&&(delete r1.definition.stepNames[e1],await n1.actions.save(r1))},deleteAutomationBlock:async(e1,t1)=>{var i1,a1;const r1=get_store_value(selectedAutomation);let o1=fp$1.cloneDeep(r1);((i1=o1.definition.trigger)==null?void 0:i1.id)===e1.id?delete o1.definition.trigger:(o1.definition.steps=o1.definition.steps.filter(s1=>s1.id!==e1.id),(a1=o1.definition.stepNames)==null||delete a1[e1.id]);try{updateStepReferences(o1.definition.steps,t1,"delete")}catch{notifications.error("Error deleting automation block")}await n1.actions.save(o1)},replace:async(e1,t1)=>{if(!t1)n1.update(r1=>{var o1;return r1.automations=r1.automations.filter(i1=>i1._id!==e1),e1===r1.selectedAutomationId&&n1.actions.select((o1=r1.automations[0])==null?void 0:o1._id),r1});else{const r1=get_store_value(n1).automations.findIndex(o1=>o1._id===t1._id);r1===-1?n1.update(o1=>({...o1,automations:[...o1.automations,t1]})):n1.update(o1=>(o1.automations[r1]=t1,o1))}}}),getTemporalStore=()=>{const t1=createLocalStorageStore("bb-temporal",{}),r1=(i1,a1,s1)=>{const l1={...a1,expiry:Date.now()+s1*1e3};t1.update(c1=>({...c1,[i1]:l1}))},o1=i1=>{const a1=get_store_value(t1)[i1];return a1?a1.expiry<Date.now()?(t1.update(l1=>(delete l1[i1],l1)),null):a1:void 0};return{subscribe:t1.subscribe,actions:{setExpiring:r1,getExpiring:o1}}},getThemeStore=()=>{const n1=document.documentElement,e1={theme:"darkest"},t1=createLocalStorageStore("bb-theme",e1);return t1.subscribe(r1=>{if(r1.darkMode!==void 0){t1.set(e1);return}Themes.forEach(i1=>{n1.classList.toggle(`spectrum--${i1.class}`,i1.class===r1.theme)});const o1=Themes.find(i1=>i1.class===r1.theme);o1!=null&&o1.base&&n1.classList.add(`spectrum--${o1.base}`)}),t1},getUserStore=()=>{const n1=writable([]);return{...n1,actions:{init:i1=>{n1.set(i1)},updateUser:i1=>{const a1=get_store_value(n1);a1.some(s1=>s1.sessionId===i1.sessionId)?n1.update(s1=>{const l1=s1.findIndex(c1=>c1.sessionId===i1.sessionId);return s1[l1]=i1,s1.slice()}):n1.set([...a1,i1])},removeUser:i1=>{n1.update(a1=>a1.filter(s1=>s1.sessionId!==i1))},reset:()=>{n1.set([])}}}},getDeploymentStore=()=>{let n1=writable([]);const e1=async()=>{try{n1.set(await API.getAppDeployments())}catch{notifications.error("Error fetching deployments")}};return{subscribe:n1.subscribe,actions:{load:e1}}};/*!
426
+ }`;var Xd=Ub(function(){return Nd(i0,Md+"return "+nd).apply(t1,g0)});if(Xd.source=nd,Pb(Xd))throw Xd;return Xd}function xb(b1){return lm(b1).toLowerCase()}function T7(b1){return lm(b1).toUpperCase()}function i9(b1,k1,T1){if(b1=lm(b1),b1&&(T1||k1===t1))return $8(b1);if(!b1||!(k1=Kh(k1)))return b1;var q1=K_(b1),J1=K_(k1),i0=r3(q1,J1),g0=Ag(q1,J1)+1;return G3(q1,i0,g0).join("")}function a9(b1,k1,T1){if(b1=lm(b1),b1&&(T1||k1===t1))return b1.slice(0,H4(b1)+1);if(!b1||!(k1=Kh(k1)))return b1;var q1=K_(b1),J1=Ag(q1,K_(k1))+1;return G3(q1,0,J1).join("")}function s9(b1,k1,T1){if(b1=lm(b1),b1&&(T1||k1===t1))return b1.replace(W0,"");if(!b1||!(k1=Kh(k1)))return b1;var q1=K_(b1),J1=r3(q1,K_(k1));return G3(q1,J1).join("")}function f8(b1,k1){var T1=P1,q1=R1;if(__(k1)){var J1="separator"in k1?k1.separator:J1;T1="length"in k1?w2(k1.length):T1,q1="omission"in k1?Kh(k1.omission):q1}b1=lm(b1);var i0=b1.length;if(K5(b1)){var g0=K_(b1);i0=g0.length}if(T1>=i0)return b1;var O0=T1-R4(q1);if(O0<1)return q1;var D0=g0?G3(g0,0,O0).join(""):b1.slice(0,O0);if(J1===t1)return D0+q1;if(g0&&(O0+=D0.length-O0),i6(J1)){if(b1.slice(O0).search(J1)){var K0,Y0=D0;for(J1.global||(J1=Q6(J1.source,lm(bm.exec(J1))+"g")),J1.lastIndex=0;K0=J1.exec(Y0);)var nd=K0.index;D0=D0.slice(0,nd===t1?O0:nd)}}else if(b1.indexOf(Kh(J1),O0)!=O0){var vd=D0.lastIndexOf(J1);vd>-1&&(D0=D0.slice(0,vd))}return D0+q1}function N2(b1){return b1=lm(b1),b1&&O2.test(b1)?b1.replace(Yd,U6):b1}var l9=e5(function(b1,k1,T1){return b1+(T1?" ":"")+k1.toUpperCase()}),gg=t8("toUpperCase");function E7(b1,k1,T1){return b1=lm(b1),k1=T1?t1:k1,k1===t1?$_(b1)?Mg(b1):Y5(b1):b1.match(k1)||[]}var Ub=T2(function(b1,k1){try{return Wh(b1,t1,k1)}catch(T1){return Pb(T1)?T1:new Sd(T1)}}),qb=d4(function(b1,k1){return ld(k1,function(T1){T1=nm(T1),Xh(b1,T1,R3(b1[T1],b1))}),b1});function z7(b1){var k1=b1==null?0:b1.length,T1=Qd();return b1=k1?C2(b1,function(q1){if(typeof q1[1]!="function")throw new k_(a1);return[T1(q1[0]),q1[1]]}):[],T2(function(q1){for(var J1=-1;++J1<k1;){var i0=b1[J1];if(Wh(i0[0],this,q1))return Wh(i0[1],this,q1)}})}function R8(b1){return Cm(A_(b1,f1))}function jb(b1){return function(){return b1}}function c9(b1,k1){return b1==null||b1!==b1?k1:b1}var u9=A6(),L7=A6(!0);function b3(b1){return b1}function Qb(b1){return U4(typeof b1=="function"?b1:A_(b1,f1))}function f9(b1){return m3(A_(b1,f1))}function d9(b1,k1){return z3(b1,A_(k1,f1))}var p9=T2(function(b1,k1){return function(T1){return p3(T1,b1,k1)}}),m9=T2(function(b1,k1){return function(T1){return p3(b1,T1,k1)}});function Wb(b1,k1,T1){var q1=e3(k1),J1=q2(k1,q1);T1==null&&!(__(k1)&&(J1.length||!q1.length))&&(T1=k1,k1=b1,b1=this,J1=q2(k1,e3(k1)));var i0=!(__(T1)&&"chain"in T1)||!!T1.chain,g0=i5(b1);return ld(J1,function(O0){var D0=k1[O0];b1[O0]=D0,g0&&(b1.prototype[O0]=function(){var K0=this.__chain__;if(i0||K0){var Y0=b1(this.__wrapped__),nd=Y0.__actions__=c_(this.__actions__);return nd.push({func:D0,args:arguments,thisArg:b1}),Y0.__chain__=K0,Y0}return D0.apply(b1,pm([this.value()],arguments))})}),b1}function _9(){return d_._===this&&(d_._=S_),this}function Gb(){}function P7(b1){return b1=w2(b1),T2(function(k1){return jg(k1,b1)})}var h9=t5(C2),g9=t5(y0),I7=t5(n3);function Yb(b1){return r0(b1)?U3(nm(b1)):Hh(b1)}function b9(b1){return function(k1){return b1==null?t1:Im(b1,k1)}}var $9=Zg(),v9=Zg(!0);function Xb(){return[]}function Zb(){return!1}function y9(){return{}}function w9(){return""}function Kb(){return!0}function D7(b1,k1){if(b1=w2(b1),b1<1||b1>Q1)return[];var T1=t0,q1=sm(b1,t0);k1=Qd(k1),b1-=t0;for(var J1=Og(q1,k1);++T1<b1;)k1(T1);return J1}function k9(b1){return L2(b1)?C2(b1,nm):L4(b1)?[b1]:c_(z_(lm(b1)))}function S9(b1){var k1=++$4;return lm(b1)+k1}var O9=Xg(function(b1,k1){return b1+k1},0),A9=i8("ceil"),C9=Xg(function(b1,k1){return b1/k1},1),M9=i8("floor");function T9(b1){return b1&&b1.length?Mm(b1,b3,C_):t1}function E9(b1,k1){return b1&&b1.length?Mm(b1,Qd(k1,2),C_):t1}function z9(b1){return m6(b1,b3)}function L9(b1,k1){return m6(b1,Qd(k1,2))}function P9(b1){return b1&&b1.length?Mm(b1,b3,w6):t1}function I9(b1,k1){return b1&&b1.length?Mm(b1,Qd(k1,2),w6):t1}var D9=Xg(function(b1,k1){return b1*k1},1),B9=i8("round"),R9=Xg(function(b1,k1){return b1-k1},0);function H9(b1){return b1&&b1.length?_6(b1,b3):0}function N9(b1,k1){return b1&&b1.length?_6(b1,Qd(k1,2)):0}return P0.after=l$,P0.ary=ob,P0.assign=W8,P0.assignIn=bb,P0.assignInWith=s6,P0.assignWith=G8,P0.at=Y8,P0.before=i7,P0.bind=R3,P0.bindAll=qb,P0.bindKey=ib,P0.castArray=g$,P0.chain=u8,P0.chunk=e_,P0.compact=Bm,P0.concat=Vh,P0.cond=z7,P0.conforms=R8,P0.constant=jb,P0.countBy=x7,P0.create=$b,P0.curry=a7,P0.curryRight=s7,P0.debounce=ab,P0.defaults=P8,P0.defaultsDeep=C$,P0.defer=c$,P0.delay=Mb,P0.difference=mg,P0.differenceBy=n5,P0.differenceWith=H_,P0.drop=p4,P0.dropRight=t_,P0.dropRightWhile=P6,P0.dropWhile=E4,P0.fill=H5,P0.filter=q7,P0.flatMap=t7,P0.flatMapDeep=Q7,P0.flatMapDepth=W7,P0.flatten=u_,P0.flattenDeep=Rm,P0.flattenDepth=kb,P0.flip=u$,P0.flow=u9,P0.flowRight=L7,P0.fromPairs=Sb,P0.functions=b7,P0.functionsIn=I8,P0.groupBy=G7,P0.initial=Ab,P0.intersection=j8,P0.intersectionBy=Cb,P0.intersectionWith=N5,P0.invert=v7,P0.invertBy=y7,P0.invokeMap=X7,P0.iteratee=Qb,P0.keyBy=Z7,P0.keys=e3,P0.keysIn=J3,P0.map=nb,P0.mapKeys=P$,P0.mapValues=Rb,P0.matches=f9,P0.matchesProperty=d9,P0.memoize=Q8,P0.merge=Hb,P0.mergeWith=Nb,P0.method=p9,P0.methodOf=m9,P0.mixin=Wb,P0.negate=sb,P0.nthArg=P7,P0.omit=N3,P0.omitBy=I$,P0.once=Tb,P0.orderBy=K7,P0.over=h9,P0.overArgs=Eb,P0.overEvery=g9,P0.overSome=I7,P0.partial=zb,P0.partialRight=l7,P0.partition=J7,P0.pick=w7,P0.pickBy=D8,P0.property=Yb,P0.propertyOf=b9,P0.pull=x1,P0.pullAll=K1,P0.pullAllBy=u0,P0.pullAllWith=w0,P0.pullAt=H0,P0.range=$9,P0.rangeRight=v9,P0.rearg=f$,P0.reject=n$,P0.remove=X0,P0.rest=d$,P0.reverse=od,P0.sampleSize=o$,P0.set=k7,P0.setWith=D$,P0.shuffle=i$,P0.slice=cd,P0.sortBy=o7,P0.sortedUniq=Hd,P0.sortedUniqBy=Fd,P0.split=M7,P0.spread=p$,P0.tail=qd,P0.take=t2,P0.takeRight=_2,P0.takeRightWhile=am,P0.takeWhile=Q_,P0.tap=tb,P0.throttle=m$,P0.thru=_g,P0.toArray=h7,P0.toPairs=S7,P0.toPairsIn=O7,P0.toPath=k9,P0.toPlainObject=Bb,P0.transform=B$,P0.unary=_$,P0.union=Gd,P0.unionBy=P2,P0.unionWith=h3,P0.uniq=g3,P0.uniqBy=m4,P0.uniqWith=Qm,P0.unset=R$,P0.unzip=K3,P0.unzipWith=_4,P0.update=H$,P0.updateWith=N$,P0.values=B8,P0.valuesIn=V$,P0.without=c8,P0.words=E7,P0.wrap=h$,P0.xor=n6,P0.xorBy=z4,P0.xorWith=eb,P0.zip=M8,P0.zipObject=m_,P0.zipObjectDeep=Jh,P0.zipWith=T8,P0.entries=S7,P0.entriesIn=O7,P0.extend=bb,P0.extendWith=s6,Wb(P0,P0),P0.add=O9,P0.attempt=Ub,P0.camelCase=q$,P0.capitalize=A7,P0.ceil=A9,P0.clamp=F$,P0.clone=b$,P0.cloneDeep=v$,P0.cloneDeepWith=y$,P0.cloneWith=$$,P0.conformsTo=w$,P0.deburr=C7,P0.defaultTo=c9,P0.divide=C9,P0.endsWith=j$,P0.eq=km,P0.escape=Q$,P0.escapeRegExp=W$,P0.every=U7,P0.find=j7,P0.findIndex=r5,P0.findKey=M$,P0.findLast=e7,P0.findLastIndex=fm,P0.findLastKey=T$,P0.floor=M9,P0.forEach=n7,P0.forEachRight=r7,P0.forIn=E$,P0.forInRight=z$,P0.forOwn=vb,P0.forOwnRight=X8,P0.get=hg,P0.gt=lb,P0.gte=Lb,P0.has=$7,P0.hasIn=Z8,P0.head=K8,P0.identity=b3,P0.includes=Y7,P0.indexOf=Ob,P0.inRange=x$,P0.invoke=L$,P0.isArguments=I6,P0.isArray=L2,P0.isArrayBuffer=r_,P0.isArrayLike=H3,P0.isArrayLikeObject=N_,P0.isBoolean=o5,P0.isBuffer=V5,P0.isDate=k$,P0.isElement=L8,P0.isEmpty=cb,P0.isEqual=ub,P0.isEqualWith=Sm,P0.isError=Pb,P0.isFinite=c7,P0.isFunction=i5,P0.isInteger=u7,P0.isLength=fb,P0.isMap=r6,P0.isMatch=db,P0.isMatchWith=f7,P0.isNaN=pb,P0.isNative=d7,P0.isNil=mb,P0.isNull=p7,P0.isNumber=Ib,P0.isObject=__,P0.isObjectLike=o_,P0.isPlainObject=o6,P0.isRegExp=i6,P0.isSafeInteger=_b,P0.isSet=m7,P0.isString=hb,P0.isSymbol=L4,P0.isTypedArray=a6,P0.isUndefined=gb,P0.isWeakMap=Db,P0.isWeakSet=S$,P0.join=J8,P0.kebabCase=G$,P0.last=_3,P0.lastIndexOf=n_,P0.lowerCase=Y$,P0.lowerFirst=X$,P0.lt=_7,P0.lte=O$,P0.max=T9,P0.maxBy=E9,P0.mean=z9,P0.meanBy=L9,P0.min=P9,P0.minBy=I9,P0.stubArray=Xb,P0.stubFalse=Zb,P0.stubObject=y9,P0.stubString=w9,P0.stubTrue=Kb,P0.multiply=D9,P0.nth=E1,P0.noConflict=_9,P0.noop=Gb,P0.now=rb,P0.pad=Z$,P0.padEnd=K$,P0.padStart=J$,P0.parseInt=e9,P0.random=U$,P0.reduce=e$,P0.reduceRight=t$,P0.repeat=t9,P0.replace=yb,P0.result=Vb,P0.round=B9,P0.runInContext=E0,P0.sample=r$,P0.size=a$,P0.snakeCase=Fb,P0.some=s$,P0.sortedIndex=Ad,P0.sortedIndexBy=Cd,P0.sortedIndexOf=Pd,P0.sortedLastIndex=Jd,P0.sortedLastIndexBy=i2,P0.sortedLastIndexOf=p2,P0.startCase=n9,P0.startsWith=r9,P0.subtract=R9,P0.sum=H9,P0.sumBy=N9,P0.template=o9,P0.times=D7,P0.toFinite=Hm,P0.toInteger=w2,P0.toLength=g7,P0.toLower=xb,P0.toNumber=a5,P0.toSafeInteger=A$,P0.toString=lm,P0.toUpper=T7,P0.trim=i9,P0.trimEnd=a9,P0.trimStart=s9,P0.truncate=f8,P0.unescape=N2,P0.uniqueId=S9,P0.upperCase=l9,P0.upperFirst=gg,P0.each=n7,P0.eachRight=r7,P0.first=K8,Wb(P0,function(){var b1={};return E3(P0,function(k1,T1){U2.call(P0.prototype,T1)||(b1[T1]=k1)}),b1}(),{chain:!1}),P0.VERSION=r1,ld(["bind","bindKey","curry","curryRight","partial","partialRight"],function(b1){P0[b1].placeholder=P0}),ld(["drop","take"],function(b1,k1){z2.prototype[b1]=function(T1){T1=T1===t1?1:Fm(w2(T1),0);var q1=this.__filtered__&&!k1?new z2(this):this.clone();return q1.__filtered__?q1.__takeCount__=sm(T1,q1.__takeCount__):q1.__views__.push({size:sm(T1,t0),type:b1+(q1.__dir__<0?"Right":"")}),q1},z2.prototype[b1+"Right"]=function(T1){return this.reverse()[b1](T1).reverse()}}),ld(["filter","map","takeWhile"],function(b1,k1){var T1=k1+1,q1=T1==B1||T1==U1;z2.prototype[b1]=function(J1){var i0=this.clone();return i0.__iteratees__.push({iteratee:Qd(J1,3),type:T1}),i0.__filtered__=i0.__filtered__||q1,i0}}),ld(["head","last"],function(b1,k1){var T1="take"+(k1?"Right":"");z2.prototype[b1]=function(){return this[T1](1).value()[0]}}),ld(["initial","tail"],function(b1,k1){var T1="drop"+(k1?"":"Right");z2.prototype[b1]=function(){return this.__filtered__?new z2(this):this[T1](1)}}),z2.prototype.compact=function(){return this.filter(b3)},z2.prototype.find=function(b1){return this.filter(b1).head()},z2.prototype.findLast=function(b1){return this.reverse().find(b1)},z2.prototype.invokeMap=T2(function(b1,k1){return typeof b1=="function"?new z2(this):this.map(function(T1){return p3(T1,b1,k1)})}),z2.prototype.reject=function(b1){return this.filter(sb(Qd(b1)))},z2.prototype.slice=function(b1,k1){b1=w2(b1);var T1=this;return T1.__filtered__&&(b1>0||k1<0)?new z2(T1):(b1<0?T1=T1.takeRight(-b1):b1&&(T1=T1.drop(b1)),k1!==t1&&(k1=w2(k1),T1=k1<0?T1.dropRight(-k1):T1.take(k1-b1)),T1)},z2.prototype.takeRightWhile=function(b1){return this.reverse().takeWhile(b1).reverse()},z2.prototype.toArray=function(){return this.take(t0)},E3(z2.prototype,function(b1,k1){var T1=/^(?:filter|find|map|reject)|While$/.test(k1),q1=/^(?:head|last)$/.test(k1),J1=P0[q1?"take"+(k1=="last"?"Right":""):k1],i0=q1||/^find/.test(k1);J1&&(P0.prototype[k1]=function(){var g0=this.__wrapped__,O0=q1?[1]:arguments,D0=g0 instanceof z2,K0=O0[0],Y0=D0||L2(g0),nd=function(r2){var o2=J1.apply(P0,pm([r2],O0));return q1&&vd?o2[0]:o2};Y0&&T1&&typeof K0=="function"&&K0.length!=1&&(D0=Y0=!1);var vd=this.__chain__,Md=!!this.__actions__.length,Dd=i0&&!vd,Xd=D0&&!Md;if(!i0&&Y0){g0=Xd?g0:new z2(this);var Bd=b1.apply(g0,O0);return Bd.__actions__.push({func:_g,args:[nd],thisArg:t1}),new em(Bd,vd)}return Dd&&Xd?b1.apply(this,O0):(Bd=this.thru(nd),Dd?q1?Bd.value()[0]:Bd.value():Bd)})}),ld(["pop","push","shift","sort","splice","unshift"],function(b1){var k1=v3[b1],T1=/^(?:push|sort|unshift)$/.test(b1)?"tap":"thru",q1=/^(?:pop|shift)$/.test(b1);P0.prototype[b1]=function(){var J1=arguments;if(q1&&!this.__chain__){var i0=this.value();return k1.apply(L2(i0)?i0:[],J1)}return this[T1](function(g0){return k1.apply(L2(g0)?g0:[],J1)})}}),E3(z2.prototype,function(b1,k1){var T1=P0[k1];if(T1){var q1=T1.name+"";U2.call(Lm,q1)||(Lm[q1]=[]),Lm[q1].push({name:k1,func:T1})}}),Lm[Um(t1,g1).name]=[{name:"wrapper",func:t1}],z2.prototype.clone=v8,z2.prototype.reverse=O3,z2.prototype.value=Lh,P0.prototype.at=E8,P0.prototype.chain=B7,P0.prototype.commit=R7,P0.prototype.next=H7,P0.prototype.plant=V7,P0.prototype.reverse=F7,P0.prototype.toJSON=P0.prototype.valueOf=P0.prototype.value=z8,P0.prototype.first=P0.prototype.head,V4&&(P0.prototype[V4]=N7),P0},J_=j6();p_?((p_.exports=J_)._=J_,l5._=J_):d_._=J_}).call(commonjsGlobal)})(lodash$2,lodash$2.exports);var lodashExports=lodash$2.exports;const _=getDefaultExportFromCjs(lodashExports),DEFAULT_CONFIG$1={platformUrl:"",logoUrl:void 0,faviconUrl:void 0,emailBrandingEnabled:!0,testimonialsEnabled:!0,platformTitle:"Budibase",loginHeading:void 0,loginButton:void 0,metaDescription:void 0,metaImageUrl:void 0,metaTitle:void 0,docsUrl:void 0,company:"Budibase",oidc:void 0,google:void 0,googleDatasourceConfigured:void 0,oidcCallbackUrl:"",googleCallbackUrl:"",isSSOEnforced:!1,loaded:!1};function createOrganisationStore(){const n1=writable(DEFAULT_CONFIG$1),{subscribe:e1,set:t1}=n1;async function r1(){const i1=get_store_value(auth).tenantId,a1=await API.getTenantConfig(i1);t1({...DEFAULT_CONFIG$1,...a1.config,loaded:!0})}async function o1(i1){const a1=_.cloneDeep(get_store_value(n1));delete a1.oidc,delete a1.google,delete a1.googleDatasourceConfigured,delete a1.oidcCallbackUrl,delete a1.googleCallbackUrl,delete a1.loaded,await API.saveConfig({type:"settings",config:{...a1,...i1}}),await r1()}return{subscribe:e1,set:t1,save:o1,init:r1}}const organisation=createOrganisationStore();function createUsersStore(){const{subscribe:n1,set:e1}=writable({});async function t1(v1={}){const S1=await API.searchUsers(v1);return e1({...S1,...v1}),S1}async function r1(v1){try{return await API.getUser(v1)}catch{return null}}const o1=async()=>await API.getUsers();async function i1(v1){return await API.onboardUsers(v1)}async function a1(v1){return API.inviteUsers(v1)}async function s1(v1,S1,O1,C1){return API.acceptInvite({inviteCode:v1,password:S1,firstName:O1,lastName:C1!=null&&C1.trim()?C1:void 0})}async function l1(v1){return API.getUserInvite(v1)}async function c1(){return API.getUserInvites()}async function u1(v1){return API.updateUserInvite(v1)}async function f1(v1){let S1=v1.users.map(C1=>{const M1={email:C1.email,password:C1.password,roles:{}};switch(C1.forceResetPassword&&(M1.forceResetPassword=C1.forceResetPassword),C1.role){case"appUser":M1.builder={global:!1},M1.admin={global:!1};break;case"developer":M1.builder={global:!0};break;case"creator":M1.builder={creator:!0,global:!1};break;case"admin":M1.admin={global:!0},M1.builder={global:!0};break}return M1});const O1=await API.createUsers({users:S1,groups:v1.groups});return await t1(),O1}async function d1(v1){await API.deleteUser(v1),lodashExports.update(S1=>S1.filter(O1=>O1._id!==v1))}async function p1({appId:v1}){return await API.getUserCountByApp({appId:v1})}async function m1(v1){return API.deleteUsers(v1)}async function _1(v1){return await API.saveUser(v1)}async function h1(v1,S1){return await API.addAppBuilder({userId:v1,appId:S1})}async function g1(v1,S1){return await API.removeAppBuilder({userId:v1,appId:S1})}const $1=v1=>isAdmin(v1)?BudibaseRoles.Admin:isBuilder(v1)?BudibaseRoles.Developer:hasCreatorPermissions(v1)?BudibaseRoles.Creator:BudibaseRoles.AppUser,y1=v1=>async(...S1)=>{const O1=await v1(...S1);return await licensing.setQuotaUsage(),O1};return{subscribe:n1,search:t1,get:r1,getUserRole:$1,fetch:o1,invite:a1,onboard:i1,fetchInvite:l1,getInvites:c1,updateInvite:u1,getUserCountByApp:p1,addAppBuilder:h1,removeAppBuilder:g1,acceptInvite:s1,create:y1(f1),save:y1(_1),bulkDelete:y1(m1),delete:y1(d1)}}const users=createUsersStore(),DEFAULT_CONFIG={loaded:!1,multiTenancy:!1,cloud:!1,isDev:!1,disableAccountPortal:!1,accountPortalUrl:"",importComplete:!1,checklist:{apps:{checked:!1},smtp:{checked:!1},adminUser:{checked:!1},sso:{checked:!1}},offlineMode:!1};function createAdminStore(){const n1=writable(DEFAULT_CONFIG);async function e1(){await i1(),await t1(),get_store_value(n1).cloud&&(await o1(),r1()),n1.update(s1=>(s1.loaded=!0,s1))}async function t1(){const s1=await API.getEnvironment();n1.update(l1=>(l1.multiTenancy=s1.multiTenancy,l1.cloud=s1.cloud,l1.disableAccountPortal=s1.disableAccountPortal,l1.accountPortalUrl=s1.accountPortalUrl,l1.isDev=s1.isDev,l1.baseUrl=s1.baseUrl,l1.offlineMode=s1.offlineMode,l1))}const r1=async()=>{var l1,c1;const s1=(c1=(l1=get_store_value(n1))==null?void 0:l1.status)==null?void 0:c1.health;s1!=null&&s1.passing||await banner.showStatus()};async function o1(){const s1=await API.getSystemStatus();n1.update(l1=>(l1.status=s1,l1))}async function i1(){const s1=get_store_value(auth).tenantId,l1=await API.getChecklist(s1);n1.update(c1=>(c1.checklist=l1,c1))}function a1(){n1.update(s1=>(s1.loaded=!1,s1))}return{subscribe:n1.subscribe,init:e1,unload:a1,getChecklist:i1}}const admin=createAdminStore(),DEV_PROPS=["updatedBy","updatedAt"],extractAppId=n1=>{const e1=(n1==null?void 0:n1.split("_"))||[];return e1.length?e1[e1.length-1]:null},getProdAppID=n1=>{if(!n1)return n1;let e1,t1="";if(n1.startsWith("app_dev")){const r1=n1.split("app_dev");r1.shift(),e1=r1.join("app_dev")}else if(!n1.startsWith("app"))e1=n1,t1="_";else return n1;return`app${t1}${e1}`};function createAppStore(){const n1=writable([]);async function e1(){const r1=await API.getApps();if(Array.isArray(r1)){let o1={},i1=r1.filter(l1=>l1.status===AppStatus.DEV),a1=r1.filter(l1=>l1.status===AppStatus.DEPLOYED);i1.forEach(l1=>{const c1=extractAppId(l1.appId);o1[c1]={...l1,devId:l1.appId,devRev:l1._rev}}),a1.forEach(l1=>{const c1=extractAppId(l1.appId);if(!o1[c1])return;let u1={};o1[c1]&&Object.entries(o1[c1]).filter(([d1])=>DEV_PROPS.indexOf(d1)!==-1).forEach(d1=>{u1[d1[0]]=d1[1]}),o1[c1]={...o1[c1],...l1,...u1,prodId:l1.appId,prodRev:l1._rev}});const s1=Object.values(o1);s1.forEach(l1=>{l1.appId=extractAppId(l1.devId),delete l1._id,delete l1._rev}),n1.set(s1)}else n1.set([])}async function t1(r1,o1){await API.saveAppMetadata({appId:r1,metadata:o1}),n1.update(i1=>{const a1=i1.findIndex(s1=>s1.instance._id===r1);if(a1!==-1){let s1=i1[a1];s1={...s1,...o1},i1.apps=i1.splice(a1,1,s1)}return i1})}return{subscribe:n1.subscribe,load:e1,update:t1,extractAppId,getProdAppID}}const apps=createAppStore();function createEmailStore(){const n1=writable({});return{subscribe:n1.subscribe,templates:{fetch:async()=>{const e1=await API.getEmailTemplateDefinitions(),t1=await API.getEmailTemplates();n1.set({definitions:e1,templates:t1})},save:async e1=>{const t1=await API.saveEmailTemplate(e1);e1._rev=t1._rev,e1._id=t1._id,n1.update(r1=>{const o1=r1.templates.findIndex(i1=>i1.purpose===t1.purpose);return r1.templates.splice(o1,1,e1),r1})}}}}const email=createEmailStore();function createAuthStore(){const n1=writable({user:null,accountPortalAccess:!1,tenantId:"default",tenantSet:!1,loaded:!1,postLogout:!1}),e1=derived(n1,l1=>{var c1;return{user:l1.user,accountPortalAccess:l1.accountPortalAccess,tenantId:l1.tenantId,tenantSet:l1.tenantSet,loaded:l1.loaded,postLogout:l1.postLogout,isSSO:!!((c1=l1.user)!=null&&c1.provider)}});function t1(l1){n1.update(c1=>(c1.loaded=!0,c1.user=l1,c1.accountPortalAccess=l1==null?void 0:l1.accountPortalAccess,l1&&(c1.tenantId=l1.tenantId||"default",c1.tenantSet=!0),c1)),l1&&analytics.activate().then(()=>{var c1,u1,f1;analytics.identify(l1._id),analytics.showChat({email:l1.email,created_at:(l1.createdAt||Date.now())/1e3,name:(c1=l1.account)==null?void 0:c1.name,user_id:l1._id,tenant:l1.tenantId,admin:isAdmin(l1),builder:isBuilder(l1),"Company size":(u1=l1.account)==null?void 0:u1.size,"Job role":(f1=l1.account)==null?void 0:f1.profession},!!(l1!=null&&l1.account))}).catch(()=>{})}async function r1(l1){const c1=get_store_value(e1).tenantId;n1.update(u1=>(u1.tenantId=l1,u1.tenantSet=!!l1,u1)),c1!==l1&&await admin.init()}async function o1(l1){return await API.setInitInfo(l1),n1.update(c1=>(c1.initInfo=l1,c1)),l1}function i1(){n1.update(l1=>(l1.postLogout=!0,l1))}async function a1(){const l1=await API.getInitInfo();return n1.update(c1=>(c1.initInfo=l1,c1)),l1}const s1={checkQueryString:async()=>{const l1=new URLSearchParams(window.location.search);if(l1.has("tenantId")){const c1=l1.get("tenantId");await r1(c1)}},setOrg:async l1=>{await r1(l1)},getSelf:async()=>{try{const l1=await API.fetchBuilderSelf();t1(l1)}catch{t1(null)}},login:async l1=>{const c1=get_store_value(e1).tenantId;await API.logIn({username:l1.username,password:l1.password,tenantId:c1}),await s1.getSelf()},logout:async()=>{await API.logOut(),i1(),t1(null),await o1({})},updateSelf:async l1=>{await API.updateSelf({...l1});try{const c1=await API.fetchBuilderSelf();t1(c1)}catch{t1(null)}},forgotPassword:async l1=>{const c1=get_store_value(e1).tenantId;await API.requestForgotPassword({tenantId:c1,email:l1})},resetPassword:async(l1,c1)=>{const u1=get_store_value(e1).tenantId;await API.resetPassword({tenantId:u1,password:l1,resetCode:c1})},generateAPIKey:async()=>API.generateAPIKey(),fetchAPIKey:async()=>{const l1=await API.fetchDeveloperInfo();return l1==null?void 0:l1.apiKey}};return{subscribe:e1.subscribe,setOrganisation:r1,getInitInfo:a1,setInitInfo:o1,...s1}}const auth=createAuthStore(),OIDC_CONFIG={logo:void 0,name:void 0,uuid:void 0};function createOidcStore(){const n1=writable(OIDC_CONFIG),{set:e1,subscribe:t1}=n1;return{subscribe:t1,set:e1,init:async()=>{const r1=get_store_value(auth).tenantId,o1=await API.getOIDCConfig(r1);Object.keys(o1||{}).length?e1(...o1):e1(OIDC_CONFIG)}}}const oidc=createOidcStore();function templatesStore(){const{subscribe:n1,set:e1}=writable([]);return{subscribe:n1,load:async()=>{const t1=await API.getAppTemplates();e1(t1)}}}const templates=templatesStore(),ExpiringKeys={LICENSING_DAYPASS_WARNING_MODAL:"licensing_daypass_warning_90_modal",LICENSING_DAYPASS_WARNING_BANNER:"licensing_daypass_warning_90_banner",LICENSING_PAYMENT_FAILED:"licensing_payment_failed",LICENSING_ACCOUNT_DOWNGRADED_MODAL:"licensing_account_downgraded_modal",LICENSING_APP_LIMIT_MODAL:"licensing_app_limit_modal",LICENSING_ROWS_WARNING_BANNER:"licensing_rows_warning_banner",LICENSING_AUTOMATIONS_WARNING_BANNER:"licensing_automations_warning_banner",LICENSING_QUERIES_WARNING_BANNER:"licensing_queries_warning_banner",LICENSING_USERS_ABOVE_LIMIT_BANNER:"licensing_users_above_limit_banner"},StripeStatus={PAST_DUE:"past_due",ACTIVE:"active"},TENANT_FEATURE_FLAGS={LICENSING:"LICENSING",USER_GROUPS:"USER_GROUPS",ONBOARDING_TOUR:"ONBOARDING_TOUR"},isEnabled=n1=>{var t1;const e1=get_store_value(auth).user;return!!((t1=e1==null?void 0:e1.featureFlags)!=null&&t1.includes(n1))},UNLIMITED=-1,createLicensingStore=()=>{const n1={goToUpgradePage:()=>{},goToPricingPage:()=>{},license:void 0,isFreePlan:!0,isEnterprisePlan:!0,isBusinessPlan:!0,groupsEnabled:!1,backupsEnabled:!1,brandingEnabled:!1,scimEnabled:!1,quotaUsage:void 0,usageMetrics:void 0,quotaResetDaysRemaining:void 0,quotaResetDate:void 0,accountPastDue:void 0,pastDueEndDate:void 0,pastDueDaysRemaining:void 0,accountDowngraded:void 0,userCount:void 0,userLimit:void 0,userLimitReached:!1,errUserLimit:!1},e1=864e5,t1=writable(n1);function r1(s1,l1){return l1===UNLIMITED?!1:s1>=l1}function o1(s1,l1){return l1===UNLIMITED?!1:s1>l1}async function i1(){let s1=get_store_value(admin);return s1.loaded||(await admin.init(),s1=get_store_value(admin)),s1.cloud}const a1={init:async()=>{a1.setNavigation(),a1.setLicense(),await a1.setQuotaUsage()},setNavigation:()=>{var d1;const s1=get_store_value(admin),l1=get_store_value(auth),c1=(d1=l1==null?void 0:l1.user)!=null&&d1.accountPortalAccess?`${s1.accountPortalUrl}/portal/upgrade`:"/builder/portal/account/upgrade",u1=()=>{window.location.href=c1},f1=()=>{window.open("https://budibase.com/pricing/","_blank")};t1.update(p1=>({...p1,goToUpgradePage:u1,goToPricingPage:f1}))},setLicense:()=>{const s1=get_store_value(auth).user.license,l1=s1==null?void 0:s1.plan.type,c1=l1===PlanType.ENTERPRISE,u1=l1===PlanType.FREE,f1=l1===PlanType.BUSINESS,d1=s1.features.includes(Feature.USER_GROUPS),p1=s1.features.includes(Feature.APP_BACKUPS),m1=s1.features.includes(Feature.SCIM),_1=s1.features.includes(Feature.ENVIRONMENT_VARIABLES),h1=s1.features.includes(Feature.ENFORCEABLE_SSO),g1=s1.features.includes(Feature.BRANDING),$1=s1.features.includes(Feature.AUDIT_LOGS),y1=s1.features.includes(Feature.SYNC_AUTOMATIONS),v1=s1.features.includes(Feature.APP_BUILDERS),S1=s1.features.includes(Feature.VIEW_PERMISSIONS);t1.update(O1=>({...O1,license:s1,isEnterprisePlan:c1,isFreePlan:u1,isBusinessPlan:f1,groupsEnabled:d1,backupsEnabled:p1,brandingEnabled:g1,scimEnabled:m1,environmentVariablesEnabled:_1,auditLogsEnabled:$1,enforceableSSO:h1,syncAutomationsEnabled:y1,isViewPermissionsEnabled:S1,perAppBuildersEnabled:v1}))},setQuotaUsage:async()=>{const s1=await API.getQuotaUsage();t1.update(l1=>({...l1,quotaUsage:s1})),await a1.setUsageMetrics()},usersLimitReached:s1=>r1(s1,get_store_value(t1).userLimit),usersLimitExceeded(s1){return o1(s1,get_store_value(t1).userLimit)},setUsageMetrics:async()=>{var s1,l1,c1,u1,f1,d1,p1,m1,_1,h1;if(isEnabled(TENANT_FEATURE_FLAGS.LICENSING)){const g1=get_store_value(t1).quotaUsage,$1=get_store_value(auth).user.license,y1=new Date,v1=(X1,W1,n0)=>!W1||!n0||!X1?{}:X1.reduce((s0,l0)=>{const f0=W1[l0].value,e0=n0[l0]/f0*100;return s0[l0]=f0>-1?Math.floor(e0):-1,s0},{}),S1=v1(["dayPasses","queries","automations"],$1.quotas.usage.monthly,g1.monthly.current),O1=v1(["apps","rows"],$1.quotas.usage.static,g1.usageQuota),C1=(X1,W1)=>W1>X1?Math.round((W1.getTime()-X1.getTime())/e1):0,M1=new Date(g1.quotaReset),z1=C1(y1,M1),P1=((l1=(s1=$1==null?void 0:$1.billing)==null?void 0:s1.subscription)==null?void 0:l1.downgradeAt)&&((u1=(c1=$1==null?void 0:$1.billing)==null?void 0:c1.subscription)==null?void 0:u1.downgradeAt)<=y1.getTime()&&((d1=(f1=$1==null?void 0:$1.billing)==null?void 0:f1.subscription)==null?void 0:d1.status)===StripeStatus.PAST_DUE&&($1==null?void 0:$1.plan.type)===PlanType.FREE,R1=(m1=(p1=$1==null?void 0:$1.billing)==null?void 0:p1.subscription)==null?void 0:m1.pastDueAt,N1=(h1=(_1=$1==null?void 0:$1.billing)==null?void 0:_1.subscription)==null?void 0:h1.downgradeAt;let F1,B1;R1&&N1&&(B1=new Date(N1),F1=C1(new Date(R1),B1));const L1=$1.quotas.usage.static.users,U1=L1==null?void 0:L1.value,j1=g1.usageQuota.users,Q1=r1(j1,U1),G1=o1(j1,U1),t0=await i1()&&$1.plan.model===PlanModel$1.PER_USER&&G1;t1.update(X1=>({...X1,usageMetrics:{...S1,...O1},quotaResetDaysRemaining:z1,quotaResetDate:M1,accountDowngraded:P1,accountPastDue:R1!=null,pastDueEndDate:B1,pastDueDaysRemaining:F1,userCount:j1,userLimit:U1,userLimitReached:Q1,errUserLimit:t0}))}}};return{subscribe:t1.subscribe,...a1}},licensing=createLicensingStore();function createGroupsStore(){const n1=writable([]),e1=o1=>{n1.update(i1=>{const a1=i1.findIndex(s1=>s1._id===o1._id);return a1>=0?i1.splice(a1,1,o1):i1.push(o1),i1})},t1=async o1=>{const i1=await API.getGroup(o1);e1(i1)},r1={init:async()=>{if(get_store_value(licensing).groupsEnabled){const o1=await API.getGroups();n1.set(o1.data)}},get:t1,save:async o1=>{const i1=await API.saveGroup(o1);return o1._id=i1._id,o1._rev=i1._rev,e1(o1),o1},delete:async o1=>{await API.deleteGroup({id:o1._id,rev:o1._rev}),n1.update(i1=>(i1=i1.filter(a1=>a1._id!==o1._id),i1))},addUser:async(o1,i1)=>{await API.addUsersToGroup(o1,i1),await t1(o1)},removeUser:async(o1,i1)=>{await API.removeUsersFromGroup(o1,i1),await t1(o1)},addApp:async(o1,i1,a1)=>{await API.addAppsToGroup(o1,[{appId:i1,roleId:a1}]),await t1(o1)},removeApp:async(o1,i1)=>{await API.removeAppsFromGroup(o1,[{appId:i1}]),await t1(o1)},getGroupAppIds:o1=>{var a1;let i1=Object.keys((o1==null?void 0:o1.roles)||{});return(a1=o1==null?void 0:o1.builder)!=null&&a1.apps&&(i1=i1.concat(o1.builder.apps)),i1},addGroupAppBuilder:async(o1,i1)=>await API.addGroupAppBuilder({groupId:o1,appId:i1}),removeGroupAppBuilder:async(o1,i1)=>await API.removeGroupAppBuilder({groupId:o1,appId:i1})};return{subscribe:n1.subscribe,actions:r1}}const groups=createGroupsStore();function createPluginsStore(){const{subscribe:n1,set:e1,update:t1}=writable([]);async function r1(){const s1=await API.getPlugins();e1(s1)}async function o1(s1){await API.deletePlugin(s1),t1(l1=>(l1=l1.filter(c1=>c1._id!==s1),l1))}async function i1(s1,l1,c1=null){let u1={source:s1,url:l1};switch(s1){case PluginSource.URL:u1.headers=c1;break;case PluginSource.GITHUB:u1.githubToken=c1;break}let d1=(await API.createPlugin(u1)).plugin;t1(p1=>{const m1=p1.findIndex(_1=>_1._id===d1._id);return m1>=0?p1.splice(m1,1,d1):p1.push(d1),p1})}async function a1(s1){if(!s1)return;let l1=new FormData;l1.append("file",s1);let u1=(await API.uploadPlugin(l1)).plugins[0];t1(f1=>{const d1=f1.findIndex(p1=>p1._id===u1._id);return d1>=0?f1.splice(d1,1,u1):f1.push(u1),f1})}return{subscribe:n1,load:r1,createPlugin:i1,deletePlugin:o1,uploadPlugin:a1}}const plugins$1=createPluginsStore();function createBackupsStore(){const n1=writable({});function e1(s1){n1.update(l1=>(l1.selectedBackup=s1,l1))}async function t1({appId:s1,trigger:l1,type:c1,page:u1,startDate:f1,endDate:d1}){return API.searchBackups({appId:s1,trigger:l1,type:c1,page:u1,startDate:f1,endDate:d1})}async function r1({appId:s1,backupId:l1,name:c1}){return API.restoreBackup({appId:s1,backupId:l1,name:c1})}async function o1({appId:s1,backupId:l1}){return API.deleteBackup({appId:s1,backupId:l1})}async function i1(s1){return API.createManualBackup(s1)}async function a1({appId:s1,backupId:l1,name:c1}){return API.updateBackup({appId:s1,backupId:l1,name:c1})}return{createManualBackup:i1,searchBackups:t1,selectBackup:e1,deleteBackup:o1,restoreBackup:r1,updateBackup:a1,subscribe:n1.subscribe}}const backups=createBackupsStore();function createEnvironmentStore(){const{subscribe:n1,update:e1}=writable({variables:[],status:{}});async function t1(){const l1=await API.checkEnvironmentVariableStatus();e1(c1=>(c1.status=l1,c1))}async function r1(){if(get_store_value(licensing).environmentVariablesEnabled){const c1=(await API.fetchEnvironmentVariables()).variables.map(u1=>({name:u1}));e1(u1=>(u1.variables=c1,u1))}}async function o1(l1){await API.createEnvironmentVariable(l1);let c1={name:l1.name};e1(u1=>(u1.variables=[c1,...u1.variables],u1))}async function i1(l1){await API.deleteEnvironmentVariable(l1),e1(c1=>(c1.variables=c1.variables.filter(u1=>u1.name!==l1),c1))}async function a1(l1){await API.updateEnvironmentVariable(l1)}async function s1(){await API.publishEvent(EventPublishType.ENV_VAR_UPGRADE_PANEL_OPENED)}return{subscribe:n1,checkStatus:t1,loadVariables:r1,createVariable:o1,deleteVariable:i1,updateVariable:a1,upgradePanelOpened:s1}}const environment=createEnvironmentStore(),menu=derived([admin,auth],([n1,e1])=>{const t1=e1==null?void 0:e1.user,r1=isAdmin(t1),o1=n1==null?void 0:n1.cloud;let i1=[{title:"Users",href:"/builder/portal/users/users"}];isEnabled(TENANT_FEATURE_FLAGS.USER_GROUPS)&&i1.push({title:"Groups",href:"/builder/portal/users/groups"});let a1=[{title:"Apps",href:"/builder/portal/apps"}];if(isGlobalBuilder(t1)&&(a1.push({title:"Users",href:"/builder/portal/users",subPages:i1}),a1.push({title:"Plugins",href:"/builder/portal/plugins"})),r1){let s1=[{title:"Auth",href:"/builder/portal/settings/auth"},{title:"Email",href:"/builder/portal/settings/email"},{title:"Organisation",href:"/builder/portal/settings/organisation"},{title:"Branding",href:"/builder/portal/settings/branding"},{title:"Environment",href:"/builder/portal/settings/environment"}];o1||(s1.push({title:"Version",href:"/builder/portal/settings/version"}),s1.push({title:"Diagnostics",href:"/builder/portal/settings/diagnostics"})),a1.push({title:"Settings",href:"/builder/portal/settings",subPages:s1})}if(isEnabled(TENANT_FEATURE_FLAGS.LICENSING)){let s1=[{title:"Usage",href:"/builder/portal/account/usage"}];r1&&(s1.push({title:"Audit Logs",href:"/builder/portal/account/auditLogs"}),o1||s1.push({title:"System Logs",href:"/builder/portal/account/systemLogs"})),o1&&(t1!=null&&t1.accountPortalAccess)?s1.push({title:"Upgrade",href:(n1==null?void 0:n1.accountPortalUrl)+"/portal/upgrade"}):!o1&&r1&&s1.push({title:"Upgrade",href:"/builder/portal/account/upgrade"}),t1!=null&&t1.accountPortalAccess&&t1.account.stripeCustomerId&&s1.push({title:"Billing",href:(n1==null?void 0:n1.accountPortalUrl)+"/portal/billing"}),a1.push({title:"Account",href:"/builder/portal/account",subPages:s1})}return a1});function createAuditLogsStore(){const{subscribe:n1,update:e1}=writable({events:{},logs:{}});async function t1(i1={}){if(get_store_value(licensing).auditLogsEnabled){const a1=await API.searchAuditLogs(i1);return e1(s1=>({...s1,logs:{...a1,opts:i1}})),a1}}async function r1(){const i1=await API.getEventDefinitions();e1(a1=>({...a1,...i1}))}function o1(i1={}){return API.getDownloadUrl(i1)}return{subscribe:n1,search:t1,getEventDefinitions:r1,getDownloadUrl:o1}}const auditLogs=createAuditLogsStore(),createFeatureStore=()=>{const n1=writable({scim:{isFeatureFlagEnabled:!1,isConfigFlagEnabled:!1}}),e1=writable({isScimEnabled:!1});n1.subscribe(r1=>{e1.update(o1=>({...o1,isScimEnabled:r1.scim.isFeatureFlagEnabled&&r1.scim.isConfigFlagEnabled}))}),licensing.subscribe(r1=>{n1.update(o1=>({...o1,scim:{...o1.scim,isFeatureFlagEnabled:r1.scimEnabled}}))});const t1={init:async()=>{const r1=await API.getConfig(ConfigType.SCIM);n1.update(o1=>{var i1;return{...o1,scim:{...o1.scim,isConfigFlagEnabled:(i1=r1==null?void 0:r1.config)==null?void 0:i1.enabled}}})}};return{subscribe:e1.subscribe,...t1}},features=createFeatureStore(),sideBarCollapsed=writable(!1),convertOldFieldFormat=n1=>n1?n1.map(t1=>typeof t1=="string"?{field:t1,active:!0}:typeof(t1==null?void 0:t1.active)!="boolean"?{field:t1.name,active:!0}:t1):[],getComponentForField=(n1,e1)=>{if(!n1||!(e1!=null&&e1[n1]))return null;const t1=e1[n1].type;return FieldTypeToComponentMap[t1]},FieldTypeToComponentMap={string:"stringfield",number:"numberfield",bigint:"bigintfield",options:"optionsfield",array:"multifieldselect",boolean:"booleanfield",longform:"longformfield",datetime:"datetimefield",attachment:"attachmentfield",link:"relationshipfield",json:"jsonfield",barcodeqr:"codescanner",bb_reference:"bbreferencefield"},CAPTURE_VAR_INSIDE_TEMPLATE=/{{([^}]+)}}/g,CAPTURE_VAR_INSIDE_JS=/\$\("([^")]+)"\)/g,UpdateReferenceAction={ADD:"add",DELETE:"delete",MOVE:"move"},getBindableProperties=(n1,e1)=>{const t1=getContextBindings(n1,e1),r1=getUserBindings(),o1=getUrlBindings(n1),i1=getDeviceBindings(),a1=getStateBindings(),s1=getSelectedRowsBindings(n1),l1=getRoleBindings();return[...t1,...o1,...a1,...r1,...i1,...s1,...l1]},getRestBindings=()=>{const n1=get_store_value(licensing).environmentVariablesEnabled;return[...getUserBindings(),...getAuthBindings(),...n1?getEnvironmentBindings():[]]},getAuthBindings=()=>{let n1=[];const e1=jh("user"),t1=jh("oauth2"),r1=jh("accessToken");return n1=[{runtime:`${e1}.${t1}.${r1}`,readable:"Current User.OAuthToken",key:"accessToken",display:{name:"OAuthToken",type:"text"}}].map(i1=>({type:"context",runtimeBinding:i1.runtime,readableBinding:i1.readable,fieldSchema:{type:"string",name:i1.key},providerId:"user",category:"Current User",display:i1.display})),n1},getEnvironmentBindings=()=>get_store_value(environment).variables.map(e1=>({type:"context",runtimeBinding:`env.${jh(e1.name)}`,readableBinding:`env.${e1.name}`,category:"Environment",icon:"Key",display:{type:"string",name:e1.name}})),toBindingsArray=(n1,e1,t1)=>n1?Object.keys(n1).reduce((r1,o1)=>{if(!o1)return r1;let i1={type:"context",runtimeBinding:o1,readableBinding:`${e1}.${o1}`,icon:"Brackets"};return t1&&(i1.category=t1),r1.push(i1),r1},[]):[],readableToRuntimeMap=(n1,e1)=>!n1||!e1?{}:Object.keys(e1).reduce((t1,r1)=>(t1[r1]=readableToRuntimeBinding(n1,e1[r1]),t1),{}),runtimeToReadableMap=(n1,e1)=>!n1||!e1?{}:Object.keys(e1).reduce((t1,r1)=>(t1[r1]=runtimeToReadableBinding(n1,e1[r1]),t1),{}),getComponentBindableProperties=(n1,e1)=>{if(!n1||!e1)return[];const t1=findComponent(n1.props,e1),r1=store.actions.components.getDefinition(t1==null?void 0:t1._component);return r1!=null&&r1.context?getProviderContextBindings(n1,t1):[]},getContextProviderComponents=(n1,e1,t1,r1={includeSelf:!1})=>{if(!n1||!e1)return[];const o1=findComponentPath(n1.props,e1);return r1!=null&&r1.includeSelf||o1.pop(),o1.filter(i1=>{const a1=store.actions.components.getDefinition(i1._component);return a1!=null&&a1.context?t1?(Array.isArray(a1.context)?a1.context:[a1.context]).find(l1=>l1.type===t1)!=null:!0:!1})},getActionProviders=(n1,e1,t1,r1={includeSelf:!1})=>{if(!n1||!e1)return[];const o1=findComponentPath(n1.props,e1);r1!=null&&r1.includeSelf||o1.pop();let i1=[];return o1.forEach(a1=>{const s1=store.actions.components.getDefinition(a1._component),c1=((s1==null?void 0:s1.actions)||[]).map(u1=>typeof u1=="string"?{type:u1}:u1).find(u1=>u1.type===t1);if(c1){let u1=a1._id;c1.suffix&&(u1+=`-${c1.suffix}`),i1.push({readableBinding:a1._instanceName,runtimeBinding:u1})}}),i1},getDatasourceForProvider=(n1,e1)=>{const t1=getComponentSettings(e1==null?void 0:e1._component),r1=t1.find(s1=>s1.type==="dataProvider");if(r1){const s1=e1[r1.key],l1=extractLiteralHandlebarsID(s1),c1=findComponent(n1==null?void 0:n1.props,l1);return getDatasourceForProvider(n1,c1)}const o1=["dataSource","table","schema"],i1=t1.find(s1=>o1.includes(s1.type));if(!i1)return null;const a1=e1[i1==null?void 0:i1.key];return typeof a1=="string"?{tableId:a1,type:"table"}:a1},getContextBindings=(n1,e1)=>{const t1=getContextProviderComponents(n1,e1);return getProviderContextBindings(n1,t1)},getProviderContextBindings=(n1,e1)=>{if(!n1||!e1)return[];Array.isArray(e1)||(e1=[e1]);let t1=[];return e1.forEach(r1=>{const o1=store.actions.components.getDefinition(r1._component);(Array.isArray(o1.context)?o1.context:[o1.context]).forEach(a1=>{var m1;if(!(a1!=null&&a1.type))return;let s1,l1,c1,u1=a1.suffix;if(a1.type==="form")s1=buildFormSchema(r1,n1),c1="Fields";else if(a1.type==="static")s1={},(a1.values||[]).forEach(h1=>{s1[h1.key]={name:h1.label,type:h1.type||"string"}});else if(a1.type==="schema"){const _1=getDatasourceForProvider(n1,r1);if(!_1)return;const h1=getSchemaForDatasource(n1,_1);if(s1=h1.schema,l1=h1.table,_1.type==="jsonarray"){const g1=_1.label.split(".");c1=g1[g1.length-1]}else if(_1.type==="viewV2"){const g1=Object.values((l1==null?void 0:l1.views)||{}).find($1=>$1.id===_1.id);c1=g1==null?void 0:g1.name}else c1=(m1=h1.table)==null?void 0:m1.name}if(!s1)return;const f1=Object.keys(s1).sort();let d1=r1._id;if(u1&&(d1+=`-${u1}`),!filterCategoryByContext(r1,a1))return;const p1=jh(d1);f1.forEach(_1=>{const h1=s1[_1],g1=_1.split(".").map(jh).join("."),$1=`${p1}.${g1}`;let y1=r1._instanceName;c1&&(y1+=`.${c1}`),y1+=`.${h1.name||_1}`;const v1=getComponentBindingCategory(r1,a1,o1);t1.push({type:"context",runtimeBinding:$1,readableBinding:y1,fieldSchema:h1,providerId:d1,tableId:l1==null?void 0:l1._id,component:r1._component,category:v1.category,icon:v1.icon,display:{name:h1.name||_1,type:h1.type}})})})}),t1},filterCategoryByContext=(n1,e1)=>{const{_component:t1}=n1;return!(t1.endsWith("formblock")&&(n1.actionType=="Create"&&e1.type==="schema"||n1.actionType=="View"&&e1.type==="form"))},getComponentBindingCategory=(n1,e1,t1)=>{let r1=t1.icon,o1=n1._instanceName;if(n1._component.endsWith("formblock")){let i1={form:"Fields",schema:"Row"};o1=`${n1._instanceName} - ${i1[e1.type]}`,r1=e1.type==="form"?"Form":"Data"}return{icon:r1,category:o1}},getUserBindings=()=>{let n1=[];const{schema:e1}=getSchemaForDatasourcePlus(TableNames.USERS),t1=Object.keys(e1).sort(),r1=jh("user");return n1=t1.reduce((o1,i1)=>{const a1=e1[i1];return o1.push({type:"context",runtimeBinding:`${r1}.${jh(i1)}`,readableBinding:`Current User.${i1}`,fieldSchema:a1,providerId:"user",category:"Current User",icon:"User",display:{name:i1}}),o1},[]),n1},getDeviceBindings=()=>{var e1;let n1=[];if((e1=get_store_value(store).clientFeatures)!=null&&e1.deviceAwareness){const t1=jh("device");n1=[{type:"context",runtimeBinding:`${t1}.${jh("mobile")}`,readableBinding:"Device.Mobile",category:"Device",icon:"DevicePhone",display:{type:"boolean",name:"mobile"}},{type:"context",runtimeBinding:`${t1}.${jh("tablet")}`,readableBinding:"Device.Tablet",category:"Device",icon:"DevicePhone",display:{type:"boolean",name:"tablet"}},{type:"context",runtimeBinding:`${t1}.${jh("theme")}`,readableBinding:"App.Theme",category:"Device",icon:"DevicePhone",display:{type:"string",name:"App Theme"}}]}return n1},getSelectedRowsBindings=n1=>{var t1;let e1=[];if((t1=get_store_value(store).clientFeatures)!=null&&t1.rowSelection){let r1=findAllMatchingComponents(n1==null?void 0:n1.props,a1=>a1._component.endsWith("table"));const o1=jh("rowSelection");e1=e1.concat(r1.map(a1=>({type:"context",runtimeBinding:`${o1}.${jh(a1._id)}.${jh("selectedRows")}`,readableBinding:`${a1._instanceName}.Selected rows`,category:"Selected rows",icon:"ViewRow",display:{name:a1._instanceName}})));let i1=findAllMatchingComponents(n1==null?void 0:n1.props,a1=>a1._component.endsWith("tableblock"));e1=e1.concat(i1.map(a1=>({type:"context",runtimeBinding:`${o1}.${jh(a1._id+"-table")}.${jh("selectedRows")}`,readableBinding:`${a1._instanceName}.Selected rows`,category:"Selected rows",icon:"ViewRow",display:{name:a1._instanceName}})))}return e1},makeStateBinding=n1=>({type:"context",runtimeBinding:`${jh("state")}.${jh(n1)}`,readableBinding:`State.${n1}`,category:"State",icon:"AutomatedSegment",display:{name:n1}}),getStateBindings=()=>{var e1;let n1=[];return(e1=get_store_value(store).clientFeatures)!=null&&e1.state&&(n1=getAllStateVariables().map(makeStateBinding)),n1},getUrlBindings=n1=>{var s1;const t1=(((s1=n1==null?void 0:n1.routing)==null?void 0:s1.route)??"").split("/");let r1=[];t1.forEach(l1=>{l1.startsWith(":")&&l1.length>1&&r1.push(l1.replace(/:/g,"").replace(/\?/g,""))});const o1=jh("url"),i1=r1.map(l1=>({type:"context",runtimeBinding:`${o1}.${jh(l1)}`,readableBinding:`URL.${l1}`,category:"URL",icon:"RailTop",display:{type:"string",name:l1}})),a1={type:"context",runtimeBinding:jh("query"),readableBinding:"Query params",category:"URL",icon:"RailTop",display:{type:"object",name:"Query params"}};return i1.concat([a1])},getRoleBindings=()=>(get_store_value(roles)||[]).map(n1=>({type:"context",runtimeBinding:`trim "${n1._id}"`,readableBinding:`Role.${n1.name}`,category:"Role",icon:"UserGroup",display:{type:"string",name:n1.name}})),getEventContextBindings=({settingKey:n1,componentInstance:e1,componentId:t1,componentDefinition:r1,asset:o1})=>{var f1;let i1=[];const a1=o1??get_store_value(currentAsset),s1=e1??findComponent(a1.props,t1);if(!s1)return i1;const l1=r1??store.actions.components.getDefinition(s1==null?void 0:s1._component),u1=getComponentSettings(s1==null?void 0:s1._component).find(d1=>d1.key===n1);return(f1=u1==null?void 0:u1.context)!=null&&f1.length&&u1.context.forEach(d1=>{i1.push({readableBinding:d1.label,runtimeBinding:`${jh("eventContext")}.${jh(d1.key)}`,category:s1._instanceName,icon:l1.icon,display:{name:d1.label}})}),i1},getActionBindings=(n1,e1)=>{let t1=[];const r1=n1==null?void 0:n1.findIndex(i1=>i1.id===e1);return r1==null||r1===-1||n1.slice(0,r1).forEach((i1,a1)=>{const s1=ActionDefinitions.actions.find(l1=>l1.name===i1["##eventHandlerType"]);s1.context&&s1.context.forEach(l1=>{t1.push({readableBinding:`Action ${a1+1}.${l1.label}`,runtimeBinding:`actions.${a1}.${l1.value}`,category:"Actions",icon:"JourneyAction",display:{name:l1.label}})})}),t1},getSchemaForDatasourcePlus=(n1,e1)=>{const r1=(n1==null?void 0:n1.includes("view_"))?{type:"viewV2",id:n1,tableId:n1.split("_").slice(1,3).join("_")}:{type:"table",tableId:n1};return getSchemaForDatasource(null,r1,e1)},getSchemaForDatasource=(n1,e1,t1)=>{var i1,a1;t1=t1||{};let r1,o1;if(e1){const{type:s1}=e1,l1=get_store_value(tables).list;if(s1==="provider"){const m1=findComponent(n1==null?void 0:n1.props,e1.providerId),_1=getDatasourceForProvider(n1,m1);return getSchemaForDatasource(n1,_1,t1)}else if(s1==="query")o1=get_store_value(queries).list.find(_1=>_1._id===e1._id);else if(s1==="field"){o1={name:e1.fieldName};const{fieldType:m1}=e1;m1==="attachment"?r1={url:{type:"string"},name:{type:"string"}}:m1==="array"&&(r1={value:{type:"string"}})}else if(s1==="jsonarray"){o1=l1.find(_1=>_1._id===e1.tableId);let m1=o1==null?void 0:o1.schema;r1=getJSONArrayDatasourceSchema(m1,e1)}else o1=l1.find(m1=>m1._id===e1.tableId);if(o1&&!r1)if(s1==="view")r1=fp$1.cloneDeep((a1=(i1=o1.views)==null?void 0:i1[e1.name])==null?void 0:a1.schema);else if(s1==="viewV2"){const m1=Object.values(o1.views||{}).find(_1=>_1.id===e1.id);r1=fp$1.cloneDeep(m1==null?void 0:m1.schema),Object.keys(r1||{}).forEach(_1=>{r1[_1].visible||delete r1[_1]})}else s1==="query"&&(t1.formSchema||t1.searchableSchema)?(r1={},(o1.parameters||[]).forEach(_1=>{_1!=null&&_1.name&&(r1[_1.name]={..._1,type:"string"})})):r1=fp$1.cloneDeep(o1.schema);if(r1){let m1={};Object.keys(r1).forEach(_1=>{const h1=r1[_1];if((h1==null?void 0:h1.type)==="json"){const g1=convertJSONSchemaToTableSchema(h1,{squashObjects:!0});Object.keys(g1).forEach($1=>{m1[`${_1}.${$1}`]={type:g1[$1].type,nestedJSON:!0}})}}),r1={...r1,...m1}}const c1=o1&&!o1.sql,u1=["table","link","viewV2"].includes(e1.type);let f1=u1,d1=u1&&c1;t1.formSchema?(f1=!1,d1=!1):t1.searchableSchema&&(f1=u1&&c1),r1&&(f1&&(r1._id={type:"string"}),d1&&(r1._rev={type:"string"}));let p1={};Object.entries(r1||{}).forEach(([m1,_1])=>{typeof _1=="string"?p1[m1]={type:_1,name:m1}:p1[m1]={..._1,name:m1}}),r1=p1}return{schema:r1,table:o1}},buildFormSchema=(n1,e1)=>{var i1;let t1={};if(!n1)return t1;if(n1._component.endsWith("formblock")){let a1={};const s1=getDatasourceForProvider(e1,n1),l1=getSchemaForDatasource(n1,s1);if(!(l1!=null&&l1.schema))return a1;if(!n1.fields)Object.values(l1.schema).filter(({autocolumn:c1,name:u1})=>!c1&&!["_rev","_id"].includes(u1)).forEach(({name:c1})=>{a1[c1]={type:l1==null?void 0:l1.schema[c1].type}});else{const c1=convertOldFieldFormat(n1.fields||[]);c1==null||c1.forEach(({field:u1,active:f1})=>{f1&&l1!=null&&l1.schema[u1]&&(a1[u1]={type:l1==null?void 0:l1.schema[u1].type})})}return a1}const o1=getComponentSettings(n1._component).find(a1=>a1.key==="field"&&a1.type.startsWith("field/"));if(o1&&n1.field){const a1=o1.type.split("field/")[1];a1&&(t1[n1.field]={type:a1})}return(i1=n1._children)==null||i1.forEach(a1=>{const s1=buildFormSchema(a1,e1);t1={...t1,...s1}}),t1},getAllStateVariables=()=>{let n1=[];getAllAssets().forEach(t1=>{findAllMatchingComponents(t1.props,r1=>{getComponentSettings(r1._component).filter(i1=>i1.type==="event").forEach(i1=>{n1.push(r1[i1.key])})})}),get_store_value(store).screens.forEach(t1=>{t1.onLoad&&n1.push(t1.onLoad)});let e1=new Set;return n1.forEach(t1=>{Array.isArray(t1)&&t1.forEach(r1=>{var o1,i1,a1;r1["##eventHandlerType"]==="Update State"&&((o1=r1.parameters)==null?void 0:o1.type)==="set"&&((i1=r1.parameters)!=null&&i1.key)&&((a1=r1.parameters)!=null&&a1.value)&&e1.add(r1.parameters.key)})}),Array.from(e1)},getAllAssets=()=>{let n1=[];return n1=n1.concat(get_store_value(store).layouts||[]),n1=n1.concat(get_store_value(store).screens||[]),n1},shouldReplaceBinding=(n1,e1,t1,r1)=>{if(!(n1!=null&&n1.includes(e1)))return!1;if(t1==="readableBinding")return n1.indexOf(r1.readableBinding)===-1;const o1=n1.replace(/\s+/g,""),i1=e1.replace(/\s+/g,"");return![`[${i1}]`,`"${i1}"`,`'${i1}'`].find(s1=>o1==null?void 0:o1.includes(s1))},replaceBetween=(n1,e1,t1,r1)=>n1.substring(0,e1)+r1+n1.substring(t1),bindingReplacement=(n1,e1,t1)=>{const r1=Rh(e1);r1&&(e1=Mh(e1));const o1=r1?CAPTURE_VAR_INSIDE_JS:CAPTURE_VAR_INSIDE_TEMPLATE,i1=t1==="runtimeBinding"?"readableBinding":"runtimeBinding";if(typeof e1!="string")return e1;const a1=n1.map(c1=>c1[i1]).sort((c1,u1)=>u1.length-c1.length),s1=e1.match(o1)||[];let l1=e1;for(let c1 of s1){let u1=c1,f1=u1;for(let d1 of a1){const p1=n1.find(m1=>m1[i1]===d1);if(r1||shouldReplaceBinding(u1,d1,t1,p1)){let m1;do if(m1=f1.indexOf(d1),m1!==-1){let _1=m1+d1.length,h1=Array(p1[t1].length+1).join("*");f1=replaceBetween(f1,m1,_1,h1),u1=replaceBetween(u1,m1,_1,p1[t1])}while(m1!==-1)}}l1=l1.replace(c1,u1)}return r1&&(l1=Ph(l1)),l1},extractLiteralHandlebarsID=n1=>{var e1;return!n1||typeof n1!="string"?null:(e1=n1.match(/{{\s*literal\s*\[+([^\]]+)].*}}/))==null?void 0:e1[1]},readableToRuntimeBinding=(n1,e1)=>bindingReplacement(n1,e1,"runtimeBinding"),runtimeToReadableBinding=(n1,e1)=>bindingReplacement(n1,e1,"readableBinding"),updateReferencesInObject=({obj:n1,modifiedIndex:e1,action:t1,label:r1,originalIndex:o1})=>{const i1=new RegExp(`{{\\s*${r1}\\.(\\d+)\\.`,"g"),a1=(s1,l1,c1)=>s1.replace(`{{ ${r1}.${l1}.`,`{{ ${r1}.${c1}.`);for(const s1 in n1)if(typeof n1[s1]=="string"){let l1;for(;(l1=i1.exec(n1[s1]))!==null;){const c1=parseInt(l1[1]);t1===UpdateReferenceAction.ADD&&c1>=e1?n1[s1]=a1(n1[s1],c1,c1+1):t1===UpdateReferenceAction.DELETE&&c1>e1?n1[s1]=a1(n1[s1],c1,c1-1):t1===UpdateReferenceAction.MOVE&&(c1===o1?n1[s1]=a1(n1[s1],c1,e1):e1<=c1&&e1<o1?n1[s1]=a1(n1[s1],c1,c1+1):e1>=c1&&e1>o1&&(n1[s1]=a1(n1[s1],c1,c1-1)))}}else typeof n1[s1]=="object"&&n1[s1]!==null&&updateReferencesInObject({obj:n1[s1],modifiedIndex:e1,action:t1,label:r1,originalIndex:o1})},getComponentFieldOptions=(n1,e1,t1,r1=!0)=>{const o1=findClosestMatchingComponent(n1,e1,l1=>l1._component==="@budibase/standard-components/form"),i1=getDatasourceForProvider(n1,o1),a1=getSchemaForDatasource(n1,i1,{formSchema:!0}).schema;let s1=[t1];return r1&&(t1==="field/options"||t1==="field/longform")&&(s1=[t1,"field/string"]),s1=s1.map(l1=>l1.slice(l1.indexOf("/")+1)),Object.entries(a1||{}).filter(l1=>s1.includes(l1[1].type)).map(l1=>l1[0])},createBuilderWebsocket=n1=>{const e1=createWebsocket("/socket/builder");return e1.on("connect",()=>{e1.emit(BuilderSocketEvent.SelectApp,{appId:n1},({users:t1})=>{userStore.actions.init(t1)})}),e1.on("connect_error",t1=>{console.log("Failed to connect to builder websocket:",t1.message)}),e1.on("disconnect",()=>{userStore.actions.reset()}),e1.onOther(SocketEvent.UserUpdate,({user:t1})=>{userStore.actions.updateUser(t1)}),e1.onOther(SocketEvent.UserDisconnect,({sessionId:t1})=>{userStore.actions.removeUser(t1)}),e1.onOther(BuilderSocketEvent.LockTransfer,({userId:t1})=>{var r1,o1;t1===((o1=(r1=get_store_value(auth))==null?void 0:r1.user)==null?void 0:o1._id)&&store.update(i1=>({...i1,hasLock:!0}))}),e1.onOther(BuilderSocketEvent.TableChange,({id:t1,table:r1})=>{tables.replaceTable(t1,r1)}),e1.onOther(BuilderSocketEvent.DatasourceChange,({id:t1,datasource:r1})=>{datasources.replaceDatasource(t1,r1)}),e1.onOther(BuilderSocketEvent.ScreenChange,({id:t1,screen:r1})=>{store.actions.screens.replace(t1,r1)}),e1.onOther(BuilderSocketEvent.AppMetadataChange,({metadata:t1})=>{store.actions.metadata.replace(t1)}),e1.onOther(BuilderSocketEvent.AppPublishChange,async({user:t1,published:r1})=>{await apps.load(),r1&&await deploymentStore.actions.load();const o1=r1?"published":"unpublished";notifications.success(`${getUserLabel(t1)} ${o1} this app`)}),e1.onOther(BuilderSocketEvent.AutomationChange,({id:t1,automation:r1})=>{automationStore.actions.replace(t1,r1)}),e1},INITIAL_FRONTEND_STATE={initialised:!1,apps:[],name:"",url:"",description:"",layouts:[],screens:[],components:[],clientFeatures:{spectrumThemes:!1,intelligentLoading:!1,deviceAwareness:!1,state:!1,rowSelection:!1,customThemes:!1,devicePreview:!1,messagePassing:!1,continueIfAction:!1,showNotificationAction:!1,sidePanel:!1},features:{componentValidation:!1,disableUserMetadata:!1},errors:[],hasAppPackage:!1,libraries:null,appId:"",routes:{},clientLibPath:"",theme:"",customTheme:{},previewDevice:"desktop",highlightedSettingKey:null,propertyFocus:null,builderSidePanel:!1,hasLock:!0,showPreview:!1,selectedScreenId:null,selectedComponentId:null,selectedLayoutId:null,selectedComponentInstance:null,onboarding:!1,tourNodes:null},getFrontendStore=()=>{const n1=writable({...INITIAL_FRONTEND_STATE});let e1;const t1=sequential(async(r1,o1)=>{const a1=get_store_value(n1).screens.find(c1=>c1._id===o1);if(!a1)return;let s1=fp$1.cloneDeep(a1);if(r1(s1)!==!1)return await n1.actions.screens.save(s1)});return n1.actions={reset:()=>{n1.set({...INITIAL_FRONTEND_STATE}),e1==null||e1.disconnect(),e1=null},initialise:async r1=>{const{layouts:o1,screens:i1,application:a1,clientLibPath:s1,hasLock:l1}=r1;e1||(e1=createBuilderWebsocket(a1.appId)),await n1.actions.components.refreshDefinitions(a1.appId),n1.update(c1=>({...c1,libraries:a1.componentLibraries,name:a1.name,description:a1.description,appId:a1.appId,url:a1.url,layouts:o1||[],screens:i1||[],theme:a1.theme||"spectrum--light",customTheme:a1.customTheme,hasAppPackage:!0,appInstance:a1.instance,clientLibPath:s1,previousTopNavPath:{},version:a1.version,revertableVersion:a1.revertableVersion,upgradableVersion:a1.upgradableVersion,navigation:a1.navigation||{},usedPlugins:a1.usedPlugins||[],hasLock:l1,features:{...INITIAL_FRONTEND_STATE.features,...a1.features},icon:a1.icon||{},initialised:!0})),screenHistoryStore.reset(),automationHistoryStore.reset(),database.set(a1.instance),await datasources.init(),await integrations.init(),await queries.init(),await tables.init()},theme:{save:async r1=>{const o1=get_store_value(n1).appId,i1=await API.saveAppMetadata({appId:o1,metadata:{theme:r1}});n1.update(a1=>(a1.theme=i1.theme,a1))}},customTheme:{save:async r1=>{const o1=get_store_value(n1).appId,i1=await API.saveAppMetadata({appId:o1,metadata:{customTheme:r1}});n1.update(a1=>(a1.customTheme=i1.customTheme,a1))}},navigation:{save:async r1=>{const o1=get_store_value(n1).appId,i1=await API.saveAppMetadata({appId:o1,metadata:{navigation:r1}});n1.update(a1=>(a1.navigation=i1.navigation,a1))}},screens:{select:r1=>{const o1=get_store_value(n1),i1=o1.screens.find(a1=>a1._id===r1);i1&&o1.selectedScreenId!==i1._id&&n1.update(a1=>(a1.selectedScreenId=i1._id,a1))},validate:r1=>{const o1=(a1,s1=[],l1=[])=>{var f1,d1,p1;const c1=a1._component;if(s1.includes(c1)||l1.length&&!l1.includes(c1))return c1;if(!((f1=a1==null?void 0:a1._children)!=null&&f1.length))return;c1==="@budibase/standard-components/sidepanel"&&(s1=[]);const u1=n1.actions.components.getDefinition(a1._component);if(l1=[],(d1=u1==null?void 0:u1.legalDirectChildren)!=null&&d1.length&&(l1=u1.legalDirectChildren.map(m1=>`@budibase/standard-components/${m1}`)),(p1=u1==null?void 0:u1.illegalChildren)!=null&&p1.length){const m1=u1.illegalChildren.map(_1=>`@budibase/standard-components/${_1}`);s1=[...new Set([...s1,...m1])]}for(let m1 of a1._children){const _1=o1(m1,s1,l1);if(_1)return _1}},i1=o1(r1.props);if(i1)throw`You can't place a ${n1.actions.components.getDefinition(i1).name} here`},save:async r1=>{var c1;const o1=get_store_value(n1);(c1=o1.features)!=null&&c1.componentValidation&&n1.actions.screens.validate(r1),n1.actions.screens.enrichEmptySettings(r1);const i1=r1._id===void 0,a1=await API.saveScreen(r1),s1=await API.fetchAppRoutes();let l1=o1.usedPlugins;if(a1.pluginAdded){const{application:u1}=await API.fetchAppPackage(o1.appId);l1=u1.usedPlugins||[]}return n1.update(u1=>{const f1=u1.screens.findIndex(d1=>d1._id===a1._id);return f1!==-1?u1.screens.splice(f1,1,a1):u1.screens.push(a1),i1&&(u1.selectedScreenId=a1._id,u1.selectedComponentId=a1.props._id),u1.routes=s1.routes,u1.usedPlugins=l1,u1}),a1},patch:async(r1,o1)=>{if(o1||(o1=get_store_value(n1).selectedScreenId),!(!o1||!r1))return await t1(r1,o1)},replace:async(r1,o1)=>{if(r1)if(!o1)n1.update(i1=>({...i1,screens:i1.screens.filter(a1=>a1._id!==r1)}));else{const i1=get_store_value(n1).screens.findIndex(a1=>a1._id===o1._id);i1===-1?n1.update(a1=>({...a1,screens:[...a1.screens,o1]})):n1.update(a1=>(a1.screens[i1]=o1,a1))}},delete:async r1=>{const o1=Array.isArray(r1)?r1:[r1];let i1=[],a1=[];o1.forEach(c1=>{i1.push(API.deleteScreen({screenId:c1._id,screenRev:c1._rev})),a1.push(c1.routing.route)}),await Promise.all(i1),await n1.actions.links.delete(a1);const s1=o1.map(c1=>c1._id),l1=await API.fetchAppRoutes();return n1.update(c1=>(c1.screens=c1.screens.filter(u1=>!s1.includes(u1._id)),s1.includes(c1.selectedScreenId)&&(c1.selectedScreenId=null,c1.selectedComponentId=null),c1.routes=l1.routes,c1)),null},updateSetting:async(r1,o1,i1)=>{if(!r1||!o1)return;const a1=u1=>{if(!u1||deepGet(u1,o1)===i1)return!1;deepSet(u1,o1,i1)};await n1.actions.screens.patch(a1,r1._id);const s1=get_store_value(n1),l1=s1.screens.find(u1=>u1._id===r1._id);if(!l1)return;const c1=s1.screens.filter(u1=>u1.routing.roleId===l1.routing.roleId&&u1.routing.homeScreen&&u1._id!==r1._id);if(c1.length&&l1.routing.homeScreen){const u1=f1=>{f1.routing.homeScreen=!1};for(let f1 of c1)await n1.actions.screens.patch(u1,f1._id)}},removeCustomLayout:async r1=>{const o1=get_store_value(n1).layouts.find(a1=>a1._id===r1.layoutId),i1=a1=>{a1.layoutId=null,a1.showNavigation=(o1==null?void 0:o1.props.navigation)!=="None",a1.width=(o1==null?void 0:o1.props.width)||"Large"};await n1.actions.screens.patch(i1,r1._id)},enrichEmptySettings:r1=>{findAllMatchingComponents(r1.props,i1=>i1).forEach(i1=>{n1.actions.components.enrichEmptySettings(i1,{screen:r1})})}},preview:{setDevice:r1=>{n1.update(o1=>(o1.previewDevice=r1,o1))},sendEvent:(r1,o1)=>{const{previewEventHandler:i1}=get_store_value(n1);i1==null||i1(r1,o1)},registerEventHandler:r1=>{n1.update(o1=>(o1.previewEventHandler=r1,o1))}},layouts:{select:r1=>{var a1;const o1=get_store_value(n1),i1=o1.layouts.find(s1=>s1._id===r1);i1&&(o1.selectedLayoutId===i1._id&&o1.selectedComponentId===((a1=i1.props)==null?void 0:a1._id)||n1.update(s1=>{var l1;return s1.selectedLayoutId=i1._id,s1.selectedComponentId=(l1=i1.props)==null?void 0:l1._id,s1}))},delete:async r1=>{r1!=null&&r1._id&&(await API.deleteLayout({layoutId:r1._id,layoutRev:r1._rev}),n1.update(o1=>(o1.layouts=o1.layouts.filter(i1=>i1._id!==r1._id),o1)))}},components:{refreshDefinitions:async r1=>{r1||(r1=get_store_value(n1).appId);const o1=await API.fetchComponentLibDefinitions(r1),i1=Object.keys(o1).filter(a1=>a1.startsWith("plugin/"));n1.update(a1=>({...a1,components:o1,customComponents:i1,clientFeatures:{...INITIAL_FRONTEND_STATE.clientFeatures,...o1.features}}))},getDefinition:r1=>r1?get_store_value(n1).components[r1]:null,getDefaultDatasource:()=>{const r1=get_store_value(tables).list.filter(i1=>i1._id!=="ta_users");let o1=r1.find(i1=>i1.sourceId!==BUDIBASE_INTERNAL_DB_ID&&i1.sourceType===DB_TYPE_INTERNAL);return o1||(o1=r1.find(i1=>i1.sourceId===BUDIBASE_INTERNAL_DB_ID&&i1.sourceType===DB_TYPE_INTERNAL),o1)?o1:r1.find(i1=>i1.sourceType===DB_TYPE_EXTERNAL)},enrichEmptySettings:(r1,o1)=>{if(!(r1!=null&&r1._component))return;const i1=n1.actions.components.getDefaultDatasource(),a1=getComponentSettings(r1._component),{parent:s1,screen:l1,useDefaultValues:c1}=o1||{},u1=(s1==null?void 0:s1._id)||r1._id;l1&&a1.forEach(f1=>{var p1,m1;const d1=r1[f1.key];if(d1==null||d1==="")if(f1.type==="multifield"&&f1.selectAllFields)r1[f1.key]=Object.keys((i1==null?void 0:i1.schema)||{});else if((f1.type==="dataSource"||f1.type==="table")&&i1)r1[f1.key]={label:i1.name,tableId:i1._id,resourceId:i1._id,type:"table"};else if(f1.type==="dataProvider"){const h1=findComponentPath(l1.props,u1).filter(g1=>{var $1;return($1=g1._component)==null?void 0:$1.endsWith("/dataprovider")});if(h1.length){const g1=(p1=h1[h1.length-1])==null?void 0:p1._id;r1[f1.key]=`{{ literal ${jh(g1)} }}`}}else if(f1.type.startsWith("field/")){let _1=getComponentFieldOptions(l1.props,u1,f1.type,!1);const h1=findClosestMatchingComponent(l1.props,u1,$1=>$1._component==="@budibase/standard-components/form"),g1=Object.keys(buildFormSchema(h1)||{});_1=_1.filter($1=>!g1.includes($1)),_1[0]&&(r1[f1.key]=_1[0],r1.label=_1[0])}else c1&&f1.defaultValue!==void 0&&(r1[f1.key]=f1.defaultValue);else if(f1.type==="dataProvider"){const _1=(s1==null?void 0:s1._id)||r1._id,g1=findComponentPath(l1==null?void 0:l1.props,_1).filter(y1=>{var v1;return(v1=y1._component)==null?void 0:v1.endsWith("/dataprovider")});if(!(g1==null?void 0:g1.some(y1=>{var v1;return(v1=d1.includes)==null?void 0:v1.call(d1,y1._id)})))if(g1.length){const y1=(m1=g1[g1.length-1])==null?void 0:m1._id;r1[f1.key]=`{{ literal ${jh(y1)} }}`}else delete r1[f1.key]}})},createInstance:(r1,o1,i1)=>{const a1=n1.actions.components.getDefinition(r1);if(!a1)return null;let s1={_id:uuid(),_component:a1.component,_styles:{normal:{},hover:{},active:{}},_instanceName:`New ${a1.friendlyName||a1.name}`,...o1};n1.actions.components.enrichEmptySettings(s1,{parent:i1,screen:get_store_value(selectedScreen),useDefaultValues:!0});let l1={};if(a1.hasChildren&&(l1._children=[]),r1.endsWith("/formstep")){const c1=findClosestMatchingComponent(get_store_value(selectedScreen).props,get_store_value(selectedComponent)._id,f1=>f1._component.endsWith("/form")),u1=findAllMatchingComponents(c1,f1=>f1._component.endsWith("/formstep"));l1.step=u1.length+1,l1._instanceName=`Step ${u1.length+1}`}return{...fp$1.cloneDeep(s1),...l1}},create:async(r1,o1,i1,a1)=>{const s1=get_store_value(n1),l1=n1.actions.components.createInstance(r1,o1,i1);if(l1)return i1&&a1!=null?await n1.actions.screens.patch(c1=>{var f1;let u1=findComponent(c1.props,i1);(f1=u1._children)!=null&&f1.length?u1._children.splice(a1,0,l1):u1._children=[l1]}):await n1.actions.screens.patch(c1=>{let u1=s1.selectedComponentId;u1.startsWith(`${c1._id}-`)&&(u1=c1==null?void 0:c1.props._id);const f1=findComponent(c1.props,u1);if(!f1)return!1;let d1;if(f1){const p1=n1.actions.components.getDefinition(f1._component);p1!=null&&p1.hasChildren?d1=f1:d1=findComponentParent(c1.props,f1._id)}else d1=c1.props;if(!d1)return!1;d1._children||(d1._children=[]),d1._children.push(l1)}),n1.update(c1=>(c1.selectedComponentId=l1._id,c1)),analytics.captureEvent(Events.COMPONENT_CREATED,{name:l1._component}),l1},patch:async(r1,o1,i1)=>{if(!o1||!i1){const s1=get_store_value(n1);o1=o1||s1.selectedComponentId,i1=i1||s1.selectedScreenId}if(!o1||!i1||!r1)return;const a1=s1=>{let l1=findComponent(s1.props,o1);return l1?r1(l1,s1):!1};await n1.actions.screens.patch(a1,i1)},delete:async r1=>{if(!r1)return;const o1=get_store_value(n1);let i1;o1.selectedComponentId===r1._id&&(i1=n1.actions.components.getNext(),i1||(i1=n1.actions.components.getPrevious())),await n1.actions.screens.patch(a1=>{if(r1=findComponent(a1.props,r1._id),!r1)return!1;const s1=findComponentParent(a1.props,r1._id);if(!s1)return!1;s1._children=s1._children.filter(l1=>l1._id!==r1._id)}),i1&&n1.update(a1=>(a1.selectedComponentId=i1,a1))},copy:(r1,o1=!1,i1=!0)=>{if(n1.update(a1=>(a1.componentToPaste=fp$1.cloneDeep(r1),a1.componentToPaste.isCut=o1,a1)),o1&&i1){const a1=get_store_value(selectedScreen),s1=findComponentParent(a1==null?void 0:a1.props,r1._id);s1&&n1.update(l1=>(l1.selectedComponentId=s1._id,l1))}},paste:async(r1,o1,i1)=>{const a1=get_store_value(n1);if(!a1.componentToPaste)return;let s1,l1=fp$1.cloneDeep(a1.componentToPaste);l1.isCut&&n1.update(f1=>(delete f1.componentToPaste,f1));const c1=f1=>{if(r1=findComponent(f1.props,r1._id),!r1)return!1;const d1=l1.isCut,p1=l1._id;if(delete l1.isCut,d1||(l1=makeComponentUnique(l1)),s1=l1._id,d1){const m1=findComponentParent(f1.props,p1);m1!=null&&m1._children&&(m1._children=m1._children.filter(_1=>_1._id!==p1))}if(o1==="inside"&&(n1.actions.components.getDefinition(r1._component).hasChildren||(o1="below")),o1==="inside")r1._children||(r1._children=[]),r1._children.push(l1);else{const m1=findComponentParent(f1.props,r1._id);if(!(m1!=null&&m1._children))return!1;const _1=m1._children.findIndex(g1=>g1._id===r1._id),h1=o1==="above"?_1:_1+1;m1._children.splice(h1,0,l1)}},u1=(i1==null?void 0:i1._id)||a1.selectedScreenId;await n1.actions.screens.patch(c1,u1),n1.update(f1=>(f1.selectedScreenId=u1,f1.selectedComponentId=s1,f1))},getPrevious:()=>{var u1,f1;const o1=get_store_value(n1).selectedComponentId,i1=get_store_value(selectedScreen),a1=findComponentParent(i1.props,o1),s1=a1==null?void 0:a1._children.findIndex(d1=>d1._id===o1),l1=`${i1._id}-screen`,c1=`${i1._id}-navigation`;if(o1===l1)return null;if(o1===c1)return l1;if(a1._id===i1.props._id&&s1===0)return c1;if(s1>0){const d1=a1._children[s1-1];if((u1=d1._children)!=null&&u1.length){let p1=d1;for(;(f1=p1._children)!=null&&f1.length;)p1=p1._children[p1._children.length-1];return p1._id}return d1._id}return a1._id},getNext:()=>{var m1,_1;const r1=get_store_value(n1),o1=get_store_value(selectedComponent),i1=o1==null?void 0:o1._id,a1=get_store_value(selectedScreen),s1=findComponentParent(a1.props,i1),l1=s1==null?void 0:s1._children.findIndex(h1=>h1._id===i1),c1=`${a1._id}-screen`,u1=`${a1._id}-navigation`;if(r1.selectedComponentId===c1)return u1;if((m1=o1._children)!=null&&m1.length)return o1._children[0]._id;if(!s1)return null;if(l1<s1._children.length-1)return s1._children[l1+1]._id;let f1=s1,d1=findComponentParent(a1.props,f1._id),p1=d1==null?void 0:d1._children.findIndex(h1=>h1._id===f1._id);for(;d1!=null&&p1===((_1=d1._children)==null?void 0:_1.length)-1;)f1=d1,d1=findComponentParent(a1.props,f1._id),p1=d1==null?void 0:d1._children.findIndex(h1=>h1._id===f1._id);return d1?d1._children[p1+1]._id:null},selectPrevious:()=>{const r1=n1.actions.components.getPrevious();r1&&n1.update(o1=>(o1.selectedComponentId=r1,o1))},selectNext:()=>{const r1=n1.actions.components.getNext();r1&&n1.update(o1=>(o1.selectedComponentId=r1,o1))},moveUp:async r1=>{await n1.actions.screens.patch(o1=>{const i1=r1==null?void 0:r1._id,a1=findComponentParent(o1.props,i1),s1=a1==null?void 0:a1._children.findIndex(c1=>c1._id===i1);if(!a1||s1===0&&a1._id===o1.props._id)return;const l1=fp$1.cloneDeep(a1._children[s1]);if(a1._children=a1._children.filter(c1=>c1._id!==i1),s1>0){const c1=a1._children[s1-1];n1.actions.components.getDefinition(c1._component).hasChildren?c1._children.push(l1):a1._children.splice(s1-1,0,l1)}else if(a1._id!==o1.props._id){const c1=findComponentParent(o1.props,a1._id),u1=c1._children.findIndex(f1=>f1._id===a1._id);c1._children.splice(u1,0,l1)}})},moveDown:async r1=>{await n1.actions.screens.patch(o1=>{var c1;const i1=r1==null?void 0:r1._id,a1=findComponentParent(o1.props,i1);if(!((c1=a1==null?void 0:a1._children)!=null&&c1.length))return!1;const s1=a1._children.findIndex(u1=>u1._id===i1);if(s1===a1._children.length-1&&a1._id===o1.props._id)return;const l1=fp$1.cloneDeep(a1._children[s1]);if(a1._children=a1._children.filter(u1=>u1._id!==i1),s1<a1._children.length){const u1=a1._children[s1];n1.actions.components.getDefinition(u1._component).hasChildren?u1._children.splice(0,0,l1):a1._children.splice(s1+1,0,l1)}else{const u1=findComponentParent(o1.props,a1._id),f1=u1._children.findIndex(d1=>d1._id===a1._id);u1._children.splice(f1+1,0,l1)}})},updateStyle:async(r1,o1)=>{await n1.actions.components.patch(i1=>{o1==null||o1===""?delete i1._styles.normal[r1]:i1._styles.normal[r1]=o1})},updateStyles:async(r1,o1)=>{const i1=a1=>{a1._styles.normal={...a1._styles.normal,...r1}};await n1.actions.components.patch(i1,o1)},updateCustomStyle:async r1=>{await n1.actions.components.patch(o1=>{o1._styles.custom=r1})},updateConditions:async r1=>{await n1.actions.components.patch(o1=>{o1._conditions=r1})},updateSetting:async(r1,o1)=>{await n1.actions.components.patch(n1.actions.components.updateComponentSetting(r1,o1))},updateComponentSetting:(r1,o1)=>i1=>{if(!r1||!i1||i1[r1]===o1)return!1;const a1=getComponentSettings(i1._component),s1=a1.find(c1=>c1.key===r1),l1=a1.filter(c1=>r1===c1.resetOn);if(l1==null||l1.forEach(c1=>{i1[c1.key]=null}),(s1==null?void 0:s1.type)==="dataSource"||(s1==null?void 0:s1.type)==="table"){const{schema:c1}=getSchemaForDatasource(null,o1),u1=Object.keys(c1||{});a1.filter(d1=>d1.type==="multifield"&&d1.selectAllFields).map(d1=>d1.key).forEach(d1=>{i1[d1]=u1})}i1[r1]=o1},requestEjectBlock:r1=>{n1.actions.preview.sendEvent("eject-block",r1)},handleEjectBlock:async(r1,o1)=>{let i1;await n1.actions.screens.patch(a1=>{var f1;const s1=findComponent(a1.props,r1),l1=findComponentParent(a1.props,r1);if(!s1||!((f1=l1==null?void 0:l1._children)!=null&&f1.length))return!1;analytics.captureEvent(Events.BLOCK_EJECTED,{block:s1._component});const c1=findAllMatchingComponents(o1,d1=>d1._containsSlot)[0];c1&&(delete c1._containsSlot,c1._children=[...c1._children||[],...s1._children||[]]),o1=makeComponentUnique(o1);const u1=l1._children.findIndex(d1=>d1._id===r1);l1._children[u1]=o1,i1=o1._id}),i1&&n1.update(a1=>(a1.selectedComponentId=i1,a1))},addParent:async(r1,o1)=>{if(!r1||!o1)return;const i1=n1.actions.components.createInstance(o1,null,parent);i1&&(await n1.actions.screens.patch(a1=>{let s1=findComponent(a1.props,r1),l1=findComponentParent(a1.props,r1);if(!s1||!l1)return!1;const c1=l1._children.findIndex(u1=>u1._id===r1);if(c1===-1)return!1;l1._children[c1]={...i1,_children:[s1]}}),n1.update(a1=>(a1.selectedComponentId=i1._id,a1)))}},links:{save:async(r1,o1)=>{const i1=get_store_value(n1).navigation;let a1=[...(i1==null?void 0:i1.links)??[]];a1.find(s1=>s1.url===r1&&s1.text===o1)||(a1.push({text:o1,url:r1}),await n1.actions.navigation.save({...i1,links:[...a1]}))},delete:async r1=>{const o1=get_store_value(n1).navigation;let i1=o1==null?void 0:o1.links;i1!=null&&i1.length&&(r1=Array.isArray(r1)?r1:[r1],i1=i1.filter(a1=>!r1.includes(a1.url)),await n1.actions.navigation.save({...o1,links:i1}))}},settings:{highlight:r1=>{n1.update(o1=>({...o1,highlightedSettingKey:r1}))},propertyFocus:r1=>{n1.update(o1=>({...o1,propertyFocus:r1}))}},dnd:{start:r1=>{n1.actions.preview.sendEvent("dragging-new-component",{dragging:!0,component:r1})},stop:()=>{n1.actions.preview.sendEvent("dragging-new-component",{dragging:!1})}},websocket:{selectResource:r1=>{e1.emit(BuilderSocketEvent.SelectResource,{resourceId:r1})}},metadata:{replace:r1=>{n1.update(o1=>({...o1,...r1}))}}},n1},initialAutomationState={automations:[],testResults:null,showTestPanel:!1,blockDefinitions:{TRIGGER:[],ACTION:[]},selectedAutomationId:null},getAutomationStore=()=>{const n1=writable(initialAutomationState);return n1.actions=automationActions(n1),n1},updateStepReferences=(n1,e1,t1)=>{n1.forEach(r1=>{updateReferencesInObject({obj:r1.inputs,modifiedIndex:e1,action:t1,label:"steps"})})},automationActions=n1=>({definitions:async()=>{const e1=await API.getAutomationDefinitions();return n1.update(t1=>(t1.blockDefinitions={TRIGGER:e1.trigger,ACTION:e1.action},t1)),e1},fetch:async()=>{const e1=await Promise.all([API.getAutomations(),API.getAutomationDefinitions()]);n1.update(t1=>(t1.automations=e1[0],t1.automations.sort((r1,o1)=>r1.name<o1.name?-1:1),t1.blockDefinitions={TRIGGER:e1[1].trigger,ACTION:e1[1].action},t1))},create:async(e1,t1)=>{const r1={name:e1,type:"automation",definition:{steps:[],trigger:t1}},o1=await n1.actions.save(r1);return await n1.actions.fetch(),n1.actions.select(o1._id),o1},duplicate:async e1=>{const t1=await n1.actions.save({...e1,name:`${e1.name} - copy`,_id:void 0,_ref:void 0});return await n1.actions.fetch(),n1.actions.select(t1._id),t1},save:async e1=>{const t1=await API.updateAutomation(e1);return n1.update(r1=>{const o1=t1.automation,i1=r1.automations.findIndex(a1=>a1._id===e1._id);return i1!==-1?(r1.automations.splice(i1,1,o1),r1):(r1.automations=[...r1.automations,o1],r1)}),t1.automation},delete:async e1=>{await API.deleteAutomation({automationId:e1==null?void 0:e1._id,automationRev:e1==null?void 0:e1._rev}),n1.update(t1=>{var r1;return t1.automations=t1.automations.filter(o1=>o1._id!==e1._id),e1._id===t1.selectedAutomationId&&n1.actions.select((r1=t1.automations[0])==null?void 0:r1._id),t1}),await n1.actions.fetch()},updateBlockInputs:async(e1,t1)=>{let r1={...e1,inputs:{...e1.inputs,...t1}};Object.keys(r1.inputs).forEach(a1=>{const s1=r1.inputs[a1];(s1==null||s1==="")&&delete r1.inputs[a1]});const o1=get_store_value(selectedAutomation),i1=n1.actions.getUpdatedDefinition(o1,r1);JSON.stringify(i1)!==JSON.stringify(o1)&&await n1.actions.save(i1)},test:async(e1,t1)=>{var o1,i1;const r1=await API.testAutomation({automationId:e1==null?void 0:e1._id,testData:t1});if(!(r1!=null&&r1.trigger)&&!((o1=r1==null?void 0:r1.steps)!=null&&o1.length))throw((i1=r1==null?void 0:r1.err)==null?void 0:i1.code)==="usage_limit_exceeded"?"You have exceeded your automation quota":"Something went wrong testing your automation";n1.update(a1=>(a1.testResults=r1,a1))},getDefinition:e1=>{var t1;return(t1=get_store_value(n1).automations)==null?void 0:t1.find(r1=>r1._id===e1)},getUpdatedDefinition:(e1,t1)=>{var o1;let r1=fp$1.cloneDeep(e1);if(((o1=e1.definition.trigger)==null?void 0:o1.id)===t1.id)r1.definition.trigger=t1;else{const i1=e1.definition.steps.findIndex(a1=>a1.id===t1.id);r1.definition.steps.splice(i1,1,t1)}return r1},select:e1=>{!e1||e1===get_store_value(n1).selectedAutomationId||n1.update(t1=>(t1.selectedAutomationId=e1,t1.testResults=null,t1.showTestPanel=!1,t1))},getLogs:async({automationId:e1,startDate:t1,status:r1,page:o1}={})=>await API.getAutomationLogs({automationId:e1,startDate:t1,status:r1,page:o1}),clearLogErrors:async({automationId:e1,appId:t1}={})=>await API.clearAutomationLogErrors({automationId:e1,appId:t1}),addTestDataToAutomation:async e1=>{let t1=fp$1.cloneDeep(get_store_value(selectedAutomation));t1.testData={...t1.testData,...e1},await n1.actions.save(t1)},constructBlock(e1,t1,r1){return{...r1,inputs:r1.inputs||{},stepId:t1,type:e1,id:shortid.generate()}},addBlockToAutomation:async(e1,t1)=>{const r1=get_store_value(selectedAutomation);let o1=fp$1.cloneDeep(r1);if(r1){try{updateStepReferences(o1.definition.steps,t1,"add")}catch{notifications.error("Error adding automation block")}o1.definition.steps.splice(t1,0,e1),await n1.actions.save(o1)}},saveAutomationName:async(e1,t1)=>{const r1=get_store_value(selectedAutomation);let o1=fp$1.cloneDeep(r1);r1&&(o1.definition.stepNames={...o1.definition.stepNames,[e1]:t1.trim()},await n1.actions.save(o1))},deleteAutomationName:async e1=>{const t1=get_store_value(selectedAutomation);let r1=fp$1.cloneDeep(t1);t1&&(delete r1.definition.stepNames[e1],await n1.actions.save(r1))},deleteAutomationBlock:async(e1,t1)=>{var i1,a1;const r1=get_store_value(selectedAutomation);let o1=fp$1.cloneDeep(r1);((i1=o1.definition.trigger)==null?void 0:i1.id)===e1.id?delete o1.definition.trigger:(o1.definition.steps=o1.definition.steps.filter(s1=>s1.id!==e1.id),(a1=o1.definition.stepNames)==null||delete a1[e1.id]);try{updateStepReferences(o1.definition.steps,t1,"delete")}catch{notifications.error("Error deleting automation block")}await n1.actions.save(o1)},replace:async(e1,t1)=>{if(!t1)n1.update(r1=>{var o1;return r1.automations=r1.automations.filter(i1=>i1._id!==e1),e1===r1.selectedAutomationId&&n1.actions.select((o1=r1.automations[0])==null?void 0:o1._id),r1});else{const r1=get_store_value(n1).automations.findIndex(o1=>o1._id===t1._id);r1===-1?n1.update(o1=>({...o1,automations:[...o1.automations,t1]})):n1.update(o1=>(o1.automations[r1]=t1,o1))}}}),getTemporalStore=()=>{const t1=createLocalStorageStore("bb-temporal",{}),r1=(i1,a1,s1)=>{const l1={...a1,expiry:Date.now()+s1*1e3};t1.update(c1=>({...c1,[i1]:l1}))},o1=i1=>{const a1=get_store_value(t1)[i1];return a1?a1.expiry<Date.now()?(t1.update(l1=>(delete l1[i1],l1)),null):a1:void 0};return{subscribe:t1.subscribe,actions:{setExpiring:r1,getExpiring:o1}}},getThemeStore=()=>{const n1=document.documentElement,e1={theme:"darkest"},t1=createLocalStorageStore("bb-theme",e1);return t1.subscribe(r1=>{if(r1.darkMode!==void 0){t1.set(e1);return}Themes.forEach(i1=>{n1.classList.toggle(`spectrum--${i1.class}`,i1.class===r1.theme)});const o1=Themes.find(i1=>i1.class===r1.theme);o1!=null&&o1.base&&n1.classList.add(`spectrum--${o1.base}`)}),t1},getUserStore=()=>{const n1=writable([]);return{...n1,actions:{init:i1=>{n1.set(i1)},updateUser:i1=>{const a1=get_store_value(n1);a1.some(s1=>s1.sessionId===i1.sessionId)?n1.update(s1=>{const l1=s1.findIndex(c1=>c1.sessionId===i1.sessionId);return s1[l1]=i1,s1.slice()}):n1.set([...a1,i1])},removeUser:i1=>{n1.update(a1=>a1.filter(s1=>s1.sessionId!==i1))},reset:()=>{n1.set([])}}}},getDeploymentStore=()=>{let n1=writable([]);const e1=async()=>{try{n1.set(await API.getAppDeployments())}catch{notifications.error("Error fetching deployments")}};return{subscribe:n1.subscribe,actions:{load:e1}}};/*!
427
427
  * https://github.com/Starcounter-Jack/JSON-Patch
428
428
  * (c) 2017-2022 Joachim Wester
429
429
  * MIT licensed
@@ -432,7 +432,7 @@ function print() { __p += __j.call(arguments, '') }
432
432
  * https://github.com/Starcounter-Jack/JSON-Patch
433
433
  * (c) 2017-2021 Joachim Wester
434
434
  * MIT license
435
- */var beforeDict=new WeakMap,Mirror=function(){function n1(e1){this.observers=new Map,this.obj=e1}return n1}(),ObserverInfo=function(){function n1(e1,t1){this.callback=e1,this.observer=t1}return n1}();function getMirror(n1){return beforeDict.get(n1)}function getObserverFromMirror(n1,e1){return n1.observers.get(e1)}function removeObserverFromMirror(n1,e1){n1.observers.delete(e1.callback)}function unobserve(n1,e1){e1.unobserve()}function observe$1(n1,e1){var t1=[],r1,o1=getMirror(n1);if(!o1)o1=new Mirror(n1),beforeDict.set(n1,o1);else{var i1=getObserverFromMirror(o1,e1);r1=i1&&i1.observer}if(r1)return r1;if(r1={},o1.value=_deepClone(n1),e1){r1.callback=e1,r1.next=null;var a1=function(){generate$1(r1)},s1=function(){clearTimeout(r1.next),r1.next=setTimeout(a1)};typeof window<"u"&&(window.addEventListener("mouseup",s1),window.addEventListener("keyup",s1),window.addEventListener("mousedown",s1),window.addEventListener("keydown",s1),window.addEventListener("change",s1))}return r1.patches=t1,r1.object=n1,r1.unobserve=function(){generate$1(r1),clearTimeout(r1.next),removeObserverFromMirror(o1,r1),typeof window<"u"&&(window.removeEventListener("mouseup",s1),window.removeEventListener("keyup",s1),window.removeEventListener("mousedown",s1),window.removeEventListener("keydown",s1),window.removeEventListener("change",s1))},o1.observers.set(e1,new ObserverInfo(e1,r1)),r1}function generate$1(n1,e1){e1===void 0&&(e1=!1);var t1=beforeDict.get(n1.object);_generate(t1.value,n1.object,n1.patches,"",e1),n1.patches.length&&applyPatch(t1.value,n1.patches);var r1=n1.patches;return r1.length>0&&(n1.patches=[],n1.callback&&n1.callback(r1)),r1}function _generate(n1,e1,t1,r1,o1){if(e1!==n1){typeof e1.toJSON=="function"&&(e1=e1.toJSON());for(var i1=_objectKeys(e1),a1=_objectKeys(n1),s1=!1,l1=a1.length-1;l1>=0;l1--){var c1=a1[l1],u1=n1[c1];if(hasOwnProperty$r(e1,c1)&&!(e1[c1]===void 0&&u1!==void 0&&Array.isArray(e1)===!1)){var f1=e1[c1];typeof u1=="object"&&u1!=null&&typeof f1=="object"&&f1!=null&&Array.isArray(u1)===Array.isArray(f1)?_generate(u1,f1,t1,r1+"/"+escapePathComponent(c1),o1):u1!==f1&&(o1&&t1.push({op:"test",path:r1+"/"+escapePathComponent(c1),value:_deepClone(u1)}),t1.push({op:"replace",path:r1+"/"+escapePathComponent(c1),value:_deepClone(f1)}))}else Array.isArray(n1)===Array.isArray(e1)?(o1&&t1.push({op:"test",path:r1+"/"+escapePathComponent(c1),value:_deepClone(u1)}),t1.push({op:"remove",path:r1+"/"+escapePathComponent(c1)}),s1=!0):(o1&&t1.push({op:"test",path:r1,value:n1}),t1.push({op:"replace",path:r1,value:e1}))}if(!(!s1&&i1.length==a1.length))for(var l1=0;l1<i1.length;l1++){var c1=i1[l1];!hasOwnProperty$r(n1,c1)&&e1[c1]!==void 0&&t1.push({op:"add",path:r1+"/"+escapePathComponent(c1),value:_deepClone(e1[c1])})}}}function compare$1(n1,e1,t1){t1===void 0&&(t1=!1);var r1=[];return _generate(n1,e1,r1,"",t1),r1}const duplex=Object.freeze(Object.defineProperty({__proto__:null,compare:compare$1,generate:generate$1,observe:observe$1,unobserve},Symbol.toStringTag,{value:"Module"}));Object.assign({},core,duplex,{JsonPatchError:PatchError,deepClone:_deepClone,escapePathComponent,unescapePathComponent});const Operations={Add:"Add",Delete:"Delete",Change:"Change"},initialState$1={history:[],position:0,loading:!1},createHistoryStore=({getDoc:n1,selectDoc:e1,beforeAction:t1,afterAction:r1})=>{const o1=writable(initialState$1),i1=derived(o1,h1=>({...h1,canUndo:h1.position>0,canRedo:h1.position<h1.history.length}));let a1,s1;const l1=()=>{o1.update(h1=>(h1.loading=!0,h1))},c1=()=>{o1.update(h1=>(h1.loading=!1,h1))},u1=()=>{o1.set(initialState$1)},f1=h1=>{o1.update(g1=>{let $1=g1.history,y1=g1.position;if(!h1.id)h1.id=Math.random(),$1=[...$1.slice(0,g1.position),h1],y1+=1;else{const v1=$1.findIndex(S1=>S1.id===h1.id);$1[v1].doc=h1.doc}return{history:$1,position:y1}})},d1=h1=>(a1=async(g1,$1)=>{if(!(!g1||Array.isArray(g1))){l1();try{const y1=n1(g1._id),v1=_deepClone(await h1(g1));return f1(y1?{type:Operations.Change,forwardPatch:compare$1(y1,g1),backwardsPatch:compare$1(g1,y1),doc:v1,id:$1}:{type:Operations.Add,doc:v1,id:$1}),c1(),v1}catch(y1){throw c1(),y1}}},a1),p1=h1=>(s1=async(g1,$1)=>{if(!(!g1||Array.isArray(g1))){l1();try{const y1=_deepClone(g1);await h1(g1),f1({type:Operations.Delete,doc:y1,id:$1}),c1()}catch(y1){throw c1(),y1}}},s1),m1=async()=>{const{canUndo:h1,history:g1,position:$1,loading:y1}=get_store_value(i1);if(!h1||y1)return;const v1=g1[$1-1];if(v1){l1(),await(t1==null?void 0:t1(v1)),o1.update(S1=>({...S1,position:S1.position-1}));try{if(v1.type===Operations.Add){const O1=n1(v1.doc._id)||v1.doc;await s1(O1,v1.id)}else if(v1.type===Operations.Delete){let S1=_deepClone(v1.doc);delete S1._rev;const O1=await a1(S1,v1.id);e1==null||e1((O1==null?void 0:O1._id)||S1._id)}else{let S1=_deepClone(n1(v1.doc._id));S1&&(applyPatch(S1,_deepClone(v1.backwardsPatch)),await a1(S1,v1.id),e1==null||e1(S1._id))}c1()}catch(S1){throw c1(),S1}await(r1==null?void 0:r1(v1))}},_1=async()=>{const{canRedo:h1,history:g1,position:$1,loading:y1}=get_store_value(i1);if(!h1||y1)return;const v1=g1[$1];if(v1){l1(),await(t1==null?void 0:t1(v1)),o1.update(S1=>({...S1,position:S1.position+1}));try{if(v1.type===Operations.Add){let S1=_deepClone(v1.doc);delete S1._rev;const O1=await a1(S1,v1.id);e1==null||e1((O1==null?void 0:O1._id)||S1._id)}else if(v1.type===Operations.Delete){const O1=n1(v1.doc._id)||v1.doc;await s1(O1,v1.id)}else{let S1=_deepClone(n1(v1.doc._id));S1&&(applyPatch(S1,_deepClone(v1.forwardPatch)),await a1(S1,v1.id),e1==null||e1(S1._id))}c1()}catch(S1){throw c1(),S1}await(r1==null?void 0:r1(v1))}};return{subscribe:i1.subscribe,wrapSaveDoc:d1,wrapDeleteDoc:p1,reset:u1,undo:m1,redo:_1}},store=getFrontendStore(),automationStore=getAutomationStore(),themeStore=getThemeStore(),temporalStore=getTemporalStore(),userStore=getUserStore(),deploymentStore=getDeploymentStore(),screenHistoryStore=createHistoryStore({getDoc:n1=>{var e1;return(e1=get_store_value(store).screens)==null?void 0:e1.find(t1=>t1._id===n1)},selectDoc:store.actions.screens.select,afterAction:()=>{get_store_value(selectedComponent)||store.update(n1=>{var e1;return{...n1,selectedComponentId:(e1=get_store_value(selectedScreen))==null?void 0:e1.props._id}})}});store.actions.screens.save=screenHistoryStore.wrapSaveDoc(store.actions.screens.save);store.actions.screens.delete=screenHistoryStore.wrapDeleteDoc(store.actions.screens.delete);const automationHistoryStore=createHistoryStore({getDoc:automationStore.actions.getDefinition,selectDoc:automationStore.actions.select});automationStore.actions.save=automationHistoryStore.wrapSaveDoc(automationStore.actions.save);automationStore.actions.delete=automationHistoryStore.wrapDeleteDoc(automationStore.actions.delete);const selectedScreen=derived(store,n1=>n1.screens.find(e1=>e1._id===n1.selectedScreenId));derived(store,n1=>{var e1;return(e1=n1.layouts)==null?void 0:e1.find(t1=>t1._id===n1.selectedLayoutId)});const selectedComponent=derived([store,selectedScreen],([n1,e1])=>{var o1;if(e1&&((o1=n1.selectedComponentId)!=null&&o1.startsWith(`${e1._id}-`)))return e1==null?void 0:e1.props;if(!e1||!n1.selectedComponentId)return null;const t1=findComponent(e1==null?void 0:e1.props,n1.selectedComponentId),r1=t1&&fp$1.cloneDeep(t1);return store.actions.components.migrateSettings(r1),r1}),currentAsset=selectedScreen,sortedScreens=derived(store,n1=>n1.screens.slice().sort((e1,t1)=>{const r1=getRolePriority(e1.routing.roleId),o1=getRolePriority(t1.routing.roleId);if(r1!==o1)return r1>o1?-1:1;const i1=!!e1.routing.homeScreen,a1=!!t1.routing.homeScreen;if(i1!==a1)return i1?-1:1;const s1=e1.routing.route.split("/"),l1=t1.routing.route.split("/");let c1=Math.min(s1.length,l1.length);for(let u1=0;u1<c1;u1++)if(s1[u1]!==l1[u1])return s1[u1]<l1[u1]?-1:1;return s1.length<l1.length?-1:1})),selectedComponentPath=derived([store,selectedScreen],([n1,e1])=>findComponentPath(e1==null?void 0:e1.props,n1.selectedComponentId).map(t1=>t1._id)),selectedAutomation=derived(automationStore,n1=>{var e1;return n1.selectedAutomationId?(e1=n1.automations)==null?void 0:e1.find(t1=>t1._id===n1.selectedAutomationId):null}),userSelectedResourceMap=derived(userStore,n1=>{let e1={};return n1.forEach(t1=>{var o1;const r1=(o1=t1.builderMetadata)==null?void 0:o1.selectedResourceId;r1&&(e1[r1]||(e1[r1]=[]),e1[r1].push(t1))}),e1}),isOnlyUser=derived(userStore,n1=>n1.length<2),API=createAPIClient({attachHeaders:n1=>{let e1=get_store_value(store).appId;e1&&(n1["x-budibase-app-id"]=e1);const t1=get_store_value(auth).user;t1!=null&&t1.csrfToken&&(n1["x-csrf-token"]=t1.csrfToken)},onError:n1=>{const{url:e1,message:t1,status:r1,method:o1,handled:i1}=n1||{};if(!i1){console.error("Unhandled error from API client",n1);return}console.warn(`[Builder] HTTP ${r1} on ${o1}:${e1}
435
+ */var beforeDict=new WeakMap,Mirror=function(){function n1(e1){this.observers=new Map,this.obj=e1}return n1}(),ObserverInfo=function(){function n1(e1,t1){this.callback=e1,this.observer=t1}return n1}();function getMirror(n1){return beforeDict.get(n1)}function getObserverFromMirror(n1,e1){return n1.observers.get(e1)}function removeObserverFromMirror(n1,e1){n1.observers.delete(e1.callback)}function unobserve(n1,e1){e1.unobserve()}function observe$1(n1,e1){var t1=[],r1,o1=getMirror(n1);if(!o1)o1=new Mirror(n1),beforeDict.set(n1,o1);else{var i1=getObserverFromMirror(o1,e1);r1=i1&&i1.observer}if(r1)return r1;if(r1={},o1.value=_deepClone(n1),e1){r1.callback=e1,r1.next=null;var a1=function(){generate$1(r1)},s1=function(){clearTimeout(r1.next),r1.next=setTimeout(a1)};typeof window<"u"&&(window.addEventListener("mouseup",s1),window.addEventListener("keyup",s1),window.addEventListener("mousedown",s1),window.addEventListener("keydown",s1),window.addEventListener("change",s1))}return r1.patches=t1,r1.object=n1,r1.unobserve=function(){generate$1(r1),clearTimeout(r1.next),removeObserverFromMirror(o1,r1),typeof window<"u"&&(window.removeEventListener("mouseup",s1),window.removeEventListener("keyup",s1),window.removeEventListener("mousedown",s1),window.removeEventListener("keydown",s1),window.removeEventListener("change",s1))},o1.observers.set(e1,new ObserverInfo(e1,r1)),r1}function generate$1(n1,e1){e1===void 0&&(e1=!1);var t1=beforeDict.get(n1.object);_generate(t1.value,n1.object,n1.patches,"",e1),n1.patches.length&&applyPatch(t1.value,n1.patches);var r1=n1.patches;return r1.length>0&&(n1.patches=[],n1.callback&&n1.callback(r1)),r1}function _generate(n1,e1,t1,r1,o1){if(e1!==n1){typeof e1.toJSON=="function"&&(e1=e1.toJSON());for(var i1=_objectKeys(e1),a1=_objectKeys(n1),s1=!1,l1=a1.length-1;l1>=0;l1--){var c1=a1[l1],u1=n1[c1];if(hasOwnProperty$r(e1,c1)&&!(e1[c1]===void 0&&u1!==void 0&&Array.isArray(e1)===!1)){var f1=e1[c1];typeof u1=="object"&&u1!=null&&typeof f1=="object"&&f1!=null&&Array.isArray(u1)===Array.isArray(f1)?_generate(u1,f1,t1,r1+"/"+escapePathComponent(c1),o1):u1!==f1&&(o1&&t1.push({op:"test",path:r1+"/"+escapePathComponent(c1),value:_deepClone(u1)}),t1.push({op:"replace",path:r1+"/"+escapePathComponent(c1),value:_deepClone(f1)}))}else Array.isArray(n1)===Array.isArray(e1)?(o1&&t1.push({op:"test",path:r1+"/"+escapePathComponent(c1),value:_deepClone(u1)}),t1.push({op:"remove",path:r1+"/"+escapePathComponent(c1)}),s1=!0):(o1&&t1.push({op:"test",path:r1,value:n1}),t1.push({op:"replace",path:r1,value:e1}))}if(!(!s1&&i1.length==a1.length))for(var l1=0;l1<i1.length;l1++){var c1=i1[l1];!hasOwnProperty$r(n1,c1)&&e1[c1]!==void 0&&t1.push({op:"add",path:r1+"/"+escapePathComponent(c1),value:_deepClone(e1[c1])})}}}function compare$1(n1,e1,t1){t1===void 0&&(t1=!1);var r1=[];return _generate(n1,e1,r1,"",t1),r1}const duplex=Object.freeze(Object.defineProperty({__proto__:null,compare:compare$1,generate:generate$1,observe:observe$1,unobserve},Symbol.toStringTag,{value:"Module"}));Object.assign({},core,duplex,{JsonPatchError:PatchError,deepClone:_deepClone,escapePathComponent,unescapePathComponent});const Operations={Add:"Add",Delete:"Delete",Change:"Change"},initialState$1={history:[],position:0,loading:!1},createHistoryStore=({getDoc:n1,selectDoc:e1,beforeAction:t1,afterAction:r1})=>{const o1=writable(initialState$1),i1=derived(o1,h1=>({...h1,canUndo:h1.position>0,canRedo:h1.position<h1.history.length}));let a1,s1;const l1=()=>{o1.update(h1=>(h1.loading=!0,h1))},c1=()=>{o1.update(h1=>(h1.loading=!1,h1))},u1=()=>{o1.set(initialState$1)},f1=h1=>{o1.update(g1=>{let $1=g1.history,y1=g1.position;if(!h1.id)h1.id=Math.random(),$1=[...$1.slice(0,g1.position),h1],y1+=1;else{const v1=$1.findIndex(S1=>S1.id===h1.id);$1[v1].doc=h1.doc}return{history:$1,position:y1}})},d1=h1=>(a1=async(g1,$1)=>{if(!(!g1||Array.isArray(g1))){l1();try{const y1=n1(g1._id),v1=_deepClone(await h1(g1));return f1(y1?{type:Operations.Change,forwardPatch:compare$1(y1,g1),backwardsPatch:compare$1(g1,y1),doc:v1,id:$1}:{type:Operations.Add,doc:v1,id:$1}),c1(),v1}catch(y1){throw c1(),y1}}},a1),p1=h1=>(s1=async(g1,$1)=>{if(!(!g1||Array.isArray(g1))){l1();try{const y1=_deepClone(g1);await h1(g1),f1({type:Operations.Delete,doc:y1,id:$1}),c1()}catch(y1){throw c1(),y1}}},s1),m1=async()=>{const{canUndo:h1,history:g1,position:$1,loading:y1}=get_store_value(i1);if(!h1||y1)return;const v1=g1[$1-1];if(v1){l1(),await(t1==null?void 0:t1(v1)),o1.update(S1=>({...S1,position:S1.position-1}));try{if(v1.type===Operations.Add){const O1=n1(v1.doc._id)||v1.doc;await s1(O1,v1.id)}else if(v1.type===Operations.Delete){let S1=_deepClone(v1.doc);delete S1._rev;const O1=await a1(S1,v1.id);e1==null||e1((O1==null?void 0:O1._id)||S1._id)}else{let S1=_deepClone(n1(v1.doc._id));S1&&(applyPatch(S1,_deepClone(v1.backwardsPatch)),await a1(S1,v1.id),e1==null||e1(S1._id))}c1()}catch(S1){throw c1(),S1}await(r1==null?void 0:r1(v1))}},_1=async()=>{const{canRedo:h1,history:g1,position:$1,loading:y1}=get_store_value(i1);if(!h1||y1)return;const v1=g1[$1];if(v1){l1(),await(t1==null?void 0:t1(v1)),o1.update(S1=>({...S1,position:S1.position+1}));try{if(v1.type===Operations.Add){let S1=_deepClone(v1.doc);delete S1._rev;const O1=await a1(S1,v1.id);e1==null||e1((O1==null?void 0:O1._id)||S1._id)}else if(v1.type===Operations.Delete){const O1=n1(v1.doc._id)||v1.doc;await s1(O1,v1.id)}else{let S1=_deepClone(n1(v1.doc._id));S1&&(applyPatch(S1,_deepClone(v1.forwardPatch)),await a1(S1,v1.id),e1==null||e1(S1._id))}c1()}catch(S1){throw c1(),S1}await(r1==null?void 0:r1(v1))}};return{subscribe:i1.subscribe,wrapSaveDoc:d1,wrapDeleteDoc:p1,reset:u1,undo:m1,redo:_1}},store=getFrontendStore(),automationStore=getAutomationStore(),themeStore=getThemeStore(),temporalStore=getTemporalStore(),userStore=getUserStore(),deploymentStore=getDeploymentStore(),screenHistoryStore=createHistoryStore({getDoc:n1=>{var e1;return(e1=get_store_value(store).screens)==null?void 0:e1.find(t1=>t1._id===n1)},selectDoc:store.actions.screens.select,afterAction:()=>{get_store_value(selectedComponent)||store.update(n1=>{var e1;return{...n1,selectedComponentId:(e1=get_store_value(selectedScreen))==null?void 0:e1.props._id}})}});store.actions.screens.save=screenHistoryStore.wrapSaveDoc(store.actions.screens.save);store.actions.screens.delete=screenHistoryStore.wrapDeleteDoc(store.actions.screens.delete);const automationHistoryStore=createHistoryStore({getDoc:automationStore.actions.getDefinition,selectDoc:automationStore.actions.select});automationStore.actions.save=automationHistoryStore.wrapSaveDoc(automationStore.actions.save);automationStore.actions.delete=automationHistoryStore.wrapDeleteDoc(automationStore.actions.delete);const selectedScreen=derived(store,n1=>n1.screens.find(e1=>e1._id===n1.selectedScreenId));derived(store,n1=>{var e1;return(e1=n1.layouts)==null?void 0:e1.find(t1=>t1._id===n1.selectedLayoutId)});const selectedComponent=derived([store,selectedScreen],([n1,e1])=>{var t1;return e1&&((t1=n1.selectedComponentId)!=null&&t1.startsWith(`${e1._id}-`))?e1==null?void 0:e1.props:!e1||!n1.selectedComponentId?null:findComponent(e1==null?void 0:e1.props,n1.selectedComponentId)}),currentAsset=selectedScreen,sortedScreens=derived(store,n1=>n1.screens.slice().sort((e1,t1)=>{const r1=getRolePriority(e1.routing.roleId),o1=getRolePriority(t1.routing.roleId);if(r1!==o1)return r1>o1?-1:1;const i1=!!e1.routing.homeScreen,a1=!!t1.routing.homeScreen;if(i1!==a1)return i1?-1:1;const s1=e1.routing.route.split("/"),l1=t1.routing.route.split("/");let c1=Math.min(s1.length,l1.length);for(let u1=0;u1<c1;u1++)if(s1[u1]!==l1[u1])return s1[u1]<l1[u1]?-1:1;return s1.length<l1.length?-1:1})),selectedComponentPath=derived([store,selectedScreen],([n1,e1])=>findComponentPath(e1==null?void 0:e1.props,n1.selectedComponentId).map(t1=>t1._id)),selectedAutomation=derived(automationStore,n1=>{var e1;return n1.selectedAutomationId?(e1=n1.automations)==null?void 0:e1.find(t1=>t1._id===n1.selectedAutomationId):null}),userSelectedResourceMap=derived(userStore,n1=>{let e1={};return n1.forEach(t1=>{var o1;const r1=(o1=t1.builderMetadata)==null?void 0:o1.selectedResourceId;r1&&(e1[r1]||(e1[r1]=[]),e1[r1].push(t1))}),e1}),isOnlyUser=derived(userStore,n1=>n1.length<2),API=createAPIClient({attachHeaders:n1=>{let e1=get_store_value(store).appId;e1&&(n1["x-budibase-app-id"]=e1);const t1=get_store_value(auth).user;t1!=null&&t1.csrfToken&&(n1["x-csrf-token"]=t1.csrfToken)},onError:n1=>{const{url:e1,message:t1,status:r1,method:o1,handled:i1}=n1||{};if(!i1){console.error("Unhandled error from API client",n1);return}console.warn(`[Builder] HTTP ${r1} on ${o1}:${e1}
436
436
  ${t1}`),r1===403&&(removeCookie(Cookies.Auth),!e1.includes("self")&&!e1.includes("login")&&location.reload())}}),Logo$1="/builder/assets/bb-emblem-5d011fde.svg",handleError=n1=>{let e1={...n1};return Object.keys(e1).reduce((t1,r1)=>(e1[r1]&&(t1[r1]=e1[r1]),t1),{})},passwordsMatch=(n1,e1)=>{let t1=e1==null?void 0:e1.trim(),r1=n1==null?void 0:n1.trim();return typeof t1=="string"&&typeof r1=="string"&&t1==r1},index_svelte_svelte_type_style_lang$t="";function create_default_slot_8$y(n1){let e1;return{c(){e1=text("Create an admin user")},m(t1,r1){insert$1(t1,e1,r1)},d(t1){t1&&detach(e1)}}}function create_default_slot_7$N(n1){let e1;return{c(){e1=text("The admin user has access to everything in Budibase.")},m(t1,r1){insert$1(t1,e1,r1)},d(t1){t1&&detach(e1)}}}function create_default_slot_6$W(n1){let e1,t1,r1,o1,i1,a1,s1;return o1=new Heading({props:{size:"M",$$slots:{default:[create_default_slot_8$y]},$$scope:{ctx:n1}}}),a1=new Body({props:{$$slots:{default:[create_default_slot_7$N]},$$scope:{ctx:n1}}}),{c(){e1=element("img"),r1=space$1(),create_component(o1.$$.fragment),i1=space$1(),create_component(a1.$$.fragment),attr(e1,"alt","logo"),src_url_equal(e1.src,t1=Logo$1)||attr(e1,"src",t1),attr(e1,"class","svelte-1rej6a3")},m(l1,c1){insert$1(l1,e1,c1),insert$1(l1,r1,c1),mount_component(o1,l1,c1),insert$1(l1,i1,c1),mount_component(a1,l1,c1),s1=!0},p(l1,c1){const u1={};c1&32768&&(u1.$$scope={dirty:c1,ctx:l1}),o1.$set(u1);const f1={};c1&32768&&(f1.$$scope={dirty:c1,ctx:l1}),a1.$set(f1)},i(l1){s1||(transition_in(o1.$$.fragment,l1),transition_in(a1.$$.fragment,l1),s1=!0)},o(l1){transition_out(o1.$$.fragment,l1),transition_out(a1.$$.fragment,l1),s1=!1},d(l1){l1&&detach(e1),l1&&detach(r1),destroy_component(o1,l1),l1&&detach(i1),destroy_component(a1,l1)}}}function create_default_slot_5$17(n1){let e1,t1,r1,o1,i1,a1;return e1=new FancyInput({props:{label:"Email",value:n1[2].email,validate:n1[6],disabled:n1[3],error:n1[1].email}}),e1.$on("change",n1[7]),r1=new FancyInput({props:{label:"Password",value:n1[2].password,type:"password",validate:n1[8],error:n1[1].password,disabled:n1[3]}}),r1.$on("change",n1[9]),i1=new FancyInput({props:{label:"Repeat Password",value:n1[2].confirmationPassword,type:"password",validate:n1[10],error:n1[1].confirmationPassword,disabled:n1[3]}}),i1.$on("change",n1[11]),{c(){create_component(e1.$$.fragment),t1=space$1(),create_component(r1.$$.fragment),o1=space$1(),create_component(i1.$$.fragment)},m(s1,l1){mount_component(e1,s1,l1),insert$1(s1,t1,l1),mount_component(r1,s1,l1),insert$1(s1,o1,l1),mount_component(i1,s1,l1),a1=!0},p(s1,l1){const c1={};l1&4&&(c1.value=s1[2].email),l1&6&&(c1.validate=s1[6]),l1&8&&(c1.disabled=s1[3]),l1&2&&(c1.error=s1[1].email),e1.$set(c1);const u1={};l1&4&&(u1.value=s1[2].password),l1&6&&(u1.validate=s1[8]),l1&2&&(u1.error=s1[1].password),l1&8&&(u1.disabled=s1[3]),r1.$set(u1);const f1={};l1&4&&(f1.value=s1[2].confirmationPassword),l1&6&&(f1.validate=s1[10]),l1&2&&(f1.error=s1[1].confirmationPassword),l1&8&&(f1.disabled=s1[3]),i1.$set(f1)},i(s1){a1||(transition_in(e1.$$.fragment,s1),transition_in(r1.$$.fragment,s1),transition_in(i1.$$.fragment,s1),a1=!0)},o(s1){transition_out(e1.$$.fragment,s1),transition_out(r1.$$.fragment,s1),transition_out(i1.$$.fragment,s1),a1=!1},d(s1){destroy_component(e1,s1),s1&&detach(t1),destroy_component(r1,s1),s1&&detach(o1),destroy_component(i1,s1)}}}function create_default_slot_4$1q(n1){let e1,t1,r1={$$slots:{default:[create_default_slot_5$17]},$$scope:{ctx:n1}};return e1=new FancyForm({props:r1}),n1[12](e1),{c(){create_component(e1.$$.fragment)},m(o1,i1){mount_component(e1,o1,i1),t1=!0},p(o1,i1){const a1={};i1&32782&&(a1.$$scope={dirty:i1,ctx:o1}),e1.$set(a1)},i(o1){t1||(transition_in(e1.$$.fragment,o1),t1=!0)},o(o1){transition_out(e1.$$.fragment,o1),t1=!1},d(o1){n1[12](null),destroy_component(e1,o1)}}}function create_default_slot_3$1U(n1){let e1;return{c(){e1=text("Create super admin user")},m(t1,r1){insert$1(t1,e1,r1)},d(t1){t1&&detach(e1)}}}function create_default_slot_2$2y(n1){let e1,t1;return e1=new Button({props:{cta:!0,size:"L",disabled:Object.keys(n1[1]).length>0||n1[3],$$slots:{default:[create_default_slot_3$1U]},$$scope:{ctx:n1}}}),e1.$on("click",n1[4]),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&10&&(i1.disabled=Object.keys(r1[1]).length>0||r1[3]),o1&32768&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_default_slot_1$3x(n1){let e1,t1,r1,o1,i1,a1;return e1=new Layout$n({props:{justifyItems:"center",noPadding:!0,$$slots:{default:[create_default_slot_6$W]},$$scope:{ctx:n1}}}),r1=new Layout$n({props:{gap:"S",noPadding:!0,$$slots:{default:[create_default_slot_4$1q]},$$scope:{ctx:n1}}}),i1=new Layout$n({props:{gap:"XS",noPadding:!0,justifyItems:"center",$$slots:{default:[create_default_slot_2$2y]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment),t1=space$1(),create_component(r1.$$.fragment),o1=space$1(),create_component(i1.$$.fragment)},m(s1,l1){mount_component(e1,s1,l1),insert$1(s1,t1,l1),mount_component(r1,s1,l1),insert$1(s1,o1,l1),mount_component(i1,s1,l1),a1=!0},p(s1,l1){const c1={};l1&32768&&(c1.$$scope={dirty:l1,ctx:s1}),e1.$set(c1);const u1={};l1&32783&&(u1.$$scope={dirty:l1,ctx:s1}),r1.$set(u1);const f1={};l1&32778&&(f1.$$scope={dirty:l1,ctx:s1}),i1.$set(f1)},i(s1){a1||(transition_in(e1.$$.fragment,s1),transition_in(r1.$$.fragment,s1),transition_in(i1.$$.fragment,s1),a1=!0)},o(s1){transition_out(e1.$$.fragment,s1),transition_out(r1.$$.fragment,s1),transition_out(i1.$$.fragment,s1),a1=!1},d(s1){destroy_component(e1,s1),s1&&detach(t1),destroy_component(r1,s1),s1&&detach(o1),destroy_component(i1,s1)}}}function create_default_slot$4N(n1){let e1,t1;return e1=new Layout$n({props:{gap:"M",noPadding:!0,$$slots:{default:[create_default_slot_1$3x]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,o1){const i1={};o1&32783&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function create_fragment$7l(n1){let e1,t1;return e1=new TestimonialPage({props:{$$slots:{default:[create_default_slot$4N]},$$scope:{ctx:n1}}}),{c(){create_component(e1.$$.fragment)},m(r1,o1){mount_component(e1,r1,o1),t1=!0},p(r1,[o1]){const i1={};o1&32783&&(i1.$$scope={dirty:o1,ctx:r1}),e1.$set(i1)},i(r1){t1||(transition_in(e1.$$.fragment,r1),t1=!0)},o(r1){transition_out(e1.$$.fragment,r1),t1=!1},d(r1){destroy_component(e1,r1)}}}function instance$7v(n1,e1,t1){let r1,o1,i1;component_subscribe(n1,goto,$1=>t1(14,o1=$1)),component_subscribe(n1,auth,$1=>t1(5,i1=$1));let a1,s1={},l1={},c1=!1;async function u1(){if(a1.validate(),!(Object.keys(s1).length>0)){t1(3,c1=!0);try{let $1={...l1,tenantId:r1};delete $1.confirmationPassword,await API.createAdminUser($1),notifications.success("Admin user created"),await admin.init(),o1("../portal")}catch{t1(3,c1=!1),notifications.error("Failed to create admin user")}}}const f1=()=>{let $1={email:l1.email?void 0:"Please enter a valid email"};t1(1,s1=handleError({...s1,...$1}))},d1=$1=>{t1(2,l1={...l1,email:$1.detail})},p1=()=>{let $1={};$1.password=l1.password?void 0:"Please enter a password",$1.confirmationPassword=!passwordsMatch(l1.password,l1.confirmationPassword)&&l1.confirmationPassword?"Passwords must match":void 0,t1(1,s1=handleError({...s1,...$1}))},m1=$1=>{t1(2,l1={...l1,password:$1.detail})},_1=()=>{let $1={confirmationPassword:!passwordsMatch(l1.password,l1.confirmationPassword)&&l1.password?"Passwords must match":void 0};t1(1,s1=handleError({...s1,...$1}))},h1=$1=>{t1(2,l1={...l1,confirmationPassword:$1.detail})};function g1($1){binding_callbacks[$1?"unshift":"push"](()=>{a1=$1,t1(0,a1)})}return n1.$$.update=()=>{n1.$$.dirty&32&&(r1=i1.tenantId)},[a1,s1,l1,c1,u1,i1,f1,d1,p1,m1,_1,h1,g1]}class Admin extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7v,create_fragment$7l,safe_not_equal,{})}}function create_if_block$3k(n1){let e1;const t1=n1[4].default,r1=create_slot(t1,n1,n1[3],null);return{c(){r1&&r1.c()},m(o1,i1){r1&&r1.m(o1,i1),e1=!0},p(o1,i1){r1&&r1.p&&(!e1||i1&8)&&update_slot_base(r1,t1,o1,o1[3],e1?get_slot_changes(t1,o1[3],i1,null):get_all_dirty_from_scope(o1[3]),null)},i(o1){e1||(transition_in(r1,o1),e1=!0)},o(o1){transition_out(r1,o1),e1=!1},d(o1){r1&&r1.d(o1)}}}function create_fragment$7k(n1){let e1,t1,r1=n1[0]&&create_if_block$3k(n1);return{c(){r1&&r1.c(),e1=empty$1()},m(o1,i1){r1&&r1.m(o1,i1),insert$1(o1,e1,i1),t1=!0},p(o1,[i1]){o1[0]?r1?(r1.p(o1,i1),i1&1&&transition_in(r1,1)):(r1=create_if_block$3k(o1),r1.c(),transition_in(r1,1),r1.m(e1.parentNode,e1)):r1&&(group_outros(),transition_out(r1,1,1,()=>{r1=null}),check_outros())},i(o1){t1||(transition_in(r1),t1=!0)},o(o1){transition_out(r1),t1=!1},d(o1){r1&&r1.d(o1),o1&&detach(e1)}}}function instance$7u(n1,e1,t1){let r1,o1,i1,a1;component_subscribe(n1,redirect,u1=>t1(6,i1=u1)),component_subscribe(n1,admin,u1=>t1(2,a1=u1));let{$$slots:s1={},$$scope:l1}=e1,c1=!1;return onMount(()=>{var u1;(u1=a1==null?void 0:a1.checklist)!=null&&u1.adminUser.checked||o1?i1("../"):t1(0,c1=!0)}),n1.$$set=u1=>{"$$scope"in u1&&t1(3,l1=u1.$$scope)},n1.$$.update=()=>{n1.$$.dirty&4&&t1(1,r1=a1.cloud),n1.$$.dirty&6&&(o1=r1&&!a1.disableAccountPortal)},[c1,r1,a1,l1,s1]}let Layout$m=class extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7u,create_fragment$7k,safe_not_equal,{})}};function instance$7t(n1,e1,t1){let r1;return component_subscribe(n1,redirect,o1=>t1(0,r1=o1)),r1("../design"),[]}class Fallback extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7t,null,safe_not_equal,{})}}function instance$7s(n1,e1,t1){let r1;return component_subscribe(n1,redirect,o1=>t1(0,r1=o1)),r1("./data"),[]}class U5Bapplicationu5D extends SvelteComponent{constructor(e1){super(),init$1(this,e1,instance$7s,null,safe_not_equal,{})}}function create_fragment$7j(n1){let e1,t1,r1,o1,i1,a1;return{c(){e1=svg_element("svg"),t1=svg_element("path"),r1=svg_element("path"),o1=svg_element("path"),i1=svg_element("path"),a1=svg_element("path"),attr(t1,"d",`M169.341 104.792C168.322 101.71 165.652 99.5637 162.199 99.0487C160.57
437
437
  98.8061 158.706 98.9095 156.499 99.3635C152.653 100.156 149.799 100.457
438
438
  147.717 100.516C155.577 87.268 161.969 72.161 165.648 57.9402C171.598