@bugspotter/sdk 0.2.5-alpha.5 → 0.3.1
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.
- package/.prettierrc +11 -0
- package/CHANGELOG.md +81 -149
- package/dist/bugspotter.min.js +1 -1
- package/dist/capture/console.d.ts +1 -0
- package/dist/capture/console.js +17 -4
- package/dist/capture/network.d.ts +6 -0
- package/dist/capture/network.js +12 -2
- package/dist/capture/screenshot.js +3 -2
- package/dist/core/buffer.js +2 -1
- package/dist/core/bug-reporter.js +16 -5
- package/dist/core/circular-buffer.js +4 -1
- package/dist/core/compress.js +2 -1
- package/dist/core/file-upload-handler.js +5 -2
- package/dist/core/offline-queue.js +5 -2
- package/dist/core/transport.js +4 -2
- package/dist/core/upload-helpers.js +3 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.esm.js +16889 -44
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +3 -1
- package/dist/utils/sanitize-patterns.js +15 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/widget/components/form-validator.js +2 -1
- package/dist/widget/components/style-manager.d.ts +17 -0
- package/dist/widget/components/style-manager.js +318 -108
- package/dist/widget/components/template-manager.js +2 -1
- package/dist/widget/modal.js +11 -4
- package/eslint.config.js +89 -0
- package/package.json +28 -14
- package/rollup.config.js +25 -0
package/dist/bugspotter.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see bugspotter.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BugSpotter=e():t.BugSpotter=e()}(this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{BugSpotter:()=>po});const n='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n<path d="M8 2v4"/>\n<path d="M16 2v4"/>\n<path d="M12 12v5"/>\n<circle cx="12" cy="10" r="4"/>\n<path d="M9 16c-1.5 1-3 2-3 4h12c0-2-1.5-3-3-4"/>\n<path d="M3 8h4"/>\n<path d="M17 8h4"/>\n<path d="M5 12h2"/>\n<path d="M17 12h2"/>\n<path d="M6 16h2"/>\n<path d="M16 16h2"/>\n</svg>',i={position:"bottom-right",icon:"svg",customSvg:void 0,backgroundColor:"#2563eb",size:56,offset:{x:20,y:20},zIndex:999999,tooltip:"Report an Issue"},r="0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)",s="0 10px 15px rgba(0, 0, 0, 0.2), 0 4px 6px rgba(0, 0, 0, 0.1)",o="scale(1)",a="scale(1.1)",l="scale(0.95)";class c{constructor(t={}){var e,n,c,d,h,u,p,g;this.eventHandlers=new Map,this.handleMouseEnter=()=>{this.button.style.transform=a,this.button.style.boxShadow=s},this.handleMouseLeave=()=>{this.button.style.transform=o,this.button.style.boxShadow=r},this.handleMouseDown=()=>{this.button.style.transform=l},this.handleMouseUp=()=>{this.button.style.transform=a},this.options={position:null!==(e=t.position)&&void 0!==e?e:i.position,icon:null!==(n=t.icon)&&void 0!==n?n:i.icon,customSvg:null!==(c=t.customSvg)&&void 0!==c?c:i.customSvg,backgroundColor:null!==(d=t.backgroundColor)&&void 0!==d?d:i.backgroundColor,size:null!==(h=t.size)&&void 0!==h?h:i.size,offset:null!==(u=t.offset)&&void 0!==u?u:i.offset,zIndex:null!==(p=t.zIndex)&&void 0!==p?p:i.zIndex,tooltip:null!==(g=t.tooltip)&&void 0!==g?g:i.tooltip},this.button=this.createButton(),document.body?document.body.appendChild(this.button):document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(this.button)})}createButton(){const t=document.createElement("button");return this.options.customSvg?t.innerHTML=this.options.customSvg:"svg"===this.options.icon?t.innerHTML=n:t.textContent=this.options.icon,t.setAttribute("aria-label",this.options.tooltip),t.setAttribute("title",this.options.tooltip),t.setAttribute("data-bugspotter-exclude","true"),t.style.cssText=this.getButtonStyles(),this.addHoverEffects(t),t}getButtonStyles(){const{position:t,size:e,offset:n,backgroundColor:i,zIndex:s}=this.options;return`\n position: fixed;\n ${this.getPositionStyles(t,n)}\n width: ${e}px;\n height: ${e}px;\n border-radius: 50%;\n background: ${i};\n color: white;\n border: none;\n cursor: pointer;\n font-size: ${.5*e}px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: ${this.options.customSvg||"svg"===this.options.icon?.25*e:0}px;\n box-shadow: ${r};\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n z-index: ${s};\n `}getPositionStyles(t,e){switch(t){case"bottom-right":default:return`bottom: ${e.y}px; right: ${e.x}px;`;case"bottom-left":return`bottom: ${e.y}px; left: ${e.x}px;`;case"top-right":return`top: ${e.y}px; right: ${e.x}px;`;case"top-left":return`top: ${e.y}px; left: ${e.x}px;`}}addHoverEffects(t){const e={mouseenter:this.handleMouseEnter,mouseleave:this.handleMouseLeave,mousedown:this.handleMouseDown,mouseup:this.handleMouseUp};Object.entries(e).forEach(([e,n])=>{t.addEventListener(e,n),this.eventHandlers.set(e,n)})}onClick(t){this.button.addEventListener("click",t)}show(){this.button.style.display="flex"}hide(){this.button.style.display="none"}setIcon(t){this.options.icon=t,"svg"===t?this.button.innerHTML=n:this.button.textContent=t}setBackgroundColor(t){this.button.style.backgroundColor=t}destroy(){this.eventHandlers.forEach((t,e)=>{this.button.removeEventListener(e,t)}),this.eventHandlers.clear(),this.button.remove()}}class d{constructor(t={}){this.config={primaryColor:t.primaryColor||"#007bff",dangerColor:t.dangerColor||"#dc3545",borderRadius:t.borderRadius||"4px",fontFamily:t.fontFamily||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',zIndex:t.zIndex||999999}}generateStyles(){return`\n .overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: ${this.config.zIndex};\n font-family: ${this.config.fontFamily};\n }\n \n .modal {\n background: white;\n border-radius: 8px;\n width: 90%;\n max-width: 600px;\n max-height: 90vh;\n overflow-y: auto;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n }\n \n .header {\n padding: 20px;\n border-bottom: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n \n .header h2 {\n margin: 0;\n font-size: 20px;\n font-weight: 600;\n }\n \n .close {\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n color: #666;\n padding: 0;\n width: 30px;\n height: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: ${this.config.borderRadius};\n }\n \n .close:hover {\n background: #f0f0f0;\n }\n \n .body {\n padding: 20px;\n }\n \n .form-group {\n margin-bottom: 20px;\n }\n \n .label {\n display: block;\n margin-bottom: 8px;\n font-weight: 500;\n font-size: 14px;\n }\n \n .input,\n .textarea {\n width: 100%;\n padding: 10px;\n border: 1px solid #ddd;\n border-radius: ${this.config.borderRadius};\n font-size: 14px;\n font-family: ${this.config.fontFamily};\n box-sizing: border-box;\n }\n \n .input:focus,\n .textarea:focus {\n outline: none;\n border-color: ${this.config.primaryColor};\n }\n \n .textarea {\n min-height: 100px;\n resize: vertical;\n }\n \n .screenshot-container {\n margin-top: 10px;\n position: relative;\n }\n \n .screenshot {\n max-width: 100%;\n border: 1px solid #ddd;\n border-radius: ${this.config.borderRadius};\n }\n \n .redaction-canvas {\n position: absolute;\n top: 0;\n left: 0;\n cursor: crosshair;\n border: 2px solid ${this.config.primaryColor};\n border-radius: ${this.config.borderRadius};\n }\n \n .redaction-controls {\n margin-top: 10px;\n display: flex;\n gap: 10px;\n }\n \n .btn-redact,\n .btn-clear {\n padding: 8px 16px;\n border: 1px solid #ddd;\n border-radius: ${this.config.borderRadius};\n background: white;\n cursor: pointer;\n font-size: 14px;\n }\n \n .btn-redact:hover,\n .btn-clear:hover {\n background: #f5f5f5;\n }\n \n .btn-redact.active {\n background: ${this.config.primaryColor};\n color: white;\n border-color: ${this.config.primaryColor};\n }\n \n .pii-section {\n margin-top: 20px;\n padding: 15px;\n background: #fff3cd;\n border: 1px solid #ffc107;\n border-radius: ${this.config.borderRadius};\n }\n \n .pii-title {\n margin: 0 0 10px 0;\n font-size: 14px;\n font-weight: 600;\n color: #856404;\n }\n \n .pii-list {\n margin: 0;\n padding-left: 20px;\n font-size: 13px;\n color: #856404;\n }\n \n .pii-badge {\n display: inline-block;\n padding: 2px 8px;\n margin: 2px;\n background: #ffc107;\n color: #856404;\n border-radius: 12px;\n font-size: 12px;\n font-weight: 500;\n }\n \n .checkbox-group {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 15px;\n }\n \n .checkbox {\n width: 18px;\n height: 18px;\n cursor: pointer;\n }\n \n .checkbox-label {\n margin: 0;\n font-size: 14px;\n cursor: pointer;\n user-select: none;\n }\n \n .footer {\n padding: 20px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n }\n \n .btn {\n padding: 10px 20px;\n border: none;\n border-radius: ${this.config.borderRadius};\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n }\n \n .btn-primary {\n background: ${this.config.primaryColor};\n color: white;\n }\n \n .btn-primary:hover {\n opacity: 0.9;\n }\n \n .btn-primary:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n \n .btn.loading {\n position: relative;\n padding-left: 2.5rem;\n }\n \n .btn.loading::after {\n content: '';\n position: absolute;\n width: 16px;\n height: 16px;\n top: 50%;\n left: 1rem;\n margin-top: -8px;\n border: 2px solid transparent;\n border-top-color: currentColor;\n border-radius: 50%;\n animation: spinner 0.6s linear infinite;\n }\n \n @keyframes spinner {\n to { transform: rotate(360deg); }\n }\n \n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n }\n \n .btn-secondary {\n background: #6c757d;\n color: white;\n }\n \n .btn-secondary:hover {\n opacity: 0.9;\n }\n \n .error {\n color: ${this.config.dangerColor};\n font-size: 12px;\n margin-top: 4px;\n }\n `}injectStyles(){const t=document.createElement("style");return t.textContent=this.generateStyles(),document.head.appendChild(t),t}removeStyles(t){t&&t.parentNode&&t.parentNode.removeChild(t)}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class h{constructor(t={}){this.config={title:t.title||"Report a Bug",titlePlaceholder:t.titlePlaceholder||"Brief description of the issue",descriptionPlaceholder:t.descriptionPlaceholder||"Detailed description of what happened...",submitButtonText:t.submitButtonText||"Submit Bug Report",cancelButtonText:t.cancelButtonText||"Cancel",showScreenshot:!1!==t.showScreenshot}}generateModalHTML(t){return`\n <div class="overlay">\n <div class="modal">\n ${this.generateHeader()}\n ${this.generateBody(t)}\n ${this.generateFooter()}\n <div role="status" aria-live="polite" aria-atomic="true" class="sr-only" id="progress-status"></div>\n </div>\n </div>\n `}generateHeader(){return`\n <div class="header">\n <h2>${this.escapeHtml(this.config.title)}</h2>\n <button class="close" aria-label="Close">×</button>\n </div>\n `}generateBody(t){return`\n <div class="body">\n <form class="form">\n ${this.generateTitleField()}\n ${this.generateDescriptionField()}\n ${this.config.showScreenshot&&t?this.generateScreenshotSection(t):""}\n ${this.generatePIISection()}\n </form>\n </div>\n `}generateTitleField(){return`\n <div class="form-group">\n <label class="label" for="title">Title *</label>\n <input\n type="text"\n id="title"\n class="input"\n placeholder="${this.escapeHtml(this.config.titlePlaceholder)}"\n required\n />\n <div class="error" id="title-error"></div>\n </div>\n `}generateDescriptionField(){return`\n <div class="form-group">\n <label class="label" for="description">Description *</label>\n <textarea\n id="description"\n class="textarea"\n placeholder="${this.escapeHtml(this.config.descriptionPlaceholder)}"\n required\n ></textarea>\n <div class="error" id="description-error"></div>\n </div>\n `}generateScreenshotSection(t){return`\n <div class="form-group">\n <label class="label">Screenshot</label>\n <div class="screenshot-container">\n <img \n src="${t}" \n alt="Bug screenshot" \n class="screenshot"\n id="screenshot"\n />\n <canvas \n class="redaction-canvas" \n id="redaction-canvas"\n style="display: none;"\n ></canvas>\n </div>\n <div class="redaction-controls">\n <button \n type="button" \n class="btn-redact" \n id="btn-redact"\n >\n ✏️ Redact Area\n </button>\n <button \n type="button" \n class="btn-clear" \n id="btn-clear"\n >\n 🗑️ Clear Redactions\n </button>\n </div>\n </div>\n `}generatePIISection(){return'\n <div class="pii-section" id="pii-section" style="display: none;">\n <h3 class="pii-title">⚠️ Potential PII Detected</h3>\n <div id="pii-content"></div>\n <div class="checkbox-group">\n <input \n type="checkbox" \n id="pii-confirm" \n class="checkbox"\n />\n <label for="pii-confirm" class="checkbox-label">\n I have reviewed and redacted sensitive information\n </label>\n </div>\n </div>\n '}generateFooter(){return`\n <div class="footer">\n <div class="error" id="submit-error" style="display: none;"></div>\n <button type="button" class="btn btn-secondary" id="btn-cancel">\n ${this.escapeHtml(this.config.cancelButtonText)}\n </button>\n <button type="submit" class="btn btn-primary submit" id="btn-submit">\n ${this.escapeHtml(this.config.submitButtonText)}\n </button>\n </div>\n `}generatePIIBadge(t,e){return`<span class="bugspotter-pii-badge">${this.escapeHtml(t)}: ${e}</span>`}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class u{constructor(){this.elements=null,this.container=null}initialize(t){this.container=t;const e=this.getRequiredElement(".overlay",t),n=this.getRequiredElement(".modal",e),i=this.getRequiredElement(".form",n);return this.elements={overlay:e,modal:n,closeButton:this.getRequiredElement(".close",n),form:i,titleInput:this.getRequiredElement("#title",i),titleError:this.getRequiredElement("#title-error",i),descriptionTextarea:this.getRequiredElement("#description",i),descriptionError:this.getRequiredElement("#description-error",i),screenshotImg:this.getOptionalElement("#screenshot",n),redactionCanvas:this.getOptionalElement("#redaction-canvas",n),redactButton:this.getOptionalElement("#btn-redact",n),clearButton:this.getOptionalElement("#btn-clear",n),piiSection:this.getRequiredElement("#pii-section",n),piiContent:this.getRequiredElement("#pii-content",n),piiConfirmCheckbox:this.getRequiredElement("#pii-confirm",n),submitError:this.getRequiredElement("#submit-error",n),cancelButton:this.getRequiredElement("#btn-cancel",n),submitButton:this.getRequiredElement("#btn-submit",n),progressStatus:this.getRequiredElement("#progress-status",n)},this.elements}get(){if(!this.elements)throw new Error("DOMElementCache not initialized. Call initialize() first.");return this.elements}isInitialized(){return null!==this.elements}clear(){this.elements=null,this.container=null}getRequiredElement(t,e){const n=(e||this.container||document).querySelector(t);if(!n)throw new Error(`Required element not found: ${t}`);return n}getOptionalElement(t,e){return(e||this.container||document).querySelector(t)||void 0}refreshElement(t,e){if(!this.elements||!this.container)throw new Error("DOMElementCache not initialized");const n=this.container.querySelector(e);n&&(this.elements[t]=n)}getContainer(){return this.container}}class p{constructor(t={}){this.minTitleLength=t.minTitleLength||3,this.maxTitleLength=t.maxTitleLength||200,this.minDescriptionLength=t.minDescriptionLength||10,this.maxDescriptionLength=t.maxDescriptionLength||5e3}validate(t){const e={},n=this.validateTitle(t.title);n&&(e.title=n);const i=this.validateDescription(t.description);return i&&(e.description=i),t.piiDetected&&!t.piiConfirmed&&(e.piiConfirmation="Please confirm you have reviewed sensitive information"),{isValid:0===Object.keys(e).length,errors:e}}validateTitle(t){const e=t.trim();return e?e.length<this.minTitleLength?`Title must be at least ${this.minTitleLength} characters`:e.length>this.maxTitleLength?`Title must not exceed ${this.maxTitleLength} characters`:null:"Title is required"}validateDescription(t){if(!t)return null;const e=t.trim();return 0===e.length?"Description cannot be only whitespace":e.length<this.minDescriptionLength?`Description must be at least ${this.minDescriptionLength} characters`:e.length>this.maxDescriptionLength?`Description must not exceed ${this.maxDescriptionLength} characters`:null}validateField(t,e,n){switch(t){case"title":return this.validateTitle(e);case"description":return this.validateDescription(e);case"piiConfirmed":return(null==n?void 0:n.piiDetected)&&!e?"Please confirm you have reviewed sensitive information":null;default:return null}}isEmpty(t){return!t||0===t.trim().length}sanitizeInput(t){return t.trim()}getConfig(){return{minTitleLength:this.minTitleLength,maxTitleLength:this.maxTitleLength,minDescriptionLength:this.minDescriptionLength,maxDescriptionLength:this.maxDescriptionLength}}}class g{constructor(t={}){this.config={showExamples:!1!==t.showExamples,groupByType:!1!==t.groupByType,maxExamplesPerType:t.maxExamplesPerType||3}}render(t,e){t&&0!==t.length?this.config.groupByType?e.innerHTML=this.renderGroupedPII(t):e.innerHTML=this.renderListPII(t):e.innerHTML=""}renderGroupedPII(t){const e=this.groupByType(t),n=[];for(const[t,i]of Object.entries(e)){const e=i.reduce((t,e)=>t+e.count,0);n.push(this.createBadge(t,e))}let i=`<div class="bugspotter-pii-badges">${n.join("")}</div>`;if(this.config.showExamples){i+='<div class="bugspotter-pii-details">',i+='<p style="margin: 10px 0 5px 0; font-size: 13px; color: #856404;">Detected types:</p>',i+='<ul class="bugspotter-pii-list">';for(const[t,n]of Object.entries(e)){const e=n.reduce((t,e)=>t+e.count,0);i+=`<li><strong>${this.escapeHtml(t)}:</strong> ${e} occurrence${1!==e?"s":""}</li>`}i+="</ul></div>"}return i}renderListPII(t){let e='<ul class="bugspotter-pii-list">';for(const n of t)e+=`<li>${this.escapeHtml(n.type)}: ${n.count} occurrence${1!==n.count?"s":""}</li>`;return e+="</ul>",e}createBadge(t,e){return`<span class="bugspotter-pii-badge">${this.escapeHtml(t)}: ${e}</span>`}groupByType(t){const e={};for(const n of t)e[n.type]||(e[n.type]=[]),e[n.type].push(n);return e}getSummary(t){const e=new Set;for(const n of t)e.add(n.type);return{totalCount:t.length,typeCount:e.size,types:Array.from(e)}}hasType(t,e){return t.some(t=>t.type===e)}filterByType(t,e){return t.filter(t=>t.type===e)}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class m{constructor(t,e={}){this.isDrawing=!1,this.isRedactionMode=!1,this.startX=0,this.startY=0,this.redactionRects=[],this.canvas=t;const n=t.getContext("2d");if(!n)throw new Error("Failed to get 2D context from canvas");this.ctx=n,this.config={redactionColor:e.redactionColor||"#000000",cursorStyle:e.cursorStyle||"crosshair"},this.handleMouseDown=this.onMouseDown.bind(this),this.handleMouseMove=this.onMouseMove.bind(this),this.handleMouseUp=this.onMouseUp.bind(this)}initializeCanvas(t){const e=()=>{const e=t.getBoundingClientRect(),n=e.width||t.width,i=e.height||t.height;this.canvas.width=t.naturalWidth||t.width,this.canvas.height=t.naturalHeight||t.height,this.canvas.style.width=`${n}px`,this.canvas.style.height=`${i}px`};t.complete&&t.naturalWidth>0?e():t.addEventListener("load",e,{once:!0})}enableRedactionMode(){this.isRedactionMode||(this.isRedactionMode=!0,this.canvas.style.display="block",this.canvas.style.cursor=this.config.cursorStyle,this.canvas.addEventListener("mousedown",this.handleMouseDown),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseup",this.handleMouseUp),this.redraw())}disableRedactionMode(){this.isRedactionMode&&(this.isRedactionMode=!1,this.isDrawing=!1,this.canvas.removeEventListener("mousedown",this.handleMouseDown),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseup",this.handleMouseUp),this.canvas.style.cursor="default")}toggleRedactionMode(){return this.isRedactionMode?this.disableRedactionMode():this.enableRedactionMode(),this.isRedactionMode}clearRedactions(){this.redactionRects=[],this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}getRedactions(){return[...this.redactionRects]}setRedactions(t){this.redactionRects=[...t],this.redraw()}isActive(){return this.isRedactionMode}getCanvas(){return this.canvas}toDataURL(t="image/png",e){return this.canvas.toDataURL(t,e)}hide(){this.canvas.style.display="none"}show(){this.canvas.style.display="block"}destroy(){this.disableRedactionMode(),this.clearRedactions()}onMouseDown(t){if(!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height;this.startX=(t.clientX-e.left)*n,this.startY=(t.clientY-e.top)*i,this.isDrawing=!0}onMouseMove(t){if(!this.isDrawing||!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height,r=(t.clientX-e.left)*n,s=(t.clientY-e.top)*i;this.redraw(),this.drawRect(this.startX,this.startY,r-this.startX,s-this.startY)}onMouseUp(t){if(!this.isDrawing||!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height,r=(t.clientX-e.left)*n,s=(t.clientY-e.top)*i,o=r-this.startX,a=s-this.startY;Math.abs(o)>5&&Math.abs(a)>5&&this.redactionRects.push({x:this.startX,y:this.startY,width:o,height:a}),this.isDrawing=!1,this.redraw()}redraw(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.redactionRects)this.drawRect(t.x,t.y,t.width,t.height)}drawRect(t,e,n,i){this.ctx.fillStyle=this.config.redactionColor,this.ctx.fillRect(t,e,n,i)}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t),this.isRedactionMode&&(this.canvas.style.cursor=this.config.cursorStyle)}getConfig(){return Object.assign({},this.config)}}class f{async mergeRedactions(t,e){return new Promise((n,i)=>{const r=new Image;r.onload=()=>{try{const t=document.createElement("canvas");t.width=r.naturalWidth||r.width,t.height=r.naturalHeight||r.height;const s=t.getContext("2d");if(!s)return void i(new Error("Failed to get canvas context"));s.drawImage(r,0,0),s.drawImage(e,0,0),n(t.toDataURL())}catch(t){i(t)}},r.onerror=()=>{i(new Error("Failed to load screenshot image"))},r.src=t})}async applyRedactions(t,e,n="#000000"){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{const t=document.createElement("canvas");t.width=s.naturalWidth||s.width,t.height=s.naturalHeight||s.height;const o=t.getContext("2d");if(!o)return void r(new Error("Failed to get canvas context"));o.drawImage(s,0,0),o.fillStyle=n;for(const t of e)o.fillRect(t.x,t.y,t.width,t.height);i(t.toDataURL())}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async resize(t,e,n){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{let t=s.naturalWidth||s.width,o=s.naturalHeight||s.height;if(t>e||o>n){const i=t/o;t>o?(t=e,o=t/i):(o=n,t=o*i)}const a=document.createElement("canvas");a.width=t,a.height=o;const l=a.getContext("2d");if(!l)return void r(new Error("Failed to get canvas context"));l.drawImage(s,0,0,t,o),i(a.toDataURL())}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async convert(t,e,n=.92){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{const t=document.createElement("canvas");t.width=s.naturalWidth||s.width,t.height=s.naturalHeight||s.height;const o=t.getContext("2d");if(!o)return void r(new Error("Failed to get canvas context"));o.drawImage(s,0,0),i(t.toDataURL(e,n))}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async getDimensions(t){return new Promise((e,n)=>{const i=new Image;i.onload=()=>{e({width:i.naturalWidth||i.width,height:i.naturalHeight||i.height})},i.onerror=()=>{n(new Error("Failed to load image"))},i.src=t})}isValidDataURL(t){return/^data:image\/(png|jpeg|jpg|webp|gif);base64,/.test(t)}getEstimatedSize(t){const e=t.split(",")[1]||"";return Math.ceil(3*e.length/4)}getFormat(t){const e=t.match(/^data:image\/([a-z]+);base64,/);return e?e[1]:null}}const y={email:{name:"email",regex:/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,description:"Email addresses",examples:["user@example.com","john.doe+tag@company.co.uk","test_user@sub.domain.com"],priority:1},creditcard:{name:"creditcard",regex:/\b(?:\d{4}[-\s]){3}\d{4}\b|\b\d{4}[-\s]\d{6}[-\s]\d{5}\b|\b\d{13,19}\b/g,description:"Credit card numbers (Visa, MC, Amex, Discover, etc.)",examples:["4532-1488-0343-6467","4532148803436467","5425 2334 3010 9903","3782 822463 10005"],priority:2},ssn:{name:"ssn",regex:/\b\d{3}-\d{2}-\d{4}\b|\b(?<!\d)\d{9}(?!\d)\b/g,description:"US Social Security Numbers",examples:["123-45-6789","987654321"],priority:3},iin:{name:"iin",regex:/\b[0-9]{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12][0-9]|3[01])\d{6}\b/g,description:"Kazakhstan IIN/BIN (12 digits with date validation)",examples:["950315300123","880612500456","021225123456"],priority:4},ip:{name:"ip",regex:/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\b/g,description:"IPv4 and IPv6 addresses",examples:["192.168.1.100","127.0.0.1","2001:0db8:85a3:0000:0000:8a2e:0370:7334"],priority:5},phone:{name:"phone",regex:/\+\d{1,3}[-.\s]\d{3}[-.\s]\d{4}\b|\+\d{1,3}[-.\s]\d{3}[-.\s]\d{3}[-.\s]\d{4}\b|\(\d{3}\)\s*\d{3}[-.\s]\d{4}\b|\b\d{3}[-.\s]\d{3}[-.\s]\d{4}\b/g,description:"International phone numbers",examples:["+1-555-1234","+1-555-123-4567","(555) 123-4567","555-123-4567","+7 777 123 4567"],priority:6},apikey:{name:"apikey",regex:/\b(?:sk|pk)_(?:live|test)_[a-zA-Z0-9]{24,}\b|AIza[a-zA-Z0-9_-]{35}|ya29\.[a-zA-Z0-9_-]+|AKIA[a-zA-Z0-9]{16}\b/g,description:"API keys (Stripe, Google, AWS, etc.)",examples:["sk_live_abc123def456ghi789jkl","pk_test_xyz789abc123def456","AIzaSyD1234567890abcdefghijklmnopqrst","AKIAIOSFODNN7EXAMPLE"],priority:7},token:{name:"token",regex:/\b(?:Bearer\s+)?[a-zA-Z0-9_-]{32,}\b|ghp_[a-zA-Z0-9]{36}|gho_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9_]{82}/g,description:"Authentication tokens (Bearer, GitHub, JWT-like)",examples:["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9","ghp_abc123def456ghi789jkl012mno345pqr","gho_xyz789abc123def456ghi789jkl012mno"],priority:8},password:{name:"password",regex:/(?:password|passwd|pwd)[\s:=]+[^\s]{6,}|(?:password|passwd|pwd)["']?\s*[:=]\s*["']?[^\s"']{6,}/gi,description:"Password fields in text (password=..., pwd:...)",examples:["password: MySecret123!","passwd=SecurePass456",'pwd: "MyP@ssw0rd"'],priority:9}},b={financial:["creditcard","ssn"],contact:["email","phone"],identification:["ssn","iin"],network:["ip","email"],credentials:["apikey","token","password"],kazakhstan:["iin"]};const w={all:Object.keys(y),minimal:["email","creditcard","ssn"],financial:b.financial,contact:b.contact,identification:b.identification,credentials:b.credentials,kazakhstan:["email","phone","iin"],gdpr:["email","phone","ip"],pci:["creditcard"],security:["email","phone","creditcard","ssn","apikey","token","password"]};class v{constructor(t,e){this.patterns=new Map,this.initializePatterns(t,e)}initializePatterns(t,e){let n;var i;n="string"==typeof t?w[t]:t.filter(t=>"custom"!==t),(i=n.map(t=>y[t]),[...i].sort((t,e)=>t.priority-e.priority)).forEach(t=>{this.patterns.set(t.name,t.regex)}),e.forEach(t=>{this.patterns.set(t.name,t.regex)})}getPatterns(){return this.patterns}}class C{constructor(t){this.patterns=t}sanitize(t){if("string"!=typeof t)return t;let e=t;return this.patterns.forEach((t,n)=>{const i=n.toUpperCase();e=e.replace(t,`[REDACTED-${i}]`)}),e}}class I{constructor(t){this.stringSanitizer=t}sanitize(t){return null==t?t:"string"==typeof t?this.stringSanitizer.sanitize(t):Array.isArray(t)?t.map(t=>this.sanitize(t)):"object"==typeof t?this.sanitizeObject(t):t}sanitizeObject(t){const e={};for(const[n,i]of Object.entries(t))e[this.stringSanitizer.sanitize(n)]=this.sanitize(i);return e}}class _{constructor(t){this.excludeSelectors=t}shouldExclude(t){return!(!t||!this.excludeSelectors.length)&&this.excludeSelectors.some(e=>{try{return t.matches(e)}catch(t){return!1}})}}class S{constructor(t){var e,n,i,r;if(this.enabled=null===(e=t.enabled)||void 0===e||e,!this.enabled)return this.stringSanitizer=new C(new Map),this.valueSanitizer=new I(this.stringSanitizer),void(this.elementMatcher=new _([]));const s=null!==(n=t.patterns)&&void 0!==n?n:"all",o=null!==(i=t.customPatterns)&&void 0!==i?i:[],a=null!==(r=t.excludeSelectors)&&void 0!==r?r:[],l=new v(s,o);this.stringSanitizer=new C(l.getPatterns()),this.valueSanitizer=new I(this.stringSanitizer),this.elementMatcher=new _(a)}guardDisabled(t){return this.enabled?void 0:t}sanitize(t){const e=this.guardDisabled(t);return void 0!==e?e:this.valueSanitizer.sanitize(t)}sanitizeConsoleArgs(t){const e=this.guardDisabled(t);return void 0!==e?e:t.map(t=>this.sanitize(t))}sanitizeNetworkData(t){const e=this.guardDisabled(t);return void 0!==e?e:this.sanitize(t)}sanitizeError(t){const e=this.guardDisabled(t);return void 0!==e?e:this.sanitize(t)}shouldExclude(t){return!!this.enabled&&this.elementMatcher.shouldExclude(t)}sanitizeTextNode(t,e){const n=this.guardDisabled(t);return void 0!==n?n:this.elementMatcher.shouldExclude(e)?t:this.stringSanitizer.sanitize(t)}detectPII(t){const e=new Map;if(!this.enabled||!t)return e;for(const[n,i]of this.stringSanitizer.patterns){const r=t.match(new RegExp(i,"g"));r&&r.length>0&&e.set(n,r.length)}return e}}function k(t){return new S(t)}const x={debug:0,log:1,warn:2,error:3,none:4};const A=new class{constructor(t={}){var e,n,i;this.enabled=null===(e=t.enabled)||void 0===e||e,this.level=null!==(n=t.level)&&void 0!==n?n:"log",this.prefix=null!==(i=t.prefix)&&void 0!==i?i:"[BugSpotter]"}shouldLog(t){return!!this.enabled&&x[t]>=x[this.level]}formatMessage(t){return this.prefix?`${this.prefix} ${t}`:t}debug(t,...e){this.shouldLog("debug")&&console.debug(this.formatMessage(t),...e)}log(t,...e){this.shouldLog("log")&&console.log(this.formatMessage(t),...e)}warn(t,...e){this.shouldLog("warn")&&console.warn(this.formatMessage(t),...e)}error(t,...e){this.shouldLog("error")&&console.error(this.formatMessage(t),...e)}configure(t){void 0!==t.enabled&&(this.enabled=t.enabled),void 0!==t.level&&(this.level=t.level),void 0!==t.prefix&&(this.prefix=t.prefix)}};function E(){return A}const R=E();class M{constructor(t){this.redactionCanvas=null,this.originalScreenshot="",this.piiDetections=[],this.options=t,this.container=document.createElement("div"),this.shadow=this.container.attachShadow({mode:"open"}),this.styleManager=new d,this.templateManager=new h,this.domCache=new u,this.validator=new p,this.piiDisplay=new g,this.screenshotProcessor=new f,this.handleEscapeKey=this.onEscapeKey.bind(this)}show(t){t&&(this.originalScreenshot=t),this.shadow.innerHTML=`\n <style>\n ${this.styleManager.generateStyles()}\n </style>\n ${this.templateManager.generateModalHTML(this.originalScreenshot)}\n `,this.domCache.initialize(this.shadow);const e=this.domCache.get();e.titleError.style.display="none",e.descriptionError.style.display="none",e.submitError.style.display="none",e.progressStatus.textContent="",this.setupRedactionCanvas(),this.attachEventListeners(),document.body.appendChild(this.container),e.titleInput.focus()}close(){document.removeEventListener("keydown",this.handleEscapeKey),this.redactionCanvas&&(this.redactionCanvas.destroy(),this.redactionCanvas=null),this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.domCache.clear(),this.options.onClose&&this.options.onClose()}destroy(){this.close()}setupRedactionCanvas(){const t=this.domCache.get();if(t.redactionCanvas&&t.screenshotImg)try{this.redactionCanvas=new m(t.redactionCanvas),this.redactionCanvas.initializeCanvas(t.screenshotImg)}catch(t){E().warn("Canvas redaction not available:",t),this.redactionCanvas=null}}attachEventListeners(){const t=this.domCache.get();t.closeButton.addEventListener("click",()=>this.close()),document.addEventListener("keydown",this.handleEscapeKey),t.form.addEventListener("submit",t=>this.handleSubmit(t)),t.submitButton.addEventListener("click",()=>{const e=new Event("submit",{bubbles:!0,cancelable:!0});t.form.dispatchEvent(e)}),t.cancelButton.addEventListener("click",()=>this.close()),t.titleInput.addEventListener("input",()=>this.validateField("title")),t.descriptionTextarea.addEventListener("input",()=>{this.validateField("description"),this.checkForPII()}),t.redactButton&&this.redactionCanvas&&t.redactButton.addEventListener("click",()=>this.toggleRedactionMode()),t.clearButton&&this.redactionCanvas&&t.clearButton.addEventListener("click",()=>this.clearRedactions()),t.piiConfirmCheckbox.addEventListener("change",()=>this.updateSubmitButton())}validateField(t){const e=this.domCache.get(),n="title"===t?e.titleInput.value:e.descriptionTextarea.value,i=this.validator.validateField(t,n),r="title"===t?e.titleError:e.descriptionError;i?(r.textContent=i,r.style.display="block"):(r.textContent="",r.style.display="none")}checkForPII(){const t=this.domCache.get(),e=`${t.titleInput.value} ${t.descriptionTextarea.value}`,n=k({enabled:!0}).detectPII(e);this.piiDetections=Array.from(n.entries()).map(([t,e])=>({type:t,count:e})),this.piiDetections.length>0?(t.piiSection.style.display="block",this.piiDisplay.render(this.piiDetections,t.piiContent)):(t.piiSection.style.display="none",t.piiConfirmCheckbox.checked=!1),this.updateSubmitButton()}updateSubmitButton(){const t=this.domCache.get(),e=this.piiDetections.length>0,n=t.piiConfirmCheckbox.checked;t.submitButton.disabled=e&&!n}toggleRedactionMode(){const t=this.domCache.get();this.redactionCanvas&&t.redactButton&&(this.redactionCanvas.toggleRedactionMode()?(t.redactButton.classList.add("active"),t.redactButton.textContent="✓ Redacting..."):(t.redactButton.classList.remove("active"),t.redactButton.textContent="✏️ Redact Area"))}clearRedactions(){this.redactionCanvas&&this.redactionCanvas.clearRedactions()}async handleSubmit(t){var e;t.preventDefault();const n=this.domCache.get();if(n.submitButton.disabled)return;const i={title:n.titleInput.value,description:n.descriptionTextarea.value,piiDetected:this.piiDetections.length>0,piiConfirmed:n.piiConfirmCheckbox.checked},r=this.validator.validate(i);if(!r.isValid)return r.errors.title?(n.titleError.textContent=r.errors.title,n.titleError.style.display="block"):(n.titleError.textContent="",n.titleError.style.display="none"),r.errors.description?(n.descriptionError.textContent=r.errors.description,n.descriptionError.style.display="block"):(n.descriptionError.textContent="",n.descriptionError.style.display="none"),void(r.errors.piiConfirmation&&alert(r.errors.piiConfirmation));n.titleError.style.display="none",n.descriptionError.style.display="none",n.submitError.style.display="none";const s=n.submitButton.textContent||"Submit Bug Report";n.submitButton.disabled=!0,n.submitButton.textContent="Preparing...",n.submitButton.classList.add("loading");const o=t=>{n.submitButton.textContent=t,n.progressStatus.textContent=t,this.options.onProgress&&this.options.onProgress(t)};o("Preparing screenshot...");let a=this.originalScreenshot;if(this.redactionCanvas&&this.redactionCanvas.getRedactions().length>0)try{a=await this.screenshotProcessor.mergeRedactions(this.originalScreenshot,this.redactionCanvas.getCanvas())}catch(t){R.error("Failed to merge redactions:",t),a=this.originalScreenshot}this.originalScreenshot=a;const l={title:i.title.trim(),description:null===(e=i.description)||void 0===e?void 0:e.trim()};try{o("Uploading report..."),await this.options.onSubmit(l),this.close()}catch(t){E().error("Error submitting bug report:",t),n.submitError.textContent="Failed to submit bug report. Please try again.",n.submitError.style.display="block",n.progressStatus.textContent="",n.submitButton.disabled=!1,n.submitButton.textContent=s,n.submitButton.classList.remove("loading")}}getScreenshot(){return this.originalScreenshot}onEscapeKey(t){"Escape"===t.key&&this.close()}}const T=E();class z extends Error{constructor(t,e){super(`Invalid endpoint URL: ${t}. ${e}`),this.endpoint=t,this.reason=e,this.name="InvalidEndpointError"}}function O(t){if(!t)throw new z("","No endpoint configured");try{const e=new URL(t),n=function(t){const e=t.lastIndexOf("/api/v1/reports");return-1!==e?t.substring(0,e):t.replace(/\/$/,"")||""}(e.pathname);return e.origin+n}catch(e){const n=e instanceof Error?e.message:String(e);throw T.error("Invalid endpoint URL - must be a valid absolute URL",{endpoint:t,error:n}),new z(t,"Must be a valid absolute URL (e.g., https://api.example.com/api/v1/reports)")}}const L=(()=>{let t=0;return()=>(t+=1,`u${`0000${(Math.random()*36**4|0).toString(36)}`.slice(-4)}${t}`)})();function F(t){const e=[];for(let n=0,i=t.length;n<i;n++)e.push(t[n]);return e}let D=null;function N(t={}){return D||(t.includeStyleProperties?(D=t.includeStyleProperties,D):(D=F(window.getComputedStyle(document.documentElement)),D))}function B(t,e){const n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function U(t,e={}){return{width:e.width||function(t){const e=B(t,"border-left-width"),n=B(t,"border-right-width");return t.clientWidth+e+n}(t),height:e.height||function(t){const e=B(t,"border-top-width"),n=B(t,"border-bottom-width");return t.clientHeight+e+n}(t)}}const Z=16384;function P(t){return new Promise((e,n)=>{const i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>e(i))})},i.onerror=n,i.crossOrigin="anonymous",i.decoding="async",i.src=t})}const W=(t,e)=>{if(t instanceof e)return!0;const n=Object.getPrototypeOf(t);return null!==n&&(n.constructor.name===e.name||W(n,e))};function j(t,e,n,i){const r=window.getComputedStyle(t,n),s=r.getPropertyValue("content");if(""===s||"none"===s)return;const o=L();try{e.className=`${e.className} ${o}`}catch(t){return}const a=document.createElement("style");a.appendChild(function(t,e,n,i){const r=`.${t}:${e}`,s=n.cssText?function(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}(n):function(t,e){return N(e).map(e=>`${e}: ${t.getPropertyValue(e)}${t.getPropertyPriority(e)?" !important":""};`).join(" ")}(n,i);return document.createTextNode(`${r}{${s}}`)}(o,n,r,i)),e.appendChild(a)}const V="application/font-woff",G="image/jpeg",q={woff:V,woff2:V,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:G,jpeg:G,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function H(t){const e=function(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}(t).toLowerCase();return q[e]||""}function K(t){return-1!==t.search(/^(data:)/)}function $(t,e){return`data:${e};base64,${t}`}async function Y(t,e,n){const i=await fetch(t,e);if(404===i.status)throw new Error(`Resource "${i.url}" not found`);const r=await i.blob();return new Promise((t,e)=>{const s=new FileReader;s.onerror=e,s.onloadend=()=>{try{t(n({res:i,result:s.result}))}catch(t){e(t)}},s.readAsDataURL(r)})}const Q={};async function X(t,e,n){const i=function(t,e,n){let i=t.replace(/\?.*/,"");return n&&(i=t),/ttf|otf|eot|woff2?/i.test(i)&&(i=i.replace(/.*\//,"")),e?`[${e}]${i}`:i}(t,e,n.includeQueryParams);if(null!=Q[i])return Q[i];let r;n.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());try{const i=await Y(t,n.fetchRequestInit,({res:t,result:n})=>(e||(e=t.headers.get("Content-Type")||""),function(t){return t.split(/,/)[1]}(n)));r=$(i,e)}catch(e){r=n.imagePlaceholder||"";let i=`Failed to fetch resource: ${t}`;e&&(i="string"==typeof e?e:e.message),i&&console.warn(i)}return Q[i]=r,r}const J=t=>null!=t.tagName&&"SLOT"===t.tagName.toUpperCase(),tt=t=>null!=t.tagName&&"SVG"===t.tagName.toUpperCase();async function et(t,e,n){return n||!e.filter||e.filter(t)?Promise.resolve(t).then(t=>async function(t,e){return W(t,HTMLCanvasElement)?async function(t){const e=t.toDataURL();return"data:,"===e?t.cloneNode(!1):P(e)}(t):W(t,HTMLVideoElement)?async function(t,e){if(t.currentSrc){const e=document.createElement("canvas"),n=e.getContext("2d");return e.width=t.clientWidth,e.height=t.clientHeight,null==n||n.drawImage(t,0,0,e.width,e.height),P(e.toDataURL())}const n=t.poster,i=H(n);return P(await X(n,i,e))}(t,e):W(t,HTMLIFrameElement)?async function(t,e){var n;try{if(null===(n=null==t?void 0:t.contentDocument)||void 0===n?void 0:n.body)return await et(t.contentDocument.body,e,!0)}catch(t){}return t.cloneNode(!1)}(t,e):t.cloneNode(tt(t))}(t,e)).then(n=>async function(t,e,n){var i,r;if(tt(e))return e;let s=[];return s=J(t)&&t.assignedNodes?F(t.assignedNodes()):W(t,HTMLIFrameElement)&&(null===(i=t.contentDocument)||void 0===i?void 0:i.body)?F(t.contentDocument.body.childNodes):F((null!==(r=t.shadowRoot)&&void 0!==r?r:t).childNodes),0===s.length||W(t,HTMLVideoElement)||await s.reduce((t,i)=>t.then(()=>et(i,n)).then(t=>{t&&e.appendChild(t)}),Promise.resolve()),e}(t,n,e)).then(n=>function(t,e,n){return W(e,Element)&&(function(t,e,n){const i=e.style;if(!i)return;const r=window.getComputedStyle(t);r.cssText?(i.cssText=r.cssText,i.transformOrigin=r.transformOrigin):N(n).forEach(n=>{let s=r.getPropertyValue(n);if("font-size"===n&&s.endsWith("px")){const t=Math.floor(parseFloat(s.substring(0,s.length-2)))-.1;s=`${t}px`}W(t,HTMLIFrameElement)&&"display"===n&&"inline"===s&&(s="block"),"d"===n&&e.getAttribute("d")&&(s=`path(${e.getAttribute("d")})`),i.setProperty(n,s,r.getPropertyPriority(n))})}(t,e,n),function(t,e,n){j(t,e,":before",n),j(t,e,":after",n)}(t,e,n),function(t,e){W(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),W(t,HTMLInputElement)&&e.setAttribute("value",t.value)}(t,e),function(t,e){if(W(t,HTMLSelectElement)){const n=e,i=Array.from(n.children).find(e=>t.value===e.getAttribute("value"));i&&i.setAttribute("selected","")}}(t,e)),e}(t,n,e)).then(t=>async function(t,e){const n=t.querySelectorAll?t.querySelectorAll("use"):[];if(0===n.length)return t;const i={};for(let r=0;r<n.length;r++){const s=n[r].getAttribute("xlink:href");if(s){const n=t.querySelector(s),r=document.querySelector(s);n||!r||i[s]||(i[s]=await et(r,e,!0))}}const r=Object.values(i);if(r.length){const e="http://www.w3.org/1999/xhtml",n=document.createElementNS(e,"svg");n.setAttribute("xmlns",e),n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.style.display="none";const i=document.createElementNS(e,"defs");n.appendChild(i);for(let t=0;t<r.length;t++)i.appendChild(r[t]);t.appendChild(n)}return t}(t,e)):null}const nt=/url\((['"]?)([^'"]+?)\1\)/g,it=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,rt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function st(t){return-1!==t.search(nt)}async function ot(t,e,n){if(!st(t))return t;const i=function(t,{preferredFontFormat:e}){return e?t.replace(rt,t=>{for(;;){const[n,,i]=it.exec(t)||[];if(!i)return"";if(i===e)return`src: ${n};`}}):t}(t,n),r=function(t){const e=[];return t.replace(nt,(t,n,i)=>(e.push(i),t)),e.filter(t=>!K(t))}(i);return r.reduce((t,i)=>t.then(t=>async function(t,e,n,i,r){try{const s=n?function(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const n=document.implementation.createHTMLDocument(),i=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(i),n.body.appendChild(r),e&&(i.href=e),r.href=t,r.href}(e,n):e,o=H(e);let a;return a=r?$(await r(s),o):await X(s,o,i),t.replace(function(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}(e),`$1${a}$3`)}catch(t){}return t}(t,i,e,n)),Promise.resolve(i))}async function at(t,e,n){var i;const r=null===(i=e.style)||void 0===i?void 0:i.getPropertyValue(t);if(r){const i=await ot(r,null,n);return e.style.setProperty(t,i,e.style.getPropertyPriority(t)),!0}return!1}async function lt(t,e){W(t,Element)&&(await async function(t,e){await at("background",t,e)||await at("background-image",t,e),await at("mask",t,e)||await at("-webkit-mask",t,e)||await at("mask-image",t,e)||await at("-webkit-mask-image",t,e)}(t,e),await async function(t,e){const n=W(t,HTMLImageElement);if((!n||K(t.src))&&(!W(t,SVGImageElement)||K(t.href.baseVal)))return;const i=n?t.src:t.href.baseVal,r=await X(i,H(i),e);await new Promise((i,s)=>{t.onload=i,t.onerror=e.onImageErrorHandler?(...t)=>{try{i(e.onImageErrorHandler(...t))}catch(t){s(t)}}:s;const o=t;o.decode&&(o.decode=i),"lazy"===o.loading&&(o.loading="eager"),n?(t.srcset="",t.src=r):t.href.baseVal=r})}(t,e),await async function(t,e){const n=F(t.childNodes).map(t=>lt(t,e));await Promise.all(n).then(()=>t)}(t,e))}const ct={};async function dt(t){let e=ct[t];if(null!=e)return e;const n=await fetch(t);return e={url:t,cssText:await n.text()},ct[t]=e,e}async function ht(t,e){let n=t.cssText;const i=/url\(["']?([^"')]+)["']?\)/g,r=(n.match(/url\([^)]+\)/g)||[]).map(async r=>{let s=r.replace(i,"$1");return s.startsWith("https://")||(s=new URL(s,t.url).href),Y(s,e.fetchRequestInit,({result:t})=>(n=n.replace(r,`url(${t})`),[r,t]))});return Promise.all(r).then(()=>n)}function ut(t){if(null==t)return[];const e=[];let n=t.replace(/(\/\*[\s\S]*?\*\/)/gi,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const t=i.exec(n);if(null===t)break;e.push(t[0])}n=n.replace(i,"");const r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let t=r.exec(n);if(null===t){if(t=s.exec(n),null===t)break;r.lastIndex=s.lastIndex}else s.lastIndex=r.lastIndex;e.push(t[0])}return e}function pt(t){return t.trim().replace(/["']/g,"")}async function gt(t,e){const n=await async function(t,e){if(null==t.ownerDocument)throw new Error("Provided element is not within a Document");const n=F(t.ownerDocument.styleSheets),i=await async function(t,e){const n=[],i=[];return t.forEach(n=>{if("cssRules"in n)try{F(n.cssRules||[]).forEach((t,r)=>{if(t.type===CSSRule.IMPORT_RULE){let s=r+1;const o=dt(t.href).then(t=>ht(t,e)).then(t=>ut(t).forEach(t=>{try{n.insertRule(t,t.startsWith("@import")?s+=1:n.cssRules.length)}catch(e){console.error("Error inserting rule from remote css",{rule:t,error:e})}})).catch(t=>{console.error("Error loading remote css",t.toString())});i.push(o)}})}catch(r){const s=t.find(t=>null==t.href)||document.styleSheets[0];null!=n.href&&i.push(dt(n.href).then(t=>ht(t,e)).then(t=>ut(t).forEach(t=>{s.insertRule(t,s.cssRules.length)})).catch(t=>{console.error("Error loading remote stylesheet",t)})),console.error("Error inlining remote css file",r)}}),Promise.all(i).then(()=>(t.forEach(t=>{if("cssRules"in t)try{F(t.cssRules||[]).forEach(t=>{n.push(t)})}catch(e){console.error(`Error while reading CSS rules from ${t.href}`,e)}}),n))}(n,e);return function(t){return t.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>st(t.style.getPropertyValue("src")))}(i)}(t,e),i=function(t){const e=new Set;return function t(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(t=>{e.add(pt(t))}),Array.from(n.children).forEach(e=>{e instanceof HTMLElement&&t(e)})}(t),e}(t);return(await Promise.all(n.filter(t=>i.has(pt(t.style.fontFamily))).map(t=>{const n=t.parentStyleSheet?t.parentStyleSheet.href:null;return ot(t.cssText,n,e)}))).join("\n")}async function mt(t,e={}){const{width:n,height:i}=U(t,e),r=await et(t,e,!0);return await async function(t,e){const n=null!=e.fontEmbedCSS?e.fontEmbedCSS:e.skipFonts?null:await gt(t,e);if(n){const e=document.createElement("style"),i=document.createTextNode(n);e.appendChild(i),t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)}}(r,e),await lt(r,e),function(t,e){const{style:n}=t;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=`${e.width}px`),e.height&&(n.height=`${e.height}px`);const i=e.style;null!=i&&Object.keys(i).forEach(t=>{n[t]=i[t]})}(r,e),await async function(t,e,n){const i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg"),s=document.createElementNS(i,"foreignObject");return r.setAttribute("width",`${e}`),r.setAttribute("height",`${n}`),r.setAttribute("viewBox",`0 0 ${e} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),r.appendChild(s),s.appendChild(t),async function(t){return Promise.resolve().then(()=>(new XMLSerializer).serializeToString(t)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}(r)}(r,n,i)}const ft=E();class yt{constructor(t){this.options=t,this.sanitizer=t.sanitizer}handleError(t,e){const n=e instanceof Error?e:new Error(String(e));ft.error(`${this.constructor.name} ${t}:`,n)}}function bt(t){let e=t.length;for(;--e>=0;)t[e]=0}const wt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),vt=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Ct=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),It=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_t=new Array(576);bt(_t);const St=new Array(60);bt(St);const kt=new Array(512);bt(kt);const xt=new Array(256);bt(xt);const At=new Array(29);bt(At);const Et=new Array(30);function Rt(t,e,n,i,r){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=t&&t.length}let Mt,Tt,zt;function Ot(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}bt(Et);const Lt=t=>t<256?kt[t]:kt[256+(t>>>7)],Ft=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Dt=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,Ft(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},Nt=(t,e,n)=>{Dt(t,n[2*e],n[2*e+1])},Bt=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},Ut=(t,e,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=15;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=Bt(i[e]++,e))}},Zt=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},Pt=t=>{t.bi_valid>8?Ft(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Wt=(t,e,n,i)=>{const r=2*e,s=2*n;return t[r]<t[s]||t[r]===t[s]&&i[e]<=i[n]},jt=(t,e,n)=>{const i=t.heap[n];let r=n<<1;for(;r<=t.heap_len&&(r<t.heap_len&&Wt(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!Wt(e,i,t.heap[r],t.depth));)t.heap[n]=t.heap[r],n=r,r<<=1;t.heap[n]=i},Vt=(t,e,n)=>{let i,r,s,o,a=0;if(0!==t.sym_next)do{i=255&t.pending_buf[t.sym_buf+a++],i+=(255&t.pending_buf[t.sym_buf+a++])<<8,r=t.pending_buf[t.sym_buf+a++],0===i?Nt(t,r,e):(s=xt[r],Nt(t,s+256+1,e),o=wt[s],0!==o&&(r-=At[s],Dt(t,r,o)),i--,s=Lt(i),Nt(t,s,n),o=vt[s],0!==o&&(i-=Et[s],Dt(t,i,o)))}while(a<t.sym_next);Nt(t,256,e)},Gt=(t,e)=>{const n=e.dyn_tree,i=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,l,c=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==n[2*o]?(t.heap[++t.heap_len]=c=o,t.depth[o]=0):n[2*o+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=c<2?++c:0,n[2*l]=1,t.depth[l]=0,t.opt_len--,r&&(t.static_len-=i[2*l+1]);for(e.max_code=c,o=t.heap_len>>1;o>=1;o--)jt(t,n,o);l=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],jt(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,n[2*l]=n[2*o]+n[2*a],t.depth[l]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,n[2*o+1]=n[2*a+1]=l,t.heap[1]=l++,jt(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,i=e.max_code,r=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length;let c,d,h,u,p,g,m=0;for(u=0;u<=15;u++)t.bl_count[u]=0;for(n[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)d=t.heap[c],u=n[2*n[2*d+1]+1]+1,u>l&&(u=l,m++),n[2*d+1]=u,d>i||(t.bl_count[u]++,p=0,d>=a&&(p=o[d-a]),g=n[2*d],t.opt_len+=g*(u+p),s&&(t.static_len+=g*(r[2*d+1]+p)));if(0!==m){do{for(u=l-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[l]--,m-=2}while(m>0);for(u=l;0!==u;u--)for(d=t.bl_count[u];0!==d;)h=t.heap[--c],h>i||(n[2*h+1]!==u&&(t.opt_len+=(u-n[2*h+1])*n[2*h],n[2*h+1]=u),d--)}})(t,e),Ut(n,c,t.bl_count)},qt=(t,e,n)=>{let i,r,s=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),e[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=e[2*(i+1)+1],++a<l&&r===o||(a<c?t.bl_tree[2*r]+=a:0!==r?(r!==s&&t.bl_tree[2*r]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=r,0===o?(l=138,c=3):r===o?(l=6,c=3):(l=7,c=4))},Ht=(t,e,n)=>{let i,r,s=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),i=0;i<=n;i++)if(r=o,o=e[2*(i+1)+1],!(++a<l&&r===o)){if(a<c)do{Nt(t,r,t.bl_tree)}while(0!==--a);else 0!==r?(r!==s&&(Nt(t,r,t.bl_tree),a--),Nt(t,16,t.bl_tree),Dt(t,a-3,2)):a<=10?(Nt(t,17,t.bl_tree),Dt(t,a-3,3)):(Nt(t,18,t.bl_tree),Dt(t,a-11,7));a=0,s=r,0===o?(l=138,c=3):r===o?(l=6,c=3):(l=7,c=4)}};let Kt=!1;const $t=(t,e,n,i)=>{Dt(t,0+(i?1:0),3),Pt(t),Ft(t,n),Ft(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n};var Yt={_tr_init:t=>{Kt||((()=>{let t,e,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(At[i]=n,t=0;t<1<<wt[i];t++)xt[n++]=i;for(xt[n-1]=i,r=0,i=0;i<16;i++)for(Et[i]=r,t=0;t<1<<vt[i];t++)kt[r++]=i;for(r>>=7;i<30;i++)for(Et[i]=r<<7,t=0;t<1<<vt[i]-7;t++)kt[256+r++]=i;for(e=0;e<=15;e++)s[e]=0;for(t=0;t<=143;)_t[2*t+1]=8,t++,s[8]++;for(;t<=255;)_t[2*t+1]=9,t++,s[9]++;for(;t<=279;)_t[2*t+1]=7,t++,s[7]++;for(;t<=287;)_t[2*t+1]=8,t++,s[8]++;for(Ut(_t,287,s),t=0;t<30;t++)St[2*t+1]=5,St[2*t]=Bt(t,5);Mt=new Rt(_t,wt,257,286,15),Tt=new Rt(St,vt,0,30,15),zt=new Rt(new Array(0),Ct,0,19,7)})(),Kt=!0),t.l_desc=new Ot(t.dyn_ltree,Mt),t.d_desc=new Ot(t.dyn_dtree,Tt),t.bl_desc=new Ot(t.bl_tree,zt),t.bi_buf=0,t.bi_valid=0,Zt(t)},_tr_stored_block:$t,_tr_flush_block:(t,e,n,i)=>{let r,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Gt(t,t.l_desc),Gt(t,t.d_desc),o=(t=>{let e;for(qt(t,t.dyn_ltree,t.l_desc.max_code),qt(t,t.dyn_dtree,t.d_desc.max_code),Gt(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*It[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==e?$t(t,e,n,i):4===t.strategy||s===r?(Dt(t,2+(i?1:0),3),Vt(t,_t,St)):(Dt(t,4+(i?1:0),3),((t,e,n,i)=>{let r;for(Dt(t,e-257,5),Dt(t,n-1,5),Dt(t,i-4,4),r=0;r<i;r++)Dt(t,t.bl_tree[2*It[r]+1],3);Ht(t,t.dyn_ltree,e-1),Ht(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Vt(t,t.dyn_ltree,t.dyn_dtree)),Zt(t),i&&Pt(t)},_tr_tally:(t,e,n)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=n,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(xt[n]+256+1)]++,t.dyn_dtree[2*Lt(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{Dt(t,2,3),Nt(t,256,_t),(t=>{16===t.bi_valid?(Ft(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},Qt=(t,e,n,i)=>{let r=65535&t,s=t>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+e[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Xt=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());var Jt=(t,e,n,i)=>{const r=Xt,s=i+n;t^=-1;for(let n=i;n<s;n++)t=t>>>8^r[255&(t^e[n])];return-1^t},te={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ee={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:ne,_tr_stored_block:ie,_tr_flush_block:re,_tr_tally:se,_tr_align:oe}=Yt,{Z_NO_FLUSH:ae,Z_PARTIAL_FLUSH:le,Z_FULL_FLUSH:ce,Z_FINISH:de,Z_BLOCK:he,Z_OK:ue,Z_STREAM_END:pe,Z_STREAM_ERROR:ge,Z_DATA_ERROR:me,Z_BUF_ERROR:fe,Z_DEFAULT_COMPRESSION:ye,Z_FILTERED:be,Z_HUFFMAN_ONLY:we,Z_RLE:ve,Z_FIXED:Ce,Z_DEFAULT_STRATEGY:Ie,Z_UNKNOWN:_e,Z_DEFLATED:Se}=ee,ke=258,xe=262,Ae=42,Ee=113,Re=666,Me=(t,e)=>(t.msg=te[e],e),Te=t=>2*t-(t>4?9:0),ze=t=>{let e=t.length;for(;--e>=0;)t[e]=0},Oe=t=>{let e,n,i,r=t.w_size;e=t.hash_size,i=e;do{n=t.head[--i],t.head[i]=n>=r?n-r:0}while(--e);e=r,i=e;do{n=t.prev[--i],t.prev[i]=n>=r?n-r:0}while(--e)};let Le=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const Fe=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},De=(t,e)=>{re(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Fe(t.strm)},Ne=(t,e)=>{t.pending_buf[t.pending++]=e},Be=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Ue=(t,e,n,i)=>{let r=t.avail_in;return r>i&&(r=i),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),n),1===t.state.wrap?t.adler=Qt(t.adler,e,r,n):2===t.state.wrap&&(t.adler=Jt(t.adler,e,r,n)),t.next_in+=r,t.total_in+=r,r)},Ze=(t,e)=>{let n,i,r=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const l=t.strstart>t.w_size-xe?t.strstart-(t.w_size-xe):0,c=t.window,d=t.w_mask,h=t.prev,u=t.strstart+ke;let p=c[s+o-1],g=c[s+o];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do{if(n=e,c[n+o]===g&&c[n+o-1]===p&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&s<u);if(i=ke-(u-s),s=u-ke,i>o){if(t.match_start=e,o=i,i>=a)break;p=c[s+o-1],g=c[s+o]}}}while((e=h[e&d])>l&&0!==--r);return o<=t.lookahead?o:t.lookahead},Pe=t=>{const e=t.w_size;let n,i,r;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-xe)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),Oe(t),i+=e),0===t.strm.avail_in)break;if(n=Ue(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=Le(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=Le(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<xe&&0!==t.strm.avail_in)},We=(t,e)=>{let n,i,r,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(n=65535,r=t.bi_valid+42>>3,t.strm.avail_out<r)break;if(r=t.strm.avail_out-r,i=t.strstart-t.block_start,n>i+t.strm.avail_in&&(n=i+t.strm.avail_in),n>r&&(n=r),n<s&&(0===n&&e!==de||e===ae||n!==i+t.strm.avail_in))break;o=e===de&&n===i+t.strm.avail_in?1:0,ie(t,0,0,o),t.pending_buf[t.pending-4]=n,t.pending_buf[t.pending-3]=n>>8,t.pending_buf[t.pending-2]=~n,t.pending_buf[t.pending-1]=~n>>8,Fe(t.strm),i&&(i>n&&(i=n),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,n-=i),n&&(Ue(t.strm,t.strm.output,t.strm.next_out,n),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n)}while(0===o);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),o?4:e!==ae&&e!==de&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(r=t.window_size-t.strstart,t.strm.avail_in>r&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,r+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),r>t.strm.avail_in&&(r=t.strm.avail_in),r&&(Ue(t.strm,t.window,t.strstart,r),t.strstart+=r,t.insert+=r>t.w_size-t.insert?t.w_size-t.insert:r),t.high_water<t.strstart&&(t.high_water=t.strstart),r=t.bi_valid+42>>3,r=t.pending_buf_size-r>65535?65535:t.pending_buf_size-r,s=r>t.w_size?t.w_size:r,i=t.strstart-t.block_start,(i>=s||(i||e===de)&&e!==ae&&0===t.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=e===de&&0===t.strm.avail_in&&n===i?1:0,ie(t,t.block_start,n,o),t.block_start+=n,Fe(t.strm)),o?3:1)},je=(t,e)=>{let n,i;for(;;){if(t.lookahead<xe){if(Pe(t),t.lookahead<xe&&e===ae)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=Le(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-xe&&(t.match_length=Ze(t,n)),t.match_length>=3)if(i=se(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=Le(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=Le(t,t.ins_h,t.window[t.strstart+1]);else i=se(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(De(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===de?(De(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(De(t,!1),0===t.strm.avail_out)?1:2},Ve=(t,e)=>{let n,i,r;for(;;){if(t.lookahead<xe){if(Pe(t),t.lookahead<xe&&e===ae)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=Le(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-xe&&(t.match_length=Ze(t,n),t.match_length<=5&&(t.strategy===be||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,i=se(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=Le(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(De(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=se(t,0,t.window[t.strstart-1]),i&&De(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=se(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===de?(De(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(De(t,!1),0===t.strm.avail_out)?1:2};function Ge(t,e,n,i,r){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=i,this.func=r}const qe=[new Ge(0,0,0,0,We),new Ge(4,4,8,4,je),new Ge(4,5,16,8,je),new Ge(4,6,32,32,je),new Ge(4,4,16,16,Ve),new Ge(8,16,32,32,Ve),new Ge(8,16,128,128,Ve),new Ge(8,32,128,256,Ve),new Ge(32,128,258,1024,Ve),new Ge(32,258,258,4096,Ve)];function He(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Se,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ze(this.dyn_ltree),ze(this.dyn_dtree),ze(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ze(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ze(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ke=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==Ae&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==Ee&&e.status!==Re?1:0},$e=t=>{if(Ke(t))return Me(t,ge);t.total_in=t.total_out=0,t.data_type=_e;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?Ae:Ee,t.adler=2===e.wrap?0:1,e.last_flush=-2,ne(e),ue},Ye=t=>{const e=$e(t);var n;return e===ue&&((n=t.state).window_size=2*n.w_size,ze(n.head),n.max_lazy_match=qe[n.level].max_lazy,n.good_match=qe[n.level].good_length,n.nice_match=qe[n.level].nice_length,n.max_chain_length=qe[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),e},Qe=(t,e,n,i,r,s)=>{if(!t)return ge;let o=1;if(e===ye&&(e=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==Se||i<8||i>15||e<0||e>9||s<0||s>Ce||8===i&&1!==o)return Me(t,ge);8===i&&(i=9);const a=new He;return t.state=a,a.strm=t,a.status=Ae,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=r+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<r+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=s,a.method=n,Ye(t)};var Xe=Qe,Je=(t,e)=>Ke(t)||2!==t.state.wrap?ge:(t.state.gzhead=e,ue),tn=(t,e)=>{if(Ke(t)||e>he||e<0)return t?Me(t,ge):ge;const n=t.state;if(!t.output||0!==t.avail_in&&!t.input||n.status===Re&&e!==de)return Me(t,0===t.avail_out?fe:ge);const i=n.last_flush;if(n.last_flush=e,0!==n.pending){if(Fe(t),0===t.avail_out)return n.last_flush=-1,ue}else if(0===t.avail_in&&Te(e)<=Te(i)&&e!==de)return Me(t,fe);if(n.status===Re&&0!==t.avail_in)return Me(t,fe);if(n.status===Ae&&0===n.wrap&&(n.status=Ee),n.status===Ae){let e=Se+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=we||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=i<<6,0!==n.strstart&&(e|=32),e+=31-e%31,Be(n,e),0!==n.strstart&&(Be(n,t.adler>>>16),Be(n,65535&t.adler)),t.adler=1,n.status=Ee,Fe(t),0!==n.pending)return n.last_flush=-1,ue}if(57===n.status)if(t.adler=0,Ne(n,31),Ne(n,139),Ne(n,8),n.gzhead)Ne(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Ne(n,255&n.gzhead.time),Ne(n,n.gzhead.time>>8&255),Ne(n,n.gzhead.time>>16&255),Ne(n,n.gzhead.time>>24&255),Ne(n,9===n.level?2:n.strategy>=we||n.level<2?4:0),Ne(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Ne(n,255&n.gzhead.extra.length),Ne(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=Jt(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Ne(n,0),Ne(n,0),Ne(n,0),Ne(n,0),Ne(n,0),Ne(n,9===n.level?2:n.strategy>=we||n.level<2?4:0),Ne(n,3),n.status=Ee,Fe(t),0!==n.pending)return n.last_flush=-1,ue;if(69===n.status){if(n.gzhead.extra){let e=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>e&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex+=r,Fe(t),0!==n.pending)return n.last_flush=-1,ue;e=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>e&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-i,i)),Fe(t),0!==n.pending)return n.last_flush=-1,ue;i=0}e=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,Ne(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-i,i)),Fe(t),0!==n.pending)return n.last_flush=-1,ue;i=0}e=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,Ne(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Fe(t),0!==n.pending))return n.last_flush=-1,ue;Ne(n,255&t.adler),Ne(n,t.adler>>8&255),t.adler=0}if(n.status=Ee,Fe(t),0!==n.pending)return n.last_flush=-1,ue}if(0!==t.avail_in||0!==n.lookahead||e!==ae&&n.status!==Re){let i=0===n.level?We(n,e):n.strategy===we?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(Pe(t),0===t.lookahead)){if(e===ae)return 1;break}if(t.match_length=0,n=se(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(De(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===de?(De(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(De(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===ve?((t,e)=>{let n,i,r,s;const o=t.window;for(;;){if(t.lookahead<=ke){if(Pe(t),t.lookahead<=ke&&e===ae)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=t.strstart+ke;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&r<s);t.match_length=ke-(s-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=se(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=se(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(De(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===de?(De(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(De(t,!1),0===t.strm.avail_out)?1:2})(n,e):qe[n.level].func(n,e);if(3!==i&&4!==i||(n.status=Re),1===i||3===i)return 0===t.avail_out&&(n.last_flush=-1),ue;if(2===i&&(e===le?oe(n):e!==he&&(ie(n,0,0,!1),e===ce&&(ze(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Fe(t),0===t.avail_out))return n.last_flush=-1,ue}return e!==de?ue:n.wrap<=0?pe:(2===n.wrap?(Ne(n,255&t.adler),Ne(n,t.adler>>8&255),Ne(n,t.adler>>16&255),Ne(n,t.adler>>24&255),Ne(n,255&t.total_in),Ne(n,t.total_in>>8&255),Ne(n,t.total_in>>16&255),Ne(n,t.total_in>>24&255)):(Be(n,t.adler>>>16),Be(n,65535&t.adler)),Fe(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?ue:pe)},en=t=>{if(Ke(t))return ge;const e=t.state.status;return t.state=null,e===Ee?Me(t,me):ue},nn=(t,e)=>{let n=e.length;if(Ke(t))return ge;const i=t.state,r=i.wrap;if(2===r||1===r&&i.status!==Ae||i.lookahead)return ge;if(1===r&&(t.adler=Qt(t.adler,e,n,0)),i.wrap=0,n>=i.w_size){0===r&&(ze(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(n-i.w_size,n),0),e=t,n=i.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,Pe(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=Le(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,Pe(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,i.wrap=r,ue};const rn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var sn=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)rn(n,e)&&(t[e]=n[e])}}return t},on=t=>{let e=0;for(let n=0,i=t.length;n<i;n++)e+=t[n].length;const n=new Uint8Array(e);for(let e=0,i=0,r=t.length;e<r;e++){let r=t[e];n.set(r,i),i+=r.length}return n};let an=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){an=!1}const ln=new Uint8Array(256);for(let t=0;t<256;t++)ln[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;ln[254]=ln[254]=1;var cn=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,i,r,s,o=t.length,a=0;for(r=0;r<o;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<o&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(a),s=0,r=0;s<a;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<o&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),n<128?e[s++]=n:n<2048?(e[s++]=192|n>>>6,e[s++]=128|63&n):n<65536?(e[s++]=224|n>>>12,e[s++]=128|n>>>6&63,e[s++]=128|63&n):(e[s++]=240|n>>>18,e[s++]=128|n>>>12&63,e[s++]=128|n>>>6&63,e[s++]=128|63&n);return e},dn=(t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,r;const s=new Array(2*n);for(r=0,i=0;i<n;){let e=t[i++];if(e<128){s[r++]=e;continue}let o=ln[e];if(o>4)s[r++]=65533,i+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&i<n;)e=e<<6|63&t[i++],o--;o>1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&an)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let i=0;i<e;i++)n+=String.fromCharCode(t[i]);return n})(s,r)},hn=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+ln[t[n]]>e?n:e},un=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const pn=Object.prototype.toString,{Z_NO_FLUSH:gn,Z_SYNC_FLUSH:mn,Z_FULL_FLUSH:fn,Z_FINISH:yn,Z_OK:bn,Z_STREAM_END:wn,Z_DEFAULT_COMPRESSION:vn,Z_DEFAULT_STRATEGY:Cn,Z_DEFLATED:In}=ee;function _n(t){this.options=sn({level:vn,method:In,chunkSize:16384,windowBits:15,memLevel:8,strategy:Cn},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new un,this.strm.avail_out=0;let n=Xe(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==bn)throw new Error(te[n]);if(e.header&&Je(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?cn(e.dictionary):"[object ArrayBuffer]"===pn.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=nn(this.strm,t),n!==bn)throw new Error(te[n]);this._dict_set=!0}}function Sn(t,e){const n=new _n(e);if(n.push(t,!0),n.err)throw n.msg||te[n.err];return n.result}_n.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?yn:gn,"string"==typeof t?n.input=cn(t):"[object ArrayBuffer]"===pn.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),(s===mn||s===fn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=tn(n,s),r===wn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=en(this.strm),this.onEnd(r),this.ended=!0,r===bn;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},_n.prototype.onData=function(t){this.chunks.push(t)},_n.prototype.onEnd=function(t){t===bn&&(this.result=on(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var kn={Deflate:_n,deflate:Sn,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Sn(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Sn(t,e)},constants:ee};const xn=16209;var An=function(t,e){let n,i,r,s,o,a,l,c,d,h,u,p,g,m,f,y,b,w,v,C,I,_,S,k;const x=t.state;n=t.next_in,S=t.input,i=n+(t.avail_in-5),r=t.next_out,k=t.output,s=r-(e-t.avail_out),o=r+(t.avail_out-257),a=x.dmax,l=x.wsize,c=x.whave,d=x.wnext,h=x.window,u=x.hold,p=x.bits,g=x.lencode,m=x.distcode,f=(1<<x.lenbits)-1,y=(1<<x.distbits)-1;t:do{p<15&&(u+=S[n++]<<p,p+=8,u+=S[n++]<<p,p+=8),b=g[u&f];e:for(;;){if(w=b>>>24,u>>>=w,p-=w,w=b>>>16&255,0===w)k[r++]=65535&b;else{if(!(16&w)){if(64&w){if(32&w){x.mode=16191;break t}t.msg="invalid literal/length code",x.mode=xn;break t}b=g[(65535&b)+(u&(1<<w)-1)];continue e}for(v=65535&b,w&=15,w&&(p<w&&(u+=S[n++]<<p,p+=8),v+=u&(1<<w)-1,u>>>=w,p-=w),p<15&&(u+=S[n++]<<p,p+=8,u+=S[n++]<<p,p+=8),b=m[u&y];;){if(w=b>>>24,u>>>=w,p-=w,w=b>>>16&255,16&w){if(C=65535&b,w&=15,p<w&&(u+=S[n++]<<p,p+=8,p<w&&(u+=S[n++]<<p,p+=8)),C+=u&(1<<w)-1,C>a){t.msg="invalid distance too far back",x.mode=xn;break t}if(u>>>=w,p-=w,w=r-s,C>w){if(w=C-w,w>c&&x.sane){t.msg="invalid distance too far back",x.mode=xn;break t}if(I=0,_=h,0===d){if(I+=l-w,w<v){v-=w;do{k[r++]=h[I++]}while(--w);I=r-C,_=k}}else if(d<w){if(I+=l+d-w,w-=d,w<v){v-=w;do{k[r++]=h[I++]}while(--w);if(I=0,d<v){w=d,v-=w;do{k[r++]=h[I++]}while(--w);I=r-C,_=k}}}else if(I+=d-w,w<v){v-=w;do{k[r++]=h[I++]}while(--w);I=r-C,_=k}for(;v>2;)k[r++]=_[I++],k[r++]=_[I++],k[r++]=_[I++],v-=3;v&&(k[r++]=_[I++],v>1&&(k[r++]=_[I++]))}else{I=r-C;do{k[r++]=k[I++],k[r++]=k[I++],k[r++]=k[I++],v-=3}while(v>2);v&&(k[r++]=k[I++],v>1&&(k[r++]=k[I++]))}break}if(64&w){t.msg="invalid distance code",x.mode=xn;break t}b=m[(65535&b)+(u&(1<<w)-1)]}}break}}while(n<i&&r<o);v=p>>3,n-=v,p-=v<<3,u&=(1<<p)-1,t.next_in=n,t.next_out=r,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=r<o?o-r+257:257-(r-o),x.hold=u,x.bits=p};const En=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Rn=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Mn=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Tn=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var zn=(t,e,n,i,r,s,o,a)=>{const l=a.bits;let c,d,h,u,p,g,m=0,f=0,y=0,b=0,w=0,v=0,C=0,I=0,_=0,S=0,k=null;const x=new Uint16Array(16),A=new Uint16Array(16);let E,R,M,T=null;for(m=0;m<=15;m++)x[m]=0;for(f=0;f<i;f++)x[e[n+f]]++;for(w=l,b=15;b>=1&&0===x[b];b--);if(w>b&&(w=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(y=1;y<b&&0===x[y];y++);for(w<y&&(w=y),I=1,m=1;m<=15;m++)if(I<<=1,I-=x[m],I<0)return-1;if(I>0&&(0===t||1!==b))return-1;for(A[1]=0,m=1;m<15;m++)A[m+1]=A[m]+x[m];for(f=0;f<i;f++)0!==e[n+f]&&(o[A[e[n+f]]++]=f);if(0===t?(k=T=o,g=20):1===t?(k=En,T=Rn,g=257):(k=Mn,T=Tn,g=0),S=0,f=0,m=y,p=s,v=w,C=0,h=-1,_=1<<w,u=_-1,1===t&&_>852||2===t&&_>592)return 1;for(;;){E=m-C,o[f]+1<g?(R=0,M=o[f]):o[f]>=g?(R=T[o[f]-g],M=k[o[f]-g]):(R=96,M=0),c=1<<m-C,d=1<<v,y=d;do{d-=c,r[p+(S>>C)+d]=E<<24|R<<16|M}while(0!==d);for(c=1<<m-1;S&c;)c>>=1;if(0!==c?(S&=c-1,S+=c):S=0,f++,0===--x[m]){if(m===b)break;m=e[n+o[f]]}if(m>w&&(S&u)!==h){for(0===C&&(C=w),p+=y,v=m-C,I=1<<v;v+C<b&&(I-=x[v+C],!(I<=0));)v++,I<<=1;if(_+=1<<v,1===t&&_>852||2===t&&_>592)return 1;h=S&u,r[h]=w<<24|v<<16|p-s}}return 0!==S&&(r[p+S]=m-C<<24|64<<16),a.bits=w,0};const{Z_FINISH:On,Z_BLOCK:Ln,Z_TREES:Fn,Z_OK:Dn,Z_STREAM_END:Nn,Z_NEED_DICT:Bn,Z_STREAM_ERROR:Un,Z_DATA_ERROR:Zn,Z_MEM_ERROR:Pn,Z_BUF_ERROR:Wn,Z_DEFLATED:jn}=ee,Vn=16180,Gn=16190,qn=16191,Hn=16192,Kn=16194,$n=16199,Yn=16200,Qn=16206,Xn=16209,Jn=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ti(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ei=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<Vn||e.mode>16211?1:0},ni=t=>{if(ei(t))return Un;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=Vn,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,Dn},ii=t=>{if(ei(t))return Un;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ni(t)},ri=(t,e)=>{let n;if(ei(t))return Un;const i=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?Un:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=n,i.wbits=e,ii(t))},si=(t,e)=>{if(!t)return Un;const n=new ti;t.state=n,n.strm=t,n.window=null,n.mode=Vn;const i=ri(t,e);return i!==Dn&&(t.state=null),i};let oi,ai,li=!0;const ci=t=>{if(li){oi=new Int32Array(512),ai=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(zn(1,t.lens,0,288,oi,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;zn(2,t.lens,0,32,ai,0,t.work,{bits:5}),li=!1}t.lencode=oi,t.lenbits=9,t.distcode=ai,t.distbits=5},di=(t,e,n,i)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(e.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(e.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0};var hi=ii,ui=si,pi=(t,e)=>{let n,i,r,s,o,a,l,c,d,h,u,p,g,m,f,y,b,w,v,C,I,_,S=0;const k=new Uint8Array(4);let x,A;const E=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(ei(t)||!t.output||!t.input&&0!==t.avail_in)return Un;n=t.state,n.mode===qn&&(n.mode=Hn),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,h=a,u=l,_=Dn;t:for(;;)switch(n.mode){case Vn:if(0===n.wrap){n.mode=Hn;break}for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(2&n.wrap&&35615===c){0===n.wbits&&(n.wbits=15),n.check=0,k[0]=255&c,k[1]=c>>>8&255,n.check=Jt(n.check,k,2,0),c=0,d=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",n.mode=Xn;break}if((15&c)!==jn){t.msg="unknown compression method",n.mode=Xn;break}if(c>>>=4,d-=4,I=8+(15&c),0===n.wbits&&(n.wbits=I),I>15||I>n.wbits){t.msg="invalid window size",n.mode=Xn;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&c?16189:qn,c=0,d=0;break;case 16181:for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(n.flags=c,(255&n.flags)!==jn){t.msg="unknown compression method",n.mode=Xn;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=Xn;break}n.head&&(n.head.text=c>>8&1),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=Jt(n.check,k,2,0)),c=0,d=0,n.mode=16182;case 16182:for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.head&&(n.head.time=c),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,k[2]=c>>>16&255,k[3]=c>>>24&255,n.check=Jt(n.check,k,4,0)),c=0,d=0,n.mode=16183;case 16183:for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.head&&(n.head.xflags=255&c,n.head.os=c>>8),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=Jt(n.check,k,2,0)),c=0,d=0,n.mode=16184;case 16184:if(1024&n.flags){for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.length=c,n.head&&(n.head.extra_len=c),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=Jt(n.check,k,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(p=n.length,p>a&&(p=a),p&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(s,s+p),I)),512&n.flags&&4&n.wrap&&(n.check=Jt(n.check,i,p,s)),a-=p,s+=p,n.length-=p),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break t;p=0;do{I=i[s+p++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I))}while(I&&p<a);if(512&n.flags&&4&n.wrap&&(n.check=Jt(n.check,i,p,s)),a-=p,s+=p,I)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===a)break t;p=0;do{I=i[s+p++],n.head&&I&&n.length<65536&&(n.head.comment+=String.fromCharCode(I))}while(I&&p<a);if(512&n.flags&&4&n.wrap&&(n.check=Jt(n.check,i,p,s)),a-=p,s+=p,I)break t}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(4&n.wrap&&c!==(65535&n.check)){t.msg="header crc mismatch",n.mode=Xn;break}c=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=qn;break;case 16189:for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}t.adler=n.check=Jn(c),c=0,d=0,n.mode=Gn;case Gn:if(0===n.havedict)return t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,Bn;t.adler=n.check=1,n.mode=qn;case qn:if(e===Ln||e===Fn)break t;case Hn:if(n.last){c>>>=7&d,d-=7&d,n.mode=Qn;break}for(;d<3;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}switch(n.last=1&c,c>>>=1,d-=1,3&c){case 0:n.mode=16193;break;case 1:if(ci(n),n.mode=$n,e===Fn){c>>>=2,d-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=Xn}c>>>=2,d-=2;break;case 16193:for(c>>>=7&d,d-=7&d;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",n.mode=Xn;break}if(n.length=65535&c,c=0,d=0,n.mode=Kn,e===Fn)break t;case Kn:n.mode=16195;case 16195:if(p=n.length,p){if(p>a&&(p=a),p>l&&(p=l),0===p)break t;r.set(i.subarray(s,s+p),o),a-=p,s+=p,l-=p,o+=p,n.length-=p;break}n.mode=qn;break;case 16196:for(;d<14;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(n.nlen=257+(31&c),c>>>=5,d-=5,n.ndist=1+(31&c),c>>>=5,d-=5,n.ncode=4+(15&c),c>>>=4,d-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=Xn;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;d<3;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.lens[E[n.have++]]=7&c,c>>>=3,d-=3}for(;n.have<19;)n.lens[E[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,x={bits:n.lenbits},_=zn(0,n.lens,0,19,n.lencode,0,n.work,x),n.lenbits=x.bits,_){t.msg="invalid code lengths set",n.mode=Xn;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;S=n.lencode[c&(1<<n.lenbits)-1],f=S>>>24,y=S>>>16&255,b=65535&S,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(b<16)c>>>=f,d-=f,n.lens[n.have++]=b;else{if(16===b){for(A=f+2;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(c>>>=f,d-=f,0===n.have){t.msg="invalid bit length repeat",n.mode=Xn;break}I=n.lens[n.have-1],p=3+(3&c),c>>>=2,d-=2}else if(17===b){for(A=f+3;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=f,d-=f,I=0,p=3+(7&c),c>>>=3,d-=3}else{for(A=f+7;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=f,d-=f,I=0,p=11+(127&c),c>>>=7,d-=7}if(n.have+p>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=Xn;break}for(;p--;)n.lens[n.have++]=I}}if(n.mode===Xn)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=Xn;break}if(n.lenbits=9,x={bits:n.lenbits},_=zn(1,n.lens,0,n.nlen,n.lencode,0,n.work,x),n.lenbits=x.bits,_){t.msg="invalid literal/lengths set",n.mode=Xn;break}if(n.distbits=6,n.distcode=n.distdyn,x={bits:n.distbits},_=zn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,x),n.distbits=x.bits,_){t.msg="invalid distances set",n.mode=Xn;break}if(n.mode=$n,e===Fn)break t;case $n:n.mode=Yn;case Yn:if(a>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,An(t,u),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,n.mode===qn&&(n.back=-1);break}for(n.back=0;S=n.lencode[c&(1<<n.lenbits)-1],f=S>>>24,y=S>>>16&255,b=65535&S,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(y&&!(240&y)){for(w=f,v=y,C=b;S=n.lencode[C+((c&(1<<w+v)-1)>>w)],f=S>>>24,y=S>>>16&255,b=65535&S,!(w+f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=w,d-=w,n.back+=w}if(c>>>=f,d-=f,n.back+=f,n.length=b,0===y){n.mode=16205;break}if(32&y){n.back=-1,n.mode=qn;break}if(64&y){t.msg="invalid literal/length code",n.mode=Xn;break}n.extra=15&y,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;S=n.distcode[c&(1<<n.distbits)-1],f=S>>>24,y=S>>>16&255,b=65535&S,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(!(240&y)){for(w=f,v=y,C=b;S=n.distcode[C+((c&(1<<w+v)-1)>>w)],f=S>>>24,y=S>>>16&255,b=65535&S,!(w+f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=w,d-=w,n.back+=w}if(c>>>=f,d-=f,n.back+=f,64&y){t.msg="invalid distance code",n.mode=Xn;break}n.offset=b,n.extra=15&y,n.mode=16203;case 16203:if(n.extra){for(A=n.extra;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=Xn;break}n.mode=16204;case 16204:if(0===l)break t;if(p=u-l,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=Xn;break}p>n.wnext?(p-=n.wnext,g=n.wsize-p):g=n.wnext-p,p>n.length&&(p=n.length),m=n.window}else m=r,g=o-n.offset,p=n.length;p>l&&(p=l),l-=p,n.length-=p;do{r[o++]=m[g++]}while(--p);0===n.length&&(n.mode=Yn);break;case 16205:if(0===l)break t;r[o++]=n.length,l--,n.mode=Yn;break;case Qn:if(n.wrap){for(;d<32;){if(0===a)break t;a--,c|=i[s++]<<d,d+=8}if(u-=l,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?Jt(n.check,r,u,o-u):Qt(n.check,r,u,o-u)),u=l,4&n.wrap&&(n.flags?c:Jn(c))!==n.check){t.msg="incorrect data check",n.mode=Xn;break}c=0,d=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(4&n.wrap&&c!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=Xn;break}c=0,d=0}n.mode=16208;case 16208:_=Nn;break t;case Xn:_=Zn;break t;case 16210:return Pn;default:return Un}return t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,(n.wsize||u!==t.avail_out&&n.mode<Xn&&(n.mode<Qn||e!==On))&&di(t,t.output,t.next_out,u-t.avail_out),h-=t.avail_in,u-=t.avail_out,t.total_in+=h,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?Jt(n.check,r,u,t.next_out-u):Qt(n.check,r,u,t.next_out-u)),t.data_type=n.bits+(n.last?64:0)+(n.mode===qn?128:0)+(n.mode===$n||n.mode===Kn?256:0),(0===h&&0===u||e===On)&&_===Dn&&(_=Wn),_},gi=t=>{if(ei(t))return Un;let e=t.state;return e.window&&(e.window=null),t.state=null,Dn},mi=(t,e)=>{if(ei(t))return Un;const n=t.state;return 2&n.wrap?(n.head=e,e.done=!1,Dn):Un},fi=(t,e)=>{const n=e.length;let i,r,s;return ei(t)?Un:(i=t.state,0!==i.wrap&&i.mode!==Gn?Un:i.mode===Gn&&(r=1,r=Qt(r,e,n,0),r!==i.check)?Zn:(s=di(t,e,n,n),s?(i.mode=16210,Pn):(i.havedict=1,Dn)))},yi=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const bi=Object.prototype.toString,{Z_NO_FLUSH:wi,Z_FINISH:vi,Z_OK:Ci,Z_STREAM_END:Ii,Z_NEED_DICT:_i,Z_STREAM_ERROR:Si,Z_DATA_ERROR:ki,Z_MEM_ERROR:xi}=ee;function Ai(t){this.options=sn({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new un,this.strm.avail_out=0;let n=ui(this.strm,e.windowBits);if(n!==Ci)throw new Error(te[n]);if(this.header=new yi,mi(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=cn(e.dictionary):"[object ArrayBuffer]"===bi.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=fi(this.strm,e.dictionary),n!==Ci)))throw new Error(te[n])}function Ei(t,e){const n=new Ai(e);if(n.push(t),n.err)throw n.msg||te[n.err];return n.result}Ai.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?vi:wi,"[object ArrayBuffer]"===bi.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),s=pi(n,o),s===_i&&r&&(s=fi(n,r),s===Ci?s=pi(n,o):s===ki&&(s=_i));n.avail_in>0&&s===Ii&&n.state.wrap>0&&0!==t[n.next_in];)hi(n),s=pi(n,o);switch(s){case Si:case ki:case _i:case xi:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===Ii))if("string"===this.options.to){let t=hn(n.output,n.next_out),e=n.next_out-t,r=dn(n.output,t);n.next_out=e,n.avail_out=i-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==Ci||0!==a){if(s===Ii)return s=gi(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Ai.prototype.onData=function(t){this.chunks.push(t)},Ai.prototype.onEnd=function(t){t===Ci&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=on(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ri={Inflate:Ai,inflate:Ei,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Ei(t,e)},ungzip:Ei,constants:ee};const{Deflate:Mi,deflate:Ti,deflateRaw:zi,gzip:Oi}=kn,{Inflate:Li,inflate:Fi,inflateRaw:Di,ungzip:Ni}=Ri;var Bi={Deflate:Mi,deflate:Ti,deflateRaw:zi,gzip:Oi,Inflate:Li,inflate:Fi,inflateRaw:Di,ungzip:Ni,constants:ee};const Ui=E();let Zi=null,Pi=null;function Wi(){return"undefined"!=typeof document&&"undefined"!=typeof Image&&"undefined"!=typeof HTMLCanvasElement}class ji extends yt{constructor(t={}){super(t)}getErrorPlaceholder(){var t;return null!==(t=this.options.errorPlaceholder)&&void 0!==t?t:"SCREENSHOT_FAILED"}shouldIncludeNode(t){if(!("hasAttribute"in t))return!0;const e=t,n=this.options.excludeAttribute||"data-bugspotter-exclude";return!e.hasAttribute(n)}buildCaptureOptions(){var t,e,n,i;return Object.assign(Object.assign(Object.assign({quality:null!==(t=this.options.quality)&&void 0!==t?t:.95,cacheBust:null===(e=this.options.cacheBust)||void 0===e||e,pixelRatio:null!==(n=this.options.pixelRatio)&&void 0!==n?n:window.devicePixelRatio,backgroundColor:null!==(i=this.options.backgroundColor)&&void 0!==i?i:"#ffffff"},this.options.width&&{width:this.options.width}),this.options.height&&{height:this.options.height}),{filter:t=>this.shouldIncludeNode(t)})}async capture(t){try{const e=t||this.options.targetElement||document.body,n=this.buildCaptureOptions(),i=await async function(t,e={}){return(await async function(t,e={}){const{width:n,height:i}=U(t,e),r=await mt(t,e),s=await P(r),o=document.createElement("canvas"),a=o.getContext("2d"),l=e.pixelRatio||function(){let t,e;try{e=process}catch(t){}const n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}(),c=e.canvasWidth||n,d=e.canvasHeight||i;return o.width=c*l,o.height=d*l,e.skipAutoScale||function(t){(t.width>Z||t.height>Z)&&(t.width>Z&&t.height>Z?t.width>t.height?(t.height*=Z/t.width,t.width=Z):(t.width*=Z/t.height,t.height=Z):t.width>Z?(t.height*=Z/t.width,t.width=Z):(t.width*=Z/t.height,t.height=Z))}(o),o.style.width=`${c}`,o.style.height=`${d}`,e.backgroundColor&&(a.fillStyle=e.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(s,0,0,o.width,o.height),o}(t,e)).toDataURL()}(e,n);return await async function(t,e){var n,i,r,s;try{if(!Wi())return t;const o=null!==(n=null==e?void 0:e.imageMaxWidth)&&void 0!==n?n:2560,a=null!==(i=null==e?void 0:e.imageMaxHeight)&&void 0!==i?i:1440,l=null!==(r=null==e?void 0:e.webpQuality)&&void 0!==r?r:.92,c=null!==(s=null==e?void 0:e.jpegQuality)&&void 0!==s?s:.92,d=3e3,h=await function(t,e){return new Promise((n,i)=>{const r=new Image,s=setTimeout(()=>{i(new Error(`Image load timeout after ${e}ms`))},e);r.onload=()=>{clearTimeout(s),n(r)},r.onerror=()=>{clearTimeout(s),i(new Error("Failed to load image"))},r.src=t})}(t,d),u=document.createElement("canvas"),p=u.getContext("2d");if(!p)throw new Error("Failed to get 2D canvas context");const{width:g,height:m}=function(t,e,n,i){let r=t,s=e;return r>n&&(s=s*n/r,r=n),s>i&&(r=r*i/s,s=i),{width:r,height:s}}(h.width,h.height,o,a);return u.width=g,u.height=m,p.imageSmoothingEnabled=!0,p.imageSmoothingQuality="high",p.drawImage(h,0,0,g,m),function(){if(null!==Pi)return Pi;if(!Wi())return Pi=!1,!1;try{const t=document.createElement("canvas");Pi=0===t.toDataURL("image/webp").indexOf("data:image/webp")}catch(t){Pi=!1}return Pi}()?u.toDataURL("image/webp",l):u.toDataURL("image/jpeg",c)}catch(n){return!1!==(null==e?void 0:e.verbose)&&E().error("Image compression failed:",n),t}}(i)}catch(t){return this.handleError("capturing screenshot",t),this.getErrorPlaceholder()}}}class Vi{constructor(t){if(this.maxSize=t,this.items=[],this.index=0,this.count=0,t<=0)throw new Error("CircularBuffer maxSize must be greater than 0")}add(t){this.count<this.maxSize?(this.items.push(t),this.count++):this.items[this.index]=t,this.index=(this.index+1)%this.maxSize}getAll(){return this.count<this.maxSize?[...this.items]:[...this.items.slice(this.index),...this.items.slice(0,this.index)]}clear(){this.items=[],this.index=0,this.count=0}get size(){return this.count}get capacity(){return this.maxSize}get isEmpty(){return 0===this.count}get isFull(){return this.count>=this.maxSize}}const Gi=["log","warn","error","info","debug"];class qi extends yt{constructor(t={}){var e,n,i;super(t),this.originalMethods=new Map;const r=null!==(e=t.maxLogs)&&void 0!==e?e:100;this.buffer=new Vi(r),this.captureStackTrace=null===(n=t.captureStackTrace)||void 0===n||n,this.interceptConsole(null!==(i=t.levels)&&void 0!==i?i:Gi)}capture(){return this.getLogs()}formatMessage(t){return t&&0!==t.length?(this.sanitizer?this.sanitizer.sanitizeConsoleArgs(t):t).map(t=>{var e;if(null===t)return"null";if(void 0===t)return"undefined";if("object"==typeof t)try{return JSON.stringify(t)}catch(n){return`[${(null===(e=t.constructor)||void 0===e?void 0:e.name)||"Object"}]`}return String(t)}).join(" "):""}createLogEntry(t,e,n){const i={level:t,message:null!=n?n:this.formatMessage(e),timestamp:Date.now()};if(this.captureStackTrace&&"error"===t){const t=this.captureStack();i.stack=this.sanitizer&&t?this.sanitizer.sanitize(t):t}return i}captureStack(){const t=(new Error).stack;return null==t?void 0:t.split("\n").slice(3).join("\n")}addLog(t){this.buffer.add(t)}shouldFilterLog(t,e){return"error"!==e&&t.startsWith("[BugSpotter]")}interceptConsole(t=Gi){t.forEach(t=>{try{const e=console[t];this.originalMethods.set(t,e),console[t]=(...n)=>{try{const e=this.formatMessage(n);if(!this.shouldFilterLog(e,t)){const i=this.createLogEntry(t,n,e);this.addLog(i)}}catch(t){this.handleError("creating log entry",t)}e.apply(console,n)}}catch(e){this.handleError(`intercepting console.${t}`,e)}})}getLogs(){return this.buffer.getAll()}clear(){this.buffer.clear()}destroy(){try{this.originalMethods.forEach((t,e)=>{console[e]=t}),this.originalMethods.clear()}catch(t){this.handleError("destroying console capture",t)}}}class Hi extends yt{constructor(t={}){var e;super(t),this.isIntercepting=!1;const n=null!==(e=t.maxRequests)&&void 0!==e?e:50;this.buffer=new Vi(n),this.filterUrls=t.filterUrls,this.originalFetch=window.fetch,this.originalXHR={open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send},this.interceptFetch(),this.interceptXHR(),this.isIntercepting=!0}capture(){return this.getRequests()}parseFetchArgs(t){const[e,n]=t;let i,r="GET";return"string"==typeof e?i=e:e instanceof Request?(i=e.url,r=e.method.toUpperCase()||"GET"):i=e.toString(),(null==n?void 0:n.method)&&(r=n.method.toUpperCase()),{url:i,method:r}}createNetworkRequest(t,e,n,i,r){const s=Object.assign({url:t,method:e,status:n,duration:Date.now()-i,timestamp:i},r&&{error:r});if(this.sanitizer){const t=this.sanitizer.sanitizeNetworkData(Object.assign({url:s.url,method:s.method,status:s.status},s.error&&{error:s.error}));return Object.assign(Object.assign({},s),{url:t.url||s.url,error:t.error})}return s}addRequest(t){this.filterUrls&&!this.filterUrls(t.url)||this.buffer.add(t)}interceptFetch(){const t=this.originalFetch;window.fetch=async(...e)=>{const n=Date.now();let i="",r="GET";try{({url:i,method:r}=this.parseFetchArgs(e))}catch(t){this.handleError("parsing fetch arguments",t)}try{const s=await t(...e);if(s&&"number"==typeof s.status){const t=this.createNetworkRequest(i,r,s.status,n);this.addRequest(t)}return s}catch(t){const e=this.createNetworkRequest(i,r,0,n,t.message);throw this.addRequest(e),t}}}interceptXHR(){const t=this.originalXHR.open,e=this.originalXHR.send,n=this.createNetworkRequest.bind(this),i=this.addRequest.bind(this);XMLHttpRequest.prototype.open=function(e,n,...i){return this._method=e.toUpperCase(),this._url=n.toString(),this._startTime=Date.now(),t.apply(this,[e,n,...i])},XMLHttpRequest.prototype.send=function(...t){return this.addEventListener("load",()=>{const t=n(this._url||"",this._method||"GET",this.status,this._startTime||Date.now());i(t)}),this.addEventListener("error",()=>{const t=n(this._url||"",this._method||"GET",0,this._startTime||Date.now(),"XMLHttpRequest failed");i(t)}),e.apply(this,t)}}getRequests(){return this.buffer.getAll()}clear(){this.buffer.clear()}destroy(){if(this.isIntercepting)try{window.fetch=this.originalFetch,XMLHttpRequest.prototype.open=this.originalXHR.open,XMLHttpRequest.prototype.send=this.originalXHR.send,this.isIntercepting=!1}catch(t){this.handleError("destroying network capture",t)}}}class Ki extends yt{constructor(t={}){super(t),this.browserPatterns=[{pattern:"Edg",name:"Edge"},{pattern:"Chrome",exclude:"Edge",name:"Chrome"},{pattern:"Firefox",name:"Firefox"},{pattern:"Safari",exclude:"Chrome",name:"Safari"}],this.osPatterns=[{patterns:["iPhone","iPad"],name:"iOS"},{patterns:["Android"],name:"Android"},{patterns:["Win"],name:"Windows"},{patterns:["Mac"],name:"macOS"},{patterns:["Linux"],name:"Linux"}]}capture(){try{const t={userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},browser:this.detectBrowser(),os:this.detectOS(),url:window.location.href,timestamp:Date.now()};return this.sanitizer&&(t.url=this.sanitizer.sanitize(t.url),t.userAgent=this.sanitizer.sanitize(t.userAgent)),t}catch(t){return this.handleError("capturing metadata",t),{userAgent:"Unknown",viewport:{width:0,height:0},browser:"Unknown",os:"Unknown",url:"Unknown",timestamp:Date.now()}}}detectBrowser(){const t=navigator.userAgent;for(const{pattern:e,exclude:n,name:i}of this.browserPatterns)if(t.includes(e)&&(!n||!t.includes(n)))return i;return"Unknown"}detectOS(){const t=navigator.userAgent;for(const{patterns:e,name:n}of this.osPatterns)if(e.some(e=>t.includes(e)))return n;return"Unknown"}}var $i;function Yi(t){var e=null==t?void 0:t.host;return Boolean((null==e?void 0:e.shadowRoot)===t)}function Qi(t){return"[object ShadowRoot]"===Object.prototype.toString.call(t)}function Xi(t){try{var e=t.rules||t.cssRules;return e?((n=Array.from(e).map(Ji).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(t){return null}var n}function Ji(t){var e=t.cssText;if(function(t){return"styleSheet"in t}(t))try{e=Xi(t.styleSheet)||e}catch(t){}return e}!function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"}($i||($i={}));var tr=function(){function t(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return t.prototype.getId=function(t){var e;if(!t)return-1;var n=null===(e=this.getMeta(t))||void 0===e?void 0:e.id;return null!=n?n:-1},t.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},t.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},t.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},t.prototype.removeNodeFromMap=function(t){var e=this,n=this.getId(t);this.idNodeMap.delete(n),t.childNodes&&t.childNodes.forEach(function(t){return e.removeNodeFromMap(t)})},t.prototype.has=function(t){return this.idNodeMap.has(t)},t.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},t.prototype.add=function(t,e){var n=e.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,e)},t.prototype.replace=function(t,e){var n=this.getNode(t);if(n){var i=this.nodeMetaMap.get(n);i&&this.nodeMetaMap.set(e,i)}this.idNodeMap.set(t,e)},t.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},t}();function er(t){var e=t.maskInputOptions,n=t.tagName,i=t.type,r=t.value,s=t.maskInputFn,o=r||"";return(e[n.toLowerCase()]||e[i])&&(o=s?s(o):"*".repeat(o.length)),o}var nr,ir,rr="__rrweb_original__",sr=1,or=new RegExp("[^a-z0-9-_:]");function ar(){return sr++}var lr=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,cr=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,dr=/^(data:)([^,]*),(.*)/i;function hr(t,e){return(t||"").replace(lr,function(t,n,i,r,s,o){var a,l=i||s||o,c=n||r||"";if(!l)return t;if(!cr.test(l))return"url(".concat(c).concat(l).concat(c,")");if(dr.test(l))return"url(".concat(c).concat(l).concat(c,")");if("/"===l[0])return"url(".concat(c).concat((a=e,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+l)).concat(c,")");var d=e.split("/"),h=l.split("/");d.pop();for(var u=0,p=h;u<p.length;u++){var g=p[u];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(c).concat(d.join("/")).concat(c,")")})}var ur=/^[^ \t\n\r\u000c]+/,pr=/^[, \t\n\r\u000c]+/;function gr(t,e){if(!e||""===e.trim())return e;var n=t.createElement("a");return n.href=e,n.href}function mr(){var t=document.createElement("a");return t.href="",t.href}function fr(t,e,n,i){return"src"===n||"href"===n&&i&&("use"!==e||"#"!==i[0])||"xlink:href"===n&&i&&"#"!==i[0]?gr(t,i):"background"!==n||!i||"table"!==e&&"td"!==e&&"th"!==e?"srcset"===n&&i?function(t,e){if(""===e.trim())return e;var n=0;function i(t){var i,r=t.exec(e.substring(n));return r?(i=r[0],n+=i.length,i):""}for(var r=[];i(pr),!(n>=e.length);){var s=i(ur);if(","===s.slice(-1))s=gr(t,s.substring(0,s.length-1)),r.push(s);else{var o="";s=gr(t,s);for(var a=!1;;){var l=e.charAt(n);if(""===l){r.push((s+o).trim());break}if(a)")"===l&&(a=!1);else{if(","===l){n+=1,r.push((s+o).trim());break}"("===l&&(a=!0)}o+=l,n+=1}}}return r.join(", ")}(t,i):"style"===n&&i?hr(i,mr()):"object"===e&&"data"===n&&i?gr(t,i):i:gr(t,i)}function yr(t,e,n){if(!t)return!1;if(t.nodeType!==t.ELEMENT_NODE)return!!n&&yr(t.parentNode,e,n);for(var i=t.classList.length;i--;){var r=t.classList[i];if(e.test(r))return!0}return!!n&&yr(t.parentNode,e,n)}function br(t,e,n){var i=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(null===i)return!1;if("string"==typeof e){if(i.classList.contains(e))return!0;if(i.closest(".".concat(e)))return!0}else if(yr(i,e,!0))return!0;if(n){if(i.matches(n))return!0;if(i.closest(n))return!0}return!1}function wr(t){return void 0===t?"":t.toLowerCase()}function vr(t,e){var n,i=e.doc,r=e.mirror,s=e.blockClass,o=e.blockSelector,a=e.maskTextClass,l=e.maskTextSelector,c=e.skipChild,d=void 0!==c&&c,h=e.inlineStylesheet,u=void 0===h||h,p=e.maskInputOptions,g=void 0===p?{}:p,m=e.maskTextFn,f=e.maskInputFn,y=e.slimDOMOptions,b=e.dataURLOptions,w=void 0===b?{}:b,v=e.inlineImages,C=void 0!==v&&v,I=e.recordCanvas,_=void 0!==I&&I,S=e.onSerialize,k=e.onIframeLoad,x=e.iframeLoadTimeout,A=void 0===x?5e3:x,E=e.onStylesheetLoad,R=e.stylesheetLoadTimeout,M=void 0===R?5e3:R,T=e.keepIframeSrcFn,z=void 0===T?function(){return!1}:T,O=e.newlyAddedElement,L=void 0!==O&&O,F=e.preserveWhiteSpace,D=void 0===F||F,N=function(t,e){var n=e.doc,i=e.mirror,r=e.blockClass,s=e.blockSelector,o=e.maskTextClass,a=e.maskTextSelector,l=e.inlineStylesheet,c=e.maskInputOptions,d=void 0===c?{}:c,h=e.maskTextFn,u=e.maskInputFn,p=e.dataURLOptions,g=void 0===p?{}:p,m=e.inlineImages,f=e.recordCanvas,y=e.keepIframeSrcFn,b=e.newlyAddedElement,w=void 0!==b&&b,v=function(t,e){if(e.hasNode(t)){var n=e.getId(t);return 1===n?void 0:n}}(n,i);switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:$i.Document,childNodes:[],compatMode:t.compatMode}:{type:$i.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:$i.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:v};case t.ELEMENT_NODE:return function(t,e){for(var n=e.doc,i=e.inlineStylesheet,r=e.maskInputOptions,s=void 0===r?{}:r,o=e.maskInputFn,a=e.dataURLOptions,l=void 0===a?{}:a,c=e.inlineImages,d=e.recordCanvas,h=e.keepIframeSrcFn,u=e.newlyAddedElement,p=void 0!==u&&u,g=e.rootId,m=function(t,e,n){if("string"==typeof e){if(t.classList.contains(e))return!0}else for(var i=t.classList.length;i--;){var r=t.classList[i];if(e.test(r))return!0}return!!n&&t.matches(n)}(t,e.blockClass,e.blockSelector),f=function(t){if(t instanceof HTMLFormElement)return"form";var e=t.tagName.toLowerCase().trim();return or.test(e)?"div":e}(t),y={},b=t.attributes.length,w=0;w<b;w++){var v=t.attributes[w];y[v.name]=fr(n,f,v.name,v.value)}if("link"===f&&i){var C=Array.from(n.styleSheets).find(function(e){return e.href===t.href}),I=null;C&&(I=Xi(C)),I&&(delete y.rel,delete y.href,y._cssText=hr(I,C.href))}if("style"===f&&t.sheet&&!(t.innerText||t.textContent||"").trim().length&&(I=Xi(t.sheet))&&(y._cssText=hr(I,mr())),"input"===f||"textarea"===f||"select"===f){var _=t.value,S=t.checked;"radio"!==y.type&&"checkbox"!==y.type&&"submit"!==y.type&&"button"!==y.type&&_?y.value=er({type:y.type,tagName:f,value:_,maskInputOptions:s,maskInputFn:o}):S&&(y.checked=S)}if("option"===f&&(t.selected&&!s.select?y.selected=!0:delete y.selected),"canvas"===f&&d)if("2d"===t.__context)(function(t){var e=t.getContext("2d");if(!e)return!0;for(var n=0;n<t.width;n+=50)for(var i=0;i<t.height;i+=50){var r=e.getImageData,s=rr in r?r[rr]:r;if(new Uint32Array(s.call(e,n,i,Math.min(50,t.width-n),Math.min(50,t.height-i)).data.buffer).some(function(t){return 0!==t}))return!1}return!0})(t)||(y.rr_dataURL=t.toDataURL(l.type,l.quality));else if(!("__context"in t)){var k=t.toDataURL(l.type,l.quality),x=document.createElement("canvas");x.width=t.width,x.height=t.height,k!==x.toDataURL(l.type,l.quality)&&(y.rr_dataURL=k)}if("img"===f&&c){nr||(nr=n.createElement("canvas"),ir=nr.getContext("2d"));var A=t,E=A.crossOrigin;A.crossOrigin="anonymous";var R=function(){try{nr.width=A.naturalWidth,nr.height=A.naturalHeight,ir.drawImage(A,0,0),y.rr_dataURL=nr.toDataURL(l.type,l.quality)}catch(t){console.warn("Cannot inline img src=".concat(A.currentSrc,"! Error: ").concat(t))}E?y.crossOrigin=E:A.removeAttribute("crossorigin")};A.complete&&0!==A.naturalWidth?R():A.onload=R}if("audio"!==f&&"video"!==f||(y.rr_mediaState=t.paused?"paused":"played",y.rr_mediaCurrentTime=t.currentTime),p||(t.scrollLeft&&(y.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(y.rr_scrollTop=t.scrollTop)),m){var M=t.getBoundingClientRect(),T=M.width,z=M.height;y={class:y.class,rr_width:"".concat(T,"px"),rr_height:"".concat(z,"px")}}return"iframe"!==f||h(y.src)||(t.contentDocument||(y.rr_src=y.src),delete y.src),{type:$i.Element,tagName:f,attributes:y,childNodes:[],isSVG:(O=t,Boolean("svg"===O.tagName||O.ownerSVGElement)||void 0),needBlock:m,rootId:g};var O}(t,{doc:n,blockClass:r,blockSelector:s,inlineStylesheet:l,maskInputOptions:d,maskInputFn:u,dataURLOptions:g,inlineImages:m,recordCanvas:f,keepIframeSrcFn:y,newlyAddedElement:w,rootId:v});case t.TEXT_NODE:return function(t,e){var n,i,r=e.maskTextClass,s=e.maskTextSelector,o=e.maskTextFn,a=e.rootId,l=t.parentNode&&t.parentNode.tagName,c=t.textContent,d="STYLE"===l||void 0,h="SCRIPT"===l||void 0;if(d&&c){try{t.nextSibling||t.previousSibling||(null===(n=t.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(i=t.parentNode.sheet).cssRules?Array.from(i.cssRules).map(function(t){return t.cssText||""}).join(""):"")}catch(e){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(e),t)}c=hr(c,mr())}return h&&(c="SCRIPT_PLACEHOLDER"),!d&&!h&&c&&br(t,r,s)&&(c=o?o(c):c.replace(/[\S]/g,"*")),{type:$i.Text,textContent:c||"",isStyle:d,rootId:a}}(t,{maskTextClass:o,maskTextSelector:a,maskTextFn:h,rootId:v});case t.CDATA_SECTION_NODE:return{type:$i.CDATA,textContent:"",rootId:v};case t.COMMENT_NODE:return{type:$i.Comment,textContent:t.textContent||"",rootId:v};default:return!1}}(t,{doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,dataURLOptions:w,inlineImages:C,recordCanvas:_,keepIframeSrcFn:z,newlyAddedElement:L});if(!N)return console.warn(t,"not serialized"),null;n=r.hasNode(t)?r.getId(t):!function(t,e){if(e.comment&&t.type===$i.Comment)return!0;if(t.type===$i.Element){if(e.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(e.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(wr(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===wr(t.attributes.name)||"icon"===wr(t.attributes.rel)||"apple-touch-icon"===wr(t.attributes.rel)||"shortcut icon"===wr(t.attributes.rel))))return!0;if("meta"===t.tagName){if(e.headMetaDescKeywords&&wr(t.attributes.name).match(/^description|keywords$/))return!0;if(e.headMetaSocial&&(wr(t.attributes.property).match(/^(og|twitter|fb):/)||wr(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===wr(t.attributes.name)))return!0;if(e.headMetaRobots&&("robots"===wr(t.attributes.name)||"googlebot"===wr(t.attributes.name)||"bingbot"===wr(t.attributes.name)))return!0;if(e.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(e.headMetaAuthorship&&("author"===wr(t.attributes.name)||"generator"===wr(t.attributes.name)||"framework"===wr(t.attributes.name)||"publisher"===wr(t.attributes.name)||"progid"===wr(t.attributes.name)||wr(t.attributes.property).match(/^article:/)||wr(t.attributes.property).match(/^product:/)))return!0;if(e.headMetaVerification&&("google-site-verification"===wr(t.attributes.name)||"yandex-verification"===wr(t.attributes.name)||"csrf-token"===wr(t.attributes.name)||"p:domain_verify"===wr(t.attributes.name)||"verify-v1"===wr(t.attributes.name)||"verification"===wr(t.attributes.name)||"shopify-checkout-api-token"===wr(t.attributes.name)))return!0}}return!1}(N,y)&&(D||N.type!==$i.Text||N.isStyle||N.textContent.replace(/^\s+|\s+$/gm,"").length)?ar():-2;var B=Object.assign(N,{id:n});if(r.add(t,B),-2===n)return null;S&&S(t);var U=!d;if(B.type===$i.Element){U=U&&!B.needBlock,delete B.needBlock;var Z=t.shadowRoot;Z&&Qi(Z)&&(B.isShadowHost=!0)}if((B.type===$i.Document||B.type===$i.Element)&&U){y.headWhitespace&&B.type===$i.Element&&"head"===B.tagName&&(D=!1);for(var P={doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:d,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:C,recordCanvas:_,preserveWhiteSpace:D,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:z},W=0,j=Array.from(t.childNodes);W<j.length;W++)(q=vr(j[W],P))&&B.childNodes.push(q);if(function(t){return t.nodeType===t.ELEMENT_NODE}(t)&&t.shadowRoot)for(var V=0,G=Array.from(t.shadowRoot.childNodes);V<G.length;V++){var q;(q=vr(G[V],P))&&(Qi(t.shadowRoot)&&(q.isShadow=!0),B.childNodes.push(q))}}return t.parentNode&&Yi(t.parentNode)&&Qi(t.parentNode)&&(B.isShadow=!0),B.type===$i.Element&&"iframe"===B.tagName&&function(t,e,n){var i=t.contentWindow;if(i){var r,s=!1;try{r=i.document.readyState}catch(t){return}if("complete"===r){var o="about:blank";if(i.location.href!==o||t.src===o||""===t.src)return setTimeout(e,0),t.addEventListener("load",e);t.addEventListener("load",e)}else{var a=setTimeout(function(){s||(e(),s=!0)},n);t.addEventListener("load",function(){clearTimeout(a),s=!0,e()})}}}(t,function(){var e=t.contentDocument;if(e&&k){var n=vr(e,{doc:e,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:C,recordCanvas:_,preserveWhiteSpace:D,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:z});n&&k(t,n)}},A),B.type===$i.Element&&"link"===B.tagName&&"stylesheet"===B.attributes.rel&&function(t,e,n){var i,r=!1;try{i=t.sheet}catch(t){return}if(!i){var s=setTimeout(function(){r||(e(),r=!0)},n);t.addEventListener("load",function(){clearTimeout(s),r=!0,e()})}}(t,function(){if(E){var e=vr(t,{doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:C,recordCanvas:_,preserveWhiteSpace:D,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:z});e&&E(t,e)}},M),B}function Cr(t,e,n=document){const i={capture:!0,passive:!0};return n.addEventListener(t,e,i),()=>n.removeEventListener(t,e,i)}new RegExp(/([^\\]):hover/.source,"g");const Ir="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let _r={map:{},getId:()=>(console.error(Ir),-1),getNode:()=>(console.error(Ir),null),removeNodeFromMap(){console.error(Ir)},has:()=>(console.error(Ir),!1),reset(){console.error(Ir)}};function Sr(t,e,n={}){let i=null,r=0;return function(...s){const o=Date.now();r||!1!==n.leading||(r=o);const a=e-(o-r),l=this;a<=0||a>e?(i&&(clearTimeout(i),i=null),r=o,t.apply(l,s)):i||!1===n.trailing||(i=setTimeout(()=>{r=!1===n.leading?0:Date.now(),i=null,t.apply(l,s)},a))}}function kr(t,e,n,i,r=window){const s=r.Object.getOwnPropertyDescriptor(t,e);return r.Object.defineProperty(t,e,i?n:{set(t){setTimeout(()=>{n.set.call(this,t)},0),s&&s.set&&s.set.call(this,t)}}),()=>kr(t,e,s||{},!0)}function xr(t,e,n){try{if(!(e in t))return()=>{};const i=t[e],r=n(i);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:i}})),t[e]=r,()=>{t[e]=i}}catch(t){return()=>{}}}function Ar(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Er(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Rr(t,e,n,i){if(!t)return!1;const r=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(!r)return!1;if("string"==typeof e){if(r.classList.contains(e))return!0;if(i&&null!==r.closest("."+e))return!0}else if(yr(r,e,i))return!0;if(n){if(t.matches(n))return!0;if(i&&null!==r.closest(n))return!0}return!1}function Mr(t,e){return-2===e.getId(t)}function Tr(t,e){if(Yi(t))return!1;const n=e.getId(t);return!e.has(n)||(!t.parentNode||t.parentNode.nodeType!==t.DOCUMENT_NODE)&&(!t.parentNode||Tr(t.parentNode,e))}function zr(t){return Boolean(t.changedTouches)}function Or(t,e){return Boolean("IFRAME"===t.nodeName&&e.getMeta(t))}function Lr(t,e){return Boolean("LINK"===t.nodeName&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&"stylesheet"===t.getAttribute("rel")&&e.getMeta(t))}function Fr(t){return Boolean(null==t?void 0:t.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(_r=new Proxy(_r,{get:(t,e,n)=>("map"===e&&console.error(Ir),Reflect.get(t,e,n))}));class Dr{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var e;return null!==(e=this.styleIDMap.get(t))&&void 0!==e?e:-1}has(t){return this.styleIDMap.has(t)}add(t,e){if(this.has(t))return this.getId(t);let n;return n=void 0===e?this.id++:e,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var Nr=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Nr||{}),Br=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t))(Br||{}),Ur=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(Ur||{}),Zr=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(Zr||{});function Pr(t){return"__ln"in t}class Wr{constructor(){this.length=0,this.head=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let e=this.head;for(let n=0;n<t;n++)e=(null==e?void 0:e.next)||null;return e}addNode(t){const e={value:t,previous:null,next:null};if(t.__ln=e,t.previousSibling&&Pr(t.previousSibling)){const n=t.previousSibling.__ln.next;e.next=n,e.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=e,n&&(n.previous=e)}else if(t.nextSibling&&Pr(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;e.previous=n,e.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=e,n&&(n.next=e)}else this.head&&(this.head.previous=e),e.next=this.head,this.head=e;this.length++}removeNode(t){const e=t.__ln;this.head&&(e.previous?(e.previous.next=e.next,e.next&&(e.next.previous=e.previous)):(this.head=e.next,this.head&&(this.head.previous=null)),t.__ln&&delete t.__ln,this.length--)}}const jr=(t,e)=>`${t}@${e}`;class Vr{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],e=new Wr,n=t=>{let e=t,n=-2;for(;-2===n;)e=e&&e.nextSibling,n=e&&this.mirror.getId(e);return n},i=i=>{var r,s,o,a;let l=null;(null===(s=null===(r=i.getRootNode)||void 0===r?void 0:r.call(i))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&i.getRootNode().host&&(l=i.getRootNode().host);let c=l;for(;(null===(a=null===(o=null==c?void 0:c.getRootNode)||void 0===o?void 0:o.call(c))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&c.getRootNode().host;)c=c.getRootNode().host;const d=!(this.doc.contains(i)||c&&this.doc.contains(c));if(!i.parentNode||d)return;const h=Yi(i.parentNode)?this.mirror.getId(l):this.mirror.getId(i.parentNode),u=n(i);if(-1===h||-1===u)return e.addNode(i);const p=vr(i,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:t=>{Or(t,this.mirror)&&this.iframeManager.addIframe(t),Lr(t,this.mirror)&&this.stylesheetManager.trackLinkElement(t),Fr(i)&&this.shadowDomManager.addShadowRoot(i.shadowRoot,this.doc)},onIframeLoad:(t,e)=>{this.iframeManager.attachIframe(t,e),this.shadowDomManager.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{this.stylesheetManager.attachLinkElement(t,e)}});p&&t.push({parentId:h,nextId:u,node:p})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const t of Array.from(this.movedSet.values()))qr(this.removes,t,this.mirror)&&!this.movedSet.has(t.parentNode)||i(t);for(const t of Array.from(this.addedSet.values()))Kr(this.droppedSet,t)||qr(this.removes,t,this.mirror)?Kr(this.movedSet,t)?i(t):this.droppedSet.add(t):i(t);let r=null;for(;e.length;){let t=null;if(r){const e=this.mirror.getId(r.value.parentNode),i=n(r.value);-1!==e&&-1!==i&&(t=r)}if(!t)for(let i=e.length-1;i>=0;i--){const r=e.get(i);if(r){const e=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==e){t=r;break}{const e=r.value;if(e.parentNode&&e.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=e.parentNode.host;if(-1!==this.mirror.getId(n)){t=r;break}}}}}if(!t){for(;e.head;)e.removeNode(e.head.value);break}r=t.previous,e.removeNode(t.value),i(t.value)}const s={texts:this.texts.map(t=>({id:this.mirror.getId(t.node),value:t.value})).filter(t=>this.mirror.has(t.id)),attributes:this.attributes.map(t=>({id:this.mirror.getId(t.node),attributes:t.attributes})).filter(t=>this.mirror.has(t.id)),removes:this.removes,adds:t};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=t=>{if(!Mr(t.target,this.mirror))switch(t.type){case"characterData":{const e=t.target.textContent;Rr(t.target,this.blockClass,this.blockSelector,!1)||e===t.oldValue||this.texts.push({value:br(t.target,this.maskTextClass,this.maskTextSelector)&&e?this.maskTextFn?this.maskTextFn(e):e.replace(/[\S]/g,"*"):e,node:t.target});break}case"attributes":{const e=t.target;let n=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(n=er({maskInputOptions:this.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),Rr(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let i=this.attributes.find(e=>e.node===t.target);if("IFRAME"===e.tagName&&"src"===t.attributeName&&!this.keepIframeSrcFn(n)){if(e.contentDocument)return;t.attributeName="rr_src"}if(i||(i={node:t.target,attributes:{}},this.attributes.push(i)),"style"===t.attributeName){const n=this.doc.createElement("span");t.oldValue&&n.setAttribute("style",t.oldValue),void 0!==i.attributes.style&&null!==i.attributes.style||(i.attributes.style={});const r=i.attributes.style;for(const t of Array.from(e.style)){const i=e.style.getPropertyValue(t),s=e.style.getPropertyPriority(t);i===n.style.getPropertyValue(t)&&s===n.style.getPropertyPriority(t)||(r[t]=""===s?i:[i,s])}for(const t of Array.from(n.style))""===e.style.getPropertyValue(t)&&(r[t]=!1)}else i.attributes[t.attributeName]=fr(this.doc,e.tagName,t.attributeName,n);break}case"childList":if(Rr(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(e=>this.genAdds(e,t.target)),t.removedNodes.forEach(e=>{const n=this.mirror.getId(e),i=Yi(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);Rr(t.target,this.blockClass,this.blockSelector,!1)||Mr(e,this.mirror)||!function(t,e){return-1!==e.getId(t)}(e,this.mirror)||(this.addedSet.has(e)?(Gr(this.addedSet,e),this.droppedSet.add(e)):this.addedSet.has(t.target)&&-1===n||Tr(t.target,this.mirror)||(this.movedSet.has(e)&&this.movedMap[jr(n,i)]?Gr(this.movedSet,e):this.removes.push({parentId:i,id:n,isShadow:!(!Yi(t.target)||!Qi(t.target))||void 0})),this.mapRemoves.push(e))})}},this.genAdds=(t,e)=>{if(this.mirror.hasNode(t)){if(Mr(t,this.mirror))return;this.movedSet.add(t);let n=null;e&&this.mirror.hasNode(e)&&(n=this.mirror.getId(e)),n&&-1!==n&&(this.movedMap[jr(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);Rr(t,this.blockClass,this.blockSelector,!1)||t.childNodes.forEach(t=>this.genAdds(t))}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(e=>{this[e]=t[e]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function Gr(t,e){t.delete(e),e.childNodes.forEach(e=>Gr(t,e))}function qr(t,e,n){return 0!==t.length&&Hr(t,e,n)}function Hr(t,e,n){const{parentNode:i}=e;if(!i)return!1;const r=n.getId(i);return!!t.some(t=>t.id===r)||Hr(t,i,n)}function Kr(t,e){return 0!==t.size&&$r(t,e)}function $r(t,e){const{parentNode:n}=e;return!!n&&(!!t.has(n)||$r(t,n))}const Yr=[],Qr="undefined"!=typeof CSSGroupingRule,Xr="undefined"!=typeof CSSMediaRule,Jr="undefined"!=typeof CSSSupportsRule,ts="undefined"!=typeof CSSConditionRule;function es(t){try{if("composedPath"in t){const e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0];return t.target}catch(e){return t.target}}function ns(t,e){var n,i;const r=new Vr;Yr.push(r),r.init(t);let s=window.MutationObserver||window.__rrMutationObserver;const o=null===(i=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===i?void 0:i.call(n,"MutationObserver");o&&window[o]&&(s=window[o]);const a=new s(r.processMutations.bind(r));return a.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function is({scrollCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,sampling:s}){return Cr("scroll",Sr(s=>{const o=es(s);if(!o||Rr(o,i,r,!0))return;const a=n.getId(o);if(o===e){const n=e.scrollingElement||e.documentElement;t({id:a,x:n.scrollLeft,y:n.scrollTop})}else t({id:a,x:o.scrollLeft,y:o.scrollTop})},s.scroll||100),e)}function rs(t,e){const n=Object.assign({},t);return e||delete n.userTriggered,n}const ss=["INPUT","TEXTAREA","SELECT"],os=new WeakMap;function as(t){return function(t,e){if(Qr&&t.parentRule instanceof CSSGroupingRule||Xr&&t.parentRule instanceof CSSMediaRule||Jr&&t.parentRule instanceof CSSSupportsRule||ts&&t.parentRule instanceof CSSConditionRule){const n=Array.from(t.parentRule.cssRules).indexOf(t);e.unshift(n)}else if(t.parentStyleSheet){const n=Array.from(t.parentStyleSheet.cssRules).indexOf(t);e.unshift(n)}return e}(t,[])}function ls(t,e,n){let i,r;return t?(t.ownerNode?i=e.getId(t.ownerNode):r=n.getId(t),{styleId:r,id:i}):{}}function cs({mirror:t,stylesheetManager:e},n){var i,r,s;let o=null;o="#document"===n.nodeName?t.getId(n):t.getId(n.host);const a="#document"===n.nodeName?null===(i=n.defaultView)||void 0===i?void 0:i.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===s?void 0:s.ShadowRoot,l=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==o&&-1!==o&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var t;return null===(t=l.get)||void 0===t?void 0:t.call(this)},set(t){var n;const i=null===(n=l.set)||void 0===n?void 0:n.call(this,t);if(null!==o&&-1!==o)try{e.adoptStyleSheets(t,o)}catch(t){}return i}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})}):()=>{}}function ds(t,e={}){const n=t.doc.defaultView;if(!n)return()=>{};!function(t,e){const{mutationCb:n,mousemoveCb:i,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:h,fontCb:u,selectionCb:p}=t;t.mutationCb=(...t)=>{e.mutation&&e.mutation(...t),n(...t)},t.mousemoveCb=(...t)=>{e.mousemove&&e.mousemove(...t),i(...t)},t.mouseInteractionCb=(...t)=>{e.mouseInteraction&&e.mouseInteraction(...t),r(...t)},t.scrollCb=(...t)=>{e.scroll&&e.scroll(...t),s(...t)},t.viewportResizeCb=(...t)=>{e.viewportResize&&e.viewportResize(...t),o(...t)},t.inputCb=(...t)=>{e.input&&e.input(...t),a(...t)},t.mediaInteractionCb=(...t)=>{e.mediaInteaction&&e.mediaInteaction(...t),l(...t)},t.styleSheetRuleCb=(...t)=>{e.styleSheetRule&&e.styleSheetRule(...t),c(...t)},t.styleDeclarationCb=(...t)=>{e.styleDeclaration&&e.styleDeclaration(...t),d(...t)},t.canvasMutationCb=(...t)=>{e.canvasMutation&&e.canvasMutation(...t),h(...t)},t.fontCb=(...t)=>{e.font&&e.font(...t),u(...t)},t.selectionCb=(...t)=>{e.selection&&e.selection(...t),p(...t)}}(t,e);const i=ns(t,t.doc),r=function({mousemoveCb:t,sampling:e,doc:n,mirror:i}){if(!1===e.mousemove)return()=>{};const r="number"==typeof e.mousemove?e.mousemove:50,s="number"==typeof e.mousemoveCallback?e.mousemoveCallback:500;let o,a=[];const l=Sr(e=>{const n=Date.now()-o;t(a.map(t=>(t.timeOffset-=n,t)),e),a=[],o=null},s),c=Sr(t=>{const e=es(t),{clientX:n,clientY:r}=zr(t)?t.changedTouches[0]:t;o||(o=Date.now()),a.push({x:n,y:r,id:i.getId(e),timeOffset:Date.now()-o}),l("undefined"!=typeof DragEvent&&t instanceof DragEvent?Br.Drag:t instanceof MouseEvent?Br.MouseMove:Br.TouchMove)},r,{trailing:!1}),d=[Cr("mousemove",c,n),Cr("touchmove",c,n),Cr("drag",c,n)];return()=>{d.forEach(t=>t())}}(t),s=function({mouseInteractionCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const o=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(Ur).filter(t=>Number.isNaN(Number(t))&&!t.endsWith("_Departed")&&!1!==o[t]).forEach(s=>{const o=s.toLowerCase(),l=(e=>s=>{const o=es(s);if(Rr(o,i,r,!0))return;const a=zr(s)?s.changedTouches[0]:s;if(!a)return;const l=n.getId(o),{clientX:c,clientY:d}=a;t({type:Ur[e],id:l,x:c,y:d})})(s);a.push(Cr(o,l,e))}),()=>{a.forEach(t=>t())}}(t),o=is(t),a=function({viewportResizeCb:t}){let e=-1,n=-1;return Cr("resize",Sr(()=>{const i=Ar(),r=Er();e===i&&n===r||(t({width:Number(r),height:Number(i)}),e=i,n=r)},200),window)}(t),l=function({inputCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,ignoreClass:s,maskInputOptions:o,maskInputFn:a,sampling:l,userTriggeredOnInput:c}){function d(t){let n=es(t);const l=t.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||ss.indexOf(n.tagName)<0||Rr(n,i,r,!0))return;const d=n.type;if(n.classList.contains(s))return;let u=n.value,p=!1;"radio"===d||"checkbox"===d?p=n.checked:(o[n.tagName.toLowerCase()]||o[d])&&(u=er({maskInputOptions:o,tagName:n.tagName,type:d,value:u,maskInputFn:a})),h(n,rs({text:u,isChecked:p,userTriggered:l},c));const g=n.name;"radio"===d&&g&&p&&e.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(t=>{t!==n&&h(t,rs({text:t.value,isChecked:!p,userTriggered:!1},c))})}function h(e,i){const r=os.get(e);if(!r||r.text!==i.text||r.isChecked!==i.isChecked){os.set(e,i);const r=n.getId(e);t(Object.assign(Object.assign({},i),{id:r}))}}const u=("last"===l.input?["change"]:["input","change"]).map(t=>Cr(t,d,e)),p=e.defaultView;if(!p)return()=>{u.forEach(t=>t())};const g=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),m=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&u.push(...m.map(t=>kr(t[0],t[1],{set(){d({target:this})}},!1,p))),()=>{u.forEach(t=>t())}}(t),c=function({mediaInteractionCb:t,blockClass:e,blockSelector:n,mirror:i,sampling:r}){const s=s=>Sr(r=>{const o=es(r);if(!o||Rr(o,e,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d}=o;t({type:s,id:i.getId(o),currentTime:a,volume:l,muted:c,playbackRate:d})},r.media||500),o=[Cr("play",s(0)),Cr("pause",s(1)),Cr("seeked",s(2)),Cr("volumechange",s(3)),Cr("ratechange",s(4))];return()=>{o.forEach(t=>t())}}(t),d=function({styleSheetRuleCb:t,mirror:e,stylesheetManager:n},{win:i}){const r=i.CSSStyleSheet.prototype.insertRule;i.CSSStyleSheet.prototype.insertRule=function(i,s){const{id:o,styleId:a}=ls(this,e,n.styleMirror);return(o&&-1!==o||a&&-1!==a)&&t({id:o,styleId:a,adds:[{rule:i,index:s}]}),r.apply(this,[i,s])};const s=i.CSSStyleSheet.prototype.deleteRule;let o,a;i.CSSStyleSheet.prototype.deleteRule=function(i){const{id:r,styleId:o}=ls(this,e,n.styleMirror);return(r&&-1!==r||o&&-1!==o)&&t({id:r,styleId:o,removes:[{index:i}]}),s.apply(this,[i])},i.CSSStyleSheet.prototype.replace&&(o=i.CSSStyleSheet.prototype.replace,i.CSSStyleSheet.prototype.replace=function(i){const{id:r,styleId:s}=ls(this,e,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&t({id:r,styleId:s,replace:i}),o.apply(this,[i])}),i.CSSStyleSheet.prototype.replaceSync&&(a=i.CSSStyleSheet.prototype.replaceSync,i.CSSStyleSheet.prototype.replaceSync=function(i){const{id:r,styleId:s}=ls(this,e,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&t({id:r,styleId:s,replaceSync:i}),a.apply(this,[i])});const l={};Qr?l.CSSGroupingRule=i.CSSGroupingRule:(Xr&&(l.CSSMediaRule=i.CSSMediaRule),ts&&(l.CSSConditionRule=i.CSSConditionRule),Jr&&(l.CSSSupportsRule=i.CSSSupportsRule));const c={};return Object.entries(l).forEach(([i,r])=>{c[i]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,s){const{id:o,styleId:a}=ls(this.parentStyleSheet,e,n.styleMirror);return(o&&-1!==o||a&&-1!==a)&&t({id:o,styleId:a,adds:[{rule:r,index:[...as(this),s||0]}]}),c[i].insertRule.apply(this,[r,s])},r.prototype.deleteRule=function(r){const{id:s,styleId:o}=ls(this.parentStyleSheet,e,n.styleMirror);return(s&&-1!==s||o&&-1!==o)&&t({id:s,styleId:o,removes:[{index:[...as(this),r]}]}),c[i].deleteRule.apply(this,[r])}}),()=>{i.CSSStyleSheet.prototype.insertRule=r,i.CSSStyleSheet.prototype.deleteRule=s,o&&(i.CSSStyleSheet.prototype.replace=o),a&&(i.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([t,e])=>{e.prototype.insertRule=c[t].insertRule,e.prototype.deleteRule=c[t].deleteRule})}}(t,{win:n}),h=cs(t,t.doc),u=function({styleDeclarationCb:t,mirror:e,ignoreCSSAttributes:n,stylesheetManager:i},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,o,a){var l;if(n.has(r))return s.apply(this,[r,o,a]);const{id:c,styleId:d}=ls(null===(l=this.parentRule)||void 0===l?void 0:l.parentStyleSheet,e,i.styleMirror);return(c&&-1!==c||d&&-1!==d)&&t({id:c,styleId:d,set:{property:r,value:o,priority:a},index:as(this.parentRule)}),s.apply(this,[r,o,a])};const o=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var s;if(n.has(r))return o.apply(this,[r]);const{id:a,styleId:l}=ls(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,e,i.styleMirror);return(a&&-1!==a||l&&-1!==l)&&t({id:a,styleId:l,remove:{property:r},index:as(this.parentRule)}),o.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=o}}(t,{win:n}),p=t.collectFonts?function({fontCb:t,doc:e}){const n=e.defaultView;if(!n)return()=>{};const i=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(t,e,n){const i=new s(t,e,n);return r.set(i,{family:t,buffer:"string"!=typeof e,descriptors:n,fontSource:"string"==typeof e?e:JSON.stringify(Array.from(new Uint8Array(e)))}),i};const o=xr(e.fonts,"add",function(e){return function(n){return setTimeout(()=>{const e=r.get(n);e&&(t(e),r.delete(n))},0),e.apply(this,[n])}});return i.push(()=>{n.FontFace=s}),i.push(o),()=>{i.forEach(t=>t())}}(t):()=>{},g=function(t){const{doc:e,mirror:n,blockClass:i,blockSelector:r,selectionCb:s}=t;let o=!0;const a=()=>{const t=e.getSelection();if(!t||o&&(null==t?void 0:t.isCollapsed))return;o=t.isCollapsed||!1;const a=[],l=t.rangeCount||0;for(let e=0;e<l;e++){const s=t.getRangeAt(e),{startContainer:o,startOffset:l,endContainer:c,endOffset:d}=s;Rr(o,i,r,!0)||Rr(c,i,r,!0)||a.push({start:n.getId(o),startOffset:l,end:n.getId(c),endOffset:d})}s({ranges:a})};return a(),Cr("selectionchange",a)}(t),m=[];for(const e of t.plugins)m.push(e.observer(e.callback,n,e.options));return()=>{Yr.forEach(t=>t.reset()),i.disconnect(),r(),s(),o(),a(),l(),c(),d(),h(),u(),p(),g(),m.forEach(t=>t())}}class hs{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,e,n,i){const r=n||this.getIdToRemoteIdMap(t),s=i||this.getRemoteIdToIdMap(t);let o=r.get(e);return o||(o=this.generateIdFn(),r.set(e,o),s.set(o,e)),o}getIds(t,e){const n=this.getIdToRemoteIdMap(t),i=this.getRemoteIdToIdMap(t);return e.map(e=>this.getId(t,e,n,i))}getRemoteId(t,e,n){const i=n||this.getRemoteIdToIdMap(t);if("number"!=typeof e)return e;return i.get(e)||-1}getRemoteIds(t,e){const n=this.getRemoteIdToIdMap(t);return e.map(e=>this.getRemoteId(t,e,n))}reset(t){if(!t)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let e=this.iframeIdToRemoteIdMap.get(t);return e||(e=new Map,this.iframeIdToRemoteIdMap.set(t,e)),e}getRemoteIdToIdMap(t){let e=this.iframeRemoteIdToIdMap.get(t);return e||(e=new Map,this.iframeRemoteIdToIdMap.set(t,e)),e}}class us{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new hs(ar),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new hs(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,e){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:e}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){if("rrweb"===t.data.type){if(!t.source)return;const e=this.crossOriginIframeMap.get(t.source);if(!e)return;const n=this.transformCrossOriginEvent(e,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}}transformCrossOriginEvent(t,e){var n;switch(e.type){case Nr.FullSnapshot:return this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(e.data.node,t),{timestamp:e.timestamp,type:Nr.IncrementalSnapshot,data:{source:Br.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:e.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Nr.Meta:case Nr.Load:case Nr.DomContentLoaded:return!1;case Nr.Plugin:return e;case Nr.Custom:return this.replaceIds(e.data.payload,t,["id","parentId","previousId","nextId"]),e;case Nr.IncrementalSnapshot:switch(e.data.source){case Br.Mutation:return e.data.adds.forEach(e=>{this.replaceIds(e,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(e.node,t)}),e.data.removes.forEach(e=>{this.replaceIds(e,t,["parentId","id"])}),e.data.attributes.forEach(e=>{this.replaceIds(e,t,["id"])}),e.data.texts.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Br.Drag:case Br.TouchMove:case Br.MouseMove:return e.data.positions.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Br.ViewportResize:return!1;case Br.MediaInteraction:case Br.MouseInteraction:case Br.Scroll:case Br.CanvasMutation:case Br.Input:return this.replaceIds(e.data,t,["id"]),e;case Br.StyleSheetRule:case Br.StyleDeclaration:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleId"]),e;case Br.Font:return e;case Br.Selection:return e.data.ranges.forEach(e=>{this.replaceIds(e,t,["start","end"])}),e;case Br.AdoptedStyleSheet:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleIds"]),null===(n=e.data.styles)||void 0===n||n.forEach(e=>{this.replaceStyleIds(e,t,["styleId"])}),e}}}replace(t,e,n,i){for(const r of i)(Array.isArray(e[r])||"number"==typeof e[r])&&(Array.isArray(e[r])?e[r]=t.getIds(n,e[r]):e[r]=t.getId(n,e[r]));return e}replaceIds(t,e,n){return this.replace(this.crossOriginIframeMirror,t,e,n)}replaceStyleIds(t,e,n){return this.replace(this.crossOriginIframeStyleMirror,t,e,n)}replaceIdOnNode(t,e){this.replaceIds(t,e,["id"]),"childNodes"in t&&t.childNodes.forEach(t=>{this.replaceIdOnNode(t,e)})}}class ps{constructor(t){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror;const e=this;this.restorePatches.push(xr(Element.prototype,"attachShadow",function(t){return function(n){const i=t.call(this,n);return this.shadowRoot&&e.addShadowRoot(this.shadowRoot,this.ownerDocument),i}}))}addShadowRoot(t,e){Qi(t)&&(this.shadowDoms.has(t)||(this.shadowDoms.add(t),ns(Object.assign(Object.assign({},this.bypassOptions),{doc:e,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t),is(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),cs({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t)},0)))}observeAttachShadow(t){if(t.contentWindow){const e=this;this.restorePatches.push(xr(t.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(i){const r=n.call(this,i);return this.shadowRoot&&e.addShadowRoot(this.shadowRoot,t.contentDocument),r}}))}}reset(){this.restorePatches.forEach(t=>t()),this.shadowDoms=new WeakSet}}for(var gs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ms="undefined"==typeof Uint8Array?[]:new Uint8Array(256),fs=0;fs<64;fs++)ms[gs.charCodeAt(fs)]=fs;const ys=new Map,bs=(t,e,n)=>{if(!t||!Cs(t,e)&&"object"!=typeof t)return;const i=function(t,e){let n=ys.get(t);return n||(n=new Map,ys.set(t,n)),n.has(e)||n.set(e,[]),n.get(e)}(n,t.constructor.name);let r=i.indexOf(t);return-1===r&&(r=i.length,i.push(t)),r};function ws(t,e,n){if(t instanceof Array)return t.map(t=>ws(t,e,n));if(null===t)return t;if(t instanceof Float32Array||t instanceof Float64Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Int8Array||t instanceof Uint8ClampedArray)return{rr_type:t.constructor.name,args:[Object.values(t)]};if(t instanceof ArrayBuffer){const e=t.constructor.name,n=function(t){var e,n=new Uint8Array(t),i=n.length,r="";for(e=0;e<i;e+=3)r+=gs[n[e]>>2],r+=gs[(3&n[e])<<4|n[e+1]>>4],r+=gs[(15&n[e+1])<<2|n[e+2]>>6],r+=gs[63&n[e+2]];return i%3==2?r=r.substring(0,r.length-1)+"=":i%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(t);return{rr_type:e,base64:n}}if(t instanceof DataView)return{rr_type:t.constructor.name,args:[ws(t.buffer,e,n),t.byteOffset,t.byteLength]};if(t instanceof HTMLImageElement){const e=t.constructor.name,{src:n}=t;return{rr_type:e,src:n}}return t instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:t.toDataURL()}:t instanceof ImageData?{rr_type:t.constructor.name,args:[ws(t.data,e,n),t.width,t.height]}:Cs(t,e)||"object"==typeof t?{rr_type:t.constructor.name,index:bs(t,e,n)}:t}const vs=(t,e,n)=>[...t].map(t=>ws(t,e,n)),Cs=(t,e)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(t=>"function"==typeof e[t]);return Boolean(n.find(n=>t instanceof e[n]))};function Is(t,e,n){const i=[];try{const r=xr(t.HTMLCanvasElement.prototype,"getContext",function(t){return function(i,...r){return Rr(this,e,n,!0)||"__context"in this||(this.__context=i),t.apply(this,[i,...r])}});i.push(r)}catch(t){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{i.forEach(t=>t())}}function _s(t,e,n,i,r,s,o){const a=[],l=Object.getOwnPropertyNames(t);for(const s of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof t[s])continue;const l=xr(t,s,function(t){return function(...a){const l=t.apply(this,a);if(bs(l,o,this),!Rr(this.canvas,i,r,!0)){const t=vs([...a],o,this),i={type:e,property:s,args:t};n(this.canvas,i)}return l}});a.push(l)}catch(i){const r=kr(t,s,{set(t){n(this.canvas,{type:e,property:s,args:[t],setter:!0})}});a.push(r)}return a}var Ss=null;try{var ks="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof require&&require("worker_threads")||"function"==typeof require&&require("worker_threads");Ss=ks.Worker}catch(t){}var xs,As,Es=(xs="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",As=!1,"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)?function(t,e,n){var i=void 0===e?null:e,r=function(t,e){return Buffer.from(t,"base64").toString(e?"utf16":"utf8")}(t,void 0!==n&&n),s=r.indexOf("\n",10)+1,o=r.substring(s)+(i?"//# sourceMappingURL="+i:"");return function(t){return new Ss(o,Object.assign({},t,{eval:!0}))}}(xs,null,As):function(t){var e;return function(n){return e=e||function(t,e,n){var i=void 0===e?null:e,r=function(t,e){var n=atob(t);if(e){for(var i=new Uint8Array(n.length),r=0,s=n.length;r<s;++r)i[r]=n.charCodeAt(r);return String.fromCharCode.apply(null,new Uint16Array(i.buffer))}return n}(t,void 0!==n&&n),s=r.indexOf("\n",10)+1,o=r.substring(s)+(i?"//# sourceMappingURL="+i:""),a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)}(t,null,false),new Worker(e,n)}}(xs));class Rs{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(t,e)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(t)||this.pendingCanvasMutations.set(t,[]),this.pendingCanvasMutations.get(t).push(e)};const{sampling:e="all",win:n,blockClass:i,blockSelector:r,recordCanvas:s,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,s&&"all"===e&&this.initCanvasMutationObserver(n,i,r),s&&"number"==typeof e&&this.initCanvasFPSObserver(e,n,i,r,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,e,n,i,r){const s=Is(e,n,i),o=new Map,a=new Es;a.onmessage=t=>{const{id:e}=t.data;if(o.set(e,!1),!("base64"in t.data))return;const{base64:n,type:i,width:r,height:s}=t.data;this.mutationCb({id:e,type:Zr["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:i}]},0,0]}]})};const l=1e3/t;let c,d=0;const h=t=>{d&&t-d<l||(d=t,(()=>{const t=[];return e.document.querySelectorAll("canvas").forEach(e=>{Rr(e,n,i,!0)||t.push(e)}),t})().forEach(t=>{return e=this,n=void 0,s=function*(){var e;const n=this.mirror.getId(t);if(o.get(n))return;if(o.set(n,!0),["webgl","webgl2"].includes(t.__context)){const n=t.getContext(t.__context);!1===(null===(e=null==n?void 0:n.getContextAttributes())||void 0===e?void 0:e.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const i=yield createImageBitmap(t);a.postMessage({id:n,bitmap:i,width:t.width,height:t.height,dataURLOptions:r.dataURLOptions},[i])},new((i=void 0)||(i=Promise))(function(t,r){function o(t){try{l(s.next(t))}catch(t){r(t)}}function a(t){try{l(s.throw(t))}catch(t){r(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(o,a)}l((s=s.apply(e,n||[])).next())});var e,n,i,s})),c=requestAnimationFrame(h)};c=requestAnimationFrame(h),this.resetObservers=()=>{s(),cancelAnimationFrame(c)}}initCanvasMutationObserver(t,e,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=Is(t,e,n),r=function(t,e,n,i){const r=[],s=Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype);for(const o of s)try{if("function"!=typeof e.CanvasRenderingContext2D.prototype[o])continue;const s=xr(e.CanvasRenderingContext2D.prototype,o,function(r){return function(...s){return Rr(this.canvas,n,i,!0)||setTimeout(()=>{const n=vs([...s],e,this);t(this.canvas,{type:Zr["2D"],property:o,args:n})},0),r.apply(this,s)}});r.push(s)}catch(n){const i=kr(e.CanvasRenderingContext2D.prototype,o,{set(e){t(this.canvas,{type:Zr["2D"],property:o,args:[e],setter:!0})}});r.push(i)}return()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,n),s=function(t,e,n,i){const r=[];return r.push(..._s(e.WebGLRenderingContext.prototype,Zr.WebGL,t,n,i,0,e)),void 0!==e.WebGL2RenderingContext&&r.push(..._s(e.WebGL2RenderingContext.prototype,Zr.WebGL2,t,n,i,0,e)),()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,n,this.mirror);this.resetObservers=()=>{i(),r(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=e=>{this.rafStamps.latestId=e,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,e)=>{const n=this.mirror.getId(e);this.flushPendingCanvasMutationFor(e,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,e){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||-1===e)return;const i=n.map(t=>{const e=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(t,["type"]);return e}),{type:r}=n[0];this.mutationCb({id:e,type:r,commands:i}),this.pendingCanvasMutations.delete(t)}}class Ms{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new Dr,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,e){"_cssText"in e.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:e.id,attributes:e.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,e){if(0===t.length)return;const n={id:e,styleIds:[]},i=[];for(const e of t){let t;if(this.styleMirror.has(e))t=this.styleMirror.getId(e);else{t=this.styleMirror.add(e);const n=Array.from(e.rules||CSSRule);i.push({styleId:t,rules:n.map((t,e)=>({rule:Ji(t),index:e}))})}n.styleIds.push(t)}i.length>0&&(n.styles=i),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}function Ts(t){return Object.assign(Object.assign({},t),{timestamp:Date.now()})}let zs,Os,Ls,Fs=!1;const Ds=new tr;function Ns(t={}){const{emit:e,checkoutEveryNms:n,checkoutEveryNth:i,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:o="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:l=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:u,maskInputFn:p,maskTextFn:g,hooks:m,packFn:f,sampling:y={},dataURLOptions:b={},mousemoveWait:w,recordCanvas:v=!1,recordCrossOriginIframes:C=!1,userTriggeredOnInput:I=!1,collectFonts:_=!1,inlineImages:S=!1,plugins:k,keepIframeSrcFn:x=()=>!1,ignoreCSSAttributes:A=new Set([])}=t,E=!C||window.parent===window;let R=!1;if(!E)try{window.parent.document,R=!1}catch(t){R=!0}if(E&&!e)throw new Error("emit function is required");void 0!==w&&void 0===y.mousemove&&(y.mousemove=w),Ds.reset();const M=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},T=!0===u||"all"===u?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===u,headMetaDescKeywords:"all"===u}:u||{};let z;!function(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let e=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1})}();let O=0;const L=t=>{for(const e of k||[])e.eventProcessor&&(t=e.eventProcessor(t));return f&&(t=f(t)),t};zs=(t,r)=>{var s;if(!(null===(s=Yr[0])||void 0===s?void 0:s.isFrozen())||t.type===Nr.FullSnapshot||t.type===Nr.IncrementalSnapshot&&t.data.source===Br.Mutation||Yr.forEach(t=>t.unfreeze()),E)null==e||e(L(t),r);else if(R){const e={type:"rrweb",event:L(t),isCheckout:r};window.parent.postMessage(e,"*")}if(t.type===Nr.FullSnapshot)z=t,O=0;else if(t.type===Nr.IncrementalSnapshot){if(t.data.source===Br.Mutation&&t.data.isAttachIframe)return;O++;const e=i&&O>=i,r=n&&t.timestamp-z.timestamp>n;(e||r)&&Os(!0)}};const F=t=>{zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.Mutation},t)}))},D=t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.Scroll},t)})),N=t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.CanvasMutation},t)})),B=new Ms({mutationCb:F,adoptedStyleSheetCb:t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.AdoptedStyleSheet},t)}))}),U=new us({mirror:Ds,mutationCb:F,stylesheetManager:B,recordCrossOriginIframes:C,wrappedEmit:zs});for(const t of k||[])t.getMirror&&t.getMirror({nodeMirror:Ds,crossOriginIframeMirror:U.crossOriginIframeMirror,crossOriginIframeStyleMirror:U.crossOriginIframeStyleMirror});Ls=new Rs({recordCanvas:v,mutationCb:N,win:window,blockClass:r,blockSelector:s,mirror:Ds,sampling:y.canvas,dataURLOptions:b});const Z=new ps({mutationCb:F,scrollCb:D,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskInputOptions:M,dataURLOptions:b,maskTextFn:g,maskInputFn:p,recordCanvas:v,inlineImages:S,sampling:y,slimDOMOptions:T,iframeManager:U,stylesheetManager:B,canvasManager:Ls,keepIframeSrcFn:x},mirror:Ds});Os=(t=!1)=>{var e,n,i,o,d,h;zs(Ts({type:Nr.Meta,data:{href:window.location.href,width:Er(),height:Ar()}}),t),B.reset(),Yr.forEach(t=>t.lock());const u=function(t,e){var n=e||{},i=n.mirror,r=void 0===i?new tr:i,s=n.blockClass,o=n.blockSelector,a=n.maskTextClass,l=n.maskTextSelector,c=n.inlineStylesheet,d=n.inlineImages,h=n.recordCanvas,u=n.maskAllInputs,p=void 0!==u&&u,g=n.slimDOM,m=void 0!==g&&g,f=n.keepIframeSrcFn;return vr(t,{doc:t,mirror:r,blockClass:void 0===s?"rr-block":s,blockSelector:void 0===o?null:o,maskTextClass:void 0===a?"rr-mask":a,maskTextSelector:void 0===l?null:l,skipChild:!1,inlineStylesheet:void 0===c||c,maskInputOptions:!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===p?{password:!0}:p,maskTextFn:n.maskTextFn,maskInputFn:n.maskInputFn,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,dataURLOptions:n.dataURLOptions,inlineImages:void 0!==d&&d,recordCanvas:void 0!==h&&h,preserveWhiteSpace:n.preserveWhiteSpace,onSerialize:n.onSerialize,onIframeLoad:n.onIframeLoad,iframeLoadTimeout:n.iframeLoadTimeout,onStylesheetLoad:n.onStylesheetLoad,stylesheetLoadTimeout:n.stylesheetLoadTimeout,keepIframeSrcFn:void 0===f?function(){return!1}:f,newlyAddedElement:!1})}(document,{mirror:Ds,blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskAllInputs:M,maskTextFn:g,slimDOM:T,dataURLOptions:b,recordCanvas:v,inlineImages:S,onSerialize:t=>{Or(t,Ds)&&U.addIframe(t),Lr(t,Ds)&&B.trackLinkElement(t),Fr(t)&&Z.addShadowRoot(t.shadowRoot,document)},onIframeLoad:(t,e)=>{U.attachIframe(t,e),Z.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{B.attachLinkElement(t,e)},keepIframeSrcFn:x});if(!u)return console.warn("Failed to snapshot the document");zs(Ts({type:Nr.FullSnapshot,data:{node:u,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(e=null===document||void 0===document?void 0:document.body)||void 0===e?void 0:e.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),Yr.forEach(t=>t.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&B.adoptStyleSheets(document.adoptedStyleSheets,Ds.getId(document))};try{const t=[];t.push(Cr("DOMContentLoaded",()=>{zs(Ts({type:Nr.DomContentLoaded,data:{}}))}));const e=t=>{var e;return ds({mutationCb:F,mousemoveCb:(t,e)=>zs(Ts({type:Nr.IncrementalSnapshot,data:{source:e,positions:t}})),mouseInteractionCb:t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.MouseInteraction},t)})),scrollCb:D,viewportResizeCb:t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.ViewportResize},t)})),inputCb:t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.Input},t)})),mediaInteractionCb:t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.MediaInteraction},t)})),styleSheetRuleCb:t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.StyleSheetRule},t)})),styleDeclarationCb:t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.StyleDeclaration},t)})),canvasMutationCb:N,fontCb:t=>zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.Font},t)})),selectionCb:t=>{zs(Ts({type:Nr.IncrementalSnapshot,data:Object.assign({source:Br.Selection},t)}))},blockClass:r,ignoreClass:o,maskTextClass:a,maskTextSelector:l,maskInputOptions:M,inlineStylesheet:c,sampling:y,recordCanvas:v,inlineImages:S,userTriggeredOnInput:I,collectFonts:_,doc:t,maskInputFn:p,maskTextFn:g,keepIframeSrcFn:x,blockSelector:s,slimDOMOptions:T,dataURLOptions:b,mirror:Ds,iframeManager:U,stylesheetManager:B,shadowDomManager:Z,canvasManager:Ls,ignoreCSSAttributes:A,plugins:(null===(e=null==k?void 0:k.filter(t=>t.observer))||void 0===e?void 0:e.map(t=>({observer:t.observer,options:t.options,callback:e=>zs(Ts({type:Nr.Plugin,data:{plugin:t.name,payload:e}}))})))||[]},m)};U.addLoadListener(n=>{t.push(e(n.contentDocument))});const n=()=>{Os(),t.push(e(document)),Fs=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():t.push(Cr("load",()=>{zs(Ts({type:Nr.Load,data:{}})),n()},window)),()=>{t.forEach(t=>t()),Fs=!1}}catch(t){console.warn(t)}}Ns.addCustomEvent=(t,e)=>{if(!Fs)throw new Error("please add custom event after start recording");zs(Ts({type:Nr.Custom,data:{tag:t,payload:e}}))},Ns.freezePage=()=>{Yr.forEach(t=>t.freeze())},Ns.takeFullSnapshot=t=>{if(!Fs)throw new Error("please take full snapshot after start recording");Os(t)},Ns.mirror=Ds;var Bs=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Bs||{});class Us{constructor(t){this.events=[],this.lastFullSnapshotIndex=-1,this.duration=1e3*t.duration}add(t){t.type===Bs.FullSnapshot&&(this.lastFullSnapshotIndex=this.events.length),this.events.push(t),this.prune()}addBatch(t){for(let e=t.length-1;e>=0;e--)if(t[e].type===Bs.FullSnapshot){this.lastFullSnapshotIndex=this.events.length+e;break}this.events.push(...t),this.prune()}prune(){if(0===this.events.length)return;const t=Date.now()-this.duration;let e=this.events.length;for(let n=0;n<this.events.length;n++)if(this.events[n].timestamp>=t){e=n;break}this.lastFullSnapshotIndex>=0&&this.lastFullSnapshotIndex<e&&(e=this.lastFullSnapshotIndex),0!==e&&(this.events=this.events.slice(e),this.lastFullSnapshotIndex>=0&&(this.lastFullSnapshotIndex-=e))}getEvents(){return this.prune(),[...this.events]}getCompressedEvents(){return this.getEvents()}clear(){this.events=[],this.lastFullSnapshotIndex=-1}size(){return this.events.length}setDuration(t){this.duration=1e3*t,this.prune()}getDuration(){return this.duration/1e3}}const Zs=E();class Ps{constructor(t={}){var e,n,i,r,s,o,a,l,c,d;this.isRecording=!1,this.sanitizer=t.sanitizer,this.config={duration:null!==(e=t.duration)&&void 0!==e?e:15,sampling:{mousemove:null!==(i=null===(n=t.sampling)||void 0===n?void 0:n.mousemove)&&void 0!==i?i:50,scroll:null!==(s=null===(r=t.sampling)||void 0===r?void 0:r.scroll)&&void 0!==s?s:100},inlineStylesheet:null===(o=t.inlineStylesheet)||void 0===o||o,inlineImages:null!==(a=t.inlineImages)&&void 0!==a&&a,collectFonts:null!==(l=t.collectFonts)&&void 0!==l&&l,recordCanvas:null!==(c=t.recordCanvas)&&void 0!==c&&c,recordCrossOriginIframes:null!==(d=t.recordCrossOriginIframes)&&void 0!==d&&d,sanitizer:t.sanitizer},this.buffer=new Us({duration:this.config.duration})}startRecording(){var t,e,n,i;if(this.isRecording)E().warn("DOMCollector: Recording already in progress");else try{const r={emit:t=>{this.buffer.add(t)},sampling:{mousemove:null!==(e=null===(t=this.config.sampling)||void 0===t?void 0:t.mousemove)&&void 0!==e?e:50,scroll:null!==(i=null===(n=this.config.sampling)||void 0===n?void 0:n.scroll)&&void 0!==i?i:100,mouseInteraction:!0},recordCanvas:this.config.recordCanvas,recordCrossOriginIframes:this.config.recordCrossOriginIframes,maskTextFn:this.sanitizer?(t,e)=>this.sanitizer.sanitizeTextNode(t,e):void 0,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},inlineStylesheet:this.config.inlineStylesheet,inlineImages:this.config.inlineImages,collectFonts:this.config.collectFonts};this.stopRecordingFn=Ns(r),this.isRecording=!0,E().debug("DOMCollector: Started recording")}catch(t){E().error("DOMCollector: Failed to start recording",t),this.isRecording=!1}}stopRecording(){if(this.isRecording&&this.stopRecordingFn)try{this.stopRecordingFn(),this.isRecording=!1,this.stopRecordingFn=void 0,Zs.debug("DOMCollector: Stopped recording")}catch(t){Zs.error("DOMCollector: Failed to stop recording",t)}else Zs.warn("DOMCollector: No recording in progress")}getEvents(){return this.buffer.getEvents()}getCompressedEvents(){return this.buffer.getCompressedEvents()}clearBuffer(){this.buffer.clear()}isCurrentlyRecording(){return this.isRecording}getBufferSize(){return this.buffer.size()}setDuration(t){this.config.duration=t,this.buffer.setDuration(t)}getDuration(){return this.config.duration}destroy(){this.stopRecording(),this.clearBuffer()}}class Ws{constructor(t){var e,n,i,r,s,o,a,l,c,d;this.screenshot=new ji,this.console=new qi({sanitizer:t.sanitizer});const h={sanitizer:t.sanitizer};if(t.apiEndpoint){const e=t.apiEndpoint;h.filterUrls=t=>!t.startsWith(e)}this.network=new Hi(h),this.metadata=new Ki({sanitizer:t.sanitizer}),(null===(n=null===(e=t.replay)||void 0===e?void 0:e.enabled)||void 0===n||n)&&(this.domCollector=new Ps({duration:null!==(r=null===(i=t.replay)||void 0===i?void 0:i.duration)&&void 0!==r?r:15,sampling:null===(s=t.replay)||void 0===s?void 0:s.sampling,inlineStylesheet:null===(o=t.replay)||void 0===o?void 0:o.inlineStylesheet,inlineImages:null===(a=t.replay)||void 0===a?void 0:a.inlineImages,collectFonts:null===(l=t.replay)||void 0===l?void 0:l.collectFonts,recordCanvas:null===(c=t.replay)||void 0===c?void 0:c.recordCanvas,recordCrossOriginIframes:null===(d=t.replay)||void 0===d?void 0:d.recordCrossOriginIframes,sanitizer:t.sanitizer}),this.domCollector.startRecording())}async captureAll(){var t,e;return{console:this.console.getLogs(),network:this.network.getRequests(),metadata:this.metadata.capture(),replay:null!==(e=null===(t=this.domCollector)||void 0===t?void 0:t.getEvents())&&void 0!==e?e:[],_screenshotPreview:await this.screenshot.capture()}}async captureScreenshot(){return await this.screenshot.capture()}destroy(){var t;this.console.destroy(),this.network.destroy(),null===(t=this.domCollector)||void 0===t||t.destroy()}}const js=E();class Vs{constructor(t,e){this.apiEndpoint=t,this.apiKey=e}async uploadFiles(t,e,n){const i=await this.prepareFiles(e,n);0!==i.length&&(await this.uploadToStorage(i),await this.confirmUploads(i,t))}async prepareFiles(t,e){const n=[];if(t._screenshotPreview&&t._screenshotPreview.startsWith("data:image/")){const i=this.getPresignedUrl("screenshot",e),r=await this.dataUrlToBlob(t._screenshotPreview);n.push({type:"screenshot",url:i.uploadUrl,key:i.storageKey,blob:r})}if(t.replay&&t.replay.length>0){const i=this.getPresignedUrl("replay",e),r=await async function(t){try{const e=function(t){return"string"==typeof t?t:JSON.stringify(t)}(t),n=(Zi||(Zi=new TextEncoder),Zi).encode(e),i=6;return Bi.gzip(n,{level:i})}catch(t){throw Ui.error("Compression failed:",t),t}}(t.replay),s=new Blob([r],{type:"application/gzip"});n.push({type:"replay",url:i.uploadUrl,key:i.storageKey,blob:s})}return n}async uploadToStorage(t){const e=t.map(async t=>{const e=new AbortController,n=setTimeout(()=>e.abort(),Vs.UPLOAD_TIMEOUT_MS);try{const i=await fetch(t.url,{method:"PUT",body:t.blob,signal:e.signal});return clearTimeout(n),{success:i.ok,type:t.type}}catch(e){return clearTimeout(n),js.error(`Upload failed for ${t.type}:`,e),{success:!1,type:t.type}}}),n=await Promise.all(e);for(const t of n)if(!t.success)throw new Error(`${this.formatFileType(t.type)} upload failed: Upload to storage failed`)}async confirmUploads(t,e){const n=t.map(async t=>{try{return{success:(await fetch(`${this.apiEndpoint}/api/v1/reports/${e}/confirm-upload`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.apiKey},body:JSON.stringify({fileType:t.type})})).ok,type:t.type}}catch(e){return js.error(`Confirmation failed for ${t.type}:`,e),{success:!1,type:t.type}}}),i=await Promise.all(n);for(const t of i)if(!t.success)throw new Error(`${this.formatFileType(t.type)} confirmation failed: Backend did not acknowledge upload`)}getPresignedUrl(t,e){const n=e[t];if(!n)throw new Error(`${this.formatFileType(t)} presigned URL not provided by server`);return n}async dataUrlToBlob(t){if(!t||!t.startsWith("data:"))throw new Error("Invalid data URL");const e=await fetch(t);if(!e||!e.blob)throw new Error("Failed to convert data URL to Blob");return await e.blob()}formatFileType(t){return t.charAt(0).toUpperCase()+t.slice(1)}}Vs.UPLOAD_TIMEOUT_MS=6e4;const Gs=E();function qs(t){if(!t||"object"!=typeof t)return"";const e=t;return`${"string"==typeof e.message?e.message:""}:${"string"==typeof e.stack?e.stack:""}`}function Hs(t,e,n){const i=t.trim().toLowerCase(),r=e.trim().toLowerCase();let s="";return n&&(Array.isArray(n)?s=n.map(t=>"string"==typeof t?t:qs(t)).join("|"):"object"==typeof n&&(s=qs(n))),function(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)|0;return(e>>>0).toString(36)}(`${i}|${r}|${s}`)}class Ks{constructor(t={}){this.recentReports=new Map,this.cleanupInterval=null,this.submittingFingerprints=new Set,this.config={windowMs:void 0!==t.windowMs?t.windowMs:6e4,maxCacheSize:void 0!==t.maxCacheSize?t.maxCacheSize:100,enabled:void 0===t.enabled||t.enabled},this.config.enabled&&"undefined"!=typeof window&&(this.cleanupInterval=window.setInterval(()=>{try{this.cleanup()}catch(t){Gs.error("Deduplicator cleanup failed",t)}},this.config.windowMs/2))}isInProgress(t,e,n){const i=Hs(t,e,n);return this.submittingFingerprints.has(i)}markInProgress(t,e,n){const i=Hs(t,e,n);this.submittingFingerprints.add(i)}markComplete(t,e,n){const i=Hs(t,e,n);this.submittingFingerprints.delete(i)}isDuplicate(t,e,n){if(!this.config.enabled)return!1;const i=Hs(t,e,n);if(this.submittingFingerprints.has(i))return Gs.warn("Duplicate submission blocked: this report is already in progress"),!0;const r=Date.now(),s=this.recentReports.get(i);if(s&&r-s.timestamp<this.config.windowMs){const e=Math.round((r-s.timestamp)/1e3);return Gs.warn(`Duplicate bug report detected (age: ${e}s)`,{fingerprint:i,title:t.substring(0,50)}),!0}return!1}recordSubmission(t,e,n){if(!this.config.enabled)return;const i=Hs(t,e,n),r=Date.now();if(this.recentReports.size>=this.config.maxCacheSize){const t=this.recentReports.keys().next().value;t&&this.recentReports.delete(t)}this.recentReports.set(i,{timestamp:r}),Gs.debug("Recorded bug report submission",{fingerprint:i,cacheSize:this.recentReports.size})}cleanup(){const t=Date.now();let e=0;this.recentReports.forEach((n,i)=>{t-n.timestamp>this.config.windowMs&&(this.recentReports.delete(i),e++)}),e>0&&Gs.debug(`Cleaned up ${e} expired report fingerprints`)}getCacheSize(){return this.recentReports.size}clear(){this.submittingFingerprints.clear(),this.recentReports.clear(),Gs.debug("Cleared all cached report fingerprints")}destroy(){null!==this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.clear()}}class $s{getItem(t){try{return"undefined"==typeof localStorage?null:localStorage.getItem(t)}catch(t){return null}}setItem(t,e){"undefined"!=typeof localStorage&&localStorage.setItem(t,e)}removeItem(t){try{if("undefined"==typeof localStorage)return;localStorage.removeItem(t)}catch(t){}}}const Ys="bugspotter_offline_queue",Qs={enabled:!1,maxQueueSize:10};class Xs{constructor(t,e,n){this.requestCounter=0,this.config=Object.assign(Object.assign({},Qs),t),this.logger=e||E(),this.storage=n||new $s}enqueue(t,e,n){try{const i=this.serializeBody(e);if(!i||!this.validateItemSize(i))return;const r=this.getQueue();r.length>=this.config.maxQueueSize&&(this.logger.warn(`Offline queue is full (${this.config.maxQueueSize}), removing oldest request`),r.shift()),r.push(this.createQueuedRequest(t,i,n)),this.saveQueue(r),this.logger.log(`Request queued for offline retry (queue size: ${r.length})`)}catch(t){this.logger.error("Failed to queue request for offline retry:",t)}}async process(t){const e=this.getQueue();if(0===e.length)return;this.logger.log(`Processing offline queue (${e.length} requests)`);const n=[],i=[];for(const r of e)if(r.attempts>=5)this.logger.warn(`Max retry attempts (5) reached for request (id: ${r.id}), removing`);else if(Date.now()-r.timestamp>6048e5)this.logger.warn(`Removing expired queued request (id: ${r.id})`);else try{const e=await fetch(r.endpoint,{method:"POST",headers:r.headers,body:r.body});e.ok?(this.logger.log(`Successfully sent queued request (id: ${r.id})`),n.push(r.id)):t.includes(e.status)?(r.attempts++,i.push(r),this.logger.warn(`Queued request failed with status ${e.status}, will retry later (id: ${r.id})`)):this.logger.warn(`Queued request failed with non-retryable status ${e.status}, removing (id: ${r.id})`)}catch(t){r.attempts++,i.push(r),this.logger.warn(`Queued request failed with network error, will retry later (id: ${r.id}):`,t)}this.saveQueue(i),(n.length>0||i.length<e.length)&&this.logger.log(`Offline queue processed: ${n.length} successful, ${i.length} remaining`)}clear(){try{this.storage.removeItem(Ys)}catch(t){}}size(){return this.getQueue().length}serializeBody(t){return"string"==typeof t?t:t instanceof Blob?(this.logger.warn("Cannot queue Blob for offline retry, skipping"),null):JSON.stringify(t)}createQueuedRequest(t,e,n){return{id:this.generateRequestId(),endpoint:t,body:e,headers:n,timestamp:Date.now(),attempts:0}}validateItemSize(t){const e=new Blob([t]).size;return!(e>102400&&(this.logger.warn(`Request body too large (${e} bytes), skipping queue`),1))}getQueue(){try{const t=this.storage.getItem(Ys);return t?JSON.parse(t):[]}catch(t){return this.logger.warn("Failed to parse offline queue data, clearing corrupted queue:",t),this.clear(),[]}}saveQueue(t){try{this.storage.setItem(Ys,JSON.stringify(t))}catch(e){this.isQuotaExceededError(e)?(this.logger.error("localStorage quota exceeded, clearing oldest items"),this.clearOldestItems(t)):this.logger.error("Failed to save offline queue:",e)}}isQuotaExceededError(t){if(!(t instanceof Error))return!1;if("QuotaExceededError"===t.name)return!0;if("code"in t&&22===t.code)return!0;const e=t.message.toLowerCase();return e.includes("quota")||e.includes("storage")||e.includes("exceeded")}clearOldestItems(t){try{const e=t.slice(Math.floor(t.length/2));this.storage.setItem(Ys,JSON.stringify(e)),this.logger.log(`Trimmed offline queue to ${e.length} items due to quota`)}catch(t){this.logger.error("Failed to save even after trimming, clearing queue"),this.clear()}}generateRequestId(){let t;if(this.requestCounter=(this.requestCounter+1)%1e4,"undefined"!=typeof crypto&&crypto.getRandomValues){const e=new Uint32Array(2);crypto.getRandomValues(e),t=Array.from(e,t=>t.toString(36)).join("")}else t=Math.random().toString(36).substring(2,9)+Math.random().toString(36).substring(2,9);return`req_${Date.now()}_${this.requestCounter}_${t}`}}Error;class Js extends Error{constructor(t){super(t),this.name="AuthenticationError"}}const to={maxRetries:3,baseDelay:1e3,maxDelay:3e4,retryOn:[502,503,504,429]},eo={enabled:!1,maxQueueSize:10};function no(t){if(!t||!t.apiKey)throw new Js("Authentication is required: API key must be provided");return{"X-API-Key":t.apiKey}}class io{constructor(t,e){this.config=t,this.logger=e}async executeWithRetry(t,e){let n=null;for(let i=0;i<=this.config.maxRetries;i++)try{const n=await t();if(e(n.status)&&i<this.config.maxRetries){const t=this.calculateDelay(i,n);this.logger.warn(`Request failed with status ${n.status}, retrying in ${t}ms (attempt ${i+1}/${this.config.maxRetries})`),await so(t);continue}return n}catch(t){if(n=t,t instanceof Js)throw t;if(i<this.config.maxRetries){const e=this.calculateDelay(i);this.logger.warn(`Network error, retrying in ${e}ms (attempt ${i+1}/${this.config.maxRetries}):`,t),await so(e);continue}}throw n||new Error("Request failed after all retry attempts")}calculateDelay(t,e){var n,i;if(null===(i=null===(n=null==e?void 0:e.headers)||void 0===n?void 0:n.has)||void 0===i?void 0:i.call(n,"Retry-After")){const t=e.headers.get("Retry-After"),n=parseInt(t,10);if(!isNaN(n))return Math.min(1e3*n,this.config.maxDelay)}const r=this.config.baseDelay*Math.pow(2,t),s=r+.1*r*(2*Math.random()-1);return Math.min(s,this.config.maxDelay)}}async function ro(t,e,n={},i){const r=i.logger||E(),s=Object.assign(Object.assign({},to),i.retry),o=Object.assign(Object.assign({},eo),i.offline);!async function(t,e,n){t.enabled&&new Xs(t,n).process(e.retryOn).catch(t=>{n.warn("Failed to process offline queue:",t)})}(o,s,r);try{const o=await async function(t,e,n,i,r,s){return new io(r,s).executeWithRetry(async()=>async function(t,e,n,i){const r=no(i),s=Object.assign(Object.assign({},n),r);return fetch(t,{method:"POST",headers:s,body:e})}(t,e,n,i),t=>r.retryOn.includes(t))}(t,e,n,i.auth,s,r);return o}catch(s){throw await async function(t,e,n,i,r,s,o){if(!s.enabled||!function(t){if(!(t instanceof Error))return!1;const e=t.message.toLowerCase();return e.includes("failed to fetch")||e.includes("network request failed")||e.includes("networkerror")||e.includes("network error")||e.includes("connection")||e.includes("timeout")||"NetworkError"===t.name||"AbortError"===t.name||"TypeError"===t.name&&(e.includes("fetch")||e.includes("network"))}(t))return;o.warn("Network error detected, queueing request for offline retry");const a=new Xs(s,o),l=no(r);await a.enqueue(e,n,Object.assign(Object.assign({},i),l))}(s,t,e,n,i.auth,o,r),s}}function so(t){return new Promise(e=>setTimeout(e,t))}const oo=E();function ao(t){var e,n,i,r;return{hasScreenshot:(r=t._screenshotPreview,!!r&&r.startsWith("data:image/")),hasReplay:(i=t.replay,!!i&&Array.isArray(i)&&i.length>0),screenshotSize:(null===(e=t._screenshotPreview)||void 0===e?void 0:e.length)||0,replayEventCount:(null===(n=t.replay)||void 0===n?void 0:n.length)||0}}function lo(t,e){return`${t}: ${e instanceof Error?e.message:String(e)}`}class co{constructor(t){this.config=t,this.deduplicator=new Ks(t.deduplication)}async submit(t){const e=this.validateAndExtractErrors(t);try{oo.debug(`Submitting bug report to ${this.config.endpoint}`);const n=await this.createBugReport(t);await this.handleFileUploads(n,t,e)}finally{this.deduplicator.markComplete(e.title,e.description,e.errorStacks)}}validateAndExtractErrors(t){var e;!function(t){if(!t.endpoint)throw new Error("No endpoint configured for bug report submission");if(!t.auth)throw new Error("API key authentication is required");if("api-key"!==t.auth.type)throw new Error("API key authentication is required");if(!t.auth.apiKey)throw new Error("API key is required in auth configuration");if(!t.auth.projectId)throw new Error("Project ID is required in auth configuration")}({endpoint:this.config.endpoint,auth:this.config.auth});const n=function(t){return{title:t.title,description:t.description||"",errorStacks:(e=t.report,(null!==(i=null===(n=e.console)||void 0===n?void 0:n.filter(t=>"error"===t.level))&&void 0!==i?i:[]).map(t=>{var e;return null!==(e=t.stack)&&void 0!==e?e:t.message}))};var e,n,i}(t);if(this.deduplicator.isDuplicate(n.title,n.description,n.errorStacks)){const t=Math.ceil(((null===(e=this.config.deduplication)||void 0===e?void 0:e.windowMs)||6e4)/1e3);throw oo.warn("Duplicate bug report blocked",{title:n.title.substring(0,50),waitSeconds:t}),new Error(`Duplicate bug report detected. Please wait ${t} seconds before submitting again.`)}return this.deduplicator.markInProgress(n.title,n.description,n.errorStacks),n}async createBugReport(t){const{report:e}=t,n=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(t,["report"]),i=ao(e);oo.debug("File upload detection",i);const r=Object.assign(Object.assign({},n),{report:{console:e.console,network:e.network,metadata:e.metadata},hasScreenshot:i.hasScreenshot,hasReplay:i.hasReplay}),s=await ro(this.config.endpoint,JSON.stringify(r),{"Content-Type":"application/json"},{auth:this.config.auth,retry:this.config.retry,offline:this.config.offline});if(!s.ok){const t=await s.text().catch(()=>"Unknown error");throw new Error(`Failed to submit bug report: ${s.status} ${s.statusText}. ${t}`)}const o=await s.json();if(!function(t){if(!t||"object"!=typeof t)return!1;const e=t;if(!("success"in e)||"boolean"!=typeof e.success)return!1;if(e.success){const t=e.data;if(!t||"object"!=typeof t||!("id"in t)||"string"!=typeof t.id)return!1;if("presignedUrls"in t&&void 0!==t.presignedUrls&&("object"!=typeof t.presignedUrls||null===t.presignedUrls))return!1}return!0}(o))throw new Error("Invalid server response format");if(!o.success)throw new Error("Bug report creation failed on server");const a=o.data;return oo.debug("Bug report creation response",{success:o.success,bugId:a.id,hasPresignedUrls:!!a.presignedUrls,presignedUrlKeys:a.presignedUrls?Object.keys(a.presignedUrls):[]}),a}async handleFileUploads(t,e,n){const i=t.id,{report:r}=e,s=ao(r);if(!s.hasScreenshot&&!s.hasReplay)return oo.debug("No files to upload, bug report created successfully",{bugId:i}),void this.deduplicator.recordSubmission(n.title,n.description,n.errorStacks);if(!t.presignedUrls)throw oo.error("Presigned URLs not returned despite requesting file uploads",{bugId:i,hasScreenshot:s.hasScreenshot,hasReplay:s.hasReplay}),new Error("Server did not provide presigned URLs for file uploads. Check backend configuration.");const o=O(this.config.endpoint),a=new Vs(o,this.config.auth.apiKey);try{await a.uploadFiles(i,r,t.presignedUrls),oo.debug("File uploads completed successfully",{bugId:i}),this.deduplicator.recordSubmission(n.title,n.description,n.errorStacks)}catch(t){throw oo.error("File upload failed",{bugId:i,error:lo("Upload",t)}),new Error(lo(`Bug report created (ID: ${i}) but file upload failed`,t))}}destroy(){this.deduplicator.destroy()}}const ho=E();function uo(t,e){var n,i,r,s,o,a,l,c,d,h,u,p,g,m,f,y,b,w;return Object.assign(Object.assign({},t),{duration:null!==(i=null!==(n=null==t?void 0:t.duration)&&void 0!==n?n:null==e?void 0:e.duration)&&void 0!==i?i:15,inlineStylesheet:null===(s=null!==(r=null==t?void 0:t.inlineStylesheet)&&void 0!==r?r:null==e?void 0:e.inline_stylesheets)||void 0===s||s,inlineImages:null!==(a=null!==(o=null==t?void 0:t.inlineImages)&&void 0!==o?o:null==e?void 0:e.inline_images)&&void 0!==a&&a,collectFonts:null!==(c=null!==(l=null==t?void 0:t.collectFonts)&&void 0!==l?l:null==e?void 0:e.collect_fonts)&&void 0!==c&&c,recordCanvas:null!==(h=null!==(d=null==t?void 0:t.recordCanvas)&&void 0!==d?d:null==e?void 0:e.record_canvas)&&void 0!==h&&h,recordCrossOriginIframes:null!==(p=null!==(u=null==t?void 0:t.recordCrossOriginIframes)&&void 0!==u?u:null==e?void 0:e.record_cross_origin_iframes)&&void 0!==p&&p,sampling:{mousemove:null!==(f=null!==(m=null===(g=null==t?void 0:t.sampling)||void 0===g?void 0:g.mousemove)&&void 0!==m?m:null==e?void 0:e.sampling_mousemove)&&void 0!==f?f:50,scroll:null!==(w=null!==(b=null===(y=null==t?void 0:t.sampling)||void 0===y?void 0:y.scroll)&&void 0!==b?b:null==e?void 0:e.sampling_scroll)&&void 0!==w?w:100}})}class po{constructor(t){var e,n,i,r,s,o;t.deduplication&&function(t){if(t){if("enabled"in t&&"boolean"!=typeof t.enabled)throw new Error("deduplication.enabled must be a boolean");if("windowMs"in t){if("number"!=typeof t.windowMs)throw new Error("deduplication.windowMs must be a number");if(!Number.isFinite(t.windowMs))throw new Error("deduplication.windowMs must be a finite number");if(t.windowMs<=0)throw new Error("deduplication.windowMs must be greater than 0")}if("maxCacheSize"in t){if("number"!=typeof t.maxCacheSize)throw new Error("deduplication.maxCacheSize must be a number");if(!Number.isFinite(t.maxCacheSize))throw new Error("deduplication.maxCacheSize must be a finite number");if(t.maxCacheSize<=0)throw new Error("deduplication.maxCacheSize must be greater than 0");if(!Number.isInteger(t.maxCacheSize))throw new Error("deduplication.maxCacheSize must be an integer")}}}(t.deduplication),this.config=t;const a=null===(n=null===(e=t.sanitize)||void 0===e?void 0:e.enabled)||void 0===n||n;a&&(this.sanitizer=k({enabled:a,patterns:null===(i=t.sanitize)||void 0===i?void 0:i.patterns,customPatterns:null===(r=t.sanitize)||void 0===r?void 0:r.customPatterns,excludeSelectors:null===(s=t.sanitize)||void 0===s?void 0:s.excludeSelectors})),this.captureManager=new Ws(Object.assign(Object.assign({sanitizer:this.sanitizer},t.endpoint&&{apiEndpoint:O(t.endpoint)}),{replay:t.replay})),this.bugReporter=new co(t),(null===(o=t.showWidget)||void 0===o||o)&&(this.widget=new c(t.widgetOptions),this.widget.onClick(async()=>{await this.handleBugReport()}))}static async init(t){if(po.instance)return ho.warn("BugSpotter.init() called multiple times. Returning existing instance. Call destroy() first to reinitialize with new config."),po.instance;if(po.initPromise)return ho.warn("BugSpotter.init() called while initialization in progress. Waiting..."),po.initPromise;po.initPromise=po.createInstance(t);try{return po.instance=await po.initPromise,po.instance}finally{po.initPromise=void 0}}static async createInstance(t){var e,n,i;let r=null;(null===(n=null===(e=t.replay)||void 0===e?void 0:e.enabled)||void 0===n||n)&&t.endpoint&&((null===(i=t.auth)||void 0===i?void 0:i.apiKey)?r=await async function(t,e){var n,i,r,s,o,a,l,c;const d={duration:15,inline_stylesheets:!0,inline_images:!1,collect_fonts:!0,record_canvas:!1,record_cross_origin_iframes:!1,sampling_mousemove:50,sampling_scroll:100};try{const h=O(t),u={};e&&(u["x-api-key"]=e);const p=await fetch(`${h}/api/v1/settings/replay`,{headers:u});if(!p.ok)return ho.warn(`Failed to fetch replay settings: ${p.status}. Using defaults.`),d;const g=await p.json();return g.success&&g.data?{duration:null!==(n=g.data.duration)&&void 0!==n?n:d.duration,inline_stylesheets:null!==(i=g.data.inline_stylesheets)&&void 0!==i?i:d.inline_stylesheets,inline_images:null!==(r=g.data.inline_images)&&void 0!==r?r:d.inline_images,collect_fonts:null!==(s=g.data.collect_fonts)&&void 0!==s?s:d.collect_fonts,record_canvas:null!==(o=g.data.record_canvas)&&void 0!==o?o:d.record_canvas,record_cross_origin_iframes:null!==(a=g.data.record_cross_origin_iframes)&&void 0!==a?a:d.record_cross_origin_iframes,sampling_mousemove:null!==(l=g.data.sampling_mousemove)&&void 0!==l?l:d.sampling_mousemove,sampling_scroll:null!==(c=g.data.sampling_scroll)&&void 0!==c?c:d.sampling_scroll}:(ho.warn("Invalid replay settings response. Using defaults."),d)}catch(t){return ho.warn("Failed to fetch replay settings from backend. Using defaults.",t),d}}(t.endpoint,t.auth.apiKey):ho.warn("Endpoint provided but no API key configured. Skipping backend settings fetch."));const s=Object.assign(Object.assign({},t),{replay:uo(t.replay,r)});return new po(s)}static getInstance(){return po.instance||null}async capture(){return await this.captureManager.captureAll()}async handleBugReport(){const t=await this.capture();new M({onSubmit:async e=>{if(ho.log("Submitting bug:",Object.assign(Object.assign({},e),{report:t})),this.config.endpoint)try{await this.submit(Object.assign(Object.assign({},e),{report:t})),ho.log("Bug report submitted successfully")}catch(t){throw ho.error("Failed to submit bug report:",t),t}},onProgress:t=>{ho.debug("Upload progress:",t)}}).show(t._screenshotPreview||"")}async submit(t){await this.bugReporter.submit(t)}getConfig(){return Object.assign({},this.config)}destroy(){var t;this.captureManager.destroy(),null===(t=this.widget)||void 0===t||t.destroy(),this.bugReporter.destroy(),po.instance=void 0,po.initPromise=void 0}}return e.BugSpotter})());
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BugSpotter=e():t.BugSpotter=e()}(this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{BugSpotter:()=>po});const n='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n<path d="M8 2v4"/>\n<path d="M16 2v4"/>\n<path d="M12 12v5"/>\n<circle cx="12" cy="10" r="4"/>\n<path d="M9 16c-1.5 1-3 2-3 4h12c0-2-1.5-3-3-4"/>\n<path d="M3 8h4"/>\n<path d="M17 8h4"/>\n<path d="M5 12h2"/>\n<path d="M17 12h2"/>\n<path d="M6 16h2"/>\n<path d="M16 16h2"/>\n</svg>',i={position:"bottom-right",icon:"svg",customSvg:void 0,backgroundColor:"#2563eb",size:56,offset:{x:20,y:20},zIndex:999999,tooltip:"Report an Issue"},r="0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)",s="0 10px 15px rgba(0, 0, 0, 0.2), 0 4px 6px rgba(0, 0, 0, 0.1)",o="scale(1)",a="scale(1.1)",l="scale(0.95)";class c{constructor(t={}){var e,n,c,d,h,u,p,g;this.eventHandlers=new Map,this.handleMouseEnter=()=>{this.button.style.transform=a,this.button.style.boxShadow=s},this.handleMouseLeave=()=>{this.button.style.transform=o,this.button.style.boxShadow=r},this.handleMouseDown=()=>{this.button.style.transform=l},this.handleMouseUp=()=>{this.button.style.transform=a},this.options={position:null!==(e=t.position)&&void 0!==e?e:i.position,icon:null!==(n=t.icon)&&void 0!==n?n:i.icon,customSvg:null!==(c=t.customSvg)&&void 0!==c?c:i.customSvg,backgroundColor:null!==(d=t.backgroundColor)&&void 0!==d?d:i.backgroundColor,size:null!==(h=t.size)&&void 0!==h?h:i.size,offset:null!==(u=t.offset)&&void 0!==u?u:i.offset,zIndex:null!==(p=t.zIndex)&&void 0!==p?p:i.zIndex,tooltip:null!==(g=t.tooltip)&&void 0!==g?g:i.tooltip},this.button=this.createButton(),document.body?document.body.appendChild(this.button):document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(this.button)})}createButton(){const t=document.createElement("button");return this.options.customSvg?t.innerHTML=this.options.customSvg:"svg"===this.options.icon?t.innerHTML=n:t.textContent=this.options.icon,t.setAttribute("aria-label",this.options.tooltip),t.setAttribute("title",this.options.tooltip),t.setAttribute("data-bugspotter-exclude","true"),t.style.cssText=this.getButtonStyles(),this.addHoverEffects(t),t}getButtonStyles(){const{position:t,size:e,offset:n,backgroundColor:i,zIndex:s}=this.options;return`\n position: fixed;\n ${this.getPositionStyles(t,n)}\n width: ${e}px;\n height: ${e}px;\n border-radius: 50%;\n background: ${i};\n color: white;\n border: none;\n cursor: pointer;\n font-size: ${.5*e}px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: ${this.options.customSvg||"svg"===this.options.icon?.25*e:0}px;\n box-shadow: ${r};\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n z-index: ${s};\n `}getPositionStyles(t,e){switch(t){case"bottom-right":default:return`bottom: ${e.y}px; right: ${e.x}px;`;case"bottom-left":return`bottom: ${e.y}px; left: ${e.x}px;`;case"top-right":return`top: ${e.y}px; right: ${e.x}px;`;case"top-left":return`top: ${e.y}px; left: ${e.x}px;`}}addHoverEffects(t){const e={mouseenter:this.handleMouseEnter,mouseleave:this.handleMouseLeave,mousedown:this.handleMouseDown,mouseup:this.handleMouseUp};Object.entries(e).forEach(([e,n])=>{t.addEventListener(e,n),this.eventHandlers.set(e,n)})}onClick(t){this.button.addEventListener("click",t)}show(){this.button.style.display="flex"}hide(){this.button.style.display="none"}setIcon(t){this.options.icon=t,"svg"===t?this.button.innerHTML=n:this.button.textContent=t}setBackgroundColor(t){this.button.style.backgroundColor=t}destroy(){this.eventHandlers.forEach((t,e)=>{this.button.removeEventListener(e,t)}),this.eventHandlers.clear(),this.button.remove()}}class d{constructor(t={}){this.SPACING={xs:8,sm:12,md:16,lg:20},this.BREAKPOINTS={tablet:768,mobile:480},this.MODAL_SIZES={desktop:"600px",tablet:"500px",mobilePercent:"98%",headerHeight:"30px"},this.FONT_SIZES={h2:"20px",h2Mobile:"18px",label:"14px",labelMobile:"13px",body:"14px",small:"12px",sr:"13px"},this.BORDER_STYLES={primary:"1px solid #e0e0e0",light:"1px solid #ddd"},this.SHADOW_STYLES={modal:"0 4px 6px rgba(0, 0, 0, 0.1)"},this.config={primaryColor:t.primaryColor||"#007bff",dangerColor:t.dangerColor||"#dc3545",borderRadius:t.borderRadius||"4px",fontFamily:t.fontFamily||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',zIndex:t.zIndex||999999}}generateStyles(){return`\n ${this.generateOverlayStyles()}\n ${this.generateModalStyles()}\n ${this.generateHeaderStyles()}\n ${this.generateBodyStyles()}\n ${this.generateFormStyles()}\n ${this.generateButtonStyles()}\n ${this.generatePIIStyles()}\n ${this.generateLoadingStyles()}\n ${this.generateAccessibilityStyles()}\n ${this.generateTabletResponsiveStyles()}\n ${this.generateMobileResponsiveStyles()}\n `}generateOverlayStyles(){return`\n .overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: ${this.config.zIndex};\n font-family: ${this.config.fontFamily};\n }\n `}generateModalStyles(){return`\n .modal {\n background: white;\n border-radius: 8px;\n width: 90%;\n max-width: ${this.MODAL_SIZES.desktop};\n max-height: 90vh;\n overflow-y: auto;\n box-shadow: ${this.SHADOW_STYLES.modal};\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n \n .modal::-webkit-scrollbar {\n display: none;\n }\n `}generateHeaderStyles(){return`\n .header {\n padding: ${this.SPACING.lg}px;\n border-bottom: ${this.BORDER_STYLES.primary};\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n \n .header h2 {\n margin: 0;\n font-size: ${this.FONT_SIZES.h2};\n font-weight: 600;\n }\n \n .close {\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n color: #666;\n padding: 0;\n width: ${this.MODAL_SIZES.headerHeight};\n height: ${this.MODAL_SIZES.headerHeight};\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: ${this.config.borderRadius};\n }\n \n .close:hover {\n background: #f0f0f0;\n }\n `}generateBodyStyles(){return`\n .body {\n padding: ${this.SPACING.lg}px;\n }\n `}generateFormStyles(){return`\n .form-group {\n margin-bottom: ${this.SPACING.lg}px;\n }\n \n .label {\n display: block;\n margin-bottom: ${this.SPACING.xs}px;\n font-weight: 500;\n font-size: ${this.FONT_SIZES.label};\n }\n \n .input,\n .textarea {\n width: 100%;\n padding: ${this.SPACING.xs}px;\n border: ${this.BORDER_STYLES.light};\n border-radius: ${this.config.borderRadius};\n font-size: ${this.FONT_SIZES.body};\n font-family: ${this.config.fontFamily};\n box-sizing: border-box;\n }\n \n .input:focus,\n .textarea:focus {\n outline: none;\n border-color: ${this.config.primaryColor};\n }\n \n .textarea {\n min-height: 100px;\n resize: vertical;\n }\n \n .checkbox-group {\n display: flex;\n align-items: center;\n gap: ${this.SPACING.xs}px;\n margin-top: ${this.SPACING.md}px;\n }\n \n .checkbox {\n width: 18px;\n height: 18px;\n cursor: pointer;\n }\n \n .checkbox-label {\n margin: 0;\n font-size: ${this.FONT_SIZES.body};\n cursor: pointer;\n user-select: none;\n }\n \n .error {\n color: ${this.config.dangerColor};\n font-size: ${this.FONT_SIZES.small};\n margin-top: 4px;\n }\n `}generateButtonStyles(){return`\n .footer {\n padding: ${this.SPACING.lg}px;\n border-top: ${this.BORDER_STYLES.primary};\n display: flex;\n justify-content: flex-end;\n gap: ${this.SPACING.xs}px;\n }\n \n .btn {\n padding: ${this.SPACING.xs}px ${this.SPACING.md}px;\n border: none;\n border-radius: ${this.config.borderRadius};\n cursor: pointer;\n font-size: ${this.FONT_SIZES.body};\n font-weight: 500;\n }\n \n .btn-primary {\n background: ${this.config.primaryColor};\n color: white;\n }\n \n .btn-primary:hover {\n opacity: 0.9;\n }\n \n .btn-primary:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n \n .btn-secondary {\n background: #6c757d;\n color: white;\n }\n \n .btn-secondary:hover {\n opacity: 0.9;\n }\n \n .redaction-controls {\n margin-top: ${this.SPACING.xs}px;\n display: flex;\n gap: ${this.SPACING.xs}px;\n }\n \n .btn-redact,\n .btn-clear {\n padding: ${this.SPACING.xs}px ${this.SPACING.md}px;\n border: ${this.BORDER_STYLES.light};\n border-radius: ${this.config.borderRadius};\n background: white;\n cursor: pointer;\n font-size: ${this.FONT_SIZES.body};\n }\n \n .btn-redact:hover,\n .btn-clear:hover {\n background: #f5f5f5;\n }\n \n .btn-redact.active {\n background: ${this.config.primaryColor};\n color: white;\n border-color: ${this.config.primaryColor};\n }\n \n .screenshot-container {\n margin-top: ${this.SPACING.xs}px;\n position: relative;\n }\n \n .screenshot {\n max-width: 100%;\n border: ${this.BORDER_STYLES.light};\n border-radius: ${this.config.borderRadius};\n }\n \n .redaction-canvas {\n position: absolute;\n top: 0;\n left: 0;\n cursor: crosshair;\n border: 2px solid ${this.config.primaryColor};\n border-radius: ${this.config.borderRadius};\n }\n `}generatePIIStyles(){return`\n .pii-section {\n margin-top: ${this.SPACING.lg}px;\n padding: ${this.SPACING.md}px;\n background: #fff3cd;\n border: 1px solid #ffc107;\n border-radius: ${this.config.borderRadius};\n }\n \n .pii-title {\n margin: 0 0 ${this.SPACING.xs}px 0;\n font-size: ${this.FONT_SIZES.body};\n font-weight: 600;\n color: #856404;\n }\n \n .pii-list {\n margin: 0;\n padding-left: 20px;\n font-size: ${this.FONT_SIZES.sr};\n color: #856404;\n }\n \n .pii-badge {\n display: inline-block;\n padding: 2px 8px;\n margin: 2px;\n background: #ffc107;\n color: #856404;\n border-radius: 12px;\n font-size: ${this.FONT_SIZES.small};\n font-weight: 500;\n }\n `}generateLoadingStyles(){return"\n .btn.loading {\n position: relative;\n padding-left: 2.5rem;\n }\n \n .btn.loading::after {\n content: '';\n position: absolute;\n width: 16px;\n height: 16px;\n top: 50%;\n left: 1rem;\n margin-top: -8px;\n border: 2px solid transparent;\n border-top-color: currentColor;\n border-radius: 50%;\n animation: spinner 0.6s linear infinite;\n }\n \n @keyframes spinner {\n to { transform: rotate(360deg); }\n }\n "}generateAccessibilityStyles(){return"\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n }\n "}generateTabletResponsiveStyles(){return`\n @media (max-width: ${this.BREAKPOINTS.tablet}px) {\n .modal {\n width: 95%;\n max-width: ${this.MODAL_SIZES.tablet};\n }\n \n .header {\n padding: ${this.SPACING.md}px;\n }\n \n .body {\n padding: ${this.SPACING.md}px;\n }\n \n .footer {\n padding: ${this.SPACING.md}px;\n }\n \n /* Prevent iOS zoom on input focus (requires 16px minimum) */\n .input,\n .textarea {\n padding: ${this.SPACING.xs}px;\n font-size: 16px;\n }\n \n .textarea {\n min-height: 80px;\n }\n }\n `}generateMobileResponsiveStyles(){return`\n @media (max-width: ${this.BREAKPOINTS.mobile}px) {\n .modal {\n width: ${this.MODAL_SIZES.mobilePercent};\n max-width: 100%;\n max-height: 95vh;\n }\n \n .header {\n padding: ${this.SPACING.sm}px;\n }\n \n .header h2 {\n font-size: ${this.FONT_SIZES.h2Mobile};\n }\n \n .body {\n padding: ${this.SPACING.sm}px;\n }\n \n .footer {\n padding: ${this.SPACING.sm}px;\n flex-direction: column;\n }\n \n .btn {\n width: 100%;\n padding: ${this.SPACING.md}px;\n }\n \n .input,\n .textarea {\n padding: ${this.SPACING.xs}px;\n }\n \n .textarea {\n resize: none;\n }\n \n .redaction-controls {\n flex-direction: column;\n }\n \n .btn-redact,\n .btn-clear {\n width: 100%;\n }\n \n .pii-section {\n padding: ${this.SPACING.sm}px;\n margin-top: ${this.SPACING.md}px;\n }\n \n .label {\n font-size: ${this.FONT_SIZES.labelMobile};\n }\n \n .close {\n width: 28px;\n height: 28px;\n font-size: 20px;\n }\n }\n `}injectStyles(){const t=document.createElement("style");return t.textContent=this.generateStyles(),document.head.appendChild(t),t}removeStyles(t){t&&t.parentNode&&t.parentNode.removeChild(t)}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class h{constructor(t={}){this.config={title:t.title||"Report a Bug",titlePlaceholder:t.titlePlaceholder||"Brief description of the issue",descriptionPlaceholder:t.descriptionPlaceholder||"Detailed description of what happened...",submitButtonText:t.submitButtonText||"Submit Bug Report",cancelButtonText:t.cancelButtonText||"Cancel",showScreenshot:!1!==t.showScreenshot}}generateModalHTML(t){return`\n <div class="overlay">\n <div class="modal">\n ${this.generateHeader()}\n ${this.generateBody(t)}\n ${this.generateFooter()}\n <div role="status" aria-live="polite" aria-atomic="true" class="sr-only" id="progress-status"></div>\n </div>\n </div>\n `}generateHeader(){return`\n <div class="header">\n <h2>${this.escapeHtml(this.config.title)}</h2>\n <button class="close" aria-label="Close">×</button>\n </div>\n `}generateBody(t){return`\n <div class="body">\n <form class="form">\n ${this.generateTitleField()}\n ${this.generateDescriptionField()}\n ${this.config.showScreenshot&&t?this.generateScreenshotSection(t):""}\n ${this.generatePIISection()}\n </form>\n </div>\n `}generateTitleField(){return`\n <div class="form-group">\n <label class="label" for="title">Title *</label>\n <input\n type="text"\n id="title"\n class="input"\n placeholder="${this.escapeHtml(this.config.titlePlaceholder)}"\n required\n />\n <div class="error" id="title-error"></div>\n </div>\n `}generateDescriptionField(){return`\n <div class="form-group">\n <label class="label" for="description">Description *</label>\n <textarea\n id="description"\n class="textarea"\n placeholder="${this.escapeHtml(this.config.descriptionPlaceholder)}"\n required\n ></textarea>\n <div class="error" id="description-error"></div>\n </div>\n `}generateScreenshotSection(t){return`\n <div class="form-group">\n <label class="label">Screenshot</label>\n <div class="screenshot-container">\n <img \n src="${t}" \n alt="Bug screenshot" \n class="screenshot"\n id="screenshot"\n />\n <canvas \n class="redaction-canvas" \n id="redaction-canvas"\n style="display: none;"\n ></canvas>\n </div>\n <div class="redaction-controls">\n <button \n type="button" \n class="btn-redact" \n id="btn-redact"\n >\n ✏️ Redact Area\n </button>\n <button \n type="button" \n class="btn-clear" \n id="btn-clear"\n >\n 🗑️ Clear Redactions\n </button>\n </div>\n </div>\n `}generatePIISection(){return'\n <div class="pii-section" id="pii-section" style="display: none;">\n <h3 class="pii-title">⚠️ Potential PII Detected</h3>\n <div id="pii-content"></div>\n <div class="checkbox-group">\n <input \n type="checkbox" \n id="pii-confirm" \n class="checkbox"\n />\n <label for="pii-confirm" class="checkbox-label">\n I have reviewed and redacted sensitive information\n </label>\n </div>\n </div>\n '}generateFooter(){return`\n <div class="footer">\n <div class="error" id="submit-error" style="display: none;"></div>\n <button type="button" class="btn btn-secondary" id="btn-cancel">\n ${this.escapeHtml(this.config.cancelButtonText)}\n </button>\n <button type="submit" class="btn btn-primary submit" id="btn-submit">\n ${this.escapeHtml(this.config.submitButtonText)}\n </button>\n </div>\n `}generatePIIBadge(t,e){return`<span class="bugspotter-pii-badge">${this.escapeHtml(t)}: ${e}</span>`}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class u{constructor(){this.elements=null,this.container=null}initialize(t){this.container=t;const e=this.getRequiredElement(".overlay",t),n=this.getRequiredElement(".modal",e),i=this.getRequiredElement(".form",n);return this.elements={overlay:e,modal:n,closeButton:this.getRequiredElement(".close",n),form:i,titleInput:this.getRequiredElement("#title",i),titleError:this.getRequiredElement("#title-error",i),descriptionTextarea:this.getRequiredElement("#description",i),descriptionError:this.getRequiredElement("#description-error",i),screenshotImg:this.getOptionalElement("#screenshot",n),redactionCanvas:this.getOptionalElement("#redaction-canvas",n),redactButton:this.getOptionalElement("#btn-redact",n),clearButton:this.getOptionalElement("#btn-clear",n),piiSection:this.getRequiredElement("#pii-section",n),piiContent:this.getRequiredElement("#pii-content",n),piiConfirmCheckbox:this.getRequiredElement("#pii-confirm",n),submitError:this.getRequiredElement("#submit-error",n),cancelButton:this.getRequiredElement("#btn-cancel",n),submitButton:this.getRequiredElement("#btn-submit",n),progressStatus:this.getRequiredElement("#progress-status",n)},this.elements}get(){if(!this.elements)throw new Error("DOMElementCache not initialized. Call initialize() first.");return this.elements}isInitialized(){return null!==this.elements}clear(){this.elements=null,this.container=null}getRequiredElement(t,e){const n=(e||this.container||document).querySelector(t);if(!n)throw new Error(`Required element not found: ${t}`);return n}getOptionalElement(t,e){return(e||this.container||document).querySelector(t)||void 0}refreshElement(t,e){if(!this.elements||!this.container)throw new Error("DOMElementCache not initialized");const n=this.container.querySelector(e);n&&(this.elements[t]=n)}getContainer(){return this.container}}class p{constructor(t={}){this.minTitleLength=t.minTitleLength||3,this.maxTitleLength=t.maxTitleLength||200,this.minDescriptionLength=t.minDescriptionLength||10,this.maxDescriptionLength=t.maxDescriptionLength||5e3}validate(t){const e={},n=this.validateTitle(t.title);n&&(e.title=n);const i=this.validateDescription(t.description);return i&&(e.description=i),t.piiDetected&&!t.piiConfirmed&&(e.piiConfirmation="Please confirm you have reviewed sensitive information"),{isValid:0===Object.keys(e).length,errors:e}}validateTitle(t){const e=t.trim();return e?e.length<this.minTitleLength?`Title must be at least ${this.minTitleLength} characters`:e.length>this.maxTitleLength?`Title must not exceed ${this.maxTitleLength} characters`:null:"Title is required"}validateDescription(t){if(!t)return null;const e=t.trim();return 0===e.length?"Description cannot be only whitespace":e.length<this.minDescriptionLength?`Description must be at least ${this.minDescriptionLength} characters`:e.length>this.maxDescriptionLength?`Description must not exceed ${this.maxDescriptionLength} characters`:null}validateField(t,e,n){switch(t){case"title":return this.validateTitle(e);case"description":return this.validateDescription(e);case"piiConfirmed":return(null==n?void 0:n.piiDetected)&&!e?"Please confirm you have reviewed sensitive information":null;default:return null}}isEmpty(t){return!t||0===t.trim().length}sanitizeInput(t){return t.trim()}getConfig(){return{minTitleLength:this.minTitleLength,maxTitleLength:this.maxTitleLength,minDescriptionLength:this.minDescriptionLength,maxDescriptionLength:this.maxDescriptionLength}}}class g{constructor(t={}){this.config={showExamples:!1!==t.showExamples,groupByType:!1!==t.groupByType,maxExamplesPerType:t.maxExamplesPerType||3}}render(t,e){t&&0!==t.length?this.config.groupByType?e.innerHTML=this.renderGroupedPII(t):e.innerHTML=this.renderListPII(t):e.innerHTML=""}renderGroupedPII(t){const e=this.groupByType(t),n=[];for(const[t,i]of Object.entries(e)){const e=i.reduce((t,e)=>t+e.count,0);n.push(this.createBadge(t,e))}let i=`<div class="bugspotter-pii-badges">${n.join("")}</div>`;if(this.config.showExamples){i+='<div class="bugspotter-pii-details">',i+='<p style="margin: 10px 0 5px 0; font-size: 13px; color: #856404;">Detected types:</p>',i+='<ul class="bugspotter-pii-list">';for(const[t,n]of Object.entries(e)){const e=n.reduce((t,e)=>t+e.count,0);i+=`<li><strong>${this.escapeHtml(t)}:</strong> ${e} occurrence${1!==e?"s":""}</li>`}i+="</ul></div>"}return i}renderListPII(t){let e='<ul class="bugspotter-pii-list">';for(const n of t)e+=`<li>${this.escapeHtml(n.type)}: ${n.count} occurrence${1!==n.count?"s":""}</li>`;return e+="</ul>",e}createBadge(t,e){return`<span class="bugspotter-pii-badge">${this.escapeHtml(t)}: ${e}</span>`}groupByType(t){const e={};for(const n of t)e[n.type]||(e[n.type]=[]),e[n.type].push(n);return e}getSummary(t){const e=new Set;for(const n of t)e.add(n.type);return{totalCount:t.length,typeCount:e.size,types:Array.from(e)}}hasType(t,e){return t.some(t=>t.type===e)}filterByType(t,e){return t.filter(t=>t.type===e)}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class m{constructor(t,e={}){this.isDrawing=!1,this.isRedactionMode=!1,this.startX=0,this.startY=0,this.redactionRects=[],this.canvas=t;const n=t.getContext("2d");if(!n)throw new Error("Failed to get 2D context from canvas");this.ctx=n,this.config={redactionColor:e.redactionColor||"#000000",cursorStyle:e.cursorStyle||"crosshair"},this.handleMouseDown=this.onMouseDown.bind(this),this.handleMouseMove=this.onMouseMove.bind(this),this.handleMouseUp=this.onMouseUp.bind(this)}initializeCanvas(t){const e=()=>{const e=t.getBoundingClientRect(),n=e.width||t.width,i=e.height||t.height;this.canvas.width=t.naturalWidth||t.width,this.canvas.height=t.naturalHeight||t.height,this.canvas.style.width=`${n}px`,this.canvas.style.height=`${i}px`};t.complete&&t.naturalWidth>0?e():t.addEventListener("load",e,{once:!0})}enableRedactionMode(){this.isRedactionMode||(this.isRedactionMode=!0,this.canvas.style.display="block",this.canvas.style.cursor=this.config.cursorStyle,this.canvas.addEventListener("mousedown",this.handleMouseDown),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseup",this.handleMouseUp),this.redraw())}disableRedactionMode(){this.isRedactionMode&&(this.isRedactionMode=!1,this.isDrawing=!1,this.canvas.removeEventListener("mousedown",this.handleMouseDown),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseup",this.handleMouseUp),this.canvas.style.cursor="default")}toggleRedactionMode(){return this.isRedactionMode?this.disableRedactionMode():this.enableRedactionMode(),this.isRedactionMode}clearRedactions(){this.redactionRects=[],this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}getRedactions(){return[...this.redactionRects]}setRedactions(t){this.redactionRects=[...t],this.redraw()}isActive(){return this.isRedactionMode}getCanvas(){return this.canvas}toDataURL(t="image/png",e){return this.canvas.toDataURL(t,e)}hide(){this.canvas.style.display="none"}show(){this.canvas.style.display="block"}destroy(){this.disableRedactionMode(),this.clearRedactions()}onMouseDown(t){if(!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height;this.startX=(t.clientX-e.left)*n,this.startY=(t.clientY-e.top)*i,this.isDrawing=!0}onMouseMove(t){if(!this.isDrawing||!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height,r=(t.clientX-e.left)*n,s=(t.clientY-e.top)*i;this.redraw(),this.drawRect(this.startX,this.startY,r-this.startX,s-this.startY)}onMouseUp(t){if(!this.isDrawing||!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height,r=(t.clientX-e.left)*n,s=(t.clientY-e.top)*i,o=r-this.startX,a=s-this.startY;Math.abs(o)>5&&Math.abs(a)>5&&this.redactionRects.push({x:this.startX,y:this.startY,width:o,height:a}),this.isDrawing=!1,this.redraw()}redraw(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.redactionRects)this.drawRect(t.x,t.y,t.width,t.height)}drawRect(t,e,n,i){this.ctx.fillStyle=this.config.redactionColor,this.ctx.fillRect(t,e,n,i)}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t),this.isRedactionMode&&(this.canvas.style.cursor=this.config.cursorStyle)}getConfig(){return Object.assign({},this.config)}}class f{async mergeRedactions(t,e){return new Promise((n,i)=>{const r=new Image;r.onload=()=>{try{const t=document.createElement("canvas");t.width=r.naturalWidth||r.width,t.height=r.naturalHeight||r.height;const s=t.getContext("2d");if(!s)return void i(new Error("Failed to get canvas context"));s.drawImage(r,0,0),s.drawImage(e,0,0),n(t.toDataURL())}catch(t){i(t)}},r.onerror=()=>{i(new Error("Failed to load screenshot image"))},r.src=t})}async applyRedactions(t,e,n="#000000"){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{const t=document.createElement("canvas");t.width=s.naturalWidth||s.width,t.height=s.naturalHeight||s.height;const o=t.getContext("2d");if(!o)return void r(new Error("Failed to get canvas context"));o.drawImage(s,0,0),o.fillStyle=n;for(const t of e)o.fillRect(t.x,t.y,t.width,t.height);i(t.toDataURL())}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async resize(t,e,n){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{let t=s.naturalWidth||s.width,o=s.naturalHeight||s.height;if(t>e||o>n){const i=t/o;t>o?(t=e,o=t/i):(o=n,t=o*i)}const a=document.createElement("canvas");a.width=t,a.height=o;const l=a.getContext("2d");if(!l)return void r(new Error("Failed to get canvas context"));l.drawImage(s,0,0,t,o),i(a.toDataURL())}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async convert(t,e,n=.92){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{const t=document.createElement("canvas");t.width=s.naturalWidth||s.width,t.height=s.naturalHeight||s.height;const o=t.getContext("2d");if(!o)return void r(new Error("Failed to get canvas context"));o.drawImage(s,0,0),i(t.toDataURL(e,n))}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async getDimensions(t){return new Promise((e,n)=>{const i=new Image;i.onload=()=>{e({width:i.naturalWidth||i.width,height:i.naturalHeight||i.height})},i.onerror=()=>{n(new Error("Failed to load image"))},i.src=t})}isValidDataURL(t){return/^data:image\/(png|jpeg|jpg|webp|gif);base64,/.test(t)}getEstimatedSize(t){const e=t.split(",")[1]||"";return Math.ceil(3*e.length/4)}getFormat(t){const e=t.match(/^data:image\/([a-z]+);base64,/);return e?e[1]:null}}const y={email:{name:"email",regex:/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,description:"Email addresses",examples:["user@example.com","john.doe+tag@company.co.uk","test_user@sub.domain.com"],priority:1},creditcard:{name:"creditcard",regex:/\b(?:\d{4}[-\s]){3}\d{4}\b|\b\d{4}[-\s]\d{6}[-\s]\d{5}\b|\b\d{13,19}\b/g,description:"Credit card numbers (Visa, MC, Amex, Discover, etc.)",examples:["4532-1488-0343-6467","4532148803436467","5425 2334 3010 9903","3782 822463 10005"],priority:2},ssn:{name:"ssn",regex:/\b\d{3}-\d{2}-\d{4}\b|\b(?<!\d)\d{9}(?!\d)\b/g,description:"US Social Security Numbers",examples:["123-45-6789","987654321"],priority:3},iin:{name:"iin",regex:/\b[0-9]{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12][0-9]|3[01])\d{6}\b/g,description:"Kazakhstan IIN/BIN (12 digits with date validation)",examples:["950315300123","880612500456","021225123456"],priority:4},ip:{name:"ip",regex:/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\b/g,description:"IPv4 and IPv6 addresses",examples:["192.168.1.100","127.0.0.1","2001:0db8:85a3:0000:0000:8a2e:0370:7334"],priority:5},phone:{name:"phone",regex:/\+\d{1,3}[-.\s]\d{3}[-.\s]\d{4}\b|\+\d{1,3}[-.\s]\d{3}[-.\s]\d{3}[-.\s]\d{4}\b|\(\d{3}\)\s*\d{3}[-.\s]\d{4}\b|\b\d{3}[-.\s]\d{3}[-.\s]\d{4}\b/g,description:"International phone numbers",examples:["+1-555-1234","+1-555-123-4567","(555) 123-4567","555-123-4567","+7 777 123 4567"],priority:6},apikey:{name:"apikey",regex:/\b(?:sk|pk)_(?:live|test)_[a-zA-Z0-9]{24,}\b|AIza[a-zA-Z0-9_-]{35}|ya29\.[a-zA-Z0-9_-]+|AKIA[a-zA-Z0-9]{16}\b/g,description:"API keys (Stripe, Google, AWS, etc.)",examples:["sk_live_abc123def456ghi789jkl","pk_test_xyz789abc123def456","AIzaSyD1234567890abcdefghijklmnopqrst","AKIAIOSFODNN7EXAMPLE"],priority:7},token:{name:"token",regex:/\b(?:Bearer\s+)?[a-zA-Z0-9_-]{32,}\b|ghp_[a-zA-Z0-9]{36}|gho_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9_]{82}/g,description:"Authentication tokens (Bearer, GitHub, JWT-like)",examples:["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9","ghp_abc123def456ghi789jkl012mno345pqr","gho_xyz789abc123def456ghi789jkl012mno"],priority:8},password:{name:"password",regex:/(?:password|passwd|pwd)[\s:=]+[^\s]{6,}|(?:password|passwd|pwd)["']?\s*[:=]\s*["']?[^\s"']{6,}/gi,description:"Password fields in text (password=..., pwd:...)",examples:["password: MySecret123!","passwd=SecurePass456",'pwd: "MyP@ssw0rd"'],priority:9}},b={financial:["creditcard","ssn"],contact:["email","phone"],identification:["ssn","iin"],network:["ip","email"],credentials:["apikey","token","password"],kazakhstan:["iin"]};const w={all:Object.keys(y),minimal:["email","creditcard","ssn"],financial:b.financial,contact:b.contact,identification:b.identification,credentials:b.credentials,kazakhstan:["email","phone","iin"],gdpr:["email","phone","ip"],pci:["creditcard"],security:["email","phone","creditcard","ssn","apikey","token","password"]};class v{constructor(t,e){this.patterns=new Map,this.initializePatterns(t,e)}initializePatterns(t,e){let n;var i;n="string"==typeof t?w[t]:t.filter(t=>"custom"!==t),(i=n.map(t=>y[t]),[...i].sort((t,e)=>t.priority-e.priority)).forEach(t=>{this.patterns.set(t.name,t.regex)}),e.forEach(t=>{this.patterns.set(t.name,t.regex)})}getPatterns(){return this.patterns}}class I{constructor(t){this.patterns=t}sanitize(t){if("string"!=typeof t)return t;let e=t;return this.patterns.forEach((t,n)=>{const i=n.toUpperCase();e=e.replace(t,`[REDACTED-${i}]`)}),e}}class C{constructor(t){this.stringSanitizer=t}sanitize(t){return null==t?t:"string"==typeof t?this.stringSanitizer.sanitize(t):Array.isArray(t)?t.map(t=>this.sanitize(t)):"object"==typeof t?this.sanitizeObject(t):t}sanitizeObject(t){const e={};for(const[n,i]of Object.entries(t))e[this.stringSanitizer.sanitize(n)]=this.sanitize(i);return e}}class S{constructor(t){this.excludeSelectors=t}shouldExclude(t){return!(!t||!this.excludeSelectors.length)&&this.excludeSelectors.some(e=>{try{return t.matches(e)}catch(t){return!1}})}}class _{constructor(t){var e,n,i,r;if(this.enabled=null===(e=t.enabled)||void 0===e||e,!this.enabled)return this.stringSanitizer=new I(new Map),this.valueSanitizer=new C(this.stringSanitizer),void(this.elementMatcher=new S([]));const s=null!==(n=t.patterns)&&void 0!==n?n:"all",o=null!==(i=t.customPatterns)&&void 0!==i?i:[],a=null!==(r=t.excludeSelectors)&&void 0!==r?r:[],l=new v(s,o);this.stringSanitizer=new I(l.getPatterns()),this.valueSanitizer=new C(this.stringSanitizer),this.elementMatcher=new S(a)}guardDisabled(t){return this.enabled?void 0:t}sanitize(t){const e=this.guardDisabled(t);return void 0!==e?e:this.valueSanitizer.sanitize(t)}sanitizeConsoleArgs(t){const e=this.guardDisabled(t);return void 0!==e?e:t.map(t=>this.sanitize(t))}sanitizeNetworkData(t){const e=this.guardDisabled(t);return void 0!==e?e:this.sanitize(t)}sanitizeError(t){const e=this.guardDisabled(t);return void 0!==e?e:this.sanitize(t)}shouldExclude(t){return!!this.enabled&&this.elementMatcher.shouldExclude(t)}sanitizeTextNode(t,e){const n=this.guardDisabled(t);return void 0!==n?n:this.elementMatcher.shouldExclude(e)?t:this.stringSanitizer.sanitize(t)}detectPII(t){const e=new Map;if(!this.enabled||!t)return e;for(const[n,i]of this.stringSanitizer.patterns){const r=t.match(new RegExp(i,"g"));r&&r.length>0&&e.set(n,r.length)}return e}}function k(t){return new _(t)}const x={debug:0,log:1,warn:2,error:3,none:4};const A=new class{constructor(t={}){var e,n,i;this.enabled=null===(e=t.enabled)||void 0===e||e,this.level=null!==(n=t.level)&&void 0!==n?n:"log",this.prefix=null!==(i=t.prefix)&&void 0!==i?i:"[BugSpotter]"}shouldLog(t){return!!this.enabled&&x[t]>=x[this.level]}formatMessage(t){return this.prefix?`${this.prefix} ${t}`:t}debug(t,...e){this.shouldLog("debug")&&console.debug(this.formatMessage(t),...e)}log(t,...e){this.shouldLog("log")&&console.log(this.formatMessage(t),...e)}warn(t,...e){this.shouldLog("warn")&&console.warn(this.formatMessage(t),...e)}error(t,...e){this.shouldLog("error")&&console.error(this.formatMessage(t),...e)}configure(t){void 0!==t.enabled&&(this.enabled=t.enabled),void 0!==t.level&&(this.level=t.level),void 0!==t.prefix&&(this.prefix=t.prefix)}};function E(){return A}const R=E();class M{constructor(t){this.redactionCanvas=null,this.originalScreenshot="",this.piiDetections=[],this.options=t,this.container=document.createElement("div"),this.shadow=this.container.attachShadow({mode:"open"}),this.styleManager=new d,this.templateManager=new h,this.domCache=new u,this.validator=new p,this.piiDisplay=new g,this.screenshotProcessor=new f,this.handleEscapeKey=this.onEscapeKey.bind(this)}show(t){t&&(this.originalScreenshot=t),this.shadow.innerHTML=`\n <style>\n ${this.styleManager.generateStyles()}\n </style>\n ${this.templateManager.generateModalHTML(this.originalScreenshot)}\n `,this.domCache.initialize(this.shadow);const e=this.domCache.get();e.titleError.style.display="none",e.descriptionError.style.display="none",e.submitError.style.display="none",e.progressStatus.textContent="",this.setupRedactionCanvas(),this.attachEventListeners(),document.body.appendChild(this.container),e.titleInput.focus()}close(){document.removeEventListener("keydown",this.handleEscapeKey),this.redactionCanvas&&(this.redactionCanvas.destroy(),this.redactionCanvas=null),this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.domCache.clear(),this.options.onClose&&this.options.onClose()}destroy(){this.close()}setupRedactionCanvas(){const t=this.domCache.get();if(t.redactionCanvas&&t.screenshotImg)try{this.redactionCanvas=new m(t.redactionCanvas),this.redactionCanvas.initializeCanvas(t.screenshotImg)}catch(t){E().warn("Canvas redaction not available:",t),this.redactionCanvas=null}}attachEventListeners(){const t=this.domCache.get();t.closeButton.addEventListener("click",()=>this.close()),document.addEventListener("keydown",this.handleEscapeKey),t.form.addEventListener("submit",t=>this.handleSubmit(t)),t.submitButton.addEventListener("click",()=>{const e=new Event("submit",{bubbles:!0,cancelable:!0});t.form.dispatchEvent(e)}),t.cancelButton.addEventListener("click",()=>this.close()),t.titleInput.addEventListener("input",()=>this.validateField("title")),t.descriptionTextarea.addEventListener("input",()=>{this.validateField("description"),this.checkForPII()}),t.redactButton&&this.redactionCanvas&&t.redactButton.addEventListener("click",()=>this.toggleRedactionMode()),t.clearButton&&this.redactionCanvas&&t.clearButton.addEventListener("click",()=>this.clearRedactions()),t.piiConfirmCheckbox.addEventListener("change",()=>this.updateSubmitButton())}validateField(t){const e=this.domCache.get(),n="title"===t?e.titleInput.value:e.descriptionTextarea.value,i=this.validator.validateField(t,n),r="title"===t?e.titleError:e.descriptionError;i?(r.textContent=i,r.style.display="block"):(r.textContent="",r.style.display="none")}checkForPII(){const t=this.domCache.get(),e=`${t.titleInput.value} ${t.descriptionTextarea.value}`,n=k({enabled:!0}).detectPII(e);this.piiDetections=Array.from(n.entries()).map(([t,e])=>({type:t,count:e})),this.piiDetections.length>0?(t.piiSection.style.display="block",this.piiDisplay.render(this.piiDetections,t.piiContent)):(t.piiSection.style.display="none",t.piiConfirmCheckbox.checked=!1),this.updateSubmitButton()}updateSubmitButton(){const t=this.domCache.get(),e=this.piiDetections.length>0,n=t.piiConfirmCheckbox.checked;t.submitButton.disabled=e&&!n}toggleRedactionMode(){const t=this.domCache.get();this.redactionCanvas&&t.redactButton&&(this.redactionCanvas.toggleRedactionMode()?(t.redactButton.classList.add("active"),t.redactButton.textContent="✓ Redacting..."):(t.redactButton.classList.remove("active"),t.redactButton.textContent="✏️ Redact Area"))}clearRedactions(){this.redactionCanvas&&this.redactionCanvas.clearRedactions()}async handleSubmit(t){var e;t.preventDefault();const n=this.domCache.get();if(n.submitButton.disabled)return;const i={title:n.titleInput.value,description:n.descriptionTextarea.value,piiDetected:this.piiDetections.length>0,piiConfirmed:n.piiConfirmCheckbox.checked},r=this.validator.validate(i);if(!r.isValid)return r.errors.title?(n.titleError.textContent=r.errors.title,n.titleError.style.display="block"):(n.titleError.textContent="",n.titleError.style.display="none"),r.errors.description?(n.descriptionError.textContent=r.errors.description,n.descriptionError.style.display="block"):(n.descriptionError.textContent="",n.descriptionError.style.display="none"),void(r.errors.piiConfirmation&&alert(r.errors.piiConfirmation));n.titleError.style.display="none",n.descriptionError.style.display="none",n.submitError.style.display="none";const s=n.submitButton.textContent||"Submit Bug Report";n.submitButton.disabled=!0,n.submitButton.textContent="Preparing...",n.submitButton.classList.add("loading");const o=t=>{n.submitButton.textContent=t,n.progressStatus.textContent=t,this.options.onProgress&&this.options.onProgress(t)};o("Preparing screenshot...");let a=this.originalScreenshot;if(this.redactionCanvas&&this.redactionCanvas.getRedactions().length>0)try{a=await this.screenshotProcessor.mergeRedactions(this.originalScreenshot,this.redactionCanvas.getCanvas())}catch(t){R.error("Failed to merge redactions:",t),a=this.originalScreenshot}this.originalScreenshot=a;const l={title:i.title.trim(),description:null===(e=i.description)||void 0===e?void 0:e.trim()};try{o("Uploading report..."),await this.options.onSubmit(l),this.close()}catch(t){E().error("Error submitting bug report:",t),n.submitError.textContent="Failed to submit bug report. Please try again.",n.submitError.style.display="block",n.progressStatus.textContent="",n.submitButton.disabled=!1,n.submitButton.textContent=s,n.submitButton.classList.remove("loading")}}getScreenshot(){return this.originalScreenshot}onEscapeKey(t){"Escape"===t.key&&this.close()}}const T=E();class O extends Error{constructor(t,e){super(`Invalid endpoint URL: ${t}. ${e}`),this.endpoint=t,this.reason=e,this.name="InvalidEndpointError"}}function z(t){if(!t)throw new O("","No endpoint configured");try{const e=new URL(t),n=function(t){const e=t.lastIndexOf("/api/v1/reports");return-1!==e?t.substring(0,e):t.replace(/\/$/,"")||""}(e.pathname);return e.origin+n}catch(e){const n=e instanceof Error?e.message:String(e);throw T.error("Invalid endpoint URL - must be a valid absolute URL",{endpoint:t,error:n}),new O(t,"Must be a valid absolute URL (e.g., https://api.example.com/api/v1/reports)")}}const N=(()=>{let t=0;return()=>(t+=1,`u${`0000${(Math.random()*36**4|0).toString(36)}`.slice(-4)}${t}`)})();function L(t){const e=[];for(let n=0,i=t.length;n<i;n++)e.push(t[n]);return e}let F=null;function D(t={}){return F||(t.includeStyleProperties?(F=t.includeStyleProperties,F):(F=L(window.getComputedStyle(document.documentElement)),F))}function B(t,e){const n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function U(t,e={}){return{width:e.width||function(t){const e=B(t,"border-left-width"),n=B(t,"border-right-width");return t.clientWidth+e+n}(t),height:e.height||function(t){const e=B(t,"border-top-width"),n=B(t,"border-bottom-width");return t.clientHeight+e+n}(t)}}const Z=16384;function P(t){return new Promise((e,n)=>{const i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>e(i))})},i.onerror=n,i.crossOrigin="anonymous",i.decoding="async",i.src=t})}const $=(t,e)=>{if(t instanceof e)return!0;const n=Object.getPrototypeOf(t);return null!==n&&(n.constructor.name===e.name||$(n,e))};function G(t,e,n,i){const r=window.getComputedStyle(t,n),s=r.getPropertyValue("content");if(""===s||"none"===s)return;const o=N();try{e.className=`${e.className} ${o}`}catch(t){return}const a=document.createElement("style");a.appendChild(function(t,e,n,i){const r=`.${t}:${e}`,s=n.cssText?function(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}(n):function(t,e){return D(e).map(e=>`${e}: ${t.getPropertyValue(e)}${t.getPropertyPriority(e)?" !important":""};`).join(" ")}(n,i);return document.createTextNode(`${r}{${s}}`)}(o,n,r,i)),e.appendChild(a)}const W="application/font-woff",j="image/jpeg",V={woff:W,woff2:W,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:j,jpeg:j,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function H(t){const e=function(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}(t).toLowerCase();return V[e]||""}function q(t){return-1!==t.search(/^(data:)/)}function K(t,e){return`data:${e};base64,${t}`}async function Y(t,e,n){const i=await fetch(t,e);if(404===i.status)throw new Error(`Resource "${i.url}" not found`);const r=await i.blob();return new Promise((t,e)=>{const s=new FileReader;s.onerror=e,s.onloadend=()=>{try{t(n({res:i,result:s.result}))}catch(t){e(t)}},s.readAsDataURL(r)})}const Q={};async function X(t,e,n){const i=function(t,e,n){let i=t.replace(/\?.*/,"");return n&&(i=t),/ttf|otf|eot|woff2?/i.test(i)&&(i=i.replace(/.*\//,"")),e?`[${e}]${i}`:i}(t,e,n.includeQueryParams);if(null!=Q[i])return Q[i];let r;n.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());try{const i=await Y(t,n.fetchRequestInit,({res:t,result:n})=>(e||(e=t.headers.get("Content-Type")||""),function(t){return t.split(/,/)[1]}(n)));r=K(i,e)}catch(e){r=n.imagePlaceholder||"";let i=`Failed to fetch resource: ${t}`;e&&(i="string"==typeof e?e:e.message),i&&console.warn(i)}return Q[i]=r,r}const J=t=>null!=t.tagName&&"SLOT"===t.tagName.toUpperCase(),tt=t=>null!=t.tagName&&"SVG"===t.tagName.toUpperCase();async function et(t,e,n){return n||!e.filter||e.filter(t)?Promise.resolve(t).then(t=>async function(t,e){return $(t,HTMLCanvasElement)?async function(t){const e=t.toDataURL();return"data:,"===e?t.cloneNode(!1):P(e)}(t):$(t,HTMLVideoElement)?async function(t,e){if(t.currentSrc){const e=document.createElement("canvas"),n=e.getContext("2d");return e.width=t.clientWidth,e.height=t.clientHeight,null==n||n.drawImage(t,0,0,e.width,e.height),P(e.toDataURL())}const n=t.poster,i=H(n);return P(await X(n,i,e))}(t,e):$(t,HTMLIFrameElement)?async function(t,e){var n;try{if(null===(n=null==t?void 0:t.contentDocument)||void 0===n?void 0:n.body)return await et(t.contentDocument.body,e,!0)}catch(t){}return t.cloneNode(!1)}(t,e):t.cloneNode(tt(t))}(t,e)).then(n=>async function(t,e,n){var i,r;if(tt(e))return e;let s=[];return s=J(t)&&t.assignedNodes?L(t.assignedNodes()):$(t,HTMLIFrameElement)&&(null===(i=t.contentDocument)||void 0===i?void 0:i.body)?L(t.contentDocument.body.childNodes):L((null!==(r=t.shadowRoot)&&void 0!==r?r:t).childNodes),0===s.length||$(t,HTMLVideoElement)||await s.reduce((t,i)=>t.then(()=>et(i,n)).then(t=>{t&&e.appendChild(t)}),Promise.resolve()),e}(t,n,e)).then(n=>function(t,e,n){return $(e,Element)&&(function(t,e,n){const i=e.style;if(!i)return;const r=window.getComputedStyle(t);r.cssText?(i.cssText=r.cssText,i.transformOrigin=r.transformOrigin):D(n).forEach(n=>{let s=r.getPropertyValue(n);if("font-size"===n&&s.endsWith("px")){const t=Math.floor(parseFloat(s.substring(0,s.length-2)))-.1;s=`${t}px`}$(t,HTMLIFrameElement)&&"display"===n&&"inline"===s&&(s="block"),"d"===n&&e.getAttribute("d")&&(s=`path(${e.getAttribute("d")})`),i.setProperty(n,s,r.getPropertyPriority(n))})}(t,e,n),function(t,e,n){G(t,e,":before",n),G(t,e,":after",n)}(t,e,n),function(t,e){$(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),$(t,HTMLInputElement)&&e.setAttribute("value",t.value)}(t,e),function(t,e){if($(t,HTMLSelectElement)){const n=e,i=Array.from(n.children).find(e=>t.value===e.getAttribute("value"));i&&i.setAttribute("selected","")}}(t,e)),e}(t,n,e)).then(t=>async function(t,e){const n=t.querySelectorAll?t.querySelectorAll("use"):[];if(0===n.length)return t;const i={};for(let r=0;r<n.length;r++){const s=n[r].getAttribute("xlink:href");if(s){const n=t.querySelector(s),r=document.querySelector(s);n||!r||i[s]||(i[s]=await et(r,e,!0))}}const r=Object.values(i);if(r.length){const e="http://www.w3.org/1999/xhtml",n=document.createElementNS(e,"svg");n.setAttribute("xmlns",e),n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.style.display="none";const i=document.createElementNS(e,"defs");n.appendChild(i);for(let t=0;t<r.length;t++)i.appendChild(r[t]);t.appendChild(n)}return t}(t,e)):null}const nt=/url\((['"]?)([^'"]+?)\1\)/g,it=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,rt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function st(t){return-1!==t.search(nt)}async function ot(t,e,n){if(!st(t))return t;const i=function(t,{preferredFontFormat:e}){return e?t.replace(rt,t=>{for(;;){const[n,,i]=it.exec(t)||[];if(!i)return"";if(i===e)return`src: ${n};`}}):t}(t,n),r=function(t){const e=[];return t.replace(nt,(t,n,i)=>(e.push(i),t)),e.filter(t=>!q(t))}(i);return r.reduce((t,i)=>t.then(t=>async function(t,e,n,i,r){try{const s=n?function(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const n=document.implementation.createHTMLDocument(),i=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(i),n.body.appendChild(r),e&&(i.href=e),r.href=t,r.href}(e,n):e,o=H(e);let a;return a=r?K(await r(s),o):await X(s,o,i),t.replace(function(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}(e),`$1${a}$3`)}catch(t){}return t}(t,i,e,n)),Promise.resolve(i))}async function at(t,e,n){var i;const r=null===(i=e.style)||void 0===i?void 0:i.getPropertyValue(t);if(r){const i=await ot(r,null,n);return e.style.setProperty(t,i,e.style.getPropertyPriority(t)),!0}return!1}async function lt(t,e){$(t,Element)&&(await async function(t,e){await at("background",t,e)||await at("background-image",t,e),await at("mask",t,e)||await at("-webkit-mask",t,e)||await at("mask-image",t,e)||await at("-webkit-mask-image",t,e)}(t,e),await async function(t,e){const n=$(t,HTMLImageElement);if((!n||q(t.src))&&(!$(t,SVGImageElement)||q(t.href.baseVal)))return;const i=n?t.src:t.href.baseVal,r=await X(i,H(i),e);await new Promise((i,s)=>{t.onload=i,t.onerror=e.onImageErrorHandler?(...t)=>{try{i(e.onImageErrorHandler(...t))}catch(t){s(t)}}:s;const o=t;o.decode&&(o.decode=i),"lazy"===o.loading&&(o.loading="eager"),n?(t.srcset="",t.src=r):t.href.baseVal=r})}(t,e),await async function(t,e){const n=L(t.childNodes).map(t=>lt(t,e));await Promise.all(n).then(()=>t)}(t,e))}const ct={};async function dt(t){let e=ct[t];if(null!=e)return e;const n=await fetch(t);return e={url:t,cssText:await n.text()},ct[t]=e,e}async function ht(t,e){let n=t.cssText;const i=/url\(["']?([^"')]+)["']?\)/g,r=(n.match(/url\([^)]+\)/g)||[]).map(async r=>{let s=r.replace(i,"$1");return s.startsWith("https://")||(s=new URL(s,t.url).href),Y(s,e.fetchRequestInit,({result:t})=>(n=n.replace(r,`url(${t})`),[r,t]))});return Promise.all(r).then(()=>n)}function ut(t){if(null==t)return[];const e=[];let n=t.replace(/(\/\*[\s\S]*?\*\/)/gi,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const t=i.exec(n);if(null===t)break;e.push(t[0])}n=n.replace(i,"");const r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let t=r.exec(n);if(null===t){if(t=s.exec(n),null===t)break;r.lastIndex=s.lastIndex}else s.lastIndex=r.lastIndex;e.push(t[0])}return e}function pt(t){return t.trim().replace(/["']/g,"")}async function gt(t,e){const n=await async function(t,e){if(null==t.ownerDocument)throw new Error("Provided element is not within a Document");const n=L(t.ownerDocument.styleSheets),i=await async function(t,e){const n=[],i=[];return t.forEach(n=>{if("cssRules"in n)try{L(n.cssRules||[]).forEach((t,r)=>{if(t.type===CSSRule.IMPORT_RULE){let s=r+1;const o=dt(t.href).then(t=>ht(t,e)).then(t=>ut(t).forEach(t=>{try{n.insertRule(t,t.startsWith("@import")?s+=1:n.cssRules.length)}catch(e){console.error("Error inserting rule from remote css",{rule:t,error:e})}})).catch(t=>{console.error("Error loading remote css",t.toString())});i.push(o)}})}catch(r){const s=t.find(t=>null==t.href)||document.styleSheets[0];null!=n.href&&i.push(dt(n.href).then(t=>ht(t,e)).then(t=>ut(t).forEach(t=>{s.insertRule(t,s.cssRules.length)})).catch(t=>{console.error("Error loading remote stylesheet",t)})),console.error("Error inlining remote css file",r)}}),Promise.all(i).then(()=>(t.forEach(t=>{if("cssRules"in t)try{L(t.cssRules||[]).forEach(t=>{n.push(t)})}catch(e){console.error(`Error while reading CSS rules from ${t.href}`,e)}}),n))}(n,e);return function(t){return t.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>st(t.style.getPropertyValue("src")))}(i)}(t,e),i=function(t){const e=new Set;return function t(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(t=>{e.add(pt(t))}),Array.from(n.children).forEach(e=>{e instanceof HTMLElement&&t(e)})}(t),e}(t);return(await Promise.all(n.filter(t=>i.has(pt(t.style.fontFamily))).map(t=>{const n=t.parentStyleSheet?t.parentStyleSheet.href:null;return ot(t.cssText,n,e)}))).join("\n")}async function mt(t,e={}){const{width:n,height:i}=U(t,e),r=await et(t,e,!0);return await async function(t,e){const n=null!=e.fontEmbedCSS?e.fontEmbedCSS:e.skipFonts?null:await gt(t,e);if(n){const e=document.createElement("style"),i=document.createTextNode(n);e.appendChild(i),t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)}}(r,e),await lt(r,e),function(t,e){const{style:n}=t;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=`${e.width}px`),e.height&&(n.height=`${e.height}px`);const i=e.style;null!=i&&Object.keys(i).forEach(t=>{n[t]=i[t]})}(r,e),await async function(t,e,n){const i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg"),s=document.createElementNS(i,"foreignObject");return r.setAttribute("width",`${e}`),r.setAttribute("height",`${n}`),r.setAttribute("viewBox",`0 0 ${e} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),r.appendChild(s),s.appendChild(t),async function(t){return Promise.resolve().then(()=>(new XMLSerializer).serializeToString(t)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}(r)}(r,n,i)}const ft=E();class yt{constructor(t){this.options=t,this.sanitizer=t.sanitizer}handleError(t,e){const n=e instanceof Error?e:new Error(String(e));ft.error(`${this.constructor.name} ${t}:`,n)}}function bt(t){let e=t.length;for(;--e>=0;)t[e]=0}const wt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),vt=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),It=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ct=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),St=new Array(576);bt(St);const _t=new Array(60);bt(_t);const kt=new Array(512);bt(kt);const xt=new Array(256);bt(xt);const At=new Array(29);bt(At);const Et=new Array(30);function Rt(t,e,n,i,r){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=t&&t.length}let Mt,Tt,Ot;function zt(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}bt(Et);const Nt=t=>t<256?kt[t]:kt[256+(t>>>7)],Lt=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Ft=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,Lt(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},Dt=(t,e,n)=>{Ft(t,n[2*e],n[2*e+1])},Bt=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},Ut=(t,e,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=15;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=Bt(i[e]++,e))}},Zt=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},Pt=t=>{t.bi_valid>8?Lt(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},$t=(t,e,n,i)=>{const r=2*e,s=2*n;return t[r]<t[s]||t[r]===t[s]&&i[e]<=i[n]},Gt=(t,e,n)=>{const i=t.heap[n];let r=n<<1;for(;r<=t.heap_len&&(r<t.heap_len&&$t(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!$t(e,i,t.heap[r],t.depth));)t.heap[n]=t.heap[r],n=r,r<<=1;t.heap[n]=i},Wt=(t,e,n)=>{let i,r,s,o,a=0;if(0!==t.sym_next)do{i=255&t.pending_buf[t.sym_buf+a++],i+=(255&t.pending_buf[t.sym_buf+a++])<<8,r=t.pending_buf[t.sym_buf+a++],0===i?Dt(t,r,e):(s=xt[r],Dt(t,s+256+1,e),o=wt[s],0!==o&&(r-=At[s],Ft(t,r,o)),i--,s=Nt(i),Dt(t,s,n),o=vt[s],0!==o&&(i-=Et[s],Ft(t,i,o)))}while(a<t.sym_next);Dt(t,256,e)},jt=(t,e)=>{const n=e.dyn_tree,i=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,l,c=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==n[2*o]?(t.heap[++t.heap_len]=c=o,t.depth[o]=0):n[2*o+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=c<2?++c:0,n[2*l]=1,t.depth[l]=0,t.opt_len--,r&&(t.static_len-=i[2*l+1]);for(e.max_code=c,o=t.heap_len>>1;o>=1;o--)Gt(t,n,o);l=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Gt(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,n[2*l]=n[2*o]+n[2*a],t.depth[l]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,n[2*o+1]=n[2*a+1]=l,t.heap[1]=l++,Gt(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,i=e.max_code,r=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length;let c,d,h,u,p,g,m=0;for(u=0;u<=15;u++)t.bl_count[u]=0;for(n[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)d=t.heap[c],u=n[2*n[2*d+1]+1]+1,u>l&&(u=l,m++),n[2*d+1]=u,d>i||(t.bl_count[u]++,p=0,d>=a&&(p=o[d-a]),g=n[2*d],t.opt_len+=g*(u+p),s&&(t.static_len+=g*(r[2*d+1]+p)));if(0!==m){do{for(u=l-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[l]--,m-=2}while(m>0);for(u=l;0!==u;u--)for(d=t.bl_count[u];0!==d;)h=t.heap[--c],h>i||(n[2*h+1]!==u&&(t.opt_len+=(u-n[2*h+1])*n[2*h],n[2*h+1]=u),d--)}})(t,e),Ut(n,c,t.bl_count)},Vt=(t,e,n)=>{let i,r,s=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),e[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=e[2*(i+1)+1],++a<l&&r===o||(a<c?t.bl_tree[2*r]+=a:0!==r?(r!==s&&t.bl_tree[2*r]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=r,0===o?(l=138,c=3):r===o?(l=6,c=3):(l=7,c=4))},Ht=(t,e,n)=>{let i,r,s=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),i=0;i<=n;i++)if(r=o,o=e[2*(i+1)+1],!(++a<l&&r===o)){if(a<c)do{Dt(t,r,t.bl_tree)}while(0!==--a);else 0!==r?(r!==s&&(Dt(t,r,t.bl_tree),a--),Dt(t,16,t.bl_tree),Ft(t,a-3,2)):a<=10?(Dt(t,17,t.bl_tree),Ft(t,a-3,3)):(Dt(t,18,t.bl_tree),Ft(t,a-11,7));a=0,s=r,0===o?(l=138,c=3):r===o?(l=6,c=3):(l=7,c=4)}};let qt=!1;const Kt=(t,e,n,i)=>{Ft(t,0+(i?1:0),3),Pt(t),Lt(t,n),Lt(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n};var Yt={_tr_init:t=>{qt||((()=>{let t,e,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(At[i]=n,t=0;t<1<<wt[i];t++)xt[n++]=i;for(xt[n-1]=i,r=0,i=0;i<16;i++)for(Et[i]=r,t=0;t<1<<vt[i];t++)kt[r++]=i;for(r>>=7;i<30;i++)for(Et[i]=r<<7,t=0;t<1<<vt[i]-7;t++)kt[256+r++]=i;for(e=0;e<=15;e++)s[e]=0;for(t=0;t<=143;)St[2*t+1]=8,t++,s[8]++;for(;t<=255;)St[2*t+1]=9,t++,s[9]++;for(;t<=279;)St[2*t+1]=7,t++,s[7]++;for(;t<=287;)St[2*t+1]=8,t++,s[8]++;for(Ut(St,287,s),t=0;t<30;t++)_t[2*t+1]=5,_t[2*t]=Bt(t,5);Mt=new Rt(St,wt,257,286,15),Tt=new Rt(_t,vt,0,30,15),Ot=new Rt(new Array(0),It,0,19,7)})(),qt=!0),t.l_desc=new zt(t.dyn_ltree,Mt),t.d_desc=new zt(t.dyn_dtree,Tt),t.bl_desc=new zt(t.bl_tree,Ot),t.bi_buf=0,t.bi_valid=0,Zt(t)},_tr_stored_block:Kt,_tr_flush_block:(t,e,n,i)=>{let r,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),jt(t,t.l_desc),jt(t,t.d_desc),o=(t=>{let e;for(Vt(t,t.dyn_ltree,t.l_desc.max_code),Vt(t,t.dyn_dtree,t.d_desc.max_code),jt(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Ct[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==e?Kt(t,e,n,i):4===t.strategy||s===r?(Ft(t,2+(i?1:0),3),Wt(t,St,_t)):(Ft(t,4+(i?1:0),3),((t,e,n,i)=>{let r;for(Ft(t,e-257,5),Ft(t,n-1,5),Ft(t,i-4,4),r=0;r<i;r++)Ft(t,t.bl_tree[2*Ct[r]+1],3);Ht(t,t.dyn_ltree,e-1),Ht(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Wt(t,t.dyn_ltree,t.dyn_dtree)),Zt(t),i&&Pt(t)},_tr_tally:(t,e,n)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=n,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(xt[n]+256+1)]++,t.dyn_dtree[2*Nt(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{Ft(t,2,3),Dt(t,256,St),(t=>{16===t.bi_valid?(Lt(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},Qt=(t,e,n,i)=>{let r=65535&t,s=t>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+e[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Xt=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());var Jt=(t,e,n,i)=>{const r=Xt,s=i+n;t^=-1;for(let n=i;n<s;n++)t=t>>>8^r[255&(t^e[n])];return-1^t},te={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ee={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:ne,_tr_stored_block:ie,_tr_flush_block:re,_tr_tally:se,_tr_align:oe}=Yt,{Z_NO_FLUSH:ae,Z_PARTIAL_FLUSH:le,Z_FULL_FLUSH:ce,Z_FINISH:de,Z_BLOCK:he,Z_OK:ue,Z_STREAM_END:pe,Z_STREAM_ERROR:ge,Z_DATA_ERROR:me,Z_BUF_ERROR:fe,Z_DEFAULT_COMPRESSION:ye,Z_FILTERED:be,Z_HUFFMAN_ONLY:we,Z_RLE:ve,Z_FIXED:Ie,Z_DEFAULT_STRATEGY:Ce,Z_UNKNOWN:Se,Z_DEFLATED:_e}=ee,ke=258,xe=262,Ae=42,Ee=113,Re=666,Me=(t,e)=>(t.msg=te[e],e),Te=t=>2*t-(t>4?9:0),Oe=t=>{let e=t.length;for(;--e>=0;)t[e]=0},ze=t=>{let e,n,i,r=t.w_size;e=t.hash_size,i=e;do{n=t.head[--i],t.head[i]=n>=r?n-r:0}while(--e);e=r,i=e;do{n=t.prev[--i],t.prev[i]=n>=r?n-r:0}while(--e)};let Ne=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const Le=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},Fe=(t,e)=>{re(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Le(t.strm)},De=(t,e)=>{t.pending_buf[t.pending++]=e},Be=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Ue=(t,e,n,i)=>{let r=t.avail_in;return r>i&&(r=i),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),n),1===t.state.wrap?t.adler=Qt(t.adler,e,r,n):2===t.state.wrap&&(t.adler=Jt(t.adler,e,r,n)),t.next_in+=r,t.total_in+=r,r)},Ze=(t,e)=>{let n,i,r=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const l=t.strstart>t.w_size-xe?t.strstart-(t.w_size-xe):0,c=t.window,d=t.w_mask,h=t.prev,u=t.strstart+ke;let p=c[s+o-1],g=c[s+o];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do{if(n=e,c[n+o]===g&&c[n+o-1]===p&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&s<u);if(i=ke-(u-s),s=u-ke,i>o){if(t.match_start=e,o=i,i>=a)break;p=c[s+o-1],g=c[s+o]}}}while((e=h[e&d])>l&&0!==--r);return o<=t.lookahead?o:t.lookahead},Pe=t=>{const e=t.w_size;let n,i,r;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-xe)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),ze(t),i+=e),0===t.strm.avail_in)break;if(n=Ue(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=Ne(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=Ne(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<xe&&0!==t.strm.avail_in)},$e=(t,e)=>{let n,i,r,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(n=65535,r=t.bi_valid+42>>3,t.strm.avail_out<r)break;if(r=t.strm.avail_out-r,i=t.strstart-t.block_start,n>i+t.strm.avail_in&&(n=i+t.strm.avail_in),n>r&&(n=r),n<s&&(0===n&&e!==de||e===ae||n!==i+t.strm.avail_in))break;o=e===de&&n===i+t.strm.avail_in?1:0,ie(t,0,0,o),t.pending_buf[t.pending-4]=n,t.pending_buf[t.pending-3]=n>>8,t.pending_buf[t.pending-2]=~n,t.pending_buf[t.pending-1]=~n>>8,Le(t.strm),i&&(i>n&&(i=n),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,n-=i),n&&(Ue(t.strm,t.strm.output,t.strm.next_out,n),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n)}while(0===o);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),o?4:e!==ae&&e!==de&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(r=t.window_size-t.strstart,t.strm.avail_in>r&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,r+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),r>t.strm.avail_in&&(r=t.strm.avail_in),r&&(Ue(t.strm,t.window,t.strstart,r),t.strstart+=r,t.insert+=r>t.w_size-t.insert?t.w_size-t.insert:r),t.high_water<t.strstart&&(t.high_water=t.strstart),r=t.bi_valid+42>>3,r=t.pending_buf_size-r>65535?65535:t.pending_buf_size-r,s=r>t.w_size?t.w_size:r,i=t.strstart-t.block_start,(i>=s||(i||e===de)&&e!==ae&&0===t.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=e===de&&0===t.strm.avail_in&&n===i?1:0,ie(t,t.block_start,n,o),t.block_start+=n,Le(t.strm)),o?3:1)},Ge=(t,e)=>{let n,i;for(;;){if(t.lookahead<xe){if(Pe(t),t.lookahead<xe&&e===ae)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=Ne(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-xe&&(t.match_length=Ze(t,n)),t.match_length>=3)if(i=se(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=Ne(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=Ne(t,t.ins_h,t.window[t.strstart+1]);else i=se(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(Fe(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===de?(Fe(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Fe(t,!1),0===t.strm.avail_out)?1:2},We=(t,e)=>{let n,i,r;for(;;){if(t.lookahead<xe){if(Pe(t),t.lookahead<xe&&e===ae)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=Ne(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-xe&&(t.match_length=Ze(t,n),t.match_length<=5&&(t.strategy===be||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,i=se(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=Ne(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(Fe(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=se(t,0,t.window[t.strstart-1]),i&&Fe(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=se(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===de?(Fe(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Fe(t,!1),0===t.strm.avail_out)?1:2};function je(t,e,n,i,r){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=i,this.func=r}const Ve=[new je(0,0,0,0,$e),new je(4,4,8,4,Ge),new je(4,5,16,8,Ge),new je(4,6,32,32,Ge),new je(4,4,16,16,We),new je(8,16,32,32,We),new je(8,16,128,128,We),new je(8,32,128,256,We),new je(32,128,258,1024,We),new je(32,258,258,4096,We)];function He(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=_e,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Oe(this.dyn_ltree),Oe(this.dyn_dtree),Oe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Oe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Oe(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const qe=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==Ae&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==Ee&&e.status!==Re?1:0},Ke=t=>{if(qe(t))return Me(t,ge);t.total_in=t.total_out=0,t.data_type=Se;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?Ae:Ee,t.adler=2===e.wrap?0:1,e.last_flush=-2,ne(e),ue},Ye=t=>{const e=Ke(t);var n;return e===ue&&((n=t.state).window_size=2*n.w_size,Oe(n.head),n.max_lazy_match=Ve[n.level].max_lazy,n.good_match=Ve[n.level].good_length,n.nice_match=Ve[n.level].nice_length,n.max_chain_length=Ve[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),e},Qe=(t,e,n,i,r,s)=>{if(!t)return ge;let o=1;if(e===ye&&(e=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==_e||i<8||i>15||e<0||e>9||s<0||s>Ie||8===i&&1!==o)return Me(t,ge);8===i&&(i=9);const a=new He;return t.state=a,a.strm=t,a.status=Ae,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=r+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<r+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=s,a.method=n,Ye(t)};var Xe=Qe,Je=(t,e)=>qe(t)||2!==t.state.wrap?ge:(t.state.gzhead=e,ue),tn=(t,e)=>{if(qe(t)||e>he||e<0)return t?Me(t,ge):ge;const n=t.state;if(!t.output||0!==t.avail_in&&!t.input||n.status===Re&&e!==de)return Me(t,0===t.avail_out?fe:ge);const i=n.last_flush;if(n.last_flush=e,0!==n.pending){if(Le(t),0===t.avail_out)return n.last_flush=-1,ue}else if(0===t.avail_in&&Te(e)<=Te(i)&&e!==de)return Me(t,fe);if(n.status===Re&&0!==t.avail_in)return Me(t,fe);if(n.status===Ae&&0===n.wrap&&(n.status=Ee),n.status===Ae){let e=_e+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=we||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=i<<6,0!==n.strstart&&(e|=32),e+=31-e%31,Be(n,e),0!==n.strstart&&(Be(n,t.adler>>>16),Be(n,65535&t.adler)),t.adler=1,n.status=Ee,Le(t),0!==n.pending)return n.last_flush=-1,ue}if(57===n.status)if(t.adler=0,De(n,31),De(n,139),De(n,8),n.gzhead)De(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),De(n,255&n.gzhead.time),De(n,n.gzhead.time>>8&255),De(n,n.gzhead.time>>16&255),De(n,n.gzhead.time>>24&255),De(n,9===n.level?2:n.strategy>=we||n.level<2?4:0),De(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(De(n,255&n.gzhead.extra.length),De(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=Jt(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(De(n,0),De(n,0),De(n,0),De(n,0),De(n,0),De(n,9===n.level?2:n.strategy>=we||n.level<2?4:0),De(n,3),n.status=Ee,Le(t),0!==n.pending)return n.last_flush=-1,ue;if(69===n.status){if(n.gzhead.extra){let e=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>e&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex+=r,Le(t),0!==n.pending)return n.last_flush=-1,ue;e=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>e&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-i,i)),Le(t),0!==n.pending)return n.last_flush=-1,ue;i=0}e=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,De(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-i,i)),Le(t),0!==n.pending)return n.last_flush=-1,ue;i=0}e=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,De(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=Jt(t.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Le(t),0!==n.pending))return n.last_flush=-1,ue;De(n,255&t.adler),De(n,t.adler>>8&255),t.adler=0}if(n.status=Ee,Le(t),0!==n.pending)return n.last_flush=-1,ue}if(0!==t.avail_in||0!==n.lookahead||e!==ae&&n.status!==Re){let i=0===n.level?$e(n,e):n.strategy===we?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(Pe(t),0===t.lookahead)){if(e===ae)return 1;break}if(t.match_length=0,n=se(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(Fe(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===de?(Fe(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Fe(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===ve?((t,e)=>{let n,i,r,s;const o=t.window;for(;;){if(t.lookahead<=ke){if(Pe(t),t.lookahead<=ke&&e===ae)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=t.strstart+ke;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&r<s);t.match_length=ke-(s-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=se(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=se(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(Fe(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===de?(Fe(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Fe(t,!1),0===t.strm.avail_out)?1:2})(n,e):Ve[n.level].func(n,e);if(3!==i&&4!==i||(n.status=Re),1===i||3===i)return 0===t.avail_out&&(n.last_flush=-1),ue;if(2===i&&(e===le?oe(n):e!==he&&(ie(n,0,0,!1),e===ce&&(Oe(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Le(t),0===t.avail_out))return n.last_flush=-1,ue}return e!==de?ue:n.wrap<=0?pe:(2===n.wrap?(De(n,255&t.adler),De(n,t.adler>>8&255),De(n,t.adler>>16&255),De(n,t.adler>>24&255),De(n,255&t.total_in),De(n,t.total_in>>8&255),De(n,t.total_in>>16&255),De(n,t.total_in>>24&255)):(Be(n,t.adler>>>16),Be(n,65535&t.adler)),Le(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?ue:pe)},en=t=>{if(qe(t))return ge;const e=t.state.status;return t.state=null,e===Ee?Me(t,me):ue},nn=(t,e)=>{let n=e.length;if(qe(t))return ge;const i=t.state,r=i.wrap;if(2===r||1===r&&i.status!==Ae||i.lookahead)return ge;if(1===r&&(t.adler=Qt(t.adler,e,n,0)),i.wrap=0,n>=i.w_size){0===r&&(Oe(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(n-i.w_size,n),0),e=t,n=i.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,Pe(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=Ne(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,Pe(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,i.wrap=r,ue};const rn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var sn=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)rn(n,e)&&(t[e]=n[e])}}return t},on=t=>{let e=0;for(let n=0,i=t.length;n<i;n++)e+=t[n].length;const n=new Uint8Array(e);for(let e=0,i=0,r=t.length;e<r;e++){let r=t[e];n.set(r,i),i+=r.length}return n};let an=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){an=!1}const ln=new Uint8Array(256);for(let t=0;t<256;t++)ln[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;ln[254]=ln[254]=1;var cn=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,i,r,s,o=t.length,a=0;for(r=0;r<o;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<o&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(a),s=0,r=0;s<a;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<o&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),n<128?e[s++]=n:n<2048?(e[s++]=192|n>>>6,e[s++]=128|63&n):n<65536?(e[s++]=224|n>>>12,e[s++]=128|n>>>6&63,e[s++]=128|63&n):(e[s++]=240|n>>>18,e[s++]=128|n>>>12&63,e[s++]=128|n>>>6&63,e[s++]=128|63&n);return e},dn=(t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,r;const s=new Array(2*n);for(r=0,i=0;i<n;){let e=t[i++];if(e<128){s[r++]=e;continue}let o=ln[e];if(o>4)s[r++]=65533,i+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&i<n;)e=e<<6|63&t[i++],o--;o>1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&an)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let i=0;i<e;i++)n+=String.fromCharCode(t[i]);return n})(s,r)},hn=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+ln[t[n]]>e?n:e},un=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const pn=Object.prototype.toString,{Z_NO_FLUSH:gn,Z_SYNC_FLUSH:mn,Z_FULL_FLUSH:fn,Z_FINISH:yn,Z_OK:bn,Z_STREAM_END:wn,Z_DEFAULT_COMPRESSION:vn,Z_DEFAULT_STRATEGY:In,Z_DEFLATED:Cn}=ee;function Sn(t){this.options=sn({level:vn,method:Cn,chunkSize:16384,windowBits:15,memLevel:8,strategy:In},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new un,this.strm.avail_out=0;let n=Xe(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==bn)throw new Error(te[n]);if(e.header&&Je(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?cn(e.dictionary):"[object ArrayBuffer]"===pn.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=nn(this.strm,t),n!==bn)throw new Error(te[n]);this._dict_set=!0}}function _n(t,e){const n=new Sn(e);if(n.push(t,!0),n.err)throw n.msg||te[n.err];return n.result}Sn.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?yn:gn,"string"==typeof t?n.input=cn(t):"[object ArrayBuffer]"===pn.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),(s===mn||s===fn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=tn(n,s),r===wn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=en(this.strm),this.onEnd(r),this.ended=!0,r===bn;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Sn.prototype.onData=function(t){this.chunks.push(t)},Sn.prototype.onEnd=function(t){t===bn&&(this.result=on(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var kn={Deflate:Sn,deflate:_n,deflateRaw:function(t,e){return(e=e||{}).raw=!0,_n(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,_n(t,e)},constants:ee};const xn=16209;var An=function(t,e){let n,i,r,s,o,a,l,c,d,h,u,p,g,m,f,y,b,w,v,I,C,S,_,k;const x=t.state;n=t.next_in,_=t.input,i=n+(t.avail_in-5),r=t.next_out,k=t.output,s=r-(e-t.avail_out),o=r+(t.avail_out-257),a=x.dmax,l=x.wsize,c=x.whave,d=x.wnext,h=x.window,u=x.hold,p=x.bits,g=x.lencode,m=x.distcode,f=(1<<x.lenbits)-1,y=(1<<x.distbits)-1;t:do{p<15&&(u+=_[n++]<<p,p+=8,u+=_[n++]<<p,p+=8),b=g[u&f];e:for(;;){if(w=b>>>24,u>>>=w,p-=w,w=b>>>16&255,0===w)k[r++]=65535&b;else{if(!(16&w)){if(64&w){if(32&w){x.mode=16191;break t}t.msg="invalid literal/length code",x.mode=xn;break t}b=g[(65535&b)+(u&(1<<w)-1)];continue e}for(v=65535&b,w&=15,w&&(p<w&&(u+=_[n++]<<p,p+=8),v+=u&(1<<w)-1,u>>>=w,p-=w),p<15&&(u+=_[n++]<<p,p+=8,u+=_[n++]<<p,p+=8),b=m[u&y];;){if(w=b>>>24,u>>>=w,p-=w,w=b>>>16&255,16&w){if(I=65535&b,w&=15,p<w&&(u+=_[n++]<<p,p+=8,p<w&&(u+=_[n++]<<p,p+=8)),I+=u&(1<<w)-1,I>a){t.msg="invalid distance too far back",x.mode=xn;break t}if(u>>>=w,p-=w,w=r-s,I>w){if(w=I-w,w>c&&x.sane){t.msg="invalid distance too far back",x.mode=xn;break t}if(C=0,S=h,0===d){if(C+=l-w,w<v){v-=w;do{k[r++]=h[C++]}while(--w);C=r-I,S=k}}else if(d<w){if(C+=l+d-w,w-=d,w<v){v-=w;do{k[r++]=h[C++]}while(--w);if(C=0,d<v){w=d,v-=w;do{k[r++]=h[C++]}while(--w);C=r-I,S=k}}}else if(C+=d-w,w<v){v-=w;do{k[r++]=h[C++]}while(--w);C=r-I,S=k}for(;v>2;)k[r++]=S[C++],k[r++]=S[C++],k[r++]=S[C++],v-=3;v&&(k[r++]=S[C++],v>1&&(k[r++]=S[C++]))}else{C=r-I;do{k[r++]=k[C++],k[r++]=k[C++],k[r++]=k[C++],v-=3}while(v>2);v&&(k[r++]=k[C++],v>1&&(k[r++]=k[C++]))}break}if(64&w){t.msg="invalid distance code",x.mode=xn;break t}b=m[(65535&b)+(u&(1<<w)-1)]}}break}}while(n<i&&r<o);v=p>>3,n-=v,p-=v<<3,u&=(1<<p)-1,t.next_in=n,t.next_out=r,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=r<o?o-r+257:257-(r-o),x.hold=u,x.bits=p};const En=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Rn=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Mn=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Tn=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var On=(t,e,n,i,r,s,o,a)=>{const l=a.bits;let c,d,h,u,p,g,m=0,f=0,y=0,b=0,w=0,v=0,I=0,C=0,S=0,_=0,k=null;const x=new Uint16Array(16),A=new Uint16Array(16);let E,R,M,T=null;for(m=0;m<=15;m++)x[m]=0;for(f=0;f<i;f++)x[e[n+f]]++;for(w=l,b=15;b>=1&&0===x[b];b--);if(w>b&&(w=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(y=1;y<b&&0===x[y];y++);for(w<y&&(w=y),C=1,m=1;m<=15;m++)if(C<<=1,C-=x[m],C<0)return-1;if(C>0&&(0===t||1!==b))return-1;for(A[1]=0,m=1;m<15;m++)A[m+1]=A[m]+x[m];for(f=0;f<i;f++)0!==e[n+f]&&(o[A[e[n+f]]++]=f);if(0===t?(k=T=o,g=20):1===t?(k=En,T=Rn,g=257):(k=Mn,T=Tn,g=0),_=0,f=0,m=y,p=s,v=w,I=0,h=-1,S=1<<w,u=S-1,1===t&&S>852||2===t&&S>592)return 1;for(;;){E=m-I,o[f]+1<g?(R=0,M=o[f]):o[f]>=g?(R=T[o[f]-g],M=k[o[f]-g]):(R=96,M=0),c=1<<m-I,d=1<<v,y=d;do{d-=c,r[p+(_>>I)+d]=E<<24|R<<16|M}while(0!==d);for(c=1<<m-1;_&c;)c>>=1;if(0!==c?(_&=c-1,_+=c):_=0,f++,0===--x[m]){if(m===b)break;m=e[n+o[f]]}if(m>w&&(_&u)!==h){for(0===I&&(I=w),p+=y,v=m-I,C=1<<v;v+I<b&&(C-=x[v+I],!(C<=0));)v++,C<<=1;if(S+=1<<v,1===t&&S>852||2===t&&S>592)return 1;h=_&u,r[h]=w<<24|v<<16|p-s}}return 0!==_&&(r[p+_]=m-I<<24|64<<16),a.bits=w,0};const{Z_FINISH:zn,Z_BLOCK:Nn,Z_TREES:Ln,Z_OK:Fn,Z_STREAM_END:Dn,Z_NEED_DICT:Bn,Z_STREAM_ERROR:Un,Z_DATA_ERROR:Zn,Z_MEM_ERROR:Pn,Z_BUF_ERROR:$n,Z_DEFLATED:Gn}=ee,Wn=16180,jn=16190,Vn=16191,Hn=16192,qn=16194,Kn=16199,Yn=16200,Qn=16206,Xn=16209,Jn=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ti(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ei=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<Wn||e.mode>16211?1:0},ni=t=>{if(ei(t))return Un;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=Wn,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,Fn},ii=t=>{if(ei(t))return Un;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ni(t)},ri=(t,e)=>{let n;if(ei(t))return Un;const i=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?Un:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=n,i.wbits=e,ii(t))},si=(t,e)=>{if(!t)return Un;const n=new ti;t.state=n,n.strm=t,n.window=null,n.mode=Wn;const i=ri(t,e);return i!==Fn&&(t.state=null),i};let oi,ai,li=!0;const ci=t=>{if(li){oi=new Int32Array(512),ai=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(On(1,t.lens,0,288,oi,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;On(2,t.lens,0,32,ai,0,t.work,{bits:5}),li=!1}t.lencode=oi,t.lenbits=9,t.distcode=ai,t.distbits=5},di=(t,e,n,i)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(e.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(e.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0};var hi=ii,ui=si,pi=(t,e)=>{let n,i,r,s,o,a,l,c,d,h,u,p,g,m,f,y,b,w,v,I,C,S,_=0;const k=new Uint8Array(4);let x,A;const E=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(ei(t)||!t.output||!t.input&&0!==t.avail_in)return Un;n=t.state,n.mode===Vn&&(n.mode=Hn),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,h=a,u=l,S=Fn;t:for(;;)switch(n.mode){case Wn:if(0===n.wrap){n.mode=Hn;break}for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(2&n.wrap&&35615===c){0===n.wbits&&(n.wbits=15),n.check=0,k[0]=255&c,k[1]=c>>>8&255,n.check=Jt(n.check,k,2,0),c=0,d=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",n.mode=Xn;break}if((15&c)!==Gn){t.msg="unknown compression method",n.mode=Xn;break}if(c>>>=4,d-=4,C=8+(15&c),0===n.wbits&&(n.wbits=C),C>15||C>n.wbits){t.msg="invalid window size",n.mode=Xn;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&c?16189:Vn,c=0,d=0;break;case 16181:for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(n.flags=c,(255&n.flags)!==Gn){t.msg="unknown compression method",n.mode=Xn;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=Xn;break}n.head&&(n.head.text=c>>8&1),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=Jt(n.check,k,2,0)),c=0,d=0,n.mode=16182;case 16182:for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.head&&(n.head.time=c),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,k[2]=c>>>16&255,k[3]=c>>>24&255,n.check=Jt(n.check,k,4,0)),c=0,d=0,n.mode=16183;case 16183:for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.head&&(n.head.xflags=255&c,n.head.os=c>>8),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=Jt(n.check,k,2,0)),c=0,d=0,n.mode=16184;case 16184:if(1024&n.flags){for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.length=c,n.head&&(n.head.extra_len=c),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=Jt(n.check,k,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(p=n.length,p>a&&(p=a),p&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(s,s+p),C)),512&n.flags&&4&n.wrap&&(n.check=Jt(n.check,i,p,s)),a-=p,s+=p,n.length-=p),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break t;p=0;do{C=i[s+p++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C))}while(C&&p<a);if(512&n.flags&&4&n.wrap&&(n.check=Jt(n.check,i,p,s)),a-=p,s+=p,C)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===a)break t;p=0;do{C=i[s+p++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C))}while(C&&p<a);if(512&n.flags&&4&n.wrap&&(n.check=Jt(n.check,i,p,s)),a-=p,s+=p,C)break t}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(4&n.wrap&&c!==(65535&n.check)){t.msg="header crc mismatch",n.mode=Xn;break}c=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=Vn;break;case 16189:for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}t.adler=n.check=Jn(c),c=0,d=0,n.mode=jn;case jn:if(0===n.havedict)return t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,Bn;t.adler=n.check=1,n.mode=Vn;case Vn:if(e===Nn||e===Ln)break t;case Hn:if(n.last){c>>>=7&d,d-=7&d,n.mode=Qn;break}for(;d<3;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}switch(n.last=1&c,c>>>=1,d-=1,3&c){case 0:n.mode=16193;break;case 1:if(ci(n),n.mode=Kn,e===Ln){c>>>=2,d-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=Xn}c>>>=2,d-=2;break;case 16193:for(c>>>=7&d,d-=7&d;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",n.mode=Xn;break}if(n.length=65535&c,c=0,d=0,n.mode=qn,e===Ln)break t;case qn:n.mode=16195;case 16195:if(p=n.length,p){if(p>a&&(p=a),p>l&&(p=l),0===p)break t;r.set(i.subarray(s,s+p),o),a-=p,s+=p,l-=p,o+=p,n.length-=p;break}n.mode=Vn;break;case 16196:for(;d<14;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(n.nlen=257+(31&c),c>>>=5,d-=5,n.ndist=1+(31&c),c>>>=5,d-=5,n.ncode=4+(15&c),c>>>=4,d-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=Xn;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;d<3;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.lens[E[n.have++]]=7&c,c>>>=3,d-=3}for(;n.have<19;)n.lens[E[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,x={bits:n.lenbits},S=On(0,n.lens,0,19,n.lencode,0,n.work,x),n.lenbits=x.bits,S){t.msg="invalid code lengths set",n.mode=Xn;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;_=n.lencode[c&(1<<n.lenbits)-1],f=_>>>24,y=_>>>16&255,b=65535&_,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(b<16)c>>>=f,d-=f,n.lens[n.have++]=b;else{if(16===b){for(A=f+2;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(c>>>=f,d-=f,0===n.have){t.msg="invalid bit length repeat",n.mode=Xn;break}C=n.lens[n.have-1],p=3+(3&c),c>>>=2,d-=2}else if(17===b){for(A=f+3;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=f,d-=f,C=0,p=3+(7&c),c>>>=3,d-=3}else{for(A=f+7;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=f,d-=f,C=0,p=11+(127&c),c>>>=7,d-=7}if(n.have+p>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=Xn;break}for(;p--;)n.lens[n.have++]=C}}if(n.mode===Xn)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=Xn;break}if(n.lenbits=9,x={bits:n.lenbits},S=On(1,n.lens,0,n.nlen,n.lencode,0,n.work,x),n.lenbits=x.bits,S){t.msg="invalid literal/lengths set",n.mode=Xn;break}if(n.distbits=6,n.distcode=n.distdyn,x={bits:n.distbits},S=On(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,x),n.distbits=x.bits,S){t.msg="invalid distances set",n.mode=Xn;break}if(n.mode=Kn,e===Ln)break t;case Kn:n.mode=Yn;case Yn:if(a>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,An(t,u),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,n.mode===Vn&&(n.back=-1);break}for(n.back=0;_=n.lencode[c&(1<<n.lenbits)-1],f=_>>>24,y=_>>>16&255,b=65535&_,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(y&&!(240&y)){for(w=f,v=y,I=b;_=n.lencode[I+((c&(1<<w+v)-1)>>w)],f=_>>>24,y=_>>>16&255,b=65535&_,!(w+f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=w,d-=w,n.back+=w}if(c>>>=f,d-=f,n.back+=f,n.length=b,0===y){n.mode=16205;break}if(32&y){n.back=-1,n.mode=Vn;break}if(64&y){t.msg="invalid literal/length code",n.mode=Xn;break}n.extra=15&y,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;_=n.distcode[c&(1<<n.distbits)-1],f=_>>>24,y=_>>>16&255,b=65535&_,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(!(240&y)){for(w=f,v=y,I=b;_=n.distcode[I+((c&(1<<w+v)-1)>>w)],f=_>>>24,y=_>>>16&255,b=65535&_,!(w+f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=w,d-=w,n.back+=w}if(c>>>=f,d-=f,n.back+=f,64&y){t.msg="invalid distance code",n.mode=Xn;break}n.offset=b,n.extra=15&y,n.mode=16203;case 16203:if(n.extra){for(A=n.extra;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=Xn;break}n.mode=16204;case 16204:if(0===l)break t;if(p=u-l,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=Xn;break}p>n.wnext?(p-=n.wnext,g=n.wsize-p):g=n.wnext-p,p>n.length&&(p=n.length),m=n.window}else m=r,g=o-n.offset,p=n.length;p>l&&(p=l),l-=p,n.length-=p;do{r[o++]=m[g++]}while(--p);0===n.length&&(n.mode=Yn);break;case 16205:if(0===l)break t;r[o++]=n.length,l--,n.mode=Yn;break;case Qn:if(n.wrap){for(;d<32;){if(0===a)break t;a--,c|=i[s++]<<d,d+=8}if(u-=l,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?Jt(n.check,r,u,o-u):Qt(n.check,r,u,o-u)),u=l,4&n.wrap&&(n.flags?c:Jn(c))!==n.check){t.msg="incorrect data check",n.mode=Xn;break}c=0,d=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(4&n.wrap&&c!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=Xn;break}c=0,d=0}n.mode=16208;case 16208:S=Dn;break t;case Xn:S=Zn;break t;case 16210:return Pn;default:return Un}return t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,(n.wsize||u!==t.avail_out&&n.mode<Xn&&(n.mode<Qn||e!==zn))&&di(t,t.output,t.next_out,u-t.avail_out),h-=t.avail_in,u-=t.avail_out,t.total_in+=h,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?Jt(n.check,r,u,t.next_out-u):Qt(n.check,r,u,t.next_out-u)),t.data_type=n.bits+(n.last?64:0)+(n.mode===Vn?128:0)+(n.mode===Kn||n.mode===qn?256:0),(0===h&&0===u||e===zn)&&S===Fn&&(S=$n),S},gi=t=>{if(ei(t))return Un;let e=t.state;return e.window&&(e.window=null),t.state=null,Fn},mi=(t,e)=>{if(ei(t))return Un;const n=t.state;return 2&n.wrap?(n.head=e,e.done=!1,Fn):Un},fi=(t,e)=>{const n=e.length;let i,r,s;return ei(t)?Un:(i=t.state,0!==i.wrap&&i.mode!==jn?Un:i.mode===jn&&(r=1,r=Qt(r,e,n,0),r!==i.check)?Zn:(s=di(t,e,n,n),s?(i.mode=16210,Pn):(i.havedict=1,Fn)))},yi=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const bi=Object.prototype.toString,{Z_NO_FLUSH:wi,Z_FINISH:vi,Z_OK:Ii,Z_STREAM_END:Ci,Z_NEED_DICT:Si,Z_STREAM_ERROR:_i,Z_DATA_ERROR:ki,Z_MEM_ERROR:xi}=ee;function Ai(t){this.options=sn({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new un,this.strm.avail_out=0;let n=ui(this.strm,e.windowBits);if(n!==Ii)throw new Error(te[n]);if(this.header=new yi,mi(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=cn(e.dictionary):"[object ArrayBuffer]"===bi.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=fi(this.strm,e.dictionary),n!==Ii)))throw new Error(te[n])}function Ei(t,e){const n=new Ai(e);if(n.push(t),n.err)throw n.msg||te[n.err];return n.result}Ai.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?vi:wi,"[object ArrayBuffer]"===bi.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),s=pi(n,o),s===Si&&r&&(s=fi(n,r),s===Ii?s=pi(n,o):s===ki&&(s=Si));n.avail_in>0&&s===Ci&&n.state.wrap>0&&0!==t[n.next_in];)hi(n),s=pi(n,o);switch(s){case _i:case ki:case Si:case xi:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===Ci))if("string"===this.options.to){let t=hn(n.output,n.next_out),e=n.next_out-t,r=dn(n.output,t);n.next_out=e,n.avail_out=i-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==Ii||0!==a){if(s===Ci)return s=gi(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Ai.prototype.onData=function(t){this.chunks.push(t)},Ai.prototype.onEnd=function(t){t===Ii&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=on(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ri={Inflate:Ai,inflate:Ei,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Ei(t,e)},ungzip:Ei,constants:ee};const{Deflate:Mi,deflate:Ti,deflateRaw:Oi,gzip:zi}=kn,{Inflate:Ni,inflate:Li,inflateRaw:Fi,ungzip:Di}=Ri;var Bi={Deflate:Mi,deflate:Ti,deflateRaw:Oi,gzip:zi,Inflate:Ni,inflate:Li,inflateRaw:Fi,ungzip:Di,constants:ee};const Ui=E();let Zi=null,Pi=null;function $i(){return"undefined"!=typeof document&&"undefined"!=typeof Image&&"undefined"!=typeof HTMLCanvasElement}class Gi extends yt{constructor(t={}){super(t)}getErrorPlaceholder(){var t;return null!==(t=this.options.errorPlaceholder)&&void 0!==t?t:"SCREENSHOT_FAILED"}shouldIncludeNode(t){if(!("hasAttribute"in t))return!0;const e=t,n=this.options.excludeAttribute||"data-bugspotter-exclude";return!e.hasAttribute(n)}buildCaptureOptions(){var t,e,n,i;return Object.assign(Object.assign(Object.assign({quality:null!==(t=this.options.quality)&&void 0!==t?t:.95,cacheBust:null===(e=this.options.cacheBust)||void 0===e||e,pixelRatio:null!==(n=this.options.pixelRatio)&&void 0!==n?n:window.devicePixelRatio,backgroundColor:null!==(i=this.options.backgroundColor)&&void 0!==i?i:"#ffffff"},this.options.width&&{width:this.options.width}),this.options.height&&{height:this.options.height}),{filter:t=>this.shouldIncludeNode(t)})}async capture(t){try{const e=t||this.options.targetElement||document.body,n=this.buildCaptureOptions(),i=await async function(t,e={}){return(await async function(t,e={}){const{width:n,height:i}=U(t,e),r=await mt(t,e),s=await P(r),o=document.createElement("canvas"),a=o.getContext("2d"),l=e.pixelRatio||function(){let t,e;try{e=process}catch(t){}const n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}(),c=e.canvasWidth||n,d=e.canvasHeight||i;return o.width=c*l,o.height=d*l,e.skipAutoScale||function(t){(t.width>Z||t.height>Z)&&(t.width>Z&&t.height>Z?t.width>t.height?(t.height*=Z/t.width,t.width=Z):(t.width*=Z/t.height,t.height=Z):t.width>Z?(t.height*=Z/t.width,t.width=Z):(t.width*=Z/t.height,t.height=Z))}(o),o.style.width=`${c}`,o.style.height=`${d}`,e.backgroundColor&&(a.fillStyle=e.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(s,0,0,o.width,o.height),o}(t,e)).toDataURL()}(e,n);return await async function(t,e){var n,i,r,s;try{if(!$i())return t;const o=null!==(n=null==e?void 0:e.imageMaxWidth)&&void 0!==n?n:2560,a=null!==(i=null==e?void 0:e.imageMaxHeight)&&void 0!==i?i:1440,l=null!==(r=null==e?void 0:e.webpQuality)&&void 0!==r?r:.92,c=null!==(s=null==e?void 0:e.jpegQuality)&&void 0!==s?s:.92,d=3e3,h=await function(t,e){return new Promise((n,i)=>{const r=new Image,s=setTimeout(()=>{i(new Error(`Image load timeout after ${e}ms`))},e);r.onload=()=>{clearTimeout(s),n(r)},r.onerror=()=>{clearTimeout(s),i(new Error("Failed to load image"))},r.src=t})}(t,d),u=document.createElement("canvas"),p=u.getContext("2d");if(!p)throw new Error("Failed to get 2D canvas context");const{width:g,height:m}=function(t,e,n,i){let r=t,s=e;return r>n&&(s=s*n/r,r=n),s>i&&(r=r*i/s,s=i),{width:r,height:s}}(h.width,h.height,o,a);return u.width=g,u.height=m,p.imageSmoothingEnabled=!0,p.imageSmoothingQuality="high",p.drawImage(h,0,0,g,m),function(){if(null!==Pi)return Pi;if(!$i())return Pi=!1,!1;try{const t=document.createElement("canvas");Pi=0===t.toDataURL("image/webp").indexOf("data:image/webp")}catch(t){Pi=!1}return Pi}()?u.toDataURL("image/webp",l):u.toDataURL("image/jpeg",c)}catch(n){return!1!==(null==e?void 0:e.verbose)&&E().error("Image compression failed:",n),t}}(i)}catch(t){return this.handleError("capturing screenshot",t),this.getErrorPlaceholder()}}}class Wi{constructor(t){if(this.maxSize=t,this.items=[],this.index=0,this.count=0,t<=0)throw new Error("CircularBuffer maxSize must be greater than 0")}add(t){this.count<this.maxSize?(this.items.push(t),this.count++):this.items[this.index]=t,this.index=(this.index+1)%this.maxSize}getAll(){return this.count<this.maxSize?[...this.items]:[...this.items.slice(this.index),...this.items.slice(0,this.index)]}clear(){this.items=[],this.index=0,this.count=0}get size(){return this.count}get capacity(){return this.maxSize}get isEmpty(){return 0===this.count}get isFull(){return this.count>=this.maxSize}}const ji=["log","warn","error","info","debug"];class Vi extends yt{constructor(t={}){var e,n,i;super(t),this.originalMethods=new Map;const r=null!==(e=t.maxLogs)&&void 0!==e?e:100;this.buffer=new Wi(r),this.captureStackTrace=null===(n=t.captureStackTrace)||void 0===n||n,this.interceptConsole(null!==(i=t.levels)&&void 0!==i?i:ji)}capture(){return this.getLogs()}formatMessage(t){return t&&0!==t.length?(this.sanitizer?this.sanitizer.sanitizeConsoleArgs(t):t).map(t=>{var e;if(null===t)return"null";if(void 0===t)return"undefined";if("object"==typeof t)try{return JSON.stringify(t)}catch(n){return`[${(null===(e=t.constructor)||void 0===e?void 0:e.name)||"Object"}]`}return String(t)}).join(" "):""}createLogEntry(t,e,n){const i={level:t,message:null!=n?n:this.formatMessage(e),timestamp:Date.now()};if(this.captureStackTrace&&"error"===t){const t=this.captureStack();i.stack=this.sanitizer&&t?this.sanitizer.sanitize(t):t}return i}captureStack(){const t=(new Error).stack;return null==t?void 0:t.split("\n").slice(3).join("\n")}addLog(t){this.buffer.add(t)}shouldFilterLog(t,e){return"error"!==e&&t.startsWith("[BugSpotter]")}interceptConsole(t=ji){t.forEach(t=>{try{const e=console[t];this.originalMethods.set(t,e),console[t]=(...n)=>{try{const e=this.formatMessage(n);if(!this.shouldFilterLog(e,t)){const i=this.createLogEntry(t,n,e);this.addLog(i)}}catch(t){this.handleError("creating log entry",t)}e.apply(console,n)}}catch(e){this.handleError(`intercepting console.${t}`,e)}})}getLogs(){return this.buffer.getAll()}clear(){this.buffer.clear()}destroy(){try{this.originalMethods.forEach((t,e)=>{console[e]=t}),this.originalMethods.clear()}catch(t){this.handleError("destroying console capture",t)}}}class Hi extends yt{constructor(t={}){var e;super(t),this.isIntercepting=!1;const n=null!==(e=t.maxRequests)&&void 0!==e?e:50;this.buffer=new Wi(n),this.filterUrls=t.filterUrls,this.originalFetch=window.fetch,this.originalXHR={open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send},this.interceptFetch(),this.interceptXHR(),this.isIntercepting=!0}capture(){return this.getRequests()}parseFetchArgs(t){const[e,n]=t;let i,r="GET";return"string"==typeof e?i=e:e instanceof Request?(i=e.url,r=e.method.toUpperCase()||"GET"):i=e.toString(),(null==n?void 0:n.method)&&(r=n.method.toUpperCase()),{url:i,method:r}}createNetworkRequest(t,e,n,i,r){const s=Object.assign({url:t,method:e,status:n,duration:Date.now()-i,timestamp:i},r&&{error:r});if(this.sanitizer){const t=this.sanitizer.sanitizeNetworkData(Object.assign({url:s.url,method:s.method,status:s.status},s.error&&{error:s.error}));return Object.assign(Object.assign({},s),{url:t.url||s.url,error:t.error})}return s}addRequest(t){if(this.filterUrls){const e=this.filterUrls(t.url),n=t.status<200||t.status>=300;if(!e&&!n)return}this.buffer.add(t)}interceptFetch(){const t=this.originalFetch;window.fetch=async(...e)=>{const n=Date.now();let i="",r="GET";try{({url:i,method:r}=this.parseFetchArgs(e))}catch(t){this.handleError("parsing fetch arguments",t)}try{const s=await t(...e);if(s&&"number"==typeof s.status){const t=this.createNetworkRequest(i,r,s.status,n);this.addRequest(t)}return s}catch(t){const e=this.createNetworkRequest(i,r,0,n,t.message);throw this.addRequest(e),t}}}interceptXHR(){const t=this.originalXHR.open,e=this.originalXHR.send,n=this.createNetworkRequest.bind(this),i=this.addRequest.bind(this);XMLHttpRequest.prototype.open=function(e,n,...i){return this._method=e.toUpperCase(),this._url=n.toString(),this._startTime=Date.now(),t.apply(this,[e,n,...i])},XMLHttpRequest.prototype.send=function(...t){return this.addEventListener("load",()=>{const t=n(this._url||"",this._method||"GET",this.status,this._startTime||Date.now());i(t)}),this.addEventListener("error",()=>{const t=n(this._url||"",this._method||"GET",0,this._startTime||Date.now(),"XMLHttpRequest failed");i(t)}),e.apply(this,t)}}getRequests(){return this.buffer.getAll()}clear(){this.buffer.clear()}destroy(){if(this.isIntercepting)try{window.fetch=this.originalFetch,XMLHttpRequest.prototype.open=this.originalXHR.open,XMLHttpRequest.prototype.send=this.originalXHR.send,this.isIntercepting=!1}catch(t){this.handleError("destroying network capture",t)}}}class qi extends yt{constructor(t={}){super(t),this.browserPatterns=[{pattern:"Edg",name:"Edge"},{pattern:"Chrome",exclude:"Edge",name:"Chrome"},{pattern:"Firefox",name:"Firefox"},{pattern:"Safari",exclude:"Chrome",name:"Safari"}],this.osPatterns=[{patterns:["iPhone","iPad"],name:"iOS"},{patterns:["Android"],name:"Android"},{patterns:["Win"],name:"Windows"},{patterns:["Mac"],name:"macOS"},{patterns:["Linux"],name:"Linux"}]}capture(){try{const t={userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},browser:this.detectBrowser(),os:this.detectOS(),url:window.location.href,timestamp:Date.now()};return this.sanitizer&&(t.url=this.sanitizer.sanitize(t.url),t.userAgent=this.sanitizer.sanitize(t.userAgent)),t}catch(t){return this.handleError("capturing metadata",t),{userAgent:"Unknown",viewport:{width:0,height:0},browser:"Unknown",os:"Unknown",url:"Unknown",timestamp:Date.now()}}}detectBrowser(){const t=navigator.userAgent;for(const{pattern:e,exclude:n,name:i}of this.browserPatterns)if(t.includes(e)&&(!n||!t.includes(n)))return i;return"Unknown"}detectOS(){const t=navigator.userAgent;for(const{patterns:e,name:n}of this.osPatterns)if(e.some(e=>t.includes(e)))return n;return"Unknown"}}var Ki;function Yi(t){var e=null==t?void 0:t.host;return Boolean((null==e?void 0:e.shadowRoot)===t)}function Qi(t){return"[object ShadowRoot]"===Object.prototype.toString.call(t)}function Xi(t){try{var e=t.rules||t.cssRules;return e?((n=Array.from(e).map(Ji).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(t){return null}var n}function Ji(t){var e=t.cssText;if(function(t){return"styleSheet"in t}(t))try{e=Xi(t.styleSheet)||e}catch(t){}return e}!function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"}(Ki||(Ki={}));var tr=function(){function t(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return t.prototype.getId=function(t){var e;if(!t)return-1;var n=null===(e=this.getMeta(t))||void 0===e?void 0:e.id;return null!=n?n:-1},t.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},t.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},t.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},t.prototype.removeNodeFromMap=function(t){var e=this,n=this.getId(t);this.idNodeMap.delete(n),t.childNodes&&t.childNodes.forEach(function(t){return e.removeNodeFromMap(t)})},t.prototype.has=function(t){return this.idNodeMap.has(t)},t.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},t.prototype.add=function(t,e){var n=e.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,e)},t.prototype.replace=function(t,e){var n=this.getNode(t);if(n){var i=this.nodeMetaMap.get(n);i&&this.nodeMetaMap.set(e,i)}this.idNodeMap.set(t,e)},t.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},t}();function er(t){var e=t.maskInputOptions,n=t.tagName,i=t.type,r=t.value,s=t.maskInputFn,o=r||"";return(e[n.toLowerCase()]||e[i])&&(o=s?s(o):"*".repeat(o.length)),o}var nr,ir,rr="__rrweb_original__",sr=1,or=new RegExp("[^a-z0-9-_:]");function ar(){return sr++}var lr=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,cr=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,dr=/^(data:)([^,]*),(.*)/i;function hr(t,e){return(t||"").replace(lr,function(t,n,i,r,s,o){var a,l=i||s||o,c=n||r||"";if(!l)return t;if(!cr.test(l))return"url(".concat(c).concat(l).concat(c,")");if(dr.test(l))return"url(".concat(c).concat(l).concat(c,")");if("/"===l[0])return"url(".concat(c).concat((a=e,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+l)).concat(c,")");var d=e.split("/"),h=l.split("/");d.pop();for(var u=0,p=h;u<p.length;u++){var g=p[u];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(c).concat(d.join("/")).concat(c,")")})}var ur=/^[^ \t\n\r\u000c]+/,pr=/^[, \t\n\r\u000c]+/;function gr(t,e){if(!e||""===e.trim())return e;var n=t.createElement("a");return n.href=e,n.href}function mr(){var t=document.createElement("a");return t.href="",t.href}function fr(t,e,n,i){return"src"===n||"href"===n&&i&&("use"!==e||"#"!==i[0])||"xlink:href"===n&&i&&"#"!==i[0]?gr(t,i):"background"!==n||!i||"table"!==e&&"td"!==e&&"th"!==e?"srcset"===n&&i?function(t,e){if(""===e.trim())return e;var n=0;function i(t){var i,r=t.exec(e.substring(n));return r?(i=r[0],n+=i.length,i):""}for(var r=[];i(pr),!(n>=e.length);){var s=i(ur);if(","===s.slice(-1))s=gr(t,s.substring(0,s.length-1)),r.push(s);else{var o="";s=gr(t,s);for(var a=!1;;){var l=e.charAt(n);if(""===l){r.push((s+o).trim());break}if(a)")"===l&&(a=!1);else{if(","===l){n+=1,r.push((s+o).trim());break}"("===l&&(a=!0)}o+=l,n+=1}}}return r.join(", ")}(t,i):"style"===n&&i?hr(i,mr()):"object"===e&&"data"===n&&i?gr(t,i):i:gr(t,i)}function yr(t,e,n){if(!t)return!1;if(t.nodeType!==t.ELEMENT_NODE)return!!n&&yr(t.parentNode,e,n);for(var i=t.classList.length;i--;){var r=t.classList[i];if(e.test(r))return!0}return!!n&&yr(t.parentNode,e,n)}function br(t,e,n){var i=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(null===i)return!1;if("string"==typeof e){if(i.classList.contains(e))return!0;if(i.closest(".".concat(e)))return!0}else if(yr(i,e,!0))return!0;if(n){if(i.matches(n))return!0;if(i.closest(n))return!0}return!1}function wr(t){return void 0===t?"":t.toLowerCase()}function vr(t,e){var n,i=e.doc,r=e.mirror,s=e.blockClass,o=e.blockSelector,a=e.maskTextClass,l=e.maskTextSelector,c=e.skipChild,d=void 0!==c&&c,h=e.inlineStylesheet,u=void 0===h||h,p=e.maskInputOptions,g=void 0===p?{}:p,m=e.maskTextFn,f=e.maskInputFn,y=e.slimDOMOptions,b=e.dataURLOptions,w=void 0===b?{}:b,v=e.inlineImages,I=void 0!==v&&v,C=e.recordCanvas,S=void 0!==C&&C,_=e.onSerialize,k=e.onIframeLoad,x=e.iframeLoadTimeout,A=void 0===x?5e3:x,E=e.onStylesheetLoad,R=e.stylesheetLoadTimeout,M=void 0===R?5e3:R,T=e.keepIframeSrcFn,O=void 0===T?function(){return!1}:T,z=e.newlyAddedElement,N=void 0!==z&&z,L=e.preserveWhiteSpace,F=void 0===L||L,D=function(t,e){var n=e.doc,i=e.mirror,r=e.blockClass,s=e.blockSelector,o=e.maskTextClass,a=e.maskTextSelector,l=e.inlineStylesheet,c=e.maskInputOptions,d=void 0===c?{}:c,h=e.maskTextFn,u=e.maskInputFn,p=e.dataURLOptions,g=void 0===p?{}:p,m=e.inlineImages,f=e.recordCanvas,y=e.keepIframeSrcFn,b=e.newlyAddedElement,w=void 0!==b&&b,v=function(t,e){if(e.hasNode(t)){var n=e.getId(t);return 1===n?void 0:n}}(n,i);switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:Ki.Document,childNodes:[],compatMode:t.compatMode}:{type:Ki.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:Ki.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:v};case t.ELEMENT_NODE:return function(t,e){for(var n=e.doc,i=e.inlineStylesheet,r=e.maskInputOptions,s=void 0===r?{}:r,o=e.maskInputFn,a=e.dataURLOptions,l=void 0===a?{}:a,c=e.inlineImages,d=e.recordCanvas,h=e.keepIframeSrcFn,u=e.newlyAddedElement,p=void 0!==u&&u,g=e.rootId,m=function(t,e,n){if("string"==typeof e){if(t.classList.contains(e))return!0}else for(var i=t.classList.length;i--;){var r=t.classList[i];if(e.test(r))return!0}return!!n&&t.matches(n)}(t,e.blockClass,e.blockSelector),f=function(t){if(t instanceof HTMLFormElement)return"form";var e=t.tagName.toLowerCase().trim();return or.test(e)?"div":e}(t),y={},b=t.attributes.length,w=0;w<b;w++){var v=t.attributes[w];y[v.name]=fr(n,f,v.name,v.value)}if("link"===f&&i){var I=Array.from(n.styleSheets).find(function(e){return e.href===t.href}),C=null;I&&(C=Xi(I)),C&&(delete y.rel,delete y.href,y._cssText=hr(C,I.href))}if("style"===f&&t.sheet&&!(t.innerText||t.textContent||"").trim().length&&(C=Xi(t.sheet))&&(y._cssText=hr(C,mr())),"input"===f||"textarea"===f||"select"===f){var S=t.value,_=t.checked;"radio"!==y.type&&"checkbox"!==y.type&&"submit"!==y.type&&"button"!==y.type&&S?y.value=er({type:y.type,tagName:f,value:S,maskInputOptions:s,maskInputFn:o}):_&&(y.checked=_)}if("option"===f&&(t.selected&&!s.select?y.selected=!0:delete y.selected),"canvas"===f&&d)if("2d"===t.__context)(function(t){var e=t.getContext("2d");if(!e)return!0;for(var n=0;n<t.width;n+=50)for(var i=0;i<t.height;i+=50){var r=e.getImageData,s=rr in r?r[rr]:r;if(new Uint32Array(s.call(e,n,i,Math.min(50,t.width-n),Math.min(50,t.height-i)).data.buffer).some(function(t){return 0!==t}))return!1}return!0})(t)||(y.rr_dataURL=t.toDataURL(l.type,l.quality));else if(!("__context"in t)){var k=t.toDataURL(l.type,l.quality),x=document.createElement("canvas");x.width=t.width,x.height=t.height,k!==x.toDataURL(l.type,l.quality)&&(y.rr_dataURL=k)}if("img"===f&&c){nr||(nr=n.createElement("canvas"),ir=nr.getContext("2d"));var A=t,E=A.crossOrigin;A.crossOrigin="anonymous";var R=function(){try{nr.width=A.naturalWidth,nr.height=A.naturalHeight,ir.drawImage(A,0,0),y.rr_dataURL=nr.toDataURL(l.type,l.quality)}catch(t){console.warn("Cannot inline img src=".concat(A.currentSrc,"! Error: ").concat(t))}E?y.crossOrigin=E:A.removeAttribute("crossorigin")};A.complete&&0!==A.naturalWidth?R():A.onload=R}if("audio"!==f&&"video"!==f||(y.rr_mediaState=t.paused?"paused":"played",y.rr_mediaCurrentTime=t.currentTime),p||(t.scrollLeft&&(y.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(y.rr_scrollTop=t.scrollTop)),m){var M=t.getBoundingClientRect(),T=M.width,O=M.height;y={class:y.class,rr_width:"".concat(T,"px"),rr_height:"".concat(O,"px")}}return"iframe"!==f||h(y.src)||(t.contentDocument||(y.rr_src=y.src),delete y.src),{type:Ki.Element,tagName:f,attributes:y,childNodes:[],isSVG:(z=t,Boolean("svg"===z.tagName||z.ownerSVGElement)||void 0),needBlock:m,rootId:g};var z}(t,{doc:n,blockClass:r,blockSelector:s,inlineStylesheet:l,maskInputOptions:d,maskInputFn:u,dataURLOptions:g,inlineImages:m,recordCanvas:f,keepIframeSrcFn:y,newlyAddedElement:w,rootId:v});case t.TEXT_NODE:return function(t,e){var n,i,r=e.maskTextClass,s=e.maskTextSelector,o=e.maskTextFn,a=e.rootId,l=t.parentNode&&t.parentNode.tagName,c=t.textContent,d="STYLE"===l||void 0,h="SCRIPT"===l||void 0;if(d&&c){try{t.nextSibling||t.previousSibling||(null===(n=t.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(i=t.parentNode.sheet).cssRules?Array.from(i.cssRules).map(function(t){return t.cssText||""}).join(""):"")}catch(e){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(e),t)}c=hr(c,mr())}return h&&(c="SCRIPT_PLACEHOLDER"),!d&&!h&&c&&br(t,r,s)&&(c=o?o(c):c.replace(/[\S]/g,"*")),{type:Ki.Text,textContent:c||"",isStyle:d,rootId:a}}(t,{maskTextClass:o,maskTextSelector:a,maskTextFn:h,rootId:v});case t.CDATA_SECTION_NODE:return{type:Ki.CDATA,textContent:"",rootId:v};case t.COMMENT_NODE:return{type:Ki.Comment,textContent:t.textContent||"",rootId:v};default:return!1}}(t,{doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,dataURLOptions:w,inlineImages:I,recordCanvas:S,keepIframeSrcFn:O,newlyAddedElement:N});if(!D)return console.warn(t,"not serialized"),null;n=r.hasNode(t)?r.getId(t):!function(t,e){if(e.comment&&t.type===Ki.Comment)return!0;if(t.type===Ki.Element){if(e.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(e.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(wr(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===wr(t.attributes.name)||"icon"===wr(t.attributes.rel)||"apple-touch-icon"===wr(t.attributes.rel)||"shortcut icon"===wr(t.attributes.rel))))return!0;if("meta"===t.tagName){if(e.headMetaDescKeywords&&wr(t.attributes.name).match(/^description|keywords$/))return!0;if(e.headMetaSocial&&(wr(t.attributes.property).match(/^(og|twitter|fb):/)||wr(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===wr(t.attributes.name)))return!0;if(e.headMetaRobots&&("robots"===wr(t.attributes.name)||"googlebot"===wr(t.attributes.name)||"bingbot"===wr(t.attributes.name)))return!0;if(e.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(e.headMetaAuthorship&&("author"===wr(t.attributes.name)||"generator"===wr(t.attributes.name)||"framework"===wr(t.attributes.name)||"publisher"===wr(t.attributes.name)||"progid"===wr(t.attributes.name)||wr(t.attributes.property).match(/^article:/)||wr(t.attributes.property).match(/^product:/)))return!0;if(e.headMetaVerification&&("google-site-verification"===wr(t.attributes.name)||"yandex-verification"===wr(t.attributes.name)||"csrf-token"===wr(t.attributes.name)||"p:domain_verify"===wr(t.attributes.name)||"verify-v1"===wr(t.attributes.name)||"verification"===wr(t.attributes.name)||"shopify-checkout-api-token"===wr(t.attributes.name)))return!0}}return!1}(D,y)&&(F||D.type!==Ki.Text||D.isStyle||D.textContent.replace(/^\s+|\s+$/gm,"").length)?ar():-2;var B=Object.assign(D,{id:n});if(r.add(t,B),-2===n)return null;_&&_(t);var U=!d;if(B.type===Ki.Element){U=U&&!B.needBlock,delete B.needBlock;var Z=t.shadowRoot;Z&&Qi(Z)&&(B.isShadowHost=!0)}if((B.type===Ki.Document||B.type===Ki.Element)&&U){y.headWhitespace&&B.type===Ki.Element&&"head"===B.tagName&&(F=!1);for(var P={doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:d,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:I,recordCanvas:S,preserveWhiteSpace:F,onSerialize:_,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:O},$=0,G=Array.from(t.childNodes);$<G.length;$++)(V=vr(G[$],P))&&B.childNodes.push(V);if(function(t){return t.nodeType===t.ELEMENT_NODE}(t)&&t.shadowRoot)for(var W=0,j=Array.from(t.shadowRoot.childNodes);W<j.length;W++){var V;(V=vr(j[W],P))&&(Qi(t.shadowRoot)&&(V.isShadow=!0),B.childNodes.push(V))}}return t.parentNode&&Yi(t.parentNode)&&Qi(t.parentNode)&&(B.isShadow=!0),B.type===Ki.Element&&"iframe"===B.tagName&&function(t,e,n){var i=t.contentWindow;if(i){var r,s=!1;try{r=i.document.readyState}catch(t){return}if("complete"===r){var o="about:blank";if(i.location.href!==o||t.src===o||""===t.src)return setTimeout(e,0),t.addEventListener("load",e);t.addEventListener("load",e)}else{var a=setTimeout(function(){s||(e(),s=!0)},n);t.addEventListener("load",function(){clearTimeout(a),s=!0,e()})}}}(t,function(){var e=t.contentDocument;if(e&&k){var n=vr(e,{doc:e,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:I,recordCanvas:S,preserveWhiteSpace:F,onSerialize:_,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:O});n&&k(t,n)}},A),B.type===Ki.Element&&"link"===B.tagName&&"stylesheet"===B.attributes.rel&&function(t,e,n){var i,r=!1;try{i=t.sheet}catch(t){return}if(!i){var s=setTimeout(function(){r||(e(),r=!0)},n);t.addEventListener("load",function(){clearTimeout(s),r=!0,e()})}}(t,function(){if(E){var e=vr(t,{doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:I,recordCanvas:S,preserveWhiteSpace:F,onSerialize:_,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:O});e&&E(t,e)}},M),B}function Ir(t,e,n=document){const i={capture:!0,passive:!0};return n.addEventListener(t,e,i),()=>n.removeEventListener(t,e,i)}new RegExp(/([^\\]):hover/.source,"g");const Cr="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Sr={map:{},getId:()=>(console.error(Cr),-1),getNode:()=>(console.error(Cr),null),removeNodeFromMap(){console.error(Cr)},has:()=>(console.error(Cr),!1),reset(){console.error(Cr)}};function _r(t,e,n={}){let i=null,r=0;return function(...s){const o=Date.now();r||!1!==n.leading||(r=o);const a=e-(o-r),l=this;a<=0||a>e?(i&&(clearTimeout(i),i=null),r=o,t.apply(l,s)):i||!1===n.trailing||(i=setTimeout(()=>{r=!1===n.leading?0:Date.now(),i=null,t.apply(l,s)},a))}}function kr(t,e,n,i,r=window){const s=r.Object.getOwnPropertyDescriptor(t,e);return r.Object.defineProperty(t,e,i?n:{set(t){setTimeout(()=>{n.set.call(this,t)},0),s&&s.set&&s.set.call(this,t)}}),()=>kr(t,e,s||{},!0)}function xr(t,e,n){try{if(!(e in t))return()=>{};const i=t[e],r=n(i);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:i}})),t[e]=r,()=>{t[e]=i}}catch(t){return()=>{}}}function Ar(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Er(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Rr(t,e,n,i){if(!t)return!1;const r=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(!r)return!1;if("string"==typeof e){if(r.classList.contains(e))return!0;if(i&&null!==r.closest("."+e))return!0}else if(yr(r,e,i))return!0;if(n){if(t.matches(n))return!0;if(i&&null!==r.closest(n))return!0}return!1}function Mr(t,e){return-2===e.getId(t)}function Tr(t,e){if(Yi(t))return!1;const n=e.getId(t);return!e.has(n)||(!t.parentNode||t.parentNode.nodeType!==t.DOCUMENT_NODE)&&(!t.parentNode||Tr(t.parentNode,e))}function Or(t){return Boolean(t.changedTouches)}function zr(t,e){return Boolean("IFRAME"===t.nodeName&&e.getMeta(t))}function Nr(t,e){return Boolean("LINK"===t.nodeName&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&"stylesheet"===t.getAttribute("rel")&&e.getMeta(t))}function Lr(t){return Boolean(null==t?void 0:t.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Sr=new Proxy(Sr,{get:(t,e,n)=>("map"===e&&console.error(Cr),Reflect.get(t,e,n))}));class Fr{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var e;return null!==(e=this.styleIDMap.get(t))&&void 0!==e?e:-1}has(t){return this.styleIDMap.has(t)}add(t,e){if(this.has(t))return this.getId(t);let n;return n=void 0===e?this.id++:e,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var Dr=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Dr||{}),Br=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t))(Br||{}),Ur=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(Ur||{}),Zr=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(Zr||{});function Pr(t){return"__ln"in t}class $r{constructor(){this.length=0,this.head=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let e=this.head;for(let n=0;n<t;n++)e=(null==e?void 0:e.next)||null;return e}addNode(t){const e={value:t,previous:null,next:null};if(t.__ln=e,t.previousSibling&&Pr(t.previousSibling)){const n=t.previousSibling.__ln.next;e.next=n,e.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=e,n&&(n.previous=e)}else if(t.nextSibling&&Pr(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;e.previous=n,e.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=e,n&&(n.next=e)}else this.head&&(this.head.previous=e),e.next=this.head,this.head=e;this.length++}removeNode(t){const e=t.__ln;this.head&&(e.previous?(e.previous.next=e.next,e.next&&(e.next.previous=e.previous)):(this.head=e.next,this.head&&(this.head.previous=null)),t.__ln&&delete t.__ln,this.length--)}}const Gr=(t,e)=>`${t}@${e}`;class Wr{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],e=new $r,n=t=>{let e=t,n=-2;for(;-2===n;)e=e&&e.nextSibling,n=e&&this.mirror.getId(e);return n},i=i=>{var r,s,o,a;let l=null;(null===(s=null===(r=i.getRootNode)||void 0===r?void 0:r.call(i))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&i.getRootNode().host&&(l=i.getRootNode().host);let c=l;for(;(null===(a=null===(o=null==c?void 0:c.getRootNode)||void 0===o?void 0:o.call(c))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&c.getRootNode().host;)c=c.getRootNode().host;const d=!(this.doc.contains(i)||c&&this.doc.contains(c));if(!i.parentNode||d)return;const h=Yi(i.parentNode)?this.mirror.getId(l):this.mirror.getId(i.parentNode),u=n(i);if(-1===h||-1===u)return e.addNode(i);const p=vr(i,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:t=>{zr(t,this.mirror)&&this.iframeManager.addIframe(t),Nr(t,this.mirror)&&this.stylesheetManager.trackLinkElement(t),Lr(i)&&this.shadowDomManager.addShadowRoot(i.shadowRoot,this.doc)},onIframeLoad:(t,e)=>{this.iframeManager.attachIframe(t,e),this.shadowDomManager.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{this.stylesheetManager.attachLinkElement(t,e)}});p&&t.push({parentId:h,nextId:u,node:p})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const t of Array.from(this.movedSet.values()))Vr(this.removes,t,this.mirror)&&!this.movedSet.has(t.parentNode)||i(t);for(const t of Array.from(this.addedSet.values()))qr(this.droppedSet,t)||Vr(this.removes,t,this.mirror)?qr(this.movedSet,t)?i(t):this.droppedSet.add(t):i(t);let r=null;for(;e.length;){let t=null;if(r){const e=this.mirror.getId(r.value.parentNode),i=n(r.value);-1!==e&&-1!==i&&(t=r)}if(!t)for(let i=e.length-1;i>=0;i--){const r=e.get(i);if(r){const e=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==e){t=r;break}{const e=r.value;if(e.parentNode&&e.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=e.parentNode.host;if(-1!==this.mirror.getId(n)){t=r;break}}}}}if(!t){for(;e.head;)e.removeNode(e.head.value);break}r=t.previous,e.removeNode(t.value),i(t.value)}const s={texts:this.texts.map(t=>({id:this.mirror.getId(t.node),value:t.value})).filter(t=>this.mirror.has(t.id)),attributes:this.attributes.map(t=>({id:this.mirror.getId(t.node),attributes:t.attributes})).filter(t=>this.mirror.has(t.id)),removes:this.removes,adds:t};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=t=>{if(!Mr(t.target,this.mirror))switch(t.type){case"characterData":{const e=t.target.textContent;Rr(t.target,this.blockClass,this.blockSelector,!1)||e===t.oldValue||this.texts.push({value:br(t.target,this.maskTextClass,this.maskTextSelector)&&e?this.maskTextFn?this.maskTextFn(e):e.replace(/[\S]/g,"*"):e,node:t.target});break}case"attributes":{const e=t.target;let n=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(n=er({maskInputOptions:this.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),Rr(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let i=this.attributes.find(e=>e.node===t.target);if("IFRAME"===e.tagName&&"src"===t.attributeName&&!this.keepIframeSrcFn(n)){if(e.contentDocument)return;t.attributeName="rr_src"}if(i||(i={node:t.target,attributes:{}},this.attributes.push(i)),"style"===t.attributeName){const n=this.doc.createElement("span");t.oldValue&&n.setAttribute("style",t.oldValue),void 0!==i.attributes.style&&null!==i.attributes.style||(i.attributes.style={});const r=i.attributes.style;for(const t of Array.from(e.style)){const i=e.style.getPropertyValue(t),s=e.style.getPropertyPriority(t);i===n.style.getPropertyValue(t)&&s===n.style.getPropertyPriority(t)||(r[t]=""===s?i:[i,s])}for(const t of Array.from(n.style))""===e.style.getPropertyValue(t)&&(r[t]=!1)}else i.attributes[t.attributeName]=fr(this.doc,e.tagName,t.attributeName,n);break}case"childList":if(Rr(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(e=>this.genAdds(e,t.target)),t.removedNodes.forEach(e=>{const n=this.mirror.getId(e),i=Yi(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);Rr(t.target,this.blockClass,this.blockSelector,!1)||Mr(e,this.mirror)||!function(t,e){return-1!==e.getId(t)}(e,this.mirror)||(this.addedSet.has(e)?(jr(this.addedSet,e),this.droppedSet.add(e)):this.addedSet.has(t.target)&&-1===n||Tr(t.target,this.mirror)||(this.movedSet.has(e)&&this.movedMap[Gr(n,i)]?jr(this.movedSet,e):this.removes.push({parentId:i,id:n,isShadow:!(!Yi(t.target)||!Qi(t.target))||void 0})),this.mapRemoves.push(e))})}},this.genAdds=(t,e)=>{if(this.mirror.hasNode(t)){if(Mr(t,this.mirror))return;this.movedSet.add(t);let n=null;e&&this.mirror.hasNode(e)&&(n=this.mirror.getId(e)),n&&-1!==n&&(this.movedMap[Gr(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);Rr(t,this.blockClass,this.blockSelector,!1)||t.childNodes.forEach(t=>this.genAdds(t))}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(e=>{this[e]=t[e]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function jr(t,e){t.delete(e),e.childNodes.forEach(e=>jr(t,e))}function Vr(t,e,n){return 0!==t.length&&Hr(t,e,n)}function Hr(t,e,n){const{parentNode:i}=e;if(!i)return!1;const r=n.getId(i);return!!t.some(t=>t.id===r)||Hr(t,i,n)}function qr(t,e){return 0!==t.size&&Kr(t,e)}function Kr(t,e){const{parentNode:n}=e;return!!n&&(!!t.has(n)||Kr(t,n))}const Yr=[],Qr="undefined"!=typeof CSSGroupingRule,Xr="undefined"!=typeof CSSMediaRule,Jr="undefined"!=typeof CSSSupportsRule,ts="undefined"!=typeof CSSConditionRule;function es(t){try{if("composedPath"in t){const e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0];return t.target}catch(e){return t.target}}function ns(t,e){var n,i;const r=new Wr;Yr.push(r),r.init(t);let s=window.MutationObserver||window.__rrMutationObserver;const o=null===(i=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===i?void 0:i.call(n,"MutationObserver");o&&window[o]&&(s=window[o]);const a=new s(r.processMutations.bind(r));return a.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function is({scrollCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,sampling:s}){return Ir("scroll",_r(s=>{const o=es(s);if(!o||Rr(o,i,r,!0))return;const a=n.getId(o);if(o===e){const n=e.scrollingElement||e.documentElement;t({id:a,x:n.scrollLeft,y:n.scrollTop})}else t({id:a,x:o.scrollLeft,y:o.scrollTop})},s.scroll||100),e)}function rs(t,e){const n=Object.assign({},t);return e||delete n.userTriggered,n}const ss=["INPUT","TEXTAREA","SELECT"],os=new WeakMap;function as(t){return function(t,e){if(Qr&&t.parentRule instanceof CSSGroupingRule||Xr&&t.parentRule instanceof CSSMediaRule||Jr&&t.parentRule instanceof CSSSupportsRule||ts&&t.parentRule instanceof CSSConditionRule){const n=Array.from(t.parentRule.cssRules).indexOf(t);e.unshift(n)}else if(t.parentStyleSheet){const n=Array.from(t.parentStyleSheet.cssRules).indexOf(t);e.unshift(n)}return e}(t,[])}function ls(t,e,n){let i,r;return t?(t.ownerNode?i=e.getId(t.ownerNode):r=n.getId(t),{styleId:r,id:i}):{}}function cs({mirror:t,stylesheetManager:e},n){var i,r,s;let o=null;o="#document"===n.nodeName?t.getId(n):t.getId(n.host);const a="#document"===n.nodeName?null===(i=n.defaultView)||void 0===i?void 0:i.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===s?void 0:s.ShadowRoot,l=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==o&&-1!==o&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var t;return null===(t=l.get)||void 0===t?void 0:t.call(this)},set(t){var n;const i=null===(n=l.set)||void 0===n?void 0:n.call(this,t);if(null!==o&&-1!==o)try{e.adoptStyleSheets(t,o)}catch(t){}return i}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})}):()=>{}}function ds(t,e={}){const n=t.doc.defaultView;if(!n)return()=>{};!function(t,e){const{mutationCb:n,mousemoveCb:i,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:h,fontCb:u,selectionCb:p}=t;t.mutationCb=(...t)=>{e.mutation&&e.mutation(...t),n(...t)},t.mousemoveCb=(...t)=>{e.mousemove&&e.mousemove(...t),i(...t)},t.mouseInteractionCb=(...t)=>{e.mouseInteraction&&e.mouseInteraction(...t),r(...t)},t.scrollCb=(...t)=>{e.scroll&&e.scroll(...t),s(...t)},t.viewportResizeCb=(...t)=>{e.viewportResize&&e.viewportResize(...t),o(...t)},t.inputCb=(...t)=>{e.input&&e.input(...t),a(...t)},t.mediaInteractionCb=(...t)=>{e.mediaInteaction&&e.mediaInteaction(...t),l(...t)},t.styleSheetRuleCb=(...t)=>{e.styleSheetRule&&e.styleSheetRule(...t),c(...t)},t.styleDeclarationCb=(...t)=>{e.styleDeclaration&&e.styleDeclaration(...t),d(...t)},t.canvasMutationCb=(...t)=>{e.canvasMutation&&e.canvasMutation(...t),h(...t)},t.fontCb=(...t)=>{e.font&&e.font(...t),u(...t)},t.selectionCb=(...t)=>{e.selection&&e.selection(...t),p(...t)}}(t,e);const i=ns(t,t.doc),r=function({mousemoveCb:t,sampling:e,doc:n,mirror:i}){if(!1===e.mousemove)return()=>{};const r="number"==typeof e.mousemove?e.mousemove:50,s="number"==typeof e.mousemoveCallback?e.mousemoveCallback:500;let o,a=[];const l=_r(e=>{const n=Date.now()-o;t(a.map(t=>(t.timeOffset-=n,t)),e),a=[],o=null},s),c=_r(t=>{const e=es(t),{clientX:n,clientY:r}=Or(t)?t.changedTouches[0]:t;o||(o=Date.now()),a.push({x:n,y:r,id:i.getId(e),timeOffset:Date.now()-o}),l("undefined"!=typeof DragEvent&&t instanceof DragEvent?Br.Drag:t instanceof MouseEvent?Br.MouseMove:Br.TouchMove)},r,{trailing:!1}),d=[Ir("mousemove",c,n),Ir("touchmove",c,n),Ir("drag",c,n)];return()=>{d.forEach(t=>t())}}(t),s=function({mouseInteractionCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const o=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(Ur).filter(t=>Number.isNaN(Number(t))&&!t.endsWith("_Departed")&&!1!==o[t]).forEach(s=>{const o=s.toLowerCase(),l=(e=>s=>{const o=es(s);if(Rr(o,i,r,!0))return;const a=Or(s)?s.changedTouches[0]:s;if(!a)return;const l=n.getId(o),{clientX:c,clientY:d}=a;t({type:Ur[e],id:l,x:c,y:d})})(s);a.push(Ir(o,l,e))}),()=>{a.forEach(t=>t())}}(t),o=is(t),a=function({viewportResizeCb:t}){let e=-1,n=-1;return Ir("resize",_r(()=>{const i=Ar(),r=Er();e===i&&n===r||(t({width:Number(r),height:Number(i)}),e=i,n=r)},200),window)}(t),l=function({inputCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,ignoreClass:s,maskInputOptions:o,maskInputFn:a,sampling:l,userTriggeredOnInput:c}){function d(t){let n=es(t);const l=t.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||ss.indexOf(n.tagName)<0||Rr(n,i,r,!0))return;const d=n.type;if(n.classList.contains(s))return;let u=n.value,p=!1;"radio"===d||"checkbox"===d?p=n.checked:(o[n.tagName.toLowerCase()]||o[d])&&(u=er({maskInputOptions:o,tagName:n.tagName,type:d,value:u,maskInputFn:a})),h(n,rs({text:u,isChecked:p,userTriggered:l},c));const g=n.name;"radio"===d&&g&&p&&e.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(t=>{t!==n&&h(t,rs({text:t.value,isChecked:!p,userTriggered:!1},c))})}function h(e,i){const r=os.get(e);if(!r||r.text!==i.text||r.isChecked!==i.isChecked){os.set(e,i);const r=n.getId(e);t(Object.assign(Object.assign({},i),{id:r}))}}const u=("last"===l.input?["change"]:["input","change"]).map(t=>Ir(t,d,e)),p=e.defaultView;if(!p)return()=>{u.forEach(t=>t())};const g=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),m=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&u.push(...m.map(t=>kr(t[0],t[1],{set(){d({target:this})}},!1,p))),()=>{u.forEach(t=>t())}}(t),c=function({mediaInteractionCb:t,blockClass:e,blockSelector:n,mirror:i,sampling:r}){const s=s=>_r(r=>{const o=es(r);if(!o||Rr(o,e,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d}=o;t({type:s,id:i.getId(o),currentTime:a,volume:l,muted:c,playbackRate:d})},r.media||500),o=[Ir("play",s(0)),Ir("pause",s(1)),Ir("seeked",s(2)),Ir("volumechange",s(3)),Ir("ratechange",s(4))];return()=>{o.forEach(t=>t())}}(t),d=function({styleSheetRuleCb:t,mirror:e,stylesheetManager:n},{win:i}){const r=i.CSSStyleSheet.prototype.insertRule;i.CSSStyleSheet.prototype.insertRule=function(i,s){const{id:o,styleId:a}=ls(this,e,n.styleMirror);return(o&&-1!==o||a&&-1!==a)&&t({id:o,styleId:a,adds:[{rule:i,index:s}]}),r.apply(this,[i,s])};const s=i.CSSStyleSheet.prototype.deleteRule;let o,a;i.CSSStyleSheet.prototype.deleteRule=function(i){const{id:r,styleId:o}=ls(this,e,n.styleMirror);return(r&&-1!==r||o&&-1!==o)&&t({id:r,styleId:o,removes:[{index:i}]}),s.apply(this,[i])},i.CSSStyleSheet.prototype.replace&&(o=i.CSSStyleSheet.prototype.replace,i.CSSStyleSheet.prototype.replace=function(i){const{id:r,styleId:s}=ls(this,e,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&t({id:r,styleId:s,replace:i}),o.apply(this,[i])}),i.CSSStyleSheet.prototype.replaceSync&&(a=i.CSSStyleSheet.prototype.replaceSync,i.CSSStyleSheet.prototype.replaceSync=function(i){const{id:r,styleId:s}=ls(this,e,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&t({id:r,styleId:s,replaceSync:i}),a.apply(this,[i])});const l={};Qr?l.CSSGroupingRule=i.CSSGroupingRule:(Xr&&(l.CSSMediaRule=i.CSSMediaRule),ts&&(l.CSSConditionRule=i.CSSConditionRule),Jr&&(l.CSSSupportsRule=i.CSSSupportsRule));const c={};return Object.entries(l).forEach(([i,r])=>{c[i]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,s){const{id:o,styleId:a}=ls(this.parentStyleSheet,e,n.styleMirror);return(o&&-1!==o||a&&-1!==a)&&t({id:o,styleId:a,adds:[{rule:r,index:[...as(this),s||0]}]}),c[i].insertRule.apply(this,[r,s])},r.prototype.deleteRule=function(r){const{id:s,styleId:o}=ls(this.parentStyleSheet,e,n.styleMirror);return(s&&-1!==s||o&&-1!==o)&&t({id:s,styleId:o,removes:[{index:[...as(this),r]}]}),c[i].deleteRule.apply(this,[r])}}),()=>{i.CSSStyleSheet.prototype.insertRule=r,i.CSSStyleSheet.prototype.deleteRule=s,o&&(i.CSSStyleSheet.prototype.replace=o),a&&(i.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([t,e])=>{e.prototype.insertRule=c[t].insertRule,e.prototype.deleteRule=c[t].deleteRule})}}(t,{win:n}),h=cs(t,t.doc),u=function({styleDeclarationCb:t,mirror:e,ignoreCSSAttributes:n,stylesheetManager:i},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,o,a){var l;if(n.has(r))return s.apply(this,[r,o,a]);const{id:c,styleId:d}=ls(null===(l=this.parentRule)||void 0===l?void 0:l.parentStyleSheet,e,i.styleMirror);return(c&&-1!==c||d&&-1!==d)&&t({id:c,styleId:d,set:{property:r,value:o,priority:a},index:as(this.parentRule)}),s.apply(this,[r,o,a])};const o=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var s;if(n.has(r))return o.apply(this,[r]);const{id:a,styleId:l}=ls(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,e,i.styleMirror);return(a&&-1!==a||l&&-1!==l)&&t({id:a,styleId:l,remove:{property:r},index:as(this.parentRule)}),o.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=o}}(t,{win:n}),p=t.collectFonts?function({fontCb:t,doc:e}){const n=e.defaultView;if(!n)return()=>{};const i=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(t,e,n){const i=new s(t,e,n);return r.set(i,{family:t,buffer:"string"!=typeof e,descriptors:n,fontSource:"string"==typeof e?e:JSON.stringify(Array.from(new Uint8Array(e)))}),i};const o=xr(e.fonts,"add",function(e){return function(n){return setTimeout(()=>{const e=r.get(n);e&&(t(e),r.delete(n))},0),e.apply(this,[n])}});return i.push(()=>{n.FontFace=s}),i.push(o),()=>{i.forEach(t=>t())}}(t):()=>{},g=function(t){const{doc:e,mirror:n,blockClass:i,blockSelector:r,selectionCb:s}=t;let o=!0;const a=()=>{const t=e.getSelection();if(!t||o&&(null==t?void 0:t.isCollapsed))return;o=t.isCollapsed||!1;const a=[],l=t.rangeCount||0;for(let e=0;e<l;e++){const s=t.getRangeAt(e),{startContainer:o,startOffset:l,endContainer:c,endOffset:d}=s;Rr(o,i,r,!0)||Rr(c,i,r,!0)||a.push({start:n.getId(o),startOffset:l,end:n.getId(c),endOffset:d})}s({ranges:a})};return a(),Ir("selectionchange",a)}(t),m=[];for(const e of t.plugins)m.push(e.observer(e.callback,n,e.options));return()=>{Yr.forEach(t=>t.reset()),i.disconnect(),r(),s(),o(),a(),l(),c(),d(),h(),u(),p(),g(),m.forEach(t=>t())}}class hs{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,e,n,i){const r=n||this.getIdToRemoteIdMap(t),s=i||this.getRemoteIdToIdMap(t);let o=r.get(e);return o||(o=this.generateIdFn(),r.set(e,o),s.set(o,e)),o}getIds(t,e){const n=this.getIdToRemoteIdMap(t),i=this.getRemoteIdToIdMap(t);return e.map(e=>this.getId(t,e,n,i))}getRemoteId(t,e,n){const i=n||this.getRemoteIdToIdMap(t);if("number"!=typeof e)return e;return i.get(e)||-1}getRemoteIds(t,e){const n=this.getRemoteIdToIdMap(t);return e.map(e=>this.getRemoteId(t,e,n))}reset(t){if(!t)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let e=this.iframeIdToRemoteIdMap.get(t);return e||(e=new Map,this.iframeIdToRemoteIdMap.set(t,e)),e}getRemoteIdToIdMap(t){let e=this.iframeRemoteIdToIdMap.get(t);return e||(e=new Map,this.iframeRemoteIdToIdMap.set(t,e)),e}}class us{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new hs(ar),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new hs(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,e){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:e}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){if("rrweb"===t.data.type){if(!t.source)return;const e=this.crossOriginIframeMap.get(t.source);if(!e)return;const n=this.transformCrossOriginEvent(e,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}}transformCrossOriginEvent(t,e){var n;switch(e.type){case Dr.FullSnapshot:return this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(e.data.node,t),{timestamp:e.timestamp,type:Dr.IncrementalSnapshot,data:{source:Br.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:e.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Dr.Meta:case Dr.Load:case Dr.DomContentLoaded:return!1;case Dr.Plugin:return e;case Dr.Custom:return this.replaceIds(e.data.payload,t,["id","parentId","previousId","nextId"]),e;case Dr.IncrementalSnapshot:switch(e.data.source){case Br.Mutation:return e.data.adds.forEach(e=>{this.replaceIds(e,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(e.node,t)}),e.data.removes.forEach(e=>{this.replaceIds(e,t,["parentId","id"])}),e.data.attributes.forEach(e=>{this.replaceIds(e,t,["id"])}),e.data.texts.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Br.Drag:case Br.TouchMove:case Br.MouseMove:return e.data.positions.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Br.ViewportResize:return!1;case Br.MediaInteraction:case Br.MouseInteraction:case Br.Scroll:case Br.CanvasMutation:case Br.Input:return this.replaceIds(e.data,t,["id"]),e;case Br.StyleSheetRule:case Br.StyleDeclaration:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleId"]),e;case Br.Font:return e;case Br.Selection:return e.data.ranges.forEach(e=>{this.replaceIds(e,t,["start","end"])}),e;case Br.AdoptedStyleSheet:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleIds"]),null===(n=e.data.styles)||void 0===n||n.forEach(e=>{this.replaceStyleIds(e,t,["styleId"])}),e}}}replace(t,e,n,i){for(const r of i)(Array.isArray(e[r])||"number"==typeof e[r])&&(Array.isArray(e[r])?e[r]=t.getIds(n,e[r]):e[r]=t.getId(n,e[r]));return e}replaceIds(t,e,n){return this.replace(this.crossOriginIframeMirror,t,e,n)}replaceStyleIds(t,e,n){return this.replace(this.crossOriginIframeStyleMirror,t,e,n)}replaceIdOnNode(t,e){this.replaceIds(t,e,["id"]),"childNodes"in t&&t.childNodes.forEach(t=>{this.replaceIdOnNode(t,e)})}}class ps{constructor(t){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror;const e=this;this.restorePatches.push(xr(Element.prototype,"attachShadow",function(t){return function(n){const i=t.call(this,n);return this.shadowRoot&&e.addShadowRoot(this.shadowRoot,this.ownerDocument),i}}))}addShadowRoot(t,e){Qi(t)&&(this.shadowDoms.has(t)||(this.shadowDoms.add(t),ns(Object.assign(Object.assign({},this.bypassOptions),{doc:e,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t),is(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),cs({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t)},0)))}observeAttachShadow(t){if(t.contentWindow){const e=this;this.restorePatches.push(xr(t.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(i){const r=n.call(this,i);return this.shadowRoot&&e.addShadowRoot(this.shadowRoot,t.contentDocument),r}}))}}reset(){this.restorePatches.forEach(t=>t()),this.shadowDoms=new WeakSet}}for(var gs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ms="undefined"==typeof Uint8Array?[]:new Uint8Array(256),fs=0;fs<64;fs++)ms[gs.charCodeAt(fs)]=fs;const ys=new Map,bs=(t,e,n)=>{if(!t||!Is(t,e)&&"object"!=typeof t)return;const i=function(t,e){let n=ys.get(t);return n||(n=new Map,ys.set(t,n)),n.has(e)||n.set(e,[]),n.get(e)}(n,t.constructor.name);let r=i.indexOf(t);return-1===r&&(r=i.length,i.push(t)),r};function ws(t,e,n){if(t instanceof Array)return t.map(t=>ws(t,e,n));if(null===t)return t;if(t instanceof Float32Array||t instanceof Float64Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Int8Array||t instanceof Uint8ClampedArray)return{rr_type:t.constructor.name,args:[Object.values(t)]};if(t instanceof ArrayBuffer){const e=t.constructor.name,n=function(t){var e,n=new Uint8Array(t),i=n.length,r="";for(e=0;e<i;e+=3)r+=gs[n[e]>>2],r+=gs[(3&n[e])<<4|n[e+1]>>4],r+=gs[(15&n[e+1])<<2|n[e+2]>>6],r+=gs[63&n[e+2]];return i%3==2?r=r.substring(0,r.length-1)+"=":i%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(t);return{rr_type:e,base64:n}}if(t instanceof DataView)return{rr_type:t.constructor.name,args:[ws(t.buffer,e,n),t.byteOffset,t.byteLength]};if(t instanceof HTMLImageElement){const e=t.constructor.name,{src:n}=t;return{rr_type:e,src:n}}return t instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:t.toDataURL()}:t instanceof ImageData?{rr_type:t.constructor.name,args:[ws(t.data,e,n),t.width,t.height]}:Is(t,e)||"object"==typeof t?{rr_type:t.constructor.name,index:bs(t,e,n)}:t}const vs=(t,e,n)=>[...t].map(t=>ws(t,e,n)),Is=(t,e)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(t=>"function"==typeof e[t]);return Boolean(n.find(n=>t instanceof e[n]))};function Cs(t,e,n){const i=[];try{const r=xr(t.HTMLCanvasElement.prototype,"getContext",function(t){return function(i,...r){return Rr(this,e,n,!0)||"__context"in this||(this.__context=i),t.apply(this,[i,...r])}});i.push(r)}catch(t){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{i.forEach(t=>t())}}function Ss(t,e,n,i,r,s,o){const a=[],l=Object.getOwnPropertyNames(t);for(const s of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof t[s])continue;const l=xr(t,s,function(t){return function(...a){const l=t.apply(this,a);if(bs(l,o,this),!Rr(this.canvas,i,r,!0)){const t=vs([...a],o,this),i={type:e,property:s,args:t};n(this.canvas,i)}return l}});a.push(l)}catch(i){const r=kr(t,s,{set(t){n(this.canvas,{type:e,property:s,args:[t],setter:!0})}});a.push(r)}return a}var _s=null;try{var ks="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof require&&require("worker_threads")||"function"==typeof require&&require("worker_threads");_s=ks.Worker}catch(t){}var xs,As,Es=(xs="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",As=!1,"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)?function(t,e,n){var i=void 0===e?null:e,r=function(t,e){return Buffer.from(t,"base64").toString(e?"utf16":"utf8")}(t,void 0!==n&&n),s=r.indexOf("\n",10)+1,o=r.substring(s)+(i?"//# sourceMappingURL="+i:"");return function(t){return new _s(o,Object.assign({},t,{eval:!0}))}}(xs,null,As):function(t){var e;return function(n){return e=e||function(t,e,n){var i=void 0===e?null:e,r=function(t,e){var n=atob(t);if(e){for(var i=new Uint8Array(n.length),r=0,s=n.length;r<s;++r)i[r]=n.charCodeAt(r);return String.fromCharCode.apply(null,new Uint16Array(i.buffer))}return n}(t,void 0!==n&&n),s=r.indexOf("\n",10)+1,o=r.substring(s)+(i?"//# sourceMappingURL="+i:""),a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)}(t,null,false),new Worker(e,n)}}(xs));class Rs{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(t,e)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(t)||this.pendingCanvasMutations.set(t,[]),this.pendingCanvasMutations.get(t).push(e)};const{sampling:e="all",win:n,blockClass:i,blockSelector:r,recordCanvas:s,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,s&&"all"===e&&this.initCanvasMutationObserver(n,i,r),s&&"number"==typeof e&&this.initCanvasFPSObserver(e,n,i,r,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,e,n,i,r){const s=Cs(e,n,i),o=new Map,a=new Es;a.onmessage=t=>{const{id:e}=t.data;if(o.set(e,!1),!("base64"in t.data))return;const{base64:n,type:i,width:r,height:s}=t.data;this.mutationCb({id:e,type:Zr["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:i}]},0,0]}]})};const l=1e3/t;let c,d=0;const h=t=>{d&&t-d<l||(d=t,(()=>{const t=[];return e.document.querySelectorAll("canvas").forEach(e=>{Rr(e,n,i,!0)||t.push(e)}),t})().forEach(t=>{return e=this,n=void 0,s=function*(){var e;const n=this.mirror.getId(t);if(o.get(n))return;if(o.set(n,!0),["webgl","webgl2"].includes(t.__context)){const n=t.getContext(t.__context);!1===(null===(e=null==n?void 0:n.getContextAttributes())||void 0===e?void 0:e.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const i=yield createImageBitmap(t);a.postMessage({id:n,bitmap:i,width:t.width,height:t.height,dataURLOptions:r.dataURLOptions},[i])},new((i=void 0)||(i=Promise))(function(t,r){function o(t){try{l(s.next(t))}catch(t){r(t)}}function a(t){try{l(s.throw(t))}catch(t){r(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(o,a)}l((s=s.apply(e,n||[])).next())});var e,n,i,s})),c=requestAnimationFrame(h)};c=requestAnimationFrame(h),this.resetObservers=()=>{s(),cancelAnimationFrame(c)}}initCanvasMutationObserver(t,e,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=Cs(t,e,n),r=function(t,e,n,i){const r=[],s=Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype);for(const o of s)try{if("function"!=typeof e.CanvasRenderingContext2D.prototype[o])continue;const s=xr(e.CanvasRenderingContext2D.prototype,o,function(r){return function(...s){return Rr(this.canvas,n,i,!0)||setTimeout(()=>{const n=vs([...s],e,this);t(this.canvas,{type:Zr["2D"],property:o,args:n})},0),r.apply(this,s)}});r.push(s)}catch(n){const i=kr(e.CanvasRenderingContext2D.prototype,o,{set(e){t(this.canvas,{type:Zr["2D"],property:o,args:[e],setter:!0})}});r.push(i)}return()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,n),s=function(t,e,n,i){const r=[];return r.push(...Ss(e.WebGLRenderingContext.prototype,Zr.WebGL,t,n,i,0,e)),void 0!==e.WebGL2RenderingContext&&r.push(...Ss(e.WebGL2RenderingContext.prototype,Zr.WebGL2,t,n,i,0,e)),()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,n,this.mirror);this.resetObservers=()=>{i(),r(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=e=>{this.rafStamps.latestId=e,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,e)=>{const n=this.mirror.getId(e);this.flushPendingCanvasMutationFor(e,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,e){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||-1===e)return;const i=n.map(t=>{const e=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(t,["type"]);return e}),{type:r}=n[0];this.mutationCb({id:e,type:r,commands:i}),this.pendingCanvasMutations.delete(t)}}class Ms{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new Fr,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,e){"_cssText"in e.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:e.id,attributes:e.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,e){if(0===t.length)return;const n={id:e,styleIds:[]},i=[];for(const e of t){let t;if(this.styleMirror.has(e))t=this.styleMirror.getId(e);else{t=this.styleMirror.add(e);const n=Array.from(e.rules||CSSRule);i.push({styleId:t,rules:n.map((t,e)=>({rule:Ji(t),index:e}))})}n.styleIds.push(t)}i.length>0&&(n.styles=i),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}function Ts(t){return Object.assign(Object.assign({},t),{timestamp:Date.now()})}let Os,zs,Ns,Ls=!1;const Fs=new tr;function Ds(t={}){const{emit:e,checkoutEveryNms:n,checkoutEveryNth:i,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:o="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:l=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:u,maskInputFn:p,maskTextFn:g,hooks:m,packFn:f,sampling:y={},dataURLOptions:b={},mousemoveWait:w,recordCanvas:v=!1,recordCrossOriginIframes:I=!1,userTriggeredOnInput:C=!1,collectFonts:S=!1,inlineImages:_=!1,plugins:k,keepIframeSrcFn:x=()=>!1,ignoreCSSAttributes:A=new Set([])}=t,E=!I||window.parent===window;let R=!1;if(!E)try{window.parent.document,R=!1}catch(t){R=!0}if(E&&!e)throw new Error("emit function is required");void 0!==w&&void 0===y.mousemove&&(y.mousemove=w),Fs.reset();const M=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},T=!0===u||"all"===u?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===u,headMetaDescKeywords:"all"===u}:u||{};let O;!function(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let e=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1})}();let z=0;const N=t=>{for(const e of k||[])e.eventProcessor&&(t=e.eventProcessor(t));return f&&(t=f(t)),t};Os=(t,r)=>{var s;if(!(null===(s=Yr[0])||void 0===s?void 0:s.isFrozen())||t.type===Dr.FullSnapshot||t.type===Dr.IncrementalSnapshot&&t.data.source===Br.Mutation||Yr.forEach(t=>t.unfreeze()),E)null==e||e(N(t),r);else if(R){const e={type:"rrweb",event:N(t),isCheckout:r};window.parent.postMessage(e,"*")}if(t.type===Dr.FullSnapshot)O=t,z=0;else if(t.type===Dr.IncrementalSnapshot){if(t.data.source===Br.Mutation&&t.data.isAttachIframe)return;z++;const e=i&&z>=i,r=n&&t.timestamp-O.timestamp>n;(e||r)&&zs(!0)}};const L=t=>{Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.Mutation},t)}))},F=t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.Scroll},t)})),D=t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.CanvasMutation},t)})),B=new Ms({mutationCb:L,adoptedStyleSheetCb:t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.AdoptedStyleSheet},t)}))}),U=new us({mirror:Fs,mutationCb:L,stylesheetManager:B,recordCrossOriginIframes:I,wrappedEmit:Os});for(const t of k||[])t.getMirror&&t.getMirror({nodeMirror:Fs,crossOriginIframeMirror:U.crossOriginIframeMirror,crossOriginIframeStyleMirror:U.crossOriginIframeStyleMirror});Ns=new Rs({recordCanvas:v,mutationCb:D,win:window,blockClass:r,blockSelector:s,mirror:Fs,sampling:y.canvas,dataURLOptions:b});const Z=new ps({mutationCb:L,scrollCb:F,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskInputOptions:M,dataURLOptions:b,maskTextFn:g,maskInputFn:p,recordCanvas:v,inlineImages:_,sampling:y,slimDOMOptions:T,iframeManager:U,stylesheetManager:B,canvasManager:Ns,keepIframeSrcFn:x},mirror:Fs});zs=(t=!1)=>{var e,n,i,o,d,h;Os(Ts({type:Dr.Meta,data:{href:window.location.href,width:Er(),height:Ar()}}),t),B.reset(),Yr.forEach(t=>t.lock());const u=function(t,e){var n=e||{},i=n.mirror,r=void 0===i?new tr:i,s=n.blockClass,o=n.blockSelector,a=n.maskTextClass,l=n.maskTextSelector,c=n.inlineStylesheet,d=n.inlineImages,h=n.recordCanvas,u=n.maskAllInputs,p=void 0!==u&&u,g=n.slimDOM,m=void 0!==g&&g,f=n.keepIframeSrcFn;return vr(t,{doc:t,mirror:r,blockClass:void 0===s?"rr-block":s,blockSelector:void 0===o?null:o,maskTextClass:void 0===a?"rr-mask":a,maskTextSelector:void 0===l?null:l,skipChild:!1,inlineStylesheet:void 0===c||c,maskInputOptions:!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===p?{password:!0}:p,maskTextFn:n.maskTextFn,maskInputFn:n.maskInputFn,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,dataURLOptions:n.dataURLOptions,inlineImages:void 0!==d&&d,recordCanvas:void 0!==h&&h,preserveWhiteSpace:n.preserveWhiteSpace,onSerialize:n.onSerialize,onIframeLoad:n.onIframeLoad,iframeLoadTimeout:n.iframeLoadTimeout,onStylesheetLoad:n.onStylesheetLoad,stylesheetLoadTimeout:n.stylesheetLoadTimeout,keepIframeSrcFn:void 0===f?function(){return!1}:f,newlyAddedElement:!1})}(document,{mirror:Fs,blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskAllInputs:M,maskTextFn:g,slimDOM:T,dataURLOptions:b,recordCanvas:v,inlineImages:_,onSerialize:t=>{zr(t,Fs)&&U.addIframe(t),Nr(t,Fs)&&B.trackLinkElement(t),Lr(t)&&Z.addShadowRoot(t.shadowRoot,document)},onIframeLoad:(t,e)=>{U.attachIframe(t,e),Z.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{B.attachLinkElement(t,e)},keepIframeSrcFn:x});if(!u)return console.warn("Failed to snapshot the document");Os(Ts({type:Dr.FullSnapshot,data:{node:u,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(e=null===document||void 0===document?void 0:document.body)||void 0===e?void 0:e.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),Yr.forEach(t=>t.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&B.adoptStyleSheets(document.adoptedStyleSheets,Fs.getId(document))};try{const t=[];t.push(Ir("DOMContentLoaded",()=>{Os(Ts({type:Dr.DomContentLoaded,data:{}}))}));const e=t=>{var e;return ds({mutationCb:L,mousemoveCb:(t,e)=>Os(Ts({type:Dr.IncrementalSnapshot,data:{source:e,positions:t}})),mouseInteractionCb:t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.MouseInteraction},t)})),scrollCb:F,viewportResizeCb:t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.ViewportResize},t)})),inputCb:t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.Input},t)})),mediaInteractionCb:t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.MediaInteraction},t)})),styleSheetRuleCb:t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.StyleSheetRule},t)})),styleDeclarationCb:t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.StyleDeclaration},t)})),canvasMutationCb:D,fontCb:t=>Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.Font},t)})),selectionCb:t=>{Os(Ts({type:Dr.IncrementalSnapshot,data:Object.assign({source:Br.Selection},t)}))},blockClass:r,ignoreClass:o,maskTextClass:a,maskTextSelector:l,maskInputOptions:M,inlineStylesheet:c,sampling:y,recordCanvas:v,inlineImages:_,userTriggeredOnInput:C,collectFonts:S,doc:t,maskInputFn:p,maskTextFn:g,keepIframeSrcFn:x,blockSelector:s,slimDOMOptions:T,dataURLOptions:b,mirror:Fs,iframeManager:U,stylesheetManager:B,shadowDomManager:Z,canvasManager:Ns,ignoreCSSAttributes:A,plugins:(null===(e=null==k?void 0:k.filter(t=>t.observer))||void 0===e?void 0:e.map(t=>({observer:t.observer,options:t.options,callback:e=>Os(Ts({type:Dr.Plugin,data:{plugin:t.name,payload:e}}))})))||[]},m)};U.addLoadListener(n=>{t.push(e(n.contentDocument))});const n=()=>{zs(),t.push(e(document)),Ls=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():t.push(Ir("load",()=>{Os(Ts({type:Dr.Load,data:{}})),n()},window)),()=>{t.forEach(t=>t()),Ls=!1}}catch(t){console.warn(t)}}Ds.addCustomEvent=(t,e)=>{if(!Ls)throw new Error("please add custom event after start recording");Os(Ts({type:Dr.Custom,data:{tag:t,payload:e}}))},Ds.freezePage=()=>{Yr.forEach(t=>t.freeze())},Ds.takeFullSnapshot=t=>{if(!Ls)throw new Error("please take full snapshot after start recording");zs(t)},Ds.mirror=Fs;var Bs=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Bs||{});class Us{constructor(t){this.events=[],this.lastFullSnapshotIndex=-1,this.duration=1e3*t.duration}add(t){t.type===Bs.FullSnapshot&&(this.lastFullSnapshotIndex=this.events.length),this.events.push(t),this.prune()}addBatch(t){for(let e=t.length-1;e>=0;e--)if(t[e].type===Bs.FullSnapshot){this.lastFullSnapshotIndex=this.events.length+e;break}this.events.push(...t),this.prune()}prune(){if(0===this.events.length)return;const t=Date.now()-this.duration;let e=this.events.length;for(let n=0;n<this.events.length;n++)if(this.events[n].timestamp>=t){e=n;break}this.lastFullSnapshotIndex>=0&&this.lastFullSnapshotIndex<e&&(e=this.lastFullSnapshotIndex),0!==e&&(this.events=this.events.slice(e),this.lastFullSnapshotIndex>=0&&(this.lastFullSnapshotIndex-=e))}getEvents(){return this.prune(),[...this.events]}getCompressedEvents(){return this.getEvents()}clear(){this.events=[],this.lastFullSnapshotIndex=-1}size(){return this.events.length}setDuration(t){this.duration=1e3*t,this.prune()}getDuration(){return this.duration/1e3}}const Zs=E();class Ps{constructor(t={}){var e,n,i,r,s,o,a,l,c,d;this.isRecording=!1,this.sanitizer=t.sanitizer,this.config={duration:null!==(e=t.duration)&&void 0!==e?e:15,sampling:{mousemove:null!==(i=null===(n=t.sampling)||void 0===n?void 0:n.mousemove)&&void 0!==i?i:50,scroll:null!==(s=null===(r=t.sampling)||void 0===r?void 0:r.scroll)&&void 0!==s?s:100},inlineStylesheet:null===(o=t.inlineStylesheet)||void 0===o||o,inlineImages:null!==(a=t.inlineImages)&&void 0!==a&&a,collectFonts:null!==(l=t.collectFonts)&&void 0!==l&&l,recordCanvas:null!==(c=t.recordCanvas)&&void 0!==c&&c,recordCrossOriginIframes:null!==(d=t.recordCrossOriginIframes)&&void 0!==d&&d,sanitizer:t.sanitizer},this.buffer=new Us({duration:this.config.duration})}startRecording(){var t,e,n,i;if(this.isRecording)E().warn("DOMCollector: Recording already in progress");else try{const r={emit:t=>{this.buffer.add(t)},sampling:{mousemove:null!==(e=null===(t=this.config.sampling)||void 0===t?void 0:t.mousemove)&&void 0!==e?e:50,scroll:null!==(i=null===(n=this.config.sampling)||void 0===n?void 0:n.scroll)&&void 0!==i?i:100,mouseInteraction:!0},recordCanvas:this.config.recordCanvas,recordCrossOriginIframes:this.config.recordCrossOriginIframes,maskTextFn:this.sanitizer?(t,e)=>this.sanitizer.sanitizeTextNode(t,e):void 0,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},inlineStylesheet:this.config.inlineStylesheet,inlineImages:this.config.inlineImages,collectFonts:this.config.collectFonts};this.stopRecordingFn=Ds(r),this.isRecording=!0,E().debug("DOMCollector: Started recording")}catch(t){E().error("DOMCollector: Failed to start recording",t),this.isRecording=!1}}stopRecording(){if(this.isRecording&&this.stopRecordingFn)try{this.stopRecordingFn(),this.isRecording=!1,this.stopRecordingFn=void 0,Zs.debug("DOMCollector: Stopped recording")}catch(t){Zs.error("DOMCollector: Failed to stop recording",t)}else Zs.warn("DOMCollector: No recording in progress")}getEvents(){return this.buffer.getEvents()}getCompressedEvents(){return this.buffer.getCompressedEvents()}clearBuffer(){this.buffer.clear()}isCurrentlyRecording(){return this.isRecording}getBufferSize(){return this.buffer.size()}setDuration(t){this.config.duration=t,this.buffer.setDuration(t)}getDuration(){return this.config.duration}destroy(){this.stopRecording(),this.clearBuffer()}}class $s{constructor(t){var e,n,i,r,s,o,a,l,c,d;this.screenshot=new Gi,this.console=new Vi({sanitizer:t.sanitizer});const h={sanitizer:t.sanitizer};if(t.apiEndpoint){const e=t.apiEndpoint;h.filterUrls=t=>!t.startsWith(e)}this.network=new Hi(h),this.metadata=new qi({sanitizer:t.sanitizer}),(null===(n=null===(e=t.replay)||void 0===e?void 0:e.enabled)||void 0===n||n)&&(this.domCollector=new Ps({duration:null!==(r=null===(i=t.replay)||void 0===i?void 0:i.duration)&&void 0!==r?r:15,sampling:null===(s=t.replay)||void 0===s?void 0:s.sampling,inlineStylesheet:null===(o=t.replay)||void 0===o?void 0:o.inlineStylesheet,inlineImages:null===(a=t.replay)||void 0===a?void 0:a.inlineImages,collectFonts:null===(l=t.replay)||void 0===l?void 0:l.collectFonts,recordCanvas:null===(c=t.replay)||void 0===c?void 0:c.recordCanvas,recordCrossOriginIframes:null===(d=t.replay)||void 0===d?void 0:d.recordCrossOriginIframes,sanitizer:t.sanitizer}),this.domCollector.startRecording())}async captureAll(){var t,e;return{console:this.console.getLogs(),network:this.network.getRequests(),metadata:this.metadata.capture(),replay:null!==(e=null===(t=this.domCollector)||void 0===t?void 0:t.getEvents())&&void 0!==e?e:[],_screenshotPreview:await this.screenshot.capture()}}async captureScreenshot(){return await this.screenshot.capture()}destroy(){var t;this.console.destroy(),this.network.destroy(),null===(t=this.domCollector)||void 0===t||t.destroy()}}const Gs=E();class Ws{constructor(t,e){this.apiEndpoint=t,this.apiKey=e}async uploadFiles(t,e,n){const i=await this.prepareFiles(e,n);0!==i.length&&(await this.uploadToStorage(i),await this.confirmUploads(i,t))}async prepareFiles(t,e){const n=[];if(t._screenshotPreview&&t._screenshotPreview.startsWith("data:image/")){const i=this.getPresignedUrl("screenshot",e),r=await this.dataUrlToBlob(t._screenshotPreview);n.push({type:"screenshot",url:i.uploadUrl,key:i.storageKey,blob:r})}if(t.replay&&t.replay.length>0){const i=this.getPresignedUrl("replay",e),r=await async function(t){try{const e=function(t){return"string"==typeof t?t:JSON.stringify(t)}(t),n=(Zi||(Zi=new TextEncoder),Zi).encode(e),i=6;return Bi.gzip(n,{level:i})}catch(t){throw Ui.error("Compression failed:",t),t}}(t.replay),s=new Blob([r],{type:"application/gzip"});n.push({type:"replay",url:i.uploadUrl,key:i.storageKey,blob:s})}return n}async uploadToStorage(t){const e=t.map(async t=>{const e=new AbortController,n=setTimeout(()=>e.abort(),Ws.UPLOAD_TIMEOUT_MS);try{const i=await fetch(t.url,{method:"PUT",body:t.blob,signal:e.signal});return clearTimeout(n),{success:i.ok,type:t.type}}catch(e){return clearTimeout(n),Gs.error(`Upload failed for ${t.type}:`,e),{success:!1,type:t.type}}}),n=await Promise.all(e);for(const t of n)if(!t.success)throw new Error(`${this.formatFileType(t.type)} upload failed: Upload to storage failed`)}async confirmUploads(t,e){const n=t.map(async t=>{try{return{success:(await fetch(`${this.apiEndpoint}/api/v1/reports/${e}/confirm-upload`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.apiKey},body:JSON.stringify({fileType:t.type})})).ok,type:t.type}}catch(e){return Gs.error(`Confirmation failed for ${t.type}:`,e),{success:!1,type:t.type}}}),i=await Promise.all(n);for(const t of i)if(!t.success)throw new Error(`${this.formatFileType(t.type)} confirmation failed: Backend did not acknowledge upload`)}getPresignedUrl(t,e){const n=e[t];if(!n)throw new Error(`${this.formatFileType(t)} presigned URL not provided by server`);return n}async dataUrlToBlob(t){if(!t||!t.startsWith("data:"))throw new Error("Invalid data URL");const e=await fetch(t);if(!e||!e.blob)throw new Error("Failed to convert data URL to Blob");return await e.blob()}formatFileType(t){return t.charAt(0).toUpperCase()+t.slice(1)}}Ws.UPLOAD_TIMEOUT_MS=6e4;const js=E();function Vs(t){if(!t||"object"!=typeof t)return"";const e=t;return`${"string"==typeof e.message?e.message:""}:${"string"==typeof e.stack?e.stack:""}`}function Hs(t,e,n){const i=t.trim().toLowerCase(),r=e.trim().toLowerCase();let s="";return n&&(Array.isArray(n)?s=n.map(t=>"string"==typeof t?t:Vs(t)).join("|"):"object"==typeof n&&(s=Vs(n))),function(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)|0;return(e>>>0).toString(36)}(`${i}|${r}|${s}`)}class qs{constructor(t={}){this.recentReports=new Map,this.cleanupInterval=null,this.submittingFingerprints=new Set,this.config={windowMs:void 0!==t.windowMs?t.windowMs:6e4,maxCacheSize:void 0!==t.maxCacheSize?t.maxCacheSize:100,enabled:void 0===t.enabled||t.enabled},this.config.enabled&&"undefined"!=typeof window&&(this.cleanupInterval=window.setInterval(()=>{try{this.cleanup()}catch(t){js.error("Deduplicator cleanup failed",t)}},this.config.windowMs/2))}isInProgress(t,e,n){const i=Hs(t,e,n);return this.submittingFingerprints.has(i)}markInProgress(t,e,n){const i=Hs(t,e,n);this.submittingFingerprints.add(i)}markComplete(t,e,n){const i=Hs(t,e,n);this.submittingFingerprints.delete(i)}isDuplicate(t,e,n){if(!this.config.enabled)return!1;const i=Hs(t,e,n);if(this.submittingFingerprints.has(i))return js.warn("Duplicate submission blocked: this report is already in progress"),!0;const r=Date.now(),s=this.recentReports.get(i);if(s&&r-s.timestamp<this.config.windowMs){const e=Math.round((r-s.timestamp)/1e3);return js.warn(`Duplicate bug report detected (age: ${e}s)`,{fingerprint:i,title:t.substring(0,50)}),!0}return!1}recordSubmission(t,e,n){if(!this.config.enabled)return;const i=Hs(t,e,n),r=Date.now();if(this.recentReports.size>=this.config.maxCacheSize){const t=this.recentReports.keys().next().value;t&&this.recentReports.delete(t)}this.recentReports.set(i,{timestamp:r}),js.debug("Recorded bug report submission",{fingerprint:i,cacheSize:this.recentReports.size})}cleanup(){const t=Date.now();let e=0;this.recentReports.forEach((n,i)=>{t-n.timestamp>this.config.windowMs&&(this.recentReports.delete(i),e++)}),e>0&&js.debug(`Cleaned up ${e} expired report fingerprints`)}getCacheSize(){return this.recentReports.size}clear(){this.submittingFingerprints.clear(),this.recentReports.clear(),js.debug("Cleared all cached report fingerprints")}destroy(){null!==this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.clear()}}class Ks{getItem(t){try{return"undefined"==typeof localStorage?null:localStorage.getItem(t)}catch(t){return null}}setItem(t,e){"undefined"!=typeof localStorage&&localStorage.setItem(t,e)}removeItem(t){try{if("undefined"==typeof localStorage)return;localStorage.removeItem(t)}catch(t){}}}const Ys="bugspotter_offline_queue",Qs={enabled:!1,maxQueueSize:10};class Xs{constructor(t,e,n){this.requestCounter=0,this.config=Object.assign(Object.assign({},Qs),t),this.logger=e||E(),this.storage=n||new Ks}enqueue(t,e,n){try{const i=this.serializeBody(e);if(!i||!this.validateItemSize(i))return;const r=this.getQueue();r.length>=this.config.maxQueueSize&&(this.logger.warn(`Offline queue is full (${this.config.maxQueueSize}), removing oldest request`),r.shift()),r.push(this.createQueuedRequest(t,i,n)),this.saveQueue(r),this.logger.log(`Request queued for offline retry (queue size: ${r.length})`)}catch(t){this.logger.error("Failed to queue request for offline retry:",t)}}async process(t){const e=this.getQueue();if(0===e.length)return;this.logger.log(`Processing offline queue (${e.length} requests)`);const n=[],i=[];for(const r of e)if(r.attempts>=5)this.logger.warn(`Max retry attempts (5) reached for request (id: ${r.id}), removing`);else if(Date.now()-r.timestamp>6048e5)this.logger.warn(`Removing expired queued request (id: ${r.id})`);else try{const e=await fetch(r.endpoint,{method:"POST",headers:r.headers,body:r.body});e.ok?(this.logger.log(`Successfully sent queued request (id: ${r.id})`),n.push(r.id)):t.includes(e.status)?(r.attempts++,i.push(r),this.logger.warn(`Queued request failed with status ${e.status}, will retry later (id: ${r.id})`)):this.logger.warn(`Queued request failed with non-retryable status ${e.status}, removing (id: ${r.id})`)}catch(t){r.attempts++,i.push(r),this.logger.warn(`Queued request failed with network error, will retry later (id: ${r.id}):`,t)}this.saveQueue(i),(n.length>0||i.length<e.length)&&this.logger.log(`Offline queue processed: ${n.length} successful, ${i.length} remaining`)}clear(){try{this.storage.removeItem(Ys)}catch(t){}}size(){return this.getQueue().length}serializeBody(t){return"string"==typeof t?t:t instanceof Blob?(this.logger.warn("Cannot queue Blob for offline retry, skipping"),null):JSON.stringify(t)}createQueuedRequest(t,e,n){return{id:this.generateRequestId(),endpoint:t,body:e,headers:n,timestamp:Date.now(),attempts:0}}validateItemSize(t){const e=new Blob([t]).size;return!(e>102400&&(this.logger.warn(`Request body too large (${e} bytes), skipping queue`),1))}getQueue(){try{const t=this.storage.getItem(Ys);return t?JSON.parse(t):[]}catch(t){return this.logger.warn("Failed to parse offline queue data, clearing corrupted queue:",t),this.clear(),[]}}saveQueue(t){try{this.storage.setItem(Ys,JSON.stringify(t))}catch(e){this.isQuotaExceededError(e)?(this.logger.error("localStorage quota exceeded, clearing oldest items"),this.clearOldestItems(t)):this.logger.error("Failed to save offline queue:",e)}}isQuotaExceededError(t){if(!(t instanceof Error))return!1;if("QuotaExceededError"===t.name)return!0;if("code"in t&&22===t.code)return!0;const e=t.message.toLowerCase();return e.includes("quota")||e.includes("storage")||e.includes("exceeded")}clearOldestItems(t){try{const e=t.slice(Math.floor(t.length/2));this.storage.setItem(Ys,JSON.stringify(e)),this.logger.log(`Trimmed offline queue to ${e.length} items due to quota`)}catch(t){this.logger.error("Failed to save even after trimming, clearing queue"),this.clear()}}generateRequestId(){let t;if(this.requestCounter=(this.requestCounter+1)%1e4,"undefined"!=typeof crypto&&crypto.getRandomValues){const e=new Uint32Array(2);crypto.getRandomValues(e),t=Array.from(e,t=>t.toString(36)).join("")}else t=Math.random().toString(36).substring(2,9)+Math.random().toString(36).substring(2,9);return`req_${Date.now()}_${this.requestCounter}_${t}`}}Error;class Js extends Error{constructor(t){super(t),this.name="AuthenticationError"}}const to={maxRetries:3,baseDelay:1e3,maxDelay:3e4,retryOn:[502,503,504,429]},eo={enabled:!1,maxQueueSize:10};function no(t){if(!t||!t.apiKey)throw new Js("Authentication is required: API key must be provided");return{"X-API-Key":t.apiKey}}class io{constructor(t,e){this.config=t,this.logger=e}async executeWithRetry(t,e){let n=null;for(let i=0;i<=this.config.maxRetries;i++)try{const n=await t();if(e(n.status)&&i<this.config.maxRetries){const t=this.calculateDelay(i,n);this.logger.warn(`Request failed with status ${n.status}, retrying in ${t}ms (attempt ${i+1}/${this.config.maxRetries})`),await so(t);continue}return n}catch(t){if(n=t,t instanceof Js)throw t;if(i<this.config.maxRetries){const e=this.calculateDelay(i);this.logger.warn(`Network error, retrying in ${e}ms (attempt ${i+1}/${this.config.maxRetries}):`,t),await so(e);continue}}throw n||new Error("Request failed after all retry attempts")}calculateDelay(t,e){var n,i;if(null===(i=null===(n=null==e?void 0:e.headers)||void 0===n?void 0:n.has)||void 0===i?void 0:i.call(n,"Retry-After")){const t=e.headers.get("Retry-After"),n=parseInt(t,10);if(!isNaN(n))return Math.min(1e3*n,this.config.maxDelay)}const r=this.config.baseDelay*Math.pow(2,t),s=r+.1*r*(2*Math.random()-1);return Math.min(s,this.config.maxDelay)}}async function ro(t,e,n={},i){const r=i.logger||E(),s=Object.assign(Object.assign({},to),i.retry),o=Object.assign(Object.assign({},eo),i.offline);!async function(t,e,n){t.enabled&&new Xs(t,n).process(e.retryOn).catch(t=>{n.warn("Failed to process offline queue:",t)})}(o,s,r);try{const o=await async function(t,e,n,i,r,s){return new io(r,s).executeWithRetry(async()=>async function(t,e,n,i){const r=no(i),s=Object.assign(Object.assign({},n),r);return fetch(t,{method:"POST",headers:s,body:e})}(t,e,n,i),t=>r.retryOn.includes(t))}(t,e,n,i.auth,s,r);return o}catch(s){throw await async function(t,e,n,i,r,s,o){if(!s.enabled||!function(t){if(!(t instanceof Error))return!1;const e=t.message.toLowerCase();return e.includes("failed to fetch")||e.includes("network request failed")||e.includes("networkerror")||e.includes("network error")||e.includes("connection")||e.includes("timeout")||"NetworkError"===t.name||"AbortError"===t.name||"TypeError"===t.name&&(e.includes("fetch")||e.includes("network"))}(t))return;o.warn("Network error detected, queueing request for offline retry");const a=new Xs(s,o),l=no(r);await a.enqueue(e,n,Object.assign(Object.assign({},i),l))}(s,t,e,n,i.auth,o,r),s}}function so(t){return new Promise(e=>setTimeout(e,t))}const oo=E();function ao(t){var e,n,i,r;return{hasScreenshot:(r=t._screenshotPreview,!!r&&r.startsWith("data:image/")),hasReplay:(i=t.replay,!!i&&Array.isArray(i)&&i.length>0),screenshotSize:(null===(e=t._screenshotPreview)||void 0===e?void 0:e.length)||0,replayEventCount:(null===(n=t.replay)||void 0===n?void 0:n.length)||0}}function lo(t,e){return`${t}: ${e instanceof Error?e.message:String(e)}`}class co{constructor(t){this.config=t,this.deduplicator=new qs(t.deduplication)}async submit(t){const e=this.validateAndExtractErrors(t);try{oo.debug(`Submitting bug report to ${this.config.endpoint}`);const n=await this.createBugReport(t);await this.handleFileUploads(n,t,e)}finally{this.deduplicator.markComplete(e.title,e.description,e.errorStacks)}}validateAndExtractErrors(t){var e;!function(t){if(!t.endpoint)throw new Error("No endpoint configured for bug report submission");if(!t.auth)throw new Error("API key authentication is required");if("api-key"!==t.auth.type)throw new Error("API key authentication is required");if(!t.auth.apiKey)throw new Error("API key is required in auth configuration");if(!t.auth.projectId)throw new Error("Project ID is required in auth configuration")}({endpoint:this.config.endpoint,auth:this.config.auth});const n=function(t){return{title:t.title,description:t.description||"",errorStacks:(e=t.report,(null!==(i=null===(n=e.console)||void 0===n?void 0:n.filter(t=>"error"===t.level))&&void 0!==i?i:[]).map(t=>{var e;return null!==(e=t.stack)&&void 0!==e?e:t.message}))};var e,n,i}(t);if(this.deduplicator.isDuplicate(n.title,n.description,n.errorStacks)){const t=Math.ceil(((null===(e=this.config.deduplication)||void 0===e?void 0:e.windowMs)||6e4)/1e3);throw oo.warn("Duplicate bug report blocked",{title:n.title.substring(0,50),waitSeconds:t}),new Error(`Duplicate bug report detected. Please wait ${t} seconds before submitting again.`)}return this.deduplicator.markInProgress(n.title,n.description,n.errorStacks),n}async createBugReport(t){const{report:e}=t,n=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(t,["report"]),i=ao(e);oo.debug("File upload detection",i);const r=Object.assign(Object.assign({},n),{report:{console:e.console,network:e.network,metadata:e.metadata},hasScreenshot:i.hasScreenshot,hasReplay:i.hasReplay}),s=await ro(this.config.endpoint,JSON.stringify(r),{"Content-Type":"application/json"},{auth:this.config.auth,retry:this.config.retry,offline:this.config.offline});if(!s.ok){const t=await s.text().catch(()=>"Unknown error");throw new Error(`Failed to submit bug report: ${s.status} ${s.statusText}. ${t}`)}const o=await s.json();if(!function(t){if(!t||"object"!=typeof t)return!1;const e=t;if(!("success"in e)||"boolean"!=typeof e.success)return!1;if(e.success){const t=e.data;if(!t||"object"!=typeof t||!("id"in t)||"string"!=typeof t.id)return!1;if("presignedUrls"in t&&void 0!==t.presignedUrls&&("object"!=typeof t.presignedUrls||null===t.presignedUrls))return!1}return!0}(o))throw new Error("Invalid server response format");if(!o.success)throw new Error("Bug report creation failed on server");const a=o.data;return oo.debug("Bug report creation response",{success:o.success,bugId:a.id,hasPresignedUrls:!!a.presignedUrls,presignedUrlKeys:a.presignedUrls?Object.keys(a.presignedUrls):[]}),a}async handleFileUploads(t,e,n){const i=t.id,{report:r}=e,s=ao(r);if(!s.hasScreenshot&&!s.hasReplay)return oo.debug("No files to upload, bug report created successfully",{bugId:i}),void this.deduplicator.recordSubmission(n.title,n.description,n.errorStacks);if(!t.presignedUrls)throw oo.error("Presigned URLs not returned despite requesting file uploads",{bugId:i,hasScreenshot:s.hasScreenshot,hasReplay:s.hasReplay}),new Error("Server did not provide presigned URLs for file uploads. Check backend configuration.");const o=z(this.config.endpoint),a=new Ws(o,this.config.auth.apiKey);try{await a.uploadFiles(i,r,t.presignedUrls),oo.debug("File uploads completed successfully",{bugId:i}),this.deduplicator.recordSubmission(n.title,n.description,n.errorStacks)}catch(t){throw oo.error("File upload failed",{bugId:i,error:lo("Upload",t)}),new Error(lo(`Bug report created (ID: ${i}) but file upload failed`,t))}}destroy(){this.deduplicator.destroy()}}const ho=E();function uo(t,e){var n,i,r,s,o,a,l,c,d,h,u,p,g,m,f,y,b,w;return Object.assign(Object.assign({},t),{duration:null!==(i=null!==(n=null==t?void 0:t.duration)&&void 0!==n?n:null==e?void 0:e.duration)&&void 0!==i?i:15,inlineStylesheet:null===(s=null!==(r=null==t?void 0:t.inlineStylesheet)&&void 0!==r?r:null==e?void 0:e.inline_stylesheets)||void 0===s||s,inlineImages:null!==(a=null!==(o=null==t?void 0:t.inlineImages)&&void 0!==o?o:null==e?void 0:e.inline_images)&&void 0!==a&&a,collectFonts:null!==(c=null!==(l=null==t?void 0:t.collectFonts)&&void 0!==l?l:null==e?void 0:e.collect_fonts)&&void 0!==c&&c,recordCanvas:null!==(h=null!==(d=null==t?void 0:t.recordCanvas)&&void 0!==d?d:null==e?void 0:e.record_canvas)&&void 0!==h&&h,recordCrossOriginIframes:null!==(p=null!==(u=null==t?void 0:t.recordCrossOriginIframes)&&void 0!==u?u:null==e?void 0:e.record_cross_origin_iframes)&&void 0!==p&&p,sampling:{mousemove:null!==(f=null!==(m=null===(g=null==t?void 0:t.sampling)||void 0===g?void 0:g.mousemove)&&void 0!==m?m:null==e?void 0:e.sampling_mousemove)&&void 0!==f?f:50,scroll:null!==(w=null!==(b=null===(y=null==t?void 0:t.sampling)||void 0===y?void 0:y.scroll)&&void 0!==b?b:null==e?void 0:e.sampling_scroll)&&void 0!==w?w:100}})}class po{constructor(t){var e,n,i,r,s,o;t.deduplication&&function(t){if(t){if("enabled"in t&&"boolean"!=typeof t.enabled)throw new Error("deduplication.enabled must be a boolean");if("windowMs"in t){if("number"!=typeof t.windowMs)throw new Error("deduplication.windowMs must be a number");if(!Number.isFinite(t.windowMs))throw new Error("deduplication.windowMs must be a finite number");if(t.windowMs<=0)throw new Error("deduplication.windowMs must be greater than 0")}if("maxCacheSize"in t){if("number"!=typeof t.maxCacheSize)throw new Error("deduplication.maxCacheSize must be a number");if(!Number.isFinite(t.maxCacheSize))throw new Error("deduplication.maxCacheSize must be a finite number");if(t.maxCacheSize<=0)throw new Error("deduplication.maxCacheSize must be greater than 0");if(!Number.isInteger(t.maxCacheSize))throw new Error("deduplication.maxCacheSize must be an integer")}}}(t.deduplication),this.config=t;const a=null===(n=null===(e=t.sanitize)||void 0===e?void 0:e.enabled)||void 0===n||n;a&&(this.sanitizer=k({enabled:a,patterns:null===(i=t.sanitize)||void 0===i?void 0:i.patterns,customPatterns:null===(r=t.sanitize)||void 0===r?void 0:r.customPatterns,excludeSelectors:null===(s=t.sanitize)||void 0===s?void 0:s.excludeSelectors})),this.captureManager=new $s(Object.assign(Object.assign({sanitizer:this.sanitizer},t.endpoint&&{apiEndpoint:z(t.endpoint)}),{replay:t.replay})),this.bugReporter=new co(t),(null===(o=t.showWidget)||void 0===o||o)&&(this.widget=new c(t.widgetOptions),this.widget.onClick(async()=>{await this.handleBugReport()}))}static async init(t){if(po.instance)return ho.warn("BugSpotter.init() called multiple times. Returning existing instance. Call destroy() first to reinitialize with new config."),po.instance;if(po.initPromise)return ho.warn("BugSpotter.init() called while initialization in progress. Waiting..."),po.initPromise;po.initPromise=po.createInstance(t);try{return po.instance=await po.initPromise,po.instance}finally{po.initPromise=void 0}}static async createInstance(t){var e,n,i;let r=null;(null===(n=null===(e=t.replay)||void 0===e?void 0:e.enabled)||void 0===n||n)&&t.endpoint&&((null===(i=t.auth)||void 0===i?void 0:i.apiKey)?r=await async function(t,e){var n,i,r,s,o,a,l,c;const d={duration:15,inline_stylesheets:!0,inline_images:!1,collect_fonts:!0,record_canvas:!1,record_cross_origin_iframes:!1,sampling_mousemove:50,sampling_scroll:100};try{const h=z(t),u={};e&&(u["x-api-key"]=e);const p=await fetch(`${h}/api/v1/settings/replay`,{headers:u});if(!p.ok)return ho.warn(`Failed to fetch replay settings: ${p.status}. Using defaults.`),d;const g=await p.json();return g.success&&g.data?{duration:null!==(n=g.data.duration)&&void 0!==n?n:d.duration,inline_stylesheets:null!==(i=g.data.inline_stylesheets)&&void 0!==i?i:d.inline_stylesheets,inline_images:null!==(r=g.data.inline_images)&&void 0!==r?r:d.inline_images,collect_fonts:null!==(s=g.data.collect_fonts)&&void 0!==s?s:d.collect_fonts,record_canvas:null!==(o=g.data.record_canvas)&&void 0!==o?o:d.record_canvas,record_cross_origin_iframes:null!==(a=g.data.record_cross_origin_iframes)&&void 0!==a?a:d.record_cross_origin_iframes,sampling_mousemove:null!==(l=g.data.sampling_mousemove)&&void 0!==l?l:d.sampling_mousemove,sampling_scroll:null!==(c=g.data.sampling_scroll)&&void 0!==c?c:d.sampling_scroll}:(ho.warn("Invalid replay settings response. Using defaults."),d)}catch(t){return ho.warn("Failed to fetch replay settings from backend. Using defaults.",t),d}}(t.endpoint,t.auth.apiKey):ho.warn("Endpoint provided but no API key configured. Skipping backend settings fetch."));const s=Object.assign(Object.assign({},t),{replay:uo(t.replay,r)});return new po(s)}static getInstance(){return po.instance||null}async capture(){return await this.captureManager.captureAll()}async handleBugReport(){const t=await this.capture();new M({onSubmit:async e=>{if(ho.log("Submitting bug:",Object.assign(Object.assign({},e),{report:t})),this.config.endpoint)try{await this.submit(Object.assign(Object.assign({},e),{report:t})),ho.log("Bug report submitted successfully")}catch(t){throw ho.error("Failed to submit bug report:",t),t}},onProgress:t=>{ho.debug("Upload progress:",t)}}).show(t._screenshotPreview||"")}async submit(t){await this.bugReporter.submit(t)}getConfig(){return Object.assign({},this.config)}destroy(){var t;this.captureManager.destroy(),null===(t=this.widget)||void 0===t||t.destroy(),this.bugReporter.destroy(),po.instance=void 0,po.initPromise=void 0}}return e.BugSpotter})());
|