|
|
/*! For license information please see 5199.96ba1dc3.js.LICENSE.txt */
|
|
|
(self.webpackChunk_coze_studio_app=self.webpackChunk_coze_studio_app||[]).push([["5199"],{481655:function(e,t,n){"use strict";n.d(t,{DL:function(){return i}}),n(745304);let i=e=>{let{transform:t}=e;return{...t,x:0}}},789034:function(e,t,n){"use strict";function i(e,t){for(var n,i=arguments.length,r=Array(i>2?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];if(!e){if(void 0===t)n=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;(n=Error(t.replace(/%s/g,function(){return r[o++]}))).name="Invariant Violation"}throw n.framesToPop=1,n}}n.d(t,{k:function(){return i}})},712003:function(e,t,n){"use strict";function i(e,t,n,i){var r=n?n.call(i,e,t):void 0;if(void 0!==r)return!!r;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var s=Object.keys(e),o=Object.keys(t);if(s.length!==o.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(t),l=0;l<s.length;l++){var d=s[l];if(!a(d))return!1;var c=e[d],h=t[d];if(!1===(r=n?n.call(i,c,h,d):void 0)||void 0===r&&c!==h)return!1}return!0}n.d(t,{w:function(){return i}})},828108:function(e){var t,n;t=0,n=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function t(t){for(var i=1;i<arguments.length;i++){var r=null!=arguments[i]?arguments[i]:{};i%2?e(Object(r),!0).forEach(function(e){(function(e,t,i){(t=n(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function n(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,n(r.key),r)}}function s(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}var a="undefined"!=typeof window&&void 0!==window.document,l=a?window:{},d=!!a&&!!l.document.documentElement&&"ontouchstart"in l.document.documentElement,c=!!a&&"PointerEvent"in l,h="cropper",u="crop",p="move",f="zoom",m="".concat(h,"-crop"),g="".concat(h,"-disabled"),v="".concat(h,"-hidden"),b="".concat(h,"-hide"),y="".concat(h,"-invisible"),x="".concat(h,"-modal"),w="".concat(h,"-move"),_="".concat(h,"Action"),S="".concat(h,"Preview"),E="crop",C="move",A="none",k="crop",T="cropend",M="cropmove",D="cropstart",O="dblclick",I=c?"pointerdown":d?"touchstart":"mousedown",N=c?"pointermove":d?"touchmove":"mousemove",R=c?"pointerup pointercancel":d?"touchend touchcancel":"mouseup",L="ready",P="resize",j="wheel",F="zoom",B="image/jpeg",z=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,H=/^data:/,U=/^data:image\/jpeg;base64,/,V=/^img|canvas$/i,$={viewMode:0,dragMode:E,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},W=Number.isNaN||l.isNaN;function G(e){return"number"==typeof e&&!W(e)}var Z=function(e){return e>0&&e<1/0};function q(e){return void 0===e}function K(e){return"object"===i(e)&&null!==e}var Y=Object.prototype.hasOwnProperty;function X(e){if(!K(e))return!1;try{var t=e.constructor,n=t.prototype;return t&&n&&Y.call(n,"isPrototypeOf")}catch(e){return!1}}function J(e){return"function"==typeof e}var Q=Array.prototype.slice;function ee(e){return Array.from?Array.from(e):Q.call(e)}function et(e,t){return e&&J(t)&&(Array.isArray(e)||G(e.length)?ee(e).forEach(function(n,i){t.call(e,n,i,e)}):K(e)&&Object.keys(e).forEach(function(n){t.call(e,e[n],n,e)})),e}var en=Object.assign||function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return K(e)&&n.length>0&&n.forEach(function(t){K(t)&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e},ei=/\.\d*(?:0|9){12}\d*$/;function er(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return ei.test(e)?Math.round(e*t)/t:e}var es=/^width|height|left|top|marginLeft|marginTop$/;function eo(e,t){var n=e.style;et(t,function(e,t){es.test(t)&&G(e)&&(e="".concat(e,"px")),n[t]=e})}function ea(e,t){if(!!t){if(G(e.length)){et(e,function(e){ea(e,t)});return}if(e.classList){e.classList.add(t);return}var n=e.className.trim();n?0>n.indexOf(t)&&(e.className="".concat(n," ").concat(t)):e.className=t}}function el(e,t){if(!!t){if(G(e.length)){et(e,function(e){el(e,t)});return}if(e.classList){e.classList.remove(t);return}e.className.indexOf(t)>=0&&(e.className=e.className.replace(t,""))}}function ed(e,t,n){if(!!t){if(G(e.length)){et(e,function(e){ed(e,t,n)});return}n?ea(e,t):el(e,t)}}var ec=/([a-z\d])([A-Z])/g;function eh(e){return e.replace(ec,"$1-$2").toLowerCase()}function eu(e,t){return K(e[t])?e[t]:e.dataset?e.dataset[t]:e.getAttribute("data-".concat(eh(t)))}function ep(e,t,n){K(n)?e[t]=n:e.dataset?e.dataset[t]=n:e.setAttribute("data-".concat(eh(t)),n)}var ef=/\s\s*/,em=function(){var e=!1;if(a){var t=!1,n=function(){},i=Object.defineProperty({},"once",{get:function(){return e=!0,t},set:function(e){t=e}});l.addEventListener("test",n,i),l.removeEventListener("test",n,i)}return e}();function eg(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=n;t.trim().split(ef).forEach(function(t){if(!em){var s=e.listeners;s&&s[t]&&s[t][n]&&(r=s[t][n],delete s[t][n],0===Object.keys(s[t]).length&&delete s[t],0===Object.keys(s).length&&delete e.listeners)}e.removeEventListener(t,r,i)})}function ev(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=n;t.trim().split(ef).forEach(function(t){if(i.once&&!em){var s=e.listeners,o=void 0===s?{}:s;r=function(){delete o[t][n],e.removeEventListener(t,r,i);for(var s=arguments.length,a=Array(s),l=0;l<s;l++)a[l]=arguments[l];n.apply(e,a)},!o[t]&&(o[t]={}),o[t][n]&&e.removeEventListener(t,o[t][n],i),o[t][n]=r,e.listeners=o}e.addEventListener(t,r,i)})}function eb(e,t,n){var i;return J(Event)&&J(CustomEvent)?i=new CustomEvent(t,{detail:n,bubbles:!0,cancelable:!0}):(i=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n),e.dispatchEvent(i)}function ey(e){var t=e.getBoundingClientRect();return{left:t.left+(window.pageXOffset-document.documentElement.clientLeft),top:t.top+(window.pageYOffset-document.documentElement.clientTop)}}var ex=l.location,ew=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function e_(e){var t=e.match(ew);return null!==t&&(t[1]!==ex.protocol||t[2]!==ex.hostname||t[3]!==ex.port)}function eS(e){var t="timestamp=".concat(new Date().getTime());return e+(-1===e.indexOf("?")?"?":"&")+t}function eE(e){var t=e.rotate,n=e.scaleX,i=e.scaleY,r=e.translateX,s=e.translateY,o=[];G(r)&&0!==r&&o.push("translateX(".concat(r,"px)")),G(s)&&0!==s&&o.push("translateY(".concat(s,"px)")),G(t)&&0!==t&&o.push("rotate(".concat(t,"deg)")),G(n)&&1!==n&&o.push("scaleX(".concat(n,")")),G(i)&&1!==i&&o.push("scaleY(".concat(i,")"));var a=o.length?o.join(" "):"none";return{WebkitTransform:a,msTransform:a,transform:a}}function eC(e,n){var i=e.pageX,r=e.pageY,s={endX:i,endY:r};return n?s:t({startX:i,startY:r},s)}function eA(e){var t=e.aspectRatio,n=e.height,i=e.width,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"contain",s=Z(i),o=Z(n);if(s&&o){var a=n*t;"contain"===r&&a>i||"cover"===r&&a<i?n=i/t:i=n*t}else s?n=i/t:o&&(i=n*t);return{width:i,height:n}}var ek=String.fromCharCode,eT=/^data:.*,/,eM=l.Cropper,eD=function(){var e,t,n;function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),!e||!V.test(e.tagName))throw Error("The first argument is required and must be an <img> or <canvas> element.");this.element=e,this.options=en({},$,X(t)&&t),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return e=i,t=[{key:"init",value:function(){var e,t=this.element,n=t.tagName.toLowerCase();if(!t[h]){if(t[h]=this,"img"===n){if(this.isImg=!0,e=t.getAttribute("src")||"",this.originalUrl=e,!e)return;e=t.src}else"canvas"===n&&window.HTMLCanvasElement&&(e=t.toDataURL());this.load(e)}}},{key:"load",value:function(e){var t,n,i,r=this;if(!!e){this.url=e,this.imageData={};var s=this.element,o=this.options;if(!o.rotatable&&!o.scalable&&(o.checkOrientation=!1),!o.checkOrientation||!window.ArrayBuffer){this.clone();return}if(H.test(e)){if(U.test(e)){;this.read((et(i=new Uint8Array(n=new ArrayBuffer((t=atob(e.replace(eT,""))).length)),function(e,n){i[n]=t.charCodeAt(n)}),n))}else this.clone();return}var a=new XMLHttpRequest,l=this.clone.bind(this);this.reloading=!0,this.xhr=a,a.onabort=l,a.onerror=l,a.ontimeout=l,a.onprogress=function(){a.getResponseHeader("content-type")!==B&&a.abort()},a.onload=function(){r.read(a.response)},a.onloadend=function(){r.reloading=!1,r.xhr=null},o.checkCrossOrigin&&e_(e)&&s.crossOrigin&&(e=eS(e)),a.open("GET",e,!0),a.responseType="arraybuffer",a.withCredentials="use-credentials"===s.crossOrigin,a.send()}}},{key:"read",value:function(e){var t=this.options,n=this.imageData,i=function(e){var t=new DataView(e);try{if(255===t.getUint8(0)&&216===t.getUint8(1)){for(var n=t.byteLength,i=2;i+1<n;){if(255===t.getUint8(i)&&225===t.getUint8(i+1)){c=i;break}i+=1}}if(c){var r=c+4,s=c+10;if("Exif"===function(e,t,n){var i="";n+=t;for(var r=t;r<n;r+=1)i+=ek(e.getUint8(r));return i}(t,r,4)){var o=t.getUint16(s);if(((d=18761===o)||19789===o)&&42===t.getUint16(s+2,d)){var a=t.getUint32(s+4,d);a>=8&&(h=s+a)}}}if(h){var l,d,c,h,u,p,f=t.getUint16(h,d);for(p=0;p<f;p+=1)if(u=h+12*p+2,274===t.getUint16(u,d)){u+=8,l=t.getUint16(u,d),t.setUint16(u,1,d);break}}}catch(e){l=1}return l}(e),r=0,s=1,o=1;if(i>1){this.url=function(e,t){for(var n=[],i=new Uint8Array(e);i.length>0;)n.push(ek.apply(null,ee(i.subarray(0,8192)))),i=i.subarray(8192);return"data:".concat(t,";base64,").concat(btoa(n.join("")))}(e,B);var a=function(e){var t=0,n=1,i=1;switch(e){case 2:n=-1;break;case 3:t=-180;break;case 4:i=-1;break;case 5:t=90,i=-1;break;case 6:t=90;break;case 7:t=90,n=-1;break;case 8:t=-90}return{rotate:t,scaleX:n,scaleY:i}}(i);r=a.rotate,s=a.scaleX,o=a.scaleY}t.rotatable&&(n.rotate=r),t.scalable&&(n.scaleX=s,n.scaleY=o),this.clone()}},{key:"clone",value:function(){var e=this.element,t=this.url,n=e.crossOrigin,i=t;this.options.checkCrossOrigin&&e_(t)&&(!n&&(n="anonymous"),i=eS(t)),this.crossOrigin=n,this.crossOriginUrl=i;var r=document.createElement("img");n&&(r.crossOrigin=n),r.src=i||t,r.alt=e.alt||"The image to crop",this.image=r,r.onload=this.start.bind(this),r.onerror=this.stop.bind(this),ea(r,b),e.parentNode.insertBefore(r,e.nextSibling)}},{key:"start",value:function(){var e=this,t=this.image;t.onload=null,t.onerror=null,this.sizing=!0;var n=l.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(l.navigator.userAgent),i=function(t,n){en(e.imageData,{naturalWidth:t,naturalHeight:n,aspectRatio:t/n}),e.initialImageData=en({},e.imageData),e.sizing=!1,e.sized=!0,e.build()};if(t.naturalWidth&&!n){i(t.naturalWidth,t.naturalHeight);return}var r=document.createElement("img"),s=document.body||document.documentElement;this.sizingImage=r,r.onload=function(){i(r.width,r.height),!n&&s.removeChild(r)},r.src=t.src,!n&&(r.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",s.appendChild(r))}},{key:"stop",value:function(){var e=this.image;e.onload=null,e.onerror=null,e.parentNode.removeChild(e),this.image=null}},{key:"build",value:function(){if(!!this.sized&&!this.ready){var e=this.element,t=this.options,n=this.image,i=e.parentNode,r=document.createElement("div");r.innerHTML='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>';var s=r.querySelector(".".concat(h,"-container")),o=s.querySelector(".".concat(h,"-canvas")),a=s.querySelector(".".concat(h,"-drag-box")),l=s.querySelector(".".concat(h,"-crop-box")),d=l.querySelector(".".concat(h,"-face"));this.container=i,this.cropper=s,this.canvas=o,this.dragBox=a,this.cropBox=l,this.viewBox=s.querySelector(".".concat(h,"-view-box")),this.face=d,o.appendChild(n),ea(e,v),i.insertBefore(s,e.nextSibling),el(n,b),this.initPreview(),this.bind(),t.initialAspectRatio=Math.max(0,t.initialAspectRatio)||NaN,t.aspectRatio=Math.max(0,t.aspectRatio)||NaN,t.viewMode=Math.max(0,Math.min(3,Math.round(t.viewMode)))||0,ea(l,v),!t.guides&&ea(l.getElementsByClassName("".concat(h,"-dashed")),v),!t.center&&ea(l.getElementsByClassName("".concat(h,"-center")),v),t.background&&ea(s,"".concat(h,"-bg")),!t.highlight&&ea(d,y),t.cropBoxMovable&&(ea(d,w),ep(d,_,"all")),!t.cropBoxResizable&&(ea(l.getElementsByClassName("".concat(h,"-line")),v),ea(l.getElementsByClassName("".concat(h,"-point")),v)),this.render(),this.ready=!0,this.setDragMode(t.dragMode),t.autoCrop&&this.crop(),this.setData(t.data),J(t.ready)&&ev(e,L,t.ready,{once:!0}),eb(e,L)}}},{key:"unbuild",value:function(){if(!!this.ready){this.ready=!1,this.unbind(),this.resetPreview();var e=this.cropper.parentNode;e&&e.removeChild(this.cropper),el(this.element,v)}}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],n=[{key:"noConflict",value:function(){return window.Cropper=eM,i}},{key:"setDefaults",value:function(e){en($,X(e)&&e)}}],t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}();return en(eD.prototype,{render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var e=this.element,t=this.options,n=this.container,i=this.cropper,r=Number(t.minContainerWidth),s=Number(t.minContainerHeight);ea(i,v),el(e,v);var o={width:Math.max(n.offsetWidth,r>=0?r:200),height:Math.max(n.offsetHeight,s>=0?s:100)};this.containerData=o,eo(i,{width:o.width,height:o.height}),ea(e,v),el(i,v)},initCanvas:function(){var e=this.containerData,t=this.imageData,n=this.options.viewMode,i=Math.abs(t.rotate)%180==90,r=i?t.naturalHeight:t.naturalWidth,s=i?t.naturalWidth:t.naturalHeight,o=r/s,a=e.width,l=e.height;e.height*o>e.width?3===n?a=e.height*o:l=e.width/o:3===n?l=e.width/o:a=e.height*o;var d={aspectRatio:o,naturalWidth:r,naturalHeight:s,width:a,height:l};this.canvasData=d,this.limited=1===n||2===n,this.limitCanvas(!0,!0),d.width=Math.min(Math.max(d.width,d.minWidth),d.maxWidth),d.height=Math.min(Math.max(d.height,d.minHeight),d.maxHeight),d.left=(e.width-d.width)/2,d.top=(e.height-d.height)/2,d.oldLeft=d.left,d.oldTop=d.top,this.initialCanvasData=en({},d)},limitCanvas:function(e,t){var n=this.options,i=this.containerData,r=this.canvasData,s=this.cropBoxData,o=n.viewMode,a=r.aspectRatio,l=this.cropped&&s;if(e){var d=Number(n.minCanvasWidth)||0,c=Number(n.minCanvasHeight)||0;o>1?(d=Math.max(d,i.width),c=Math.max(c,i.height),3===o&&(c*a>d?d=c*a:c=d/a)):o>0&&(d?d=Math.max(d,l?s.width:0):c?c=Math.max(c,l?s.height:0):l&&(d=s.width,(c=s.height)*a>d?d=c*a:c=d/a));var h=eA({aspectRatio:a,width:d,height:c});d=h.width,c=h.height,r.minWidth=d,r.minHeight=c,r.maxWidth=1/0,r.maxHeight=1/0}if(t){if(o>(l?0:1)){var u=i.width-r.width,p=i.height-r.height;r.minLeft=Math.min(0,u),r.minTop=Math.min(0,p),r.maxLeft=Math.max(0,u),r.maxTop=Math.max(0,p),l&&this.limited&&(r.minLeft=Math.min(s.left,s.left+(s.width-r.width)),r.minTop=Math.min(s.top,s.top+(s.height-r.height)),r.maxLeft=s.left,r.maxTop=s.top,2===o&&(r.width>=i.width&&(r.minLeft=Math.min(0,u),r.maxLeft=Math.max(0,u)),r.height>=i.height&&(r.minTop=Math.min(0,p),r.maxTop=Math.max(0,p))))}else r.minLeft=-r.width,r.minTop=-r.height,r.maxLeft=i.width,r.maxTop=i.height}},renderCanvas:function(e,t){var n=this.canvasData,i=this.imageData;if(t){var r=function(e){var t=e.width,n=e.height,i=e.degree;if(90==(i=Math.abs(i)%180))return{width:n,height:t};var r=i%90*Math.PI/180,s=Math.sin(r),o=Math.cos(r),a=t*o+n*s,l=t*s+n*o;return i>90?{width:l,height:a}:{width:a,height:l}}({width:i.naturalWidth*Math.abs(i.scaleX||1),height:i.naturalHeight*Math.abs(i.scaleY||1),degree:i.rotate||0}),s=r.width,o=r.height,a=n.width*(s/n.naturalWidth),l=n.height*(o/n.naturalHeight);n.left-=(a-n.width)/2,n.top-=(l-n.height)/2,n.width=a,n.height=l,n.aspectRatio=s/o,n.naturalWidth=s,n.naturalHeight=o,this.limitCanvas(!0,!1)}(n.width>n.maxWidth||n.width<n.minWidth)&&(n.left=n.oldLeft),(n.height>n.maxHeight||n.height<n.minHeight)&&(n.top=n.oldTop),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),this.limitCanvas(!1,!0),n.left=Math.min(Math.max(n.left,n.minLeft),n.maxLeft),n.top=Math.min(Math.max(n.top,n.minTop),n.maxTop),n.oldLeft=n.left,n.oldTop=n.top,eo(this.canvas,en({width:n.width,height:n.height},eE({translateX:n.left,translateY:n.top}))),this.renderImage(e),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(e){var t=this.canvasData,n=this.imageData,i=n.naturalWidth*(t.width/t.naturalWidth),r=n.naturalHeight*(t.height/t.naturalHeight);en(n,{width:i,height:r,left:(t.width-i)/2,top:(t.height-r)/2}),eo(this.image,en({width:n.width,height:n.height},eE(en({translateX:n.left,translateY:n.top},n)))),e&&this.output()},initCropBox:function(){var e=this.options,t=this.canvasData,n=e.aspectRatio||e.initialAspectRatio,i=Number(e.autoCropArea)||.8,r={width:t.width,height:t.height};n&&(t.height*n>t.width?r.height=r.width/n:r.width=r.height*n),this.cropBoxData=r,this.limitCropBox(!0,!0),r.width=Math.min(Math.max(r.width,r.minWidth),r.maxWidth),r.height=Math.min(Math.max(r.height,r.minHeight),r.maxHeight),r.width=Math.max(r.minWidth,r.width*i),r.height=Math.max(r.minHeight,r.height*i),r.left=t.left+(t.width-r.width)/2,r.top=t.top+(t.height-r.height)/2,r.oldLeft=r.left,r.oldTop=r.top,this.initialCropBoxData=en({},r)},limitCropBox:function(e,t){var n=this.options,i=this.containerData,r=this.canvasData,s=this.cropBoxData,o=this.limited,a=n.aspectRatio;if(e){var l=Number(n.minCropBoxWidth)||0,d=Number(n.minCropBoxHeight)||0,c=o?Math.min(i.width,r.width,r.width+r.left,i.width-r.left):i.width,h=o?Math.min(i.height,r.height,r.height+r.top,i.height-r.top):i.height;l=Math.min(l,i.width),d=Math.min(d,i.height),a&&(l&&d?d*a>l?d=l/a:l=d*a:l?d=l/a:d&&(l=d*a),h*a>c?h=c/a:c=h*a),s.minWidth=Math.min(l,c),s.minHeight=Math.min(d,h),s.maxWidth=c,s.maxHeight=h}t&&(o?(s.minLeft=Math.max(0,r.left),s.minTop=Math.max(0,r.top),s.maxLeft=Math.min(i.width,r.left+r.width)-s.width,s.maxTop=Math.min(i.height,r.top+r.height)-s.height):(s.minLeft=0,s.minTop=0,s.maxLeft=i.width-s.width,s.maxTop=i.height-s.height))},renderCropBox:function(){var e=this.options,t=this.containerData,n=this.cropBoxData;(n.width>n.maxWidth||n.width<n.minWidth)&&(n.left=n.oldLeft),(n.height>n.maxHeight||n.height<n.minHeight)&&(n.top=n.oldTop),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),this.limitCropBox(!1,!0),n.left=Math.min(Math.max(n.left,n.minLeft),n.maxLeft),n.top=Math.min(Math.max(n.top,n.minTop),n.maxTop),n.oldLeft=n.left,n.oldTop=n.top,e.movable&&e.cropBoxMovable&&ep(this.face,_,n.width>=t.width&&n.height>=t.height?p:"all"),eo(this.cropBox,en({width:n.width,height:n.height},eE({translateX:n.left,translateY:n.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),!this.disabled&&this.output()},output:function(){this.preview(),eb(this.element,k,this.getData())}},{initPreview:function(){var e=this.element,t=this.crossOrigin,n=this.options.preview,i=t?this.crossOriginUrl:this.url,r=e.alt||"The image to preview",s=document.createElement("img");if(t&&(s.crossOrigin=t),s.src=i,s.alt=r,this.viewBox.appendChild(s),this.viewBoxImage=s,!!n){var o=n;"string"==typeof n?o=e.ownerDocument.querySelectorAll(n):n.querySelector&&(o=[n]),this.previews=o,et(o,function(e){var n=document.createElement("img");ep(e,S,{width:e.offsetWidth,height:e.offsetHeight,html:e.innerHTML}),t&&(n.crossOrigin=t),n.src=i,n.alt=r,n.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',e.innerHTML="",e.appendChild(n)})}},resetPreview:function(){et(this.previews,function(e){var t=eu(e,S);eo(e,{width:t.width,height:t.height}),e.innerHTML=t.html,!function(e,t){if(K(e[t]))try{delete e[t]}catch(n){e[t]=void 0}else if(e.dataset)try{delete e.dataset[t]}catch(n){e.dataset[t]=void 0}else e.removeAttribute("data-".concat(eh(t)))}(e,S)})},preview:function(){var e=this.imageData,t=this.canvasData,n=this.cropBoxData,i=n.width,r=n.height,s=e.width,o=e.height,a=n.left-t.left-e.left,l=n.top-t.top-e.top;if(!!this.cropped&&!this.disabled)eo(this.viewBoxImage,en({width:s,height:o},eE(en({translateX:-a,translateY:-l},e)))),et(this.previews,function(t){var n=eu(t,S),d=n.width,c=n.height,h=d,u=c,p=1;i&&(u=r*(p=d/i)),r&&u>c&&(h=i*(p=c/r),u=c),eo(t,{width:h,height:u}),eo(t.getElementsByTagName("img")[0],en({width:s*p,height:o*p},eE(en({translateX:-a*p,translateY:-l*p},e))))})}},{bind:function(){var e=this.element,t=this.options,n=this.cropper;J(t.cropstart)&&ev(e,D,t.cropstart),J(t.cropmove)&&ev(e,M,t.cropmove),J(t.cropend)&&ev(e,T,t.cropend),J(t.crop)&&ev(e,k,t.crop),J(t.zoom)&&ev(e,F,t.zoom),ev(n,I,this.onCropStart=this.cropStart.bind(this)),t.zoomable&&t.zoomOnWheel&&ev(n,j,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),t.toggleDragModeOnDblclick&&ev(n,O,this.onDblclick=this.dblclick.bind(this)),ev(e.ownerDocument,N,this.onCropMove=this.cropMove.bind(this)),ev(e.ownerDocument,R,this.onCropEnd=this.cropEnd.bind(this)),t.responsive&&ev(window,P,this.onResize=this.resize.bind(this))},unbind:function(){var e=this.element,t=this.options,n=this.cropper;J(t.cropstart)&&eg(e,D,t.cropstart),J(t.cropmove)&&eg(e,M,t.cropmove),J(t.cropend)&&eg(e,T,t.cropend),J(t.crop)&&eg(e,k,t.crop),J(t.zoom)&&eg(e,F,t.zoom),eg(n,I,this.onCropStart),t.zoomable&&t.zoomOnWheel&&eg(n,j,this.onWheel,{passive:!1,capture:!0}),t.toggleDragModeOnDblclick&&eg(n,O,this.onDblclick),eg(e.ownerDocument,N,this.onCropMove),eg(e.ownerDocument,R,this.onCropEnd),t.responsive&&eg(window,P,this.onResize)}},{resize:function(){if(!this.disabled){var e,t,n=this.options,i=this.container,r=this.containerData,s=i.offsetWidth/r.width,o=i.offsetHeight/r.height,a=Math.abs(s-1)>Math.abs(o-1)?s:o;1!==a&&(n.restore&&(e=this.getCanvasData(),t=this.getCropBoxData()),this.render(),n.restore&&(this.setCanvasData(et(e,function(t,n){e[n]=t*a})),this.setCropBoxData(et(t,function(e,n){t[n]=e*a}))))}},dblclick:function(){var e,t;if(!this.disabled&&this.options.dragMode!==A)this.setDragMode((e=this.dragBox,t=m,e.classList?e.classList.contains(t):e.className.indexOf(t)>-1)?C:E)},wheel:function(e){var t=this,n=Number(this.options.wheelZoomRatio)||.1,i=1;if(this.disabled)return;if(e.preventDefault(),!this.wheeling)this.wheeling=!0,setTimeout(function(){t.wheeling=!1},50),e.deltaY?i=e.deltaY>0?1:-1:e.wheelDelta?i=-e.wheelDelta/120:e.detail&&(i=e.detail>0?1:-1),this.zoom(-i*n,e)},cropStart:function(e){var t,n=e.buttons,i=e.button;if(this.disabled||("mousedown"===e.type||"pointerdown"===e.type&&"mouse"===e.pointerType)&&(G(n)&&1!==n||G(i)&&0!==i||e.ctrlKey))return;var r=this.options,s=this.pointers;if(e.changedTouches?et(e.changedTouches,function(e){s[e.identifier]=eC(e)}):s[e.pointerId||0]=eC(e),t=Object.keys(s).length>1&&r.zoomable&&r.zoomOnTouch?f:eu(e.target,_),!!z.test(t)&&!1!==eb(this.element,D,{originalEvent:e,action:t}))e.preventDefault(),this.action=t,this.cropping=!1,t===u&&(this.cropping=!0,ea(this.dragBox,x))},cropMove:function(e){var t=this.action;if(this.disabled||!t)return;var n=this.pointers;if(e.preventDefault(),!1!==eb(this.element,M,{originalEvent:e,action:t}))e.changedTouches?et(e.changedTouches,function(e){en(n[e.identifier]||{},eC(e,!0))}):en(n[e.pointerId||0]||{},eC(e,!0)),this.change(e)},cropEnd:function(e){if(this.disabled)return;var t=this.action,n=this.pointers;if(e.changedTouches?et(e.changedTouches,function(e){delete n[e.identifier]}):delete n[e.pointerId||0],!!t)e.preventDefault(),!Object.keys(n).length&&(this.action=""),this.cropping&&(this.cropping=!1,ed(this.dragBox,x,this.cropped&&this.options.modal)),eb(this.element,T,{originalEvent:e,action:t})}},{change:function(e){var n,i,r,s,o=this.options,a=this.canvasData,l=this.containerData,d=this.cropBoxData,c=this.pointers,h=this.action,m=o.aspectRatio,g=d.left,b=d.top,y=d.width,x=d.height,w=g+y,_=b+x,S=0,E=0,C=l.width,A=l.height,k=!0;!m&&e.shiftKey&&(m=y&&x?y/x:1),this.limited&&(S=d.minLeft,E=d.minTop,C=S+Math.min(l.width,a.width,a.left+a.width),A=E+Math.min(l.height,a.height,a.top+a.height));var T=c[Object.keys(c)[0]],M={x:T.endX-T.startX,y:T.endY-T.startY},D=function(e){switch(e){case"e":w+M.x>C&&(M.x=C-w);break;case"w":g+M.x<S&&(M.x=S-g);break;case"n":b+M.y<E&&(M.y=E-b);break;case"s":_+M.y>A&&(M.y=A-_)}};switch(h){case"all":g+=M.x,b+=M.y;break;case"e":if(M.x>=0&&(w>=C||m&&(b<=E||_>=A))){k=!1;break}D("e"),(y+=M.x)<0&&(h="w",g-=y=-y),m&&(x=y/m,b+=(d.height-x)/2);break;case"n":if(M.y<=0&&(b<=E||m&&(g<=S||w>=C))){k=!1;break}D("n"),x-=M.y,b+=M.y,x<0&&(h="s",b-=x=-x),m&&(y=x*m,g+=(d.width-y)/2);break;case"w":if(M.x<=0&&(g<=S||m&&(b<=E||_>=A))){k=!1;break}D("w"),y-=M.x,g+=M.x,y<0&&(h="e",g-=y=-y),m&&(x=y/m,b+=(d.height-x)/2);break;case"s":if(M.y>=0&&(_>=A||m&&(g<=S||w>=C))){k=!1;break}D("s"),(x+=M.y)<0&&(h="n",b-=x=-x),m&&(y=x*m,g+=(d.width-y)/2);break;case"ne":if(m){if(M.y<=0&&(b<=E||w>=C)){k=!1;break}D("n"),x-=M.y,b+=M.y,y=x*m}else D("n"),D("e"),M.x>=0?w<C?y+=M.x:M.y<=0&&b<=E&&(k=!1):y+=M.x,M.y<=0?b>E&&(x-=M.y,b+=M.y):(x-=M.y,b+=M.y);y<0&&x<0?(h="sw",y=-y,b-=x=-x,g-=y):y<0?(h="nw",g-=y=-y):x<0&&(h="se",b-=x=-x);break;case"nw":if(m){if(M.y<=0&&(b<=E||g<=S)){k=!1;break}D("n"),x-=M.y,b+=M.y,y=x*m,g+=d.width-y}else D("n"),D("w"),M.x<=0?g>S?(y-=M.x,g+=M.x):M.y<=0&&b<=E&&(k=!1):(y-=M.x,g+=M.x),M.y<=0?b>E&&(x-=M.y,b+=M.y):(x-=M.y,b+=M.y);y<0&&x<0?(h="se",y=-y,b-=x=-x,g-=y):y<0?(h="ne",g-=y=-y):x<0&&(h="sw",b-=x=-x);break;case"sw":if(m){if(M.x<=0&&(g<=S||_>=A)){k=!1;break}D("w"),y-=M.x,g+=M.x,x=y/m}else D("s"),D("w"),M.x<=0?g>S?(y-=M.x,g+=M.x):M.y>=0&&_>=A&&(k=!1):(y-=M.x,g+=M.x),M.y>=0?_<A&&(x+=M.y):x+=M.y;y<0&&x<0?(h="ne",y=-y,b-=x=-x,g-=y):y<0?(h="se",g-=y=-y):x<0&&(h="nw",b-=x=-x);break;case"se":if(m){if(M.x>=0&&(w>=C||_>=A)){k=!1;break}D("e"),y+=M.x,x=y/m}else D("s"),D("e"),M.x>=0?w<C?y+=M.x:M.y>=0&&_>=A&&(k=!1):y+=M.x,M.y>=0?_<A&&(x+=M.y):x+=M.y;y<0&&x<0?(h="nw",y=-y,b-=x=-x,g-=y):y<0?(h="sw",g-=y=-y):x<0&&(h="ne",b-=x=-x);break;case p:this.move(M.x,M.y),k=!1;break;case f:;this.zoom((i=t({},n=c),r=0,et(n,function(e,t){delete i[t],et(i,function(t){var n=Math.abs(e.startX-t.startX),i=Math.abs(e.startY-t.startY),s=Math.abs(e.endX-t.endX),o=Math.abs(e.endY-t.endY),a=Math.sqrt(n*n+i*i),l=(Math.sqrt(s*s+o*o)-a)/a;Math.abs(l)>Math.abs(r)&&(r=l)})}),r),e),k=!1;break;case u:if(!M.x||!M.y){k=!1;break}s=ey(this.cropper),g=T.startX-s.left,b=T.startY-s.top,y=d.minWidth,x=d.minHeight,M.x>0?h=M.y>0?"se":"ne":M.x<0&&(g-=y,h=M.y>0?"sw":"nw"),M.y<0&&(b-=x),!this.cropped&&(el(this.cropBox,v),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}k&&(d.width=y,d.height=x,d.left=g,d.top=b,this.action=h,this.renderCropBox()),et(c,function(e){e.startX=e.endX,e.startY=e.endY})}},{crop:function(){return this.ready&&!this.cropped&&!this.disabled&&(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&ea(this.dragBox,x),el(this.cropBox,v),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=en({},this.initialImageData),this.canvasData=en({},this.initialCanvasData),this.cropBoxData=en({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(en(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),el(this.dragBox,x),ea(this.cropBox,v)),this},replace:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&e&&(this.isImg&&(this.element.src=e),t?(this.url=e,this.image.src=e,this.ready&&(this.viewBoxImage.src=e,et(this.previews,function(t){t.getElementsByTagName("img")[0].src=e}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(e))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,el(this.cropper,g)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,ea(this.cropper,g)),this},destroy:function(){var e=this.element;return e[h]?(e[h]=void 0,this.isImg&&this.replaced&&(e.src=this.originalUrl),this.uncreate(),this):this},move:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=this.canvasData,i=n.left,r=n.top;return this.moveTo(q(e)?e:i+Number(e),q(t)?t:r+Number(t))},moveTo:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=this.canvasData,i=!1;return e=Number(e),t=Number(t),this.ready&&!this.disabled&&this.options.movable&&(G(e)&&(n.left=e,i=!0),G(t)&&(n.top=t,i=!0),i&&this.renderCanvas(!0)),this},zoom:function(e,t){var n=this.canvasData;return e=(e=Number(e))<0?1/(1-e):1+e,this.zoomTo(n.width*e/n.naturalWidth,null,t)},zoomTo:function(e,t,n){var i=this.options,r=this.canvasData,s=r.width,o=r.height,a=r.naturalWidth,l=r.naturalHeight;if((e=Number(e))>=0&&this.ready&&!this.disabled&&i.zoomable){var d=a*e,c=l*e;if(!1===eb(this.element,F,{ratio:e,oldRatio:s/a,originalEvent:n}))return this;if(n){var h,u,p,f=this.pointers,m=ey(this.cropper);var g=f&&Object.keys(f).length?(h=0,u=0,p=0,et(f,function(e){var t=e.startX,n=e.startY;h+=t,u+=n,p+=1}),h/=p,u/=p,{pageX:h,pageY:u}):{pageX:n.pageX,pageY:n.pageY};r.left-=(d-s)*((g.pageX-m.left-r.left)/s),r.top-=(c-o)*((g.pageY-m.top-r.top)/o)}else X(t)&&G(t.x)&&G(t.y)?(r.left-=(d-s)*((t.x-r.left)/s),r.top-=(c-o)*((t.y-r.top)/o)):(r.left-=(d-s)/2,r.top-=(c-o)/2);r.width=d,r.height=c,this.renderCanvas(!0)}return this},rotate:function(e){return this.rotateTo((this.imageData.rotate||0)+Number(e))},rotateTo:function(e){return G(e=Number(e))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=e%360,this.renderCanvas(!0,!0)),this},scaleX:function(e){var t=this.imageData.scaleY;return this.scale(e,G(t)?t:1)},scaleY:function(e){var t=this.imageData.scaleX;return this.scale(G(t)?t:1,e)},scale:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,n=this.imageData,i=!1;return e=Number(e),t=Number(t),this.ready&&!this.disabled&&this.options.scalable&&(G(e)&&(n.scaleX=e,i=!0),G(t)&&(n.scaleY=t,i=!0),i&&this.renderCanvas(!0,!0)),this},getData:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=this.options,i=this.imageData,r=this.canvasData,s=this.cropBoxData;if(this.ready&&this.cropped){e={x:s.left-r.left,y:s.top-r.top,width:s.width,height:s.height};var o=i.width/i.naturalWidth;if(et(e,function(t,n){e[n]=t/o}),t){var a=Math.round(e.y+e.height),l=Math.round(e.x+e.width);e.x=Math.round(e.x),e.y=Math.round(e.y),e.width=l-e.x,e.height=a-e.y}}else e={x:0,y:0,width:0,height:0};return n.rotatable&&(e.rotate=i.rotate||0),n.scalable&&(e.scaleX=i.scaleX||1,e.scaleY=i.scaleY||1),e},setData:function(e){var t=this.options,n=this.imageData,i=this.canvasData,r={};if(this.ready&&!this.disabled&&X(e)){var s=!1;t.rotatable&&G(e.rotate)&&e.rotate!==n.rotate&&(n.rotate=e.rotate,s=!0),t.scalable&&(G(e.scaleX)&&e.scaleX!==n.scaleX&&(n.scaleX=e.scaleX,s=!0),G(e.scaleY)&&e.scaleY!==n.scaleY&&(n.scaleY=e.scaleY,s=!0)),s&&this.renderCanvas(!0,!0);var o=n.width/n.naturalWidth;G(e.x)&&(r.left=e.x*o+i.left),G(e.y)&&(r.top=e.y*o+i.top),G(e.width)&&(r.width=e.width*o),G(e.height)&&(r.height=e.height*o),this.setCropBoxData(r)}return this},getContainerData:function(){return this.ready?en({},this.containerData):{}},getImageData:function(){return this.sized?en({},this.imageData):{}},getCanvasData:function(){var e=this.canvasData,t={};return this.ready&&et(["left","top","width","height","naturalWidth","naturalHeight"],function(n){t[n]=e[n]}),t},setCanvasData:function(e){var t=this.canvasData,n=t.aspectRatio;return this.ready&&!this.disabled&&X(e)&&(G(e.left)&&(t.left=e.left),G(e.top)&&(t.top=e.top),G(e.width)?(t.width=e.width,t.height=e.width/n):G(e.height)&&(t.height=e.height,t.width=e.height*n),this.renderCanvas(!0)),this},getCropBoxData:function(){var e,t=this.cropBoxData;return this.ready&&this.cropped&&(e={left:t.left,top:t.top,width:t.width,height:t.height}),e||{}},setCropBoxData:function(e){var t,n,i=this.cropBoxData,r=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&X(e)&&(G(e.left)&&(i.left=e.left),G(e.top)&&(i.top=e.top),G(e.width)&&e.width!==i.width&&(t=!0,i.width=e.width),G(e.height)&&e.height!==i.height&&(n=!0,i.height=e.height),r&&(t?i.height=i.width/r:n&&(i.width=i.height*r)),this.renderCropBox()),this},getCroppedCanvas:function(){var e,t,n,i,r,o,a,l,d,c,h,u,p,f,m,g,v,b,y,x,w,_,S,E,C,A,k,T,M,D,O,I,N,R,L,P,j,F,B,z,H=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var U=this.canvasData;var V=(e=this.image,t=this.imageData,n=U,i=H,r=t.aspectRatio,o=t.naturalWidth,a=t.naturalHeight,l=t.rotate,d=t.scaleX,c=t.scaleY,h=n.aspectRatio,u=n.naturalWidth,p=n.naturalHeight,f=i.fillColor,m=i.imageSmoothingEnabled,g=i.imageSmoothingQuality,b=void 0===(v=i.maxWidth)?1/0:v,x=void 0===(y=i.maxHeight)?1/0:y,_=void 0===(w=i.minWidth)?0:w,E=void 0===(S=i.minHeight)?0:S,A=(C=document.createElement("canvas")).getContext("2d"),k=eA({aspectRatio:h,width:b,height:x}),T=eA({aspectRatio:h,width:_,height:E},"cover"),M=Math.min(k.width,Math.max(T.width,u)),D=Math.min(k.height,Math.max(T.height,p)),O=eA({aspectRatio:r,width:b,height:x}),I=eA({aspectRatio:r,width:_,height:E},"cover"),N=Math.min(O.width,Math.max(I.width,o)),R=Math.min(O.height,Math.max(I.height,a)),C.width=er(M),C.height=er(D),A.fillStyle=void 0===f?"transparent":f,A.fillRect(0,0,M,D),A.save(),A.translate(M/2,D/2),A.rotate((void 0===l?0:l)*Math.PI/180),A.scale(void 0===d?1:d,void 0===c?1:c),A.imageSmoothingEnabled=void 0===m||m,A.imageSmoothingQuality=void 0===g?"low":g,A.drawImage.apply(A,[e].concat(s([-N/2,-R/2,N,R].map(function(e){return Math.floor(er(e))})))),A.restore(),C);if(!this.cropped)return V;var $=this.getData(H.rounded),W=$.x,G=$.y,Z=$.width,q=$.height,K=V.width/Math.floor(U.naturalWidth);1!==K&&(W*=K,G*=K,Z*=K,q*=K);var Y=Z/q,X=eA({aspectRatio:Y,width:H.maxWidth||1/0,height:H.maxHeight||1/0}),J=eA({aspectRatio:Y,width:H.minWidth||0,height:H.minHeight||0},"cover"),Q=eA({aspectRatio:Y,width:H.width||(1!==K?V.width:Z),height:H.height||(1!==K?V.height:q)}),ee=Q.width,et=Q.height;ee=Math.min(X.width,Math.max(J.width,ee)),et=Math.min(X.height,Math.max(J.height,et));var en=document.createElement("canvas"),ei=en.getContext("2d");en.width=er(ee),en.height=er(et),ei.fillStyle=H.fillColor||"transparent",ei.fillRect(0,0,ee,et);var es=H.imageSmoothingEnabled,eo=H.imageSmoothingQuality;ei.imageSmoothingEnabled=void 0===es||es,eo&&(ei.imageSmoothingQuality=eo);var ea=V.width,el=V.height,ed=W,ec=G;ed<=-Z||ed>ea?(ed=0,L=0,j=0,B=0):ed<=0?(j=-ed,B=L=Math.min(ea,Z+(ed=0))):ed<=ea&&(j=0,B=L=Math.min(Z,ea-ed)),L<=0||ec<=-q||ec>el?(ec=0,P=0,F=0,z=0):ec<=0?(F=-ec,z=P=Math.min(el,q+(ec=0))):ec<=el&&(F=0,z=P=Math.min(q,el-ec));var eh=[ed,ec,L,P];if(B>0&&z>0){var eu=ee/Z;eh.push(j*eu,F*eu,B*eu,z*eu)}return ei.drawImage.apply(ei,[V].concat(s(eh.map(function(e){return Math.floor(er(e))})))),en},setAspectRatio:function(e){var t=this.options;return!this.disabled&&!q(e)&&(t.aspectRatio=Math.max(0,e)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(e){var t=this.options,n=this.dragBox,i=this.face;if(this.ready&&!this.disabled){var r=e===E,s=t.movable&&e===C;e=r||s?e:A,t.dragMode=e,ep(n,_,e),ed(n,m,r),ed(n,w,s),!t.cropBoxMovable&&(ep(i,_,e),ed(i,m,r),ed(i,w,s))}return this}}),eD},e.exports=n()},739561:function(e){"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((i=(s=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=i;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,s[r]))return!1;for(r=i;0!=r--;){var i,r,s,o=s[r];if(!e(t[o],n[o]))return!1}return!0}return t!=t&&n!=n}},602042:function(e,t,n){"use strict";n.d(t,{m:()=>nQ});var i,r,s,o,a={};n.r(a),n.d(a,{access:()=>D,bound:()=>b,dfs:()=>C,focusNextElement:()=>k,focusPrevElement:()=>T,getInsertIndex:()=>P,getInsertParentId:()=>j,identify:()=>I,identifyNull:()=>O,indexOf:()=>S,isClosed:()=>x,isDescendant:()=>_,isItem:()=>y,isOpenWithEmptyChildren:()=>w,mergeRefs:()=>N,noop:()=>E,safeRun:()=>R,waitFor:()=>L,walk:()=>A});var l={};n.r(l),n.d(l,{FILE:()=>tT,HTML:()=>tO,TEXT:()=>tD,URL:()=>tM});var d=n("151064"),c=n("455069"),h=n("532973");let u=(0,c.createContext)(null);function p(){let e=(0,c.useContext)(u);if(null===e)throw Error("No Tree Api Provided");return e}let f=(0,c.createContext)(null),m=(0,c.createContext)(null),g=(0,c.createContext)(0);function v(){(0,c.useContext)(g)}function b(e,t,n){return Math.max(Math.min(e,n),t)}function y(e){return e&&e.isLeaf}function x(e){return e&&e.isInternal&&!e.isOpen}function w(e){var t;return e&&e.isOpen&&!(null===(t=e.children)||void 0===t?void 0:t.length)}let _=(e,t)=>{let n=e;for(;n;){if(n.id===t.id)return!0;n=n.parent}return!1},S=e=>{if(!e.parent)throw Error("Node does not have a parent");return e.parent.children.findIndex(t=>t.id===e.id)};function E(){}function C(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let n of e.children){let e=C(n,t);if(e)return e}return null}function A(e,t){if(t(e),e.children)for(let n of e.children)A(n,t)}function k(e){let t;let n=M(e);for(let i=0;i<n.length;++i)if(n[i]===e){t=function(e,t){return t+1<e.length?e[t+1]:e[0]}(n,i);break}null==t||t.focus()}function T(e){let t;let n=M(e);for(let i=0;i<n.length;++i)if(n[i]===e){t=function(e,t){return t-1>=0?e[t-1]:e[e.length-1]}(n,i);break}null==t||t.focus()}function M(e){return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter(t=>t===e||!e.contains(t))}function D(e,t){return"boolean"==typeof t?t:"string"==typeof t?e[t]:t(e)}function O(e){return null===e?null:I(e)}function I(e){return"string"==typeof e?e:e.id}function N(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}function R(e,...t){if(e)return e(...t)}function L(e){return new Promise((t,n)=>{let i=0;!function r(){100===(i+=1)&&n(),e()?t():setTimeout(r,10)}()})}function P(e){var t,n;let i=e.focusedNode;return i?i.isOpen?0:i.parent?i.childIndex+1:0:null!==(n=null===(t=e.root.children)||void 0===t?void 0:t.length)&&void 0!==n?n:0}function j(e){let t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}let F={display:"flex",alignItems:"center",zIndex:1},B={flex:1,height:"2px",background:"#4B91E2",borderRadius:"1px"},z={width:"4px",height:"4px",boxShadow:"0 0 0 3px #4B91E2",borderRadius:"50%"},H=c.memo(function({top:e,left:t,indent:n}){return(0,d.jsxs)("div",{style:Object.assign(Object.assign({},F),{position:"absolute",pointerEvents:"none",top:e-2+"px",left:t+"px",right:n+"px"}),children:[(0,d.jsx)("div",{style:Object.assign({},z)}),(0,d.jsx)("div",{style:Object.assign({},B)})]})});function U({node:e,attrs:t,innerRef:n,children:i}){return(0,d.jsx)("div",Object.assign({},t,{ref:n,onFocus:e=>e.stopPropagation(),onClick:e.handleClick,children:i}))}function V(e){return(0,d.jsxs)("div",{ref:e.dragHandle,style:e.style,children:[(0,d.jsx)("span",{onClick:t=>{t.stopPropagation(),e.node.toggle()},children:e.node.isLeaf?"\uD83C\uDF33":e.node.isOpen?"\uD83D\uDDC1":"\uD83D\uDDC0"})," ",e.node.isEditing?(0,d.jsx)(W,Object.assign({},e)):(0,d.jsx)($,Object.assign({},e))]})}function $(e){return(0,d.jsx)(d.Fragment,{children:(0,d.jsx)("span",{children:e.node.data.name})})}function W({node:e}){let t=(0,c.useRef)();return(0,c.useEffect)(()=>{var e,n;null===(e=t.current)||void 0===e||e.focus(),null===(n=t.current)||void 0===n||n.select()},[]),(0,d.jsx)("input",{ref:t,defaultValue:e.data.name,onBlur:()=>e.reset(),onKeyDown:n=>{var i;"Escape"===n.key&&e.reset(),"Enter"===n.key&&e.submit((null===(i=t.current)||void 0===i?void 0:i.value)||"")}})}function G(e){return{type:"EDIT",id:e}}function Z(e){return{type:"FOCUS",id:e}}class q{constructor(e){this.handleClick=e=>{e.metaKey&&!this.tree.props.disableMultiSelection?this.isSelected?this.deselect():this.selectMulti():e.shiftKey&&!this.tree.props.disableMultiSelection?this.selectContiguous():(this.select(),this.activate())},this.tree=e.tree,this.id=e.id,this.data=e.data,this.level=e.level,this.children=e.children,this.parent=e.parent,this.isDraggable=e.isDraggable,this.rowIndex=e.rowIndex}get isRoot(){return this.id===K}get isLeaf(){return!Array.isArray(this.children)}get isInternal(){return!this.isLeaf}get isOpen(){return!this.isLeaf&&this.tree.isOpen(this.id)}get isClosed(){return!this.isLeaf&&!this.tree.isOpen(this.id)}get isEditable(){return this.tree.isEditable(this.data)}get isEditing(){return this.tree.editingId===this.id}get isSelected(){return this.tree.isSelected(this.id)}get isOnlySelection(){return this.isSelected&&this.tree.hasOneSelection}get isSelectedStart(){var e;return this.isSelected&&!(null===(e=this.prev)||void 0===e?void 0:e.isSelected)}get isSelectedEnd(){var e;return this.isSelected&&!(null===(e=this.next)||void 0===e?void 0:e.isSelected)}get isFocused(){return this.tree.isFocused(this.id)}get isDragging(){return this.tree.isDragging(this.id)}get willReceiveDrop(){return this.tree.willReceiveDrop(this.id)}get state(){return{isClosed:this.isClosed,isDragging:this.isDragging,isEditing:this.isEditing,isFocused:this.isFocused,isInternal:this.isInternal,isLeaf:this.isLeaf,isOpen:this.isOpen,isSelected:this.isSelected,isSelectedEnd:this.isSelectedEnd,isSelectedStart:this.isSelectedStart,willReceiveDrop:this.willReceiveDrop}}get childIndex(){return this.parent&&this.parent.children?this.parent.children.findIndex(e=>e.id===this.id):-1}get next(){return null===this.rowIndex?null:this.tree.at(this.rowIndex+1)}get prev(){return null===this.rowIndex?null:this.tree.at(this.rowIndex-1)}get nextSibling(){var e,t;let n=this.childIndex;return null!==(t=null===(e=this.parent)||void 0===e?void 0:e.children[n+1])&&void 0!==t?t:null}isAncestorOf(e){if(!e)return!1;let t=e;for(;t;){if(t.id===this.id)return!0;t=t.parent}return!1}select(){this.tree.select(this)}deselect(){this.tree.deselect(this)}selectMulti(){this.tree.selectMulti(this)}selectContiguous(){this.tree.selectContiguous(this)}activate(){this.tree.activate(this)}focus(){this.tree.focus(this)}toggle(){this.tree.toggle(this)}open(){this.tree.open(this)}openParents(){this.tree.openParents(this)}close(){this.tree.close(this)}submit(e){this.tree.submit(this,e)}reset(){this.tree.reset()}clone(){return new q(Object.assign({},this))}edit(){return this.tree.edit(this)}}let K="__REACT_ARBORIST_INTERNAL_ROOT__";function Y(e){var t;let n=new q({tree:e,id:K,data:{id:K},level:-1,parent:null,children:null,isDraggable:!0,rowIndex:null}),i=null!==(t=e.props.data)&&void 0!==t?t:[];return n.children=i.map(t=>(function t(n,i,r){let s=e.accessId(n),o=new q({tree:e,data:n,level:i,parent:r,id:s,children:null,isDraggable:e.isDraggable(n),rowIndex:null}),a=e.accessChildren(n);return a&&(o.children=a.map(e=>t(e,i+1,o))),o})(t,0,n)),n}let X={open:(e,t)=>({type:"VISIBILITY_OPEN",id:e,filtered:t}),close:(e,t)=>({type:"VISIBILITY_CLOSE",id:e,filtered:t}),clear:e=>({type:"VISIBILITY_CLEAR",filtered:e})};function J(e={},t){if("VISIBILITY_OPEN"===t.type)return Object.assign(Object.assign({},e),{[t.id]:!0});if("VISIBILITY_CLOSE"===t.type)return Object.assign(Object.assign({},e),{[t.id]:!1});if("VISIBILITY_TOGGLE"===t.type){let n=e[t.id];return Object.assign(Object.assign({},e),{[t.id]:!n})}else if("VISIBILITY_CLEAR"===t.type)return{};else return e}let Q=e=>{var t;return{nodes:{open:{filtered:{},unfiltered:null!==(t=null==e?void 0:e.initialOpenState)&&void 0!==t?t:{}},focus:{id:null,treeFocused:!1},edit:{id:null},drag:{id:null,selectedIds:[],destinationParentId:null,destinationIndex:null},selection:{ids:new Set,anchor:null,mostRecent:null}},dnd:{cursor:{type:"none"},dragId:null,dragIds:[],parentId:null,index:-1}}},ee={only:e=>({type:"SELECTION_ONLY",id:I(e)}),add:e=>({type:"SELECTION_ADD",ids:(Array.isArray(e)?e:[e]).map(I)}),remove:e=>({type:"SELECTION_REMOVE",ids:(Array.isArray(e)?e:[e]).map(I)}),set:e=>Object.assign({type:"SELECTION_SET"},e),mostRecent:e=>({type:"SELECTION_MOST_RECENT",id:null===e?null:I(e)}),anchor:e=>({type:"SELECTION_ANCHOR",id:null===e?null:I(e)})},et={cursor:e=>({type:"DND_CURSOR",cursor:e}),dragStart:(e,t)=>({type:"DND_DRAG_START",id:e,dragIds:t}),dragEnd:()=>({type:"DND_DRAG_END"}),hovering:(e,t)=>({type:"DND_HOVERING",parentId:e,index:t})},en={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},ei=e=>{if(!e)return{display:"none"};let{x:t,y:n}=e;return{transform:`translate(${t}px, ${n}px)`}},er=e=>{if(!e)return{display:"none"};let{x:t,y:n}=e;return{transform:`translate(${t+10}px, ${n+10}px)`}};function es({offset:e,mouse:t,id:n,dragIds:i,isDragging:r}){return(0,d.jsxs)(eo,{isDragging:r,children:[(0,d.jsx)(ea,{offset:e,children:(0,d.jsx)(ed,{id:n,dragIds:i})}),(0,d.jsx)(el,{mouse:t,count:i.length})]})}let eo=(0,c.memo)(function(e){return e.isDragging?(0,d.jsx)("div",{style:en,children:e.children}):null});function ea(e){return(0,d.jsx)("div",{className:"row preview",style:ei(e.offset),children:e.children})}function el(e){let{count:t,mouse:n}=e;return t>1?(0,d.jsx)("div",{className:"selected-count",style:er(n),children:t}):null}let ed=(0,c.memo)(function(e){let t=p(),n=t.get(e.id);return n?(0,d.jsx)(t.renderNode,{preview:!0,node:n,style:{paddingLeft:n.level*t.indent,opacity:.2,background:"transparent"},tree:t}):null});var ec=n("517432");function eh(){var e,t;let n=p(),i=function(){let e=(0,c.useContext)(m);if(null===e)throw Error("Provide a DnDContext");return e}().cursor;if(!i||"line"!==i.type)return null;let r=n.indent,s=n.rowHeight*i.index+(null!==(t=null!==(e=n.props.padding)&&void 0!==e?e:n.props.paddingTop)&&void 0!==t?t:0),o=r*i.level,a=n.renderCursor;return(0,d.jsx)(a,{top:s,left:o,indent:r})}var eu=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)0>t.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n};let ep=(0,c.forwardRef)(function(e,t){let{children:n}=e,i=eu(e,["children"]),r=p();return(0,d.jsxs)("div",Object.assign({ref:t},i,{onClick:e=>{e.currentTarget===e.target&&r.deselectAll()},children:[(0,d.jsx)(ef,{}),n]}))}),ef=()=>{let e=p();return(0,d.jsx)("div",{style:{height:e.visibleNodes.length*e.rowHeight,width:"100%",position:"absolute",left:"0",right:"0"},children:(0,d.jsx)(eh,{})})};var em=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)0>t.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n};let eg=(0,c.forwardRef)(function(e,t){var n,i,r,s,{style:o}=e,a=em(e,["style"]);let l=p(),c=null!==(i=null!==(n=l.props.padding)&&void 0!==n?n:l.props.paddingTop)&&void 0!==i?i:0,h=null!==(s=null!==(r=l.props.padding)&&void 0!==r?r:l.props.paddingBottom)&&void 0!==s?s:0;return(0,d.jsx)("div",Object.assign({ref:t,style:Object.assign(Object.assign({},o),{height:`${parseFloat(o.height)+c+h}px`})},a))});var ev="undefined"!=typeof window?c.useLayoutEffect:c.useEffect;function eb(e){return(eb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ey(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ex(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ew=function(){var e,t,n;function i(e,t,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),ex(this,"spec",void 0),ex(this,"monitor",void 0),ex(this,"connector",void 0),this.spec=e,this.monitor=t,this.connector=n}return e=i,t=[{key:"beginDrag",value:function(){var e,t=this.spec,n=this.monitor,i=null;return null!==(e=i="object"===eb(t.item)?t.item:"function"==typeof t.item?t.item(n):{})&&void 0!==e?e:null}},{key:"canDrag",value:function(){var e=this.spec,t=this.monitor;return"boolean"==typeof e.canDrag?e.canDrag:"function"!=typeof e.canDrag||e.canDrag(t)}},{key:"isDragging",value:function(e,t){var n=this.spec,i=this.monitor,r=n.isDragging;return r?r(i):t===e.getSourceId()}},{key:"endDrag",value:function(){var e=this.spec,t=this.monitor,n=this.connector,i=e.end;i&&i(t.getItem(),t),n.reconnect()}}],ey(e.prototype,t),i}(),e_=n("789034"),eS=(0,c.createContext)({dragDropManager:void 0});function eE(){var e=(0,c.useContext)(eS).dragDropManager;return(0,e_.k)(null!=e,"Expected drag drop context"),e}function eC(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function eA(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function ek(e,t){var n,i=function(e){if(Array.isArray(e))return eA(e)}(n=t||[])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e,t){if(e){if("string"==typeof e)return eA(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eA(e,t)}}(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();return null==t&&"function"!=typeof e&&i.push(e),(0,c.useMemo)(function(){return"function"==typeof e?e():e},i)}function eT(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function eM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var eD=!1,eO=!1,eI=function(){var e,t,n;function i(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),eM(this,"internalMonitor",void 0),eM(this,"sourceId",null),this.internalMonitor=e.getMonitor()}return e=i,t=[{key:"receiveHandlerId",value:function(e){this.sourceId=e}},{key:"getHandlerId",value:function(){return this.sourceId}},{key:"canDrag",value:function(){(0,e_.k)(!eD,"You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return eD=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{eD=!1}}},{key:"isDragging",value:function(){if(!this.sourceId)return!1;(0,e_.k)(!eO,"You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return eO=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{eO=!1}}},{key:"subscribeToStateChange",value:function(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}},{key:"isDraggingSource",value:function(e){return this.internalMonitor.isDraggingSource(e)}},{key:"isOverTarget",value:function(e,t){return this.internalMonitor.isOverTarget(e,t)}},{key:"getTargetIds",value:function(){return this.internalMonitor.getTargetIds()}},{key:"isSourcePublic",value:function(){return this.internalMonitor.isSourcePublic()}},{key:"getSourceId",value:function(){return this.internalMonitor.getSourceId()}},{key:"subscribeToOffsetChange",value:function(e){return this.internalMonitor.subscribeToOffsetChange(e)}},{key:"canDragSource",value:function(e){return this.internalMonitor.canDragSource(e)}},{key:"canDropOnTarget",value:function(e){return this.internalMonitor.canDropOnTarget(e)}},{key:"getItemType",value:function(){return this.internalMonitor.getItemType()}},{key:"getItem",value:function(){return this.internalMonitor.getItem()}},{key:"getDropResult",value:function(){return this.internalMonitor.getDropResult()}},{key:"didDrop",value:function(){return this.internalMonitor.didDrop()}},{key:"getInitialClientOffset",value:function(){return this.internalMonitor.getInitialClientOffset()}},{key:"getInitialSourceClientOffset",value:function(){return this.internalMonitor.getInitialSourceClientOffset()}},{key:"getSourceClientOffset",value:function(){return this.internalMonitor.getSourceClientOffset()}},{key:"getClientOffset",value:function(){return this.internalMonitor.getClientOffset()}},{key:"getDifferenceFromInitialOffset",value:function(){return this.internalMonitor.getDifferenceFromInitialOffset()}}],eT(e.prototype,t),i}();function eN(e){var t={};return Object.keys(e).forEach(function(n){var i=e[n];if(n.endsWith("Ref"))t[n]=e[n];else{var r,s=(r=i,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,c.isValidElement)(e)?(!function(e){if("string"!=typeof e.type){var t=e.type.displayName||e.type.name||"the component";throw Error("Only native element nodes can now be passed to React DnD connectors."+"You can either wrap ".concat(t," into a <div>, or turn it into a ")+"drag source or a drop target itself.")}}(e),function(e,t){var n=e.ref;return((0,e_.k)("string"!=typeof n,"Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"),n)?(0,c.cloneElement)(e,{ref:function(e){eR(n,e),eR(t,e)}}):(0,c.cloneElement)(e,{ref:t})}(e,t?function(e){return r(e,t)}:r)):(r(e,t),e)});t[n]=function(){return s}}}),t}function eR(e,t){"function"==typeof e?e(t):e.current=t}function eL(e){return(eL="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function eP(e){return null!==e&&"object"===eL(e)&&Object.prototype.hasOwnProperty.call(e,"current")}var ej=n("712003");function eF(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function eB(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ez=function(){var e,t,n;function i(e){var t=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),eB(this,"hooks",eN({dragSource:function(e,n){t.clearDragSource(),t.dragSourceOptions=n||null,eP(e)?t.dragSourceRef=e:t.dragSourceNode=e,t.reconnectDragSource()},dragPreview:function(e,n){t.clearDragPreview(),t.dragPreviewOptions=n||null,eP(e)?t.dragPreviewRef=e:t.dragPreviewNode=e,t.reconnectDragPreview()}})),eB(this,"handlerId",null),eB(this,"dragSourceRef",null),eB(this,"dragSourceNode",void 0),eB(this,"dragSourceOptionsInternal",null),eB(this,"dragSourceUnsubscribe",void 0),eB(this,"dragPreviewRef",null),eB(this,"dragPreviewNode",void 0),eB(this,"dragPreviewOptionsInternal",null),eB(this,"dragPreviewUnsubscribe",void 0),eB(this,"lastConnectedHandlerId",null),eB(this,"lastConnectedDragSource",null),eB(this,"lastConnectedDragSourceOptions",null),eB(this,"lastConnectedDragPreview",null),eB(this,"lastConnectedDragPreviewOptions",null),eB(this,"backend",void 0),this.backend=e}return e=i,t=[{key:"receiveHandlerId",value:function(e){if(this.handlerId!==e)this.handlerId=e,this.reconnect()}},{key:"connectTarget",get:function(){return this.dragSource}},{key:"dragSourceOptions",get:function(){return this.dragSourceOptionsInternal},set:function(e){this.dragSourceOptionsInternal=e}},{key:"dragPreviewOptions",get:function(){return this.dragPreviewOptionsInternal},set:function(e){this.dragPreviewOptionsInternal=e}},{key:"reconnect",value:function(){this.reconnectDragSource(),this.reconnectDragPreview()}},{key:"reconnectDragSource",value:function(){var e=this.dragSource,t=this.didHandlerIdChange()||this.didConnectedDragSourceChange()||this.didDragSourceOptionsChange();if(t&&this.disconnectDragSource(),!!this.handlerId){if(!e){this.lastConnectedDragSource=e;return}t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragSource=e,this.lastConnectedDragSourceOptions=this.dragSourceOptions,this.dragSourceUnsubscribe=this.backend.connectDragSource(this.handlerId,e,this.dragSourceOptions))}}},{key:"reconnectDragPreview",value:function(){var e=this.dragPreview,t=this.didHandlerIdChange()||this.didConnectedDragPreviewChange()||this.didDragPreviewOptionsChange();if(t&&this.disconnectDragPreview(),!!this.handlerId){if(!e){this.lastConnectedDragPreview=e;return}t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragPreview=e,this.lastConnectedDragPreviewOptions=this.dragPreviewOptions,this.dragPreviewUnsubscribe=this.backend.connectDragPreview(this.handlerId,e,this.dragPreviewOptions))}}},{key:"didHandlerIdChange",value:function(){return this.lastConnectedHandlerId!==this.handlerId}},{key:"didConnectedDragSourceChange",value:function(){return this.lastConnectedDragSource!==this.dragSource}},{key:"didConnectedDragPreviewChange",value:function(){return this.lastConnectedDragPreview!==this.dragPreview}},{key:"didDragSourceOptionsChange",value:function(){return!(0,ej.w)(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}},{key:"didDragPreviewOptionsChange",value:function(){return!(0,ej.w)(this.lastConnectedDragPreviewOptions,this.dragPreviewOptions)}},{key:"disconnectDragSource",value:function(){this.dragSourceUnsubscribe&&(this.dragSourceUnsubscribe(),this.dragSourceUnsubscribe=void 0)}},{key:"disconnectDragPreview",value:function(){this.dragPreviewUnsubscribe&&(this.dragPreviewUnsubscribe(),this.dragPreviewUnsubscribe=void 0,this.dragPreviewNode=null,this.dragPreviewRef=null)}},{key:"dragSource",get:function(){return this.dragSourceNode||this.dragSourceRef&&this.dragSourceRef.current}},{key:"dragPreview",get:function(){return this.dragPreviewNode||this.dragPreviewRef&&this.dragPreviewRef.current}},{key:"clearDragSource",value:function(){this.dragSourceNode=null,this.dragSourceRef=null}},{key:"clearDragPreview",value:function(){this.dragPreviewNode=null,this.dragPreviewRef=null}}],eF(e.prototype,t),i}(),eH=n("739561"),eU=n.n(eH);function eV(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function e$(e,t,n){var i,r,s=(r=2,function(e){if(Array.isArray(e))return e}(i=(0,c.useState)(function(){return t(e)}))||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var s=[],o=!0,a=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);o=!0);}catch(e){a=!0,i=e}finally{try{!o&&null!=r.return&&r.return()}finally{if(a)throw i}}return s}}(i,2)||function(e,t){if(e){if("string"==typeof e)return eV(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eV(e,t)}}(i,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=s[0],a=s[1],l=(0,c.useCallback)(function(){var i=t(e);!eU()(o,i)&&(a(i),n&&n())},[o,e,n]);return ev(l),[o,l]}function eW(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function eG(e,t,n){var i,r,s,o,a,l;return a=(o=(s=2,function(e){if(Array.isArray(e))return e}(r=e$(i=t,e||function(){return{}},function(){return n.reconnect()}))||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var s=[],o=!0,a=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);o=!0);}catch(e){a=!0,i=e}finally{try{!o&&null!=r.return&&r.return()}finally{if(a)throw i}}return s}}(r,2)||function(e,t){if(e){if("string"==typeof e)return eW(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eW(e,t)}}(r,s)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))[0],ev(function(){var e=i.getHandlerId();if(null!=e)return i.subscribeToStateChange(l,{handlerIds:[e]})},[i,l=o[1]]),a}function eZ(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function eq(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var eK=function(){var e,t,n;function i(e,t){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),eq(this,"spec",void 0),eq(this,"monitor",void 0),this.spec=e,this.monitor=t}return e=i,t=[{key:"canDrop",value:function(){var e=this.spec,t=this.monitor;return!e.canDrop||e.canDrop(t.getItem(),t)}},{key:"hover",value:function(){var e=this.spec,t=this.monitor;e.hover&&e.hover(t.getItem(),t)}},{key:"drop",value:function(){var e=this.spec,t=this.monitor;if(e.drop)return e.drop(t.getItem(),t)}}],eZ(e.prototype,t),i}();function eY(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function eX(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function eJ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var eQ=!1,e0=function(){var e,t,n;function i(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),eJ(this,"internalMonitor",void 0),eJ(this,"targetId",null),this.internalMonitor=e.getMonitor()}return e=i,t=[{key:"receiveHandlerId",value:function(e){this.targetId=e}},{key:"getHandlerId",value:function(){return this.targetId}},{key:"subscribeToStateChange",value:function(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}},{key:"canDrop",value:function(){if(!this.targetId)return!1;(0,e_.k)(!eQ,"You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor");try{return eQ=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{eQ=!1}}},{key:"isOver",value:function(e){return!!this.targetId&&this.internalMonitor.isOverTarget(this.targetId,e)}},{key:"getItemType",value:function(){return this.internalMonitor.getItemType()}},{key:"getItem",value:function(){return this.internalMonitor.getItem()}},{key:"getDropResult",value:function(){return this.internalMonitor.getDropResult()}},{key:"didDrop",value:function(){return this.internalMonitor.didDrop()}},{key:"getInitialClientOffset",value:function(){return this.internalMonitor.getInitialClientOffset()}},{key:"getInitialSourceClientOffset",value:function(){return this.internalMonitor.getInitialSourceClientOffset()}},{key:"getSourceClientOffset",value:function(){return this.internalMonitor.getSourceClientOffset()}},{key:"getClientOffset",value:function(){return this.internalMonitor.getClientOffset()}},{key:"getDifferenceFromInitialOffset",value:function(){return this.internalMonitor.getDifferenceFromInitialOffset()}}],eX(e.prototype,t),i}();function e1(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function e2(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var e5=function(){var e,t,n;function i(e){var t=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),e2(this,"hooks",eN({dropTarget:function(e,n){t.clearDropTarget(),t.dropTargetOptions=n,eP(e)?t.dropTargetRef=e:t.dropTargetNode=e,t.reconnect()}})),e2(this,"handlerId",null),e2(this,"dropTargetRef",null),e2(this,"dropTargetNode",void 0),e2(this,"dropTargetOptionsInternal",null),e2(this,"unsubscribeDropTarget",void 0),e2(this,"lastConnectedHandlerId",null),e2(this,"lastConnectedDropTarget",null),e2(this,"lastConnectedDropTargetOptions",null),e2(this,"backend",void 0),this.backend=e}return e=i,t=[{key:"connectTarget",get:function(){return this.dropTarget}},{key:"reconnect",value:function(){var e=this.didHandlerIdChange()||this.didDropTargetChange()||this.didOptionsChange();e&&this.disconnectDropTarget();var t=this.dropTarget;if(!!this.handlerId){if(!t){this.lastConnectedDropTarget=t;return}e&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDropTarget=t,this.lastConnectedDropTargetOptions=this.dropTargetOptions,this.unsubscribeDropTarget=this.backend.connectDropTarget(this.handlerId,t,this.dropTargetOptions))}}},{key:"receiveHandlerId",value:function(e){if(e!==this.handlerId)this.handlerId=e,this.reconnect()}},{key:"dropTargetOptions",get:function(){return this.dropTargetOptionsInternal},set:function(e){this.dropTargetOptionsInternal=e}},{key:"didHandlerIdChange",value:function(){return this.lastConnectedHandlerId!==this.handlerId}},{key:"didDropTargetChange",value:function(){return this.lastConnectedDropTarget!==this.dropTarget}},{key:"didOptionsChange",value:function(){return!(0,ej.w)(this.lastConnectedDropTargetOptions,this.dropTargetOptions)}},{key:"disconnectDropTarget",value:function(){this.unsubscribeDropTarget&&(this.unsubscribeDropTarget(),this.unsubscribeDropTarget=void 0)}},{key:"dropTarget",get:function(){return this.dropTargetNode||this.dropTargetRef&&this.dropTargetRef.current}},{key:"clearDropTarget",value:function(){this.dropTargetRef=null,this.dropTargetNode=null}}],e1(e.prototype,t),i}();function e3(e,t){var n,i,r,s,o,a,l,d,h,u,p,f,m,g,v,b,y=ek(e,t);var x=(n=eE(),(0,c.useMemo)(function(){return new e0(n)},[n]));var w=(i=y.options,r=eE(),s=(0,c.useMemo)(function(){return new e5(r.getBackend())},[r]),ev(function(){return s.dropTargetOptions=i||null,s.reconnect(),function(){return s.disconnectDropTarget()}},[i]),s);return o=y,a=x,l=w,d=eE(),f=(h=o,u=a,p=(0,c.useMemo)(function(){return new eK(h,u)},[u]),(0,c.useEffect)(function(){p.spec=h},[h]),p),ev(function(){var e,t,n,i,r,s,o=(s=2,function(e){if(Array.isArray(e))return e}(r=(e=v,t=f,[i=(n=d.getRegistry()).addTarget(e,t),function(){return n.removeTarget(i)}]))||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var s=[],o=!0,a=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);o=!0);}catch(e){a=!0,i=e}finally{try{!o&&null!=r.return&&r.return()}finally{if(a)throw i}}return s}}(r,2)||function(e,t){if(e){if("string"==typeof e)return eY(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eY(e,t)}}(r,s)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=o[0],h=o[1];return a.receiveHandlerId(c),l.receiveHandlerId(c),h},[d,a,f,l,(v=(g=(m=o).accept,(0,c.useMemo)(function(){return(0,e_.k)(null!=m.accept,"accept must be defined"),Array.isArray(g)?g:[g]},[g]))).map(function(e){return e.toString()}).join("|")]),[eG(y.collect,x,w),(b=w,(0,c.useMemo)(function(){return b.hooks.dropTarget()},[b]))]}function e4(e,t){return{parentId:e||null,index:t}}function e6(e,t){return{type:"line",index:e,level:t}}function e8(e,t){var n;let i=e;for(;i.parent&&i.level>t;)i=i.parent;let r=(null===(n=i.parent)||void 0===n?void 0:n.id)||null;return{parentId:r,index:S(i)+1}}function e7(e){var t;let n=function(e,t){let n=e.getBoundingClientRect(),i=t.x-Math.round(n.x),r=t.y-Math.round(n.y),s=n.height,o=r<s/2,a=!o,l=s/4,d=r>l&&r<s-l;return{x:i,inTopHalf:o,inBottomHalf:a,inMiddle:d,atTop:!d&&o,atBottom:!d&&a}}(e.element,e.offset),i=e.indent,r=Math.round(Math.max(0,n.x-i)/i),{node:s,nextNode:o,prevNode:a}=e,[l,d]=function(e,t,n,i){if(!e)return[t,null];if(e.isInternal)return i.atTop?[t,e]:i.inMiddle?[e,e]:[e,n];return i.inTopHalf?[t,e]:[e,n]}(s,a,o,n);if(s&&s.isInternal&&n.inMiddle)return{drop:e4(s.id,null),cursor:{type:"highlight",id:s.id}};if(!l)return{drop:e4(null===(t=null==d?void 0:d.parent)||void 0===t?void 0:t.id,0),cursor:e6(0,0)};if(y(l)||x(l)){let e=b(r,(null==d?void 0:d.level)||0,l.level);return{drop:e8(l,e),cursor:e6(l.rowIndex+1,e)}}if(w(l)){let e=b(r,0,l.level+1);return e>l.level?{drop:e4(l.id,0),cursor:e6(l.rowIndex+1,e)}:{drop:e8(l,e),cursor:e6(l.rowIndex+1,e)}}return{drop:e4(null==l?void 0:l.id,0),cursor:e6(l.rowIndex+1,l.level+1)}}let e9=c.memo(function({index:e,style:t}){v(),!function(){let e=(0,c.useContext)(f);if(null===e)throw Error("Provide a NodesContext");}();let n=p(),i=function(e){let t=p(),n=t.at(e);if(!n)throw Error(`Could not find node for index: ${e}`);return(0,c.useMemo)(()=>{let i=n.clone();return t.visibleNodes[e]=i,i},[...Object.values(n.state),n])}(e),s=(0,c.useRef)(null),o=function(e){var t,n,i,s,o,a,l,d,h,u,f,m,g,v,b,y,x,w,_,S,E;let C=p(),A=C.selectedIds;let[k,T,M]=(t=ek(()=>({canDrag:()=>e.isDraggable,type:"NODE",item:()=>{let t=C.isSelected(e.id)?Array.from(A):[e.id];return C.dispatch(et.dragStart(e.id,t)),{id:e.id,dragIds:t}},end:()=>{C.hideCursor(),C.dispatch(et.dragEnd())}}),[A,e]),(0,e_.k)(!t.begin,"useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)"),i=(n=eE(),(0,c.useMemo)(function(){return new eI(n)},[n])),d=(s=t.options,o=t.previewOptions,a=eE(),ev(function(){return l.dragSourceOptions=s||null,l.reconnect(),function(){return l.disconnectDragSource()}},[l=(0,c.useMemo)(function(){return new ez(a.getBackend())},[a]),s]),ev(function(){return l.dragPreviewOptions=o||null,l.reconnect(),function(){return l.disconnectDragPreview()}},[l,o]),l),h=t,u=i,f=d,m=eE(),x=(g=h,v=u,b=f,y=(0,c.useMemo)(function(){return new ew(g,v,b)},[v,b]),(0,c.useEffect)(function(){y.spec=g},[g]),y),ev(function(){if(null!=_){var e,t,n,i,r,s,o=(s=2,function(e){if(Array.isArray(e))return e}(r=(e=_,t=x,[i=(n=m.getRegistry()).addSource(e,t),function(){return n.removeSource(i)}]))||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var s=[],o=!0,a=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);o=!0);}catch(e){a=!0,i=e}finally{try{!o&&null!=r.return&&r.return()}finally{if(a)throw i}}return s}}(r,2)||function(e,t){if(e){if("string"==typeof e)return eC(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eC(e,t)}}(r,s)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=o[0],l=o[1];return u.receiveHandlerId(a),f.receiveHandlerId(a),l}},[m,u,f,x,_=(w=h,(0,c.useMemo)(function(){var e=w.type;return(0,e_.k)(null!=e,"spec.type must be defined"),e},[w]))]),[eG(t.collect,i,d),(S=d,(0,c.useMemo)(function(){return S.hooks.dragSource()},[S])),(E=d,(0,c.useMemo)(function(){return E.hooks.dragPreview()},[E]))]);return(0,c.useEffect)(()=>{M((!r&&((r=new Image).src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),r))},[M]),T}(i),a=function(e,t){let n=p(),[i,r]=e3(()=>({accept:"NODE",canDrop:()=>n.canDrop(),hover:(i,r)=>{let s=r.getClientOffset();if(!e.current||!s)return;let{cursor:o,drop:a}=e7({element:e.current,offset:s,indent:n.indent,node:t,prevNode:t.prev,nextNode:t.next});a&&n.dispatch(et.hovering(a.parentId,a.index)),r.canDrop()?o&&n.showCursor(o):n.hideCursor()},drop:(e,t)=>{if(!t.canDrop())return null;let{parentId:i,index:r,dragIds:s}=n.state.dnd;R(n.props.onMove,{dragIds:s,parentId:i===K?null:i,index:null===r?0:r,dragNodes:n.dragNodes,parentNode:n.get(i)}),n.open(i)}}),[t,e.current,n.props]);return r}(s,i),l=(0,c.useCallback)(e=>{s.current=e,a(e)},[a]),h=n.indent*i.level,u=(0,c.useMemo)(()=>({paddingLeft:h}),[h]),m=(0,c.useMemo)(()=>{var e,i;return Object.assign(Object.assign({},t),{top:parseFloat(t.top)+(null!==(i=null!==(e=n.props.padding)&&void 0!==e?e:n.props.paddingTop)&&void 0!==i?i:0)})},[t,n.props.padding,n.props.paddingTop]),g={role:"treeitem","aria-level":i.level+1,"aria-selected":i.isSelected,"aria-expanded":i.isOpen,style:m,tabIndex:-1,className:n.props.rowClassName};(0,c.useEffect)(()=>{var e;!i.isEditing&&i.isFocused&&(null===(e=s.current)||void 0===e||e.focus({preventScroll:!0}))},[i.isEditing,i.isFocused,s.current]);let b=n.renderNode,y=n.renderRow;return(0,d.jsx)(y,{node:i,innerRef:l,attrs:g,children:(0,d.jsx)(b,{node:i,tree:n,style:u,dragHandle:o})})}),te="",tt=null;function tn(){v();let e=p();return(0,d.jsx)("div",{role:"tree",style:{height:e.height,width:e.width,minHeight:0,minWidth:0},onContextMenu:e.props.onContextMenu,onClick:e.props.onClick,tabIndex:0,onFocus:t=>{!t.currentTarget.contains(t.relatedTarget)&&e.onFocus()},onBlur:t=>{!t.currentTarget.contains(t.relatedTarget)&&e.onBlur()},onKeyDown:t=>{var n;if(e.isEditing)return;if("Backspace"===t.key){if(!e.props.onDelete)return;let t=Array.from(e.selectedIds);if(t.length>1){let n=e.mostRecentNode;for(;n&&n.isSelected;)n=n.nextSibling;!n&&(n=e.lastNode),e.focus(n,{scroll:!1}),e.delete(Array.from(t))}else{let t=e.focusedNode;if(t){let n=t.nextSibling,i=t.parent;e.focus(n||i,{scroll:!1}),e.delete(t)}}return}if("Tab"===t.key&&!t.shiftKey){t.preventDefault(),k(t.currentTarget);return}if("Tab"===t.key&&t.shiftKey){t.preventDefault(),T(t.currentTarget);return}if("ArrowDown"===t.key){t.preventDefault();let n=e.nextNode;if(t.metaKey){e.select(e.focusedNode),e.activate(e.focusedNode);return}if(!t.shiftKey||e.props.disableMultiSelection){e.focus(n);return}else{if(!n)return;let t=e.focusedNode;t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.firstNode);return}}if("ArrowUp"===t.key){t.preventDefault();let n=e.prevNode;if(!t.shiftKey||e.props.disableMultiSelection){e.focus(n);return}{if(!n)return;let t=e.focusedNode;t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.lastNode);return}}if("ArrowRight"===t.key){let t=e.focusedNode;if(!t)return;t.isInternal&&t.isOpen?e.focus(e.nextNode):t.isInternal&&e.open(t.id);return}if("ArrowLeft"===t.key){let t=e.focusedNode;if(!t||t.isRoot)return;t.isInternal&&t.isOpen?e.close(t.id):!(null===(n=t.parent)||void 0===n?void 0:n.isRoot)&&e.focus(t.parent);return}if("a"===t.key&&t.metaKey&&!e.props.disableMultiSelection){t.preventDefault(),e.selectAll();return}if("a"===t.key&&!t.metaKey&&e.props.onCreate){e.createLeaf();return}if("A"===t.key&&!t.metaKey){if(!e.props.onCreate)return;e.createInternal();return}if("Home"===t.key){t.preventDefault(),e.focus(e.firstNode);return}if("End"===t.key){t.preventDefault(),e.focus(e.lastNode);return}if("Enter"===t.key){let t=e.focusedNode;if(!t||!t.isEditable||!e.props.onRename)return;setTimeout(()=>{t&&e.edit(t)});return}if(" "===t.key){t.preventDefault();let n=e.focusedNode;if(!n)return;n.isLeaf?(n.select(),n.activate()):n.toggle();return}if("*"===t.key){let t=e.focusedNode;if(!t)return;e.openSiblings(t);return}if("PageUp"===t.key){t.preventDefault(),e.pageUp();return}"PageDown"===t.key&&(t.preventDefault(),e.pageDown()),clearTimeout(tt),te+=t.key,tt=setTimeout(()=>{te=""},600);let i=e.visibleNodes.find(e=>{let t=e.data.name;return"string"==typeof t&&t.toLowerCase().startsWith(te)});i&&e.focus(i.id)},children:(0,d.jsx)(ec.t7,{className:e.props.className,outerRef:e.listEl,itemCount:e.visibleNodes.length,height:e.height,width:e.width,itemSize:e.rowHeight,overscanCount:e.overscanCount,itemKey:t=>{var n;return(null===(n=e.visibleNodes[t])||void 0===n?void 0:n.id)||t},outerElementType:ep,innerElementType:eg,onScroll:e.props.onScroll,onItemsRendered:e.onItemsRendered.bind(e),ref:e.list,children:e9})})}function ti(e){return e.isFiltered?function(e,t){let n={},i=[];return!function e(i){if(!i.isRoot&&t(i)){n[i.id]=!0;let e=i.parent;for(;e;)n[e.id]=!0,e=e.parent}if(i.children)for(let t of i.children)e(t)}(e),!function e(t){var r;t.level>=0&&n[t.id]&&i.push(t),t.isOpen&&(null===(r=t.children)||void 0===r||r.forEach(e))}(e),i.forEach(tr),i}(e.root,e.isMatch.bind(e)):function(e){let t=[];return!function e(n){var i;n.level>=0&&t.push(n),n.isOpen&&(null===(i=n.children)||void 0===i||i.forEach(e))}(e),t.forEach(tr),t}(e.root)}function tr(e,t){e.rowIndex=t}let ts=e=>e.reduce((e,t,n)=>(e[t.id]=n,e),{});var to=function(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})};let{safeRun:ta,identify:tl,identifyNull:td}=a;class tc{constructor(e,t,n,i){this.store=e,this.props=t,this.list=n,this.listEl=i,this.visibleStartIndex=0,this.visibleStopIndex=0,this.root=Y(this),this.visibleNodes=ti(this),this.idToIndex=ts(this.visibleNodes)}update(e){this.props=e,this.root=Y(this),this.visibleNodes=ti(this),this.idToIndex=ts(this.visibleNodes)}dispatch(e){return this.store.dispatch(e)}get state(){return this.store.getState()}get openState(){return this.state.nodes.open.unfiltered}get width(){var e;return null!==(e=this.props.width)&&void 0!==e?e:300}get height(){var e;return null!==(e=this.props.height)&&void 0!==e?e:500}get indent(){var e;return null!==(e=this.props.indent)&&void 0!==e?e:24}get rowHeight(){var e;return null!==(e=this.props.rowHeight)&&void 0!==e?e:24}get overscanCount(){var e;return null!==(e=this.props.overscanCount)&&void 0!==e?e:1}get searchTerm(){return(this.props.searchTerm||"").trim()}get matchFn(){var e;let t=null!==(e=this.props.searchMatch)&&void 0!==e?e:(e,t)=>JSON.stringify(Object.values(e.data)).toLocaleLowerCase().includes(t.toLocaleLowerCase());return e=>t(e,this.searchTerm)}accessChildren(e){var t;return null!==(t=D(e,this.props.childrenAccessor||"children"))&&void 0!==t?t:null}accessId(e){let t=D(e,this.props.idAccessor||"id");if(!t)throw Error("Data must contain an 'id' property or props.idAccessor must return a string");return t}get firstNode(){var e;return null!==(e=this.visibleNodes[0])&&void 0!==e?e:null}get lastNode(){var e;return null!==(e=this.visibleNodes[this.visibleNodes.length-1])&&void 0!==e?e:null}get focusedNode(){var e;return null!==(e=this.get(this.state.nodes.focus.id))&&void 0!==e?e:null}get mostRecentNode(){var e;return null!==(e=this.get(this.state.nodes.selection.mostRecent))&&void 0!==e?e:null}get nextNode(){let e=this.indexOf(this.focusedNode);return null===e?null:this.at(e+1)}get prevNode(){let e=this.indexOf(this.focusedNode);return null===e?null:this.at(e-1)}get(e){return e&&e in this.idToIndex&&this.visibleNodes[this.idToIndex[e]]||null}at(e){return this.visibleNodes[e]||null}nodesBetween(e,t){var n;if(null===e||null===t)return[];let i=null!==(n=this.indexOf(e))&&void 0!==n?n:0,r=this.indexOf(t);if(null===r)return[];let s=Math.min(i,r),o=Math.max(i,r);return this.visibleNodes.slice(s,o+1)}indexOf(e){let t=O(e);return t?this.idToIndex[t]:null}get editingId(){return this.state.nodes.edit.id}createInternal(){return this.create({type:"internal"})}createLeaf(){return this.create({type:"leaf"})}create(){return to(this,arguments,void 0,function*(e={}){var t,n;let i=void 0===e.parentId?j(this):e.parentId,r=null!==(t=e.index)&&void 0!==t?t:P(this),s=null!==(n=e.type)&&void 0!==n?n:"leaf",o=yield ta(this.props.onCreate,{type:s,parentId:i,index:r,parentNode:this.get(i)});o&&(this.focus(o),setTimeout(()=>{this.edit(o).then(()=>{this.select(o),this.activate(o)})}))})}delete(e){return to(this,void 0,void 0,function*(){if(!e)return;let t=(Array.isArray(e)?e:[e]).map(tl),n=t.map(e=>this.get(e)).filter(e=>!!e);yield ta(this.props.onDelete,{nodes:n,ids:t})})}edit(e){let t=tl(e);return this.resolveEdit({cancelled:!0}),this.scrollTo(t),this.dispatch(G(t)),new Promise(e=>{tc.editPromise=e})}submit(e,t){return to(this,void 0,void 0,function*(){if(!e)return;let n=tl(e);yield ta(this.props.onRename,{id:n,name:t,node:this.get(n)}),this.dispatch(G(null)),this.resolveEdit({cancelled:!1,value:t}),setTimeout(()=>this.onFocus())})}reset(){this.dispatch(G(null)),this.resolveEdit({cancelled:!0}),setTimeout(()=>this.onFocus())}activate(e){let t=this.get(td(e));t&&ta(this.props.onActivate,t)}resolveEdit(e){let t=tc.editPromise;t&&t(e),tc.editPromise=null}get selectedIds(){return this.state.nodes.selection.ids}get selectedNodes(){let e=[];for(let t of Array.from(this.selectedIds)){let n=this.get(t);n&&e.push(n)}return e}focus(e,t={}){e&&(this.props.selectionFollowsFocus?this.select(e):(this.dispatch(Z(tl(e))),!1!==t.scroll&&this.scrollTo(e),this.focusedNode&&ta(this.props.onFocus,this.focusedNode)))}pageUp(){var e,t;let n=this.visibleStartIndex,i=this.visibleStopIndex-n,r=null!==(t=null===(e=this.focusedNode)||void 0===e?void 0:e.rowIndex)&&void 0!==t?t:0;r=r>n?n:Math.max(n-i,0),this.focus(this.at(r))}pageDown(){var e,t;let n=this.visibleStartIndex,i=this.visibleStopIndex,r=i-n,s=null!==(t=null===(e=this.focusedNode)||void 0===e?void 0:e.rowIndex)&&void 0!==t?t:0;s=s<i?i:Math.min(s+r,this.visibleNodes.length-1),this.focus(this.at(s))}select(e,t={}){if(!e)return;let n=!1!==t.focus,i=tl(e);n&&this.dispatch(Z(i)),this.dispatch(ee.only(i)),this.dispatch(ee.anchor(i)),this.dispatch(ee.mostRecent(i)),this.scrollTo(i,t.align),this.focusedNode&&n&&ta(this.props.onFocus,this.focusedNode),ta(this.props.onSelect,this.selectedNodes)}deselect(e){if(!e)return;let t=tl(e);this.dispatch(ee.remove(t)),ta(this.props.onSelect,this.selectedNodes)}selectMulti(e){let t=this.get(td(e));t&&(this.dispatch(Z(t.id)),this.dispatch(ee.add(t.id)),this.dispatch(ee.anchor(t.id)),this.dispatch(ee.mostRecent(t.id)),this.scrollTo(t),this.focusedNode&&ta(this.props.onFocus,this.focusedNode),ta(this.props.onSelect,this.selectedNodes))}selectContiguous(e){if(!e)return;let t=tl(e),{anchor:n,mostRecent:i}=this.state.nodes.selection;this.dispatch(Z(t)),this.dispatch(ee.remove(this.nodesBetween(n,i))),this.dispatch(ee.add(this.nodesBetween(n,td(t)))),this.dispatch(ee.mostRecent(t)),this.scrollTo(t),this.focusedNode&&ta(this.props.onFocus,this.focusedNode),ta(this.props.onSelect,this.selectedNodes)}deselectAll(){this.setSelection({ids:[],anchor:null,mostRecent:null}),ta(this.props.onSelect,this.selectedNodes)}selectAll(){var e;this.setSelection({ids:Object.keys(this.idToIndex),anchor:this.firstNode,mostRecent:this.lastNode}),this.dispatch(Z(null===(e=this.lastNode)||void 0===e?void 0:e.id)),this.focusedNode&&ta(this.props.onFocus,this.focusedNode),ta(this.props.onSelect,this.selectedNodes)}setSelection(e){var t;let n=new Set(null===(t=e.ids)||void 0===t?void 0:t.map(tl)),i=td(e.anchor),r=td(e.mostRecent);this.dispatch(ee.set({ids:n,anchor:i,mostRecent:r})),ta(this.props.onSelect,this.selectedNodes)}get cursorParentId(){let{cursor:e}=this.state.dnd;if("highlight"===e.type)return e.id;return null}get cursorOverFolder(){return"highlight"===this.state.dnd.cursor.type}get dragNodes(){return this.state.dnd.dragIds.map(e=>this.get(e)).filter(e=>!!e)}get dragNode(){return this.get(this.state.nodes.drag.id)}get dragDestinationParent(){return this.get(this.state.nodes.drag.destinationParentId)}get dragDestinationIndex(){return this.state.nodes.drag.destinationIndex}canDrop(){var e;if(this.isFiltered)return!1;let t=null!==(e=this.get(this.state.dnd.parentId))&&void 0!==e?e:this.root,n=this.dragNodes,i=this.props.disableDrop;for(let e of n)if(!e||!t||e.isInternal&&_(t,e))return!1;if("function"==typeof i)return!i({parentNode:t,dragNodes:this.dragNodes,index:this.state.dnd.index||0});if("string"==typeof i)return!t.data[i];if("boolean"==typeof i)return!i;else return!0}hideCursor(){this.dispatch(et.cursor({type:"none"}))}showCursor(e){this.dispatch(et.cursor(e))}open(e){let t=td(e);if(!!t)!this.isOpen(t)&&(this.dispatch(X.open(t,this.isFiltered)),ta(this.props.onToggle,t))}close(e){let t=td(e);if(!!t)this.isOpen(t)&&(this.dispatch(X.close(t,this.isFiltered)),ta(this.props.onToggle,t))}toggle(e){let t=td(e);if(t)return this.isOpen(t)?this.close(t):this.open(t)}openParents(e){let t=td(e);if(!t)return;let n=C(this.root,t),i=null==n?void 0:n.parent;for(;i;)this.open(i.id),i=i.parent}openSiblings(e){let t=e.parent;if(t){if(t.children){let n=e.isOpen;for(let e of t.children)e.isInternal&&(n?this.close(e.id):this.open(e.id));this.scrollTo(this.focusedNode)}}else this.toggle(e.id)}openAll(){A(this.root,e=>{e.isInternal&&e.open()})}closeAll(){A(this.root,e=>{e.isInternal&&e.close()})}scrollTo(e,t="smart"){if(!e)return;let n=tl(e);return this.openParents(n),L(()=>n in this.idToIndex).then(()=>{var e;let i=this.idToIndex[n];void 0!==i&&(null===(e=this.list.current)||void 0===e||e.scrollToItem(i,t))}).catch(()=>{})}get isEditing(){return null!==this.state.nodes.edit.id}get isFiltered(){var e;return!!(null===(e=this.props.searchTerm)||void 0===e?void 0:e.trim())}get hasFocus(){return this.state.nodes.focus.treeFocused}get hasNoSelection(){return 0===this.state.nodes.selection.ids.size}get hasOneSelection(){return 1===this.state.nodes.selection.ids.size}get hasMultipleSelections(){return this.state.nodes.selection.ids.size>1}isSelected(e){return!!e&&this.state.nodes.selection.ids.has(e)}isOpen(e){var t,n,i;if(!e)return!1;if(e===K)return!0;let r=null===(t=this.props.openByDefault)||void 0===t||t;return this.isFiltered?null===(n=this.state.nodes.open.filtered[e])||void 0===n||n:null!==(i=this.state.nodes.open.unfiltered[e])&&void 0!==i?i:r}isEditable(e){return!D(e,this.props.disableEdit||(()=>!1))}isDraggable(e){return!D(e,this.props.disableDrag||(()=>!1))}isDragging(e){let t=td(e);return!!t&&this.state.nodes.drag.id===t}isFocused(e){return this.hasFocus&&this.state.nodes.focus.id===e}isMatch(e){return this.matchFn(e)}willReceiveDrop(e){let t=td(e);if(!t)return!1;let{destinationParentId:n,destinationIndex:i}=this.state.nodes.drag;return t===n&&null===i}onFocus(){let e=this.focusedNode||this.firstNode;e&&this.dispatch(Z(e.id))}onBlur(){this.dispatch({type:"TREE_BLUR"})}onItemsRendered(e){this.visibleStartIndex=e.visibleStartIndex,this.visibleStopIndex=e.visibleStopIndex}get renderContainer(){return this.props.renderContainer||tn}get renderRow(){return this.props.renderRow||U}get renderNode(){return this.props.children||V}get renderDragPreview(){return this.props.renderDragPreview||es}get renderCursor(){return this.props.renderCursor||H}}function th(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var tu="function"==typeof Symbol&&Symbol.observable||"@@observable",tp=()=>Math.random().toString(36).substring(7).split("").join("."),tf={INIT:`@@redux/INIT${tp()}`,REPLACE:`@@redux/REPLACE${tp()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${tp()}`};function tm(e){let t;let n=Object.keys(e),i={};for(let t=0;t<n.length;t++){let r=n[t];"function"==typeof e[r]&&(i[r]=e[r])}let r=Object.keys(i);try{!function(e){Object.keys(e).forEach(t=>{let n=e[t];if(void 0===n(void 0,{type:tf.INIT}))throw Error(th(12));if(void 0===n(void 0,{type:tf.PROBE_UNKNOWN_ACTION()}))throw Error(th(13))})}(i)}catch(e){t=e}return function(e={},n){if(t)throw t;let s=!1,o={};for(let t=0;t<r.length;t++){let a=r[t],l=i[a],d=e[a],c=l(d,n);if(void 0===c)throw n&&n.type,Error(th(14));o[a]=c,s=s||c!==d}return(s=s||r.length!==Object.keys(e).length)?o:e}}let tg=tm({nodes:tm({focus:function(e={id:null,treeFocused:!1},t){return"FOCUS"===t.type?Object.assign(Object.assign({},e),{id:t.id,treeFocused:!0}):"TREE_BLUR"===t.type?Object.assign(Object.assign({},e),{treeFocused:!1}):e},edit:function(e={id:null},t){return"EDIT"===t.type?Object.assign(Object.assign({},e),{id:t.id}):e},open:function(e={filtered:{},unfiltered:{}},t){return t.type.startsWith("VISIBILITY")?t.filtered?Object.assign(Object.assign({},e),{filtered:J(e.filtered,t)}):Object.assign(Object.assign({},e),{unfiltered:J(e.unfiltered,t)}):e},selection:function(e=Q().nodes.selection,t){let n=e.ids;switch(t.type){case"SELECTION_CLEAR":return Object.assign(Object.assign({},e),{ids:new Set});case"SELECTION_ONLY":return Object.assign(Object.assign({},e),{ids:new Set([t.id])});case"SELECTION_ADD":if(0===t.ids.length)return e;return t.ids.forEach(e=>n.add(e)),Object.assign(Object.assign({},e),{ids:new Set(n)});case"SELECTION_REMOVE":if(0===t.ids.length)return e;return t.ids.forEach(e=>n.delete(e)),Object.assign(Object.assign({},e),{ids:new Set(n)});case"SELECTION_SET":return Object.assign(Object.assign({},e),{ids:t.ids,mostRecent:t.mostRecent,anchor:t.anchor});case"SELECTION_MOST_RECENT":return Object.assign(Object.assign({},e),{mostRecent:t.id});case"SELECTION_ANCHOR":return Object.assign(Object.assign({},e),{anchor:t.id});default:return e}},drag:function(e=Q().nodes.drag,t){switch(t.type){case"DND_DRAG_START":return Object.assign(Object.assign({},e),{id:t.id,selectedIds:t.dragIds});case"DND_DRAG_END":return Object.assign(Object.assign({},e),{id:null,destinationParentId:null,destinationIndex:null,selectedIds:[]});case"DND_HOVERING":if(t.parentId!==e.destinationParentId||t.index!=e.destinationIndex)return Object.assign(Object.assign({},e),{destinationParentId:t.parentId,destinationIndex:t.index});return e;default:return e}}}),dnd:function(e=Q().dnd,t){switch(t.type){case"DND_CURSOR":return Object.assign(Object.assign({},e),{cursor:t.cursor});case"DND_DRAG_START":return Object.assign(Object.assign({},e),{dragId:t.id,dragIds:t.dragIds});case"DND_DRAG_END":return Q().dnd;case"DND_HOVERING":return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}});function tv(e){var t=null;return function(){return null==t&&(t=e()),t}}function tb(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tx=function(){var e,t,n;function i(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),ty(this,"entered",[]),ty(this,"isNodeInDocument",void 0),this.isNodeInDocument=e}return e=i,t=[{key:"enter",value:function(e){var t,n,i,r,s,o=this,a=this.entered.length;return this.entered=(t=this.entered.filter(function(t){return o.isNodeInDocument(t)&&(!t.contains||t.contains(e))}),n=[e],i=new Set,r=function(e){return i.add(e)},t.forEach(r),n.forEach(r),s=[],i.forEach(function(e){return s.push(e)}),s),0===a&&this.entered.length>0}},{key:"leave",value:function(e){var t,n,i=this.entered.length;return this.entered=(t=this.entered.filter(this.isNodeInDocument),n=e,t.filter(function(e){return e!==n})),i>0&&0===this.entered.length}},{key:"reset",value:function(){this.entered=[]}}],tb(e.prototype,t),i}(),tw=tv(function(){return/firefox/i.test(navigator.userAgent)}),t_=tv(function(){return!!window.safari});function tS(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function tE(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tC=function(){var e,t,n;function i(e,t){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),tE(this,"xs",void 0),tE(this,"ys",void 0),tE(this,"c1s",void 0),tE(this,"c2s",void 0),tE(this,"c3s",void 0);for(var n,r,s,o=e.length,a=[],l=0;l<o;l++)a.push(l);a.sort(function(t,n){return e[t]<e[n]?-1:1});for(var d=[],c=[],h=[],u=0;u<o-1;u++)n=e[u+1]-e[u],r=t[u+1]-t[u],c.push(n),d.push(r),h.push(r/n);for(var p=[h[0]],f=0;f<c.length-1;f++){var m=h[f],g=h[f+1];if(m*g<=0)p.push(0);else{n=c[f];var v=c[f+1],b=n+v;p.push(3*b/((b+v)/m+(b+n)/g))}}p.push(h[h.length-1]);for(var y=[],x=[],w=0;w<p.length-1;w++){s=h[w];var _=p[w],S=1/c[w],E=_+p[w+1]-s-s;y.push((s-_-E)*S),x.push(E*S*S)}this.xs=e,this.ys=t,this.c1s=p,this.c2s=y,this.c3s=x}return e=i,t=[{key:"interpolate",value:function(e){var t,n=this.xs,i=this.ys,r=this.c1s,s=this.c2s,o=this.c3s,a=n.length-1;if(e===n[a])return i[a];for(var l=0,d=o.length-1;l<=d;){var c=n[t=Math.floor(.5*(l+d))];if(c<e)l=t+1;else{if(!(c>e))return i[t];d=t-1}}var h=e-n[a=Math.max(0,d)],u=h*h;return i[a]+r[a]*h+s[a]*u+o[a]*h*u}}],tS(e.prototype,t),i}();function tA(e){var t=1===e.nodeType?e:e.parentElement;if(!t)return null;var n=t.getBoundingClientRect(),i=n.top;return{x:n.left,y:i}}function tk(e){return{x:e.clientX,y:e.clientY}}var tT="__NATIVE_FILE__",tM="__NATIVE_URL__",tD="__NATIVE_TEXT__",tO="__NATIVE_HTML__";function tI(e,t,n){var i=t.reduce(function(t,n){return t||e.getData(n)},"");return null!=i?i:n}function tN(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tR=(tN(s={},tT,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items},dataTransfer:function(e){return e}},matchesTypes:["Files"]}),tN(s,tO,{exposeProperties:{html:function(e,t){return tI(e,t,"")},dataTransfer:function(e){return e}},matchesTypes:["Html","text/html"]}),tN(s,tM,{exposeProperties:{urls:function(e,t){return tI(e,t,"").split("\n")},dataTransfer:function(e){return e}},matchesTypes:["Url","text/uri-list"]}),tN(s,tD,{exposeProperties:{text:function(e,t){return tI(e,t,"")},dataTransfer:function(e){return e}},matchesTypes:["Text","text/plain"]}),s);function tL(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function tP(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tj=function(){var e,t,n;function i(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),tP(this,"item",void 0),tP(this,"config",void 0),this.config=e,this.item={},this.initializeExposedProperties()}return e=i,t=[{key:"initializeExposedProperties",value:function(){var e=this;Object.keys(this.config.exposeProperties).forEach(function(t){Object.defineProperty(e.item,t,{configurable:!0,enumerable:!0,get:function(){return console.warn("Browser doesn't allow reading \"".concat(t,'" until the drop event.')),null}})})}},{key:"loadDataTransfer",value:function(e){var t=this;if(e){var n={};Object.keys(this.config.exposeProperties).forEach(function(i){n[i]={value:t.config.exposeProperties[i](e,t.config.matchesTypes),configurable:!0,enumerable:!0}}),Object.defineProperties(this.item,n)}}},{key:"canDrag",value:function(){return!0}},{key:"beginDrag",value:function(){return this.item}},{key:"isDragging",value:function(e,t){return t===e.getSourceId()}},{key:"endDrag",value:function(){}}],tL(e.prototype,t),i}();function tF(e){if(!e)return null;var t=Array.prototype.slice.call(e.types||[]);return Object.keys(tR).filter(function(e){return tR[e].matchesTypes.some(function(e){return t.indexOf(e)>-1})})[0]||null}function tB(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function tz(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tH=function(){var e,t,n;function i(e,t){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),tz(this,"ownerDocument",null),tz(this,"globalContext",void 0),tz(this,"optionsArgs",void 0),this.globalContext=e,this.optionsArgs=t}return e=i,t=[{key:"window",get:function(){return this.globalContext?this.globalContext:"undefined"!=typeof window?window:void 0}},{key:"document",get:function(){var e;return null!==(e=this.globalContext)&&void 0!==e&&e.document?this.globalContext.document:this.window?this.window.document:void 0}},{key:"rootElement",get:function(){var e;return(null===(e=this.optionsArgs)||void 0===e?void 0:e.rootElement)||this.window}}],tB(e.prototype,t),i}();function tU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function tV(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tU(Object(n),!0).forEach(function(t){tW(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function t$(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function tW(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tG=function(){var e,t,n;function i(e,t,n){var r=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),tW(this,"options",void 0),tW(this,"actions",void 0),tW(this,"monitor",void 0),tW(this,"registry",void 0),tW(this,"enterLeaveCounter",void 0),tW(this,"sourcePreviewNodes",new Map),tW(this,"sourcePreviewNodeOptions",new Map),tW(this,"sourceNodes",new Map),tW(this,"sourceNodeOptions",new Map),tW(this,"dragStartSourceIds",null),tW(this,"dropTargetIds",[]),tW(this,"dragEnterTargetIds",[]),tW(this,"currentNativeSource",null),tW(this,"currentNativeHandle",null),tW(this,"currentDragSourceNode",null),tW(this,"altKeyPressed",!1),tW(this,"mouseMoveTimeoutTimer",null),tW(this,"asyncEndDragFrameId",null),tW(this,"dragOverTargetIds",null),tW(this,"lastClientOffset",null),tW(this,"hoverRafId",null),tW(this,"getSourceClientOffset",function(e){var t=r.sourceNodes.get(e);return t&&tA(t)||null}),tW(this,"endDragNativeItem",function(){if(!!r.isDraggingNativeItem())r.actions.endDrag(),r.currentNativeHandle&&r.registry.removeSource(r.currentNativeHandle),r.currentNativeHandle=null,r.currentNativeSource=null}),tW(this,"isNodeInDocument",function(e){return!!(e&&r.document&&r.document.body&&r.document.body.contains(e))}),tW(this,"endDragIfSourceWasRemovedFromDOM",function(){var e=r.currentDragSourceNode;if(!(null==e||r.isNodeInDocument(e)))r.clearCurrentDragSourceNode()&&r.monitor.isDragging()&&r.actions.endDrag()}),tW(this,"handleTopDragStartCapture",function(){r.clearCurrentDragSourceNode(),r.dragStartSourceIds=[]}),tW(this,"handleTopDragStart",function(e){if(!e.defaultPrevented){var t=r.dragStartSourceIds;r.dragStartSourceIds=null;var n=tk(e);r.monitor.isDragging()&&r.actions.endDrag(),r.actions.beginDrag(t||[],{publishSource:!1,getSourceClientOffset:r.getSourceClientOffset,clientOffset:n});var i=e.dataTransfer,s=tF(i);if(r.monitor.isDragging()){if(i&&"function"==typeof i.setDragImage){var o=r.monitor.getSourceId(),a=r.sourceNodes.get(o),l=r.sourcePreviewNodes.get(o)||a;if(l){var d,c,h,u,p,f,m,g,v,b,y,x,w,_,S,E,C,A,k,T,M,D,O,I,N,R,L=r.getCurrentSourcePreviewNodeOptions(),P=L.anchorX,j=L.anchorY,F=L.offsetX,B=L.offsetY;var z=(d=a,c=l,h=n,u={anchorX:P,anchorY:j},p={offsetX:F,offsetY:B},v=tA((g="IMG"===(f=c).nodeName&&(tw()||!(null!==(m=document.documentElement)&&void 0!==m&&m.contains(f))))?d:c),b={x:h.x-v.x,y:h.y-v.y},y=d.offsetWidth,x=d.offsetHeight,w=u.anchorX,_=u.anchorY,D=(M=(S=g,E=c,C=y,A=x,k=S?E.width:C,T=S?E.height:A,t_()&&S&&(T/=window.devicePixelRatio,k/=window.devicePixelRatio),{dragPreviewWidth:k,dragPreviewHeight:T})).dragPreviewWidth,O=M.dragPreviewHeight,I=p.offsetX,N=p.offsetY,{x:0===I||I?I:new tC([0,.5,1],[b.x,b.x/y*D,b.x+D-y]).interpolate(w),y:0===N||N?N:(R=new tC([0,.5,1],[b.y,b.y/x*O,b.y+O-x]).interpolate(_),t_()&&g&&(R+=(window.devicePixelRatio-1)*O),R)});i.setDragImage(l,z.x,z.y)}}try{null==i||i.setData("application/json",{})}catch(e){}r.setCurrentDragSourceNode(e.target),r.getCurrentSourcePreviewNodeOptions().captureDraggingState?r.actions.publishDragSource():setTimeout(function(){return r.actions.publishDragSource()},0)}else if(s)r.beginDragNativeItem(s);else{if(i&&!i.types&&(e.target&&!e.target.hasAttribute||!e.target.hasAttribute("draggable")))return;e.preventDefault()}}}),tW(this,"handleTopDragEndCapture",function(){r.clearCurrentDragSourceNode()&&r.monitor.isDragging()&&r.actions.endDrag()}),tW(this,"handleTopDragEnterCapture",function(e){if(r.dragEnterTargetIds=[],!(!r.enterLeaveCounter.enter(e.target)||r.monitor.isDragging())){var t=e.dataTransfer,n=tF(t);n&&r.beginDragNativeItem(n,t)}}),tW(this,"handleTopDragEnter",function(e){var t=r.dragEnterTargetIds;if(r.dragEnterTargetIds=[],!!r.monitor.isDragging())r.altKeyPressed=e.altKey,t.length>0&&r.actions.hover(t,{clientOffset:tk(e)}),t.some(function(e){return r.monitor.canDropOnTarget(e)})&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=r.getCurrentDropEffect()))}),tW(this,"handleTopDragOverCapture",function(){r.dragOverTargetIds=[]}),tW(this,"handleTopDragOver",function(e){var t=r.dragOverTargetIds;if(r.dragOverTargetIds=[],!r.monitor.isDragging()){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none");return}r.altKeyPressed=e.altKey,r.lastClientOffset=tk(e),null===r.hoverRafId&&"undefined"!=typeof requestAnimationFrame&&(r.hoverRafId=requestAnimationFrame(function(){r.monitor.isDragging()&&r.actions.hover(t||[],{clientOffset:r.lastClientOffset}),r.hoverRafId=null})),(t||[]).some(function(e){return r.monitor.canDropOnTarget(e)})?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=r.getCurrentDropEffect())):r.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))}),tW(this,"handleTopDragLeaveCapture",function(e){if(r.isDraggingNativeItem()&&e.preventDefault(),!!r.enterLeaveCounter.leave(e.target))r.isDraggingNativeItem()&&setTimeout(function(){return r.endDragNativeItem()},0)}),tW(this,"handleTopDropCapture",function(e){if(r.dropTargetIds=[],r.isDraggingNativeItem()){var t;e.preventDefault(),null===(t=r.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer)}else tF(e.dataTransfer)&&e.preventDefault();r.enterLeaveCounter.reset()}),tW(this,"handleTopDrop",function(e){var t=r.dropTargetIds;r.dropTargetIds=[],r.actions.hover(t,{clientOffset:tk(e)}),r.actions.drop({dropEffect:r.getCurrentDropEffect()}),r.isDraggingNativeItem()?r.endDragNativeItem():r.monitor.isDragging()&&r.actions.endDrag()}),tW(this,"handleSelectStart",function(e){var t=e.target;if("function"==typeof t.dragDrop&&"INPUT"!==t.tagName&&"SELECT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable)e.preventDefault(),t.dragDrop()}),this.options=new tH(t,n),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.registry=e.getRegistry(),this.enterLeaveCounter=new tx(this.isNodeInDocument)}return e=i,t=[{key:"profile",value:function(){var e,t;return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:(null===(e=this.dragStartSourceIds)||void 0===e?void 0:e.length)||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:(null===(t=this.dragOverTargetIds)||void 0===t?void 0:t.length)||0}}},{key:"window",get:function(){return this.options.window}},{key:"document",get:function(){return this.options.document}},{key:"rootElement",get:function(){return this.options.rootElement}},{key:"setup",value:function(){var e=this.rootElement;if(void 0!==e){if(e.__isReactDndBackendSetUp)throw Error("Cannot have two HTML5 backends at the same time.");e.__isReactDndBackendSetUp=!0,this.addEventListeners(e)}}},{key:"teardown",value:function(){var e,t=this.rootElement;if(void 0!==t)t.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId&&(null===(e=this.window)||void 0===e||e.cancelAnimationFrame(this.asyncEndDragFrameId))}},{key:"connectDragPreview",value:function(e,t,n){var i=this;return this.sourcePreviewNodeOptions.set(e,n),this.sourcePreviewNodes.set(e,t),function(){i.sourcePreviewNodes.delete(e),i.sourcePreviewNodeOptions.delete(e)}}},{key:"connectDragSource",value:function(e,t,n){var i=this;this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,n);var r=function(t){return i.handleDragStart(t,e)},s=function(e){return i.handleSelectStart(e)};return t.setAttribute("draggable","true"),t.addEventListener("dragstart",r),t.addEventListener("selectstart",s),function(){i.sourceNodes.delete(e),i.sourceNodeOptions.delete(e),t.removeEventListener("dragstart",r),t.removeEventListener("selectstart",s),t.setAttribute("draggable","false")}}},{key:"connectDropTarget",value:function(e,t){var n=this,i=function(t){return n.handleDragEnter(t,e)},r=function(t){return n.handleDragOver(t,e)},s=function(t){return n.handleDrop(t,e)};return t.addEventListener("dragenter",i),t.addEventListener("dragover",r),t.addEventListener("drop",s),function(){t.removeEventListener("dragenter",i),t.removeEventListener("dragover",r),t.removeEventListener("drop",s)}}},{key:"addEventListeners",value:function(e){if(!!e.addEventListener)e.addEventListener("dragstart",this.handleTopDragStart),e.addEventListener("dragstart",this.handleTopDragStartCapture,!0),e.addEventListener("dragend",this.handleTopDragEndCapture,!0),e.addEventListener("dragenter",this.handleTopDragEnter),e.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.addEventListener("dragover",this.handleTopDragOver),e.addEventListener("dragover",this.handleTopDragOverCapture,!0),e.addEventListener("drop",this.handleTopDrop),e.addEventListener("drop",this.handleTopDropCapture,!0)}},{key:"removeEventListeners",value:function(e){if(!!e.removeEventListener)e.removeEventListener("dragstart",this.handleTopDragStart),e.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),e.removeEventListener("dragend",this.handleTopDragEndCapture,!0),e.removeEventListener("dragenter",this.handleTopDragEnter),e.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.removeEventListener("dragover",this.handleTopDragOver),e.removeEventListener("dragover",this.handleTopDragOverCapture,!0),e.removeEventListener("drop",this.handleTopDrop),e.removeEventListener("drop",this.handleTopDropCapture,!0)}},{key:"getCurrentSourceNodeOptions",value:function(){var e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return tV({dropEffect:this.altKeyPressed?"copy":"move"},t||{})}},{key:"getCurrentDropEffect",value:function(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}},{key:"getCurrentSourcePreviewNodeOptions",value:function(){var e=this.monitor.getSourceId();return tV({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}},{key:"isDraggingNativeItem",value:function(){var e=this.monitor.getItemType();return Object.keys(l).some(function(t){return l[t]===e})}},{key:"beginDragNativeItem",value:function(e,t){var n,i,r;this.clearCurrentDragSourceNode(),this.currentNativeSource=(n=e,i=t,(r=new tj(tR[n])).loadDataTransfer(i),r),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:"setCurrentDragSourceNode",value:function(e){var t=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e;this.mouseMoveTimeoutTimer=setTimeout(function(){var e;return null===(e=t.rootElement)||void 0===e?void 0:e.addEventListener("mousemove",t.endDragIfSourceWasRemovedFromDOM,!0)},1e3)}},{key:"clearCurrentDragSourceNode",value:function(){if(this.currentDragSourceNode){if(this.currentDragSourceNode=null,this.rootElement){var e;null===(e=this.window)||void 0===e||e.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)}return this.mouseMoveTimeoutTimer=null,!0}return!1}},{key:"handleDragStart",value:function(e,t){if(!e.defaultPrevented)!this.dragStartSourceIds&&(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(t)}},{key:"handleDragEnter",value:function(e,t){this.dragEnterTargetIds.unshift(t)}},{key:"handleDragOver",value:function(e,t){null===this.dragOverTargetIds&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}},{key:"handleDrop",value:function(e,t){this.dropTargetIds.unshift(t)}}],t$(e.prototype,t),i}(),tZ=function(e,t,n){return new tG(e,t,n)},tq="dnd-core/INIT_COORDS",tK="dnd-core/BEGIN_DRAG",tY="dnd-core/PUBLISH_DRAG_SOURCE",tX="dnd-core/HOVER",tJ="dnd-core/DROP",tQ="dnd-core/END_DRAG";function t0(e,t){return{type:tq,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}function t1(e){return(t1="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t2(e){return"object"===t1(e)}var t5={type:tq,payload:{clientOffset:null,sourceClientOffset:null}};function t3(e,t){return null===t?null===e:Array.isArray(e)?e.some(function(e){return e===t}):e===t}function t4(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function t6(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?t4(Object(n),!0).forEach(function(t){(function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t4(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function t8(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function t7(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var t9=function(){var e,t,n;function i(e,t){var n=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),t7(this,"store",void 0),t7(this,"monitor",void 0),t7(this,"backend",void 0),t7(this,"isSetUp",!1),t7(this,"handleRefCountChange",function(){var e=n.store.getState().refCount>0;n.backend&&(e&&!n.isSetUp?(n.backend.setup(),n.isSetUp=!0):!e&&n.isSetUp&&(n.backend.teardown(),n.isSetUp=!1))}),this.store=e,this.monitor=t,e.subscribe(this.handleRefCountChange)}return e=i,t=[{key:"receiveBackend",value:function(e){this.backend=e}},{key:"getMonitor",value:function(){return this.monitor}},{key:"getBackend",value:function(){return this.backend}},{key:"getRegistry",value:function(){return this.monitor.registry}},{key:"getActions",value:function(){var e,t,n,i,r,s,o=this,a=this.store.dispatch;var l=(e=this,{beginDrag:(t=e,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{publishSource:!0},i=n.publishSource,r=n.clientOffset,s=n.getSourceClientOffset,o=t.getMonitor(),a=t.getRegistry();t.dispatch(t0(r)),function(e,t,n){(0,e_.k)(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(e){(0,e_.k)(n.getSource(e),"Expected sourceIds to be registered.")})}(e,o,a);var l=function(e,t){for(var n=null,i=e.length-1;i>=0;i--)if(t.canDragSource(e[i])){n=e[i];break}return n}(e,o);if(null===l){t.dispatch(t5);return}var d=null;if(r){if(!s)throw Error("getSourceClientOffset must be defined");(function(e){(0,e_.k)("function"==typeof e,"When clientOffset is provided, getSourceClientOffset must be a function.")})(s),d=s(l)}t.dispatch(t0(r,d));var c=a.getSource(l).beginDrag(o,l);if(null!=c)return function(e){(0,e_.k)(t2(e),"Item must be an object.")}(c),a.pinSource(l),{type:tK,payload:{itemType:a.getSourceType(l),item:c,sourceId:l,clientOffset:r||null,sourceClientOffset:d||null,isSourcePublic:!!(void 0===i||i)}}}),publishDragSource:(n=e,function(){if(n.getMonitor().isDragging())return{type:tY}}),hover:(i=e,function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.clientOffset;(function(e){(0,e_.k)(Array.isArray(e),"Expected targetIds to be an array.")})(e);var r=e.slice(0),s=i.getMonitor(),o=i.getRegistry();return function(e,t,n){(0,e_.k)(t.isDragging(),"Cannot call hover while not dragging."),(0,e_.k)(!t.didDrop(),"Cannot call hover after drop.");for(var i=0;i<e.length;i++){var r=e[i];(0,e_.k)(e.lastIndexOf(r)===i,"Expected targetIds to be unique in the passed array.");var s=n.getTarget(r);(0,e_.k)(s,"Expected targetIds to be registered.")}}(r,s,o),function(e,t,n){for(var i=e.length-1;i>=0;i--){var r=e[i];!t3(t.getTargetType(r),n)&&e.splice(i,1)}}(r,o,s.getItemType()),function(e,t,n){e.forEach(function(e){n.getTarget(e).hover(t,e)})}(r,s,o),{type:tX,payload:{targetIds:r,clientOffset:n||null}}}),drop:(r=e,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.getMonitor(),n=r.getRegistry();(function(e){(0,e_.k)(e.isDragging(),"Cannot call drop while not dragging."),(0,e_.k)(!e.didDrop(),"Cannot call drop twice during one drag operation.")})(t),(function(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t})(t).forEach(function(i,s){var o=function(e,t,n,i){var r=n.getTarget(e),s=r?r.drop(i,e):void 0;return function(e){(0,e_.k)(void 0===e||t2(e),"Drop result must either be an object or undefined.")}(s),void 0===s&&(s=0===t?{}:i.getDropResult()),s}(i,s,n,t),a={type:tJ,payload:{dropResult:t6(t6({},e),o)}};r.dispatch(a)})}),endDrag:(s=e,function(){var e=s.getMonitor(),t=s.getRegistry();(function(e){(0,e_.k)(e.isDragging(),"Cannot call endDrag while not dragging.")})(e);var n=e.getSourceId();return null!=n&&(t.getSource(n,!0).endDrag(e,n),t.unpinSource()),{type:tQ}})});return Object.keys(l).reduce(function(e,t){var n,i=l[t];return e[t]=(n=i,function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];var r=n.apply(o,t);void 0!==r&&a(r)}),e},{})}},{key:"dispatch",value:function(e){this.store.dispatch(e)}}],t8(e.prototype,t),i}(),ne=n("275211"),nt=function(e,t){return e===t};function nn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function ni(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nn(Object(n),!0).forEach(function(t){(function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var nr={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null},ns="dnd-core/ADD_SOURCE",no="dnd-core/ADD_TARGET",na="dnd-core/REMOVE_SOURCE",nl="dnd-core/REMOVE_TARGET";function nd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function nc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nd(Object(n),!0).forEach(function(t){(function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nd(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var nh={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null},nu=[],np=[];nu.__IS_NONE__=!0,np.__IS_ALL__=!0;function nf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function nm(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nf(Object(n),!0).forEach(function(t){(function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nf(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ng(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];var e,t,n,i,r,s=arguments.length>1?arguments[1]:void 0;switch(s.type){case tX:break;case ns:case no:case nl:case na:return nu;default:return np}var o=s.payload,a=o.targetIds,l=void 0===a?[]:a,d=o.prevTargetIds,c=void 0===d?[]:d;var h=(e=l,t=c,n=new Map,i=function(e){n.set(e,n.has(e)?n.get(e)+1:1)},e.forEach(i),t.forEach(i),r=[],n.forEach(function(e,t){1===e&&r.push(t)}),r);if(!(h.length>0||!function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:nt;if(e.length!==t.length)return!1;for(var i=0;i<e.length;++i)if(!n(e[i],t[i]))return!1;return!0}(l,c)))return nu;var u=c[c.length-1],p=l[l.length-1];return u!==p&&(u&&h.push(u),p&&h.push(p)),h}(n.dirtyHandlerIds,{type:i.type,payload:nm(nm({},i.payload),{},{prevTargetIds:(e=n,t=[],"dragOperation.targetIds".split(".").reduce(function(e,n){return e&&e[n]?e[n]:t||null},e))})}),dragOffset:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nr,i=arguments.length>1?arguments[1]:void 0,r=i.payload;switch(i.type){case tq:case tK:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case tX:;if(e=n.clientOffset,t=r.clientOffset,!e&&!t||e&&t&&e.x===t.x&&e.y===t.y)return n;return ni(ni({},n),{},{clientOffset:r.clientOffset});case tQ:case tJ:return nr;default:return n}}(n.dragOffset,i),refCount:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case ns:case no:return e+1;case na:case nl:return e-1;default:return e}}(n.refCount,i),dragOperation:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nh,i=arguments.length>1?arguments[1]:void 0,r=i.payload;switch(i.type){case tK:return nc(nc({},n),{},{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case tY:return nc(nc({},n),{},{isSourcePublic:!0});case tX:return nc(nc({},n),{},{targetIds:r.targetIds});case nl:;if(-1===n.targetIds.indexOf(r.targetId))return n;return nc(nc({},n),{},{targetIds:(e=n.targetIds,t=r.targetId,e.filter(function(e){return e!==t}))});case tJ:return nc(nc({},n),{},{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case tQ:return nc(nc({},n),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return n}}(n.dragOperation,i),stateId:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e+1}(n.stateId)}}function nv(e,t){return{x:e.x-t.x,y:e.y-t.y}}function nb(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ny(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var nx=function(){var e,t,n;function i(e,t){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),ny(this,"store",void 0),ny(this,"registry",void 0),this.store=e,this.registry=t}return e=i,t=[{key:"subscribeToStateChange",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{handlerIds:void 0},i=n.handlerIds;(0,e_.k)("function"==typeof e,"listener must be a function."),(0,e_.k)(void 0===i||Array.isArray(i),"handlerIds, when specified, must be an array of strings.");var r=this.store.getState().stateId;return this.store.subscribe(function(){var n=t.store.getState(),s=n.stateId;try{!(s===r||s===r+1&&!function(e,t){var n,i;if(e===nu)return!1;if(e===np||void 0===t)return!0;return(n=t,i=e,n.filter(function(e){return i.indexOf(e)>-1})).length>0}(n.dirtyHandlerIds,i))&&e()}finally{r=s}})}},{key:"subscribeToOffsetChange",value:function(e){var t=this;(0,e_.k)("function"==typeof e,"listener must be a function.");var n=this.store.getState().dragOffset;return this.store.subscribe(function(){var i=t.store.getState().dragOffset;if(i!==n)n=i,e()})}},{key:"canDragSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e);return(0,e_.k)(t,"Expected to find a valid source. sourceId=".concat(e)),!this.isDragging()&&t.canDrag(this,e)}},{key:"canDropOnTarget",value:function(e){if(!e)return!1;var t=this.registry.getTarget(e);return(0,e_.k)(t,"Expected to find a valid target. targetId=".concat(e)),!(!this.isDragging()||this.didDrop())&&t3(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e)}},{key:"isDragging",value:function(){return!!this.getItemType()}},{key:"isDraggingSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e,!0);return(0,e_.k)(t,"Expected to find a valid source. sourceId=".concat(e)),!!(this.isDragging()&&this.isSourcePublic())&&this.registry.getSourceType(e)===this.getItemType()&&t.isDragging(this,e)}},{key:"isOverTarget",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shallow:!1};if(!e)return!1;var n=t.shallow;if(!this.isDragging())return!1;var i=this.registry.getTargetType(e),r=this.getItemType();if(r&&!t3(i,r))return!1;var s=this.getTargetIds();if(!s.length)return!1;var o=s.indexOf(e);return n?o===s.length-1:o>-1}},{key:"getItemType",value:function(){return this.store.getState().dragOperation.itemType}},{key:"getItem",value:function(){return this.store.getState().dragOperation.item}},{key:"getSourceId",value:function(){return this.store.getState().dragOperation.sourceId}},{key:"getTargetIds",value:function(){return this.store.getState().dragOperation.targetIds}},{key:"getDropResult",value:function(){return this.store.getState().dragOperation.dropResult}},{key:"didDrop",value:function(){return this.store.getState().dragOperation.didDrop}},{key:"isSourcePublic",value:function(){return!!this.store.getState().dragOperation.isSourcePublic}},{key:"getInitialClientOffset",value:function(){return this.store.getState().dragOffset.initialClientOffset}},{key:"getInitialSourceClientOffset",value:function(){return this.store.getState().dragOffset.initialSourceClientOffset}},{key:"getClientOffset",value:function(){return this.store.getState().dragOffset.clientOffset}},{key:"getSourceClientOffset",value:function(){return function(e){var t,n,i=e.clientOffset,r=e.initialClientOffset,s=e.initialSourceClientOffset;if(!i||!r||!s)return null;return nv((t=i,n=s,{x:t.x+n.x,y:t.y+n.y}),r)}(this.store.getState().dragOffset)}},{key:"getDifferenceFromInitialOffset",value:function(){var e,t,n;return t=(e=this.store.getState().dragOffset).clientOffset,n=e.initialClientOffset,t&&n?nv(t,n):null}}],nb(e.prototype,t),i}(),nw=0;function n_(e){return(n_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}(i=o||(o={})).SOURCE="SOURCE",i.TARGET="TARGET";function nS(e,t){if(t&&Array.isArray(e)){e.forEach(function(e){return nS(e,!1)});return}(0,e_.k)("string"==typeof e||"symbol"===n_(e),t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}let nE="undefined"!=typeof global?global:self,nC=nE.MutationObserver||nE.WebKitMutationObserver;function nA(e){return function(){let t=setTimeout(i,0),n=setInterval(i,50);function i(){clearTimeout(t),clearInterval(n),e()}}}let nk="function"==typeof nC?function(e){let t=1,n=new nC(e),i=document.createTextNode("");return n.observe(i,{characterData:!0}),function(){t=-t,i.data=t}}:nA;class nT{call(){try{this.task&&this.task()}catch(e){this.onError(e)}finally{this.task=null,this.release(this)}}constructor(e,t){this.onError=e,this.release=t,this.task=null}}let nM=new class e{enqueueTask(e){let{queue:t,requestFlush:n}=this;!t.length&&(n(),this.flushing=!0),t[t.length]=e}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{let{queue:e}=this;for(;this.index<e.length;){let t=this.index;if(this.index++,e[t].call(),this.index>this.capacity){for(let t=0,n=e.length-this.index;t<n;t++)e[t]=e[t+this.index];e.length-=this.index,this.index=0}}e.length=0,this.index=0,this.flushing=!1},this.registerPendingError=e=>{this.pendingErrors.push(e),this.requestErrorThrow()},this.requestFlush=nk(this.flush),this.requestErrorThrow=nA(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}},nD=new class e{create(e){let t=this.freeTasks,n=t.length?t.pop():new nT(this.onError,e=>t[t.length]=e);return n.task=e,n}constructor(e){this.onError=e,this.freeTasks=[]}}(nM.registerPendingError);function nO(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function nI(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nN(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function nR(e){switch(e[0]){case"S":return o.SOURCE;case"T":return o.TARGET;default:(0,e_.k)(!1,"Cannot parse handler ID: ".concat(e))}}function nL(e,t){var n=e.entries(),i=!1;do{var r,s,o=n.next(),a=o.done;if((r=o.value,s=2,function(e){if(Array.isArray(e))return e}(r)||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var s=[],o=!0,a=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);o=!0);}catch(e){a=!0,i=e}finally{try{!o&&null!=r.return&&r.return()}finally{if(a)throw i}}return s}}(r,2)||function(e,t){if(e){if("string"==typeof e)return nN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nN(e,t)}}(r,s)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1]===t)return!0;i=!!a}while(!i);return!1}var nP=function(){var e,t,n;function i(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),nI(this,"types",new Map),nI(this,"dragSources",new Map),nI(this,"dropTargets",new Map),nI(this,"pinnedSourceId",null),nI(this,"pinnedSource",null),nI(this,"store",void 0),this.store=e}return e=i,t=[{key:"addSource",value:function(e,t){nS(e),n=t,(0,e_.k)("function"==typeof n.canDrag,"Expected canDrag to be a function."),(0,e_.k)("function"==typeof n.beginDrag,"Expected beginDrag to be a function."),(0,e_.k)("function"==typeof n.endDrag,"Expected endDrag to be a function.");var n,i=this.addHandler(o.SOURCE,e,t);return this.store.dispatch({type:ns,payload:{sourceId:i}}),i}},{key:"addTarget",value:function(e,t){nS(e,!0),n=t,(0,e_.k)("function"==typeof n.canDrop,"Expected canDrop to be a function."),(0,e_.k)("function"==typeof n.hover,"Expected hover to be a function."),(0,e_.k)("function"==typeof n.drop,"Expected beginDrag to be a function.");var n,i=this.addHandler(o.TARGET,e,t);return this.store.dispatch({type:no,payload:{targetId:i}}),i}},{key:"containsHandler",value:function(e){return nL(this.dragSources,e)||nL(this.dropTargets,e)}},{key:"getSource",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,e_.k)(this.isSourceId(e),"Expected a valid source ID."),t&&e===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(e)}},{key:"getTarget",value:function(e){return(0,e_.k)(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}},{key:"getSourceType",value:function(e){return(0,e_.k)(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}},{key:"getTargetType",value:function(e){return(0,e_.k)(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}},{key:"isSourceId",value:function(e){return nR(e)===o.SOURCE}},{key:"isTargetId",value:function(e){return nR(e)===o.TARGET}},{key:"removeSource",value:function(e){var t,n=this;(0,e_.k)(this.getSource(e),"Expected an existing source."),this.store.dispatch({type:na,payload:{sourceId:e}}),t=function(){n.dragSources.delete(e),n.types.delete(e)},nM.enqueueTask(nD.create(t))}},{key:"removeTarget",value:function(e){(0,e_.k)(this.getTarget(e),"Expected an existing target."),this.store.dispatch({type:nl,payload:{targetId:e}}),this.dropTargets.delete(e),this.types.delete(e)}},{key:"pinSource",value:function(e){var t=this.getSource(e);(0,e_.k)(t,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=t}},{key:"unpinSource",value:function(){(0,e_.k)(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}},{key:"addHandler",value:function(e,t,n){var i=function(e){var t=(nw++).toString();switch(e){case o.SOURCE:return"S".concat(t);case o.TARGET:return"T".concat(t);default:throw Error("Unknown Handler Role: ".concat(e))}}(e);return this.types.set(i,t),e===o.SOURCE?this.dragSources.set(i,n):e===o.TARGET&&this.dropTargets.set(i,n),i}}],nO(e.prototype,t),i}(),nj=["children"];function nF(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}var nB=0,nz=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__"),nH=(0,c.memo)(function(e){var t,n,i=e.children;var r=(n=2,function(e){if(Array.isArray(e))return e}(t=function(e){return"manager"in e?[{dragDropManager:e.manager},!1]:[function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nU(),n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return!t[nz]&&(t[nz]={dragDropManager:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=function(e){var t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__;return(0,ne.MT)(ng,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}(i),s=new nx(r,new nP(r)),o=new t9(r,s),a=e(o,t,n);return o.receiveBackend(a),o}(e,t,n,i)}),t[nz]}(e.backend,e.context,e.options,e.debugMode),!e.context]}(function(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},s=Object.keys(e);for(i=0;i<s.length;i++)n=s[i],!(t.indexOf(n)>=0)&&(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++){if(n=s[i],!(t.indexOf(n)>=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}}return r}(e,nj)))||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var s=[],o=!0,a=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);o=!0);}catch(e){a=!0,i=e}finally{try{!o&&null!=r.return&&r.return()}finally{if(a)throw i}}return s}}(t,2)||function(e,t){if(e){if("string"==typeof e)return nF(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nF(e,t)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=r[0],o=r[1];return(0,c.useEffect)(function(){if(o){var e=nU();return++nB,function(){0==--nB&&(e[nz]=null)}}},[]),(0,d.jsx)(eS.Provider,Object.assign({value:s},{children:i}),void 0)});function nU(){return void 0!==n.g?n.g:window}let nV=Q();function n$({treeProps:e,imperativeHandle:t,children:n}){let i=(0,c.useRef)(null),r=(0,c.useRef)(null),s=(0,c.useRef)(function e(t,n,i){if("function"!=typeof t)throw Error(th(2));if("function"==typeof n&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw Error(th(0));if("function"==typeof n&&void 0===i&&(i=n,n=void 0),void 0!==i){if("function"!=typeof i)throw Error(th(1));return i(e)(t,n)}let r=t,s=n,o=new Map,a=o,l=0,d=!1;function c(){a===o&&(a=new Map,o.forEach((e,t)=>{a.set(t,e)}))}function h(){if(d)throw Error(th(3));return s}function u(e){if("function"!=typeof e)throw Error(th(4));if(d)throw Error(th(5));let t=!0;c();let n=l++;return a.set(n,e),function(){if(!!t){if(d)throw Error(th(6));t=!1,c(),a.delete(n),o=null}}}function p(e){if(!function(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}(e))throw Error(th(7));if(void 0===e.type)throw Error(th(8));if("string"!=typeof e.type)throw Error(th(17));if(d)throw Error(th(9));try{d=!0,s=r(s,e)}finally{d=!1}return(o=a).forEach(e=>{e()}),e}return p({type:tf.INIT}),{dispatch:p,subscribe:u,getState:h,replaceReducer:function(e){if("function"!=typeof e)throw Error(th(10));r=e,p({type:tf.REPLACE})},[tu]:function(){return{subscribe(e){if("object"!=typeof e||null===e)throw Error(th(11));function t(){e.next&&e.next(h())}return t(),{unsubscribe:u(t)}},[tu](){return this}}}}}(tg,Q(e))),o=(0,h.useSyncExternalStore)(s.current.subscribe,s.current.getState,()=>nV),a=(0,c.useMemo)(()=>new tc(s.current,e,i,r),[]),l=(0,c.useRef)(0);return(0,c.useMemo)(()=>{l.current+=1,a.update(e)},[...Object.values(e),o.nodes.open]),(0,c.useImperativeHandle)(t,()=>a),(0,c.useEffect)(()=>{a.props.selection?a.select(a.props.selection,{focus:!1}):a.deselectAll()},[a.props.selection]),(0,c.useEffect)(()=>{!a.props.searchTerm&&s.current.dispatch(X.clear(!0))},[a.props.searchTerm]),(0,d.jsx)(u.Provider,{value:a,children:(0,d.jsx)(g.Provider,{value:l.current,children:(0,d.jsx)(f.Provider,{value:o.nodes,children:(0,d.jsx)(m.Provider,{value:o.dnd,children:(0,d.jsx)(nH,Object.assign({backend:tZ,options:{rootElement:a.props.dndRootElement||void 0}},e.dndManager&&{manager:e.dndManager},{children:n}))})})})})}function nW(e){return!function(){let e=p(),[,t]=e3(()=>({accept:"NODE",canDrop:(t,n)=>!!n.isOver({shallow:!0})&&e.canDrop(),hover:(t,n)=>{if(!n.isOver({shallow:!0}))return;let i=n.getClientOffset();if(!e.listEl.current||!i)return;let{cursor:r,drop:s}=e7({element:e.listEl.current,offset:i,indent:e.indent,node:null,prevNode:e.visibleNodes[e.visibleNodes.length-1],nextNode:null});s&&e.dispatch(et.hovering(s.parentId,s.index)),n.canDrop()?r&&e.showCursor(r):e.hideCursor()}}),[e]);t(e.listEl)}(),e.children}function nG(){let e=p().props.renderContainer||tn;return(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(e,{})})}function nZ(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function nq(){var e,t,n,i,r,s,o;let a=p();let{offset:l,mouse:h,item:u,isDragging:f}=(e=e=>({offset:e.getSourceClientOffset(),mouse:e.getClientOffset(),item:e.getItem(),isDragging:e.isDragging()}),s=(r=(i=2,function(e){if(Array.isArray(e))return e}(n=e$(t=eE().getMonitor(),e))||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var s=[],o=!0,a=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);o=!0);}catch(e){a=!0,i=e}finally{try{!o&&null!=r.return&&r.return()}finally{if(a)throw i}}return s}}(n,2)||function(e,t){if(e){if("string"==typeof e)return nZ(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nZ(e,t)}}(n,i)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))[0],o=r[1],(0,c.useEffect)(function(){return t.subscribeToOffsetChange(o)}),(0,c.useEffect)(function(){return t.subscribeToStateChange(o)}),s),m=a.props.renderDragPreview||es;return(0,d.jsx)(m,{offset:l,mouse:h,id:(null==u?void 0:u.id)||null,dragIds:(null==u?void 0:u.dragIds)||[],isDragging:f})}class nK{constructor(e){this.root=function(e){let t=new nX({id:"ROOT"},null);return t.children=e.map(e=>nY(e,t)),t}(e)}get data(){var e,t;return null!==(t=null===(e=this.root.children)||void 0===e?void 0:e.map(e=>e.data))&&void 0!==t?t:[]}create(e){let t=e.parentId?this.find(e.parentId):this.root;if(!t)return null;t.addChild(e.data,e.index)}move(e){let t=this.find(e.id),n=e.parentId?this.find(e.parentId):this.root;t&&n&&(n.addChild(t.data,e.index),t.drop())}update(e){let t=this.find(e.id);t&&t.update(e.changes)}drop(e){let t=this.find(e.id);t&&t.drop()}find(e,t=this.root){if(!t)return null;if(t.id===e)return t;if(t.children)for(let n of t.children){let t=this.find(e,n);if(t)return t}return null}}function nY(e,t){let n=new nX(e,t);return e.children&&(n.children=e.children.map(e=>nY(e,n))),n}class nX{constructor(e,t){this.data=e,this.parent=t,this.id=e.id}hasParent(){return!!this.parent}get childIndex(){return this.hasParent()?this.parent.children.indexOf(this):-1}addChild(e,t){var n,i;let r=nY(e,this);this.children=null!==(n=this.children)&&void 0!==n?n:[],this.children.splice(t,0,r),this.data.children=null!==(i=this.data.children)&&void 0!==i?i:[],this.data.children.splice(t,0,e)}removeChild(e){var t,n;null===(t=this.children)||void 0===t||t.splice(e,1),null===(n=this.data.children)||void 0===n||n.splice(e,1)}update(e){if(this.hasParent()){let t=this.childIndex;this.parent.addChild(Object.assign(Object.assign({},this.data),e),t),this.drop()}}drop(){this.hasParent()&&this.parent.removeChild(this.childIndex)}}let nJ=0,nQ=(0,c.forwardRef)(function(e,t){let n=function(e){if(e.initialData&&e.data)throw Error("React Arborist Tree => Provide either a data or initialData prop, but not both.");if(e.initialData&&(e.onCreate||e.onDelete||e.onMove||e.onRename))throw Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
|
|
|
Use the data prop if you want to provide your own handlers.`);if(!e.initialData)return e;{let[t,n]=function(e){let[t,n]=(0,c.useState)(e),i=(0,c.useMemo)(()=>new nK(t),[t]);return[t,{onMove:e=>{for(let t of e.dragIds)i.move({id:t,parentId:e.parentId,index:e.index});n(i.data)},onRename:({name:e,id:t})=>{i.update({id:t,changes:{name:e}}),n(i.data)},onCreate:({parentId:e,index:t,type:r})=>{let s={id:`simple-tree-id-${nJ++}`,name:""};return"internal"===r&&(s.children=[]),i.create({parentId:e,index:t,data:s}),n(i.data),s},onDelete:e=>{e.ids.forEach(e=>i.drop({id:e})),n(i.data)}}]}(e.initialData);return Object.assign(Object.assign(Object.assign({},e),n),{data:t})}}(e);return(0,d.jsxs)(n$,{treeProps:n,imperativeHandle:t,children:[(0,d.jsx)(nW,{children:(0,d.jsx)(nG,{})}),(0,d.jsx)(nq,{})]})})},275211:function(e,t,n){"use strict";n.d(t,{DE:function(){return c},MT:function(){return l},md:function(){return u},qC:function(){return h}});var i=n(894626);function r(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var s="function"==typeof Symbol&&Symbol.observable||"@@observable",o=function(){return Math.random().toString(36).substring(7).split("").join(".")},a={INIT:"@@redux/INIT"+o(),REPLACE:"@@redux/REPLACE"+o(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+o()}};function l(e,t,n){if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw Error(r(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw Error(r(1));return n(l)(e,t)}if("function"!=typeof e)throw Error(r(2));var i,o=e,d=t,c=[],h=c,u=!1;function p(){h===c&&(h=c.slice())}function f(){if(u)throw Error(r(3));return d}function m(e){if("function"!=typeof e)throw Error(r(4));if(u)throw Error(r(5));var t=!0;return p(),h.push(e),function(){if(!!t){if(u)throw Error(r(6));t=!1,p();var n=h.indexOf(e);h.splice(n,1),c=null}}}function g(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error(r(7));if(void 0===e.type)throw Error(r(8));if(u)throw Error(r(9));try{u=!0,d=o(d,e)}finally{u=!1}for(var t=c=h,n=0;n<t.length;n++)(0,t[n])();return e}return g({type:a.INIT}),(i={dispatch:g,subscribe:m,getState:f,replaceReducer:function(e){if("function"!=typeof e)throw Error(r(10));o=e,g({type:a.REPLACE})}})[s]=function(){var e;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw Error(r(11));function t(){e.next&&e.next(f())}return t(),{unsubscribe:m(t)}}})[s]=function(){return this},e},i}function d(e,t){return function(){return t(e.apply(this,arguments))}}function c(e,t){if("function"==typeof e)return d(e,t);if("object"!=typeof e||null===e)throw Error(r(16));var n={};for(var i in e){var s=e[i];"function"==typeof s&&(n[i]=d(s,t))}return n}function h(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}function u(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),s=function(){throw Error(r(15))},o={getState:n.getState,dispatch:function(){return s.apply(void 0,arguments)}},a=t.map(function(e){return e(o)});return s=h.apply(void 0,a)(n.dispatch),(0,i.Z)((0,i.Z)({},n),{},{dispatch:s})}}}},675210:function(e,t,n){"use strict";n.d(t,{Z:function(){return s}});var i=n(455069);function r(e,t,n){if(!e[t])return"contentBoxSize"===t?e.contentRect["inlineSize"===n?"width":"height"]:void 0;return e[t][0]?e[t][0][n]:e[t][n]}function s(e){void 0===e&&(e={});var t,n,s,o,a,l,d=e.onResize,c=(0,i.useRef)(void 0);c.current=d;var h=e.round||Math.round,u=(0,i.useRef)(),p=(0,i.useState)({width:void 0,height:void 0}),f=p[0],m=p[1],g=(0,i.useRef)(!1);(0,i.useEffect)(function(){return g.current=!1,function(){g.current=!0}},[]);var v=(0,i.useRef)({width:void 0,height:void 0});var b=(t=(0,i.useCallback)(function(t){return(!u.current||u.current.box!==e.box||u.current.round!==h)&&(u.current={box:e.box,round:h,instance:new ResizeObserver(function(t){var n=t[0],i="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",s=r(n,i,"inlineSize"),o=r(n,i,"blockSize"),a=s?h(s):void 0,l=o?h(o):void 0;if(v.current.width!==a||v.current.height!==l){var d={width:a,height:l};v.current.width=a,v.current.height=l,c.current?c.current(d):!g.current&&m(d)}})}),u.current.instance.observe(t,{box:e.box}),function(){u.current&&u.current.instance.unobserve(t)}},[e.box,h]),n=e.ref,s=(0,i.useRef)(null),(o=(0,i.useRef)(null)).current=n,a=(0,i.useRef)(null),(0,i.useEffect)(function(){l()}),l=(0,i.useCallback)(function(){var e=a.current,n=o.current,i=e||(n?n instanceof Element?n:n.current:null);if(!s.current||s.current.element!==i||s.current.subscriber!==t)s.current&&s.current.cleanup&&s.current.cleanup(),s.current={element:i,subscriber:t,cleanup:i?t(i):void 0}},[t]),(0,i.useEffect)(function(){return function(){s.current&&s.current.cleanup&&(s.current.cleanup(),s.current=null)}},[]),(0,i.useCallback)(function(e){a.current=e,l()},[l]));return(0,i.useMemo)(function(){return{ref:b,width:f.width,height:f.height}},[b,f.width,f.height])}},733216:function(e){"use strict";var t,n=function(){};e.exports=n},189284:function(e,t,n){"use strict";n.d(t,{V:function(){return o}});var i=n(455069),r=n(864114),s=n(839974),o=()=>{var e=(0,s.L)(),[,t]=(0,i.useState)(0);return(0,i.useEffect)(()=>{var e=()=>{t(Date.now())};return r.l.on("change",e),()=>{r.l.off("change",e)}},[]),[e]}},757208:function(e,t,n){"use strict";n.d(t,{OL:function(){return r}});var i,r=((i={})[i.PendingVectoring=0]="PendingVectoring",i[i.FinishVectoring=1]="FinishVectoring",i[i.Deactive=9]="Deactive",i[i.AuditFailed=1e3]="AuditFailed",i)},672958:function(e,t,n){"use strict";n.d(t,{n:function(){return r}});var i,r=((i={})[i.AllData=0]="AllData",i[i.OnlySchema=1]="OnlySchema",i[i.OnlyPreview=2]="OnlyPreview",i)},487377:function(e,t,n){"use strict";n.d(t,{a:function(){return s}});var i=n(455069),r=n(579367),s=e=>{var{isLive:t,extra:n,scene:s=r.ik}=e;(0,i.useEffect)(()=>{t&&(0,r.WQ)(n,s)},[t])}},579367:function(e,t,n){"use strict";n.d(t,{WQ:function(){return d},ik:function(){return l}});var i=n(808549),r=n(120454),s=n(297158),o="first-contentful-paint",a={name:"",reportScene:[]},l="init",d=(e,t)=>{var n=null!=t?t:l,d=performance.now(),u=performance.getEntriesByName("route_change"),p=u.at(-1);if(!((null==p?void 0:null===(g=p.detail)||void 0===g?void 0:null===(m=g.location)||void 0===m?void 0:m.pathname)&&p.detail.location.pathname===a.name&&a.reportScene.includes(n))){if("hidden"===document.visibilityState){s.E7.info({message:"page_hidden_on_tti_report",namespace:"performance"});return}if(a.name=null==p?void 0:null===(b=p.detail)||void 0===b?void 0:null===(v=b.location)||void 0===v?void 0:v.pathname,a.reportScene.push(n),u.length>1){h(d-(null!==(y=null==p?void 0:p.startTime)&&void 0!==y?y:0),e);return}var f=performance.getEntriesByName(o)[0];if(f)c(d>f.startTime?d:f.startTime,(0,r._)((0,i._)({},e),{fcpTime:"".concat(f.startTime)}));else if(window.PerformanceObserver){var m,g,v,b,y,x,w=new PerformanceObserver(t=>{var n=t.getEntriesByName(o)[0];n&&(c(n.startTime,(0,r._)((0,i._)({},e),{fcpTime:"".concat(n.startTime)})),w.disconnect())});try{w.observe({type:"paint",buffered:!0})}catch(e){if(null===(x=PerformanceObserver.supportedEntryTypes)||void 0===x?void 0:x.includes("paint"))try{w.observe({entryTypes:["paint"]})}catch(e){s.E7.info({message:e.message,namespace:"performance"})}s.E7.info({message:e.message,namespace:"performance"})}}}},c=(e,t)=>{var n;null===(n=(0,s.f5)())||void 0===n||n("sendCustomPerfMetric",{value:e,name:"coze_custom_tti",type:"perf",extra:(0,i._)({},t)}),s.kg.info({message:"coze_custom_tti",meta:{value:e,extra:t}})},h=(e,t)=>{var n;null===(n=(0,s.f5)())||void 0===n||n("sendCustomPerfMetric",{value:e,name:"coze_custom_tti_hot",type:"perf",extra:(0,i._)({},t)}),s.kg.info({message:"coze_custom_tti_hot",meta:{value:e,extra:t}})}},304194:function(e,t,n){"use strict";n.d(t,{j:()=>c});var i=n("825955"),r=n("808549"),s=n("120454"),o=n("61111"),a=n("297158"),l=n("921463");class d{constructor(){this._listeners=new Set,this._produce=e=>{var t=(0,o.Uy)(this._state,e);t!==this._state&&(this._state=t,this._dispatch())},this._dispatch=()=>{if(!!this._listeners.size)(0,l.unstable_batchedUpdates)(()=>{this._listeners.forEach(e=>e())})},this.subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)}),this.getSnapshot=()=>this._state,(0,o.MD)()}}new class e extends d{add(e){this._produce(t=>{t.add(e)})}delete(e){this._produce(t=>{t.delete(e)})}constructor(...e){super(...e),this._state=new Set}};class c extends d{get featureMap(){return this._state.featureMap}getFeature(e){var t=this.getFeatureKey(e),n=this.featureMap.get(t);if(!n){a.kg.error({error:Error("[Message Feature]: ".concat(this.name," get feature not exist ").concat(e))});return}return n}getFeatureKey(e){return"feature_".concat(this.name,"_").concat(e)}getName(){return this.name}_register(e,t){var{defaultFeature:n}=this,{type:i}=t,r=this.getFeatureKey(i);if(n&&i===n.type){a.kg.error({error:Error("[Message Feature]: ".concat(this.name," register type is default feature ").concat(i))});return}this._state.featureMap.get(r)&&a.kg.warning("[Message Feature]: ".concat(this.name," register feature already registered ").concat(i)),e.featureMap.set(r,(0,o.cA)(t))}register(e){return this._produce(t=>{this._register(t,e)}),()=>{this._produce(t=>{this._deregister(t,e.type)})}}registerSome(e){return this._produce(t=>{e.map(e=>this._register(t,e))}),()=>{this._produce(t=>{e.forEach(e=>{this._deregister(t,e.type)})})}}_deregister(e,t){var{defaultFeature:n}=this,i=this.getFeatureKey(t);if(n&&t===n.type){a.kg.error({error:Error("[Message Feature]: ".concat(this.name," deregister type is default feature ").concat(t))});return}if(!this._state.featureMap.get(i)){a.kg.error({error:Error("[Message Feature]: ".concat(this.name," deregister invalid feature ").concat(t))});return}e.featureMap.delete(i)}deregister(e){this._produce(t=>{this._deregister(t,e)})}deregisterSome(e){this._produce(t=>{e.forEach(e=>{this._deregister(t,e)})})}deregisterAll(){this._produce(e=>{e.featureMap=new Map})}load(e){var t=this;return(0,i._)(function*(){var n=t.getFeature(e);if(!n){a.kg.error({error:Error("[Message Feature]: ".concat(t.name," load unknown feature ").concat(e))});return}if(!n.loader){a.kg.error({error:Error("[Message Feature]: ".concat(t.name," load feature loader unset ").concat(e))});return}var i=yield n.loader();t._produce(n=>{var r=n.featureMap.get(t.getFeatureKey(e));r&&(r.module=(0,o.cA)(i.default))})})()}isLoaded(e){var t=this.getFeature(e);return t?!!t.module||!1:(a.kg.error({error:Error("[Message Feature]: ".concat(this.name," isLoaded unknown feature ").concat(e))}),!1)}has(e){return!!this.getFeature(e)}getModule(e){var t=this.getFeature(e);if(!t){a.kg.error({error:Error("[Message Feature][getModule]: ".concat(this.name," get feature not exist ").concat(e))});return}if(!t.module){a.kg.error({error:Error("[Message Feature][getModule]: ".concat(this.name," get feature module unset ").concat(e))});return}return t.module}get(e){var t=this.getFeature(e);if(!t){a.kg.error({error:Error("[Message Feature][get]: ".concat(this.name," get feature not exist ").concat(e))});return}if(!t.module){a.kg.error({error:Error("[Message Feature][get]: ".concat(this.name," get feature module unset ").concat(e))});return}return(0,s._)((0,r._)({},t.module),{type:e})}getAsync(e){var t=this;return(0,i._)(function*(){var n=t.getFeature(e);if(!n){a.kg.error({error:Error("[Message Feature]: ".concat(t.name," getAsync unknown feature ").concat(e))});return}return!n.module&&(yield t.load(e)),t.get(e)})()}entries(){var{featureMap:e}=this;return[...e.values()].filter(e=>(!e.module&&a.kg.warning("[Message Feature][entries]: ".concat(this.name," entries module unloaded feature.type=").concat(e.type)),null!==e.module&&void 0!==e.module)).map(e=>[e.type,e.module])}getAllAsync(){var e=this;return(0,i._)(function*(){var{featureMap:t}=e,n=[...t.values()];return(yield Promise.all(n.map(t=>e.getAsync(t.type)))).filter(e=>!!e)})()}getTypeByContext(e){var t,n,{featureTypeParser:i}=this;if(!i)return a.kg.error({error:Error("[Message Feature]: ".concat(this.name," getTypeByContext featureTypeParser unset"))}),null!==(t=this.getDefaultType())&&void 0!==t?t:"";try{return i(e)}catch(e){return a.kg.error({error:Error("[Message Feature]: ".concat(this.name," getTypeByContext featureTypeParser error ").concat(e))}),null!==(n=this.getDefaultType())&&void 0!==n?n:""}}getByContext(e){var t=this.getTypeByContext(e);return this.get(t)}getByContextAsync(e){var t=this;return(0,i._)(function*(){var n=t.getTypeByContext(e);return t.getAsync(n)})()}getDefault(){if(!!this.defaultFeature)return(0,r._)({type:this.defaultFeature.type},this.defaultFeature.module)}getDefaultType(){var e;return null===(e=this.defaultFeature)||void 0===e?void 0:e.type}setDefaultFeature(e){var{type:t}=e,n=this.getFeatureKey(t);this.defaultFeature=e,this._produce(t=>{t.featureMap.set(n,(0,o.cA)(e))})}setFeatureTypeParser(e){this.featureTypeParser=e.bind({internalHas:e=>{try{var t=this.getFeatureKey(e);return!!this.featureMap.get(t)}catch(e){return a.kg.error({error:Error("[Message Feature]: ".concat(this.name," featureTypeParser internalHas error ").concat(e))}),!1}}})}deregisterByTag(e){var{featureMap:t}=this,n=[...t.values()].filter(t=>{var n;return null===(n=t.tags)||void 0===n?void 0:n.includes(e)});this._produce(e=>{n.forEach(t=>{this._deregister(e,t.type)})})}getByTag(e){var{featureMap:t}=this,n=[...t.values()].filter(t=>{var n;return null===(n=t.tags)||void 0===n?void 0:n.includes(e)});return n.length?n.map(e=>this.get(e.type)).filter((e,t)=>(!e&&a.kg.warning("[Message Feature]: ".concat(this.name," getByTag module unloaded features[index].type=").concat(n[t].type)),!!e)):(a.kg.warning("[Message Feature]: ".concat(this.name," getByTag no feature include tag ").concat(e)),[])}getByTagAsync(e){var t=this;return(0,i._)(function*(){var{featureMap:n}=t,i=[...n.values()].filter(t=>{var n;return null===(n=t.tags)||void 0===n?void 0:n.includes(e)});return i.length?(yield Promise.all(i.map(e=>t.getAsync(e.type)))).filter(e=>!!e):(a.kg.warning("[Message Feature]: ".concat(t.name," getByTagAsync no feature include tag ").concat(e)),[])})()}constructor(e){super();var{name:t,defaultFeature:n,features:i,featureTypeParser:r}=e;this.name=t,this._state={featureMap:new Map},n&&this.setDefaultFeature(n),i&&this.registerSome(i),r&&this.setFeatureTypeParser(r)}}},420998:function(e,t,n){"use strict";n.d(t,{SA:()=>a,Tn:()=>l,yt:()=>F,Is:()=>g});var i=n("825955"),r=n("151064"),s=n("455069"),o=n("659596"),a=e=>{var{fileUrl:t}=e,[n,a]=(0,s.useState)(""),[l,d]=(0,s.useState)(!0);(0,s.useEffect)(()=>{fetch(t).then(e=>e.text()).then(e=>{d(!1),a(e)})},[t]);var c=(0,s.useRef)(null);return(0,s.useEffect)(()=>{function e(){return(e=(0,i._)(function*(){if(c.current){for(var e=0,t=n.length;e<Math.ceil(t/5e4);e++)yield new Promise(e=>setTimeout(e,10)),c.current.textContent+=n.slice(5e4*e,(e+1)*5e4);c.current.textContent=n}})).apply(this,arguments)}!function(){e.apply(this,arguments)}()},[n]),(0,r.jsx)("div",{className:"flex flex-col items-center w-full h-full flex-1 py-2 px-4",children:(0,r.jsx)(o.yC,{wrapperClassName:"w-full h-full grow",spinning:l,childStyle:{width:"100%",height:"100%",flexGrow:1},children:n?(0,r.jsx)("div",{children:(0,r.jsx)("pre",{className:"max-w-full overflow-auto whitespace-pre-wrap break-all text-[14px] leading-[22px]",ref:c})}):null})})},l=e=>{var{fileUrl:t}=e,[n,a]=(0,s.useState)(""),[l,d]=(0,s.useState)(!0);(0,s.useEffect)(()=>{fetch(t).then(e=>e.text()).then(e=>{d(!1),a(e)})},[t]);var c=(0,s.useRef)(null);return(0,s.useEffect)(()=>{function e(){return(e=(0,i._)(function*(){if(c.current){for(var e=0,t=n.length;e<Math.ceil(t/5e4);e++)yield new Promise(e=>setTimeout(e,10)),c.current&&(c.current.textContent+=n.slice(5e4*e,(e+1)*5e4));c.current&&(c.current.textContent=n)}})).apply(this,arguments)}!function(){e.apply(this,arguments)}()},[n]),(0,r.jsx)("div",{className:"flex flex-col items-center w-full h-full flex-1 py-2 px-4",children:(0,r.jsx)(o.yC,{wrapperClassName:"w-full h-full grow",spinning:l,childStyle:{width:"100%",height:"100%",flexGrow:1},children:(0,r.jsx)("pre",{className:"max-w-full overflow-auto whitespace-pre-wrap break-all text-[14px] leading-[22px]",ref:c})})})},d=n("262941"),c=n("876945"),h=n("90265"),u=n("252237"),p=n.n(u),f=n("910656");n("107440"),n("887869"),d.GlobalWorkerOptions.workerSrc="//lf-cdn.coze.cn/obj/unpkg/pdfjs-dist/".concat(d.version,"/build/pdf.worker.min.mjs");var m={cMapUrl:"//lf-cdn.coze.cn/obj/unpkg/pdfjs-dist/".concat(d.version,"/cmaps/"),cMapPacked:!0},g=e=>{var t,n,{fileUrl:i}=e,[a,l]=(0,s.useState)(!0),[d,u]=(0,s.useState)(0),[g,v]=(0,s.useState)(0),b=(0,s.useRef)(null),y=(0,s.useRef)(null),[x,w]=(0,s.useState)(null===(t=b.current)||void 0===t?void 0:t.clientHeight),_=Math.floor((null!=x?x:500)+20),S=e=>{var{scrollOffset:t}=e;v(Math.floor(t/_))},[E,C]=(0,s.useState)(1),A=(0,s.useMemo)(()=>a?null:(0,r.jsx)(f.qj,{children:e=>{var{height:t,width:n}=e;return(0,r.jsx)(f.t7,{height:null!=t?t:0,itemCount:d,itemSize:_,width:null!=n?n:0,onScroll:S,ref:y,children:e=>{var t,{index:i,style:s}=e;return(0,r.jsx)("div",{style:s,children:(0,r.jsx)(c.Z,{pageNumber:i+1,className:p()("flex items-center justify-center !coz-bg-primary"),width:(null!=n?n:100)-32,scale:E,onLoadSuccess:e=>{w(e.height)},loading:(0,r.jsx)("div",{style:{height:null===(t=b.current)||void 0===t?void 0:t.clientHeight}})})},"page_".concat(i+1))}})}}),[a,d,x,E,_]);return{pdfNode:(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-col items-center w-full h-full relative coz-bg-primary",children:[(0,r.jsx)("div",{className:p()("absolute top-0 left-0 right-0 bot-0 flex items-center justify-center h-full","z-10",!a&&"invisible"),children:(0,r.jsx)(o.yC,{})}),(0,r.jsx)("div",{className:p()("flex absolute top-0 left-0 right-0 overflow-auto px-5 w-full h-full justify-center",a&&"invisible"),ref:b,children:(0,r.jsx)(h.Z,{file:i,onLoadSuccess:e=>{var{numPages:t}=e;l(!1),u(t)},options:m,className:p()("flex w-full h-full"),loading:(0,r.jsx)(o.yC,{wrapperClassName:"w-full h-full",childStyle:{width:null===(n=b.current)||void 0===n?void 0:n.clientWidth,height:"100%"}}),children:b.current?A:null},i)})]})}),numPages:d,currentPage:g+1,onNext:()=>{if(g<d-1){var e,t=g+1;v(t),null===(e=y.current)||void 0===e||e.scrollToItem(t,"start")}},onBack:()=>{if(g>0){var e,t=g-1;v(t),null===(e=y.current)||void 0===e||e.scrollToItem(t,"start")}},scale:E,increaseScale:()=>{C(e=>Math.min(e+.1,2))},decreaseScale:()=>{C(e=>Math.max(e-.1,.5))}}},v=n("336205"),b=n("873183"),y=n("728901");n("615739");var x=n("127139"),w=n("193604");n("541269");var _=n("808549"),S=n("602042"),E=n("675210"),C=n("120454"),A=n("628949"),k=n("335740"),T=e=>{var t,n,i=e.find(e=>-1===e.parent&&"title"===e.type);return i?[(0,C._)((0,_._)({},i),{id:null===(t=i.id)||void 0===t?void 0:t.toString(),parent:null===(n=i.parent)||void 0===n?void 0:n.toString(),children:M(i,e)})]:e.map(e=>{var t;return(0,C._)((0,_._)({},e),{id:e.id.toString(),parent:null===(t=e.parent)||void 0===t?void 0:t.toString(),children:[]})})},M=(e,t)=>{var n;return(null!==(n=e.children)&&void 0!==n?n:[]).reduce((e,n)=>{var i,r,s=t.find(e=>e.id===n);return s?[...e,(0,C._)((0,_._)({},s),{id:null===(i=s.id)||void 0===i?void 0:i.toString(),parent:null===(r=s.parent)||void 0===r?void 0:r.toString(),children:M(s,t)})]:[...e]},[])},D=e=>{var t=new Set,n=e=>{if(!!e&&!!e.id){var{children:i}=e;i&&i.length&&i.forEach(e=>{e&&e.id&&(t.add(e.id),n(e))})}};return n(e),t},O=(e,t)=>{var n=function(t){var n=i.findIndex(e=>e.id.toString()===t);if(-1===n)return"continue";var r=i[n],s=i.find(t=>t.id.toString()===e.parentID);if(!s)return{v:{segments:null,errMsg:v.o.t("knowledge_hierarchies_categories_02")}};var o=s.children.indexOf(r.id)<e.dropIndex&&r.parent===s.id?e.dropIndex-1:e.dropIndex;if(r.parent!==s.id){var a=i.find(e=>e.id===r.parent);null==a||a.children.splice(a.children.indexOf(r.id),1),r.parent=s.id}s.children=s.children.filter(e=>e!==r.id),s.children.splice(o,0,r.id)};if(null===e.parentID)return{segments:null,errMsg:v.o.t("knowledge_hierarchies_categories_01")};var i=(0,k.Z)(t);for(var r of e.dragIDs){var s=n(r);if("object"===(0,A._)(s))return s.v}return{segments:i,errMsg:null}},I=(e,t)=>{var n=function(e){var t=i.findIndex(t=>t.id.toString()===e),n=i.find(e=>e.id===i[t].parent);n&&(n.children=n.children.filter(e=>e!==i[t].id)),i.splice(t,1)},i=(0,k.Z)(t);for(var r of e)n(r);return i},N=(e,t,n)=>{var i=function(e){var t,n=r.find(t=>t.id.toString()===e);if(!n)return{v:{segments:null,errMsg:v.o.t("knowledge_hierarchies_categories_04")}};var i=r.find(e=>e.id===n.parent);if(i&&(i.children=i.children.filter(e=>e!==n.id)),["table","image","title"].includes(null!==(t=null==n?void 0:n.type)&&void 0!==t?t:""))n.parent=s.id,s.children.push(n.id);else{s.text+=n.text;var o=r.findIndex(e=>e.id===n.id);-1!==o&&r.splice(o,1)}},r=(0,k.Z)(n),s=r.find(t=>t.id.toString()===e);if(!s||-1===s.parent&&"title"===s.type)return{segments:null,errMsg:v.o.t("knowledge_hierarchies_categories_03")};for(var o of(s.children=[],s.type="section-text",t)){var a=i(o);if("object"===(0,A._)(a))return a.v}return{segments:r,errMsg:null}},R=n("22916"),L=e=>{var{segments:t,setLevelSegments:n,setSelectionIDs:i,disabled:a}=e,[l,d]=(0,s.useState)(new Set),[c,h]=(0,s.useState)(new Set),{ref:u,width:f,height:m}=(0,E.Z)(),g=e=>{d(new Set([e.id])),h(D(e)),null==i||i([e.id,...D(e)])},{popoverNode:y,onContextMenu:x}=function(e){var t,n,{onDelete:i,onMerge:a}=e,[l,d]=(0,s.useState)(),[c,h]=(0,s.useState)(!1),[u,p]=(0,s.useState)({top:0,left:0}),f=(0,R.kF)();return{popoverNode:(0,r.jsx)(o.v2,{visible:c,onVisibleChange:h,onClickOutSide:()=>{h(!1),d(null)},trigger:"custom",position:"bottomLeft",render:(0,r.jsxs)(o.oU,{mode:"menu",children:[!l||(null===(t=l.children)||void 0===t?void 0:t.length)?null:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(o.v2.Item,{isMenu:!0,onClick:()=>{i(l.data),h(!1)},children:v.o.t("knowledge_level_028")})}),l&&(null===(n=l.children)||void 0===n?void 0:n.length)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.v2.Item,{isMenu:!0,onClick:()=>{a(l.data),h(!1)},children:v.o.t("knowledge_level_029")}),(0,r.jsx)(o.v2.Item,{isMenu:!0,onClick:()=>{i(l.data),h(!1)},children:v.o.t("knowledge_level_028")})]}):null]}),children:(0,r.jsx)("div",{style:{height:0,width:0,position:"fixed",top:u.top,left:u.left}})}),onContainerScroll:()=>{c&&h(!1)},onContextMenu:(e,t)=>{e.preventDefault(),d(t);var n=e.pageX,i=e.pageY,r=document.getElementById("coze-project:///knowledge/".concat(f.datasetID));if(r){var{left:s,top:o}=r.getBoundingClientRect();n-=s,i-=o}p({left:n,top:i}),h(!0)}}}({onMerge:e=>{var{segments:i,errMsg:r}=N(e.id,Array.from(D(e)),t);r&&o.FN.error(r),(null==i?void 0:i.length)&&(null==n||n(i))},onDelete:e=>{var i=I([e.id,...D(e)],t);null==n||n(i)}});return(0,r.jsxs)("div",{ref:u,className:"w-full h-full relative translate-z-0",children:[(0,r.jsx)(S.m,{data:T(t),disableDrag:a,disableDrop:a,onMove:e=>{var{dragIds:i,parentId:r,index:s}=e,{segments:a,errMsg:l}=O({dragIDs:i,parentID:r,dropIndex:s},t);l&&o.FN.error(l),(null==a?void 0:a.length)&&(null==n||n(a))},rowHeight:34,paddingTop:4,paddingBottom:4,width:f,height:m,renderCursor:P,children:e=>{var t,{node:n,style:i,dragHandle:s}=e,{isOpen:d,data:h}=n,u=!(null===(t=h.children)||void 0===t?void 0:t.length),f=(0,r.jsx)(o.hU,{size:"small",color:"secondary",icon:(0,r.jsx)(b.x5d,{className:p()(d&&"rotate-90","transition duration-150 ease-in-out")}),onClick:e=>{e.stopPropagation(),n.toggle()},className:p()("bg-transparent ml-[4px] shrink-0")});return(0,r.jsxs)("div",{className:p()("flex items-center gap-[4px]","h-[32px] py-[4px] pr-[8px] mb-[2px]","hover:coz-mg-primary cursor-pointer","transition duration-150 ease-in-out","rounded-[8px]",(l.has(h.id)||c.has(h.id))&&"coz-mg-primary"),onClick:()=>{g(h)},onContextMenu:e=>{if(!a)x(e,n)},style:i,ref:s,children:[u?(0,r.jsx)("span",{className:"w-6 ml-[4px] shrink-0"}):f,(0,r.jsx)("span",{className:p()("text-[14px] leading-[20px] coz-fg-primary truncate"),children:"image"!==h.type?h.text.slice(0,50):v.o.t("knowledge_level_110")})]})}}),y]})},P=e=>{var{top:t,left:n,indent:i}=e;return(0,r.jsx)("div",{style:(0,_._)({},{display:"flex",alignItems:"center",zIndex:1},{position:"absolute",pointerEvents:"none",top:"".concat(t-2,"px"),left:"".concat(n,"px"),right:"".concat(i,"px")}),children:(0,r.jsx)("div",{className:p()("flex-1 h-[2px] coz-mg-hglt-plus")})})},j=e=>{var{id:t,onClick:n,title:i,selected:s,tag:a,label:l}=e;return(0,r.jsx)("div",{className:p()("w-full h-8 px-2 py-[6px] rounded-[8px] hover:coz-mg-primary cursor-pointer","flex items-center",s&&"coz-mg-primary"),onClick:()=>null==n?void 0:n(t),children:l?(0,r.jsx)("div",{className:"w-full",children:l}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.ZT.Text,{ellipsis:{showTooltip:!0},className:"w-full coz-fg-primary text-[14px] leading-[20px] grow truncate",children:i}),(0,r.jsx)("div",{className:"flex items-center shrink-0",children:a})]})})},F=e=>{var{isSearchable:t,list:n,onClick:i,selectedID:a,levelSegments:l,setLevelSegments:d,setSelectionIDs:c,treeDisabled:h,treeVisible:u}=e,[f,m]=(0,s.useState)("");return(0,r.jsxs)("div",{className:"flex flex-col grow w-full h-full",children:[t?(0,r.jsx)(o.ol,{value:f,placeholder:v.o.t("datasets_placeholder_search"),onChange:m}):null,(0,r.jsx)("div",{className:"pl-2 h-6 mt-4 mb-1 flex items-center",children:(0,r.jsx)("div",{className:"coz-fg-secondary text-[12px] font-[400] leading-4 shrink-0",children:v.o.t("knowledge_level_012")})}),(0,r.jsxs)("div",{className:"flex flex-col grow w-full",children:[(0,r.jsx)("div",{className:"flex flex-col gap-1 h-[150px] grow !overflow-auto shrink-0",children:n.filter(e=>e.title.includes(f)).map(e=>""!==e.id?(0,r.jsx)(j,{id:e.id,selected:e.id===a,onClick:i,title:e.title,tag:e.tag,label:e.label},e.id):null)}),(null==l?void 0:l.length)&&u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"h-4 flex justify-center items-center px-[8px] mb-[8px]",children:(0,r.jsx)("div",{className:p()("border border-solid border-[0.5px] transition w-full","coz-stroke-primary")})}),(0,r.jsxs)("div",{className:"flex flex-col gap-1 !overflow-auto",children:[(0,r.jsxs)("div",{className:"w-full pl-2 h-6 items-center flex gap-[4px]",children:[(0,r.jsx)("div",{className:"coz-fg-secondary text-[12px] font-[400] leading-4 shrink-0",children:v.o.t("knowledge_level_adjust")}),h?null:(0,r.jsx)(o.u,{style:{maxWidth:602},position:"left",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"coz-fg-plus text-[14px] font-[500] leading-[20px] mb-3",children:v.o.t("knowledge_hierarchies_categories")}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1 justify-between w-[182px]",children:[(0,r.jsx)("span",{className:"coz-fg-primary text-[12px] leading-[16px] font-[400]",children:v.o.t("level_999")}),(0,r.jsx)("img",{src:x,className:"w-[182px]"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1 justify-between w-[182px]",children:[(0,r.jsx)("span",{className:"coz-fg-primary text-[12px] leading-[16px] font-[400]",children:v.o.t("level_998")}),(0,r.jsx)("img",{src:y,className:"w-[182px]"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1 justify-between w-[182px]",children:[(0,r.jsx)("span",{className:"coz-fg-primary text-[12px] leading-[16px] font-[400]",children:v.o.t("level_997")}),(0,r.jsx)("img",{src:w,className:"w-[182px]"})]})]})]}),children:(0,r.jsx)(b.L03,{className:"coz-fg-secondary"})})]}),(0,r.jsx)("div",{className:"h-[360px]",children:(0,r.jsx)(L,{segments:l,setLevelSegments:d,setSelectionIDs:c,disabled:h})})]})]}):null]})]})};n("461654"),n("136710"),n("347852"),n("601142")},788911:function(e,t,n){"use strict";n.d(t,{OR:function(){return o},YB:function(){return s}});var i=n(455069),r=n(917085),s=(0,r.Z)(),o=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];(0,i.useEffect)(()=>(s.on(e,t),()=>{s.off(e,t)}),n)}},272661:function(e,t,n){"use strict";n.d(t,{L:function(){return r}});var i=n(304194),r=e=>new i.j({name:e})},836511:function(e,t,n){"use strict";n.d(t,{IF:()=>S,E1:()=>A});var i,r=n("151064"),s=n("455069"),o=n("336205"),a=n("659596"),l=n("825955"),d=n("745474"),c=n("458620"),h=n("727914"),u=n("178385"),p=n("382534"),f=e=>0x1400000>e,m=e=>new Promise((t,n)=>{var i=new FileReader;i.onload=e=>{var i,r=null===(i=e.target)||void 0===i?void 0:i.result;if(!r||"string"!=typeof r){n(new h.sH("getBase64","file read invalid"));return}t(r.replace(/^.*?,/,""))},i.onerror=()=>{a.FN.error(o.o.t("read_file_failed_please_retry")),n(new h.sH("getBase64","file read fail"))},i.onabort=()=>{n(new h.sH("getBase64","file read abort"))},i.readAsDataURL(e)}),g=e=>{var t=e.lastIndexOf(".");return e.slice(t+1)},v=e=>{var{customRequest:t,children:n}=e;return(0,r.jsx)(a.gq,{accept:"image/*",maxSize:20480,fileList:[],customRequest:t,onChange:e=>{var t,{currentFile:n}=e;if(n){;!f((null==n?void 0:null===(t=n.fileInstance)||void 0===t?void 0:t.size)||0)&&a.FN.error(o.o.t("knowledge_insert_img_013"))}},children:n})};var b=(i=(0,l._)(function*(e){var{object:t,options:n}=e,{onSuccess:i,onProgress:r,file:s}=t,{onFinish:o,onFinally:a,onBeforeUpload:l}=n;if("string"!=typeof s)try{null==l||l();var{name:f,fileInstance:v}=s;if(v){var b=g(f),y=yield m(v),x=yield p.nA.UploadFile({file_head:{file_type:b,biz_type:u.ym.BIZ_BOT_DATASET},data:y},{onUploadProgress:e=>{var t;r({total:null!==(t=e.total)&&void 0!==t?t:v.size,loaded:e.loaded})}});i(x.data),x.data&&(null==o||o({url:x.data.upload_url,tosKey:x.data.upload_uri}))}else d.s5.errorEvent(d.xW.KNOWLEDGE,{eventName:c.b.KnowledgeUploadFile,error:new h.sH(c.b.KnowledgeUploadFile,"".concat(c.b.KnowledgeUploadFile,": Failed to upload image"))})}catch(e){d.s5.errorEvent(d.xW.KNOWLEDGE,{eventName:c.b.KnowledgeUploadFile,error:e})}finally{null==a||a()}}),function(e){return i.apply(this,arguments)}),y=e=>{var{editor:t,disabled:n,showTooltip:i,renderUI:l}=e,d=i?a.u:s.Fragment;return(0,r.jsx)(v,{customRequest:e=>{if(!t)return;var{fileInstance:n}=e;if(!!n)return b({object:e,options:{onFinish:e=>{e.url&&t&&t.chain().focus().setImage({src:e.url}).run()}}})},children:(0,r.jsx)(d,{content:o.o.t("knowledge_insert_img_002"),clickToHide:!0,autoAdjustOverflow:!0,children:l({disabled:n,showTooltip:i})})})},x=n("808549"),w=n("120454"),_=n("873183"),S=e=>(0,r.jsx)(y,(0,w._)((0,x._)({},e),{renderUI:e=>{var{disabled:t}=e;return(0,r.jsx)(a.zx,{disabled:t,color:"primary",className:"coz-fg-primary leading-none",icon:(0,r.jsx)(_.Q2$,{className:"text-[14px]"}),children:o.o.t("knowledge_insert_img_002")})}})),E=n("252237"),C=n.n(E),A=e=>(0,r.jsx)(y,(0,w._)((0,x._)({},e),{renderUI:e=>{var{disabled:t}=e;return(0,r.jsx)(a.v2.Item,{disabled:t,icon:(0,r.jsx)(_.Q2$,{className:C()("w-3.5 h-3.5",{"opacity-30":t})}),className:C()("h-8 p-2 text-xs rounded-lg",{"cursor-not-allowed":t}),children:o.o.t("knowledge_insert_img_002")})}}))},461654:function(e,t,n){"use strict";n.d(t,{R:()=>g});var i=n("151064"),r=n("455069"),s=n("252237"),o=n.n(s),a=n("707291"),l=n("819195"),d=n("636436"),c=n("373025"),h=n("17236"),u=e=>{var{editorRef:t,exclude:n,onExitEditMode:i}=e;(0,r.useEffect)(()=>{var e=e=>{t.current&&!t.current.contains(e.target)&&!(null==n?void 0:n.some(t=>{var n;return null===(n=t.current)||void 0===n?void 0:n.contains(e.target)}))&&(null==i||i())};return window.addEventListener("mousedown",e),()=>{window.removeEventListener("mousedown",e)}},[t,n,i])},p=n("542284"),f=n("659596"),m=e=>{var{editorActionRegistry:t,readonly:n,contextMenuRef:r,x:s,y:a,editor:l}=e;return n?null:(0,i.jsx)("div",{ref:r,className:"absolute bg-white shadow-lg rounded-md py-1 z-50",style:{top:"".concat(a,"px"),left:"".concat(s,"px")},children:(0,i.jsx)(f.v2,{visible:!0,clickToHide:!0,keepDOM:!0,position:"bottomLeft",spacing:-4,trigger:"custom",getPopupContainer:()=>{var e;return null!==(e=r.current)&&void 0!==e?e:document.body},className:o()("coz-shadow-large"),render:(0,i.jsx)(f.v2.SubMenu,{className:o()("p-1"),mode:"menu",children:t.entries().map(e=>{var[t,{Component:n}]=e;return(0,i.jsx)(n,{editor:l},t)})})})})},g=e=>{var{editor:t,placeholder:n,editorContextMenuItemsRegistry:s,editorBottomSlot:f,onBlur:g}=e,v=(0,r.useRef)(null),b=(0,r.useRef)(null),{contextMenuPosition:y,openContextMenu:x}=(0,p.H)({contextMenuRef:b});return(u({editorRef:v,exclude:[b],onExitEditMode:()=>{var e=(0,l.k)(t);null==g||g(e)}}),t)?(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsx)("div",{ref:v,className:o()("relative","mb-2 p-2","text-sm leading-5","coz-fg-primary coz-bg-max","border border-solid coz-stroke-hglt rounded-lg"),onContextMenu:x,children:(0,i.jsxs)("div",{className:o()((0,c.X)(),(0,h.X)(),(0,d.I)()),children:[(0,i.jsx)(a.kg,{editor:t,placeholder:n}),f]})}),y&&s?(0,i.jsx)(m,{x:y.x,y:y.y,contextMenuRef:b,editor:t,editorActionRegistry:s}):null]}):null}},398412:function(e,t,n){"use strict";n.d(t,{y:function(){return c}});var i=n(151064);n(455069);var r=n(385038),s=n(336205),o=n(873183),a=n(659596),l=n(95196),d=n(788911),c=e=>{var{chunk:t,chunks:n,disabled:c}=e,{addEmptyChunkAfter:h}=(0,l.i)({chunks:n||[],onChunksChange:e=>{var{newChunk:n,chunks:i}=e;d.YB.emit("hoverEditBarAction",{type:"add-after",targetChunk:t,chunks:i,newChunk:n})}});return(0,i.jsx)(a.u,{content:s.o.t("knowledge_optimize_016"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(a.hU,{"data-dtestid":"".concat(r.w.SegmentDetailContentItemAddBottomIcon,".").concat(t.text_knowledge_editor_chunk_uuid),size:"small",color:"secondary",disabled:c,icon:(0,i.jsx)(o.BPm,{className:"text-[14px]"}),iconPosition:"left",className:"coz-fg-secondary leading-none !w-6 !h-6",onClick:()=>h(t)})})}},179231:function(e,t,n){"use strict";n.d(t,{$:function(){return c}});var i=n(151064);n(455069);var r=n(385038),s=n(336205),o=n(873183),a=n(659596),l=n(95196),d=n(788911),c=e=>{var{chunk:t,chunks:n=[],disabled:c}=e,{addEmptyChunkBefore:h}=(0,l.i)({chunks:n,onChunksChange:e=>{var{newChunk:n,chunks:i}=e;d.YB.emit("hoverEditBarAction",{type:"add-before",targetChunk:t,chunks:i,newChunk:n})}});return(0,i.jsx)(a.u,{content:s.o.t("knowledge_optimize_017"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(a.hU,{"data-dtestid":"".concat(r.w.SegmentDetailContentItemAddTopIcon,".").concat(t.text_knowledge_editor_chunk_uuid),size:"small",color:"secondary",disabled:c,icon:(0,i.jsx)(o.wu0,{className:"text-[14px]"}),iconPosition:"left",className:"coz-fg-secondary leading-none !w-6 !h-6",onClick:()=>h(t)})})}},876143:function(e,t,n){"use strict";n.d(t,{s:function(){return d}});var i=n(151064);n(455069);var r=n(336205),s=n(873183),o=n(659596),a=n(95196),l=n(788911),d=e=>{var{chunk:t,chunks:n=[],disabled:d}=e,{deleteChunk:c}=(0,a.S)({chunks:n,onChunksChange:e=>{var{chunks:n}=e;l.YB.emit("hoverEditBarAction",{type:"delete",targetChunk:t,chunks:n})}});return(0,i.jsx)(o.u,{content:r.o.t("knowledge_level_028"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(o.hU,{size:"small",color:"secondary",disabled:d,icon:(0,i.jsx)(s.dVD,{className:"text-[14px]"}),iconPosition:"left",className:"coz-fg-secondary leading-none !w-6 !h-6",onClick:()=>c(t)})})}},476350:function(e,t,n){"use strict";n.d(t,{i:function(){return d}});var i=n(151064);n(455069);var r=n(385038),s=n(336205),o=n(873183),a=n(659596),l=n(788911),d=e=>{var{chunk:t,disabled:n}=e;return(0,i.jsx)(a.u,{content:s.o.t("datasets_segment_edit"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(a.hU,{"data-dtestid":"".concat(r.w.SegmentDetailContentItemEditIcon,".").concat(t.text_knowledge_editor_chunk_uuid),size:"small",color:"secondary",disabled:n,icon:(0,i.jsx)(o.JAz,{className:"text-[14px]"}),iconPosition:"left",className:"coz-fg-secondary leading-none !w-6 !h-6",onClick:()=>{l.YB.emit("hoverEditBarAction",{type:"edit",targetChunk:t})}})})}},144416:function(e,t,n){"use strict";n.d(t,{H:function(){return r}});var i=n(304194),r=e=>new i.j({name:e})},642158:function(e,t,n){"use strict";n.d(t,{o:function(){return c}});var i=n(151064);n(455069);var r=n(252237),s=n.n(r),o=n(336205),a=n(873183),l=n(659596),d=n(757208),c=e=>{var{chunk:t,chunks:n,disabled:r,hoverEditBarActionsRegistry:c,onChunksChange:h}=e,u=t.status===d.OL.AuditFailed;return c?(0,i.jsxs)("div",{className:"absolute top-[2px] right-[2px] flex z-10",children:[r?null:(0,i.jsx)("div",{className:s()("p-1 coz-bg-plus rounded-lg","coz-shadow-default"),children:(0,i.jsx)(l.T,{spacing:3,children:c.entries().map(e=>{var[r,{Component:s}]=e;return(0,i.jsx)(s,{chunk:t,chunks:n,onChunksChange:h},r)})})}),u?(0,i.jsx)("div",{className:s()("p-1 coz-bg-plus rounded-lg","coz-shadow-default","ml-1"),children:(0,i.jsx)(l.u,{content:o.o.t("community_This_is_a_toast_Machine_review_failed"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(l.hU,{icon:(0,i.jsx)(a.L03,{className:"text-[14px] coz-fg-hglt-red"}),size:"small",color:"secondary",className:"coz-fg-secondary leading-none !w-6 !h-6"})})}):null]}):null}},202147:function(e,t,n){"use strict";n.d(t,{s:function(){return h}});var i=n(151064);n(455069);var r=n(252237),s=n.n(r),o=n(336205),a=n(873183),l=n(659596),d=n(95196),c=n(788911),h=e=>{let t,n;var{chunk:r,chunks:h=[],disabled:u}=e,{deleteChunk:p}=(0,d.S)({chunks:h,onChunksChange:e=>{var{chunks:t}=e;c.YB.emit("previewContextMenuItemAction",{type:"delete",targetChunk:r,chunks:t})}});return(0,i.jsx)(l.v2.Item,{disabled:u,icon:(0,i.jsx)(a.dVD,{className:(t=!!u,s()("w-3.5 h-3.5",{"opacity-30":t}))}),onClick:()=>p(r),className:(n=!!u,s()("h-8 px-2 py-2 text-xs rounded-lg",{"cursor-not-allowed":n})),children:o.o.t("Delete")})}},71132:function(e,t,n){"use strict";n.d(t,{i:function(){return c}});var i=n(151064);n(455069);var r=n(252237),s=n.n(r),o=n(336205),a=n(873183),l=n(659596),d=n(788911),c=e=>{let t,n;var{chunk:r,disabled:c}=e;return(0,i.jsx)(l.v2.Item,{disabled:c,icon:(0,i.jsx)(a.JAz,{className:(t=!!c,s()("w-3.5 h-3.5",{"opacity-30":t}))}),onClick:()=>{d.YB.emit("previewContextMenuItemAction",{type:"edit",targetChunk:r})},className:(n=!!c,s()("h-8 px-2 py-2 text-xs rounded-lg",{"cursor-not-allowed":n})),children:o.o.t("Edit")})}},577487:function(e,t,n){"use strict";n.d(t,{C:function(){return r}});var i=n(304194),r=e=>new i.j({name:e})},136710:function(e,t,n){"use strict";n.d(t,{i:()=>y});var i=n("151064"),r=n("455069"),s=n("252237"),o=n.n(s),a=()=>{var[e,t]=(0,r.useState)(null);return{hoveredChunk:e,handleMouseEnter:e=>{t(e)},handleMouseLeave:()=>{t(null)}}},l=n("542284"),d=n("472891"),c=n.n(d),h=n("976482"),u=n("636436"),p=n("373025"),f=n("17236"),m=e=>{var t,n,{chunk:r,locateId:s}=e;return(0,i.jsx)("div",{id:s,className:o()("relative","mb-2 p-2","text-sm leading-5","coz-fg-primary hover:coz-mg-hglt-secondary-hovered coz-mg-secondary","border border-solid coz-stroke-primary rounded-lg",(0,p.X)(),(0,f.X)(),(0,u.I)()),children:(0,i.jsx)("p",{dangerouslySetInnerHTML:{__html:null!==(n=c().sanitize((0,h.F)(null!==(t=r.content)&&void 0!==t?t:""),{FORBID_TAGS:["style"]}))&&void 0!==n?n:""}})})},g=n("659596"),v=e=>{var{previewContextMenuItemsRegistry:t,chunk:n,chunks:r,readonly:s,contextMenuRef:a,x:l,y:d}=e;return s?null:(0,i.jsx)("div",{ref:a,className:"absolute bg-white shadow-lg rounded-md py-1 z-50",style:{top:"".concat(d,"px"),left:"".concat(l,"px")},children:(0,i.jsx)(g.v2,{visible:!0,position:"bottomLeft",spacing:-4,trigger:"custom",getPopupContainer:()=>{var e;return null!==(e=a.current)&&void 0!==e?e:document.body},className:o()("rounded-lg"),render:(0,i.jsx)(g.v2.SubMenu,{className:o()("w-40 p-1"),mode:"menu",children:t.entries().map(e=>{var[t,{Component:s}]=e;return(0,i.jsx)(s,{chunk:n,chunks:r},t)})})})})},b=n("642158"),y=r.memo(e=>{var{chunk:t,chunks:n,readonly:s=!1,locateId:d,onActivateEditMode:c,hoverEditBarActionsRegistry:h,previewContextMenuItemsRegistry:u}=e,p=(0,r.useRef)(null),{hoveredChunk:f,handleMouseEnter:g,handleMouseLeave:y}=a(),{contextMenuPosition:x,openContextMenu:w}=(0,l.H)({contextMenuRef:p});return(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsxs)("div",{className:o()("relative overflow-hidden"),onContextMenu:s?void 0:e=>w(e),onMouseEnter:s?void 0:()=>g(t.text_knowledge_editor_chunk_uuid),onMouseLeave:s?void 0:y,onDoubleClick:s?void 0:()=>null==c?void 0:c(t),children:[f!==t.text_knowledge_editor_chunk_uuid||s?null:(0,i.jsx)(b.o,{chunk:t,chunks:n,hoverEditBarActionsRegistry:h}),(0,i.jsx)(m,{chunk:t,locateId:d||""})]}),x?(0,i.jsx)(v,{previewContextMenuItemsRegistry:u,x:x.x,y:x.y,chunk:t,chunks:n,readonly:s,contextMenuRef:p}):null]})},(e,t)=>e.chunk.content===t.chunk.content&&!0)},542284:function(e,t,n){"use strict";n.d(t,{H:function(){return r}});var i=n(455069),r=e=>{var{contextMenuRef:t}=e,[n,r]=(0,i.useState)(null),s=()=>{r(null)};return(0,i.useEffect)(()=>{var e=e=>{t.current&&!t.current.contains(e.target)&&s()};return window.addEventListener("mousedown",e),()=>{window.removeEventListener("mousedown",e)}},[]),{contextMenuPosition:n,openContextMenu:e=>{e.preventDefault();var t=e.currentTarget.getBoundingClientRect();r({x:e.clientX-t.left,y:e.clientY-t.top})},closeContextMenu:s}}},195523:function(e,t,n){"use strict";n.d(t,{z:function(){return a}});var i=n(825955),r=n(735114),s=n(727914),o=n(382534),a=()=>{var e,{runAsync:t}=(0,r.Z)((e=(0,i._)(function*(e){if(!e)throw new s.sH("normal_error","missing slice_id");yield o.MJ.DeleteSlice({slice_ids:[e]})}),function(t){return e.apply(this,arguments)}),{manual:!0});return{deleteSlice:t}}},95196:function(e,t,n){"use strict";n.d(t,{S:()=>a,i:()=>s});var i=n("455069"),r=n("68851"),s=e=>{var{chunks:t,onChunksChange:n}=e,s=(0,i.useRef)(t);return(0,i.useEffect)(()=>{s.current=t},[t]),{addEmptyChunkAfter:e=>{var t,i,o=s.current,a=o.findIndex(t=>t.text_knowledge_editor_chunk_uuid===e.text_knowledge_editor_chunk_uuid);if(-1!==a){var l=null!==(i=null===(t=o.find(t=>t.text_knowledge_editor_chunk_uuid===e.text_knowledge_editor_chunk_uuid))||void 0===t?void 0:t.sequence)&&void 0!==i?i:"1",d=(0,r.k8)({sequence:String(Number(l)+1)}),c=[...o.slice(0,a+1),d,...o.slice(a+1)];null==n||n({newChunk:d,chunks:c})}},addEmptyChunkBefore:e=>{var t,i,o=s.current,a=o.findIndex(t=>t.text_knowledge_editor_chunk_uuid===e.text_knowledge_editor_chunk_uuid),l=null!==(i=null===(t=o.find(t=>t.text_knowledge_editor_chunk_uuid===e.text_knowledge_editor_chunk_uuid))||void 0===t?void 0:t.sequence)&&void 0!==i?i:"1";if(-1!==a){var d=(0,r.k8)({sequence:l}),c=[...o.slice(0,a),d,...o.slice(a)];null==n||n({newChunk:d,chunks:c})}}}},o=n("195523"),a=e=>{var{chunks:t,onChunksChange:n}=e,r=(0,i.useRef)(t),{deleteSlice:s}=(0,o.z)();return(0,i.useEffect)(()=>{r.current=t},[t]),{deleteChunk:(0,i.useCallback)(e=>{var t=r.current.filter(t=>t.text_knowledge_editor_chunk_uuid!==e.text_knowledge_editor_chunk_uuid);if(!!e.slice_id)s(e.slice_id).then(()=>{null==n||n({chunks:t,targetChunk:e})})},[n,s])}}},916853:function(e,t,n){"use strict";n.d(t,{n:function(){return m}});var i=n(808549),r=n(120454),s=n(455069),o=n(724830),a=n(707291),l=n(76049),d=n(357962),c=n(778681),h=n(481265),u=n(550745),p=n(976482),f=n(819195),m=e=>{var{chunk:t,editorProps:n,onChange:m}=e,g=(0,a.jE)({extensions:[o.Z.configure({hardBreak:{keepMarks:!1},paragraph:{HTMLAttributes:{class:"text-knowledge-tiptap-editor-paragraph"}}}),h.ZP.configure({resizable:!0}),l.Z,c.Z,d.Z,u.ZP.configure({inline:!1,allowBase64:!0})],content:(0,p.F)((null==t?void 0:t.content)||""),parseOptions:{preserveWhitespace:"full"},onUpdate:e=>{var{editor:n}=e;if(!!t&&!!n){var s=(0,f.k)(n);null==m||m((0,r._)((0,i._)({},t),{content:s}))}},editorProps:(0,r._)((0,i._)({},n),{handlePaste(e,t,n){if(!g)return!1;var i,r=null===(i=t.clipboardData)||void 0===i?void 0:i.getData("text/plain");if(null==r?void 0:r.includes("\n")){t.preventDefault();var s=(0,p.F)(r);return g.chain().focus().insertContent(s).run(),!0}return!1}})});return(0,s.useEffect)(()=>{if(!!g&&!!t){var e=(0,p.F)(t.content||"");g.commands.setContent(e||"",!1,{preserveWhitespace:"full"})}},[t,g]),{editor:g}}},149951:function(e,t,n){"use strict";n.d(t,{B:()=>x});var i=n("825955"),r=n("659596"),s=n("987633"),o=(e,t)=>{var n,i;return(0,s.PJ)(null!==(i=t.content)&&void 0!==i?i:"")!==(null===(n=e.find(e=>e.slice_id===t.slice_id))||void 0===n?void 0:n.content)},a=n("68851"),l=n("735114"),d=n("727914"),c=n("382534"),h=()=>{var e,{runAsync:t,loading:n}=(0,l.Z)((e=(0,i._)(function*(e,t){if(!e)throw new d.sH("normal_error","missing slice_id");return yield c.MJ.UpdateSlice({slice_id:e,raw_text:t}),t}),function(t,n){return e.apply(this,arguments)}),{manual:!0});return{updateSlice:t,updateLoading:n}},u=e=>{var t,{chunks:n,onChunksChange:s,onUpdateChunk:l}=e,{updateSlice:d}=h();return{updateRemoteChunk:(t=(0,i._)(function*(e){if(!e.slice_id){r.FN.error("The slice ID does not exist. Please refresh the page");return}if(!o(n,e)){null==s||s(n);return}yield d(e.slice_id,null!==(t=e.content)&&void 0!==t?t:"");var t,i=(0,a.PU)(n,e);null==l||l(e),null==s||s(i)}),function(e){return t.apply(this,arguments)})}},p=n("195523"),f=e=>{var t,{chunks:n,onChunksChange:r,onDeleteChunk:s}=e,{deleteSlice:o}=(0,p.z)();return{deleteRemoteChunk:(t=(0,i._)(function*(e){if(!!e.slice_id){yield o(e.slice_id);var t=(0,a.Qe)(n,e.slice_id);null==r||r(t),null==s||s(e)}}),function(e){return t.apply(this,arguments)})}},m=e=>{var{chunks:t,onChunksChange:n}=e;return{deleteLocalChunk:e=>{if(!!e.local_slice_id){var i=(0,a.wL)(t,e.local_slice_id);null==n||n(i)}}}},g=n("745474"),v=n("458620"),b=e=>{var t,{documentId:n}=e;var{runAsync:r}=(0,l.Z)((t=(0,i._)(function*(e){var t,{content:i,sequence:r}=e;if(!n)throw new d.sH("normal_error","missing doc_id");var s=yield c.MJ.CreateSlice({document_id:n,raw_text:i,sequence:r});return(0,a.bc)({slice_id:null!==(t=null==s?void 0:s.slice_id)&&void 0!==t?t:"",sequence:r,content:i})}),function(e){return t.apply(this,arguments)}),{manual:!0,onError:e=>{g.s5.errorEvent(g.xW.KNOWLEDGE,{eventName:v.b.KnowledgeCreateSlice,error:e})}});return{createChunk:r}},y=e=>{var t,{chunks:n,documentId:r,onChunksChange:s,onAddChunk:o}=e,{createChunk:l}=b({documentId:r});return{createLocalChunk:(t=(0,i._)(function*(e){if(!!e.local_slice_id){var t,i,r=yield l({content:null!==(t=e.content)&&void 0!==t?t:"",sequence:null!==(i=e.sequence)&&void 0!==i?i:"1"}),d=(0,a.Gf)({chunks:n,localChunkSliceId:e.local_slice_id,newChunk:r});null==o||o(r),null==s||s(d)}}),function(e){return t.apply(this,arguments)})}},x=e=>{var t,n,r,{chunks:s,documentId:o,onAddChunk:a,onUpdateChunk:l,onChunksChange:d,onDeleteChunk:c}=e,{createLocalChunk:h}=y({chunks:s,documentId:o,onChunksChange:d,onAddChunk:a}),{updateRemoteChunk:p}=u({chunks:s,onChunksChange:d,onUpdateChunk:l}),{deleteLocalChunk:g}=m({chunks:s,onChunksChange:d}),{deleteRemoteChunk:v}=f({chunks:s,onChunksChange:d,onDeleteChunk:c});var b=(t=(0,i._)(function*(e){if(""===e.content){yield v(e);return}yield p(e)}),function(e){return t.apply(this,arguments)});var x=(n=(0,i._)(function*(e){""===e.content?g(e):yield h(e)}),function(e){return n.apply(this,arguments)});return{saveChunk:(r=(0,i._)(function*(e){if(!e.local_slice_id){yield b(e);return}yield x(e)}),function(e){return r.apply(this,arguments)})}}},523652:function(e,t,n){"use strict";n.d(t,{R_:()=>i.R,go:()=>o,pR:()=>a.p,UF:()=>l.U,nR:()=>r.n});var i=n("461654");n("136710"),n("149951");var r=n("916853"),s=n("151064"),o=e=>{var{editor:t,actionRegistry:n}=e;return(0,s.jsx)("div",{className:"h-[32px] box-content px-2 pt-2",children:n.entries().map(e=>{var[n,{Component:i}]=e;return(0,s.jsx)(i,{editor:t},n)})})},a=n("347852"),l=n("601142");n("642158"),n("476350"),n("876143"),n("179231"),n("398412"),n("144416"),n("788911")},789662:function(e,t,n){"use strict";n.d(t,{p:function(){return o}});var i,r=n(836511),s=n(272661);var o=((i=(0,s.L)("editor-context-actions")).registerSome([{type:"upload-image",module:{Component:r.E1}}]),i)},601142:function(e,t,n){"use strict";n.d(t,{U:()=>N});var i,r,s=n("808549"),o=n("120454"),a=n("151064"),l=n("455069"),d=n("149951"),c=n("916853"),h=n("788911"),u=n("136710"),p=n("461654"),f=n("577487"),m=n("71132"),g=n("202147"),v=n("252237"),b=n.n(v),y=n("336205"),x=n("873183"),w=n("659596"),_=n("95196"),S=e=>{let t,n;var{chunk:i,chunks:r=[],disabled:s}=e,{addEmptyChunkBefore:o}=(0,_.i)({chunks:r,onChunksChange:e=>{var{newChunk:t,chunks:n}=e;h.YB.emit("previewContextMenuItemAction",{type:"add-before",targetChunk:i,newChunk:t,chunks:n})}});return(0,a.jsx)(w.v2.Item,{disabled:s,icon:(0,a.jsx)(x.wu0,{className:(t=!!s,b()("w-3.5 h-3.5",{"opacity-30":t}))}),onClick:()=>o(i),className:(n=!!s,b()("h-8 px-2 py-2 text-xs rounded-lg",{"cursor-not-allowed":n})),children:y.o.t("knowledge_optimize_017")})},E=e=>{let t,n;var{chunk:i,chunks:r=[],disabled:s}=e,{addEmptyChunkAfter:o}=(0,_.i)({chunks:r,onChunksChange:e=>{var{newChunk:t,chunks:n}=e;h.YB.emit("previewContextMenuItemAction",{type:"add-after",newChunk:t,targetChunk:i,chunks:n})}});return(0,a.jsx)(w.v2.Item,{disabled:s,icon:(0,a.jsx)(x.BPm,{className:(t=!!s,b()("w-3.5 h-3.5",{"opacity-30":t}))}),onClick:()=>o(i),className:(n=!!s,b()("h-8 px-2 py-2 text-xs rounded-lg",{"cursor-not-allowed":n})),children:y.o.t("knowledge_optimize_016")})};var C=((i=(0,f.C)("preview-context-menu-items")).registerSome([{type:"edit",module:{Component:m.i}},{type:"add-before",module:{Component:S}},{type:"add-after",module:{Component:E}},{type:"delete",module:{Component:g.s}}]),i),A=n("144416"),k=n("476350"),T=n("876143"),M=n("179231"),D=n("398412");var O=((r=(0,A.H)("hover-edit-bar-actions")).registerSome([{type:"edit",module:{Component:k.i}},{type:"add-before",module:{Component:M.$}},{type:"add-after",module:{Component:D.y}},{type:"delete",module:{Component:T.s}}]),r),I=n("789662"),N=e=>{var{chunks:t,documentId:n,readonly:i=!1,onChange:r,onAddChunk:f,onDeleteChunk:m}=e,[g,v]=(0,l.useState)(t),[b,y]=(0,l.useState)(null),{editor:x}=(0,c.n)({chunk:b}),{saveChunk:w}=(0,d.B)({chunks:g,documentId:n,onChunksChange:e=>{null==r||r(e),y(null)},onAddChunk:f,onDeleteChunk:m});return(0,h.OR)("previewContextMenuItemAction",(0,l.useCallback)(e=>{var{type:t,newChunk:n,chunks:i,targetChunk:s}=e;"add-after"===t&&(n&&y(n),i&&v(i)),"add-before"===t&&(n&&y(n),i&&v(i)),"delete"===t&&(null==m||m(s),i&&(null==r||r(i))),"edit"===t&&y(s)},[m,r])),(0,h.OR)("hoverEditBarAction",(0,l.useCallback)(e=>{var{type:t,targetChunk:n,chunks:i,newChunk:s}=e;"add-after"===t&&(s&&y(s),i&&v(i)),"add-before"===t&&(s&&y(s),i&&v(i)),"delete"===t&&(null==m||m(n),i&&(null==r||r(i))),"edit"===t&&y(n)},[m,r])),(0,l.useEffect)(()=>{v(t)},[t]),(0,a.jsx)(a.Fragment,{children:g.map(e=>(0,a.jsx)("div",{children:e.text_knowledge_editor_chunk_uuid===(null==b?void 0:b.text_knowledge_editor_chunk_uuid)&&b?(0,a.jsx)(p.R,{editor:x,editorContextMenuItemsRegistry:I.p,onBlur:e=>{w((0,o._)((0,s._)({},b),{content:e}))}}):(0,a.jsx)(u.i,{chunk:e,chunks:g,readonly:i,onActivateEditMode:y,hoverEditBarActionsRegistry:O,previewContextMenuItemsRegistry:C})},e.text_knowledge_editor_chunk_uuid))})}},347852:function(e,t,n){"use strict";n.d(t,{p:()=>P,D:()=>C});var i,r,s=n("151064"),o=n("455069"),a=n("987633"),l=n("149951"),d=n("916853"),c=n("788911"),h=n("252237"),u=n.n(h),p=e=>{var{title:t,id:n}=e;return(0,s.jsx)("div",{id:n,className:u()("w-full text-[14px] font-[500] leading-[20px] coz-fg-plus"),children:t})},f=n("472891"),m=n.n(f),g=e=>{var{base64:t,htmlText:n,link:i,caption:r,locateId:o,selected:a}=e;return(0,s.jsxs)("div",{id:o,className:u()("flex items-center flex-col gap-2","w-full p-2 coz-mg-secondary","border border-solid coz-stroke-primary rounded-[8px]",a&&"!coz-mg-hglt"),children:[t?(0,s.jsx)("img",{src:"data:image/jpeg;base64, ".concat(t),className:"w-full h-full"}):null,n?(0,s.jsx)("div",{className:"w-full h-full overflow-auto [&>*]:w-full [&>*]:h-full",dangerouslySetInnerHTML:{__html:m().sanitize(n)}}):null,i?(0,s.jsx)("div",{className:"coz-fg-primary text-[14px] leading-[20px] font-[400] break-all",children:i}):null,r?(0,s.jsx)("div",{className:"coz-fg-primary text-[14px] leading-[20px] font-[400] break-all",children:r}):null]})},v=n("789662"),b=n("136710"),y=n("461654"),x=e=>"segment-".concat(e),w=n("808549"),_=n("120454"),S=e=>{var t,n,i=e.find(e=>-1===e.parent&&"title"===e.type);return i?[(0,_._)((0,w._)({},i),{text:null!==(n=i.content)&&void 0!==n?n:"",parent:null===(t=i.parent)||void 0===t?void 0:t.toString(),children:E(i,e,"root"),renderLevel:"root-".concat(i.text_knowledge_editor_chunk_uuid)})]:e.map(e=>{var t,n;return(0,_._)((0,w._)({},e),{text:null!==(n=e.content)&&void 0!==n?n:"",parent:null===(t=e.parent)||void 0===t?void 0:t.toString(),children:[],renderLevel:"root-".concat(e.text_knowledge_editor_chunk_uuid)})})},E=(e,t,n)=>{var i;return(null!==(i=e.children)&&void 0!==i?i:[]).reduce((e,i,r)=>{var s=t.find(e=>e.id.toString()===i.toString());if(!s)return[...e];var o,a,l="".concat(n,"-").concat(r),d="".concat(l,"-").concat(s.text_knowledge_editor_chunk_uuid);return[...e,(0,_._)((0,w._)({},s),{parent:null===(o=s.parent)||void 0===o?void 0:o.toString(),text:null!==(a=s.content)&&void 0!==a?a:"",children:E(s,t,l),renderLevel:d})]},[])},C=(e,t)=>e.map(e=>-1!==e.parent||"title"!==e.type||e.text?e:(0,_._)((0,w._)({},e),{text:null!=t?t:""})),A=n("577487"),k=n("71132"),T=n("202147");var M=((i=(0,A.C)("preview-context-menu-items")).registerSome([{type:"edit",module:{Component:k.i}},{type:"delete",module:{Component:T.s}}]),i),D=n("144416"),O=n("476350"),I=n("876143");var N=((r=(0,D.H)("hover-edit-bar-actions")).registerSome([{type:"edit",module:{Component:O.i}},{type:"delete",module:{Component:I.s}}]),r),R=e=>{(0,o.useEffect)(()=>{if(null==e?void 0:e.length){var t=e[0],n=document.getElementById(x(t));null==n||n.scrollIntoView({behavior:"smooth",block:"start"})}},[e])},L=()=>{var[e,t]=(0,o.useState)({chunk:null,renderLevel:null});return{activeChunkInfo:e,clearActiveChunk:()=>{t({chunk:null,renderLevel:null})},setActiveChunkWithLevel:e=>{if(!e.renderLevel){console.warn("Chunk does not have renderLevel field",e);return}t({chunk:e,renderLevel:e.renderLevel})},isActiveChunk:t=>!!t&&t===e.renderLevel}},P=e=>{var{readonly:t,chunks:n,documentId:i,selectionIDs:r,onChange:a,onDeleteChunk:h}=e,[u,p]=(0,o.useState)(n),f=(0,o.useMemo)(()=>S(u),[u]),{activeChunkInfo:m,clearActiveChunk:g,setActiveChunkWithLevel:v,isActiveChunk:b}=L(),{editor:y}=(0,d.n)({chunk:m.chunk}),{saveChunk:x}=(0,l.B)({chunks:n,documentId:i,onChunksChange:e=>{null==a||a(e),g()},onDeleteChunk:e=>{null==h||h(e)}});return(R(r),(0,c.OR)("previewContextMenuItemAction",(0,o.useCallback)(e=>{var{type:t,targetChunk:n,chunks:i}=e;"delete"===t&&(null==h||h(n),i&&(null==a||a(i))),"edit"===t&&v(n)},[])),(0,c.OR)("hoverEditBarAction",(0,o.useCallback)(e=>{var{type:t,targetChunk:n,chunks:i}=e;"delete"===t&&(null==h||h(n),i&&(null==a||a(i))),"edit"===t&&v(n)},[])),(0,o.useEffect)(()=>{p(n)},[n]),f)?(0,s.jsx)("div",{className:"flex flex-col gap-2 w-full h-full",children:f.map(e=>(0,s.jsx)(j,{editor:y,chunks:u,levelDocumentTree:e,activeChunkInfo:m,isActiveChunk:b,setActiveChunkWithLevel:v,selectionIDs:r,readonly:t,saveChunk:x,setChunks:p},e.text_knowledge_editor_chunk_uuid))}):null},j=e=>{var t,n,i,r,o,{levelDocumentTree:l,selectionIDs:d,chunks:c,activeChunkInfo:h,isActiveChunk:u,setActiveChunkWithLevel:f,readonly:m,editor:w,saveChunk:_,setChunks:S}=e,E=(null==l?void 0:null===(t=l.children)||void 0===t?void 0:t.length)?(0,s.jsxs)("div",{className:"flex w-full",children:[(0,s.jsx)("div",{className:"w-6 shrink-0"}),(0,s.jsx)("div",{className:"flex flex-col w-[calc(100%-24px)] gap-2",children:l.children.map(e=>(0,s.jsx)(j,{editor:w,chunks:c,saveChunk:_,levelDocumentTree:e,selectionIDs:d,activeChunkInfo:h,isActiveChunk:u,setActiveChunkWithLevel:f,readonly:m,setChunks:S},e.text_knowledge_editor_chunk_uuid))})]}):null;return l?(0,s.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[["title","section-title","page-title"].includes(l.type)?(0,s.jsx)(p,{title:l.text,id:x(l.id)}):null,["section-text","text","header-footer","caption","header","footer","formula","footnote","toc","code","table"].includes(l.type)?(0,s.jsx)("div",{children:u(l.renderLevel)?(0,s.jsx)(y.R,{editor:w,editorContextMenuItemsRegistry:v.p,onBlur:e=>{null==_||_((0,a.Pd)(l,e))}}):(0,s.jsx)(b.i,{chunk:l,readonly:m,chunks:c,locateId:x(l.id),hoverEditBarActionsRegistry:N,previewContextMenuItemsRegistry:M,onActivateEditMode:e=>{f(e)}})},l.text_knowledge_editor_chunk_uuid):null,["image"].includes(l.type)?(0,s.jsx)(g,{base64:null!==(i=l.image_detail.base64)&&void 0!==i?i:"",htmlText:l.html_text||l.text,link:null!==(r=null===(n=l.image_detail.links)||void 0===n?void 0:n[0])&&void 0!==r?r:"",caption:null!==(o=l.image_detail.caption)&&void 0!==o?o:"",locateId:x(l.id),selected:null==d?void 0:d.includes(l.id.toString())}):null,E]},l.text_knowledge_editor_chunk_uuid):null}},68851:function(e,t,n){"use strict";n.d(t,{Gf:function(){return o},PU:function(){return d},Qe:function(){return l},bc:function(){return c},k8:function(){return s},wL:function(){return a}});var i=n(801815),r=n(757208),s=e=>{var t=(0,i.x0)();return{text_knowledge_editor_chunk_uuid:(0,i.x0)(),local_slice_id:t,slice_id:t,sequence:e.sequence,content:""}},o=e=>{var{chunks:t,localChunkSliceId:n,newChunk:i}=e;return t.map(e=>e.local_slice_id===n?i:e)},a=(e,t)=>e.filter(e=>e.local_slice_id!==t),l=(e,t)=>e.filter(e=>e.slice_id!==t),d=(e,t)=>e.map(e=>e.slice_id===t.slice_id?t:e),c=e=>{var t;return{text_knowledge_editor_chunk_uuid:(0,i.x0)(),status:r.OL.FinishVectoring,content:e.content,sequence:e.sequence,slice_id:null!==(t=e.slice_id)&&void 0!==t?t:""}}},987633:function(e,t,n){"use strict";n.d(t,{PJ:function(){return o},Pd:function(){return s}});var i=n(808549),r=n(120454),s=(e,t)=>(0,r._)((0,i._)({},e),{content:t}),o=e=>{if(!e)return"";var t=e.match(RegExp("^<p>(.*?)<\\/p>$","s"));return t?t[1]:e}},17236:function(e,t,n){"use strict";n.d(t,{X:function(){return s}});var i=n(252237),r=n.n(i),s=()=>r()("[&_img]:relative [&_img]:block","[&_img]:my-3 [&_img]:bg-white [&_img]:rounded-md","[&_img]:max-w-[610px] [&_img]:max-h-[367px] [&_img]:w-auto","[&_img.ProseMirror-selectednode]:outline-2 [&_img.ProseMirror-selectednode]:outline [&_img.ProseMirror-selectednode]:outline-blue-500","[&_img.ProseMirror-selectednode]:shadow-md")},373025:function(e,t,n){"use strict";n.d(t,{X:function(){return s}});var i=n(252237),r=n.n(i),s=()=>r()("[&_table]:border-collapse [&_table]:m-0 [&_table]:w-full [&_table]:table-fixed [&_table]:overflow-hidden [&_table]:text-[0.9em]","[&_table_td]:border [&_table_th]:border [&_table_td]:border-[#ddd] [&_table_th]:border-[#ddd]","[&_table_td]:p-2 [&_table_th]:p-2","[&_table_td]:relative [&_table_th]:relative","[&_table_td]:align-top [&_table_th]:align-top","[&_table_td]:box-border [&_table_th]:box-border","[&_table_td]:border-solid [&_table_th]:border-solid","[&_table_td]:min-w-[100px] [&_table_th]:min-w-[100px]")},636436:function(e,t,n){"use strict";n.d(t,{I:function(){return s}});var i=n(252237),r=n.n(i),s=()=>r()("[&_p]:break-words [&_p]:whitespace-pre-wrap","[&_.ProseMirror_*]:break-words [&_.ProseMirror_*]:whitespace-pre-wrap","[&_.editor-paragraph]:min-h-[1.5em] [&_.editor-paragraph]:leading-normal","[&_.editor-paragraph:empty]:min-h-[1.5em] [&_.editor-paragraph:empty]:block")},819195:function(e,t,n){"use strict";n.d(t,{k:function(){return i}});var i=e=>e?r(e.isEmpty?"":e.getHTML()):"",r=e=>{if(!e)return"";var t=new DOMParser().parseFromString(e,"text/html");return t.querySelectorAll("p.text-knowledge-tiptap-editor-paragraph").forEach(e=>{var t=e.parentNode;if(t){for(var n=document.createDocumentFragment();e.firstChild;)n.appendChild(e.firstChild);t.replaceChild(n,e)}}),t.body.innerHTML}},976482:function(e,t,n){"use strict";n.d(t,{F:()=>r});var i=["img","table","colgroup","col","tbody","thead","tfoot","tr","td","th","br","p"],r=e=>""===e?"":(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i;if(!e)return"";var n=t.join("|"),r=RegExp("<(?!(".concat(n,")\\b[^>]*>|\\/(?:").concat(n,")>)"),"g");return e.replace(r,"<")})(e).replace(/\n/g,"<br />")},431282:function(e,t,n){"use strict";n.d(t,{zd:()=>s}),n("69258");var i=n("825955"),r=n("735114"),s=e=>{var{data:t,loading:n,error:s}=(0,r.Z)((0,i._)(function*(){if(!e)return null;var t=yield fetch(e,{cache:"no-cache"});if(!t.ok)throw Error("Failed to fetch content");return t.json()}),{refreshDeps:[e]});return{content:t,loading:n,error:s}}},616426:function(e,t,n){"use strict";n.d(t,{ZK:()=>i.Z,mm:()=>l});var i=n("69258"),r=n("808549"),s=n("120454"),o=n("157728"),a=n("937393"),l=()=>{var e=(0,o.useNavigate)(),t=(0,a.S)();return(n,i)=>{if("string"==typeof n){var o=new URL(n.startsWith("/")?n:"".concat(location.pathname,"/").concat(n),window.location.origin);Object.entries(t).forEach(e=>{var[t,n]=e;n&&!o.searchParams.has(t)&&o.searchParams.set(t,n)});var{pathname:a,search:l}=o;return e("".concat(a).concat(l),i)}if(d(n)){var{search:h}=n,u=new URLSearchParams(h);return Object.entries(t).forEach(e=>{var[t,n]=e;n&&!u.has(t)&&u.set(t,n)}),e((0,s._)((0,r._)({},n),{search:u.toString()}),i)}return c(n)?e(n):e(n,i)}},d=e=>"object"==typeof e,c=e=>"number"==typeof e},69258:function(e,t,n){"use strict";n.d(t,{Z:function(){return h}});var i=n(825955),r=n(735114),s=n(214942),o=n(297158),a=n(336205),l=n(727914),d=n(382534),c=n(659596),h=e=>{var t=(0,s.rY)(e=>e.space.id),n="dataset-".concat(e.datasetID),h=(0,o.UQ)();return(0,r.Z)((0,i._)(function*(){if(!e.datasetID)throw new l.sH("useListDataSetReq_error","datasetid cannot be empty");var n,i=yield d.MJ.ListDataset({filter:{dataset_ids:[e.datasetID]},space_id:t});if(null==i?void 0:i.total)return null==i?void 0:null===(n=i.dataset_list)||void 0===n?void 0:n.find(t=>t.dataset_id===e.datasetID);(null==i?void 0:i.total)!==0&&h(new l.sH("useListDataSetReq_error",i.msg||""))}),{cacheKey:n,setCache:e=>sessionStorage.setItem(n,JSON.stringify(e)),getCache:()=>JSON.parse(sessionStorage.getItem(n)||"{}"),onError:e=>{c.FN.error({content:a.o.t("Network_error"),showClose:!1}),h(e)}})}},937393:function(e,t,n){"use strict";n.d(t,{S:function(){return i}});var i=()=>{var e=new URLSearchParams(location.search);return Object.fromEntries(Object.entries({biz:e.get("biz"),bot_id:e.get("bot_id"),workflow_id:e.get("workflow_id"),agent_id:e.get("agent_id"),page_mode:e.get("page_mode")}).filter(e=>!!e[1]))}},331362:function(e,t,n){"use strict";n.d(t,{z:()=>rc,g:()=>rn});var i,r,s,o,a,l,d,c,h,u,p,f,m,g=n("962289"),v=n("537714"),b=n("151064"),y=n("336205"),x=n("222363"),w=n("64605"),_=n("659596"),S=n("407821"),E=n.n(S),C=n("472772"),A=n.n(C),k=n("395245"),T=n.n(k),M=n("297998"),D=n.n(M),O=n("646576"),I=n.n(O),N=n("606121"),R=n.n(N),L=n("135987"),P={};P.styleTagTransform=R(),P.setAttributes=D(),P.insert=T().bind(null,"head"),P.domAPI=A(),P.insertStyleElement=I(),E()(L.Z,P);var j=L.Z&&L.Z.locals?L.Z.locals:void 0,F=e=>{var t,n,i,{controls:r}=e,s=[];if((t=r)&&(0,x.Z)(t))s=r;if((n=r)&&(0,w.Z)(n)&&(0,g.Z)(n,"btns")&&(0,g.Z)(n,"prefix"))({btns:s,prefix:i}=r);return(0,b.jsxs)("div",{className:j["upload-footer"],children:[i,s.map(e=>{var t=e.disableHoverContent&&e.status===v.xZ.DISABLE,n=(0,b.jsx)(_.zx,{"data-testid":e.e2e,disabled:e.status===v.xZ.DISABLE,loading:e.status===v.xZ.LOADING,color:e.type||"hgltplus",onClick:e.onClick,children:e.text},e.text);return t?(0,b.jsx)(_.u,{content:e.disableHoverContent,children:n}):n})]})},B=n("455069"),z=n("695673"),H=n("523652"),U=n("382534"),V=n("836511"),$=n("272661");(0,$.L)("editor-toolbar-actions").registerSome([{type:"upload-image",module:{Component:V.IF}}]),(0,$.L)("editor-context-actions").registerSome([{type:"upload-image",module:{Component:V.E1}}]);var W=n("637667"),G={};G.styleTagTransform=R(),G.setAttributes=D(),G.insert=T().bind(null,"head"),G.domAPI=A(),G.insertStyleElement=I(),E()(W.Z,G),W.Z&&W.Z.locals&&W.Z.locals;var Z=n("392902"),q=n("263825"),K=n("22916"),Y=n("385038"),X=n("280053"),J=n("298203"),Q=n("237365"),ee=n("936731"),et=n("274971"),en=n("561119"),ei=n("14909"),er={};er.styleTagTransform=R(),er.setAttributes=D(),er.insert=T().bind(null,"head"),er.domAPI=A(),er.insertStyleElement=I(),E()(ei.Z,er);var es=ei.Z&&ei.Z.locals?ei.Z.locals:void 0,eo=(e,t,n)=>{var i=(null==t?void 0:t.statusDesc)||y.o.t("datasets_unit_upload_fail");if(e===en.N.Failed)return(0,b.jsx)("div",{"data-dtestid":"".concat(Y.w.CreateUnitListProgressName,".","subText"),className:"text-12px",children:i});var r="";if(n){var s,o,a=isNaN(o="string"==typeof(s=(null==t?void 0:t.update_interval)||0)?parseInt(s):s)?0:o/24;r=(0,et.hd)(a)}else r=(0,J.td)((null==t?void 0:t.size)||0);return(0,b.jsx)("div",{"data-dtestid":"".concat(Y.w.CreateUnitListProgressName,".").concat(null==t?void 0:t.name),className:"coz-fg-secondary text-12px",children:r})},ea=e=>{var{progressList:t,createStatus:n}=e,i=(0,K.kF)(),r=(0,B.useMemo)(()=>{var e=y.o.t("datasets_createFileModel_step4_processing");return n===v.uy.TASK_FINISH&&(e=t.every(e=>e.status===X._m.Failed)?y.o.t("datasets_createFileModel_step4_failed"):y.o.t("datasets_createFileModel_step4_Finish")),e},[n,t]),s=i.type,o=(0,q.HA)(s),a=[v.Cm.TABLE_API,v.Cm.TABLE_FEISHU,v.Cm.TABLE_GOOGLE_DRIVE,v.Cm.TABLE_LARK,v.Cm.TEXT_FEISHU,v.Cm.TEXT_LARK,v.Cm.TEXT_NOTION,v.Cm.TEXT_URL,v.Cm.TEXT_GOOGLE_DRIVE].includes(s),l=(e,t)=>{var n,{minutes:i,seconds:r}={minutes:Math.floor((n=t)/60),seconds:n%60},s=y.o.t("knowledge_upload_remaining_time_text",{minutes:i,seconds:r});return e<100?"".concat(e,"% ").concat(Number(t)>0?"(".concat(s,")"):""):null};return(0,b.jsx)("div",{className:es["embed-progress"],children:(0,b.jsxs)("div",{className:es["progress-info"],children:[(0,b.jsx)("div",{className:es.text,"data-testid":Y.w.CreateUnitProgressTitle,children:r}),(0,b.jsx)("div",{className:es["progress-list"],children:t.map(e=>{var{status:t}=e,n=[X._m.Failed,X._m.AuditFailed].includes(t)?en.N.Failed:[X._m.Processing,X._m.Resegment,X._m.Refreshing].includes(t)?en.N.Processing:[X._m.Enable,X._m.Disable].includes(t)?en.N.Complete:en.N.Processing,i=(null==e?void 0:e.progress)||10;return(0,b.jsx)(ee.v,{className:es["data-processing"],mainText:null==e?void 0:e.name,subText:eo(n,e,a),tipText:eo(n,e,a),status:n,avatar:(0,Q.a)({type:null==e?void 0:e.type,url:null==e?void 0:e.url,formatType:o}),percent:i,percentFormat:l(i,null==e?void 0:e.remaining_time),actions:[en.N.Complete?(0,b.jsx)("div",{className:es["finish-text"],"data-testid":"".concat(Y.w.CreateUnitListProgressSuccessIcon,".").concat((null==e?void 0:e.name)||""),children:y.o.t("datasets_unit_process_success")}):null]},null==e?void 0:e.documentId)})})]})})},el=n("270917"),ed=n("47522"),ec=n("763055"),eh=n("775699"),eu=n("343155"),ep={};ep.styleTagTransform=R(),ep.setAttributes=D(),ep.insert=T().bind(null,"head"),ep.domAPI=A(),ep.insertStyleElement=I(),E()(eu.Z,ep);var ef=eu.Z&&eu.Z.locals?eu.Z.locals:void 0,em=e=>{var{fetchTableInfo:t}=e;return(0,b.jsx)(eh.YZ,{className:ef["load-failure"],empty:{title:"Read failure",description:"",icon:(0,b.jsx)(ec.xs,{}),btnText:"Retry",btnOnClick:t}})},eg=()=>(0,b.jsxs)("div",{className:ef.loading,children:[(0,b.jsx)(_.yC,{spinning:!0}),(0,b.jsx)("div",{className:ef["loading-content"],children:y.o.t("knowledge_1221_03")})]}),ev=()=>(0,b.jsx)(_.jL,{style:{marginTop:"10px"},type:"warning",description:y.o.t("knowledge_limit_20")}),eb=n("252237"),ey=n.n(eb),ex=n("893121"),ew={};ew.styleTagTransform=R(),ew.setAttributes=D(),ew.insert=T().bind(null,"head"),ew.domAPI=A(),ew.insertStyleElement=I(),E()(ex.Z,ew),ex.Z&&ex.Z.locals&&ex.Z.locals;var e_=n("49630"),eS={};eS.styleTagTransform=R(),eS.setAttributes=D(),eS.insert=T().bind(null,"head"),eS.domAPI=A(),eS.insertStyleElement=I(),E()(e_.Z,eS),e_.Z&&e_.Z.locals&&e_.Z.locals;var eE=n("528751"),eC=n("417478"),eA={};eA.styleTagTransform=R(),eA.setAttributes=D(),eA.insert=T().bind(null,"head"),eA.domAPI=A(),eA.insertStyleElement=I(),E()(eC.Z,eA),eC.Z&&eC.Z.locals&&eC.Z.locals;var ek=n("873183");function eT(e){var{header:t,keepDOM:n,children:i}=e,[r,s]=(0,B.useState)(!0);return(0,b.jsxs)("div",{className:"mb-[4px]",children:[(0,b.jsxs)("div",{className:ey()("h-[40px] flex items-center gap-[4px] shrink-0 rounded","cursor-pointer hover:coz-mg-secondary-hovered active:coz-mg-secondary-pressed"),onClick:()=>s(!r),children:[(0,b.jsx)(ek.x5d,{className:ey()("coz-fg-secondary text-[14px] m-[4px]",{"rotate-90":r})}),(0,b.jsx)(_.ZT.Text,{fontSize:"14px",weight:400,children:t})]}),(0,b.jsx)(_.zF,{className:"ml-[26px] [&>div]:pt-[4px]",isOpen:r,keepDOM:n,children:i})]})}var eM=n("848001"),eD={};eD.styleTagTransform=R(),eD.setAttributes=D(),eD.insert=T().bind(null,"head"),eD.domAPI=A(),eD.insertStyleElement=I(),E()(eM.Z,eD);var eO=eM.Z&&eM.Z.locals?eM.Z.locals:void 0;function eI(e){var{value:t,onChange:n,className:i,children:r}=e;return(0,b.jsx)(_.FX,{type:"pureCard",direction:"vertical",value:t,onChange:e=>{null==n||n(e.target.value)},className:ey()(eO["card-radio-group"],i),children:r})}var eN=n("808549"),eR=n("120454"),eL=n("479910"),eP=n("598208"),ej=n("871873"),eF=n("288391"),eB=()=>({createStatus:v.uy.UPLOAD_UNIT,progressList:[],unitList:[],currentStep:0,segmentRule:eE.v1,segmentMode:eF.OX.AUTO,enableStorageStrategy:!1,storageLocation:X.Ac.Default,openSearchConfig:{},testConnectionSuccess:!1}),ez=e=>(0,eR._)((0,eN._)({},eB()),{setCurrentStep:t=>{e({currentStep:t})},setCreateStatus:t=>{e({createStatus:t})},setProgressList:t=>{e({progressList:t})},setUnitList:t=>{e({unitList:t})},setSegmentRule:t=>e({segmentRule:t}),setSegmentMode:t=>e({segmentMode:t}),setEnableStorageStrategy:t=>{e({enableStorageStrategy:t})},setStorageLocation:t=>{e({storageLocation:t})},setOpenSearchConfig:t=>{e({openSearchConfig:t})},setTestConnectionSuccess:t=>{e({testConnectionSuccess:t})},reset:()=>{e(eB())}});var eH=((i={})[i.SEGMENT_CLEANER=0]="SEGMENT_CLEANER",i[i.EMBED_PROGRESS=1]="EMBED_PROGRESS",i),eU=()=>(0,eR._)((0,eN._)({},eB()),{currentStep:eH.SEGMENT_CLEANER,parsingStrategy:{parsing_type:X.lC.AccurateParsing,image_extraction:!0,image_ocr:!1,table_extraction:!0},filterStrategy:[],indexStrategy:{},documentInfo:null,levelChunkStrategy:{maxLevel:3}}),eV=n("473980"),e$=n("664319"),eW=n("346707"),eG=n("888711"),eZ=n("825955"),eq=n("735114"),eK=n("745474"),eY=n("458620"),eX=(e,t)=>{var n,{run:i}=(0,eq.Z)((n=(0,eZ._)(function*(t){var n=yield U.MJ.ListDocument(t);e&&e(n)}),function(e){return n.apply(this,arguments)}),{onError:e=>{eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeGetTableInfo,error:e}),t&&t()},manual:!0});return i},eJ=e=>{var t,n=(0,K.kF)();var{run:i}=(0,eq.Z)((t=(0,eZ._)(function*(t){var i=yield U.MJ.CreateDocument((0,eN._)({dataset_id:n.datasetID},t));(null==e?void 0:e.onSuccess)&&e.onSuccess(i)}),function(e){return t.apply(this,arguments)}),{onError:t=>{eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeCreateDocument,error:t}),(null==e?void 0:e.onFail)&&e.onFail(t)},manual:!0});return i},eQ=e=>{var{segmentRule:t,onChange:n}=e,{separator:i,maxTokens:r,preProcessRules:s,overlap:o}=t;return(0,b.jsxs)("div",{className:"flex flex-col gap-[12px] mt-12px",children:[(0,b.jsxs)("div",{"data-testid":Y.w.ResegmentCustomIdentifierSelect,children:[(0,b.jsx)(_.l0.Label,{required:!0,children:y.o.t("datasets_Custom_segmentID")}),(0,b.jsx)(_.Ph,{placeholder:y.o.t("datasets_custom_segmentID_placeholder"),optionList:(0,eE.Px)(),className:"w-full",value:i.type,onChange:e=>{"string"==typeof e&&n((0,eR._)((0,eN._)({},t),{separator:{type:e,customValue:i.customValue}}))}}),i.type===eF.IB.CUSTOM?(0,b.jsx)(_.II,{className:"w-full mt-[4px]",value:i.customValue,onChange:e=>{n((0,eR._)((0,eN._)({},t),{separator:{type:i.type,customValue:e}}))},placeholder:y.o.t("datasets_custom_segmentID_placeholder")}):null]}),(0,b.jsxs)("div",{"data-testid":Y.w.ResegmentCustomMaxLenInput,children:[(0,b.jsx)(_.l0.Label,{required:!0,children:y.o.t("datasets_Custom_maxLength")}),(0,b.jsx)(_.k7,{value:r,onChange:e=>{var i;n((0,eR._)((0,eN._)({},t),{maxTokens:(i=Number(e))<100?100:i>5e3?5e3:i}))},className:"w-full",min:100,max:5e3})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)(_.l0.Label,{required:!0,children:y.o.t("kl_write_014")}),(0,b.jsx)(_.k7,{value:o,onChange:e=>{n((0,eR._)((0,eN._)({},t),{overlap:Number(e)}))},className:"w-full",max:90,min:0})]}),(0,b.jsxs)("div",{"data-testid":Y.w.ResegmentCustomRuleText,children:[(0,b.jsx)(_.l0.Label,{children:y.o.t("datasets_Custom_rule")}),(0,b.jsxs)(_.cO,{value:s,className:"w-full gap-[4px]","aria-label":y.o.t("datasets_Custom_rule"),onChange:e=>{n((0,eR._)((0,eN._)({},t),{preProcessRules:e}))},children:[(0,b.jsx)(_.XZ,{value:eF.dV.REMOVE_SPACES,children:y.o.t("datasets_Custom_rule_replace")}),(0,b.jsx)(_.XZ,{value:eF.dV.REMOVE_EMAILS,children:y.o.t("datasets_Custom_rule_delete")})]})]})]})},e0=e=>{var{segmentMode:t,segmentRule:n,onChange:i}=e;return(0,b.jsx)(_.Y8,{"data-testid":Y.w.CreateUnitResegmentCustomRadio,className:ey()(t===eF.OX.CUSTOM?"custom-wrapper":""),value:eF.OX.CUSTOM,extra:(0,b.jsxs)(b.Fragment,{children:[y.o.t("datasets_createFileModel_step3_customDescription"),t===eF.OX.CUSTOM&&(0,b.jsx)(eQ,{segmentRule:n,onChange:e=>{i({segmentRule:e})}})]}),children:y.o.t("datasets_createFileModel_step3_custom")})},e1=()=>(0,b.jsx)(_.Y8,{"data-testid":Y.w.CreateUnitResegmentAutoRadio,value:eF.OX.AUTO,extra:y.o.t("datasets_createFileModel_step3_autoDescription"),children:y.o.t("datasets_createFileModel_step3_auto")}),e2=e=>{var{segmentMode:t,segmentRule:n=eE.v1,onChange:i}=e;return(0,b.jsx)(b.Fragment,{children:(0,b.jsx)(eT,{header:y.o.t("kl_write_011"),children:(0,b.jsxs)(eI,{value:t,onChange:e=>{i({segmentMode:e,segmentRule:n})},children:[(0,b.jsx)(e1,{}),(0,b.jsx)(e0,{segmentMode:t,segmentRule:n,onChange:i})]})})})},e5=e=>{var[t,n]=(0,B.useState)([]),{useStore:i,footer:r}=e,s=(0,B.useRef)(),{setCurrentStep:o,segmentRule:a,segmentMode:l,parsingStrategy:d,filterStrategy:c}=i((0,e$.N)(e=>({setCurrentStep:e.setCurrentStep,segmentRule:e.segmentRule,segmentMode:e.segmentMode||eF.OX.AUTO,parsingStrategy:e.parsingStrategy,filterStrategy:e.filterStrategy}))),{setSegmentMode:h,setParsingStrategyByMerge:u,setSegmentRule:p,setFilterStrategy:f}=i.getState(),m=(0,K.kF)(),g=eX(e=>{var t=null===(l=e.document_infos)||void 0===l?void 0:l[0];if(!t)return;var i=(0,et.VR)(t);if(!!i){var{docInfo:r}=i,o=(0,eV._)(i,["docInfo"]);p(o.segmentRule),h(o.segmentMode),u(null!==(m=r.parsing_strategy)&&void 0!==m?m:{}),null===(d=s.current)||void 0===d||d.setValues(null!==(g=r.parsing_strategy)&&void 0!==g?g:{});var a=(null===(c=r.type)||void 0===c?void 0:c.toLocaleLowerCase())==="pdf";if(r.filter_strategy&&a){var l,d,c,m,g,v,b,y,x,w,_,S,E,C,[A=0,k=0,T=0,M=0]=null!==(x=r.filter_strategy.filter_box_position)&&void 0!==x?x:[],D=[{uri:null!==(w=r.tos_uri)&&void 0!==w?w:"",filterPagesConfig:null!==(_=null===(b=r.filter_strategy)||void 0===b?void 0:null===(v=b.filter_page)||void 0===v?void 0:v.map(e=>({pageIndex:e,isFilter:!0})))&&void 0!==_?_:[],cropperSizePercent:{topPercent:A,rightPercent:k,bottomPercent:T,leftPercent:M}}];f(D),null===(y=s.current)||void 0===y||y.setValue("filterStrategy",D),n([{uri:null!==(S=r.tos_uri)&&void 0!==S?S:"",url:null!==(E=r.web_url)&&void 0!==E?E:"",name:null!==(C=r.name)&&void 0!==C?C:""}])}}});return(0,B.useEffect)(()=>{g({dataset_id:(null==m?void 0:m.datasetID)||"",document_ids:[(null==m?void 0:m.docID)||""]})},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(e2,{pdfList:t,segmentRule:a,segmentMode:l,parsingStrategy:d,filterStrategy:c,getParseFormApi:e=>{s.current=e},onChange:e=>{var{segmentRule:t,segmentMode:n,parsingStrategy:i,filterStrategy:r}=e;void 0!==t&&p(t),void 0!==n&&h(n),!(0,eW.Z)(i)&&u(i),!(0,eW.Z)(r)&&f(r)}}),null==r?void 0:r([{e2e:Y.w.ResegmentUploadUnitNextBtn,type:"hgltplus",theme:"solid",onClick:()=>o(eH.EMBED_PROGRESS),text:y.o.t("datasets_createFileModel_NextBtn"),status:(0,eG.Y)(l,a)}])]})},e3=n("937393"),e4=n("727914"),e6=e=>e.format_type===X.a5.Text&&e.source_type===X.NZ.Document,e8=e=>e.map(e=>e.isFilter?e.pageIndex:null).filter(e=>"number"==typeof e),e7=e=>e?{filter_strategy:{filter_page:e8(e.filterPagesConfig)}}:{},e9=n("896335"),te=n("653598"),tt=()=>{var e,t=(0,B.useRef)();(0,B.useEffect)(()=>()=>{(0,et.uA)(t)},[]);var n=(e=(0,eZ._)(function*(e,i){var{data:r=[]}=yield U.MJ.GetDocumentProgress({document_ids:e.map(e=>e.document_id).filter(e9.Z)}),s=e.map(e=>{var t,n,i,s,o,{document_id:a,uri:l}=e,d=r.find(e=>e.document_id===a);return(0,eR._)((0,eN._)({},d),{documentId:null!=a?a:"",progress:null!==(t=null==d?void 0:d.progress)&&void 0!==t?t:0,name:null!==(n=null==d?void 0:d.document_name)&&void 0!==n?n:"",uri:null!=l?l:"",status:null!==(i=null==d?void 0:d.status)&&void 0!==i?i:te._m.Processing,statusDesc:null!==(s=null==d?void 0:d.status_descript)&&void 0!==s?s:"",remainingTime:null!==(o=null==d?void 0:d.remaining_time)&&void 0!==o?o:0})});if((0,et.te)(r),i.onProgressing(s),(0,et.zP)(r)){i.onFinish();return}t.current=window.setTimeout(()=>n(e,i),eE.Yg)}),function(t,n){return e.apply(this,arguments)});return n},tn=(e,t)=>{var n,i=(0,K.kF)(),r=e(e=>e.setCreateStatus),s=e(e=>e.setProgressList),o=tt();var{run:a}=(0,eq.Z)((n=(0,eZ._)(function*(e){try{var n,a=yield U.MJ.CreateDocument((0,eN._)({dataset_id:i.datasetID},e)),{document_infos:l=[]}=a;l.length&&(yield o(l,{onProgressing:e=>{s(e)},onFinish:()=>{r(v.uy.TASK_FINISH)}})),(null==t?void 0:t.onSuccess)&&t.onSuccess(a)}catch(i){;s((null==e?void 0:null===(n=e.document_bases)||void 0===n?void 0:n.map(t=>(0,eR._)((0,eN._)({},t),{name:(null==t?void 0:t.name)||"unknown",documentId:"",uri:"",remainingTime:0,remaining_time:0,progress:100,status:te._m.Failed,statusDesc:null==i?void 0:i.message,format_type:null==e?void 0:e.format_type})))||[]),eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeCreateDocument,error:i}),(null==t?void 0:t.onFail)&&t.onFail(i)}}),function(e){return n.apply(this,arguments)}),{onError:e=>{eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeCreateDocument,error:e}),(null==t?void 0:t.onFail)&&t.onFail(e)},manual:!0});return a},ti=()=>{var e=(0,B.useRef)(v.zM.SIMPLE),t=eX(t=>{(null==t?void 0:t.total)===0&&(e.current=v.zM.HAD_SEGMENT_RULES)}),n=(0,K.kF)();return(0,B.useEffect)(()=>{n.datasetID&&t({dataset_id:n.datasetID})},[n.datasetID]),[void 0,e.current]},tr=()=>{var e=(0,B.useRef)(v.zM.SIMPLE),t=eX(t=>{(null==t?void 0:t.total)===0&&(e.current=v.zM.HAD_SEGMENT_RULES)}),n=(0,K.kF)();return(0,B.useEffect)(()=>{n.datasetID&&t({dataset_id:n.datasetID})},[n.datasetID]),[void 0,e.current]},ts=(e,t,n)=>{var i,r;if(e===eF.OX.AUTO)return{chunk_type:X.x2.DefaultChunk};if(e===eF.OX.LEVEL)return{chunk_type:X.x2.LevelChunk,max_level:null==n?void 0:n.maxLevel,save_title:null==n?void 0:n.isSaveTitle};return{separator:t.separator.type===eF.IB.CUSTOM?t.separator.customValue:t.separator.type,max_tokens:t.maxTokens,remove_extra_spaces:null==t?void 0:null===(i=t.preProcessRules)||void 0===i?void 0:i.includes(eF.dV.REMOVE_SPACES),remove_urls_emails:null==t?void 0:null===(r=t.preProcessRules)||void 0===r?void 0:r.includes(eF.dV.REMOVE_EMAILS),chunk_type:X.x2.CustomChunk,overlap:t.overlap}},to=e=>{var t,n=(0,K.kF)(),{segmentMode:i,segmentRule:r,setCreateStatus:s,setProgressList:o}=e((0,e$.N)(e=>({segmentMode:e.segmentMode,segmentRule:e.segmentRule,setCreateStatus:e.setCreateStatus,setProgressList:e.setProgressList}))),a=tt(),l=null!==(t=(0,et.td)())&&void 0!==t?t:"",{run:d}=(0,eq.Z)((0,eZ._)(function*(){if(!n.datasetID)throw _.FN.warning({content:y.o.t("datasets_ID_miss"),showClose:!1}),new e4.sH(eY.b.KnowledgeResegment,"".concat(eY.b.KnowledgeResegment,": missing datasets_id"));var{parsingStrategy:t,filterStrategy:d,documentInfo:c}=e.getState(),h=c&&e6(c);try{var{document_infos:u=[]}=yield U.MJ.Resegment((0,ej.Z)({},{dataset_id:n.datasetID,document_ids:[l],chunk_strategy:ts(i,r),parsing_strategy:h?t:void 0},e7(d.at(0))));Object.keys(u).length&&(s(v.uy.GET_TASK_PROGRESS),yield a(u,{onProgressing:e=>{o(e)},onFinish:()=>{s(v.uy.TASK_FINISH)}}),(0,et.As)(u,eY.b.KnowledgeProcessDocument))}catch(e){eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeProcessDocument,error:e})}}),{manual:!0});return d},ta=n("707140"),tl={};tl.styleTagTransform=R(),tl.setAttributes=D(),tl.insert=T().bind(null,"head"),tl.domAPI=A(),tl.insertStyleElement=I(),E()(ta.Z,tl);var td=ta.Z&&ta.Z.locals?ta.Z.locals:void 0,tc=e=>{var{useStore:t,footer:n}=e,i=(0,K.EV)(),r=t(e=>e.progressList),s=t(e=>e.createStatus),o=(0,K.kF)(),a=to(t);return(0,B.useEffect)(()=>{a()},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ea,{progressList:r,createStatus:s}),null==n?void 0:n({btns:[{e2e:Y.w.ResegmentUnitConfirmBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{var e,t=(0,e3.S)();null===(e=i.toResource)||void 0===e||e.call(i,"knowledge",o.datasetID,t)}}],prefix:(0,b.jsx)("span",{className:td["footer-sub-tip"],children:(0,et.mZ)(s)})})]})},th={steps:[{content:e=>(0,b.jsx)(e5,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step3"),step:eH.SEGMENT_CLEANER},{content:e=>(0,b.jsx)(tc,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step4"),step:eH.EMBED_PROGRESS}],createStore:()=>(0,eP.Ue)()((0,eL.mW)(function(e,t){for(var n=arguments.length,i=Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return(0,eR._)((0,eN._)({},ez(e,t,...i),eU()),{reset:()=>{e(eU())},setFilterStrategy:t=>{e({filterStrategy:t},!1,"setFilterStrategy")},setIndexStrategyByMerge:n=>{e({indexStrategy:(0,ej.Z)({},t().indexStrategy,n)},!1,"setIndexStrategyByMerge")},setParsingStrategyByMerge:n=>{e({parsingStrategy:(0,ej.Z)({},t().parsingStrategy,n)},!1,"setParsingStrategyByMerge")},setDocumentInfo:t=>e({documentInfo:t},!1,"setDocumentInfo"),setLevelChunkStrategy:(t,n)=>{e(e=>(0,eR._)((0,eN._)({},e),{levelChunkStrategy:(0,eR._)((0,eN._)({},e.levelChunkStrategy),{[t]:n})}))}})},{enabled:!1,name:"Coz.Data.TextResegment"})),showStep:!0},tu=()=>({createStatus:v.uy.UPLOAD_UNIT,progressList:[],unitList:[],currentStep:0,status:eE.c3.NORMAL,semanticValidate:{},tableData:{},originTableData:{},tableSettings:eE.Q,documentList:[]}),tp=(e,t)=>(0,eR._)((0,eN._)({},tu()),{setCurrentStep:t=>{e({currentStep:t})},setCreateStatus:t=>{e({createStatus:t})},setProgressList:t=>{e({progressList:t})},setUnitList:t=>{e({unitList:t})},setStatus:t=>{e({status:t})},setSemanticValidate:t=>{e({semanticValidate:t})},setTableData:t=>{e({tableData:t})},setOriginTableData:t=>{e({originTableData:t})},setTableSettings:t=>{e({tableSettings:t})},setDocumentList:t=>{e({documentList:t})},reset:()=>{e(tu())}}),tf=(e,t,n)=>(0,eR._)((0,eN._)({},tp(e,t,n)),{tableSettings:eE.z2,reset:()=>{e((0,eR._)((0,eN._)({},tu()),{tableSettings:eE.z2}))}}),tm=n("801815"),tg=n("788637"),tv=n("44172"),tb=n("672958"),ty=n("311807"),tx=n("189284"),tw=n("594022"),t_=n("861445"),tS=n("178385"),tE=e=>{var t=e(e=>e.unitList);return(0,B.useMemo)(()=>({tos_uri:(0,g.Z)(t,"0.uri",""),document_source:X.NZ.Document}),[t])},tC=e=>{var t,n=e(e=>e.setUnitList),i=e(e=>e.unitList);return t=(0,eZ._)(function*(e,t){try{var{fileInstance:r}=e;if(r){var{name:s}=r,o=(0,et.mD)(s),a=yield(0,et.y3)(r),l=yield U.nA.UploadFile({file_head:{file_type:o,biz_type:tS.ym.BIZ_BOT_DATASET},data:a});n((0,et.wV)({unitList:i,data:null==l?void 0:l.data,fileInstance:r,index:t}))}}catch(e){console.log(e)}}),function(e,n){return t.apply(this,arguments)}};var tA=((r={})[r.Text=0]="Text",r[r.Table=1]="Table",r),tk=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!e)return{};var{table_meta:n,preview_data:i}=e;if(!n||!i||!Object.keys(n).length||!Object.keys(i).length)return{};var r={};return Object.keys(n).forEach(e=>{r[e]={};var s=n[e];if(!Array.isArray(s))return{};s.forEach(n=>{var{column_type:s,sequence:o}=n;if(void 0!==o)r[e][o]={valid:!0,msg:""},i[e].slice(t).forEach(t=>{if(s===te.QD.Image){r[e][o]={valid:!1,msg:y.o.t("knowledge_insert_img_011")};return}})})}),r},tT=()=>({document_id:(0,et.td)(),table_data_type:tw.nZ.AllData});function tM(e){return e===eE.c3.LOADING}function tD(e){return e===eE.c3.ERROR}function tO(e,t,n){return e?((0,g.Z)(t,"table_meta.".concat(n[eE.hD.SHEET]))||[]).length>eE.pL:Object.keys((0,g.Z)(t,"preview_data.".concat(n[eE.hD.SHEET],".").concat(n[eE.hD.KEY_START_ROW]))||{}).length>eE.pL}function tI(e,t){return e?((e.table_meta||{})[t[eE.hD.SHEET]||0]||[]).map(e=>{var t;return(0,eR._)((0,eN._)({},e),{key:e.id,column_name:(null!==(t=e.column_name)&&void 0!==t?t:"").substring(0,eE.DU)})}):[]}function tN(e,t){if(!e)return v.xZ.DISABLE;var{table_meta:n}=e,i=(0,g.Z)(n,t[eE.hD.SHEET])||[],r=i.some(e=>{var t;return(null!==(t=e.column_name)&&void 0!==t?t:"")===""}),s=i.some(e=>{var t;return!(null!==(t=e.column_type)&&void 0!==t?t:"")}),o=i.some(e=>{var t,n;return(null===(t=(0,et.OP)(null!==(n=null==e?void 0:e.column_name)&&void 0!==n?n:""))||void 0===t?void 0:t.valid)===!1}),a=i.some(e=>!0===e.is_semantic),l=i.some(e=>i.filter(t=>t.column_name===e.column_name).length>=2);return!Object.keys(i).length||r||s||!a||o||i.length>eE.pL||l?v.xZ.DISABLE:v.xZ.ENABLE}function tR(e){return Array.isArray(e)&&e.length>0?(0,g.Z)(e,"0.documentId"):null}var tL=(e,t)=>{var n;return e.some(e=>!e.column_type)||!(null===(n=(0,et.OP)(t))||void 0===n?void 0:n.valid)||!e.some(e=>!0===e.is_semantic)||e.some(e=>{var t,n;return(null===(t=(0,et.OP)(null!==(n=e.column_name)&&void 0!==n?n:""))||void 0===t?void 0:t.valid)===!1})?v.xZ.DISABLE:v.xZ.ENABLE};function tP(e){var{spaceId:t,docId:n,datasetId:i,documentInfo:r}=e;return{space_id:t,document_id:n,dataset_id:i,format_type:tA.Table,document_bases:r,is_append:!0}}var tj=(e,t)=>{var n,{run:i}=(0,eq.Z)((n=(0,eZ._)(function*(t){e((yield U.v6.GetDocumentTableInfo(t)))}),function(e){return n.apply(this,arguments)}),{onError:e=>{eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeGetTableInfo,error:e}),t()},manual:!0});return i},tF=(e,t)=>{var n,{run:i}=(0,eq.Z)((n=(0,eZ._)(function*(n){try{var i,r,s,o=yield U.MJ.GetTableSchema(n),{table_meta:a,preview_data:l}=o,d=(0,eV._)(o,["table_meta","preview_data"]),c=(null==n?void 0:n.table_data_type)===tw.nZ.OnlyPreview?{preview_data:{["".concat((null===(i=n.table_sheet)||void 0===i?void 0:i.sheet_id)||"0")]:null!=l?l:[]}}:(0,eR._)((0,eN._)({},d),{table_meta:{["".concat((null===(r=n.table_sheet)||void 0===r?void 0:r.sheet_id)||"0")]:null!=a?a:[]},preview_data:{["".concat((null===(s=n.table_sheet)||void 0===s?void 0:s.sheet_id)||"0")]:null!=l?l:[]}});e(c)}catch(e){eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeGetTableInfo,error:e}),t()}}),function(e){return n.apply(this,arguments)}),{onError:e=>{eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeGetTableInfo,error:e}),t()},manual:!0});return i},tB=e=>{var t=e(e=>e.tableData),n=e(e=>e.setSemanticValidate),i=e(e=>e.setOriginTableData),r=e(e=>e.setTableData),s=e(e=>e.setStatus);return tF(e=>{var o=!(0,g.Z)(e,"table_meta"),a=o?(0,eR._)((0,eN._)({},t),{preview_data:(0,g.Z)(e,"preview_data")}):e;!o&&i(a),n(tk(a)),r(a),s(eE.c3.NORMAL)},()=>{console.log("setStatus(TableStatus.ERROR)"),s(eE.c3.ERROR)})},tz=e=>{var t,n,i,{type:r,docID:s,opt:o}=(0,K.kF)(),a=e(e=>e.setStatus),l=e(e=>e.setTableSettings),d=e(e=>{var t;return null!==(t=e.fileIdsMap)&&void 0!==t?t:{}}),c=e(e=>e.docInfo),h=e(e=>e.tosUrlRef),u=null!==(i=null===(t=d[null===(n=Object.keys(d))||void 0===n?void 0:n[0]])||void 0===t?void 0:t[0].source_file_id)&&void 0!==i?i:null==c?void 0:c.source_file_id,p=tB(e),f=tE(e),m=(0,et.V1)(null!=o?o:v.VP.ADD,r),b=(0,et.BD)(null!=o?o:v.VP.ADD);return(0,ty.Z)(e=>{a(eE.c3.LOADING);var t=r&&[v.Cm.TABLE_GOOGLE_DRIVE,v.Cm.TABLE_FEISHU].includes(r)?{tos_uri:r===v.Cm.TABLE_FEISHU?h:void 0,source_file_id:null!=u?u:void 0,document_source:r===v.Cm.TABLE_GOOGLE_DRIVE?X.NZ.GoogleDrive:X.NZ.FeishuWeb}:f;p({source_file:m?void 0:t,table_sheet:b||(0,g.Z)(t,"document_source")!==X.NZ.Web?{sheet_id:String(e.sheet_id),header_line_idx:String(e.header_line_idx),start_line_idx:String(e.start_line_idx)}:void 0,document_id:m||b?s:void 0,table_data_type:tw.nZ.AllData}),l(e)},500)},tH=(e,t)=>{var n,{run:i}=(0,eq.Z)((n=(0,eZ._)(function*(t){var n=yield U.MJ.ValidateTableSchema(t),i=(null==n?void 0:n.column_valid_result)||{};e(0===Object.keys(i).length&&(null==n?void 0:n.code)===0,i)}),function(e){return n.apply(this,arguments)}),{onError:e=>{eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeTableSchemaValid,error:e}),null==t||t(e)},manual:!0});return i},tU=(e,t)=>{var n,{run:i,loading:r}=(0,eq.Z)((n=(0,eZ._)(function*(t){e((yield U.MJ.CreateDocument(t)))}),function(e){return n.apply(this,arguments)}),{onError:e=>{eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeTableAddSegment,error:e}),null==t||t()},manual:!0});return{fetchAddSegment:i,addSegmentLoading:r}},tV=e=>{var t,n=e(e=>e.setStatus),i=e(e=>e.setCreateStatus),r=e(e=>e.setProgressList),s=tt(),{docID:o}=(0,K.kF)();var{fetchAddSegment:a}=tU((t=(0,eZ._)(function*(e){yield s([{document_id:o}],{onProgressing:e=>{r(e)},onFinish:()=>{i(v.uy.TASK_FINISH)}}),n(eE.c3.NORMAL)}),function(e){return t.apply(this,arguments)}),()=>{n(eE.c3.ERROR)});return a},t$=(e,t)=>{var n=(0,K.kF)(),{run:i}=(0,eq.Z)((0,eZ._)(function*(){if(!n.datasetID)throw new e4.sH(eY.b.KnowledgeListDocument,"".concat(eY.b.KnowledgeListDocument,": no datasetID"));if(!n.docID)throw new e4.sH(eY.b.KnowledgeListDocument,"".concat(eY.b.KnowledgeListDocument,": no docId"));var t,i=yield U.MJ.ListDocument({dataset_id:n.datasetID,document_ids:[n.docID]});e((null==i?void 0:null===(t=i.document_infos)||void 0===t?void 0:t.find(e=>e.document_id===n.docID))||{})}),{onError:e=>{eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeListDocument,error:e}),null==t||t()},manual:!0});return i},tW=()=>{var[e]=(0,tx.V)();return t_.xT.filter(t=>e["bot.data.knowledge_md_xls"]?!!t:".xls"!==t).join(",")};var tG=((s={})[s.CONFIGURATION=0]="CONFIGURATION",s[s.PREVIEW=1]="PREVIEW",s[s.PROCESSING=2]="PROCESSING",s),tZ=n("451357"),tq={};tq.styleTagTransform=R(),tq.setAttributes=D(),tq.insert=T().bind(null,"head"),tq.domAPI=A(),tq.insertStyleElement=I(),E()(tZ.Z,tq);var tK=tZ.Z&&tZ.Z.locals?tZ.Z.locals:void 0,tY=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.setCurrentStep),r=t(e=>e.status),s=t(e=>e.tableData),o=t(e=>e.originTableData),a=t(e=>e.tableSettings),l=t(e=>e.semanticValidate),d=t(e=>e.setTableData),c=t(e=>e.setStatus),h=t(e=>e.setSemanticValidate),u=(0,et.l$)(),p=tM(r),f=tD(r),m=tO(u,s,a),g=tI(s,a),v=tB(t),x=tT();return((0,B.useEffect)(()=>{!s.table_meta&&(c(eE.c3.LOADING),v(x))},[s]),p)?(0,b.jsx)(eg,{}):f?(0,b.jsx)(em,{fetchTableInfo:()=>{c(eE.c3.LOADING),v(x)}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:tK["table-resegment"],children:[(0,b.jsx)(Z.u3,{tipsNode:(0,b.jsxs)(b.Fragment,{children:[m?(0,b.jsx)(ev,{}):null,!g.length||(0,tg.Z)(o)?(0,b.jsx)(eh.YZ,{empty:{title:y.o.t("knowledge_1221_02"),icon:(0,b.jsx)(ec.xs,{})}}):null]}),showTitle:!0,initValid:!0,isDragTable:!0,baseKey:"".concat(a[eE.hD.SHEET],".").concat(a[eE.hD.KEY_START_ROW],"."),data:g,verifyMap:l[a[eE.hD.SHEET]]||{},setData:e=>{var t=a[eE.hD.SHEET],n=(0,eR._)((0,eN._)({},s),{table_meta:(0,eR._)((0,eN._)({},s.table_meta),{[t]:(e||[]).map((e,t)=>(0,eR._)((0,eN._)({},e),{sequence:t.toString()}))})});d(n),h(tk(n))},loading:p}),(0,b.jsx)(e=>{var{children:t}=e;return g.length>=eE.pL?(0,b.jsx)(_.u,{trigger:"hover",content:y.o.t("knowledge_1222_01"),children:t}):(0,b.jsx)(b.Fragment,{children:t})},{children:(0,b.jsx)(_.zx,{className:tK["add-btn"],color:"primary",disabled:g.length>=eE.pL,icon:(0,b.jsx)(tv.N_R,{}),onClick:()=>{var e,t,n=(0,tm.x0)(),i=a[eE.hD.SHEET];d((0,eR._)((0,eN._)({},s),{table_meta:(0,eR._)((0,eN._)({},s.table_meta),{[i]:null==s?void 0:null===(t=s.table_meta)||void 0===t?void 0:null===(e=t[i])||void 0===e?void 0:e.concat({id:n,key:n,column_name:"",is_semantic:!1,column_type:void 0,sequence:void 0,is_new_column:!0})})}))},children:y.o.t("datasets_segment_tableStructure_add_field")})})]}),n?n([{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),disableHoverContent:y.o.t("knowledge_multi_index_noti"),onClick:()=>{var e,t;i(tG.PREVIEW),v((0,eR._)((0,eN._)({},x),{table_data_type:tb.n.OnlyPreview,origin_table_meta:null==o?void 0:null===(e=o.table_meta)||void 0===e?void 0:e[0],preview_table_meta:((null==s?void 0:null===(t=s.table_meta)||void 0===t?void 0:t[0])||[]).map(e=>({column_name:e.column_name,column_type:e.column_type,desc:e.desc,id:(null==e?void 0:e.is_new_column)?"0":e.id,is_semantic:e.is_semantic,sequence:e.sequence}))}))},status:tN(s,a)}]):null]})},tX=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.tableData),r=t(e=>e.tableSettings),s=t(e=>e.setCurrentStep);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Z.IO,{data:i,settings:r}),n?n([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",text:y.o.t("datasets_createFileModel_previousBtn"),onClick:()=>{s(tG.CONFIGURATION)},status:v.xZ.ENABLE},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),onClick:()=>{s(tG.PROCESSING)},status:v.xZ.ENABLE}]):null]})},tJ=e=>{var t=e(e=>e.tableData),n=e(e=>e.setStatus),i=e(e=>e.setCreateStatus),r=e(e=>e.setProgressList),s=tt(),o=(0,et.td)(),{run:a}=(0,eq.Z)((0,eZ._)(function*(){try{var e;n(eE.c3.LOADING),yield U.MJ.UpdateDocument({document_id:o,table_meta:((null==t?void 0:null===(e=t.table_meta)||void 0===e?void 0:e[0])||[]).map(e=>({column_name:e.column_name,column_type:e.column_type,desc:e.desc,id:(null==e?void 0:e.is_new_column)?"0":e.id,is_semantic:e.is_semantic,sequence:e.sequence}))}),yield s([{document_id:o}],{onProgressing:e=>{r(e)},onFinish:()=>{i(v.uy.TASK_FINISH)}})}catch(e){eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeUpdateDocument,error:e})}finally{n(eE.c3.NORMAL)}}),{manual:!0});return a},tQ=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.progressList),r=t(e=>e.createStatus),s=(0,K.kF)(),o=(0,K.EV)(),a=(0,B.useMemo)(()=>tR(i),[i]),l=tJ(t);return(0,B.useEffect)(()=>{l()},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ea,{progressList:i,createStatus:r}),n?n([{e2e:Y.w.CreateUnitConfirmBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{var e;null===(e=o.toResource)||void 0===e||e.call(o,"knowledge",s.datasetID)},status:a?v.xZ.ENABLE:v.xZ.DISABLE}]):null]})},t0={steps:[{content:e=>(0,b.jsx)(tY,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_tab_step2"),step:tG.CONFIGURATION},{content:e=>(0,b.jsx)(tX,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_tab_step3"),step:tG.PREVIEW},{content:e=>(0,b.jsx)(tQ,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step4"),step:tG.PROCESSING}],createStore:()=>(0,eP.Ue)()((0,eL.mW)((e,t,n)=>(0,eN._)({},tf(e,t,n))))};var t1=((o={})[o.SEGMENT_CLEANER=0]="SEGMENT_CLEANER",o[o.SEGMENT_PREVIEW=1]="SEGMENT_PREVIEW",o[o.EMBED_PROGRESS=2]="EMBED_PROGRESS",o),t2=()=>({currentReviewID:void 0,selectionID:void 0,docReviewList:[]}),t5=e=>(0,eR._)((0,eN._)({},t2()),{setCurrentReviewID:t=>e(()=>({currentReviewID:t})),setSelectionIDs:t=>e(()=>({selectionIDs:t})),setDocReviewList:t=>e(()=>({docReviewList:t}))}),t3=()=>(0,eR._)((0,eN._)({},eB(),t2(),(0,K.G6)()),{currentStep:t1.SEGMENT_CLEANER,parsingStrategy:{parsing_type:X.lC.AccurateParsing,image_extraction:!0,table_extraction:!0,image_ocr:!1},indexStrategy:{},filterStrategy:[],levelChunkStrategy:{maxLevel:3,isSaveTitle:!0},documentInfo:null}),t4=n("417062"),t6=()=>(0,b.jsx)(_.Y8,{value:X.lC.FastParsing,extra:y.o.t("kl_write_005"),children:y.o.t("kl_write_004")}),t8=n("529801"),t7=e=>e.filter(e=>e.isFilter).map(e=>e.pageIndex).sort((e,t)=>e-t),t9=e=>e.join(" / "),ne=e=>{var{filterValue:t,pdfList:n}=e;return t.map(e=>{var t=n.find(t=>t.uri===e.uri);if(!t)return null;var i=t7(e.filterPagesConfig);if(!i.length)return null;var r=t9(i);return"".concat(t.name,": ").concat(y.o.t("data_filter_values",{filterPages:r}))}).filter(e=>!!e).join("\n")},nt=n("61111"),nn=e=>{var{id:t,onClick:n,title:i,selected:r,addonAfter:s}=e;return(0,b.jsxs)("div",{className:ey()("w-full h-8 px-2 py-[6px] rounded-[8px] hover:coz-mg-primary cursor-pointer flex flex-nowrap",r&&"coz-mg-primary"),onClick:()=>n(t),children:[(0,b.jsx)(_.ZT.Text,{className:"w-full coz-fg-primary text-[14px] leading-[20px] grow truncate",ellipsis:!0,children:i}),s]})},ni=e=>(0,b.jsxs)("div",{className:ey()("flex flex-col gap-1 h-full",e.className),children:[(0,b.jsx)("div",{className:"w-full pl-2 h-6 items-center flex",children:(0,b.jsx)("div",{className:"coz-fg-secondary text-[12px] font-[400] leading-4 shrink-0",children:y.o.t("kl_write_105")})}),(0,b.jsx)("div",{className:"flex flex-col gap-1 h-[150px] !overflow-scroll shrink-0",children:e.documents.map(t=>{if(!t.id)return null;var n=t7(t.filterPageConfigList),i=!!n.length,r=t9(n);return(0,b.jsx)(nn,{id:t.id,selected:t.id===e.value,onClick:t=>{e.onChange(t)},title:t.title,addonAfter:i?(0,b.jsx)(_.u,{content:y.o.t("data_filter_values",{filterPages:r}),children:(0,b.jsx)(_.Vp,{color:"primary",className:"flex-shrink-0",children:y.o.t("knowledge_new_002")})}):null})})})]}),nr=n("262941"),ns=n("90265"),no=n("876945"),na=n("828108"),nl=n.n(na);n("84094");var nd=e=>parseFloat(e.toFixed(2)),nc=e=>{var{data:t,pdfSize:{naturalHeight:n,naturalWidth:i}}=e,r=t.y,s=t.y+t.height,o=t.x,a=t.x+t.width;return{topPercent:nd(r/n),bottomPercent:nd((n-s)/n),leftPercent:nd(o/i),rightPercent:nd((i-a)/i)}},nh=e=>{var{cropSizePercent:{topPercent:t,bottomPercent:n,rightPercent:i,leftPercent:r},pdfSize:{naturalHeight:s,naturalWidth:o}}=e,a=r*o,l=t*s;return{scaleX:1,scaleY:1,rotate:0,x:a,y:l,width:o-a-o*i,height:s-l-s*n}};nr.GlobalWorkerOptions.workerSrc="//lf-cdn.coze.cn/obj/unpkg/pdfjs-dist/".concat(nr.version,"/build/pdf.worker.min.mjs");var nu=()=>({totalPages:0,currentPage:0,percentZoomRatio:100}),np=e=>{var t,{uri:n,url:i,onChange:r,className:s,initPageCropperSizePercent:o,filterPagesConfig:a,enableCropper:l}=e,{totalPages:d,currentPage:c,percentZoomRatio:h}=nu(),[u,p]=(0,B.useState)(!1),[f,m]=(0,B.useState)(d),[g,v]=(0,B.useState)(c),[x,w]=(0,B.useState)(h),S=(0,B.useRef)(null),E=(0,B.useRef)(),C=()=>{if(!!l&&!!S.current){var e={naturalHeight:S.current.height,naturalWidth:S.current.width};E.current=new(nl())(S.current,{dragMode:"crop",zoomable:!0,zoomOnWheel:!1,viewMode:2,modal:!1,background:!1,highlight:!0,crop:t=>{null==r||r({uri:n,filterPagesConfig:a,cropperSizePercent:nc({data:t.detail,pdfSize:e})})},data:o?nh({cropSizePercent:o,pdfSize:e}):void 0})}},A=(e,t)=>{var n=10;return"decrease"===t?e-n:e+n},k=e=>{w(t=>{var n,i=A(t,e);return null===(n=E.current)||void 0===n||n.zoomTo(i/100),i})},T=()=>{var e,{currentPage:t,totalPages:n,percentZoomRatio:i}=nu();v(t),m(n),w(i),null===(e=E.current)||void 0===e||e.destroy()};return(0,B.useEffect)(()=>(p(!0),()=>{var e;null===(e=E.current)||void 0===e||e.destroy()}),[g]),(0,B.useEffect)(()=>T,[n]),(0,b.jsxs)("div",{className:ey()("relative flex justify-center py-16px",s),children:[u?null:(0,b.jsx)("div",{className:"absolute left-8px top-8px",children:(0,b.jsx)(_.XZ,{checked:null===(t=a.find(e=>e.pageIndex===g))||void 0===t?void 0:t.isFilter,onChange:e=>{null==r||r((0,nt.Uy)({uri:n,filterPagesConfig:a,cropperSizePercent:l&&E.current?nc({data:E.current.getData(),pdfSize:E.current.getCanvasData()}):null},t=>{var n=t.filterPagesConfig.find(e=>e.pageIndex===g);if(!n){t.filterPagesConfig.push({pageIndex:g,isFilter:!!e.target.checked});return}n.isFilter=!!e.target.checked}))},children:y.o.t("kl_write_106")})}),u?(0,b.jsx)("div",{className:"absolute w-full flex items-center justify-center",style:{height:624},children:(0,b.jsx)(_.gb,{loading:!0})}):null,(0,b.jsx)("div",{style:{height:624,width:484},children:(0,b.jsx)(ns.Z,{className:"w-full",file:i,onLoadSuccess:e=>{var{numPages:t}=e;v(1),m(t)},loading:null,children:(0,b.jsx)(no.Z,{loading:(0,b.jsx)(_.gb,{loading:!0}),className:"w-full",height:624,width:484,canvasRef:S,pageNumber:g,onRenderSuccess:()=>{p(!1),C()},renderTextLayer:!1,renderAnnotationLayer:!1})})}),u?null:(0,b.jsxs)("div",{className:"absolute right-8px top-8px flex items-center p-[4px] rounded-normal coz-shadow-default",children:[(0,b.jsx)(_.hU,{onClick:()=>{v(e=>Math.max(e-1,1))},disabled:g<=1,icon:(0,b.jsx)(ek.$1i,{})}),(0,b.jsxs)("div",{children:[g,"/",f]}),(0,b.jsx)(_.hU,{onClick:()=>{v(e=>Math.min(e+1,f))},disabled:g>=f,icon:(0,b.jsx)(ek.x5d,{})}),l?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(_.iz,{margin:3,layout:"vertical"}),(0,b.jsx)(_.hU,{disabled:x<=h,onClick:()=>{k("decrease")},icon:(0,b.jsx)(ek.ozt,{})}),(0,b.jsxs)("div",{children:[x,"%"]}),(0,b.jsx)(_.hU,{onClick:()=>{k("increase")},icon:(0,b.jsx)(ek.PwN,{})})]}):null]})]})},nf=n("836894"),nm={};nm.styleTagTransform=R(),nm.setAttributes=D(),nm.insert=T().bind(null,"head"),nm.domAPI=A(),nm.insertStyleElement=I(),E()(nf.Z,nm);var ng=nf.Z&&nf.Z.locals?nf.Z.locals:void 0,nv=e=>{var t,n,i,r,s,{pdfList:o,value:a,onChange:l,onCancel:d}=e,c=(0,eV._)(e,["pdfList","value","onChange","onCancel"]),[h,u]=(0,B.useState)(null!==(i=null===(t=o.at(0))||void 0===t?void 0:t.uri)&&void 0!==i?i:""),p=null===(n=o.find(e=>e.uri===h))||void 0===n?void 0:n.url,f=null==a?void 0:a.find(e=>e.uri===h),m=(0,B.useRef)([]),g=e=>{m.current=e},v=()=>{null==l||l(m.current)};return(0,B.useEffect)(()=>{var e,t;if(!!c.visible)return u(null!==(t=null===(e=o.at(0))||void 0===e?void 0:e.uri)&&void 0!==t?t:""),g(null!=a?a:[]),()=>{m.current=[]}},[c.visible]),(0,b.jsx)(_.u_,(0,eR._)((0,eN._)({title:y.o.t("kl_write_103"),size:"xxl",maskClosable:!1,className:ng["filter-modal"],cancelText:y.o.t("Cancel"),okText:y.o.t("Confirm"),onCancel:e=>{v(),null==d||d(e)}},c),{children:(0,b.jsxs)("div",{className:ey()("flex h-full","border border-solid coz-stroke-primary rounded-[8px]","overflow-hidden"),children:[(0,b.jsx)(ni,{className:"w-240px p-[16px]",documents:o.map(e=>{var t,n,i;return{id:null!==(n=e.uri)&&void 0!==n?n:"",title:e.name,filterPageConfigList:null!==(i=null==a?void 0:null===(t=a.find(t=>t.uri===e.uri))||void 0===t?void 0:t.filterPagesConfig)&&void 0!==i?i:[]}}),value:h,onChange:u}),(0,b.jsx)("div",{className:"border-[0.5px] border-solid coz-stroke-primary h-full w-[1px]"}),h&&p?(0,b.jsx)(np,{enableCropper:!1,className:"flex-[1]",uri:h,url:p,onChange:e=>{if(!a){null==l||l([e]);return}var t=(0,nt.Uy)(a,t=>{var n=t.findIndex(t=>t.uri===e.uri);if(n<0){t.push(e);return}t[n]=e});null==l||l(t)},filterPagesConfig:null!==(r=null==f?void 0:f.filterPagesConfig)&&void 0!==r?r:[],initPageCropperSizePercent:null!==(s=null==f?void 0:f.cropperSizePercent)&&void 0!==s?s:null}):null]})}))},nb=(0,_.Q2)(e=>{var{value:t,onChange:n,pdfList:i}=e,[r,s]=(0,B.useState)(!1),o=i&&i.length>0,a=()=>{s(!1)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("label",{className:"leading-[20px] mb-[4px] flex items-center gap-[4px]",children:[(0,b.jsx)(_.ZT.Text,{fontSize:"14px",weight:500,children:y.o.t("kl_write_102")}),(0,b.jsx)(_.ZT.Text,{fontSize:"12px",link:o,disabled:!o,onClick:()=>{o&&s(!0)},children:y.o.t("kl_write_103")})]}),(0,b.jsx)(_.Kx,{disabled:!0,className:"!coz-mg-primary",autosize:{minRows:3,maxRows:6},value:t&&i?ne({filterValue:t,pdfList:i}):"",placeholder:y.o.t("kl_write_104")}),(0,b.jsx)(nv,{value:t,onChange:n,visible:r,onOk:a,onCancel:a,pdfList:null!=i?i:[]})]})}),ny="filterStrategy",nx="image_extraction",nw="image_ocr",n_="table_extraction",nS=e=>{var{pdfList:t}=e,n=(0,eV._)(e,["pdfList"]);return(0,b.jsx)(b.Fragment,{children:(0,b.jsxs)(_.l0,(0,eR._)((0,eN._)({className:"flex flex-col gap-[4px] [&_.semi-form-field]:p-0"},n),{children:[(0,b.jsx)("div",{className:"h-[24px] leading-[24px]",children:(0,b.jsx)(_.ZT.Text,{fontSize:"14px",weight:500,children:y.o.t("kl_write_100")})}),(0,b.jsxs)(_.l0.Checkbox,{noLabel:!0,field:nx,children:[y.o.t("kl_write_008"),(0,b.jsx)(_.u,{content:y.o.t("pic_not_supported"),children:(0,b.jsx)(ek.L03,{className:"coz-fg-secondary w-[14px] ml-[4px]"})})]}),(0,b.jsx)(_.l0.Checkbox,{noLabel:!0,field:nw,children:y.o.t("kl_write_009")}),(0,b.jsx)(_.l0.Checkbox,{noLabel:!0,field:n_,children:y.o.t("kl_write_010")}),(0,b.jsx)(nb,{field:ny,pdfList:t,noLabel:!0,fieldClassName:"!mt-[8px]"})]}))})},nE=e=>{var{parsingStrategy:t,filterStrategy:n,pdfList:i,getParseFormApi:r,onChange:s}=e;return(0,b.jsxs)(b.Fragment,{children:[y.o.t("kl_write_007"),(0,b.jsxs)("div",{className:ey()({hidden:(null==t?void 0:t.parsing_type)!==X.lC.AccurateParsing}),children:[(0,b.jsx)(_.iz,{margin:12}),(0,b.jsx)(nS,{getFormApi:r,pdfList:i,initValues:(0,eR._)((0,eN._)({},(0,t8.Z)(t,"parsing_type")),{filterStrategy:null!=n?n:[]}),onValueChange:e=>{var{filterStrategy:t}=e,n=(0,eV._)(e,["filterStrategy"]);s({parsingStrategy:(0,ej.Z)({},n),filterStrategy:t})}})]})]})},nC=e=>(0,b.jsx)(_.Y8,{value:X.lC.AccurateParsing,extra:(0,b.jsx)(nE,(0,eN._)({},e)),children:y.o.t("kl_write_006")}),nA=e=>{var{segmentMode:t,segmentRule:n=eE.v1,parsingStrategy:i,filterStrategy:r,onChange:s,pdfList:o,getParseFormApi:a}=e;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(eT,{keepDOM:!0,header:y.o.t("kl_write_032"),children:(0,b.jsxs)(eI,{value:null==i?void 0:i.parsing_type,onChange:e=>{s({parsingStrategy:{parsing_type:e}})},children:[(0,b.jsx)(nC,{parsingStrategy:i,filterStrategy:r,pdfList:o,getParseFormApi:a,onChange:s}),(0,b.jsx)(t6,{})]})}),(0,b.jsx)(eT,{header:y.o.t("kl_write_011"),children:(0,b.jsxs)(eI,{value:t,onChange:e=>{s({segmentMode:e,segmentRule:n})},children:[(0,b.jsx)(e1,{}),(0,b.jsx)(e0,{segmentMode:t,segmentRule:n,onChange:s})]})})]})},nk=e=>{var{useStore:t,footer:n}=e,i=(0,B.useRef)(),{setCurrentStep:r,segmentRule:s,segmentMode:o,parsingStrategy:a,filterStrategy:l}=t((0,e$.N)(e=>({setCurrentStep:e.setCurrentStep,segmentRule:e.segmentRule,segmentMode:e.segmentMode||eF.OX.AUTO,parsingStrategy:e.parsingStrategy,filterStrategy:e.filterStrategy}))),{setSegmentMode:d,setParsingStrategyByMerge:c,setSegmentRule:h,setFilterStrategy:u,setLevelChunkStrategy:p,setDocumentInfo:f}=t.getState(),{datasetID:m,docID:g}=(0,K.kF)(),v=eX(e=>{var t,n,r,s,o,a=null===(t=e.document_infos)||void 0===t?void 0:t[0];if(!a||!a.chunk_strategy)return;var l=a.chunk_strategy,u=(0,t4.VR)(a);if(!!u)d(u.segmentMode),h(u.segmentRule),c(null!==(r=a.parsing_strategy)&&void 0!==r?r:{}),null===(n=i.current)||void 0===n||n.setValues(null!==(s=a.parsing_strategy)&&void 0!==s?s:{}),p("maxLevel",null!==(o=l.max_level)&&void 0!==o?o:3),p("isSaveTitle",l.save_title),f(a)});return(0,B.useEffect)(()=>{g&&v({dataset_id:m||"",document_ids:g?[g]:[]})},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(nA,{segmentRule:s,segmentMode:o,parsingStrategy:a,filterStrategy:l,getParseFormApi:e=>{i.current=e},onChange:e=>{var{segmentRule:t,segmentMode:n,parsingStrategy:i,filterStrategy:r}=e;void 0!==t&&h(t),void 0!==n&&d(n),!(0,eW.Z)(i)&&c(i),!(0,eW.Z)(r)&&u(r)}}),null==n?void 0:n([{e2e:Y.w.ResegmentUploadUnitNextBtn,type:"hgltplus",theme:"solid",onClick:()=>r(t1.SEGMENT_PREVIEW),text:y.o.t("datasets_createFileModel_NextBtn"),status:(0,eG.Y)(o,s)}])]})},nT=e=>{var t,n=(0,K.kF)(),[i,r]=e(e=>[e.segmentMode,e.segmentRule]),[s,o]=e(e=>[e.setCreateStatus,e.setProgressList]),a=e(e=>e.docReviewList),l=tt(),d=null!==(t=n.docID)&&void 0!==t?t:"",{run:c}=(0,eq.Z)((0,eZ._)(function*(){if(!n.datasetID)throw _.FN.warning({content:y.o.t("datasets_ID_miss"),showClose:!1}),new e4.sH(eY.b.KnowledgeResegment,"".concat(eY.b.KnowledgeResegment,": missing datasets_id"));var{parsingStrategy:t,filterStrategy:c}=e.getState();try{var{document_infos:h=[]}=yield U.MJ.Resegment((0,ej.Z)({},{dataset_id:n.datasetID,document_ids:[d],review_ids:a.map(e=>e.review_id),chunk_strategy:ts(i,r),parsing_strategy:t},e7(c.at(0))));Object.keys(h).length&&(s(v.uy.GET_TASK_PROGRESS),yield l(h,{onProgressing:e=>{o(e)},onFinish:()=>{s(v.uy.TASK_FINISH)}}))}catch(e){eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeProcessDocument,error:e})}}),{manual:!0});return c},nM=n("356696"),nD={};nD.styleTagTransform=R(),nD.setAttributes=D(),nD.insert=T().bind(null,"head"),nD.domAPI=A(),nD.insertStyleElement=I(),E()(nM.Z,nD);var nO=nM.Z&&nM.Z.locals?nM.Z.locals:void 0,nI=e=>{var{useStore:t,footer:n}=e,i=(0,K.EV)(),r=t(e=>e.progressList),s=t(e=>e.createStatus),o=(0,K.kF)(),a=nT(t);return(0,B.useEffect)(()=>{a()},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ea,{progressList:r,createStatus:s}),null==n?void 0:n({btns:[{e2e:Y.w.ResegmentUnitConfirmBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{var e,t=(0,e3.S)();null===(e=i.toResource)||void 0===e||e.call(i,"knowledge",o.datasetID,t)}}],prefix:(0,b.jsx)("span",{className:nO["footer-sub-tip"],children:(0,et.mZ)(s)})})]})},nN=n("431282"),nR=n("347852"),nL=n("420998"),nP=e=>{var t,n,i,r,{docReviewList:s,setDocReviewList:o,currentReviewID:a,setCurrentReviewID:l,levelSegments:d,setLevelSegments:c,selectionIDs:h,setSelectionIDs:u,segmentMode:p,datasetID:f,segmentInfo:m}=e,[g,v]=(0,B.useState)(!0),x=s.find(e=>e.review_id===a),w=null==x?void 0:x.document_type,S=["docx","doc"].includes(null!=w?w:"")?null!==(n=null==x?void 0:x.preview_tos_url)&&void 0!==n?n:"":null!==(i=null==x?void 0:x.tos_url)&&void 0!==i?i:"",E=null!==(r=null==x?void 0:x.doc_tree_tos_url)&&void 0!==r?r:"",{loading:C,runAsync:A}=(0,eq.Z)((0,eZ._)(function*(){return 0===(yield U.MJ.SaveDocumentReview({review_id:a,dataset_id:f,doc_tree_json:JSON.stringify({chunks:d})})).code}),{manual:!0}),{runAsync:k}=(0,eq.Z)((0,eZ._)(function*(){var e,t=yield U.MJ.MGetDocumentReview({dataset_id:f,review_ids:s.map(e=>{var t;return null!==(t=e.review_id)&&void 0!==t?t:""})});0===t.code&&(null==o||o(null!==(e=t.reviews)&&void 0!==e?e:[]))}),{manual:!0}),{pdfNode:T,numPages:M,currentPage:D,onNext:O,onBack:I,scale:N,increaseScale:R,decreaseScale:L}=(0,nL.Is)({fileUrl:S}),{content:P,loading:j}=(0,nN.zd)((null==x?void 0:x.status)===X.CT.Enable&&E?E:void 0);(0,B.useEffect)(()=>{if(P){var e;c((0,nR.D)(null!==(e=null==P?void 0:P.chunks)&&void 0!==e?e:[],null==x?void 0:x.document_name))}},[P]);var F=e=>{switch(e){case X.CT.Failed:return(0,b.jsx)(_.Vp,{size:"mini",color:"red",children:y.o.t("knowlege_qqq_003")});case X.CT.Processing:return(0,b.jsx)(_.Vp,{size:"mini",children:y.o.t("knowlege_qqq_002")});case X.CT.Enable:default:return null}};return(0,b.jsx)("div",{className:"w-full grow flex flex-col item-center justify-center",children:(0,b.jsx)("div",{className:"flex w-full h-full border border-solid coz-stroke-primary coz-bg-max rounded-[8px]",children:(0,b.jsxs)("div",{className:"w-full h-full flex",children:[(0,b.jsxs)("div",{className:ey()("w-[300px] h-full px-4 flex flex-col","transition-all duration-100 ease-in-out",!g&&"!w-[0px] !p-0 !invisible"),children:[(0,b.jsxs)("div",{className:"w-full flex justify-between h-[48px] pl-[8px] items-center shrink-0",children:[(0,b.jsxs)("div",{className:"text-[14px] font-[500] leading-[20px] coz-fg-plus shrink-0 flex items-center gap-[4px]",children:[p===eF.OX.CUSTOM?y.o.t("datasets_createFileModel_step3_custom"):null,p===eF.OX.AUTO?y.o.t("datasets_createFileModel_step3_auto"):null,p===eF.OX.LEVEL?y.o.t("knowledge_level_001"):null,m?(0,b.jsx)(_.u,{content:m,style:{maxWidth:500},children:(0,b.jsx)(ek.L03,{className:"coz-fg-secondary cursor-pointer"})}):null]}),(0,b.jsx)(_.hU,{icon:(0,b.jsx)(ek.m7o,{}),color:"secondary",onClick:()=>{v(!1)}})]}),(0,b.jsx)(_.yC,{wrapperClassName:"w-full h-[500px] grow flex flex-col",childStyle:{width:"100%",height:"100%"},spinning:C||j,children:(0,b.jsx)(nL.yt,{list:s.map(e=>{var t,n,i,r;return{id:null!==(t=e.review_id)&&void 0!==t?t:"",title:null!==(n=e.document_name)&&void 0!==n?n:"",tosUrl:null!==(i=e.doc_tree_tos_url)&&void 0!==i?i:"",tag:F(null!==(r=e.status)&&void 0!==r?r:X.CT.Enable)}}),selectedID:a,onClick:(t=(0,eZ._)(function*(e){e!==a&&(yield A(),yield k(),c([])),l(e)}),function(e){return t.apply(this,arguments)}),levelSegments:d,setLevelSegments:c,setSelectionIDs:u,treeVisible:p===eF.OX.LEVEL})})]}),(0,b.jsxs)("div",{className:"h-full w-[calc(100%-300px)] flex grow",children:[(0,b.jsxs)("div",{className:ey()("h-full w-1/2 flex-1",g&&"border border-r-0 border-y-0 border-solid coz-stroke-primary","flex flex-col"),children:[(0,b.jsx)("div",{className:ey()("w-full flex justify-between h-[48px] px-[16px] items-center coz-bg-max","border border-x-0 border-t-0 border-solid coz-stroke-primary",!g&&"rounded-tl-[8px]"),children:(0,b.jsxs)("div",{className:"flex w-full h-full items-center justify-between",children:[(0,b.jsxs)("div",{className:"flex h-full items-center",children:[g?null:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(_.hU,{icon:(0,b.jsx)(ek.m7o,{className:"rotate-180"}),color:"secondary",className:"mr-[8px]",onClick:()=>{v(!0)}}),(0,b.jsx)("div",{className:"w-[1px] h-[12px] coz-mg-primary mr-[8px]"})]}),(0,b.jsx)("div",{className:"text-[14px] font-[500] leading-[20px] coz-fg-plus",children:y.o.t("knowledge_level_010")})]}),["pdf","docx","doc"].includes(null!=w?w:"")&&M>=1?(0,b.jsxs)("div",{className:"flex h-full items-center gap-[3px]",children:[(0,b.jsx)(_.hU,{icon:(0,b.jsx)(ek.$1i,{}),size:"small",color:"secondary",onClick:I}),(0,b.jsxs)("div",{className:"coz-fg-secondary text-[12px] font-[400] leading-[24px]",children:[D," / ",M]}),(0,b.jsx)(_.hU,{icon:(0,b.jsx)(ek.x5d,{}),size:"small",color:"secondary",onClick:O}),(0,b.jsx)("div",{className:"w-[1px] h-[12px] coz-mg-primary"}),(0,b.jsx)(_.hU,{icon:(0,b.jsx)(ek.ozt,{}),size:"small",color:"secondary",onClick:L}),(0,b.jsxs)("div",{className:"coz-fg-secondary text-[12px] font-[400] leading-[16px]",children:[Math.round(100*N),"%"]}),(0,b.jsx)(_.hU,{icon:(0,b.jsx)(ek.PwN,{}),size:"small",color:"secondary",onClick:R})]}):null]})}),(0,b.jsxs)("div",{className:"grow w-full h-[650px] flex flex-col items-center overflow-auto",children:["md"===w?(0,b.jsx)(nL.SA,{fileUrl:S}):null,"txt"===w?(0,b.jsx)(nL.Tn,{fileUrl:S}):null,["docx","pdf","doc"].includes(null!=w?w:"")?(0,b.jsx)("div",{className:"grow w-full",children:T}):null]})]}),(0,b.jsxs)("div",{className:ey()("h-full w-1/2 flex-1 coz-bg-max","border border-r-0 border-y-0 border-solid coz-stroke-primary","rounded-r-[8px]","flex flex-col"),children:[(0,b.jsx)("div",{className:ey()("w-full flex justify-between h-[48px] px-[16px] items-center","border border-x-0 border-t-0 border-solid coz-stroke-primary"),children:(0,b.jsx)("div",{className:"text-[14px] font-[500] leading-[20px] coz-fg-plus",children:y.o.t("knowledge_level_011")})}),(0,b.jsx)("div",{className:ey()("w-full h-[650px] grow flex flex-col items-center overflow-auto","p-4 pb-0"),children:(0,b.jsx)(_.yC,{wrapperClassName:"!w-full min-h-[650px] grow",childStyle:{width:"100%",minHeight:"100%"},spinning:!P,children:(0,b.jsx)(H.pR,{readonly:!0,documentId:null!=a?a:"",selectionIDs:h,chunks:d.map(e=>{var t;return(0,eR._)((0,eN._)({},e),{text_knowledge_editor_chunk_uuid:(0,tm.x0)(),sequence:null===(t=e.slice_sequence)||void 0===t?void 0:t.toString(),content:e.text})})})})})]})]})]})})})},nj=e=>{var t,{useStore:n,footer:i}=e,r=(0,K.kF)(),s=n(e=>e.setCurrentStep),o=n(e=>e.segmentMode),a=n(e=>e.docReviewList),l=n(e=>e.setDocReviewList),d=n(e=>e.currentReviewID),c=n(e=>e.setCurrentReviewID),h=n(e=>e.selectionIDs),u=n(e=>e.setSelectionIDs),p=n(e=>e.levelSegments),f=n(e=>e.setLevelSegments),m=n(e=>e.parsingStrategy),g=n(e=>e.levelChunkStrategy),x=n(e=>e.segmentRule),w=n(e=>e.documentInfo),S=(0,B.useMemo)(()=>!!a.find(e=>e.document_name===(null==w?void 0:w.name)),[a,w]);(0,B.useEffect)(()=>{var e,t=(e=(0,eZ._)(function*(){var e,t,n=yield U.MJ.CreateDocumentReview({dataset_id:r.datasetID,reviews:[{document_id:null==w?void 0:w.document_id}],parsing_strategy:m,chunk_strategy:ts(o,x,g)});0===n.code&&(null===(e=n.reviews)||void 0===e?void 0:e.length)&&(l(n.reviews),c(null!==(t=n.reviews[0].review_id)&&void 0!==t?t:""))}),function(){return e.apply(this,arguments)});!S&&t()},[S,m,o,x,g,w]);var{run:E,cancel:C}=(0,eq.Z)((0,eZ._)(function*(){var e,t=yield U.MJ.MGetDocumentReview({dataset_id:r.datasetID,review_ids:a.map(e=>{var t;return null!==(t=e.review_id)&&void 0!==t?t:""})});0===t.code&&l(null!==(e=t.reviews)&&void 0!==e?e:[])}),{manual:!0,pollingInterval:2e3});(0,B.useEffect)(()=>(S&&E(),()=>{C()}),[S]);var A=a.length>0&&a.every(e=>void 0!==e.status&&e.status!==X.CT.Processing);(0,B.useEffect)(()=>{A&&C()},[A]);var{loading:k,run:T}=(0,eq.Z)((0,eZ._)(function*(){return 0===(yield U.MJ.SaveDocumentReview({review_id:d,dataset_id:r.datasetID,doc_tree_json:JSON.stringify({chunks:p})})).code}),{manual:!0,onSuccess:e=>{e&&s(t1.EMBED_PROGRESS)},onError:()=>{_.FN.error("变更保存失败")}});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(nP,{docReviewList:a,segmentMode:o,currentReviewID:d,setCurrentReviewID:c,selectionIDs:h,setSelectionIDs:u,levelSegments:p,setLevelSegments:f,datasetID:r.datasetID,segmentInfo:o!==eF.OX.AUTO?(0,b.jsxs)("div",{className:ey()("flex flex-col","text-[14px] font-[400] leading-[20px] coz-fg-primary"),children:[o===eF.OX.LEVEL?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("span",{children:["•"," ",y.o.t("knowledge_level_004"),":",g.maxLevel]}),g.isSaveTitle?(0,b.jsxs)("span",{children:["•"," ",y.o.t("knowledge_level_005")]}):null]}):null,o===eF.OX.CUSTOM?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("span",{children:["•"," ",y.o.t("datasets_Custom_segmentID"),":",x.separator.type!==eF.IB.CUSTOM?null===(t=(0,eE.Px)().find(e=>e.value===x.separator.type))||void 0===t?void 0:t.label:x.separator.customValue]}),(0,b.jsxs)("span",{children:["•"," ",y.o.t("datasets_Custom_maxLength"),":",x.maxTokens]}),(0,b.jsxs)("span",{children:["•"," ",y.o.t("kl_write_014"),": ",x.overlap]}),x.preProcessRules.includes(eF.dV.REMOVE_SPACES)?(0,b.jsxs)("span",{children:["•"," ",y.o.t("datasets_Custom_rule_replace")]}):null,x.preProcessRules.includes(eF.dV.REMOVE_EMAILS)?(0,b.jsxs)("span",{children:["•"," ",y.o.t("datasets_Custom_rule_delete")]}):null]}):null]}):null}),null==i?void 0:i([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",onClick:()=>s(t1.SEGMENT_CLEANER),text:y.o.t("datasets_createFileModel_previousBtn")},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",status:k?v.xZ.LOADING:v.xZ.ENABLE,onClick:(0,eZ._)(function*(){yield T()}),text:y.o.t("datasets_createFileModel_NextBtn")}])]})},nF={steps:[{content:e=>(0,b.jsx)(nk,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("kl_write_107"),step:t1.SEGMENT_CLEANER},{content:e=>(0,b.jsx)(nj,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("knowlege_qqq_001"),step:t1.SEGMENT_PREVIEW,showThisStep:()=>!0},{content:e=>(0,b.jsx)(nI,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step4"),step:t1.EMBED_PROGRESS}],createStore:()=>(0,eP.Ue)()((0,eL.mW)(function(e,t){for(var n=arguments.length,i=Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return(0,eR._)((0,eN._)({},ez(e,t,...i),t5(e,t,...i),(0,K.Y8)(e,t,...i),t3()),{reset:()=>{e(t3())},setFilterStrategy:t=>{e({filterStrategy:t},!1,"setFilterStrategy")},setIndexStrategyByMerge:n=>{e({indexStrategy:(0,ej.Z)({},t().indexStrategy,n)},!1,"setIndexStrategyByMerge")},setParsingStrategyByMerge:n=>{e({parsingStrategy:(0,ej.Z)({},t().parsingStrategy,n)},!1,"setParsingStrategyByMerge")},setLevelChunkStrategy:(t,n)=>{e(e=>(0,eR._)((0,eN._)({},e),{levelChunkStrategy:(0,eR._)((0,eN._)({},e.levelChunkStrategy),{[t]:n})}))},setDocumentInfo:t=>{e({documentInfo:t})}})},{enabled:!1,name:"Coz.Data.TextLocalResegment"})),useUploadMount:e=>ti()};var nB=((a={})[a.UPLOAD_FILE=0]="UPLOAD_FILE",a[a.SEGMENT_CLEANER=1]="SEGMENT_CLEANER",a[a.SEGMENT_PREVIEW=2]="SEGMENT_PREVIEW",a[a.EMBED_PROGRESS=3]="EMBED_PROGRESS",a),nz=()=>({currentReviewID:void 0,selectionID:void 0,docReviewList:[]}),nH=e=>(0,eR._)((0,eN._)({},nz()),{setCurrentReviewID:t=>e(()=>({currentReviewID:t})),setSelectionIDs:t=>e(()=>({selectionIDs:t})),setDocReviewList:t=>e(()=>({docReviewList:t}))}),nU=()=>(0,eR._)((0,eN._)({},eB(),nz(),(0,K.G6)()),{currentStep:nB.UPLOAD_FILE,parsingStrategy:{parsing_type:X.lC.AccurateParsing,image_extraction:!0,table_extraction:!0,image_ocr:!1},indexStrategy:{},filterStrategy:[],levelChunkStrategy:{maxLevel:3,isSaveTitle:!0}}),nV=n("615655"),n$=e=>{var t,{useStore:n,footer:i}=e,r=(0,K.kF)(),s=n(e=>e.setCurrentStep),o=n(e=>e.unitList),a=n(e=>e.segmentMode),l=n(e=>e.docReviewList),d=n(e=>e.setDocReviewList),c=n(e=>e.currentReviewID),h=n(e=>e.setCurrentReviewID),u=n(e=>e.selectionIDs),p=n(e=>e.setSelectionIDs),f=n(e=>e.levelSegments),m=n(e=>e.setLevelSegments),g=n(e=>e.parsingStrategy),x=n(e=>e.levelChunkStrategy),w=n(e=>e.segmentRule),S=(0,B.useMemo)(()=>(0,nV.Z)(l.map(e=>e.document_name),o.map(e=>e.name)),[l,o]);(0,B.useEffect)(()=>{var e,t=(e=(0,eZ._)(function*(){var e,t,{unitList:i}=n.getState(),s=yield U.MJ.CreateDocumentReview({dataset_id:r.datasetID,reviews:i.map(e=>({tos_uri:e.uri,document_name:e.name,document_type:e.type})),parsing_strategy:g,chunk_strategy:ts(a,w,x)});0===s.code&&(null===(e=s.reviews)||void 0===e?void 0:e.length)&&(d(s.reviews),h(null!==(t=s.reviews[0].review_id)&&void 0!==t?t:""))}),function(){return e.apply(this,arguments)});!S&&t()},[S,g,a,w,x]);var{run:E,cancel:C}=(0,eq.Z)((0,eZ._)(function*(){var e,t=yield U.MJ.MGetDocumentReview({dataset_id:r.datasetID,review_ids:l.map(e=>{var t;return null!==(t=e.review_id)&&void 0!==t?t:""})});0===t.code&&d(null!==(e=t.reviews)&&void 0!==e?e:[])}),{manual:!0,pollingInterval:2e3});(0,B.useEffect)(()=>(S&&E(),()=>{C()}),[S]);var A=l.length>0&&l.every(e=>void 0!==e.status&&e.status!==X.CT.Processing);(0,B.useEffect)(()=>{A&&C()},[A]);var{loading:k,run:T}=(0,eq.Z)((0,eZ._)(function*(){return 0===(yield U.MJ.SaveDocumentReview({review_id:c,dataset_id:r.datasetID,doc_tree_json:JSON.stringify({chunks:f})})).code}),{manual:!0,onSuccess:e=>{e&&s(nB.EMBED_PROGRESS)},onError:()=>{_.FN.error("变更保存失败")}});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(nP,{docReviewList:l,setDocReviewList:d,segmentMode:a,currentReviewID:c,setCurrentReviewID:h,selectionIDs:u,setSelectionIDs:p,levelSegments:f,setLevelSegments:m,datasetID:r.datasetID,segmentInfo:a!==eF.OX.AUTO?(0,b.jsxs)("div",{className:ey()("flex flex-col","text-[14px] font-[400] leading-[20px] coz-fg-primary"),children:[a===eF.OX.LEVEL?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("span",{children:["•"," ",y.o.t("knowledge_level_004"),":",x.maxLevel]}),x.isSaveTitle?(0,b.jsxs)("span",{children:["•"," ",y.o.t("knowledge_level_005")]}):null]}):null,a===eF.OX.CUSTOM?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("span",{children:["•"," ",y.o.t("datasets_Custom_segmentID"),":",w.separator.type!==eF.IB.CUSTOM?null===(t=(0,eE.Px)().find(e=>e.value===w.separator.type))||void 0===t?void 0:t.label:w.separator.customValue]}),(0,b.jsxs)("span",{children:["•"," ",y.o.t("datasets_Custom_maxLength"),":",w.maxTokens]}),(0,b.jsxs)("span",{children:["•"," ",y.o.t("kl_write_014"),": ",w.overlap]}),w.preProcessRules.includes(eF.dV.REMOVE_SPACES)?(0,b.jsxs)("span",{children:["•"," ",y.o.t("datasets_Custom_rule_replace")]}):null,w.preProcessRules.includes(eF.dV.REMOVE_EMAILS)?(0,b.jsxs)("span",{children:["•"," ",y.o.t("datasets_Custom_rule_delete")]}):null]}):null]}):null}),null==i?void 0:i([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",onClick:()=>{d([]),s(nB.SEGMENT_CLEANER)},text:y.o.t("datasets_createFileModel_previousBtn")},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",status:k?v.xZ.LOADING:v.xZ.ENABLE,onClick:(0,eZ._)(function*(){yield T()}),text:y.o.t("datasets_createFileModel_NextBtn")}])]})},nW=n("975083"),nG=n("735997"),nZ=e=>{var{unitList:t=[]}=e;if(0===t.length)return null;var n=e=>{var{record:t}=e,n=(0,Q.Z)(null==t?void 0:t.status);return{formatType:te.a5.Text,subText:(0,ed.G8)(t),actions:[n===en.N.Failed?(0,b.jsx)(ed.vL,(0,eN._)({},e)):null,n===en.N.Complete?(0,b.jsx)(ed.k1,(0,eN._)({},e)):null,(0,b.jsx)(ed.Zq,(0,eN._)({},e))]}};return(0,b.jsx)(nG.n,(0,eR._)((0,eN._)({},e),{type:v.Cm.TEXT_DOC,getColumns:(t,i)=>n({record:t,index:i,params:(0,eR._)((0,eN._)({},e),{type:v.Cm.TEXT_DOC})})}))},nq=n("116497"),nK=e=>{var t,{unitList:n,setUnitList:i}=e;return t=(0,eZ._)(function*(e,t){try{var{fileInstance:r}=e;if(r){var{name:s}=r,o=(0,et.mD)(s),a=yield(0,et.y3)(r),l=yield U.nA.UploadFile({file_head:{file_type:o,biz_type:tS.ym.BIZ_BOT_DATASET},data:a});i((0,et.wV)({unitList:n,data:null==l?void 0:l.data,fileInstance:r,index:t}))}}catch(e){eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeUploadFile,error:e})}}),function(e,n){return t.apply(this,arguments)}},nY=e=>{var t,n,{useStore:i,footer:r}=e,s=null===(n=(0,B.useContext)(nW.J))||void 0===n?void 0:null===(t=n.paramsStore)||void 0===t?void 0:t.call(n,e=>{var t;return null===(t=e.params)||void 0===t?void 0:t.isDouyinBot}),o=i(e=>e.unitList),a=i(e=>e.setUnitList),l=i(e=>e.setCurrentStep),d=nK({unitList:o,setUnitList:a}),c=(0,et.td)(),h=(0,t_.WT)(s?"DOUYIN":"DEFAULT"),u=h.addUnitMaxLimit,p=(0,B.useMemo)(()=>0===o.length||o.some(e=>0===e.name.length||e.status!==v.Dm.SUCCESS)?v.xZ.DISABLE:v.xZ.ENABLE,[o]),f=(0,B.useMemo)(()=>!!c,[c]),m=(0,B.useMemo)(()=>f?1:u,[f,u]),g=(0,B.useMemo)(()=>f&&(null==o?void 0:o.length)===1,[o,f]),x=e=>{var t=e;c&&(t=e.map(e=>(0,eR._)((0,eN._)({},e),{docId:c}))),a(t)},w=h.acceptFileTypes.join(",");return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(el.p,{action:"",accept:w,dragMainText:y.o.t("datasets_createFileModel_step2_UploadDoc"),dragSubText:y.o.t("datasets_createFileModel_step2_UploadDoc_description",{fileFormat:h.fileFormatString,maxDocNum:m,filesize:"".concat(eE.G2,"MB"),pdfPageNum:nq.XC}),limit:m,unitList:o,multiple:m>1,style:g?{visibility:"hidden",height:0}:void 0,setUnitList:x,onFinish:x}),o.length>0?(0,b.jsx)("div",{className:"overflow-y-auto mt-[16px]",children:(0,b.jsx)(nZ,{edit:!f,unitList:o,onChange:a,onRetry:d})}):null,null==r?void 0:r([{type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),status:p,onClick:()=>{l(nB.SEGMENT_CLEANER)},e2e:Y.w.UploadUnitNextBtn}])]})},nX=e=>{var{useStore:t,footer:n}=e,{unitList:i,setCurrentStep:r,segmentRule:s,segmentMode:o,parsingStrategy:a,filterStrategy:l}=t((0,e$.N)(e=>({unitList:e.unitList,setCurrentStep:e.setCurrentStep,segmentRule:e.segmentRule,segmentMode:e.segmentMode||eF.OX.AUTO,parsingStrategy:e.parsingStrategy,filterStrategy:e.filterStrategy}))),{setSegmentMode:d,setParsingStrategyByMerge:c,setSegmentRule:h,setFilterStrategy:u,setEnableStorageStrategy:p}=t.getState(),{datasetID:f,docID:m}=(0,K.kF)(),v=eX(e=>{var t=(0,et.VR)((0,g.Z)(e,"document_infos[0]",{}));t&&(h(t.segmentRule),d(t.segmentMode))});(0,B.useEffect)(()=>{m&&v({dataset_id:f||"",document_ids:[m||""]})},[]),(0,B.useEffect)(()=>{f&&U.MJ.DatasetDetail({dataset_ids:[f]}).then(e=>{var t,n=null===(t=e.dataset_details)||void 0===t?void 0:t[f];p((0,et.UQ)(n))})},[f]);var x=(0,eG.Y)(o,s);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(nA,{pdfList:i.filter(e=>"pdf"===e.type.toLocaleLowerCase()),segmentRule:s,segmentMode:o,parsingStrategy:a,filterStrategy:l,onChange:e=>{var{segmentRule:t,segmentMode:n,parsingStrategy:i,filterStrategy:r}=e;void 0!==t&&h(t),void 0!==n&&d(n),!(0,eW.Z)(i)&&c(i),!(0,eW.Z)(r)&&u(r)}}),null==n?void 0:n([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",onClick:()=>r(nB.UPLOAD_FILE),text:y.o.t("datasets_createFileModel_previousBtn")},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",onClick:()=>r(nB.SEGMENT_PREVIEW),text:y.o.t("datasets_createFileModel_NextBtn"),status:x}])]})},nJ=n("846954"),nQ={};nQ.styleTagTransform=R(),nQ.setAttributes=D(),nQ.insert=T().bind(null,"head"),nQ.domAPI=A(),nQ.insertStyleElement=I(),E()(nJ.Z,nQ);var n0=nJ.Z&&nJ.Z.locals?nJ.Z.locals:void 0,n1=e=>{var{useStore:t,footer:n}=e,i=(0,K.EV)(),r=(0,K.kF)(),{unitList:s,progressList:o,createStatus:a,segmentMode:l,segmentRule:d,enableStorageStrategy:c,storageLocation:h,openSearchConfig:u,docReviewList:p}=t((0,e$.N)(e=>({unitList:e.unitList,progressList:e.progressList,createStatus:e.createStatus,segmentMode:e.segmentMode,segmentRule:e.segmentRule,enableStorageStrategy:e.enableStorageStrategy,storageLocation:e.storageLocation,openSearchConfig:e.openSearchConfig,docReviewList:e.docReviewList}))),f=tn(t,{onSuccess:e=>{var t,n=null!==(t=e.document_infos)&&void 0!==t?t:[];(0,et.As)(n,eY.b.KnowledgeProcessDocument)}});return(0,B.useEffect)(()=>{var{parsingStrategy:e,filterStrategy:n,levelChunkStrategy:i}=t.getState();f((0,eR._)((0,eN._)({},function(e){var t,n,i,{unitList:r,segmentMode:s,segmentRule:o,pdfFilterValueList:a,levelChunkStrategy:l,enableStorageStrategy:d,storageLocation:c,openSearchConfig:h,docReviewList:u}=e;var p={format_type:X.a5.Text,document_bases:(t=r,n=a,i=u,t.map((e,t)=>{var r,s=n.find(t=>t.uri===e.uri),o={name:e.name,source_info:{tos_uri:e.uri,document_source:X.NZ.Document,review_id:null===(r=i[t])||void 0===r?void 0:r.review_id}};return(0,ej.Z)({},o,e7(s))})),chunk_strategy:ts(s,o,l)};return p}({unitList:s,segmentMode:l,segmentRule:d,pdfFilterValueList:n,levelChunkStrategy:i,docReviewList:p,enableStorageStrategy:c,storageLocation:h,openSearchConfig:u})),{parsing_strategy:e}))},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ea,{progressList:o,createStatus:a}),null==n?void 0:n({btns:[{e2e:Y.w.CreateUnitConfirmBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{var e,t=(0,e3.S)();null===(e=i.toResource)||void 0===e||e.call(i,"knowledge",r.datasetID,t)}}],prefix:(0,b.jsx)("span",{className:n0["footer-sub-tip"],children:(0,et.mZ)(a)})})]})},n2={steps:[{content:e=>(0,b.jsx)(nY,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:e.checkStatus}),title:y.o.t("datasets_createFileModel_step2"),step:nB.UPLOAD_FILE},{content:e=>(0,b.jsx)(nX,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("kl_write_107"),step:nB.SEGMENT_CLEANER},{content:e=>(0,b.jsx)(n$,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("knowlege_qqq_001"),step:nB.SEGMENT_PREVIEW,showThisStep:()=>!0},{content:e=>(0,b.jsx)(n1,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step4"),step:nB.EMBED_PROGRESS}],createStore:()=>(0,eP.Ue)()((0,eL.mW)(function(e,t){for(var n=arguments.length,i=Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return(0,eR._)((0,eN._)({},ez(e,t,...i),nH(e,t,...i),(0,K.Y8)(e,t,...i),(0,K.j_)(e,t,...i),nU()),{reset:()=>{e(nU())},setFilterStrategy:t=>{e({filterStrategy:t},!1,"setFilterStrategy")},setIndexStrategyByMerge:n=>{e({indexStrategy:(0,ej.Z)({},t().indexStrategy,n)},!1,"setIndexStrategyByMerge")},setParsingStrategyByMerge:n=>{e({parsingStrategy:(0,ej.Z)({},t().parsingStrategy,n)},!1,"setParsingStrategyByMerge")},setLevelChunkStrategy:(t,n)=>{e(e=>(0,eR._)((0,eN._)({},e),{levelChunkStrategy:(0,eR._)((0,eN._)({},e.levelChunkStrategy),{[t]:n})}))}})},{enabled:!1,name:"Coz.Data.TextLocalAddUpdate"})),useUploadMount:e=>ti()};var n5=((l={})[l.UPLOAD_CONTENT=0]="UPLOAD_CONTENT",l[l.SEGMENT_CLEANER=1]="SEGMENT_CLEANER",l[l.EMBED_PROGRESS=2]="EMBED_PROGRESS",l),n3=()=>(0,eR._)((0,eN._)({},eB()),{currentStep:n5.UPLOAD_CONTENT,docName:"",docContent:""}),n4=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return(0,eR._)((0,eN._)({},ez(e,...n),n3()),{reset:()=>{e(n3())},setDocContent:t=>{e({docContent:t})},setDocName:t=>{e({docName:t})}})};var n6=((d=(0,$.L)("editor-toolbar-actions")).registerSome([{type:"upload-image",module:{Component:V.IF}}]),d);var n8=((c=(0,$.L)("editor-context-actions")).registerSome([{type:"upload-image",module:{Component:V.E1}}]),c),n7=n("153745"),n9={};n9.styleTagTransform=R(),n9.setAttributes=D(),n9.insert=T().bind(null,"head"),n9.domAPI=A(),n9.insertStyleElement=I(),E()(n7.Z,n9);var ie=n7.Z&&n7.Z.locals?n7.Z.locals:void 0,it=e=>{var t,n,{useStore:i,footer:r}=e,s=i(e=>e.docName),o=i(e=>e.docContent),a=null===(n=(0,B.useContext)(K.JK))||void 0===n?void 0:null===(t=n.paramsStore)||void 0===t?void 0:t.call(n,e=>{var t;return null===(t=e.params)||void 0===t?void 0:t.isDouyinBot}),l=i(e=>e.setDocName),d=i(e=>e.setDocContent),c=i(e=>e.setCurrentStep),h=(0,B.useMemo)(()=>s&&o?v.xZ.ENABLE:v.xZ.DISABLE,[s,o]),u=(0,B.useMemo)(()=>({text_knowledge_editor_chunk_uuid:(0,tm.x0)(),content:""}),[]),{editor:p}=(0,H.nR)({chunk:u,editorProps:{attributes:{class:"h-[360px] overflow-y-auto"}},onChange:e=>{var t;d(null!==(t=e.content)&&void 0!==t?t:"")}});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(eh.l0,{layout:"vertical",showValidateIcon:!1,className:ie["custom-text-form"],children:[(0,b.jsx)(q.NB,{"data-testid":Y.w.CustomUploadNameInput,className:ie["doc-name-input"],field:"docName",autoFocus:!0,trigger:"blur",onChange:e=>l(e),maxLength:100,placeholder:y.o.t("knowledge_upload_text_custom_doc_name_tips"),label:y.o.t("knowledge_upload_text_custom_doc_name"),rules:[{required:!0,message:y.o.t("knowledge_upload_text_custom_doc_name_tips")}]}),(0,b.jsx)(eh.l0.Slot,{className:ie["form-segment-content"],label:{text:y.o.t("knowledge_upload_text_custom_doc_content")},children:(0,b.jsx)(H.R_,{editor:p,placeholder:y.o.t("knowledge_upload_text_custom_doc_content_tips"),editorContextMenuItemsRegistry:a?void 0:n8,editorBottomSlot:a?null:(0,b.jsx)(H.go,{editor:p,actionRegistry:n6})})})]}),null==r?void 0:r([{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),status:h,onClick:()=>{c(n5.SEGMENT_CLEANER)}}])]})},ii=e=>{var t,{useStore:n,footer:i}=e,{setCurrentStep:r,segmentRule:s,setSegmentRule:o,segmentMode:a,setSegmentMode:l,setEnableStorageStrategy:d,storageLocation:c,testConnectionSuccess:h}=n((0,e$.N)(e=>({setCurrentStep:e.setCurrentStep,segmentRule:e.segmentRule,setSegmentRule:e.setSegmentRule,segmentMode:e.segmentMode||eF.OX.AUTO,setSegmentMode:e.setSegmentMode,setEnableStorageStrategy:e.setEnableStorageStrategy,storageLocation:e.storageLocation,testConnectionSuccess:e.testConnectionSuccess}))),{datasetID:u,docID:p}=(0,K.kF)(),f=eX(e=>{var t=(0,et.VR)((0,g.Z)(e,"document_infos[0]",{}));t&&(o(t.segmentRule),l(t.segmentMode))});return(0,B.useEffect)(()=>{p&&f({dataset_id:u||"",document_ids:[p||""]})},[]),(0,B.useEffect)(()=>{u&&U.MJ.DatasetDetail({dataset_ids:[u]}).then(e=>{var t,n=null===(t=e.dataset_details)||void 0===t?void 0:t[u];d((0,et.UQ)(n))})},[u]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(e2,{segmentRule:s,segmentMode:a,onChange:e=>{var{segmentRule:t,segmentMode:n}=e;void 0!==t&&o(t),void 0!==n&&l(n)}}),null==i?void 0:i([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",onClick:()=>r(n5.UPLOAD_CONTENT),text:y.o.t("datasets_createFileModel_previousBtn")},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",onClick:()=>r(n5.EMBED_PROGRESS),text:y.o.t("datasets_createFileModel_NextBtn"),status:function(e,t){if(e===eF.OX.CUSTOM){var n=(null==t?void 0:t.maxTokens)||0,i=null==t?void 0:t.separator,r=(null==i?void 0:i.type)===eF.IB.CUSTOM&&!(null==i?void 0:i.customValue);0===n}return!0}((t={segmentMode:a,segmentRule:s,storageLocation:c,testConnectionSuccess:h}).segmentMode,t.segmentRule)?v.xZ.ENABLE:v.xZ.DISABLE}])]})},ir=n("45425"),is={};is.styleTagTransform=R(),is.setAttributes=D(),is.insert=T().bind(null,"head"),is.domAPI=A(),is.insertStyleElement=I(),E()(ir.Z,is);var io=ir.Z&&ir.Z.locals?ir.Z.locals:void 0,ia=e=>{var{useStore:t,footer:n}=e,i=(0,K.EV)(),r=(0,K.kF)(),{progressList:s,createStatus:o,docName:a,docContent:l,segmentMode:d,segmentRule:c,enableStorageStrategy:h,storageLocation:u,openSearchConfig:p}=t((0,e$.N)(e=>({progressList:e.progressList,createStatus:e.createStatus,docName:e.docName,docContent:e.docContent,segmentMode:e.segmentMode,segmentRule:e.segmentRule,enableStorageStrategy:e.enableStorageStrategy,storageLocation:e.storageLocation,openSearchConfig:e.openSearchConfig}))),f=tn(t);return(0,B.useEffect)(()=>{f({format_type:X.a5.Text,document_bases:[{name:a,source_info:{custom_content:l,document_source:X.NZ.Custom}}],chunk_strategy:ts(d,c),storage_strategy:void 0})},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ea,{progressList:s,createStatus:o}),null==n?void 0:n({btns:[{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{var e,t=(0,e3.S)();null===(e=i.toResource)||void 0===e||e.call(i,"knowledge",r.datasetID,t)}}],prefix:(0,b.jsx)("span",{className:io["footer-sub-tip"],children:(0,et.mZ)(o)})})]})},il={steps:[{content:e=>(0,b.jsx)(it,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("knowledge_upload_text_custom_add_title"),step:n5.UPLOAD_CONTENT},{content:e=>(0,b.jsx)(ii,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("kl_write_107"),step:n5.SEGMENT_CLEANER},{content:e=>(0,b.jsx)(ia,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step4"),step:n5.EMBED_PROGRESS}],createStore:()=>(0,eP.Ue)()((0,eL.mW)((e,t,n)=>(0,eN._)({},n4(e,t,n)))),useUploadMount:e=>ti()};var id=((h={})[h.UPLOAD=0]="UPLOAD",h[h.CONFIGURATION=1]="CONFIGURATION",h[h.PREVIEW=2]="PREVIEW",h[h.PROCESSING=3]="PROCESSING",h),ic=e=>{var t=e(e=>e.unitList);return(0,B.useMemo)(()=>({tos_uri:(0,g.Z)(t,"0.uri",""),document_source:X.NZ.Document}),[t])},ih=e=>{var t,n=e(e=>e.setUnitList),i=e(e=>e.unitList);return t=(0,eZ._)(function*(e,t){try{var{fileInstance:r}=e;if(r){var{name:s}=r,o=(0,et.mD)(s),a=yield(0,et.y3)(r),l=yield U.nA.UploadFile({file_head:{file_type:o,biz_type:tS.ym.BIZ_BOT_DATASET},data:a});n((0,et.wV)({unitList:i,data:null==l?void 0:l.data,fileInstance:r,index:t}))}}catch(e){console.log(e)}}),function(e,n){return t.apply(this,arguments)}},iu=e=>{var t,{useStore:n,footer:i}=e,r=(0,et.td)(),s=n(e=>e.unitList),o=n(e=>e.setUnitList),a=n(e=>e.setCurrentStep),l=n(e=>e.originTableData),d=n(e=>e.tableSettings),c=n(e=>e.setOriginTableData),h=n(e=>e.setTableData),u=n(e=>e.setTableSettings),p=n(e=>e.setStatus),f=ih(n),m=ic(n),g=tB(n);(0,B.useEffect)(()=>{!s.length&&(c({}),h({}),u(eE.Q))},[s.length]);var x=tW();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(el.p,{setUnitList:o,unitList:s,onFinish:e=>{o(e)},limit:1,accept:x,dragMainText:y.o.t("datasets_createFileModel_step2_UploadDoc"),dragSubText:(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{children:y.o.t("datasets_unit_update_exception_tips3")}),(0,b.jsx)("p",{children:y.o.t("knowledg_table_increment_tips")})]}),action:"",style:s.length?{display:"none"}:{},showIllustration:!1}),(0,b.jsx)("div",{className:"upload-unit-table",children:(0,b.jsx)(ed.nC,{edit:!1,type:v.Cm.TABLE_DOC,unitList:s,onChange:e=>{o(e)},canValidator:!1,onRetry:f})}),i?i([{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),onClick:()=>{if(a(id.CONFIGURATION),!!(0,tg.Z)(l))p(eE.c3.LOADING),g({source_file:m,document_id:r,table_sheet:(0,et.wO)(d),table_data_type:tw.nZ.AllData})},status:0===(t=s).length||t.some(e=>0===e.name.length||e.status!==v.Dm.SUCCESS)?v.xZ.DISABLE:v.xZ.ENABLE}]):null]})},ip=n("499283"),im=n("344842"),ig={};ig.styleTagTransform=R(),ig.setAttributes=D(),ig.insert=T().bind(null,"head"),ig.domAPI=A(),ig.insertStyleElement=I(),E()(im.Z,ig);var iv=im.Z&&im.Z.locals?im.Z.locals:void 0,ib=e=>{var{isTableStructureError:t}=e;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:iv["validation-results"],children:[(0,b.jsx)("div",{className:iv["validation-item"]}),(0,b.jsxs)("div",{className:iv["validation-item"],children:[t?(0,b.jsx)("p",{className:iv["error-msg"],children:y.o.t("knowledg_table_structure_err_msg")}):null,(0,b.jsx)("p",{className:iv.tips,children:y.o.t("knowledg_table_structure_tips")})]}),(0,b.jsx)("div",{className:iv["validation-item"]})]}),(0,b.jsx)("div",{className:iv["table-structure-title"],"data-testid":Y.w.TableLocalTableStructureTitle,children:y.o.t("datasets_segment_tableStructure_title")})]})},iy=e=>{var t,n,i,r,s,{useStore:o,footer:a}=e,l=o(e=>e.setCurrentStep),d=o(e=>e.status),c=o(e=>e.tableData),h=o(e=>e.originTableData),u=o(e=>e.tableSettings),p=o(e=>e.semanticValidate),f=o(e=>e.setTableData),m=o(e=>e.setSemanticValidate),g=tM(d),[x,w]=(0,B.useState)(!1),_=tD(d),[S,E]=(0,B.useState)(!1),C=(0,B.useRef)({});var A=(t=c,n=u,i=C.current,r=tI(t,n),s=Object.keys(i),r.map(e=>{var t=(0,eN._)({},e);return s.includes((null==e?void 0:e.column_name)||"")&&(t.errMsg=i[(null==e?void 0:e.column_name)||""]),t})),k=tz(o),T=ic(o),M=(0,K.kF)(),D=tB(o),O=tH((e,t)=>{E(!e),w(e),C.current=t},e=>{(0,ip.k0)(e)&&(null==e?void 0:e.code)==="708024073"&&E(!0),w(!1),C.current={}});return((0,B.useEffect)(()=>{u&&(w(!1),O({space_id:M.spaceID||"",document_id:M.docID||"",source_file:{tos_uri:T.tos_uri||"",document_source:X.NZ.Document},table_sheet:{sheet_id:u.sheet_id.toString(),header_line_idx:u.header_line_idx.toString(),start_line_idx:u.start_line_idx.toString()}}))},[u]),g)?(0,b.jsx)(eg,{}):_?(0,b.jsx)(em,{fetchTableInfo:()=>{D((0,eR._)((0,eN._)({},T),{document_id:M.docID,table_data_type:tw.nZ.AllData,table_sheet:(0,et.wO)(u)}))}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Z.tM,{className:"".concat(iv["table-setting-bar-container"]," ").concat(S?iv["is-error"]:""),data:c,tableSettings:u,setTableSettings:k}),(0,b.jsx)(ib,{isTableStructureError:S}),!A.length||(0,tg.Z)(h)?(0,b.jsx)(eh.YZ,{empty:{title:y.o.t("knowledge_1221_02"),icon:(0,b.jsx)(ec.xs,{})}}):(0,b.jsx)(Z.u3,{initValid:!1,baseKey:"".concat(u[eE.hD.SHEET],".").concat(u[eE.hD.KEY_START_ROW],"."),data:A,verifyMap:p[u[eE.hD.SHEET]]||{},setData:e=>{var t=u[eE.hD.SHEET],n=(0,eR._)((0,eN._)({},c),{table_meta:(0,eR._)((0,eN._)({},c.table_meta),{[t]:e})});f(n),m(tk(n))},loading:g,isPreview:!0}),a?a([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",text:y.o.t("datasets_createFileModel_previousBtn"),onClick:()=>{l(id.UPLOAD)},status:v.xZ.ENABLE},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),onClick:()=>{var e,t;l(id.PREVIEW),D({table_data_type:tw.nZ.OnlyPreview,source_file:T,document_id:M.docID,origin_table_meta:null==h?void 0:null===(e=h.table_meta)||void 0===e?void 0:e[u.sheet_id],preview_table_meta:null==c?void 0:null===(t=c.table_meta)||void 0===t?void 0:t[u.sheet_id],table_sheet:(0,et.wO)(u)})},status:x?v.xZ.ENABLE:v.xZ.DISABLE}]):null]})},ix=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.tableData),r=t(e=>e.tableSettings),s=t(e=>e.setCurrentStep);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Z.IO,{data:i,settings:r}),n?n([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",text:y.o.t("datasets_createFileModel_previousBtn"),onClick:()=>{s(id.CONFIGURATION)},status:v.xZ.ENABLE},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),onClick:()=>{s(id.PROCESSING)},status:v.xZ.ENABLE}]):null]})},iw=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.unitList),r=t(e=>e.progressList),s=t(e=>e.createStatus),o=t(e=>e.tableSettings),a=(0,K.kF)(),{docID:l,spaceID:d,datasetID:c}=a,h=(0,K.EV)(),u=(0,B.useMemo)(()=>tR(r),[r]),p=tV(t);return(0,B.useEffect)(()=>{if(!!l&&!!c&&!!d&&!!o&&!!i)p(tP({spaceId:d,docId:l,datasetId:c,documentInfo:i.map(e=>({name:"",source_info:{document_source:X.NZ.Document,tos_uri:e.uri},table_sheet:{sheet_id:o.sheet_id.toString(),header_line_idx:o.header_line_idx.toString(),start_line_idx:o.start_line_idx.toString()}}))}))},[o,i]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ea,{progressList:r,createStatus:s}),n?n([{e2e:Y.w.CreateUnitConfirmBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{var e;null===(e=h.toResource)||void 0===e||e.call(h,"knowledge",a.datasetID)},status:u?v.xZ.ENABLE:v.xZ.DISABLE}]):null]})},i_={steps:[{content:e=>(0,b.jsx)(iu,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step2"),step:id.UPLOAD},{content:e=>(0,b.jsx)(iy,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_tab_step2"),step:id.CONFIGURATION},{content:e=>(0,b.jsx)(ix,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_tab_step3"),step:id.PREVIEW},{content:e=>(0,b.jsx)(iw,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step4"),step:id.PROCESSING}],createStore:()=>(0,eP.Ue)()((0,eL.mW)((e,t,n)=>(0,eN._)({},tp(e,t,n)))),className:"table-local-wrapper"},iS=e=>{var t=(0,K.kF)(),n=e(e=>e.setDocumentList),i=eX(e=>{var{document_infos:t=[]}=e;n&&n(t)});return(0,B.useEffect)(()=>{var e;i({dataset_id:null!==(e=t.datasetID)&&void 0!==e?e:"",document_ids:t.docID?[t.docID]:void 0})},[]),null},iE=e=>{var t,{useStore:n,footer:i}=e,r=n(e=>e.unitList),s=n(e=>e.setUnitList),o=n(e=>e.setCurrentStep),a=n(e=>e.tableSettings),l=n(e=>e.setOriginTableData),d=n(e=>e.setTableData),c=n(e=>e.setTableSettings),h=n(e=>e.setStatus),u=tC(n),p=tE(n),f=tB(n);(0,B.useEffect)(()=>{!r.length&&(l({}),d({}),c(eE.Q))},[r.length]);var m=tW();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(el.p,{setUnitList:s,unitList:r,onFinish:e=>{s(e)},limit:1,accept:m,dragMainText:y.o.t("datasets_createFileModel_step2_UploadDoc"),dragSubText:y.o.t("datasets_unit_update_exception_tips3"),action:"",style:r.length?{display:"none"}:{},showIllustration:!1}),(0,b.jsx)("div",{className:"upload-unit-table",children:(0,b.jsx)(ed.nC,{edit:!1,type:v.Cm.TABLE_DOC,unitList:r,onChange:e=>{s(e)},onRetry:u})}),i?i([{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),onClick:()=>{o(id.CONFIGURATION),h(eE.c3.LOADING),f({source_file:p,table_data_type:tw.nZ.AllData,table_sheet:(0,et.wO)(a)})},status:0===(t=r).length||t.some(e=>0===e.name.length||e.status!==v.Dm.SUCCESS)?v.xZ.DISABLE:v.xZ.ENABLE}]):null]})},iC=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.setCurrentStep),r=t(e=>e.status),s=t(e=>e.tableData),o=t(e=>e.originTableData),a=t(e=>e.tableSettings),l=t(e=>e.semanticValidate),d=t(e=>e.setTableData),c=t(e=>e.setSemanticValidate),h=(0,et.l$)(),u=tM(r),p=tD(r),f=tO(h,s,a),m=tI(s,a).map((e,t)=>(0,eR._)((0,eN._)({},e),{key:t+e.column_name})),g=tz(t),x=tE(t),w=tB(t);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Z.tM,{data:s,tableSettings:a,setTableSettings:g}),u?(0,b.jsx)(eg,{}):p?(0,b.jsx)(em,{fetchTableInfo:()=>{w({source_file:x,table_data_type:tw.nZ.AllData,table_sheet:(0,et.wO)(a)})}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Z.u3,{tipsNode:(0,b.jsxs)(b.Fragment,{children:[f?(0,b.jsx)(ev,{}):null,!m.length||(0,tg.Z)(o)?(0,b.jsx)(eh.YZ,{empty:{title:y.o.t("knowledge_1221_02"),icon:(0,b.jsx)(ec.xs,{})}}):null]}),showTitle:!0,initValid:!0,isDragTable:!0,baseKey:"".concat(a[eE.hD.SHEET],".").concat(a[eE.hD.KEY_START_ROW],"."),data:m,verifyMap:l[a[eE.hD.SHEET]]||{},setData:e=>{var t=a[eE.hD.SHEET],n=(0,eR._)((0,eN._)({},s),{table_meta:(0,eR._)((0,eN._)({},s.table_meta),{[t]:e})});d(n),c(tk(n))},loading:u}),n?n([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",text:y.o.t("datasets_createFileModel_previousBtn"),onClick:()=>{i(id.UPLOAD)},status:v.xZ.ENABLE},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),onClick:()=>{var e,t;i(id.PREVIEW),w({table_sheet:(0,et.wO)(a),table_data_type:tw.nZ.OnlyPreview,source_file:x,origin_table_meta:null==o?void 0:null===(e=o.table_meta)||void 0===e?void 0:e[a.sheet_id],preview_table_meta:null==s?void 0:null===(t=s.table_meta)||void 0===t?void 0:t[a.sheet_id]})},status:tN(s,a)}]):null]})]})},iA=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.tableData),r=t(e=>e.tableSettings),s=t(e=>e.setCurrentStep);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Z.IO,{data:i,settings:r}),n?n([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",text:y.o.t("datasets_createFileModel_previousBtn"),onClick:()=>{s(id.CONFIGURATION)},status:v.xZ.ENABLE},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),onClick:()=>{s(id.PROCESSING)},status:v.xZ.ENABLE}]):null]})},ik=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.progressList),r=t(e=>e.unitList),s=t(e=>e.createStatus),o=t(e=>e.tableData),a=t(e=>e.tableSettings),l=tI(o,a),d=(0,K.kF)(),c=(0,K.EV)(),h=(0,B.useMemo)(()=>tR(i),[i]),u=tn(t);return(0,B.useEffect)(()=>{u(function(e){var{isAppend:t,unitList:n,metaData:i,tableSettings:r,sourceType:s,updateRule:o}=e,a=null!=s?s:X.NZ.Document,l=e=>[X.NZ.GoogleDrive,X.NZ.Notion].includes(a)?e.file_id:e.entity_id,d=()=>o?o:!t&&(a===X.NZ.Web||(0,q.$6)(a))?{update_interval:(0,g.Z)(n,"0.updateInterval"),update_type:(0,g.Z)(n,"0.updateType")}:void 0;return{source_type:a,format_type:tA.Table,document_bases:n.map(e=>({name:"",source_info:{tos_uri:e.uri,document_source:a,source_file_id:l(e),web_id:e.webID},update_rule:d(),table_sheet:(0,et.wO)(r),table_meta:i.map(e=>({id:t?e.id:"0",column_name:e.column_name,is_semantic:e.is_semantic,column_type:e.column_type,desc:e.desc,sequence:e.sequence}))})),is_append:t}}({isAppend:!1,unitList:r,metaData:l,tableSettings:a}))},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ea,{progressList:i,createStatus:s}),n?n([{e2e:Y.w.CreateUnitConfirmBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{var e;null===(e=c.toResource)||void 0===e||e.call(c,"knowledge",d.datasetID)},status:h?v.xZ.ENABLE:v.xZ.DISABLE}]):null]})},iT={steps:[{content:e=>(0,b.jsx)(iE,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step2"),step:id.UPLOAD},{content:e=>(0,b.jsx)(iC,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_tab_step2"),step:id.CONFIGURATION},{content:e=>(0,b.jsx)(iA,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_tab_step3"),step:id.PREVIEW},{content:e=>(0,b.jsx)(ik,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step4"),step:id.PROCESSING}],createStore:()=>(0,eP.Ue)()((0,eL.mW)((e,t,n)=>(0,eN._)({},tp(e,t,n)))),className:"table-local-wrapper",useUploadMount:e=>iS(e)},iM=n("461190"),iD=n("690612"),iO=n("5718"),iI={};iI.styleTagTransform=R(),iI.setAttributes=D(),iI.insert=T().bind(null,"head"),iI.domAPI=A(),iI.insertStyleElement=I(),E()(iO.Z,iI);var iN=iO.Z&&iO.Z.locals?iO.Z.locals:void 0;function iR(e,t,n){var i={};return e.forEach(e=>{var r=e[t],s=n?e[n]:"";i[r]=s}),[i]}var iL=e=>(0,b.jsx)(_.Vp,{color:"primary",className:iN["column-type"],children:(0,q.y8)(e.columnType)}),iP=function(e){var{initialData:t=[],editTableSegment:n}=e,[i,r]=(0,B.useState)(t),s=(0,B.useRef)(t),o=(0,B.useRef)([]),[a,l]=(0,B.useState)(-1),d=(0,B.useCallback)((e,t)=>{r(n=>n.map((n,i)=>i===t?(0,eN._)({},n,e):n))},[i]),c=(0,B.useCallback)(e=>{var t=[...s.current];e.forEach(e=>{t.splice(Number(e),1)}),r(t)},[s.current]),h=(0,B.useCallback)((e,t)=>{var i=s.current;l(Number(t));var r=i[Number(t)],a=Object.keys(r).map(e=>{var t=o.current.find(t=>t.column_name===e);return{column_name:(null==t?void 0:t.column_name)||"",column_id:(null==t?void 0:t.id)||"",is_semantic:!!(null==t?void 0:t.is_semantic),value:r[e]}});null==n||n(a)},[o.current,s.current]),u=(0,B.useCallback)(()=>{var e=iR(o.current,"column_name");r([...s.current,...e])},[s.current]);return(0,B.useEffect)(()=>{s.current=i},[i]),{editItemIndex:a,tableData:i,setTableData:r,handleCellUpdate:d,handleAdd:u,handleDel:c,handleEdit:h,tableDataRef:s,sheetStructureRef:o}},ij=e=>{var{docTitle:t}=e;return(0,b.jsx)("div",{className:iN["structure-bar"],"data-testid":Y.w.IncrementTableUploadStructureTitle,children:(0,b.jsx)("div",{className:iN["structure-bar-title"],children:t})})},iF=e=>{var{loading:t,tableData:n,columns:i,handleAdd:r,handleDel:s,handleEdit:o}=e;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"".concat(iN["unit-table-container"]," "),children:(0,b.jsx)(eh.yC,{spinning:t,wrapperClassName:iN.spin,size:"large",style:{width:"100%",height:"100%"},children:n.length?(0,b.jsx)(iM.HA,{className:"".concat(iN["unit-table-view"]," "),dataSource:n,columns:i,rowOperation:!0,editProps:{onDelete:s,onEdit:o}}):(0,b.jsx)("div",{className:iN["unit-table-empty"]})})}),(0,b.jsx)("div",{className:"".concat(iN["footer-toolbar"]," "),children:(0,b.jsx)(_.zx,{"data-testid":Y.w.IncrementTableUploadStructureAddBtn,className:iN["structure-bar-button"],type:"tertiary",onClick:()=>{r()},icon:(0,b.jsx)(ek.PwN,{}),children:y.o.t("knowledge_custom_add_content")})})]})},iB=e=>{var{useStore:t,footer:n}=e,{docID:i,spaceID:r,datasetID:s}=(0,K.kF)(),o=t(e=>e.setStatus),a=t(e=>e.status),[l,d]=(0,B.useState)([]),[c,h]=(0,B.useState)({}),u=(0,B.useRef)(null),p=(0,B.useRef)([]),f=(0,B.useMemo)(()=>(null==c?void 0:c.name)||"",[c]),{node:m,edit:g}=(0,z.nV)({title:y.o.t("knowledg_table_segments_content"),meta:p.current||[],onFinish:(e,t)=>{var n=iR(t,"column_name","value");e===z.wO.Edit?C(n[0],x):S([...w,...n])}}),{editItemIndex:x,tableData:w,setTableData:S,sheetStructureRef:E,handleCellUpdate:C,handleDel:A,handleEdit:k,handleAdd:T}=iP({editTableSegment:g}),M=tj(e=>{var{tableColumns:t,tableData:n,sheetStructure:i}=function(e){var t,{data:n,handleEdit:i,handleDel:r,handleCellUpdate:s,tableContainerRef:o}=e,a={sheetStructure:[],tableColumns:[],tableData:[]};if(!n)return a;var{table_meta:l,sheet_list:d}=n;if(!l||!Object.keys(l).length||!(null==d?void 0:d.length))return a;var c=d[0],h=l[null!==(t=null==c?void 0:c.id)&&void 0!==t?t:""]||[],u=o.current,p=u?u.offsetWidth-397:1400,f=p/h.length>200?p/h.length:200,m=h.map(e=>({id:e.column_name,dataIndex:e.column_name,columnType:e.column_type,title:(0,b.jsxs)("div",{className:iN["table-view-title"],children:[(0,b.jsx)(eh.ZT.Text,{className:iN["table-view-title-content"],ellipsis:{showTooltip:{opts:{content:e.column_name}}},children:e.column_name}),e.is_semantic?(0,b.jsx)(_.Vp,{color:"green",className:iN["semantic-tag"],children:y.o.t("knowledge_1226_001")}):null,e.column_type?(0,b.jsx)(iL,{columnType:e.column_type}):null]}),width:f,render:(t,n,i)=>{if(e.column_type===te.QD.Image){var r,o=(0,iD.bp)(null==n?void 0:n[null==e?void 0:e.column_name]);return(0,b.jsx)(iM.e0,{srcList:o,onChange:(t,r)=>{var o="";(t||r)&&(o='<img src="'.concat(null!=t?t:"",'" ').concat(r?'data-tos-key="'.concat(r,'"'):"",">")),s((0,eR._)((0,eN._)({},n),{[null==e?void 0:e.column_name]:o}),i)}})}return(0,b.jsx)(iM.EY,{dataIndex:e.column_name,value:t,record:n,index:i,editable:!0,validator:{validate:t=>!!e.is_semantic&&(!t||""===t),errorMsg:y.o.t("datasets_url_empty")},onBlur:(r=(0,eZ._)(function*(e,t){return yield s(t,i)}),function(e,t){return r.apply(this,arguments)})})}}));m.push({title:(0,b.jsx)(b.Fragment,{}),width:100,dataIndex:"actions",className:iN["unit-actions-column"],fixed:"right",render:(e,t,n)=>(0,b.jsx)(iM.E2,{record:t,index:n,editProps:{disabled:!1,onEdit:()=>{null==i||i(t,n)}},deleteProps:{disabled:!1,onDelete:()=>{null==r||r([n])}}})});var g=iR(h,"column_name");return{sheetStructure:h,tableColumns:m,tableData:g}}({data:e,tableContainerRef:u,handleCellUpdate:C,handleEdit:k,handleDel:A});t.length>0&&d(t),n.length>0&&S(n),i.length>0&&(p.current=i,E.current=i),o(eE.c3.NORMAL)},()=>{o(eE.c3.NORMAL)}),D=(0,K.EV)(),{fetchAddSegment:O,addSegmentLoading:I}=tU(e=>{var t;null===(t=D.toResource)||void 0===t||t.call(D,"knowledge",s)}),N=t$(h);return(0,B.useEffect)(()=>{i&&(o(eE.c3.LOADING),N(),M({document_id:i}))},[i]),(0,b.jsxs)("div",{ref:u,className:ey()("custom-table-container",iN["custom-table-container"]),children:[(0,b.jsx)(ij,{docTitle:f}),(0,b.jsx)(iF,{loading:a===eE.c3.LOADING,columns:l,tableData:w,handleAdd:T,handleDel:A,handleEdit:k}),m,n?n({prefix:(0,b.jsx)("span",{className:iN["footer-sub-tip"],children:y.o.t("knowledge_table_custom_submit_tips")}),btns:[{e2e:Y.w.CreateUnitConfirmBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{!function(){if(!!r&&!!s&&!!i){var e=[];l.forEach(t=>{t.columnType===te.QD.Image&&e.push(t.id)});var t=w.map(t=>Object.fromEntries(Object.entries(t).map(t=>{var[n,i]=t;return e.includes(n)?[n,(0,z.Yw)(i)]:[n,i]})));O(tP({spaceId:r,docId:i,datasetId:s,documentInfo:[{source_info:{document_source:X.NZ.Custom,custom_content:JSON.stringify(t)},table_sheet:{sheet_id:"0",header_line_idx:"0",start_line_idx:"0"}}]}))}}()},status:function(e,t,n){if(n)return v.xZ.LOADING;var i=e.find(e=>e.is_semantic);if(!i)return v.xZ.DISABLE;var r=null==i?void 0:i.column_name;return!r||!t.length||t.some(e=>e&&""===e[r])?v.xZ.DISABLE:v.xZ.ENABLE}(E.current,w,I)}]}):null]})};var iz=((u={})[u.UPLOAD=0]="UPLOAD",u),iH={steps:[{content:e=>(0,b.jsx)(iB,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step2"),step:iz.UPLOAD}],createStore:()=>(0,eP.Ue)()((0,eL.mW)((e,t,n)=>(0,eN._)({},tp(e,t,n)))),className:"table-custom-increment-wrapper",showStep:!1},iU=(e,t,n)=>(0,eR._)((0,eN._)({},tp(e,t,n)),{tableSettings:eE.z2,reset:()=>{e((0,eR._)((0,eN._)({},tu()),{tableSettings:eE.z2}))}}),iV=n("669854"),i$={};i$.styleTagTransform=R(),i$.setAttributes=D(),i$.insert=T().bind(null,"head"),i$.domAPI=A(),i$.insertStyleElement=I(),E()(iV.Z,i$);var iW=iV.Z&&iV.Z.locals?iV.Z.locals:void 0,iG=e=>{var t,{footer:n,useStore:i}=e,r=(0,K.kF)(),s=(0,K.EV)(),{datasetID:o}=r,[a,l]=(0,B.useState)(v.xZ.ENABLE),d=(0,tm.x0)(),[c,h]=(0,B.useState)([{id:d,key:d,column_name:"",is_semantic:!1}]),u=0!==(null!==(t=i(e=>e.documentList))&&void 0!==t?t:[]).length,p=eJ({onSuccess:()=>{var e;l(v.xZ.ENABLE),null===(e=s.toResource)||void 0===e||e.call(s,"knowledge",o)},onFail:()=>{l(v.xZ.DISABLE)}});return(0,B.useEffect)(()=>{a!==v.xZ.LOADING&&l(tL(c,"toBeDelete"))},[c]),(0,b.jsxs)("div",{className:iW["create-table-wrapper"],children:[(0,b.jsx)(Z.zx,{}),(0,b.jsx)(Z.u3,{initValid:!0,isDragTable:!0,data:c,setData:h}),(0,b.jsx)(e=>{var{children:t}=e;return c.length>=eE.pL?(0,b.jsx)(eh.u,{trigger:"hover",content:y.o.t("knowledge_1222_01"),children:t}):(0,b.jsx)(b.Fragment,{children:t})},{children:(0,b.jsx)(_.zx,{"data-testid":Y.w.TableCustomUAddFieldBtn,className:iW["add-column-button"],type:"tertiary",disabled:c.length>=eE.pL,onClick:()=>{var e=(0,tm.x0)();h(c.concat({id:e,key:e,column_name:"",is_semantic:!1}))},block:!1,icon:(0,b.jsx)(ek.PwN,{}),children:y.o.t("datasets_segment_tableStructure_add_field")})}),n?n([{e2e:Y.w.CreateUnitConfirmBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{var e,t;l(v.xZ.LOADING),p((e=c,t=u,{document_bases:[{name:"",source_info:{document_source:X.NZ.Custom},table_meta:e.map((e,t)=>({column_name:e.column_name,is_semantic:e.is_semantic,column_type:e.column_type,desc:e.desc,sequence:t.toString()}))}],format_type:X.a5.Table,is_append:t}))},status:a}]):null]})},iZ=e=>(0,b.jsx)(iG,(0,eN._)({},e));var iq=((p={})[p.CREATE=0]="CREATE",p),iK={steps:[{content:e=>(0,b.jsx)(iZ,{useStore:e.useStore,footer:e=>(0,b.jsx)(F,{controls:e}),checkStatus:void 0}),title:y.o.t("datasets_createFileModel_step2"),step:iq.CREATE}],createStore:()=>(0,eP.Ue)()((0,eL.mW)((e,t,n)=>(0,eN._)({},iU(e,t,n)))),showStep:!1,className:"table-custom-wrapper",useUploadMount:e=>iS(e)};var iY=((f={})[f.Upload=0]="Upload",f[f.Annotation=1]="Annotation",f[f.Process=2]="Process",f);var iX=((m={}).Auto="auto",m.Manual="manual",m),iJ={currentStep:iY.Upload,unitList:[],annotationType:iX.Auto,createStatus:v.uy.UPLOAD_UNIT,progressList:[]},iQ=e=>{var t,{unitList:n,setUnitList:i}=e;return t=(0,eZ._)(function*(e,t){try{var{fileInstance:r}=e;if(r){var{name:s}=r,o=(0,et.mD)(s),a=yield(0,et.y3)(r),l=yield U.nA.UploadFile({file_head:{file_type:o,biz_type:tS.ym.BIZ_BOT_DATASET},data:a});i((0,et.wV)({unitList:n,data:null==l?void 0:l.data,fileInstance:r,index:t}))}}catch(e){eK.s5.errorEvent(eK.xW.KNOWLEDGE,{eventName:eY.b.KnowledgeUploadFile,error:e})}}),function(e,n){return t.apply(this,arguments)}},i0=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.setCurrentStep),r=t(e=>e.unitList),s=t(e=>e.setUnitList),o=iQ({unitList:r,setUnitList:s}),a=(0,B.useMemo)(()=>0===r.length||r.some(e=>0===e.name.length||e.status!==v.Dm.SUCCESS)?v.xZ.DISABLE:v.xZ.ENABLE,[r]),l=e=>{s(e)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(el.p,{action:"",accept:".png,.jpg,.jpeg,.webp",dragMainText:y.o.t("knowledge_photo_004"),dragSubText:y.o.t("knowledge_photo_005"),limit:300,unitList:r,multiple:true,style:void 0,setUnitList:l,onFinish:l,maxSizeMB:20,onSizeError:e=>_.FN.error(y.o.t("photo-size-limit",{fileName:e.name}))}),r.length>0?(0,b.jsx)("div",{className:"mt-[25px] mb-[25px] overflow-y-auto",children:(0,b.jsx)(ed.nC,{type:v.Cm.IMAGE_FILE,edit:!0,unitList:r,onChange:s,onRetry:o})}):null,null==n?void 0:n([{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),status:a,onClick:()=>{i(iY.Annotation)}}])]})},i1=n("900539"),i2=n("923124"),i5={};i5.styleTagTransform=R(),i5.setAttributes=D(),i5.insert=T().bind(null,"head"),i5.domAPI=A(),i5.insertStyleElement=I(),E()(i2.Z,i5);var i3=i2.Z&&i2.Z.locals?i2.Z.locals:void 0,i4=e=>{var{useStore:t,footer:n}=e,i=(0,K.EV)(),r=(0,K.kF)(),s=t(e=>e.unitList),o=t(e=>e.annotationType),a=t(e=>e.progressList),l=t(e=>e.createStatus),d=tn(t,{onSuccess:e=>{var t,n=null!==(t=e.document_infos)&&void 0!==t?t:[];(0,i1.As)(n,eY.b.KnowledgeProcessDocument)}});return(0,B.useEffect)(()=>{d({format_type:X.a5.Image,chunk_strategy:{caption_type:o===iX.Manual?X._S.Manual:X._S.Auto},document_bases:s.map(e=>({name:e.name,source_info:{tos_uri:e.uri,document_source:X.NZ.Document}}))})},[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ea,{progressList:a,createStatus:l}),null==n?void 0:n({btns:[{e2e:Y.w.CreateUnitConfirmBtn,type:"hgltplus",theme:"solid",text:y.o.t("variable_reset_yes"),onClick:()=>{var e,t=(0,e3.S)();null===(e=i.toResource)||void 0===e||e.call(i,"knowledge",r.datasetID,t)}}],prefix:(0,b.jsx)("span",{className:i3["footer-sub-tip"],children:(0,et.mZ)(l)})})]})},i6=n("716437"),i8={};i8.styleTagTransform=R(),i8.setAttributes=D(),i8.insert=T().bind(null,"head"),i8.domAPI=A(),i8.insertStyleElement=I(),E()(i6.Z,i8);var i7=i6.Z&&i6.Z.locals?i6.Z.locals:void 0,i9=e=>{var{useStore:t,footer:n}=e,i=t(e=>e.setCurrentStep),r=t(e=>e.annotationType),s=t(e=>e.setAnnotationType),o=(0,B.useMemo)(()=>r?v.xZ.ENABLE:v.xZ.DISABLE,[r]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:i7["segment-radio-wrapper"],children:(0,b.jsxs)(_.FX,{type:"pureCard",onChange:e=>{s(e.target.value)},direction:"vertical",value:r,children:[(0,b.jsx)(_.Y8,{"data-testid":Y.w.ImageAnnotationAiRadio,value:iX.Auto,extra:y.o.t("knowledge_photo_009"),children:y.o.t("knowledge_photo_008")}),(0,b.jsx)(_.Y8,{"data-testid":Y.w.ImageAnnotationManualRadio,value:iX.Manual,extra:y.o.t("knowledge_photo_011"),children:y.o.t("knowledge_photo_010")})]})}),null==n?void 0:n([{e2e:Y.w.UploadUnitUpBtn,type:"primary",theme:"light",text:y.o.t("datasets_createFileModel_previousBtn"),onClick:()=>i(iY.Upload)},{e2e:Y.w.UploadUnitNextBtn,type:"hgltplus",theme:"solid",text:y.o.t("datasets_createFileModel_NextBtn"),status:o,onClick:()=>{i(iY.Process)}}])]})},re={steps:[{title:y.o.t("knowledge_photo_006"),step:iY.Upload,content:e=>(0,b.jsx)(i0,(0,eR._)((0,eN._)({},e),{footer:e=>(0,b.jsx)(F,{controls:e})}))},{title:y.o.t("knowledge_photo_007"),step:iY.Annotation,content:e=>(0,b.jsx)(i9,(0,eR._)((0,eN._)({},e),{footer:e=>(0,b.jsx)(F,{controls:e})}))},{title:y.o.t("db_table_0126_015"),step:iY.Process,content:e=>(0,b.jsx)(i4,(0,eR._)((0,eN._)({},e),{footer:e=>(0,b.jsx)(F,{controls:e})}))}],createStore:()=>(0,eP.Ue)()((0,eL.mW)((e,t,n)=>(0,eR._)((0,eN._)({},iJ),{setCurrentStep:t=>{e({currentStep:t})},setUnitList:t=>{e({unitList:t})},setAnnotationType:t=>{e({annotationType:t})},setCreateStatus:t=>{e({createStatus:t})},setProgressList:t=>{e({progressList:t})},reset:()=>{e(iJ)}}))),useUploadMount:e=>tr()},rt=()=>({[v.Cm.TEXT]:{[v.VP.RESEGMENT]:th},[v.Cm.TABLE]:{[v.VP.RESEGMENT]:t0},[v.Cm.TEXT_DOC]:{[v.VP.ADD]:n2,[v.VP.RESEGMENT]:nF},[v.Cm.TEXT_CUSTOM]:{[v.VP.ADD]:il},[v.Cm.TABLE_DOC]:{[v.VP.ADD]:iT,[v.VP.INCREMENTAL]:i_},[v.Cm.TABLE_CUSTOM]:{[v.VP.ADD]:iK,[v.VP.INCREMENTAL]:iH},[v.Cm.IMAGE_FILE]:{[v.VP.ADD]:re}}),rn=(e,t)=>{var n=t||v.VP.ADD,i=rt();return(0,g.Z)(i,"".concat(e,".").concat(n),null)},ri=n("616426"),rr=n("487377"),rs=e=>{var{title:t}=e,n=(0,K.kF)(),i=(0,K.EV)(),r="project"===n.biz;return(0,b.jsx)("div",{className:ey()("flex items-center justify-between shrink-0 h-[56px] coz-fg-primary",r?"px-[12px]":""),children:(0,b.jsxs)("div",{className:"flex items-center",children:[(0,b.jsx)(_.hU,{color:"secondary",icon:(0,b.jsx)(ek.$1i,{className:"text-[16px]"}),iconPosition:"left",className:"!p-[8px]",onClick:()=>{var e,t=(0,e3.S)();null===(e=i.toResource)||void 0===e||e.call(i,"knowledge",n.datasetID,t)}}),(0,b.jsx)(_.ZT.Text,{fontSize:"16px",weight:500,className:"ml-[8px]",children:t})]})})},ro=n("492483"),ra={};ra.styleTagTransform=R(),ra.setAttributes=D(),ra.insert=T().bind(null,"head"),ra.domAPI=A(),ra.insertStyleElement=I(),E()(ro.Z,ra);var rl=ro.Z&&ro.Z.locals?ro.Z.locals:void 0,rd=e=>{var t,{keepDocTitle:n,uploadConfig:i,children:r}=e,{onUpdateDisplayName:s,onStatusChange:o}=(0,K.kJ)(),{datasetID:a,opt:l,docID:d,biz:c}=(0,K.kF)(),{data:h,loading:u}=(0,ri.ZK)({datasetID:a||""}),p=(0,B.useMemo)(()=>!d,[d]),f=(0,B.useMemo)(()=>{var e,t=y.o.t("knowledge_upload_create_title");return l===v.VP.RESEGMENT?y.o.t("datasets_unit_config_title1"):t=l===v.VP.INCREMENTAL||(null==h?void 0:null===(e=h.file_list)||void 0===e?void 0:e.length)?y.o.t("knowledg_unit_add_segments"):p?y.o.t("knowledge_upload_create_title"):y.o.t("datasets_unit_config_title1")},[p,l,h]);return(0,rr.a)({isLive:!!h&&!u}),(0,B.useEffect)(()=>{null==s||s(f),null==o||o("normal")},[f]),(0,b.jsx)(eK.xV,{namespace:eK.xW.KNOWLEDGE,children:(0,b.jsxs)(_.Ar,{className:ey()("flex flex-col gap-[16px]","project"===c?"coz-bg-max border border-solid coz-stroke-primary":"p-[24px] pt-[16px]"),title:(0,J.Z$)(y.o.t("tab_dataset_detail",{dataset_name:null!==(t=null==h?void 0:h.name)&&void 0!==t?t:""})),keepDocTitle:n,children:[(0,b.jsx)(rs,{title:f}),(0,b.jsxs)(_.Ar.Content,{className:ey()("!px-[76px] h-full"),scrollY:!0,children:[r,(0,b.jsx)("div",{className:rl["upload-unit-wrap"],children:i?(0,b.jsx)(v.RB,{createStore:i.createStore,children:(0,b.jsx)(v.gq,{config:i})}):(0,b.jsx)(eK.Z9,{namespace:eK.xW.KNOWLEDGE})})]})]})})},rc=e=>{var{type:t,opt:n}=(0,K.kF)(),i=rn(null!=t?t:v.Cm.TEXT,null!=n?n:v.VP.ADD);return i?(0,b.jsx)(rd,(0,eR._)((0,eN._)({},e),{uploadConfig:i})):(0,b.jsx)(b.Fragment,{})}},936731:function(e,t,n){"use strict";n.d(t,{v:function(){return i.v}});var i=n(888461)},888461:function(e,t,n){"use strict";n.d(t,{v:function(){return h}});var i=n(151064),r=n(455069),s=n(252237),o=n.n(s),a=n(385038),l=n(659596),d=n(561119),c=n(105452),h=e=>{var{className:t,style:n,mainText:s,subText:h,percent:u=10,percentFormat:p,avatar:f,status:m,actions:g,tipText:v=""}=e;return(0,i.jsxs)("div",{className:o()(c.Z["progress-wrap"],"flex justify-between relative mb-[8px]",m===d.N.Failed?c.Z["processing-failed"]:"",m===d.N.Processing?c.Z.processing:"",t),style:n,children:[(0,i.jsx)("div",{className:o()(c.Z.content,"process-progress-item-content","max-w-[calc(100%-100px)]"),children:(0,i.jsxs)("div",{className:o()("flex items-center",c.Z.info),children:[f,(0,i.jsxs)("div",{className:o()("pl-[10px] max-w-full"),children:[(0,i.jsx)("div",{className:c.Z["main-text"],children:(0,i.jsx)(l.ZT.Text,{"data-dtestid":"".concat(a.w.CreateUnitListProgressName,".").concat(s),className:"coz-fg-primary text-14px",ellipsis:{showTooltip:{opts:{content:s}}},children:s})}),(0,i.jsxs)("div",{className:c.Z["sub-text"],children:[(0,i.jsx)("div",{className:c.Z.desc,children:h}),v?(0,i.jsx)("div",{className:c.Z["tip-desc"],children:v}):null]})]})]})}),(0,i.jsx)("div",{className:o()(c.Z.right,"process-progress-item-right"),children:m===d.N.Processing?(0,i.jsx)("span",{className:c.Z.percent,children:p||"".concat(u,"%")}):(0,i.jsx)("div",{className:o()(c.Z.actions,"process-progress-item-actions"),children:Array.isArray(g)?(0,i.jsx)(l.T,{spacing:"tight",children:g.map((e,t)=>(0,i.jsx)(r.Fragment,{children:e},t))}):null})}),m===d.N.Processing?(0,i.jsx)("div",{className:c.Z.progress,style:{width:"".concat(u,"%")}}):null]},s)}},392902:function(e,t,n){"use strict";n.d(t,{u3:()=>H,zx:()=>U,IO:()=>T,tM:()=>y});var i=n("808549"),r=n("120454"),s=n("473980"),o=n("151064"),a=n("455069"),l=n("962289"),d=n("550655"),c=n("252237"),h=n.n(c),u=n("385038"),p=n("336205"),f=n("775699"),m=n("659596"),g=n("528751"),v=(e,t)=>{for(var n=e>50?50:e,i=[],r=t;r<n;r++)i.push({label:p.o.t("datasets_createFileModel_tab_dataStarRow_value",{LineNumber:r+1}),value:r});return i},b=n("151359"),y=e=>{var{className:t="",data:n={},tableSettings:c,setTableSettings:y}=e,{preview_data:x,sheet_list:w}=n;if(!x||!w||!w.length)return(0,o.jsx)(o.Fragment,{});var _=(0,a.useRef)(),S=(0,a.useMemo)(()=>(0,l.Z)(w,c[g.hD.SHEET]),[w,c]),E=(0,a.useMemo)(()=>c,[w]),C=(0,a.useMemo)(()=>{var e=S.id||0===S.id?v(Number(null==S?void 0:S.total_row)>1?Number(S.total_row):2,0):[];return[{e2e:u.w.TableLocalTableConfigurationDataSheet,field:g.hD.SHEET,label:p.o.t("datasets_createFileModel_tab_DataSheet"),options:w.map(e=>({value:e.id,label:e.sheet_name}))},{e2e:u.w.TableLocalTableConfigurationSheetHeader,field:g.hD.KEY_START_ROW,label:p.o.t("datasets_createFileModel_tab_header"),options:e.slice(0,e.length-1)},{e2e:u.w.TableLocalTableConfigurationStarRow,field:g.hD.DATA_START_ROW,label:p.o.t("datasets_createFileModel_tab_dataStarRow"),options:e.slice(Number(c[g.hD.KEY_START_ROW])+1)}]},[n,S]),A=(e,t)=>{y&&y((0,i._)({},e));var n=(0,l.Z)(t,g.hD.SHEET),r=(0,l.Z)(t,g.hD.KEY_START_ROW);(0,d.Z)(n)&&_.current&&(_.current.setValue(g.hD.KEY_START_ROW,0),_.current.setValue(g.hD.DATA_START_ROW,1)),r&&_.current&&!(r<(0,l.Z)(e,g.hD.DATA_START_ROW))&&_.current.setValue(g.hD.DATA_START_ROW,r+1)};return(0,o.jsx)("div",{className:h()(b.Z["table-setting-bar"],t),children:(0,o.jsx)(f.l0,{layout:"horizontal",initValues:E,getFormApi:e=>_.current=e,onValueChange:(e,t)=>{A(e,t)},children:C.map(e=>{var{options:t}=e,n=(0,s._)(e,["options"]);return(0,o.jsx)(m.ih,(0,r._)((0,i._)({"data-testid":e.e2e,optionList:t},n),{onChange:t=>{if(!!t)A((0,r._)((0,i._)({},c),{[e.field]:t}),{[e.field]:t})}}),e.field)})})})},x=n("763055"),w=n("263825"),_=n("461190"),S=n("594022"),E=n("690612"),C=n("210208"),A=e=>(0,o.jsx)(m.Vp,{color:"primary",className:C.Z["column-type"],size:"mini",children:(0,w.y8)(e.columnType)}),k="table-preview",T=e=>{var{data:t,settings:n}=e,{sheet_list:i=[],table_meta:r={},preview_data:s={}}=t,l=Number(n[g.hD.DATA_START_ROW])||0,d=(0,a.useMemo)(()=>n[g.hD.SHEET]||0,[n]),c=(0,a.useMemo)(()=>{var e;return null===(e=(i||[]).find(e=>(null==e?void 0:e.id)===d))||void 0===e?void 0:e.sheet_name},[i,d]),h=(0,a.useMemo)(()=>{var e;return Number((null===(e=(i||[]).find(e=>(null==e?void 0:e.id)===d))||void 0===e?void 0:e.total_row)||0)-l||0},[i,d]),f=(r[d]||[]).map(e=>{var{sequence:t,column_name:n,is_semantic:i,column_type:r=S.QD.Unknown}=e;return r===S.QD.Image?{title:(0,o.jsxs)("div",{className:C.Z["td-title"],children:[(0,o.jsx)("div",{children:n}),(0,o.jsx)(A,{columnType:r})]}),dataIndex:t,render:(e,t)=>{var n=(0,E.bp)(e);return(0,o.jsx)(_.e0,{srcList:n,editable:!1})}}:{title:i?(0,o.jsxs)("div",{className:C.Z["td-title"],children:[n,i?(0,o.jsx)(m.Vp,{size:"mini",color:"green",className:C.Z["semantic-tag"],"data-testid":u.w.TableLocalPreviewSemantic,children:p.o.t("knowledge_1226_001")}):null,(0,o.jsx)(A,{columnType:r})]}):(0,o.jsxs)("div",{className:C.Z["td-title"],children:[n,(0,o.jsx)(A,{columnType:r})]}),width:180,dataIndex:t,ellipsis:{showTitle:!1},render:e=>(0,o.jsx)(m.ZT.Text,{ellipsis:{showTooltip:!0},children:e})}}),v=(0,a.useMemo)(()=>(s[d]||[]).slice(0,10).sort((e,t)=>JSON.stringify(e)>JSON.stringify(t)?1:-1),[s,d]);return(0,o.jsx)("div",{className:C.Z[k],children:v.length?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:C.Z["".concat(k,"-title")],"data-testid":u.w.TableLocalPreviewTitle,children:c}),(0,o.jsx)("div",{className:C.Z["".concat(k,"-content")],children:(0,o.jsx)(m.iA,{tableProps:{dataSource:v,columns:f}})}),(0,o.jsx)("div",{className:C.Z["preview-tips"],"data-testid":u.w.TableLocalPreviewFooterTotal,children:p.o.t("datasets_unit_tableformat_tips1",{TotalRows:h,ShowRows:Number(h)>10?10:h})})]}):(0,o.jsxs)("div",{className:C.Z["no-result"],children:[(0,o.jsx)(x.xs,{}),(0,o.jsx)("div",{className:C.Z["no-result-tips"],children:p.o.t("knowledge_1221_02")})]})})},M=n("745304"),D=n("306785"),O=n("481655"),I=n("410517"),N=n("537714"),R=n("873183"),L=n("44172"),P=n("274971"),j=n("391757"),F="table-structure",B=e=>{var{children:t,tooltip:n,dataTestId:i}=e;return(0,o.jsxs)("div",{className:j.Z["".concat(F,"-required-container")],"data-testid":i,children:[t,(0,o.jsx)("span",{className:j.Z["".concat(F,"-col-required")],children:" *"}),n]})},z=e=>{var{onChange:t,record:n,value:i,autofocus:r=!1,isBlurValid:s=!1,initValid:l,validate:d,isPreview:c,placeholder:h,maxStrLen:u}=e,f=e=>{var t=null==d?void 0:d(e,p.o.t("datasets_segment_tableStructure_field_errEmpty"));return{valid:!l||!!(d?null==t?void 0:t.valid:e&&""!==e),errorMsg:(null==t?void 0:t.errorMsg)||p.o.t("datasets_segment_tableStructure_field_errEmpty")}},[g,v]=(0,a.useState)(i),[b,y]=(0,a.useState)(()=>{var e=f(i);return{valid:!!s||e.valid,errorMsg:e.errorMsg}}),x=e=>{y(f(e))},w=(null==n?void 0:n.errMsg)||"",_=(0,a.useMemo)(()=>w?"error":b.valid?"default":"error",[b,w]),S=(0,a.useCallback)(()=>w?(0,o.jsx)("div",{className:j.Z["input-error-msg"],children:w}):(0,o.jsx)(o.Fragment,{children:!b.valid&&(0,o.jsx)("div",{className:j.Z["input-error-msg"],children:b.errorMsg})}),[w,b]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(m.II,{autoFocus:r,value:g,maxLength:u,onChange:e=>{v(e.substring(0,u)),s||x(e)},disabled:c,validateStatus:_,suffix:(0,o.jsxs)("span",{className:j.Z["input-suffix"],children:[(g||"").length,"/",u]}),onBlur:()=>{t((null==g?void 0:g.substring(0,u))||""),x(g)},placeholder:h}),S()]})},H=e=>{var{data:t=[],setData:n,verifyMap:a={},initValid:l=!1,isBlurValid:d=!1,isPreview:c=!1,baseKey:g,showTitle:v=!1,children:b,tipsNode:y,isDragTable:x=!1}=e,_=(0,s._)(e,["data","setData","verifyMap","initValid","isBlurValid","isPreview","baseKey","showTitle","children","tipsNode","isDragTable"]),E=(0,P.l$)()===N.VP.RESEGMENT,C=[{title:()=>(0,o.jsx)(B,{dataTestId:u.w.TableLocalTableConfigurationIndex,tooltip:(0,o.jsx)(m.u,{className:"whitespace-pre-line",content:p.o.t("knowledge_multi_index"),children:(0,o.jsx)(f.y3,{size:"small",theme:"borderless",type:"tertiary",style:{marginLeft:4},icon:(0,o.jsx)(R.L03,{className:"coz-fg-secondary"})})}),children:(0,o.jsx)("div",{className:j.Z["table-header-tooltip"],"data-testid":u.w.TableLocalTableConfigurationIndex,children:(0,o.jsx)("span",{children:p.o.t("knowledge_table_structure_semantic")})})}),dataIndex:"is_semantic",width:90,align:"left",render:(e,i,r)=>{var s,{sequence:l}=i;var d=!!Object.keys(a).length&&!(null===(s=a[l||r])||void 0===s?void 0:s.valid)||c;return(0,o.jsxs)("div",{className:j.Z["semantic-radio"],children:[x?(0,o.jsx)(L.lls,{className:"structure-table-drag-icon"}):null,(0,o.jsx)(e=>{var t,n,{children:i}=e;return d&&(null===(t=a[l||r])||void 0===t?void 0:t.msg)?(0,o.jsx)(m.u,{trigger:"hover",content:null===(n=a[l||r])||void 0===n?void 0:n.msg,children:i}):i},{children:(0,o.jsx)(m.XZ,{checked:e,disabled:d,onChange:e=>{var i=[...t];i[r].is_semantic=!!e.target.checked,n(i)},"data-testid":u.w.TableStructureIndexCheckbox})})]})}},{title:()=>(0,o.jsx)(B,{dataTestId:u.w.TableLocalTableConfigurationColumnName,children:p.o.t("knowledge_table_structure_column_name")}),dataIndex:"column_name",align:"left",render:(e,i,r)=>{var{autofocus:s=!1}=i;return(0,o.jsx)("div",{className:j.Z["column-item"],children:(0,o.jsx)(z,{initValid:l,isBlurValid:d,onChange:e=>{var i=[...t];i[r].column_name=e,n(i)},record:i,value:e,validate:(e,n)=>(null==t?void 0:t.filter(t=>t.column_name===e).length)>=2?{valid:!1,errorMsg:p.o.t("Manual_crawling_040")}:(0,P.OP)(e,n),autofocus:s,isPreview:c,maxStrLen:30},"".concat(g).concat(null==i?void 0:i.sequence))})}},{title:()=>(0,o.jsx)("div",{"data-testid":u.w.TableLocalTableConfigurationDesc,children:p.o.t("knowledge_table_structure_desc")}),dataIndex:"desc",align:"left",render:(e,i,r)=>(0,o.jsx)("div",{className:j.Z["column-item"],children:(0,o.jsx)(z,{initValid:!1,isBlurValid:!1,placeholder:p.o.t("knowledge_variable_description_placeholder"),onChange:e=>{var i=[...t];i[r].desc=e,n(i)},record:i,value:e,autofocus:!1,isPreview:c,maxStrLen:2e3},"column-desc.".concat(g).concat(null==i?void 0:i.sequence))})},{title:()=>(0,o.jsx)(B,{dataTestId:u.w.TableLocalTableConfigurationType,children:p.o.t("knowledge_table_structure_data_type")}),dataIndex:"column_type",align:"left",render:(e,s,a)=>{var l=!!d||!!e;return(0,o.jsx)("div",{className:"pr-[16px] ".concat(j.Z["column-item"]),children:c?(0,o.jsx)(f.ZT.Text,{className:j.Z["column-item-value"],children:(0,w.y8)(e)}):(0,o.jsx)(w.L5,{value:e||"",selectProps:{disabled:!s.is_new_column&&E,optionList:(0,w.iQ)().map(e=>e.value===S.QD.Image?(0,r._)((0,i._)({},e),{disabled:s.is_semantic}):e),placeholder:p.o.t("db_table_save_exception_fieldtype")},errorMsg:l?void 0:p.o.t("datasets_segment_tableStructure_field_type_errEmpty"),handleChange:e=>{var i=[...t];i[a].column_type=e,n(i)}})},s.sequence)}},{title:(0,o.jsx)("div",{"data-testid":u.w.TableLocalTableConfigurationAction,children:p.o.t("datasets_unit_upload_field_action")}),dataIndex:"operate",width:82,align:"left",render:(e,i,r)=>(0,o.jsx)("div",{className:j.Z["column-item-action"],onClick:()=>{n(t.filter((e,t)=>r!==t))},children:(0,o.jsx)(m.u,{content:p.o.t(i.is_semantic?"datasets_segment_tableStructure_delTips":"datasets_table_title_actions_delete"),children:(0,o.jsx)(R.dVD,{"aria-disabled":!!i.is_semantic,className:j.Z["column-item-action-delete"]})})})}];c&&C.pop();var A=(0,I.Dy)((0,I.VT)(I.we,{activationConstraint:{distance:1}})),k=e=>{var{active:i,over:r}=e;if(i&&r&&i.id!==r.id){var s=Array.from(t),o=s.findIndex(e=>e.key===i.id),a=s.findIndex(e=>e.key===r.id);n((0,D.Rp)(s,o,a))}},T=e=>{var{attributes:t,listeners:n,setNodeRef:s,transform:a,transition:l,isDragging:d}=(0,D.nB)({id:e["data-row-key"]}),c=(0,i._)((0,r._)((0,i._)({},e.style),{transform:M.ux.Transform.toString(a),transition:l,cursor:d?"grabbing":"grab"}),d?{zIndex:999,position:"relative",background:"rgba(217, 220, 250, 1)"}:{});return(0,o.jsx)("tr",(0,i._)((0,r._)((0,i._)({},e),{ref:s,style:c}),t,n))};return(0,o.jsxs)("div",{className:j.Z["structure-wrapper"],children:[v?(0,o.jsx)(U,{}):null,y||null,x?(0,o.jsx)(I.LB,{autoScroll:!0,sensors:A,modifiers:[O.DL],onDragEnd:k,children:(0,o.jsx)(D.Fo,{items:t.map(e=>e.key||""),strategy:D.qw,children:(0,o.jsx)(m.iA,{wrapperClassName:h()(j.Z["".concat(F,"-wrapper")],j.Z["drag-table"]),tableProps:(0,i._)({sticky:!0,dataSource:t,columns:C,pagination:!1,className:j.Z[F],components:{body:{row:T}}},_)},g)})}):(0,o.jsx)(m.iA,{wrapperClassName:j.Z["".concat(F,"-wrapper")],tableProps:(0,i._)({sticky:!0,dataSource:t,columns:C,pagination:!1,className:j.Z[F]},_)},g),b]})},U=()=>(0,o.jsxs)("div",{className:j.Z["table-structure-bar-title"],"data-testid":u.w.TableLocalTableStructureTitle,children:[(0,o.jsx)("span",{children:p.o.t("datasets_segment_tableStructure_title")}),(0,o.jsx)(m.u,{content:p.o.t("knowledge_table_structure_column_tooltip"),children:(0,o.jsx)(R.L03,{className:h()(j.Z.icon,"coz-fg-secondary")})})]})},270917:function(e,t,n){"use strict";n.d(t,{p:()=>z});var i,r=n("808549"),s=n("120454"),o=n("473980"),a=n("151064"),l=n("455069"),d=n("252237"),c=n.n(d),h=n("763055"),u=n("263825"),p=n("385038"),f=n("336205"),m=n("873183"),g=n("659596"),v=n("528751"),b=n("537714"),y=n("695673"),x=n("900539"),w=e=>e.substring(0,e.lastIndexOf(".")),_=(e,t)=>{var n;return null==e?void 0:null===(n=e[t])||void 0===n?void 0:n.name},S=e=>e.reduce((e,t)=>(e[t.uid||""]=t,e),{}),E=(e,t)=>e.filter(e=>null==t?void 0:t.find(t=>{var n;return t.uri===(null==e?void 0:null===(n=e.response)||void 0===n?void 0:n.upload_uri)})),C=(e,t)=>{var n,i,r,s;return{type:(0,x.mD)((null==e?void 0:null===(n=e.response)||void 0===n?void 0:n.upload_uri)||e.name),uri:null==e?void 0:null===(i=e.response)||void 0===i?void 0:i.upload_uri,url:null==e?void 0:null===(r=e.response)||void 0===r?void 0:r.upload_url,name:(null!==(s=null==t?void 0:t.filename)&&void 0!==s?s:w(e.name)).slice(0,y.I1),size:e.size,status:e.status,percent:e.percent||0,fileInstance:e.fileInstance,uid:e.uid,validateMessage:e.validateMessage||""}},A=e=>e.filter(e=>!(!e.shouldUpload&&e.status===b.Dm.VALIDATE_FAIL)).map((t,n)=>C(t,{filename:_(e,n)})),k=(e,t)=>{var n=S(t);return e.filter(e=>{var t=n[e.uid||""];return!!t.shouldUpload||t.status!==b.Dm.VALIDATE_FAIL||!1}).map((e,i)=>{var s=n[e.uid||""],o=_(t,i);return(0,r._)({},e,C(s,{filename:o}))})},T=n("44172"),M=e=>{var t=(0,x.mD)(e.name)||"unknown",n={unknown:T.dd3,pdf:T.t1r,text:T.mBV,docx:T.yA0}[t]||T.dd3;return(0,a.jsx)(n,{})},D=n("825955"),O=n("745474"),I=n("458620"),N=n("727914"),R=n("178385"),L=n("382534"),P=n("274971");var j=(i=(0,D._)(function*(e){var{onSuccess:t,onError:n,onProgress:i,file:r}=e;try{var{name:s,fileInstance:o}=r;if(o){var a=(0,P.mD)(s),l=yield(0,P.y3)(o),d=yield L.nA.UploadFile({file_head:{file_type:a,biz_type:R.ym.BIZ_BOT_DATASET},data:l},{onUploadProgress:e=>{var t,n=null==r?void 0:r.status,s=null==r?void 0:r.response;if(n!==b.Dm.SUCCESS&&n!==b.Dm.UPLOAD_FAIL&&n!==b.Dm.VALIDATE_FAIL&&(null==s?!void 0:!s.upload_url)){var{total:a,loaded:l}=e;void 0!==a&&l<a&&i({total:null!==(t=e.total)&&void 0!==t?t:o.size,loaded:e.loaded})}}});t(d.data)}else n({status:0}),O.s5.errorEvent(O.xW.KNOWLEDGE,{eventName:I.b.KnowledgeUploadFile,error:new N.sH(I.b.KnowledgeUploadFile,"".concat(I.b.KnowledgeUploadFile,": Failed to upload file"))})}catch(e){n({status:0}),O.s5.errorEvent(O.xW.KNOWLEDGE,{eventName:I.b.KnowledgeUploadFile,error:e})}}),function(e){return i.apply(this,arguments)}),F=e=>{var t,{maxSizeMB:i}=e;return t=(0,D._)(function*(e){var t={fileInstance:e.file.fileInstance,status:e.file.status,validateMessage:e.file.validateMessage,shouldUpload:!0,autoRemove:!1},{fileInstance:o}=e.file;if(!o)return(0,s._)((0,r._)({},t),{status:b.Dm.UPLOAD_FAIL,shouldUpload:!1});var a=i||v.G2;if(o.size>1048576*a)return g.FN.warning({showClose:!1,content:f.o.t("file_too_large",{max_size:"".concat(a,"MB")})}),(0,s._)((0,r._)({},t),{shouldUpload:!1,status:b.Dm.VALIDATE_FAIL,validateMessage:f.o.t("file_too_large",{max_size:"".concat(a,"MB")})});if("pdf"===(0,P.mD)(o.name).toLowerCase())try{var{getDocument:l,initPdfJsWorker:d}=yield n.e("7841").then(n.bind(n,187394));d();var c=yield(0,P.JD)(o);if((yield l({data:c}).promise).numPages>v.XC)return g.FN.warning({showClose:!1,content:f.o.t("atasets_createpdf_over250")}),{shouldUpload:!1,status:b.Dm.VALIDATE_FAIL}}catch(e){if(O.s5.errorEvent(O.xW.KNOWLEDGE,{eventName:I.b.KnowledgeParseFile,error:e}),(null==e?void 0:e.name)==="PasswordException")return g.FN.error({showClose:!1,content:f.o.t("pdf_encrypted")}),{shouldUpload:!1,status:b.Dm.VALIDATE_FAIL}}return t}),function(e){return t.apply(this,arguments)}},B=n("928589"),z=e=>{var{unitList:t,onFinish:n,setUnitList:i,showIllustration:d=!0,multiple:b=!0,maxSizeMB:y=v.G2}=e,x=(0,o._)(e,["unitList","onFinish","setUnitList","showIllustration","multiple","maxSizeMB"]),{limit:w}=x,[_,S]=(0,l.useState)([]);(0,l.useEffect)(()=>{t.length<_.length&&S(E(_,t))},[t.length]);var C=(0,l.useCallback)(()=>{g.FN.warning({showClose:!1,content:f.o.t("knowledge_upload_format_error")})},[]),T=(0,u.hJ)(),D=(0,u.S2)(e=>{S(e.fileList),i(A(e.fileList))},T),O=(0,u.S2)(()=>{n(k(t,_))},T),I=(0,l.useMemo)(()=>t.length>=w,[t,w]),N=F({maxSizeMB:y});return(0,a.jsx)(g.gq,(0,s._)((0,r._)({draggable:!0,"data-testid":p.w.UploadUnitFile,multiple:b,fileList:_,disabled:I,previewFile:M,onAcceptInvalid:C,beforeUpload:N,customRequest:j,onChange:D,onSuccess:O,dragIcon:(0,a.jsx)(m.Isu,{className:B.Z["upload-icon"]})},x),{className:c()(B.Z.upload,x.className),children:t.length>=w&&d?(0,a.jsxs)("div",{className:B.Z["create-enough-file"],onClick:e=>e.stopPropagation(),children:[(0,a.jsx)(h.ns,{className:B.Z.picture}),(0,a.jsx)("div",{className:B.Z.text,children:f.o.t("knowledge_1218_001",{MaxDocs:w})})]}):null}))}},47522:function(e,t,n){"use strict";n.d(t,{vL:()=>p,k1:()=>u,Zq:()=>h,nC:()=>i.n,G8:()=>c});var i=n("735997"),r=n("151064"),s=n("695673"),o=n("385038"),a=n("336205"),l=n("873183"),d=n("659596");function c(e){return(0,r.jsx)("div",{"data-dtestid":"".concat(o.w.LocalUploadListFileSize,".").concat(e.name),className:"coz-fg-secondary text-12px",children:null==e?void 0:e.size})}function h(e){var{index:t,record:n,params:i}=e,{onChange:s,unitList:o,onDelete:c}=i;return(0,r.jsx)(d.u,{spacing:12,content:a.o.t("Delete"),position:"top",children:(0,r.jsx)(d.hU,{color:"secondary",icon:(0,r.jsx)(l.dVD,{className:"text-14px"}),iconPosition:"left",size:"small",onClick:()=>{s(o.filter((e,n)=>t!==n)),"function"==typeof c&&(null==c||c(n,t))}})})}function u(e){var t,{index:n,record:i,params:o}=e,{onChange:c,unitList:h}=o,{node:u,open:p}=(0,s.i0)({name:null!==(t=null==i?void 0:i.name)&&void 0!==t?t:"",onOk:e=>{var t=[...h];t[n].name=e,c(t)}});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.u,{spacing:12,content:a.o.t("Edit"),position:"top",children:(0,r.jsx)(d.hU,{color:"secondary",icon:(0,r.jsx)(l.JAz,{className:"text-14px"}),iconPosition:"left",size:"small",onClick:()=>p()})}),u]})}function p(e){var{index:t,record:n,params:i}=e;if(i.disableRetry)return null;var{onRetry:s}=i;return(0,r.jsx)(d.u,{spacing:12,content:a.o.t("datasets_unit_update_retry"),position:"top",children:(0,r.jsx)(d.hU,{color:"secondary",icon:(0,r.jsx)(l.mxP,{className:"text-14px"}),iconPosition:"left",size:"small",onClick:()=>{null==s||s(n,t)}})})}n("274971"),n("237365")},735997:function(e,t,n){"use strict";n.d(t,{n:function(){return u}});var i=n(808549),r=n(120454),s=n(151064);n(455069);var o=n(385038),a=n(336205),l=n(888461),d=n(561119),c=n(237365),h=(e,t,n)=>e===d.N.Failed?(0,s.jsx)("div",{"data-dtestid":"".concat(o.w.CreateUnitListProgressName,".","subText"),className:"text-12px",children:t||a.o.t("datasets_unit_upload_fail")}):n,u=e=>{var{unitList:t=[],getColumns:n}=e;return 0===t.length?null:(0,s.jsx)("div",{className:"upload-container",children:t.map((e,t)=>{var u=(0,c.Z)(null==e?void 0:e.status),p=(null==e?void 0:e.statusDescript)||"",{subText:f,actions:m,formatType:g}=n?n(e,t):{};return(0,s.jsx)(l.v,{mainText:e.name||"--",subText:h(u,p,f),tipText:(0,s.jsx)("span",{"data-dtestid":"".concat(o.w.LocalUploadListStatus,".").concat(e.name),children:u===d.N.Failed?p||a.o.t("datasets_unit_upload_fail"):a.o.t("datasets_unit_upload_success")}),status:u,avatar:(0,c.a)((0,r._)((0,i._)({},e),{formatType:g})),actions:m,percent:e.percent||10},e.uid)})})}},237365:function(e,t,n){"use strict";n.d(t,{Z:function(){return c},a:function(){return d}});var i=n(151064),r=n(537714),s=n(280053),o=n(775699),a=n(44172),l=n(561119),d=e=>{var{type:t,formatType:n,url:r}=e;return n===s.a5.Image&&["jpg","jpeg","png","webp"].includes(t)?(0,i.jsx)(o.Ee,{src:r,width:24,height:24,style:{borderRadius:"4px",marginRight:"12px",flexShrink:0}}):"md"===t?(0,i.jsx)(a.s7F,{}):"pdf"===t?(0,i.jsx)(a.I2v,{}):"docx"===t?(0,i.jsx)(a.KHq,{}):"txt"===t?(0,i.jsx)(a.KNN,{}):"xlsx"===t||"xltx"===t||"xls"===t?(0,i.jsx)(a.$lV,{}):"csv"===t?(0,i.jsx)(a.tsT,{}):n===s.a5.Table?(0,i.jsx)(a.LAr,{}):(0,i.jsx)(a.Hnk,{})},c=e=>e===r.Dm.UPLOADING||e===r.Dm.VALIDATING||e===r.Dm.WAIT||e===s.Vq.Handling||e===r.Ao.EntityStatusProcess?l.N.Processing:e===r.Dm.SUCCESS||e===s.Vq.Finish||e===r.Ao.EntityStatusSuccess?l.N.Complete:e===r.Dm.VALIDATE_FAIL||e===r.Dm.UPLOAD_FAIL||e===s.Vq.Failed||e===r.Ao.EntityStatusFail?l.N.Failed:l.N.Processing},861445:function(e,t,n){"use strict";n.d(t,{O7:function(){return i},WT:function(){return a},Yg:function(){return r},xT:function(){return s}});var i=100,r=3e3,s=[".xls",".xlsx",".csv"],o={DOUYIN:{acceptFileTypes:[".pdf",".txt",".doc",".docx"],fileFormatString:"PDF、TXT、DOC、DOCX",addUnitMaxLimit:100},DEFAULT:{acceptFileTypes:[".pdf",".txt",".docx",".md"],fileFormatString:"PDF、TXT、DOCX、MD",addUnitMaxLimit:300}},a=e=>e&&o[e]||o.DEFAULT},116497:function(e,t,n){"use strict";n.d(t,{G2:function(){return s},XC:function(){return o},ge:function(){return r}});var i,r=((i={})[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.THREE=3]="THREE",i[i.SEVEN=7]="SEVEN",i[i.THIRTY=30]="THIRTY",i),s=1e3,o=5e3},528751:function(e,t,n){"use strict";n.d(t,{pL:()=>a,O7:()=>s.O7,Q:()=>c,ge:()=>p.ge,hD:()=>d,XC:()=>p.XC,z2:()=>h,DU:()=>l,c3:()=>o,v1:()=>u.v,Px:()=>u.P,G2:()=>p.G2,Yg:()=>s.Yg});var i,r,s=n("861445");var o=((i={}).ERROR="error",i.LOADING="loading",i.NORMAL="normal",i),a=50,l=30;var d=((r={}).SHEET="sheet_id",r.KEY_START_ROW="header_line_idx",r.DATA_START_ROW="start_line_idx",r),c={sheet_id:0,header_line_idx:0,start_line_idx:1},h={sheet_id:0,header_line_idx:0,start_line_idx:0},u=n("461334"),p=n("116497")},461334:function(e,t,n){"use strict";n.d(t,{P:function(){return o},v:function(){return a}});var i=n(336205),r=n(288391),s=()=>({[r.IB.LINE_BREAK]:i.o.t("datasets_Custom_segmentID_linebreak"),[r.IB.LINE_BREAK2]:i.o.t("datasets_Custom_segmentID_2linebreak"),[r.IB.CN_PERIOD]:i.o.t("datasets_Custom_segmentID_cnperiod"),[r.IB.CN_EXCLAMATION]:i.o.t("datasets_Custom_segmentID_cn_exclamation"),[r.IB.EN_PERIOD]:i.o.t("datasets_Custom_segmentID_enperiod"),[r.IB.EN_EXCLAMATION]:i.o.t("datasets_Custom_segmentID_en_exclamation"),[r.IB.CN_QUESTION]:i.o.t("datasets_Custom_segmentID_cn_question"),[r.IB.EN_QUESTION]:i.o.t("datasets_Custom_segmentID_en_question"),[r.IB.CUSTOM]:i.o.t("datasets_Custom_segmentID_custom")}),o=()=>Object.entries(s()).map(e=>{var[t,n]=e;return{value:t,label:n}}),a={separator:{type:r.IB.LINE_BREAK,customValue:"###"},maxTokens:800,preProcessRules:[],overlap:10}},561119:function(e,t,n){"use strict";n.d(t,{N:function(){return r}});var i,r=((i={})[i.Processing=0]="Processing",i[i.Complete=1]="Complete",i[i.Failed=2]="Failed",i)},288391:function(e,t,n){"use strict";n.d(t,{IB:function(){return l},OX:function(){return o},dV:function(){return a}});var i,r,s,o=((i={})[i.AUTO=0]="AUTO",i[i.CUSTOM=1]="CUSTOM",i[i.LEVEL=2]="LEVEL",i);var a=((r={}).REMOVE_SPACES="remove_extra_spaces",r.REMOVE_EMAILS="remove_urls_emails",r);var l=((s={}).LINE_BREAK="\n",s.LINE_BREAK2="\n\n",s.CN_PERIOD="。",s.CN_EXCLAMATION="!",s.EN_PERIOD=".",s.EN_EXCLAMATION="!",s.CN_QUESTION="?",s.EN_QUESTION="?",s.CUSTOM="custom",s)},900539:function(e,t,n){"use strict";n.d(t,{As:function(){return E},BD:function(){return k},JD:function(){return S},V1:function(){return A},l$:function(){return y},mD:function(){return w},mZ:function(){return C},td:function(){return x},te:function(){return g},uA:function(){return b},wV:function(){return m},y3:function(){return _},zP:function(){return v}});var i=n(808549),r=n(120454),s=n(962289),o=n(22916),a=n(745474),l=n(537714),d=n(458620),c=n(336205),h=n(727914),u=n(280053),p=n(659596),f=n(528751),m=e=>{var{unitList:t,data:n,fileInstance:s,index:o}=e;return n?t.map((e,t)=>o===t?(0,r._)((0,i._)({},e),{uri:n.upload_uri||"",status:l.Dm.SUCCESS,percent:100,fileInstance:s}):e):t};function g(e){var t=e.filter(e=>e.status===u._m.Failed);t.length&&a.s5.errorEvent(a.xW.KNOWLEDGE,{eventName:d.b.KnowledgeGetTaskProgress,error:new h.sH(d.b.KnowledgeGetTaskProgress,"".concat(d.b.KnowledgeGetTaskProgress,": get progress fail. ").concat(JSON.stringify(t))),meta:{failIds:t}})}function v(e){return e.length>0&&e.every(e=>e.progress===f.O7||e.status===u._m.Failed)}var b=e=>{e.current&&(clearTimeout(e.current),e.current=void 0)};function y(){var e=(0,o.kF)();return(0,s.Z)(e,"opt",l.VP.ADD)}function x(){var e=(0,o.kF)();return(0,s.Z)(e,"docID",void 0)}var w=e=>{var t=e.lastIndexOf(".");return e.slice(t+1).toLowerCase()},_=e=>new Promise((t,n)=>{var i=new FileReader;i.onload=e=>{var i,r=null===(i=e.target)||void 0===i?void 0:i.result;if(!r||"string"!=typeof r){n(new h.sH("getBase64","file read invalid"));return}t(r.replace(/^.*?,/,""))},i.onerror=()=>{p.FN.error(c.o.t("read_file_failed_please_retry")),n(new h.sH("getBase64","file read fail"))},i.onabort=()=>{n(new h.sH("getBase64","file read abort"))},i.readAsDataURL(e)}),S=e=>new Promise((t,n)=>{var i=new FileReader;i.onload=e=>{var i;(null===(i=e.target)||void 0===i?void 0:i.result)?t(new Uint8Array(e.target.result)):n(new h.sH("getUint8Array","file read invalid"))},i.readAsArrayBuffer(e)});function E(e,t){var n=e.filter(e=>e.status===u._m.Failed);n.length>0&&a.s5.errorEvent(a.xW.KNOWLEDGE,{eventName:t,error:new h.sH(t,"".concat(t,": fail document_ids are ").concat(JSON.stringify(n))),meta:{failDocumentIds:n}})}var C=e=>c.o.t("knowledge_add_unit_process_notice"),A=(e,t)=>e===l.VP.RESEGMENT&&t&&[l.Cm.TABLE_GOOGLE_DRIVE,l.Cm.TABLE_FEISHU].includes(t),k=e=>e===l.VP.INCREMENTAL},274971:function(e,t,n){"use strict";n.d(t,{wO:()=>i.wO,hd:()=>i.hd,l$:()=>r.l$,VR:()=>s.VR,V1:()=>r.V1,y3:()=>r.y3,mZ:()=>r.mZ,mD:()=>r.mD,zP:()=>r.zP,JD:()=>r.JD,td:()=>r.td,As:()=>r.As,UQ:()=>o,te:()=>r.te,wV:()=>r.wV,BD:()=>r.BD,OP:()=>i.OP,uA:()=>r.uA});var i=n("690612"),r=n("900539"),s=n("417062");function o(e){return!1}n("888711")},690612:function(e,t,n){"use strict";n.d(t,{OP:function(){return a},bp:function(){return l},hd:function(){return o},wO:function(){return c}});var i=n(962289),r=n(336205),s=n(528751),o=e=>({[s.ge.ZERO]:r.o.t("datasets_frequencyModal_frequency_noUpdate"),[s.ge.ONE]:r.o.t("datasets_frequencyModal_frequency_day",{num:1}),[s.ge.THREE]:r.o.t("datasets_frequencyModal_frequency_day",{num:3}),[s.ge.SEVEN]:r.o.t("datasets_frequencyModal_frequency_day",{num:7}),[s.ge.THIRTY]:r.o.t("datasets_frequencyModal_frequency_day",{num:30})})[e],a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=!0,i="";return e?(/["'`\\]+/g.test(e)&&(n=!1,i=r.o.t("knowledge_tableStructure_field_errLegally")),["_knowledge_slice_id"].includes(e)&&(n=!1,i=r.o.t("knowledge_tableStructure_errSystemField")),{valid:n,errorMsg:i}):{valid:!1,errorMsg:t}},l=e=>{if(!e)return[];var t=e.match(/<img[^>]+src\s*=\s*['"]([^'"]+)['"][^>]*>/g),n=[];if(t)for(var i=0;i<t.length;i++){var r,s=null===(r=t[i].match(/src\s*=\s*['"]([^'"]+)['"]/))||void 0===r?void 0:r[1];s&&n.push(s)}return n},d=e=>Object.values(s.hD).includes(e),c=e=>{var t={sheet_id:"",header_line_idx:"",start_line_idx:""};return Object.keys(e).reduce((t,n)=>(d(n)&&(t[n]=String((0,i.Z)(e,n))),t),t),t}},417062:function(e,t,n){"use strict";n.d(t,{VR:function(){return a}});var i=n(280053),r=n(461334),s=n(288391),o=e=>e.chunk_type===i.x2.CustomChunk?s.OX.CUSTOM:e.chunk_type===i.x2.LevelChunk?s.OX.LEVEL:s.OX.AUTO,a=e=>{if(e&&Object.keys(e)&&(null==e?void 0:e.chunk_strategy))try{var t=(null==e?void 0:e.chunk_strategy)||{},n=[];return t.remove_extra_spaces&&n.push(s.dV.REMOVE_SPACES),t.remove_urls_emails&&n.push(s.dV.REMOVE_EMAILS),{docInfo:e,segmentMode:o(null==e?void 0:e.chunk_strategy),segmentRule:{separator:t.separator?l(t.separator):r.v.separator,maxTokens:t.max_tokens?Number(t.max_tokens):r.v.maxTokens,preProcessRules:n,overlap:t.overlap?Number(t.overlap):r.v.overlap}}}catch(e){}},l=e=>(function(e){var t=[];for(var[,n]of Object.entries(e))n!==e.CUSTOM&&t.push(n);return t})(s.IB).indexOf(e)>-1?{type:e}:{type:s.IB.CUSTOM,customValue:e}},888711:function(e,t,n){"use strict";n.d(t,{Y:function(){return s}});var i=n(537714),r=n(288391),s=(e,t)=>{if(e===r.OX.CUSTOM){var n=(null==t?void 0:t.maxTokens)||0,s=null==t?void 0:t.separator,o=(null==s?void 0:s.type)===r.IB.CUSTOM&&!(null==s?void 0:s.customValue);if(0===n||o||"number"!=typeof t.overlap||Number.isNaN(t.overlap))return i.xZ.DISABLE}return i.xZ.ENABLE}},768905:function(e,t,n){"use strict";n.r(t),n.d(t,{KnowledgeUploadPage:function(){return p}});var i=n(808549),r=n(120454),s=n(151064),o=n(157728),a=n(517465),l=n.n(a),d=n(22916),c=n(537714),h=n(331362),u=n(214942),p=()=>{var e=(0,o.useNavigate)(),t=(0,u.rY)(e=>e.space.id),n=new URLSearchParams(location.search),a=n.get("type")||c.Cm.TEXT_DOC,p=n.get("opt")||c.VP.ADD,f=n.get("doc_id")||"",m="true"===n.get("is_douyin"),{dataset_id:g,space_id:v}=(0,o.useParams)(),b={datasetID:g||"",spaceID:v||"",type:a,opt:p,docID:f,isDouyinBot:m,biz:"library"},y=(0,h.g)(null!=a?a:c.Cm.TEXT,null!=p?p:c.VP.ADD);return y?(0,s.jsx)(d.S9,{params:(0,r._)((0,i._)({},b),{spaceID:t}),resourceNavigate:{toResource:(t,n,i,r)=>e("/space/".concat(b.spaceID,"/").concat(t,"/").concat(n,"?").concat(l().stringify(i)),r),upload:(t,n)=>e("/space/".concat(b.spaceID,"/knowledge/").concat(b.datasetID,"/upload?").concat(l().stringify(t)),n)},children:(0,s.jsx)(h.z,{uploadConfig:y})}):(0,s.jsx)(s.Fragment,{})}},105452:function(e,t,n){"use strict";var i=n(407821),r=n.n(i),s=n(472772),o=n.n(s),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(136965),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=o(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},210208:function(e,t,n){"use strict";var i=n(407821),r=n.n(i),s=n(472772),o=n.n(s),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(716998),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=o(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},151359:function(e,t,n){"use strict";var i=n(407821),r=n.n(i),s=n(472772),o=n.n(s),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(903687),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=o(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},391757:function(e,t,n){"use strict";var i=n(407821),r=n.n(i),s=n(472772),o=n.n(s),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(264622),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=o(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},928589:function(e,t,n){"use strict";var i=n(407821),r=n.n(i),s=n(472772),o=n.n(s),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(238205),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=o(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},116458:function(e){"use strict";e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC"},541269:function(e,t,n){"use strict";e.exports=n.p+"static/image/delete-operation-en.44b1f340.png"},193604:function(e,t,n){"use strict";e.exports=n.p+"static/image/delete-operation.97fc5d6f.png"},127139:function(e,t,n){"use strict";e.exports=n.p+"static/image/level-operation.423f9b14.png"},615739:function(e,t,n){"use strict";e.exports=n.p+"static/image/merge-operation-en.76af0b44.png"},728901:function(e,t,n){"use strict";e.exports=n.p+"static/image/merge-operation.d9654306.png"},637667:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".browse-detail-modal-G7py31{padding-bottom:40px}.browse-detail-modal-main-OiglzK{color:#1c1f23;align-items:center;margin-bottom:16px;font-size:14px;font-weight:600;line-height:20px;display:flex}.browse-detail-modal-main-image-Q8aVNY{background-color:#98cdfd;border-radius:2px;flex-shrink:0;justify-content:center;align-items:center;width:18px;height:18px;margin-right:7px;display:flex}.browse-detail-modal-main-title-EEkSF8{max-width:40%}.browse-detail-modal-main-url-Kbqole{color:rgba(28,31,35,.35);max-width:40%;margin-left:7px;font-size:12px;font-weight:400;line-height:16px}.browse-detail-modal-collapse-T8YH3_{background-color:#f5f5f5;border-radius:4px;max-height:400px;overflow-y:auto}.browse-detail-modal-collapse-T8YH3_ .semi-collapse-item{border-color:#efefef!important}.browse-detail-modal-collapse-T8YH3_ .semi-input-textarea-wrapper{background-color:transparent!important;border:none!important}.browse-modal-header-U4nuzC{flex-wrap:nowrap;align-items:center;padding:24px 0;display:flex}.browse-modal-header-left-AI0E76{align-items:center;display:flex}.browse-modal-header-left-icon-cYcFqE{margin-right:8px}.modal-i1yfPQ.upgrade-level-uuygZh .semi-modal-body{height:0;padding-bottom:0}.modal-i1yfPQ.upgrade-level-uuygZh .semi-modal-content{background-color:var(--semi-color-tertiary-light-default)}.browse-detail-tooltip-ZTxCjJ{word-wrap:break-word;width:200px}.browse-source-url-_vmPyT{color:rgba(29,28,36,.35);margin-top:12px;font-size:12px;font-style:normal;font-weight:400;line-height:16px}",""]),o.locals={"browse-detail-modal":"browse-detail-modal-G7py31",browseDetailModal:"browse-detail-modal-G7py31","browse-detail-modal-main":"browse-detail-modal-main-OiglzK",browseDetailModalMain:"browse-detail-modal-main-OiglzK","browse-detail-modal-main-image":"browse-detail-modal-main-image-Q8aVNY",browseDetailModalMainImage:"browse-detail-modal-main-image-Q8aVNY","browse-detail-modal-main-title":"browse-detail-modal-main-title-EEkSF8",browseDetailModalMainTitle:"browse-detail-modal-main-title-EEkSF8","browse-detail-modal-main-url":"browse-detail-modal-main-url-Kbqole",browseDetailModalMainUrl:"browse-detail-modal-main-url-Kbqole","browse-detail-modal-collapse":"browse-detail-modal-collapse-T8YH3_",browseDetailModalCollapse:"browse-detail-modal-collapse-T8YH3_","browse-modal-header":"browse-modal-header-U4nuzC",browseModalHeader:"browse-modal-header-U4nuzC","browse-modal-header-left":"browse-modal-header-left-AI0E76",browseModalHeaderLeft:"browse-modal-header-left-AI0E76","browse-modal-header-left-icon":"browse-modal-header-left-icon-cYcFqE",browseModalHeaderLeftIcon:"browse-modal-header-left-icon-cYcFqE",modal:"modal-i1yfPQ","upgrade-level":"upgrade-level-uuygZh",upgradeLevel:"upgrade-level-uuygZh","browse-detail-tooltip":"browse-detail-tooltip-ZTxCjJ",browseDetailTooltip:"browse-detail-tooltip-ZTxCjJ","browse-source-url":"browse-source-url-_vmPyT",browseSourceUrl:"browse-source-url-_vmPyT"},t.Z=o},848001:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".card-radio-group-wzfiJX{gap:4px}.card-radio-group-wzfiJX .semi-radio{border-radius:8px;padding:12px}.card-radio-group-wzfiJX .semi-radio:hover{background-color:var(--coz-mg-secondary-hovered)}.card-radio-group-wzfiJX .semi-radio:active{background-color:var(--coz-mg-secondary-pressed)}.card-radio-group-wzfiJX .semi-radio.semi-radio-checked{background-color:var(--coz-mg-card);border-width:1.5px;padding:11.5px}.card-radio-group-wzfiJX .semi-radio-content{flex-grow:1}.card-radio-group-wzfiJX .semi-radio-content .semi-radio-addon{font-weight:500}.card-radio-group-wzfiJX .semi-radio-content .semi-radio-extra{font-size:12px;line-height:16px}",""]),o.locals={"card-radio-group":"card-radio-group-wzfiJX",cardRadioGroup:"card-radio-group-wzfiJX"},t.Z=o},343155:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".load-failure-cflv8K{min-height:400px}.loading-gWseuj{justify-content:center;align-items:center;width:100%;min-height:400px;display:flex}.loading-content-mQodwK{color:rgba(29,28,35,.35);margin-left:8px;font-family:SF Pro Display;font-size:14px;font-style:normal;font-weight:400;line-height:20px}",""]),o.locals={"load-failure":"load-failure-cflv8K",loadFailure:"load-failure-cflv8K",loading:"loading-gWseuj","loading-content":"loading-content-mQodwK",loadingContent:"loading-content-mQodwK"},t.Z=o},893121:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".auth-empty-wrapper-fr6klo{justify-content:center;align-items:center;height:calc(100% - 112px);display:flex}.auth-empty-wrapper-fr6klo .auth-empty-Xjao95{flex-direction:column;align-items:center;display:flex}.auth-empty-wrapper-fr6klo .auth-empty-image-VDpxNW{justify-content:center;align-items:center;width:140px;height:140px;display:flex}.auth-empty-wrapper-fr6klo .auth-empty-description-nlZRXc{color:var(--coz-fg-primary);margin-top:16px;font-size:16px;font-weight:600;line-height:22px}.auth-empty-wrapper-fr6klo .auth-empty-second-desc-VD10hC{color:var(--coz-fg-secondary);margin-top:4px;font-size:14px;line-height:20px}.auth-empty-wrapper-fr6klo .auth-empty-button-ugpRLF{margin-top:21px}",""]),o.locals={"auth-empty-wrapper":"auth-empty-wrapper-fr6klo",authEmptyWrapper:"auth-empty-wrapper-fr6klo","auth-empty":"auth-empty-Xjao95",authEmpty:"auth-empty-Xjao95","auth-empty-image":"auth-empty-image-VDpxNW",authEmptyImage:"auth-empty-image-VDpxNW","auth-empty-description":"auth-empty-description-nlZRXc",authEmptyDescription:"auth-empty-description-nlZRXc","auth-empty-second-desc":"auth-empty-second-desc-VD10hC",authEmptySecondDesc:"auth-empty-second-desc-VD10hC","auth-empty-button":"auth-empty-button-ugpRLF",authEmptyButton:"auth-empty-button-ugpRLF"},t.Z=o},49630:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".auth-empty-wrapper-RhjsLq{justify-content:center;align-items:center;height:calc(100% - 112px);display:flex}.auth-empty-wrapper-RhjsLq .auth-empty-Sl0qKt{flex-direction:column;align-items:center;display:flex}.auth-empty-wrapper-RhjsLq .auth-empty-image-UXdNZu{justify-content:center;align-items:center;width:140px;height:140px;display:flex}.auth-empty-wrapper-RhjsLq .auth-empty-description-PkOJj9{color:var(--Light-usage-text---color-text-0,#1d1c23);margin-top:16px;font-size:16px;font-weight:600;line-height:22px}.auth-empty-wrapper-RhjsLq .auth-empty-second-desc-Nuf4Nr{color:var(--Light-usage-text---color-text-2,rgba(29,28,35,.6));margin-top:4px;font-size:14px;line-height:20px}.auth-empty-wrapper-RhjsLq .auth-empty-button-X6asn5{margin-top:21px}",""]),o.locals={"auth-empty-wrapper":"auth-empty-wrapper-RhjsLq",authEmptyWrapper:"auth-empty-wrapper-RhjsLq","auth-empty":"auth-empty-Sl0qKt",authEmpty:"auth-empty-Sl0qKt","auth-empty-image":"auth-empty-image-UXdNZu",authEmptyImage:"auth-empty-image-UXdNZu","auth-empty-description":"auth-empty-description-PkOJj9",authEmptyDescription:"auth-empty-description-PkOJj9","auth-empty-second-desc":"auth-empty-second-desc-Nuf4Nr",authEmptySecondDesc:"auth-empty-second-desc-Nuf4Nr","auth-empty-button":"auth-empty-button-X6asn5",authEmptyButton:"auth-empty-button-X6asn5"},t.Z=o},417478:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".frequency-form-item-SghTVA .title-AvpUA4{box-sizing:border-box;color:var(--coz-fg-secondary);flex-shrink:0;margin-bottom:8px;font-size:12px;line-height:16px;display:block}.frequency-form-item-SghTVA .content-pU2lYR{flex:1}",""]),o.locals={"frequency-form-item":"frequency-form-item-SghTVA",frequencyFormItem:"frequency-form-item-SghTVA",title:"title-AvpUA4",content:"content-pU2lYR"},t.Z=o},136965:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".progress-wrap-aG7E1c{background:var(--coz-mg-card);border:1px solid var(--coz-stroke-primary);border-radius:var(--default,8px);align-self:stretch;align-items:center;gap:10px;padding:8px 10px;display:flex;overflow:hidden}.progress-wrap-aG7E1c .content-oMctjI{z-index:1}.progress-wrap-aG7E1c .progress-rFtZNC{background:linear-gradient(rgba(148,152,247,.44),rgba(255,255,255,0));position:absolute;top:0;bottom:0;left:0}.progress-wrap-aG7E1c .info-HxV9yH .main-text-MMJMjm{color:var(--coz-fg-primary);font-size:14px;line-height:20px}.progress-wrap-aG7E1c .info-HxV9yH .sub-text-fLSQkk{color:var(--coz-fg-secondary);font-size:12px;line-height:16px}.progress-wrap-aG7E1c .info-HxV9yH .desc-perJT2{display:block}.progress-wrap-aG7E1c .info-HxV9yH .tip-desc-zJnp5I{display:none}.progress-wrap-aG7E1c .info-HxV9yH .semi-image{margin-right:0!important}.progress-wrap-aG7E1c:hover .info-HxV9yH .desc-perJT2{display:none}.progress-wrap-aG7E1c:hover .info-HxV9yH .tip-desc-zJnp5I{display:block}.progress-wrap-aG7E1c.processing-failed-Ngh1Ak{border:1px solid var(--coz-stroke-hglt-red)}.progress-wrap-aG7E1c.processing-failed-Ngh1Ak .sub-text-fLSQkk{color:var(--coz-fg-hglt-red)!important}.progress-wrap-aG7E1c.processing-EXtgs8:hover .info-HxV9yH .desc-perJT2{display:block}.progress-wrap-aG7E1c.processing-EXtgs8:hover .info-HxV9yH .tip-desc-zJnp5I{display:none}.progress-wrap-aG7E1c .right-d4B8Yg{z-index:2}.progress-wrap-aG7E1c .percent-_hawuy{color:var(--coz-fg-primary);text-align:right;text-overflow:ellipsis;font-size:14px;font-style:normal;font-weight:400;line-height:20px}.progress-wrap-aG7E1c .actions-iVWvwU{display:none}.progress-wrap-aG7E1c:hover .actions-iVWvwU{display:block}",""]),o.locals={"progress-wrap":"progress-wrap-aG7E1c",progressWrap:"progress-wrap-aG7E1c",content:"content-oMctjI",progress:"progress-rFtZNC",info:"info-HxV9yH","main-text":"main-text-MMJMjm",mainText:"main-text-MMJMjm","sub-text":"sub-text-fLSQkk",subText:"sub-text-fLSQkk",desc:"desc-perJT2","tip-desc":"tip-desc-zJnp5I",tipDesc:"tip-desc-zJnp5I","processing-failed":"processing-failed-Ngh1Ak",processingFailed:"processing-failed-Ngh1Ak",processing:"processing-EXtgs8",right:"right-d4B8Yg",percent:"percent-_hawuy",actions:"actions-iVWvwU"},t.Z=o},716998:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".table-preview-RdOhnY{flex-direction:column;flex:1;display:flex;overflow:hidden}.table-preview-title-j9ZsaQ{height:32px;color:var(--coz-fg-plus);align-items:center;margin-bottom:5px;font-size:14px;font-style:normal;font-weight:600;line-height:20px;display:flex}.table-preview-RdOhnY .semantic-tag-v5UgTT,.table-preview-RdOhnY .column-type-fL_9tS{margin-left:6px}.table-preview-RdOhnY .preview-tips-tVs0lE{color:var(--coz-fg-dim);text-align:left;letter-spacing:0;margin-top:8px;font-size:12px;font-weight:400;line-height:20px}.table-preview-RdOhnY .no-result-auNDcw{flex-direction:column;justify-content:center;align-items:center;width:100%;height:448px;display:flex}.table-preview-RdOhnY .no-result-tips-lC6ADQ{color:var(--coz-fg-plus);margin-top:16px;font-size:16px;font-style:normal;font-weight:600;line-height:22px}.table-preview-content-Pn5Efi{overflow:auto}.table-preview-content-Pn5Efi th{background-color:transparent!important}.table-preview-content-Pn5Efi tr{background-color:transparent!important}.table-preview-content-Pn5Efi .semi-table-wrapper{height:100%;margin-top:0}.table-preview-content-Pn5Efi .semi-table-wrapper .coz-tag{font-weight:400}.table-preview-content-Pn5Efi .coz-table-wrapper .coz-table-list-hover .semi-table-row:hover>.semi-table-row-cell:before{background-color:transparent}.table-preview-content-Pn5Efi .coz-table-wrapper .coz-table-list-hover .semi-table-row:hover>.semi-table-row-cell:first-child{border-top-left-radius:0;border-bottom-left-radius:0}.table-preview-content-Pn5Efi .coz-table-wrapper .coz-table-list .semi-table-thead>.semi-table-row>.semi-table-row-head{color:var(--coz-fg-secondary);font-size:12px;font-weight:500}.table-preview-content-Pn5Efi .coz-table-wrapper .coz-table-list .semi-table-tbody>.semi-table-row>.semi-table-row-cell{height:56px;text-align:unset}.table-preview-content-Pn5Efi .coz-table-wrapper .coz-table-list .semi-table-tbody>.semi-table-row>.semi-table-row-cell .semi-typography{color:var(--coz-fg-secondary)}.table-preview-content-Pn5Efi .coz-table-wrapper .coz-table-list .semi-table-container>.semi-table-body{padding-top:0}.table-preview-content-Pn5Efi .coz-table-wrapper .coz-table-list .semi-table-tbody>.semi-table-row:last-child>.semi-table-row-cell{border-bottom:1px solid var(--coz-stroke-primary)}.table-preview-content-Pn5Efi .semi-table-header{z-index:99;position:-webkit-sticky;position:sticky;overflow-y:hidden!important}.table-preview-content-Pn5Efi .semi-table-colgroup .semi-table-col{min-width:200px}.table-preview-content-Pn5Efi .semi-table-tbody>.semi-table-row>.semi-table-row-cell{min-height:40px;padding:9px 16px!important}.table-preview-content-Pn5Efi .semi-table-tbody .semi-table-row:hover>.semi-table-row-cell{border-bottom:1px solid var(--coz-stroke-primary);background-color:transparent!important;background-image:none!important}.td-title-jJaSXe{align-items:center;display:flex}",""]),o.locals={"table-preview":"table-preview-RdOhnY",tablePreview:"table-preview-RdOhnY","table-preview-title":"table-preview-title-j9ZsaQ",tablePreviewTitle:"table-preview-title-j9ZsaQ","semantic-tag":"semantic-tag-v5UgTT",semanticTag:"semantic-tag-v5UgTT","column-type":"column-type-fL_9tS",columnType:"column-type-fL_9tS","preview-tips":"preview-tips-tVs0lE",previewTips:"preview-tips-tVs0lE","no-result":"no-result-auNDcw",noResult:"no-result-auNDcw","no-result-tips":"no-result-tips-lC6ADQ",noResultTips:"no-result-tips-lC6ADQ","table-preview-content":"table-preview-content-Pn5Efi",tablePreviewContent:"table-preview-content-Pn5Efi","td-title":"td-title-jJaSXe",tdTitle:"td-title-jJaSXe"},t.Z=o},903687:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".table-setting-bar-a5JPpu{width:100%;margin-bottom:30px}.table-setting-bar-a5JPpu .semi-form-horizontal .semi-form-field{flex:1}.table-setting-bar-a5JPpu .semi-form-horizontal .semi-form-field .semi-select{border-radius:8px;width:100%}.table-setting-bar-a5JPpu .semi-form-field-label-text{color:var(--coz-fg-plus);font-size:14px;font-style:normal;font-weight:500;line-height:24px}.table-setting-bar-a5JPpu .semi-form-field-label{align-items:center;height:24px;margin-bottom:4px;display:flex}.table-setting-bar-a5JPpu .semi-form-horizontal .semi-form-field:last-child{margin-right:0;padding-right:0}",""]),o.locals={"table-setting-bar":"table-setting-bar-a5JPpu",tableSettingBar:"table-setting-bar-a5JPpu"},t.Z=o},264622:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".table-structure-wrapper-UotMHC{flex:1;height:100%;overflow:hidden}.structure-wrapper-ALSVya{flex-direction:column;display:flex;overflow:hidden}.drag-table-wWjfw6 .semi-table-container .semi-table-tbody .semi-table-row .semi-table-row-cell:first-child{padding-left:16px!important}.table-structure-XrsiMG{border-radius:8px;overflow:hidden;margin-top:4px!important}.table-structure-XrsiMG .semi-spin{height:100%}.table-structure-XrsiMG .semi-spin-children{height:100%}.table-structure-XrsiMG .semi-table-fixed-header{height:100%}.table-structure-XrsiMG .semi-table-container{height:100%}.table-structure-required-container-UyIP6_{align-items:center;display:flex}.table-structure-col-required-Z1g12T{color:var(--coz-fg-hglt-red);text-overflow:ellipsis;margin-top:4px;font-size:12px;font-style:normal;font-weight:600;line-height:16px}.table-structure-XrsiMG .input-suffix-y7iErZ{margin-right:5px;font-size:12px;display:inline-block}.table-structure-XrsiMG .input-error-msg-d1JQO6{z-index:100;color:var(--coz-fg-hglt-red);margin-top:4px;margin-bottom:-20px;font-size:12px;font-style:normal;font-weight:400;line-height:16px;position:relative}.table-structure-XrsiMG .semantic-radio-TDSa9p{align-items:center;height:100%;padding-left:2px;display:flex;position:relative}.table-structure-XrsiMG .column-item-action-j7uaYU{align-items:center;height:100%;padding-top:3px;padding-left:7px;display:flex}.table-structure-XrsiMG .column-item-action-delete-fypzZy{cursor:pointer;font-size:14px}.table-structure-XrsiMG .column-item-Qnr35T{flex-direction:column;height:100%;display:flex}.table-structure-XrsiMG .column-item-value-ZKkacM{color:var(--coz-fg-secondary);text-overflow:ellipsis;font-size:14px;line-height:32px}.table-structure-XrsiMG .structure-table-drag-icon{opacity:0;position:absolute;left:-16px}.table-structure-XrsiMG .semi-table-row:hover .structure-table-drag-icon{opacity:1}.table-structure-XrsiMG .semi-table-row:focus .structure-table-drag-icon{opacity:1}.table-structure-XrsiMG .semi-table-thead>.semi-table-row>.semi-table-row-head{color:var(--coz-fg-secondary)!important;font-size:12px!important}.table-structure-XrsiMG .semi-table-container .semi-table-body{padding-bottom:12px;height:calc(100% - 39px)!important}.table-structure-XrsiMG .select-error-text{padding-top:0!important}.table-structure-XrsiMG .singleline-select-error-content{height:0}.table-structure-XrsiMG .semi-table-thead>.semi-table-row>.semi-table-row-head:first-child{padding-left:8px}.table-structure-XrsiMG .semi-table-thead>.semi-table-row>.semi-table-row-head{background-color:transparent!important}.table-structure-XrsiMG .semi-table-tbody>.semi-table-row{background-color:transparent!important}.table-structure-XrsiMG .semi-table-tbody>.semi-table-row>.semi-table-cell-fixed-left{background-color:transparent!important}.table-structure-XrsiMG .semi-table-thead>.semi-table-row>.semi-table-row-head.semi-table-cell-fixed-left:before{background-color:transparent!important}.table-structure-XrsiMG .semi-table-tbody{padding:5px 0}.table-structure-XrsiMG .semi-table-tbody .semi-table-row .semi-table-row-cell{border-bottom:0;height:56px!important;padding:12px 8px!important}.table-structure-XrsiMG .semi-table-tbody .semi-table-row .semi-table-row-cell:first-child{border-radius:0!important;padding-left:8px!important;padding-right:28px!important}.table-structure-XrsiMG .semi-table-tbody .semi-table-row:hover{cursor:auto;background:var(--coz-mg-secondary-hovered)}.table-structure-XrsiMG .semi-table-tbody .semi-table-row:hover>.semi-table-row-cell{background:0 0!important;border-bottom:0!important}.table-header-tooltip-Yh0j21{align-items:center;display:flex}.table-structure-bar-title-Naiqz6{height:32px;color:var(--coz-fg-plus);align-items:center;font-size:14px;font-style:normal;font-weight:600;display:flex}.table-structure-bar-title-Naiqz6 .icon-KXcibB{margin-top:3px;margin-left:4px}",""]),o.locals={"table-structure-wrapper":"table-structure-wrapper-UotMHC",tableStructureWrapper:"table-structure-wrapper-UotMHC","structure-wrapper":"structure-wrapper-ALSVya",structureWrapper:"structure-wrapper-ALSVya","drag-table":"drag-table-wWjfw6",dragTable:"drag-table-wWjfw6","table-structure":"table-structure-XrsiMG",tableStructure:"table-structure-XrsiMG","table-structure-required-container":"table-structure-required-container-UyIP6_",tableStructureRequiredContainer:"table-structure-required-container-UyIP6_","table-structure-col-required":"table-structure-col-required-Z1g12T",tableStructureColRequired:"table-structure-col-required-Z1g12T","input-suffix":"input-suffix-y7iErZ",inputSuffix:"input-suffix-y7iErZ","input-error-msg":"input-error-msg-d1JQO6",inputErrorMsg:"input-error-msg-d1JQO6","semantic-radio":"semantic-radio-TDSa9p",semanticRadio:"semantic-radio-TDSa9p","column-item-action":"column-item-action-j7uaYU",columnItemAction:"column-item-action-j7uaYU","column-item-action-delete":"column-item-action-delete-fypzZy",columnItemActionDelete:"column-item-action-delete-fypzZy","column-item":"column-item-Qnr35T",columnItem:"column-item-Qnr35T","column-item-value":"column-item-value-ZKkacM",columnItemValue:"column-item-value-ZKkacM","table-header-tooltip":"table-header-tooltip-Yh0j21",tableHeaderTooltip:"table-header-tooltip-Yh0j21","table-structure-bar-title":"table-structure-bar-title-Naiqz6",tableStructureBarTitle:"table-structure-bar-title-Naiqz6",icon:"icon-KXcibB"},t.Z=o},14909:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".embed-progress-rIEMwe{flex:1}.embed-progress-rIEMwe .progress-info-hfP0J8{width:100%}.embed-progress-rIEMwe .progress-info-hfP0J8 .text-g0239m{height:32px;color:var(--coz-fg-primary);align-items:center;margin-bottom:8px;font-size:14px;font-style:normal;font-weight:500;line-height:20px;display:flex}.embed-progress-rIEMwe .progress-info-hfP0J8 .progress-list-GBBk7a{max-height:532px;overflow-y:auto}.embed-progress-rIEMwe .banner-ydKIT1{width:100%}.embed-progress-rIEMwe .progress-success-icon-VoWH3W>svg{width:16px;height:16px}.embed-progress-rIEMwe .progress-success-icon-VoWH3W>svg>path{fill:var(--semi-color-primary)}.data-processing-S9ldN3 .finish-text-YYzx_J{color:var(--coz-fg-primary);text-align:right;text-overflow:ellipsis;font-size:14px;font-style:normal;font-weight:400;line-height:20px;overflow:hidden}.data-processing-S9ldN3 .process-progress-item-actions{display:block!important}",""]),o.locals={"embed-progress":"embed-progress-rIEMwe",embedProgress:"embed-progress-rIEMwe","progress-info":"progress-info-hfP0J8",progressInfo:"progress-info-hfP0J8",text:"text-g0239m","progress-list":"progress-list-GBBk7a",progressList:"progress-list-GBBk7a",banner:"banner-ydKIT1","progress-success-icon":"progress-success-icon-VoWH3W",progressSuccessIcon:"progress-success-icon-VoWH3W","data-processing":"data-processing-S9ldN3",dataProcessing:"data-processing-S9ldN3","finish-text":"finish-text-YYzx_J",finishText:"finish-text-YYzx_J"},t.Z=o},135987:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".upload-footer-HwRnxg{justify-content:flex-end;margin-top:auto;margin-bottom:18px;padding-top:24px;padding-bottom:24px;line-height:32px;display:flex}.upload-footer-HwRnxg .semi-button{margin-left:10px}",""]),o.locals={"upload-footer":"upload-footer-HwRnxg",uploadFooter:"upload-footer-HwRnxg"},t.Z=o},238205:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".upload-si61kX{width:100%}.upload-si61kX .semi-upload-drag-area{background-color:var(--coz-mg-card);border-radius:8px;height:202px}.upload-si61kX .semi-upload-drag-area:hover{border-radius:var(--default,8px)}.upload-si61kX .semi-upload-drag-area.semi-upload-drag-area-legal{border-radius:var(--default,8px)}.upload-si61kX .semi-upload-drag-area-sub-text{color:var(--coz-fg-dim)}.upload-si61kX .semi-button-with-icon-only{border-radius:4px}.upload-si61kX .semi-upload-file-list{display:none}.upload-icon-iaQIvU{width:32px;height:32px}.create-enough-file-gKQjYO{cursor:not-allowed;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;display:flex}.create-enough-file-gKQjYO .picture-rutWZA{width:122px;height:122px;margin-bottom:14px}.create-enough-file-gKQjYO .text-fu7IXG{color:rgba(28,31,35,.6);font-size:12px;line-height:16px}",""]),o.locals={upload:"upload-si61kX","upload-icon":"upload-icon-iaQIvU",uploadIcon:"upload-icon-iaQIvU","create-enough-file":"create-enough-file-gKQjYO",createEnoughFile:"create-enough-file-gKQjYO",picture:"picture-rutWZA",text:"text-fu7IXG"},t.Z=o},716437:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,'.segment-radio-wrapper-TKAZbc .displayNone-dkIssP{display:none}.segment-radio-wrapper-TKAZbc .custom-wrapper-mHiLQ2{width:100%;position:relative}.segment-radio-wrapper-TKAZbc .custom-wrapper-mHiLQ2 .form-segment-_4or5l{margin-top:33px;margin-bottom:15px}.segment-radio-wrapper-TKAZbc .custom-wrapper-mHiLQ2 .form-segment-_4or5l .item-yNLwbz{margin-bottom:20px}.segment-radio-wrapper-TKAZbc .custom-wrapper-mHiLQ2 .form-segment-_4or5l .item-yNLwbz .label-B8cOJV{color:var(--coz-fg-primary);margin-bottom:8px;font-size:14px;font-weight:600;line-height:22px;display:block}.segment-radio-wrapper-TKAZbc .custom-wrapper-mHiLQ2 .form-segment-_4or5l .item-yNLwbz .label-red-ynWrpC:after{content:"*";color:var(--coz-fg-hglt-red);margin-left:4px;font-weight:600}.segment-radio-wrapper-TKAZbc .custom-wrapper-mHiLQ2 .form-segment-_4or5l .item-yNLwbz .custom-input-XsgTSG{margin-top:8px}.segment-radio-wrapper-TKAZbc .line-LbCaPK:before{content:"";background:var(--light-usage-border-color-border,rgba(28,31,35,.08));width:100%;height:1px;margin-top:26px;display:inline-block;position:absolute;top:10px}.segment-radio-wrapper-TKAZbc .semi-radioGroup.semi-radioGroup-vertical{row-gap:16px}.segment-radio-wrapper-TKAZbc .semi-radioGroup .semi-radio-content{flex-grow:1}.segment-radio-wrapper-TKAZbc .semi-radioGroup .custom-wrapper{padding-bottom:0}.segment-radio-wrapper-TKAZbc .semi-radioGroup .custom-wrapper .semi-input-default{border-radius:8px}.segment-radio-wrapper-TKAZbc .semi-radioGroup .custom-wrapper .semi-input-wrapper-focus{border-radius:8px}.segment-radio-wrapper-TKAZbc .semi-radio-cardRadioGroup{border:1px solid var(--coz-stroke-plus);border-radius:8px;padding:16px 16px 16px 19px}.segment-radio-wrapper-TKAZbc .semi-radio-cardRadioGroup:hover{background:var(--coz-mg-secondary-hovered)}.segment-radio-wrapper-TKAZbc .semi-radio-cardRadioGroup:active{background:var(--coz-mg-secondary-pressed)}.segment-radio-wrapper-TKAZbc .semi-radio-cardRadioGroup .semi-radio-extra{margin-top:4px}.segment-radio-wrapper-TKAZbc .semi-radio-cardRadioGroup_checked{background:var(--coz-mg-hglt);border:1px solid var(--coz-stroke-hglt)}.segment-radio-wrapper-TKAZbc .semi-radio-cardRadioGroup_checked:hover{background:var(--coz-mg-hglt-hovered)}.segment-radio-wrapper-TKAZbc .semi-radio-cardRadioGroup_checked:active{background:var(--coz-mg-hglt-pressed)}.segment-radio-wrapper-TKAZbc .semi-radio-addon{margin-bottom:2px}.segment-radio-wrapper-TKAZbc .semi-form-field-label{margin-bottom:8px}.segment-radio-wrapper-TKAZbc .semi-checkboxGroup-vertical{row-gap:8px}',""]),o.locals={"segment-radio-wrapper":"segment-radio-wrapper-TKAZbc",segmentRadioWrapper:"segment-radio-wrapper-TKAZbc",displayNone:"displayNone-dkIssP","custom-wrapper":"custom-wrapper-mHiLQ2",customWrapper:"custom-wrapper-mHiLQ2","form-segment":"form-segment-_4or5l",formSegment:"form-segment-_4or5l",item:"item-yNLwbz",label:"label-B8cOJV","label-red":"label-red-ynWrpC",labelRed:"label-red-ynWrpC","custom-input":"custom-input-XsgTSG",customInput:"custom-input-XsgTSG",line:"line-LbCaPK"},t.Z=o},923124:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".footer-sub-tip-Ao5RTt{color:var(--light-usage-text-color-text-2,rgba(28,31,35,.6));font-size:12px}",""]),o.locals={"footer-sub-tip":"footer-sub-tip-Ao5RTt",footerSubTip:"footer-sub-tip-Ao5RTt"},t.Z=o},669854:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".create-table-wrapper-Rmcxg9{flex-direction:column;justify-content:center;height:100%;display:flex}.add-column-button-JCssGI{width:114px;margin-top:16px}",""]),o.locals={"create-table-wrapper":"create-table-wrapper-Rmcxg9",createTableWrapper:"create-table-wrapper-Rmcxg9","add-column-button":"add-column-button-JCssGI",addColumnButton:"add-column-button-JCssGI"},t.Z=o},5718:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".structure-bar-YhAhlN{flex-direction:row;justify-content:space-between;align-items:center;margin-bottom:10px;display:flex}.structure-bar-title-yFsfz3{color:var(--coz-fg-primary);font-size:14px;font-style:normal;font-weight:600;line-height:20px}.custom-table-container-rKmfoR{flex-direction:column;height:100%;display:flex}.unit-table-container-jC7mC5{border:1px solid var(--coz-stroke-primary);border-radius:8px}.unit-table-container-jC7mC5 .unit-table-view-JZykq7{min-height:90px;max-height:540px}.unit-table-container-jC7mC5 .unit-table-view-JZykq7 .semi-table-wrapper{margin-top:0}.unit-table-container-jC7mC5 .unit-table-view-JZykq7 .coz-tag.coz-tag-primary{font-weight:400}.unit-table-container-jC7mC5 .unit-table-view-JZykq7 .semi-table-thead>.semi-table-row>.semi-table-row-head{border-bottom:1px solid var(--coz-stroke-primary)}.unit-table-container-jC7mC5 .unit-table-view-JZykq7 .semi-table-header{border-top-left-radius:8px;border-top-right-radius:8px}.unit-table-container-jC7mC5 .unit-table-view-JZykq7 .semi-table-row:last-child .semi-table-row-cell{border-bottom:1px solid transparent}.unit-table-container-jC7mC5 .unit-table-view-JZykq7 .semi-table-row:hover>.semi-table-row-cell:first-child{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.unit-table-container-jC7mC5 .unit-table-view-JZykq7 .semi-table-row:hover>.semi-table-row-cell:last-child{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.unit-table-container-jC7mC5 .unit-table-view-JZykq7 .semi-table-body{border-bottom-right-radius:8px;border-bottom-left-radius:8px;max-height:499px!important}.unit-table-container-jC7mC5 .table-view-title-R5PkXj{flex-direction:row;align-items:center;display:flex}.unit-table-container-jC7mC5 .table-view-title-R5PkXj .semantic-tag-KqZfNg{margin-left:8px}.unit-table-container-jC7mC5 .unit-table-empty-wR5NGZ{height:64px}.footer-toolbar-zOANOz{margin-top:10px}.spin-MXg6cV .semi-spin-wrapper{position:absolute}.spin-MXg6cV .semi-tabs-content{padding:0}.spin-MXg6cV .semi-spin-children{height:100%}.footer-sub-tip-ZYIj1y{color:var(--coz-fg-primary);font-size:12px}.column-type-K9Rv9d{margin-left:6px}",""]),o.locals={"structure-bar":"structure-bar-YhAhlN",structureBar:"structure-bar-YhAhlN","structure-bar-title":"structure-bar-title-yFsfz3",structureBarTitle:"structure-bar-title-yFsfz3","custom-table-container":"custom-table-container-rKmfoR",customTableContainer:"custom-table-container-rKmfoR","unit-table-container":"unit-table-container-jC7mC5",unitTableContainer:"unit-table-container-jC7mC5","unit-table-view":"unit-table-view-JZykq7",unitTableView:"unit-table-view-JZykq7","table-view-title":"table-view-title-R5PkXj",tableViewTitle:"table-view-title-R5PkXj","semantic-tag":"semantic-tag-KqZfNg",semanticTag:"semantic-tag-KqZfNg","unit-table-empty":"unit-table-empty-wR5NGZ",unitTableEmpty:"unit-table-empty-wR5NGZ","footer-toolbar":"footer-toolbar-zOANOz",footerToolbar:"footer-toolbar-zOANOz",spin:"spin-MXg6cV","footer-sub-tip":"footer-sub-tip-ZYIj1y",footerSubTip:"footer-sub-tip-ZYIj1y","column-type":"column-type-K9Rv9d",columnType:"column-type-K9Rv9d"},t.Z=o},344842:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".table-structure-title-VenJKC{color:var(--coz-fg-primary);margin:12px 0 6px;font-family:PingFang SC;font-size:14px;font-style:normal;font-weight:600;line-height:20px}.no-result-BoLElK{flex-direction:column;justify-content:center;align-items:center;width:100%;height:448px;display:flex}.no-result-tips-fQ2rIO{color:var(--coz-fg-primary);margin-top:16px;font-family:SF Pro Display;font-size:16px;font-style:normal;font-weight:600;line-height:22px}.table-local-wrapper .semi-banner-full .semi-banner-content-wrapper .semi-banner-content{justify-content:flex-start}.table-local-wrapper .select-page-content .semi-tree-option-expand-icon{justify-content:center;align-items:center;width:20px!important;height:20px!important;line-height:20px!important}.table-local-wrapper .select-page-content .expand-placeholder{width:0!important;height:0!important;line-height:0!important}.table-local-wrapper .select-page-content .file-selector{justify-content:center;align-items:center;width:20px;height:20px;margin:0 8px}.table-local-wrapper .select-page-content .no-real-expand{margin:0 8px 0 0!important}.table-local-wrapper .select-page-content .file-icon{justify-content:center;align-self:center;align-items:center;width:20px;height:20px;margin-right:4px;line-height:20px;display:flex}.table-local-wrapper .select-page-content .file-selector{justify-content:center;width:20px;height:20px;margin:0 8px;padding:2px 0;display:flex}.table-local-wrapper .select-page-content .semi-tree-option-list{padding:0}.table-local-wrapper .select-page-content .file-node-row-content .action-placeholder{width:0;margin:0 0 0 8px}.footer-sub-tip-jRLlUx{color:var(--light-usage-text-color-text-2,rgba(28,31,35,.6));font-size:12px}.table-doc-footer-NLEYKz{float:right;margin-top:40px}.table-doc-footer-NLEYKz .semi-button{margin-left:10px}.table-setting-bar-container-B1lgTN{margin-bottom:0}.table-setting-bar-container-B1lgTN.is-error-A5YgGJ [x-field-id=header_line_idx] .semi-select{border:1px solid var(--coz-stroke-hglt-red)}.validation-results-Z91Ydh{flex-wrap:wrap;margin-top:4px;margin-bottom:6px;display:flex}.validation-results-Z91Ydh .validation-item-F7yUwf{flex:1;padding:0 8px}.validation-results-Z91Ydh .validation-item-F7yUwf .tips-YaFegc{color:var(--coz-fg-secondary);font-size:12px;line-height:16px}.validation-results-Z91Ydh .validation-item-F7yUwf .error-msg-xHwlV0{color:var(--coz-stroke-hglt-red);font-size:12px;line-height:16px}",""]),o.locals={"table-structure-title":"table-structure-title-VenJKC",tableStructureTitle:"table-structure-title-VenJKC","no-result":"no-result-BoLElK",noResult:"no-result-BoLElK","no-result-tips":"no-result-tips-fQ2rIO",noResultTips:"no-result-tips-fQ2rIO","footer-sub-tip":"footer-sub-tip-jRLlUx",footerSubTip:"footer-sub-tip-jRLlUx","table-doc-footer":"table-doc-footer-NLEYKz",tableDocFooter:"table-doc-footer-NLEYKz","table-setting-bar-container":"table-setting-bar-container-B1lgTN",tableSettingBarContainer:"table-setting-bar-container-B1lgTN","is-error":"is-error-A5YgGJ",isError:"is-error-A5YgGJ","validation-results":"validation-results-Z91Ydh",validationResults:"validation-results-Z91Ydh","validation-item":"validation-item-F7yUwf",validationItem:"validation-item-F7yUwf",tips:"tips-YaFegc","error-msg":"error-msg-xHwlV0",errorMsg:"error-msg-xHwlV0"},t.Z=o},45425:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".footer-sub-tip-MIX2OZ{color:var(--light-usage-text-color-text-2,rgba(28,31,35,.6));font-size:12px}",""]),o.locals={"footer-sub-tip":"footer-sub-tip-MIX2OZ",footerSubTip:"footer-sub-tip-MIX2OZ"},t.Z=o},153745:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".custom-text-form-vUVDqG .semi-form-field-error-message{color:var(--coz-fg-hglt-red)}.custom-text-form-vUVDqG .semi-form-field-label-required .semi-form-field-label-text:after{color:var(--coz-fg-hglt-red)}",""]),o.locals={"custom-text-form":"custom-text-form-vUVDqG",customTextForm:"custom-text-form-vUVDqG"},t.Z=o},846954:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".footer-sub-tip-XECZc4{color:var(--light-usage-text-color-text-2,rgba(28,31,35,.6));font-size:12px}",""]),o.locals={"footer-sub-tip":"footer-sub-tip-XECZc4",footerSubTip:"footer-sub-tip-XECZc4"},t.Z=o},356696:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".footer-sub-tip-syrvzP{color:var(--light-usage-text-color-text-2,rgba(28,31,35,.6));font-size:12px}",""]),o.locals={"footer-sub-tip":"footer-sub-tip-syrvzP",footerSubTip:"footer-sub-tip-syrvzP"},t.Z=o},451357:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".add-btn-ZzEFmI{margin-top:10px;margin-right:auto}.table-resegment-v6zXg3{flex-direction:column;flex:1;padding-bottom:8px;display:flex;overflow:hidden}",""]),o.locals={"add-btn":"add-btn-ZzEFmI",addBtn:"add-btn-ZzEFmI","table-resegment":"table-resegment-v6zXg3",tableResegment:"table-resegment-v6zXg3"},t.Z=o},707140:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".footer-sub-tip-Y7M9KW{color:var(--light-usage-text-color-text-2,rgba(28,31,35,.6));font-size:12px}",""]),o.locals={"footer-sub-tip":"footer-sub-tip-Y7M9KW",footerSubTip:"footer-sub-tip-Y7M9KW"},t.Z=o},836894:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".filter-modal-X99FWX .semi-modal{width:1280px!important;height:800px!important}",""]),o.locals={"filter-modal":"filter-modal-X99FWX",filterModal:"filter-modal-X99FWX"},t.Z=o},492483:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,".upload-unit-wrap-LRpAVk{width:100%;min-width:1008px;height:100%;margin:0 auto}.upload-unit-wrap-LRpAVk .upload-unit-steps{width:100%;margin:0 auto 54px}.upload-ui-content-rC0xye{background-color:rgba(var(--coze-bg-3),var(--coze-bg-3-alpha));height:100%;padding-top:40px;padding-bottom:30px}.breadcrumb-voCP4f{align-items:center;display:flex}",""]),o.locals={"upload-unit-wrap":"upload-unit-wrap-LRpAVk",uploadUnitWrap:"upload-unit-wrap-LRpAVk","upload-ui-content":"upload-ui-content-rC0xye",uploadUiContent:"upload-ui-content-rC0xye",breadcrumb:"breadcrumb-voCP4f"},t.Z=o},450953:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s),a=n(964824),l=n.n(a),d=new URL(n(116458),n.b),c=o()(r()),h=l()(d);c.push([e.id,`.cropper-container{touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;direction:ltr;font-size:0;line-height:0;position:relative}.cropper-container img{-webkit-backface-visibility:hidden;backface-visibility:hidden;image-orientation:0deg;width:100%;height:100%;display:block;min-width:0!important;max-width:none!important;min-height:0!important;max-height:none!important}.cropper-wrap-box,.cropper-canvas,.cropper-drag-box,.cropper-crop-box,.cropper-modal{position:absolute;top:0;bottom:0;left:0;right:0}.cropper-wrap-box,.cropper-canvas{overflow:hidden}.cropper-drag-box{opacity:0;background-color:#fff}.cropper-modal{opacity:.5;background-color:#000}.cropper-view-box{outline:1px solid rgba(51,153,255,.75);width:100%;height:100%;display:block;overflow:hidden}.cropper-dashed{opacity:.5;border:0 dashed #eee;display:block;position:absolute}.cropper-dashed.dashed-h{border-top-width:1px;border-bottom-width:1px;width:100%;height:33.3333%;top:33.3333%;left:0}.cropper-dashed.dashed-v{border-left-width:1px;border-right-width:1px;width:33.3333%;height:100%;top:0;left:33.3333%}.cropper-center{opacity:.75;width:0;height:0;display:block;position:absolute;top:50%;left:50%}.cropper-center:before,.cropper-center:after{content:" ";background-color:#eee;display:block;position:absolute}.cropper-center:before{width:7px;height:1px;top:0;left:-3px}.cropper-center:after{width:1px;height:7px;top:-3px;left:0}.cropper-face,.cropper-line,.cropper-point{opacity:.1;width:100%;height:100%;display:block;position:absolute}.cropper-face{background-color:#fff;top:0;left:0}.cropper-line{background-color:#39f}.cropper-line.line-e{cursor:ew-resize;width:5px;top:0;right:-3px}.cropper-line.line-n{cursor:ns-resize;height:5px;top:-3px;left:0}.cropper-line.line-w{cursor:ew-resize;width:5px;top:0;left:-3px}.cropper-line.line-s{cursor:ns-resize;height:5px;bottom:-3px;left:0}.cropper-point{opacity:.75;background-color:#39f;width:5px;height:5px}.cropper-point.point-e{cursor:ew-resize;margin-top:-3px;top:50%;right:-3px}.cropper-point.point-n{cursor:ns-resize;margin-left:-3px;top:-3px;left:50%}.cropper-point.point-w{cursor:ew-resize;margin-top:-3px;top:50%;left:-3px}.cropper-point.point-s{cursor:s-resize;margin-left:-3px;bottom:-3px;left:50%}.cropper-point.point-ne{cursor:nesw-resize;top:-3px;right:-3px}.cropper-point.point-nw{cursor:nwse-resize;top:-3px;left:-3px}.cropper-point.point-sw{cursor:nesw-resize;bottom:-3px;left:-3px}.cropper-point.point-se{cursor:nwse-resize;opacity:1;width:20px;height:20px;bottom:-3px;right:-3px}@media (min-width:768px){.cropper-point.point-se{width:15px;height:15px}}@media (min-width:992px){.cropper-point.point-se{width:10px;height:10px}}@media (min-width:1200px){.cropper-point.point-se{opacity:.75;width:5px;height:5px}}.cropper-point.point-se:before{content:" ";opacity:0;background-color:#39f;width:200%;height:200%;display:block;position:absolute;bottom:-50%;right:-50%}.cropper-invisible{opacity:0}.cropper-bg{background-image:url(${h})}.cropper-hide{width:0;height:0;display:block;position:absolute}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed}`,""]),t.Z=c},315631:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,":root{--react-pdf-annotation-layer:1;--annotation-unfocused-field-background:url(\"data:image/svg+xml;charset=UTF-8,<svg width='1px' height='1px' xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' style='fill:rgba(0, 54, 255, 0.13);'/></svg>\");--input-focus-border-color:Highlight;--input-focus-outline:1px solid Canvas;--input-unfocused-border-color:transparent;--input-disabled-border-color:transparent;--input-hover-border-color:black;--link-outline:none}@media screen and (forced-colors:active){:root{--input-focus-border-color:CanvasText;--input-unfocused-border-color:ActiveText;--input-disabled-border-color:GrayText;--input-hover-border-color:Highlight;--link-outline:1.5px solid LinkText}.annotationLayer .textWidgetAnnotation input:required{outline:1.5px solid selecteditem}.annotationLayer .textWidgetAnnotation textarea:required{outline:1.5px solid selecteditem}.annotationLayer .buttonWidgetAnnotation.checkBox input:required{outline:1.5px solid selecteditem}.annotationLayer .buttonWidgetAnnotation.radioButton input:required{outline:1.5px solid selecteditem}.annotationLayer .choiceWidgetAnnotation select:required{outline:1.5px solid selecteditem}.annotationLayer .linkAnnotation:hover{-webkit-backdrop-filter:invert();backdrop-filter:invert()}}.annotationLayer{pointer-events:none;transform-origin:0 0;z-index:3;position:absolute;top:0;left:0}.annotationLayer[data-main-rotation=\"90\"] .norotate{transform:rotate(270deg)translate(-100%)}.annotationLayer[data-main-rotation=\"180\"] .norotate{transform:rotate(180deg)translate(-100%,-100%)}.annotationLayer[data-main-rotation=\"270\"] .norotate{transform:rotate(90deg)translateY(-100%)}.annotationLayer canvas{width:100%;height:100%;position:absolute}.annotationLayer section{text-align:initial;pointer-events:auto;box-sizing:border-box;transform-origin:0 0;margin:0;position:absolute}.annotationLayer .linkAnnotation{outline:var(--link-outline)}.annotationLayer .linkAnnotation:not(.does-not-exist)>a,.annotationLayer .buttonWidgetAnnotation.pushButton>a{width:100%;height:100%;font-size:1em;position:absolute;top:0;left:0}.annotationLayer .linkAnnotation:not(.does-not-exist)>a:hover,.annotationLayer .buttonWidgetAnnotation.pushButton>a:hover{opacity:.2;background:#ff0;box-shadow:0 2px 10px #ff0}.annotationLayer .textAnnotation img{cursor:pointer;width:100%;height:100%;position:absolute;top:0;left:0}.annotationLayer .textWidgetAnnotation input,.annotationLayer .textWidgetAnnotation textarea,.annotationLayer .choiceWidgetAnnotation select,.annotationLayer .buttonWidgetAnnotation.checkBox input,.annotationLayer .buttonWidgetAnnotation.radioButton input{background-image:var(--annotation-unfocused-field-background);border:2px solid var(--input-unfocused-border-color);box-sizing:border-box;font:calc(9px*var(--scale-factor))sans-serif;vertical-align:top;width:100%;height:100%;margin:0}.annotationLayer .textWidgetAnnotation input:required{outline:1.5px solid red}.annotationLayer .textWidgetAnnotation textarea:required{outline:1.5px solid red}.annotationLayer .buttonWidgetAnnotation.checkBox input:required{outline:1.5px solid red}.annotationLayer .buttonWidgetAnnotation.radioButton input:required{outline:1.5px solid red}.annotationLayer .choiceWidgetAnnotation select:required{outline:1.5px solid red}.annotationLayer .choiceWidgetAnnotation select option{padding:0}.annotationLayer .buttonWidgetAnnotation.radioButton input{border-radius:50%}.annotationLayer .textWidgetAnnotation textarea{resize:none}.annotationLayer .textWidgetAnnotation input[disabled],.annotationLayer .textWidgetAnnotation textarea[disabled],.annotationLayer .choiceWidgetAnnotation select[disabled],.annotationLayer .buttonWidgetAnnotation.checkBox input[disabled],.annotationLayer .buttonWidgetAnnotation.radioButton input[disabled]{border:2px solid var(--input-disabled-border-color);cursor:not-allowed;background:0 0}.annotationLayer .textWidgetAnnotation input:hover,.annotationLayer .textWidgetAnnotation textarea:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .buttonWidgetAnnotation.checkBox input:hover,.annotationLayer .buttonWidgetAnnotation.radioButton input:hover{border:2px solid var(--input-hover-border-color)}.annotationLayer .textWidgetAnnotation input:hover,.annotationLayer .textWidgetAnnotation textarea:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .buttonWidgetAnnotation.checkBox input:hover{border-radius:2px}.annotationLayer .textWidgetAnnotation input:focus,.annotationLayer .textWidgetAnnotation textarea:focus,.annotationLayer .choiceWidgetAnnotation select:focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline);background:0 0;border-radius:2px}.annotationLayer .buttonWidgetAnnotation.checkBox :focus,.annotationLayer .buttonWidgetAnnotation.radioButton :focus{background-color:transparent;background-image:none}.annotationLayer .buttonWidgetAnnotation.checkBox :focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline);border-radius:2px}.annotationLayer .buttonWidgetAnnotation.radioButton :focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{content:\"\";background-color:canvastext;display:block;position:absolute}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{width:1px;height:80%;left:45%}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{transform:rotate(45deg)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{transform:rotate(-45deg)}.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{border-radius:50%;width:50%;height:50%;top:20%;left:30%}.annotationLayer .textWidgetAnnotation input.comb{padding-left:2px;padding-right:0;font-family:monospace}.annotationLayer .textWidgetAnnotation input.comb:focus{width:103%}.annotationLayer .buttonWidgetAnnotation.checkBox input,.annotationLayer .buttonWidgetAnnotation.radioButton input{-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none}.annotationLayer .popupTriggerArea{width:100%;height:100%}.annotationLayer .fileAttachmentAnnotation .popupTriggerArea{position:absolute}.annotationLayer .popupWrapper{font-size:calc(9px*var(--scale-factor));width:100%;min-width:calc(180px*var(--scale-factor));pointer-events:none;position:absolute}.annotationLayer .popup{max-width:calc(180px*var(--scale-factor));box-shadow:0 calc(2px*var(--scale-factor))calc(5px*var(--scale-factor))#888;border-radius:calc(2px*var(--scale-factor));padding:calc(6px*var(--scale-factor));margin-left:calc(5px*var(--scale-factor));cursor:pointer;font:message-box;white-space:normal;word-wrap:break-word;pointer-events:auto;background-color:#ff9;position:absolute}.annotationLayer .popup>*{font-size:calc(9px*var(--scale-factor))}.annotationLayer .popup h1{display:inline-block}.annotationLayer .popupDate{margin-left:calc(5px*var(--scale-factor));display:inline-block}.annotationLayer .popupContent{margin-top:calc(2px*var(--scale-factor));padding-top:calc(2px*var(--scale-factor));border-top:1px solid #333}.annotationLayer .richText>*{white-space:pre-wrap;font-size:calc(9px*var(--scale-factor))}.annotationLayer .highlightAnnotation,.annotationLayer .underlineAnnotation,.annotationLayer .squigglyAnnotation,.annotationLayer .strikeoutAnnotation,.annotationLayer .freeTextAnnotation,.annotationLayer .lineAnnotation svg line,.annotationLayer .squareAnnotation svg rect,.annotationLayer .circleAnnotation svg ellipse,.annotationLayer .polylineAnnotation svg polyline,.annotationLayer .polygonAnnotation svg polygon,.annotationLayer .caretAnnotation,.annotationLayer .inkAnnotation svg polyline,.annotationLayer .stampAnnotation,.annotationLayer .fileAttachmentAnnotation{cursor:pointer}.annotationLayer section svg{width:100%;height:100%;position:absolute;top:0;left:0}.annotationLayer .annotationTextContent{opacity:0;color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;width:100%;height:100%;position:absolute}.annotationLayer .annotationTextContent span{width:100%;display:inline-block}",""]),t.Z=o},145518:function(e,t,n){"use strict";var i=n(125161),r=n.n(i),s=n(404442),o=n.n(s)()(r());o.push([e.id,':root{--react-pdf-text-layer:1;--highlight-bg-color:#b400aa;--highlight-selected-bg-color:#006400}@media screen and (forced-colors:active){:root{--highlight-bg-color:Highlight;--highlight-selected-bg-color:ButtonText}}[data-main-rotation="90"]{transform:rotate(90deg)translateY(-100%)}[data-main-rotation="180"]{transform:rotate(180deg)translate(-100%,-100%)}[data-main-rotation="270"]{transform:rotate(270deg)translate(-100%)}.textLayer{text-align:initial;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;-ms-text-size-adjust:none;text-size-adjust:none;forced-color-adjust:none;transform-origin:0 0;z-index:2;line-height:1;position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden}.textLayer span,.textLayer br{color:transparent;white-space:pre;cursor:text;transform-origin:0 0;margin:0;position:absolute}.textLayer span.markedContent{height:0;top:0}.textLayer .highlight{background-color:var(--highlight-bg-color);border-radius:4px;margin:-1px;padding:1px}.textLayer .highlight.appended{position:initial}.textLayer .highlight.begin{border-radius:4px 0 0 4px}.textLayer .highlight.end{border-radius:0 4px 4px 0}.textLayer .highlight.middle{border-radius:0}.textLayer .highlight.selected{background-color:var(--highlight-selected-bg-color)}.textLayer br::-moz-selection{background:0 0}.textLayer br::selection{background:0 0}.textLayer .endOfContent{z-index:-1;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:block;position:absolute;top:100%;bottom:0;left:0;right:0}.textLayer .endOfContent.active{top:0}.hiddenCanvasElement{width:0;height:0;display:none;position:absolute;top:0;left:0}',""]),t.Z=o},84094:function(e,t,n){"use strict";var i=n(407821),r=n.n(i),s=n(472772),o=n.n(s),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(450953),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=o(),g.insertStyleElement=u(),r()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals},887869:function(e,t,n){"use strict";var i=n(407821),r=n.n(i),s=n(472772),o=n.n(s),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(315631),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=o(),g.insertStyleElement=u(),r()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals},107440:function(e,t,n){"use strict";var i=n(407821),r=n.n(i),s=n(472772),o=n.n(s),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(145518),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=o(),g.insertStyleElement=u(),r()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals},453203:function(e,t,n){"use strict";n.d(t,{ML:()=>e8,P1:()=>q,hj:()=>eg,NB:()=>tn,x2:()=>e9,zK:()=>te,S0:()=>tt,qv:()=>eB,Cf:()=>e7,vc:()=>ec,Nl:()=>$,nU:()=>X,EG:()=>eG,K9:()=>ti});var i,r=n("871738"),s=n("661763"),o=n("132308"),a=n("153737"),l=n("240554");let d=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function c(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("backward",e):!(n.parentOffset>0))?n:null}let h=(e,t,n)=>{let i=c(e,n);if(!i)return!1;let s=v(i);if(!s){let n=i.blockRange(),r=n&&(0,l.k9)(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let o=s.nodeBefore;if(O(e,s,t,-1))return!0;if(0==i.parent.content.size&&(m(o,"end")||r.qv.isSelectable(o)))for(let n=i.depth;;n--){let d=(0,l.dR)(e.doc,i.before(n),i.after(n),a.p2.empty);if(d&&d.slice.size<d.to-d.from){if(t){let n=e.tr.step(d);n.setSelection(m(o,"end")?r.Y1.findFrom(n.doc.resolve(n.mapping.map(s.pos,-1)),-1):r.qv.create(n.doc,s.pos-o.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||i.node(n-1).childCount>1)break}return!!o.isAtom&&s.depth==i.depth-1&&(t&&t(e.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0)},u=(e,t,n)=>{let i=c(e,n);if(!i)return!1;let r=v(i);return!!r&&f(e,r,t)},p=(e,t,n)=>{let i=b(e,n);if(!i)return!1;let r=w(i);return!!r&&f(e,r,t)};function f(e,t,n){let i=t.nodeBefore,s=t.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let e=i.lastChild;if(!e)return!1;i=e}let o=t.nodeAfter,d=t.pos+1;for(;!o.isTextblock;d++){if(o.type.spec.isolating)return!1;let e=o.firstChild;if(!e)return!1;o=e}let c=(0,l.dR)(e.doc,s,d,a.p2.empty);if(!c||c.from!=s||c instanceof l.Pu&&c.slice.size>=d-s)return!1;if(n){let t=e.tr.step(c);t.setSelection(r.Bs.create(t.doc,s)),n(t.scrollIntoView())}return!0}function m(e,t,n=!1){for(let i=e;i;i="start"==t?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(n&&1!=i.childCount)break}return!1}let g=(e,t,n)=>{let{$head:i,empty:s}=e.selection,o=i;if(!s)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):i.parentOffset>0)return!1;o=v(i)}let a=o&&o.nodeBefore;return!!(a&&r.qv.isSelectable(a))&&(t&&t(e.tr.setSelection(r.qv.create(e.doc,o.pos-a.nodeSize)).scrollIntoView()),!0)};function v(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function b(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("forward",e):!(n.parentOffset<n.parent.content.size))?n:null}let y=(e,t,n)=>{let i=b(e,n);if(!i)return!1;let s=w(i);if(!s)return!1;let o=s.nodeAfter;if(O(e,s,t,1))return!0;if(0==i.parent.content.size&&(m(o,"start")||r.qv.isSelectable(o))){let n=(0,l.dR)(e.doc,i.before(),i.after(),a.p2.empty);if(n&&n.slice.size<n.to-n.from){if(t){let i=e.tr.step(n);i.setSelection(m(o,"start")?r.Y1.findFrom(i.doc.resolve(i.mapping.map(s.pos)),1):r.qv.create(i.doc,i.mapping.map(s.pos))),t(i.scrollIntoView())}return!0}}return!!o.isAtom&&s.depth==i.depth-1&&(t&&t(e.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0)},x=(e,t,n)=>{let{$head:i,empty:s}=e.selection,o=i;if(!s)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):i.parentOffset<i.parent.content.size)return!1;o=w(i)}let a=o&&o.nodeAfter;return!!(a&&r.qv.isSelectable(a))&&(t&&t(e.tr.setSelection(r.qv.create(e.doc,o.pos)).scrollIntoView()),!0)};function w(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}let _=(e,t)=>{let n=e.selection,i=n instanceof r.qv,s;if(i){if(n.node.isTextblock||!(0,l.Mn)(e.doc,n.from))return!1;s=n.from}else if(null==(s=(0,l.GJ)(e.doc,n.from,-1)))return!1;if(t){let n=e.tr.join(s);i&&n.setSelection(r.qv.create(n.doc,s-e.doc.resolve(s).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},S=(e,t)=>{let n=e.selection,i;if(n instanceof r.qv){if(n.node.isTextblock||!(0,l.Mn)(e.doc,n.to))return!1;i=n.to}else if(null==(i=(0,l.GJ)(e.doc,n.to,1)))return!1;return t&&t(e.tr.join(i).scrollIntoView()),!0},E=(e,t)=>{let{$from:n,$to:i}=e.selection,r=n.blockRange(i),s=r&&(0,l.k9)(r);return null!=s&&(t&&t(e.tr.lift(r,s).scrollIntoView()),!0)},C=(e,t)=>{let{$head:n,$anchor:i}=e.selection;return!!(n.parent.type.spec.code&&n.sameParent(i))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function A(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}let k=(e,t)=>{let{$head:n,$anchor:i}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(i))return!1;let s=n.node(-1),o=n.indexAfter(-1),a=A(s.contentMatchAt(o));if(!a||!s.canReplaceWith(o,o,a))return!1;if(t){let i=n.after(),s=e.tr.replaceWith(i,i,a.createAndFill());s.setSelection(r.Y1.near(s.doc.resolve(i),1)),t(s.scrollIntoView())}return!0},T=(e,t)=>{let n=e.selection,{$from:i,$to:s}=n;if(n instanceof r.C1||i.parent.inlineContent||s.parent.inlineContent)return!1;let o=A(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let n=(!i.parentOffset&&s.index()<s.parent.childCount?i:s).pos,a=e.tr.insert(n,o.createAndFill());a.setSelection(r.Bs.create(a.doc,n+1)),t(a.scrollIntoView())}return!0},M=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if((0,l.Ax)(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let i=n.blockRange(),r=i&&(0,l.k9)(i);return null!=r&&(t&&t(e.tr.lift(i,r).scrollIntoView()),!0)};let D=(e,t)=>{let{$from:n,to:i}=e.selection,s,o=n.sharedDepth(i);return 0!=o&&(s=n.before(o),t&&t(e.tr.setSelection(r.qv.create(e.doc,s))),!0)};function O(e,t,n,i){var s,o,d;let c,h,u,p=t.nodeBefore,f=t.nodeAfter,g,v,b=p.type.spec.isolating||f.type.spec.isolating;if(!b&&(s=e,o=t,d=n,c=o.nodeBefore,h=o.nodeAfter,u=o.index(),c&&h&&c.type.compatibleContent(h.type)&&(!c.content.size&&o.parent.canReplace(u-1,u)?(d&&d(s.tr.delete(o.pos-c.nodeSize,o.pos).scrollIntoView()),!0):!!(o.parent.canReplace(u,u+1)&&(h.isTextblock||(0,l.Mn)(s.doc,o.pos)))&&(d&&d(s.tr.join(o.pos).scrollIntoView()),!0))))return!0;let y=!b&&t.parent.canReplace(t.index(),t.index()+1);if(y&&(g=(v=p.contentMatchAt(p.childCount)).findWrapping(f.type))&&v.matchType(g[0]||f.type).validEnd){if(n){let i=t.pos+f.nodeSize,r=a.HY.empty;for(let e=g.length-1;e>=0;e--)r=a.HY.from(g[e].create(null,r));r=a.HY.from(p.copy(r));let s=e.tr.step(new l.FC(t.pos-1,i,t.pos,i,new a.p2(r,1,0),g.length,!0)),o=s.doc.resolve(i+2*g.length);o.nodeAfter&&o.nodeAfter.type==p.type&&(0,l.Mn)(s.doc,o.pos)&&s.join(o.pos),n(s.scrollIntoView())}return!0}let x=f.type.spec.isolating||i>0&&b?null:r.Y1.findFrom(t,1),w=x&&x.$from.blockRange(x.$to),_=w&&(0,l.k9)(w);if(null!=_&&_>=t.depth)return n&&n(e.tr.lift(w,_).scrollIntoView()),!0;if(y&&m(f,"start",!0)&&m(p,"end")){let i=p,r=[];for(;r.push(i),!i.isTextblock;){;i=i.lastChild}let s=f,o=1;for(;!s.isTextblock;s=s.firstChild)o++;if(i.canReplace(i.childCount,i.childCount,s.content)){if(n){let i=a.HY.empty;for(let e=r.length-1;e>=0;e--)i=a.HY.from(r[e].copy(i));n(e.tr.step(new l.FC(t.pos-r.length,t.pos+f.nodeSize,t.pos+o,t.pos+f.nodeSize-o,new a.p2(i,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function I(e){return function(t,n){let i=t.selection,s=e<0?i.$from:i.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return!!s.node(o).isTextblock&&(n&&n(t.tr.setSelection(r.Bs.create(t.doc,e<0?s.start(o):s.end(o)))),!0)}}let N=I(-1),R=I(1);function L(e,t=null){return function(n,i){let r=!1;for(let i=0;i<n.selection.ranges.length&&!r;i++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[i];n.doc.nodesBetween(s,o,(i,s)=>{if(r)return!1;if(!(!i.isTextblock||i.hasMarkup(e,t))){if(i.type==e)r=!0;else{let t=n.doc.resolve(s),i=t.index();r=t.parent.canReplaceWith(i,i+1,e)}}})}if(!r)return!1;if(i){let r=n.tr;for(let i=0;i<n.selection.ranges.length;i++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[i];r.setBlockType(s,o,e,t)}i(r.scrollIntoView())}return!0}}function P(...e){return function(t,n,i){for(let r=0;r<e.length;r++)if(e[r](t,n,i))return!0;return!1}}let j=P(d,h,g),F=P(d,y,x),B={Enter:P(C,T,M,(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof r.qv&&e.selection.node.isBlock)return!!(n.parentOffset&&(0,l.Ax)(e.doc,n.pos))&&(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let s=[],o,a,d=!1,c=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){d=n.end(e)==n.pos+(n.depth-e),c=n.start(e)==n.pos-(n.depth-e),a=A(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));let t=void 0;s.unshift(t||(d&&a?{type:a}:null)),o=e;break}if(1==e)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof r.Bs||e.selection instanceof r.C1)&&h.deleteSelection();let u=h.mapping.map(n.pos),p=(0,l.Ax)(h.doc,u,s.length,s);if(!p&&(s[0]=a?{type:a}:null,p=(0,l.Ax)(h.doc,u,s.length,s)),!p)return!1;if(h.split(u,s.length,s),!d&&c&&n.node(o).type!=a){let e=h.mapping.map(n.before(o)),t=h.doc.resolve(e);a&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,a)&&h.setNodeMarkup(h.mapping.map(n.before(o)),a)}return t&&t(h.scrollIntoView()),!0}),"Mod-Enter":k,Backspace:j,"Mod-Backspace":j,"Shift-Backspace":j,Delete:F,"Mod-Delete":F,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new r.C1(e.doc))),!0)},z={"Ctrl-h":B.Backspace,"Alt-Backspace":B["Mod-Backspace"],"Ctrl-d":B.Delete,"Ctrl-Alt-Backspace":B["Mod-Delete"],"Alt-Delete":B["Mod-Delete"],"Alt-d":B["Mod-Delete"],"Ctrl-a":N,"Ctrl-e":R};for(let e in B)z[e]=B[e];"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"==typeof os||!os.platform||os.platform();function H(e){let{state:t,transaction:n}=e,{selection:i}=n,{doc:r}=n,{storedMarks:s}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return s},get selection(){return i},get doc(){return r},get tr(){return i=n.selection,r=n.doc,s=n.storedMarks,n}}}class U{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:i}=t,{tr:r}=n,s=this.buildProps(r);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(s);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:i,state:r}=this,{view:s}=i,o=[],a=!!e,l=e||r.tr,d={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let i=this.buildProps(l,t),r=n(...e)(i);return o.push(r),d}])),run:()=>(!a&&t&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),o.every(e=>!0===e))};return d}createCan(e){let{rawCommands:t,state:n}=this,i=e||n.tr,r=this.buildProps(i,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...r,dispatch:void 0})])),chain:()=>this.createChain(i,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:i,state:r}=this,{view:s}=i,o={tr:e,editor:i,view:s,state:H({state:r,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}}class V{constructor(){this.callbacks={}}on(e,t){return!this.callbacks[e]&&(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...i)=>{this.off(e,n),t.apply(this,i)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}}function $(e,t,n){return void 0===e.config[t]&&e.parent?$(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind({...n,parent:e.parent?$(e.parent,t,n):null}):e.config[t]}function W(e){let t=e.filter(e=>"extension"===e.type),n=e.filter(e=>"node"===e.type);return{baseExtensions:t,nodeExtensions:n,markExtensions:e.filter(e=>"mark"===e.type)}}function G(e){let t=[],{nodeExtensions:n,markExtensions:i}=W(e),r=[...n,...i],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage,extensions:r},i=$(e,"addGlobalAttributes",n);if(!!i)i().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,i])=>{t.push({type:n,name:e,attribute:{...s,...i}})})})})}),r.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage},i=$(e,"addAttributes",n);if(!!i)Object.entries(i()).forEach(([n,i])=>{let r={...s,...i};"function"==typeof(null==r?void 0:r.default)&&(r.default=r.default()),(null==r?void 0:r.isRequired)&&(null==r?void 0:r.default)===void 0&&delete r.default,t.push({type:e.name,name:n,attribute:r})})}),t}function Z(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function q(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if("class"===e){let i=t?String(t).split(" "):[],r=n[e]?n[e].split(" "):[],s=i.filter(e=>!r.includes(e));n[e]=[...r,...s].join(" ")}else if("style"===e){let i=t?t.split(";").map(e=>e.trim()).filter(Boolean):[],r=n[e]?n[e].split(";").map(e=>e.trim()).filter(Boolean):[],s=new Map;r.forEach(e=>{let[t,n]=e.split(":").map(e=>e.trim());s.set(t,n)}),i.forEach(e=>{let[t,n]=e.split(":").map(e=>e.trim());s.set(t,n)}),n[e]=Array.from(s.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t}),n},{})}function K(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>q(e,t),{})}function Y(e){return"function"==typeof e}function X(e,t,...n){if(Y(e))return t?e.bind(t)(...n):e(...n);return e}function J(e,t){return"style"in e?e:{...e,getAttrs:n=>{let i=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===i)return!1;let r=t.reduce((e,t)=>{var i;let r=t.attribute.parseHTML?t.attribute.parseHTML(n):"string"!=typeof(i=n.getAttribute(t.name))?i:i.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(i):"true"===i||"false"!==i&&i;return null==r?e:{...e,[t.name]:r}},{});return{...i,...r}}}}function Q(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!("attrs"===e&&function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t))}function ee(e,t){return t.nodes[e]||t.marks[e]||null}function et(e,t){return Array.isArray(t)?t.some(t=>("string"==typeof t?t:t.name)===e.name):t}function en(e,t){let n=a.PW.fromSchema(t).serializeFragment(e),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}let ei=(e,t=500)=>{let n="",i=e.parentOffset;return e.parent.nodesBetween(Math.max(0,i-t),i,(e,t,r,s)=>{var o,a;let l=(null===(a=(o=e.type.spec).toText)||void 0===a?void 0:a.call(o,{node:e,pos:t,parent:r,index:s}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?l:l.slice(0,Math.max(0,i-t))}),n};function er(e){return"[object RegExp]"===Object.prototype.toString.call(e)}class es{constructor(e){this.find=e.find,this.handler=e.handler}}let eo=(e,t)=>{if(er(t))return t.exec(e);let n=t(e);if(!n)return null;let i=[n.text];return i.index=n.index,i.input=e,i.data=n.data,n.replaceWith&&(!n.text.includes(n.replaceWith)&&console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(n.replaceWith)),i};function ea(e){var t;let{editor:n,from:i,to:r,text:s,rules:o,plugin:a}=e,{view:l}=n;if(l.composing)return!1;let d=l.state.doc.resolve(i);if(d.parent.type.spec.code||(null===(t=d.nodeBefore||d.nodeAfter)||void 0===t?void 0:t.marks.find(e=>e.type.spec.code)))return!1;let c=!1,h=ei(d)+s;return o.forEach(e=>{if(c)return;let t=eo(h,e.find);if(!t)return;let o=l.state.tr,d=H({state:l.state,transaction:o}),u={from:i-(t[0].length-s.length),to:r},{commands:p,chain:f,can:m}=new U({editor:n,state:d});if(null!==e.handler({state:d,range:u,match:t,commands:p,chain:f,can:m})&&!!o.steps.length)o.setMeta(a,{transform:o,from:i,to:r,text:s}),l.dispatch(o),c=!0}),c}function el(e){var t;return"Object"===(t=e,Object.prototype.toString.call(t).slice(8,-1))&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function ed(e,t){let n={...e};return el(e)&&el(t)&&Object.keys(t).forEach(i=>{el(t[i])&&el(e[i])?n[i]=ed(e[i],t[i]):n[i]=t[i]}),n}class ec{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=X($(this,"addOptions",{name:this.name}))),this.storage=X($(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ec(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>ed(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new ec(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=X($(t,"addOptions",{name:t.name})),t.storage=X($(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let r=i.marks();if(!r.find(e=>(null==e?void 0:e.type.name)===t.name))return!1;let s=r.find(e=>(null==e?void 0:e.type.name)===t.name);return s&&n.removeStoredMark(s),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}}class eh{constructor(e){this.find=e.find,this.handler=e.handler}}let eu=(e,t,n)=>{if(er(t))return[...e.matchAll(t)];let i=t(e,n);return i?i.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(!t.text.includes(t.replaceWith)&&console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]},ep=null,ef=e=>{var t;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null===(t=n.clipboardData)||void 0===t||t.setData("text/html",e),n};class em{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=em.resolve(e),this.schema=function(e,t){var n;let i=G(e),{nodeExtensions:r,markExtensions:s}=W(e),o=null===(n=r.find(e=>$(e,"topNode")))||void 0===n?void 0:n.name,l=Object.fromEntries(r.map(n=>{let r=i.filter(e=>e.type===n.name),s={name:n.name,options:n.options,storage:n.storage,editor:t},o=Q({...e.reduce((e,t)=>{let i=$(t,"extendNodeSchema",s);return{...e,...i?i(n):{}}},{}),content:X($(n,"content",s)),marks:X($(n,"marks",s)),group:X($(n,"group",s)),inline:X($(n,"inline",s)),atom:X($(n,"atom",s)),selectable:X($(n,"selectable",s)),draggable:X($(n,"draggable",s)),code:X($(n,"code",s)),whitespace:X($(n,"whitespace",s)),linebreakReplacement:X($(n,"linebreakReplacement",s)),defining:X($(n,"defining",s)),isolating:X($(n,"isolating",s)),attrs:Object.fromEntries(r.map(e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]}))}),a=X($(n,"parseHTML",s));a&&(o.parseDOM=a.map(e=>J(e,r)));let l=$(n,"renderHTML",s);l&&(o.toDOM=e=>l({node:e,HTMLAttributes:K(e,r)}));let d=$(n,"renderText",s);return d&&(o.toText=d),[n.name,o]})),d=Object.fromEntries(s.map(n=>{let r=i.filter(e=>e.type===n.name),s={name:n.name,options:n.options,storage:n.storage,editor:t},o=Q({...e.reduce((e,t)=>{let i=$(t,"extendMarkSchema",s);return{...e,...i?i(n):{}}},{}),inclusive:X($(n,"inclusive",s)),excludes:X($(n,"excludes",s)),group:X($(n,"group",s)),spanning:X($(n,"spanning",s)),code:X($(n,"code",s)),attrs:Object.fromEntries(r.map(e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]}))}),a=X($(n,"parseHTML",s));a&&(o.parseDOM=a.map(e=>J(e,r)));let l=$(n,"renderHTML",s);return l&&(o.toDOM=e=>l({mark:e,HTMLAttributes:K(e,r)})),[n.name,o]}));return new a.V_({topNode:o,nodes:l,marks:d})}(this.extensions,t),this.setupExtensions()}static resolve(e){var t;let n=em.sort(em.flatten(e));let i=Array.from(new Set((t=n.map(e=>e.name)).filter((e,n)=>t.indexOf(e)!==n)));return i.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${i.map(e=>`'${e}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(e=>{let t={name:e.name,options:e.options,storage:e.storage},n=$(e,"addExtensions",t);return n?[e,...this.flatten(n())]:e}).flat(10)}static sort(e){return e.sort((e,t)=>{let n=$(e,"priority")||100,i=$(t,"priority")||100;return n>i?-1:n<i?1:0})}get commands(){return this.extensions.reduce((e,t)=>{let n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:ee(t.name,this.schema)},i=$(t,"addCommands",n);return i?{...e,...i()}:e},{})}get plugins(){let{editor:e}=this,t=em.sort([...this.extensions].reverse()),n=[],i=[],s=t.map(t=>{let r={name:t.name,options:t.options,storage:t.storage,editor:e,type:ee(t.name,this.schema)},s=[],a=$(t,"addKeyboardShortcuts",r),l={};if("mark"===t.type&&$(t,"exitable",r)&&(l.ArrowRight=()=>ec.handleExit({editor:e,mark:t})),a){let t=Object.fromEntries(Object.entries(a()).map(([t,n])=>[t,()=>n({editor:e})]));l={...l,...t}}let d=(0,o.h)(l);s.push(d);let c=$(t,"addInputRules",r);et(t,e.options.enableInputRules)&&c&&n.push(...c());let h=$(t,"addPasteRules",r);et(t,e.options.enablePasteRules)&&h&&i.push(...h());let u=$(t,"addProseMirrorPlugins",r);if(u){let e=u();s.push(...e)}return s}).flat();return[function(e){let{editor:t,rules:n}=e,i=new r.Sy({state:{init:()=>null,apply(e,r,s){let o=e.getMeta(i);if(o)return o;let l=e.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:e}=l;"string"==typeof e||(e=en(a.HY.from(e),s.schema));let{from:r}=l,o=r+e.length;ea({editor:t,from:r,to:o,text:e,rules:n,plugin:i})}),e.selectionSet||e.docChanged?null:r}},props:{handleTextInput:(e,r,s,o)=>ea({editor:t,from:r,to:s,text:o,rules:n,plugin:i}),handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:r}=e.state.selection;r&&ea({editor:t,from:r.pos,to:r.pos,text:"",rules:n,plugin:i})}),!1)},handleKeyDown(e,r){if("Enter"!==r.key)return!1;let{$cursor:s}=e.state.selection;return!!s&&ea({editor:t,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:i})}},isInputRules:!0});return i}({editor:e,rules:n}),...function(e){let t;let{editor:n,rules:i}=e,s=null,o=!1,l=!1,d="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{t=null}let c=({state:e,from:i,to:r,rule:s,pasteEvt:o})=>{let a=e.tr;if(!!function(e){let{editor:t,state:n,from:i,to:r,rule:s,pasteEvent:o,dropEvent:a}=e,{commands:l,chain:d,can:c}=new U({editor:t,state:n}),h=[];return n.doc.nodesBetween(i,r,(e,t)=>{if(!e.isTextblock||e.type.spec.code)return;let u=Math.max(i,t),p=Math.min(r,t+e.content.size);eu(e.textBetween(u-t,p-t,void 0,""),s.find,o).forEach(e=>{if(void 0===e.index)return;let t=u+e.index+1,i=t+e[0].length,r={from:n.tr.mapping.map(t),to:n.tr.mapping.map(i)},p=s.handler({state:n,range:r,match:e,commands:l,chain:d,can:c,pasteEvent:o,dropEvent:a});h.push(p)})}),h.every(e=>null!==e)}({editor:n,state:H({state:e,transaction:a}),from:Math.max(i-1,0),to:r.b-1,rule:s,pasteEvent:o,dropEvent:t})&&!!a.steps.length){try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{t=null}return d="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,a}};return i.map(e=>new r.Sy({view(e){let t=t=>{var i;(s=(null===(i=e.dom.parentElement)||void 0===i?void 0:i.contains(t.target))?e.dom.parentElement:null)&&(ep=n)},i=()=>{ep&&(ep=null)};return window.addEventListener("dragstart",t),window.addEventListener("dragend",i),{destroy(){window.removeEventListener("dragstart",t),window.removeEventListener("dragend",i)}}},props:{handleDOMEvents:{drop:(e,n)=>{if(l=s===e.dom.parentElement,t=n,!l){let e=ep;e&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{var n;let i=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return d=t,o=!!(null==i?void 0:i.includes("data-pm-slice")),!1}}},appendTransaction:(t,n,i)=>{let r=t[0],s="paste"===r.getMeta("uiEvent")&&!o,h="drop"===r.getMeta("uiEvent")&&!l,u=r.getMeta("applyPasteRules"),p=!!u;if(!s&&!h&&!p)return;if(p){let{text:t}=u;"string"==typeof t||(t=en(a.HY.from(t),i.schema));let{from:n}=u,r=n+t.length;return c({rule:e,state:i,from:n,to:{b:r},pasteEvt:ef(t)})}let f=n.doc.content.findDiffStart(i.doc.content),m=n.doc.content.findDiffEnd(i.doc.content);if("number"==typeof f&&!!m&&f!==m.b)return c({rule:e,state:i,from:f,to:m,pasteEvt:d})}}))}({editor:e,rules:i}),...s]}get attributes(){return G(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=W(this.extensions);return Object.fromEntries(t.filter(e=>!!$(e,"addNodeView")).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),i={name:t.name,options:t.options,storage:t.storage,editor:e,type:Z(t.name,this.schema)},r=$(t,"addNodeView",i);return r?[t.name,(i,s,o,a,l)=>{let d=K(i,n);return r()({node:i,view:s,getPos:o,decorations:a,innerDecorations:l,editor:e,extension:t,HTMLAttributes:d})}]:[]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;let n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:ee(e.name,this.schema)};"mark"===e.type&&(null===(t=X($(e,"keepOnSplit",n)))||void 0===t||t)&&this.splittableMarks.push(e.name);let i=$(e,"onBeforeCreate",n),r=$(e,"onCreate",n),s=$(e,"onUpdate",n),o=$(e,"onSelectionUpdate",n),a=$(e,"onTransaction",n),l=$(e,"onFocus",n),d=$(e,"onBlur",n),c=$(e,"onDestroy",n);i&&this.editor.on("beforeCreate",i),r&&this.editor.on("create",r),s&&this.editor.on("update",s),o&&this.editor.on("selectionUpdate",o),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),d&&this.editor.on("blur",d),c&&this.editor.on("destroy",c)})}}class eg{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=X($(this,"addOptions",{name:this.name}))),this.storage=X($(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new eg(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>ed(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new eg({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=X($(t,"addOptions",{name:t.name})),t.storage=X($(t,"addStorage",{name:t.name,options:t.options})),t}}function ev(e,t,n){let{from:i,to:r}=t,{blockSeparator:s="\n\n",textSerializers:o={}}=n||{},a="";return e.nodesBetween(i,r,(e,n,l,d)=>{var c;e.isBlock&&n>i&&(a+=s);let h=null==o?void 0:o[e.type.name];if(h)return l&&(a+=h({node:e,pos:n,parent:l,index:d,range:t})),!1;e.isText&&(a+=null===(c=null==e?void 0:e.text)||void 0===c?void 0:c.slice(Math.max(i,n)-n,r-n))}),a}function eb(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}let ey=eg.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:i,selection:r}=t,{ranges:s}=r,o=Math.min(...s.map(e=>e.$from.pos)),a=Math.max(...s.map(e=>e.$to.pos)),l=eb(n);return ev(i,{from:o,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}});function ex(e,t,n={strict:!0}){let i=Object.keys(t);return!i.length||i.every(i=>n.strict?t[i]===e[i]:er(t[i])?t[i].test(e[i]):t[i]===e[i])}function ew(e,t,n={}){return e.find(e=>e.type===t&&ex(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function e_(e,t,n={}){return!!ew(e,t,n)}function eS(e,t,n){var i;if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(n=n||(null===(i=r.node.marks[0])||void 0===i?void 0:i.attrs),!ew([...r.node.marks],t,n))return;let s=r.index,o=e.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(;s>0&&e_([...e.parent.child(s-1).marks],t,n);)s-=1,o-=e.parent.child(s).nodeSize;for(;a<e.parent.childCount&&e_([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function eE(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}function eC(e){return e instanceof r.Bs}function eA(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function ek(e,t=null){if(!t)return null;let n=r.Y1.atStart(e),i=r.Y1.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return i;let s=n.from,o=i.to;return"all"===t?r.Bs.create(e,eA(0,s,o),eA(e.content.size,s,o)):r.Bs.create(e,eA(t,s,o),eA(t,s,o))}function eT(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}let eM=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){let i=t[n];3===i.nodeType&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?e.removeChild(i):1===i.nodeType&&eM(i)}return e};function eD(e){let t=`<body>${e}</body>`;return eM(new window.DOMParser().parseFromString(t,"text/html").body)}function eO(e,t,n){if(e instanceof a.NB||e instanceof a.HY)return e;n={slice:!0,parseOptions:{},...n};let i="object"==typeof e&&null!==e,r="string"==typeof e;if(i)try{if(Array.isArray(e)&&e.length>0)return a.HY.fromArray(e.map(e=>t.nodeFromJSON(e)));let i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),eO("",t,n)}if(r){if(n.errorOnInvalidContent){let i=!1,r="",s=new a.V_({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:e=>(i=!0,r="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?a.aw.fromSchema(s).parseSlice(eD(e),n.parseOptions):a.aw.fromSchema(s).parse(eD(e),n.parseOptions),n.errorOnInvalidContent&&i)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${r}`)})}let i=a.aw.fromSchema(t);return n.slice?i.parseSlice(eD(e),n.parseOptions).content:i.parse(eD(e),n.parseOptions)}return eO("",t,n)}let eI=e=>!("type"in e);function eN(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function eR(e,t,n={}){let{from:i,to:r,empty:s}=e.selection,o=t?Z(t,e.schema):null,a=[];e.doc.nodesBetween(i,r,(e,t)=>{if(e.isText)return;let n=Math.max(i,t),s=Math.min(r,t+e.nodeSize);a.push({node:e,from:n,to:s})});let l=r-i,d=a.filter(e=>!o||o.name===e.node.type.name).filter(e=>ex(e.node.attrs,n,{strict:!1}));return s?!!d.length:d.reduce((e,t)=>e+t.to-t.from,0)>=l}function eL(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function eP(e,t){let n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,i)=>(!n.includes(i)&&(t[i]=e[i]),t),{})}function ej(e,t,n={},i={}){return eO(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:i.errorOnInvalidContent})}function eF(e,t){let n=eE(t,e.schema),{from:i,to:r,empty:s}=e.selection,o=[];s?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(i,r,e=>{o.push(...e.marks)});let a=o.find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}function eB(e,t){for(let n=e.depth;n>0;n-=1){let i=e.node(n);if(t(i))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:i}}}function ez(e){return t=>eB(t.$from,e)}function eH(e,t,n){let i=[];return e===t?n.resolve(e).marks().forEach(t=>{let r=eS(n.resolve(e),t.type);if(!!r)i.push({mark:t,...r})}):n.nodesBetween(e,t,(e,t)=>{if(!!e&&(null==e?void 0:e.nodeSize)!==void 0)i.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),i}function eU(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let i=e.find(e=>e.type===t&&e.name===n);return!!i&&i.attribute.keepOnSplit}))}function eV(e,t,n={}){let{empty:i,ranges:r}=e.selection,s=t?eE(t,e.schema):null;if(i)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!s||s.name===e.type.name).find(e=>ex(e.attrs,n,{strict:!1}));let o=0,a=[];if(r.forEach(({$from:t,$to:n})=>{let i=t.pos,r=n.pos;e.doc.nodesBetween(i,r,(e,t)=>{if(!e.isText&&!e.marks.length)return;let n=Math.max(i,t),s=Math.min(r,t+e.nodeSize);o+=s-n,a.push(...e.marks.map(e=>({mark:e,from:n,to:s})))})}),0===o)return!1;let l=a.filter(e=>!s||s.name===e.mark.type.name).filter(e=>ex(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),d=a.filter(e=>!s||e.mark.type!==s&&e.mark.type.excludes(s)).reduce((e,t)=>e+t.to-t.from,0);return(l>0?l+d:l)>=o}function e$(e,t){let{nodeExtensions:n}=W(t),i=n.find(t=>t.name===e);if(!i)return!1;let r={name:i.name,options:i.options,storage:i.storage},s=X($(i,"group",r));return"string"==typeof s&&s.split(" ").includes("list")}function eW(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var i;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!==(i=e.text)&&void 0!==i?i:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){let i=!0;return e.content.forEach(e=>{if(!1!==i)!eW(e,{ignoreWhitespace:n,checkChildren:t})&&(i=!1)}),i}return!1}function eG(e){return e instanceof r.qv}function eZ(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let i=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(i)}}let eq=(e,t)=>{let n=ez(e=>e.type===t)(e.selection);if(!n)return!0;let i=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===i)return!0;let r=e.doc.nodeAt(i);return!(n.node.type===(null==r?void 0:r.type)&&(0,l.Mn)(e.doc,n.pos))||(e.join(n.pos),!0)},eK=(e,t)=>{let n=ez(e=>e.type===t)(e.selection);if(!n)return!0;let i=e.doc.resolve(n.start).after(n.depth);if(void 0===i)return!0;let r=e.doc.nodeAt(i);return!(n.node.type===(null==r?void 0:r.type)&&(0,l.Mn)(e.doc,i))||(e.join(i),!0)};var eY=Object.freeze({__proto__:null,blur:()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;!e.isDestroyed&&(t.dom.blur(),null===(n=null==window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())}),!0),clearContent:(e=!1)=>({commands:t})=>t.setContent("",e),clearNodes:()=>({state:e,tr:t,dispatch:n})=>{let{selection:i}=t,{ranges:r}=i;return!n||(r.forEach(({$from:n,$to:i})=>{e.doc.nodesBetween(n.pos,i.pos,(e,n)=>{if(e.type.isText)return;let{doc:i,mapping:r}=t,s=i.resolve(r.map(n)),o=i.resolve(r.map(n+e.nodeSize)),a=s.blockRange(o);if(!a)return;let d=(0,l.k9)(a);if(e.type.isTextblock){let{defaultType:e}=s.parent.contentMatchAt(s.index());t.setNodeMarkup(a.start,e)}(d||0===d)&&t.lift(a,d)})}),!0)},command:e=>t=>e(t),createParagraphNear:()=>({state:e,dispatch:t})=>T(e,t),cut:(e,t)=>({editor:n,tr:i})=>{let{state:s}=n,o=s.doc.slice(e.from,e.to);i.deleteRange(e.from,e.to);let a=i.mapping.map(t);return i.insert(a,o.content),i.setSelection(new r.Bs(i.doc.resolve(a-1))),!0},deleteCurrentNode:()=>({tr:e,dispatch:t})=>{let{selection:n}=e,i=n.$anchor.node();if(i.content.size>0)return!1;let r=e.selection.$anchor;for(let n=r.depth;n>0;n-=1)if(r.node(n).type===i.type){if(t){let t=r.before(n),i=r.after(n);e.delete(t,i).scrollIntoView()}return!0}return!1},deleteNode:e=>({tr:t,state:n,dispatch:i})=>{let r=Z(e,n.schema),s=t.selection.$anchor;for(let e=s.depth;e>0;e-=1)if(s.node(e).type===r){if(i){let n=s.before(e),i=s.after(e);t.delete(n,i).scrollIntoView()}return!0}return!1},deleteRange:e=>({tr:t,dispatch:n})=>{let{from:i,to:r}=e;return n&&t.delete(i,r),!0},deleteSelection:()=>({state:e,dispatch:t})=>d(e,t),enter:()=>({commands:e})=>e.keyboardShortcut("Enter"),exitCode:()=>({state:e,dispatch:t})=>k(e,t),extendMarkRange:(e,t={})=>({tr:n,state:i,dispatch:s})=>{let o=eE(e,i.schema),{doc:a,selection:l}=n,{$from:d,from:c,to:h}=l;if(s){let e=eS(d,o,t);if(e&&e.from<=c&&e.to>=h){let t=r.Bs.create(a,e.from,e.to);n.setSelection(t)}}return!0},first:e=>t=>{let n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1},focus:(e=null,t={})=>({editor:n,view:i,tr:r,dispatch:s})=>{t={scrollIntoView:!0,...t};let o=()=>{(eT()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&i.dom.focus(),requestAnimationFrame(()=>{!n.isDestroyed&&(i.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};if(i.hasFocus()&&null===e||!1===e)return!0;if(s&&null===e&&!eC(n.state.selection))return o(),!0;let a=ek(r.doc,e)||n.state.selection,l=n.state.selection.eq(a);return s&&(!l&&r.setSelection(a),l&&r.storedMarks&&r.setStoredMarks(r.storedMarks),o()),!0},forEach:(e,t)=>n=>e.every((e,i)=>t(e,{...n,index:i})),insertContent:(e,t)=>({tr:n,commands:i})=>i.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),insertContentAt:(e,t,n)=>({tr:i,dispatch:s,editor:o})=>{var d;if(s){let s,c;n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let h=e=>{o.emit("contentError",{editor:o,error:e,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{eO(t,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(e){h(e)}try{s=eO(t,o.schema,{parseOptions:u,errorOnInvalidContent:null!==(d=n.errorOnInvalidContent)&&void 0!==d?d:o.options.enableContentCheck})}catch(e){return h(e),!1}let{from:p,to:f}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},m=!0,g=!0;if((eI(s)?s:[s]).forEach(e=>{e.check(),m=!!m&&e.isText&&0===e.marks.length,g=!!g&&e.isBlock}),p===f&&g){let{parent:e}=i.doc.resolve(p);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(p-=1,f+=1)}if(m){if(Array.isArray(t))c=t.map(e=>e.text||"").join("");else if(t instanceof a.HY){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),c=e}else c="object"==typeof t&&t&&t.text?t.text:t;i.insertText(c,p,f)}else c=s,i.replaceWith(p,f,c);n.updateSelection&&!function(e,t,n){let i=e.steps.length-1;if(i<t)return;let s=e.steps[i];if(!(s instanceof l.Pu||s instanceof l.FC))return;let o=e.mapping.maps[i],a=0;o.forEach((e,t,n,i)=>{0===a&&(a=i)}),e.setSelection(r.Y1.near(e.doc.resolve(a),-1))}(i,i.steps.length-1,-1),n.applyInputRules&&i.setMeta("applyInputRules",{from:p,text:c}),n.applyPasteRules&&i.setMeta("applyPasteRules",{from:p,text:c})}return!0},joinBackward:()=>({state:e,dispatch:t})=>h(e,t),joinDown:()=>({state:e,dispatch:t})=>S(e,t),joinForward:()=>({state:e,dispatch:t})=>y(e,t),joinItemBackward:()=>({state:e,dispatch:t,tr:n})=>{try{let i=(0,l.GJ)(e.doc,e.selection.$from.pos,-1);if(null==i)return!1;return n.join(i,2),t&&t(n),!0}catch{return!1}},joinItemForward:()=>({state:e,dispatch:t,tr:n})=>{try{let i=(0,l.GJ)(e.doc,e.selection.$from.pos,1);if(null==i)return!1;return n.join(i,2),t&&t(n),!0}catch{return!1}},joinTextblockBackward:()=>({state:e,dispatch:t})=>u(e,t),joinTextblockForward:()=>({state:e,dispatch:t})=>p(e,t),joinUp:()=>({state:e,dispatch:t})=>_(e,t),keyboardShortcut:e=>({editor:t,view:n,tr:i,dispatch:r})=>{let s=(function(e){let t,n,i,r;let s=e.split(/-(?!$)/),o=s[s.length-1];"Space"===o&&(o=" ");for(let e=0;e<s.length-1;e+=1){let o=s[e];if(/^(cmd|meta|m)$/i.test(o))r=!0;else if(/^a(lt)?$/i.test(o))t=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))i=!0;else if(/^mod$/i.test(o))eT()||eN()?r=!0:n=!0;else throw Error(`Unrecognized modifier name: ${o}`)}return t&&(o=`Alt-${o}`),n&&(o=`Ctrl-${o}`),r&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o})(e).split(/-(?!$)/),o=s.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,a))});return null==l||l.steps.forEach(e=>{let t=e.map(i.mapping);t&&r&&i.maybeStep(t)}),!0},lift:(e,t={})=>({state:n,dispatch:i})=>{let r=Z(e,n.schema);return!!eR(n,r,t)&&E(n,i)},liftEmptyBlock:()=>({state:e,dispatch:t})=>M(e,t),liftListItem:e=>({state:t,dispatch:n})=>{var i;return(i=Z(e,t.schema),function(e,t){let{$from:n,$to:r}=e.selection,s=n.blockRange(r,e=>e.childCount>0&&e.firstChild.type==i);return!!s&&(!t||(n.node(s.depth-1).type==i?function(e,t,n,i){let r=e.tr,s=i.end,o=i.$to.end(i.depth);s<o&&(r.step(new l.FC(s-1,o,s,o,new a.p2(a.HY.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new a.Ts(r.doc.resolve(i.$from.pos),r.doc.resolve(o),i.depth));let d=(0,l.k9)(i);if(null==d)return!1;r.lift(i,d);let c=r.doc.resolve(r.mapping.map(s,-1)-1);return(0,l.Mn)(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),t(r.scrollIntoView()),!0}(e,t,i,s):function(e,t,n){let i=e.tr,r=n.parent;for(let e=n.end,t=n.endIndex-1,s=n.startIndex;t>s;t--)e-=r.child(t).nodeSize,i.delete(e-1,e+1);let s=i.doc.resolve(n.start),o=s.nodeAfter;if(i.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let d=0==n.startIndex,c=n.endIndex==r.childCount,h=s.node(-1),u=s.index(-1);if(!h.canReplace(u+(d?0:1),u+1,o.content.append(c?a.HY.empty:a.HY.from(r))))return!1;let p=s.pos,f=p+o.nodeSize;return i.step(new l.FC(p-(d?1:0),f+(c?1:0),p+1,f-1,new a.p2((d?a.HY.empty:a.HY.from(r.copy(a.HY.empty))).append(c?a.HY.empty:a.HY.from(r.copy(a.HY.empty))),d?0:1,c?0:1),d?0:1)),t(i.scrollIntoView()),!0}(e,t,s)))})(t,n)},newlineInCode:()=>({state:e,dispatch:t})=>C(e,t),resetAttributes:(e,t)=>({tr:n,state:i,dispatch:r})=>{let s=null,o=null,a=eL("string"==typeof e?e:e.name,i.schema);return!!a&&("node"===a&&(s=Z(e,i.schema)),"mark"===a&&(o=eE(e,i.schema)),r&&n.selection.ranges.forEach(e=>{i.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,i)=>{s&&s===e.type&&n.setNodeMarkup(i,void 0,eP(e.attrs,t)),o&&e.marks.length&&e.marks.forEach(r=>{o===r.type&&n.addMark(i,i+e.nodeSize,o.create(eP(r.attrs,t)))})})}),!0)},scrollIntoView:()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),selectAll:()=>({tr:e,dispatch:t})=>{if(t){let t=new r.C1(e.doc);e.setSelection(t)}return!0},selectNodeBackward:()=>({state:e,dispatch:t})=>g(e,t),selectNodeForward:()=>({state:e,dispatch:t})=>x(e,t),selectParentNode:()=>({state:e,dispatch:t})=>D(e,t),selectTextblockEnd:()=>({state:e,dispatch:t})=>R(e,t),selectTextblockStart:()=>({state:e,dispatch:t})=>N(e,t),setContent:(e,t=!1,n={},i={})=>({editor:r,tr:s,dispatch:o,commands:a})=>{var l,d;let{doc:c}=s;if("full"!==n.preserveWhitespace){let a=ej(e,r.schema,n,{errorOnInvalidContent:null!==(l=i.errorOnInvalidContent)&&void 0!==l?l:r.options.enableContentCheck});return o&&s.replaceWith(0,c.content.size,a).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:c.content.size},e,{parseOptions:n,errorOnInvalidContent:null!==(d=i.errorOnInvalidContent)&&void 0!==d?d:r.options.enableContentCheck})},setMark:(e,t={})=>({tr:n,state:i,dispatch:r})=>{let{selection:s}=n,{empty:o,ranges:a}=s,l=eE(e,i.schema);if(r){if(o){let e=eF(i,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach(e=>{let r=e.$from.pos,s=e.$to.pos;i.doc.nodesBetween(r,s,(e,i)=>{let o=Math.max(i,r),a=Math.min(i+e.nodeSize,s);e.marks.find(e=>e.type===l)?e.marks.forEach(e=>{l===e.type&&n.addMark(o,a,l.create({...e.attrs,...t}))}):n.addMark(o,a,l.create(t))})})}return function(e,t,n){var i;let{selection:r}=t,s=null;if(eC(r)&&(s=r.$cursor),s){let t=null!==(i=e.storedMarks)&&void 0!==i?i:s.marks();return!!n.isInSet(t)||!t.some(e=>e.type.excludes(n))}let{ranges:o}=r;return o.some(({$from:t,$to:i})=>{let r=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,i.pos,(e,t,i)=>{if(r)return!1;if(e.isInline){let t=!i||i.type.allowsMarkType(n),s=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));r=t&&s}return!r}),r})}(i,n,l)},setMeta:(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),setNode:(e,t={})=>({state:n,dispatch:i,chain:r})=>{let s;let o=Z(e,n.schema);return(n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock)?r().command(({commands:e})=>!!L(o,{...s,...t})(n)||e.clearNodes()).command(({state:e})=>L(o,{...s,...t})(e,i)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,i=eA(e,0,n.content.size),s=r.qv.create(n,i);t.setSelection(s)}return!0},setTextSelection:e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:i,to:s}="number"==typeof e?{from:e,to:e}:e,o=r.Bs.atStart(n).from,a=r.Bs.atEnd(n).to,l=eA(i,o,a),d=eA(s,o,a),c=r.Bs.create(n,l,d);t.setSelection(c)}return!0},sinkListItem:e=>({state:t,dispatch:n})=>{var i;return(i=Z(e,t.schema),function(e,t){let{$from:n,$to:r}=e.selection,s=n.blockRange(r,e=>e.childCount>0&&e.firstChild.type==i);if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let d=s.parent,c=d.child(o-1);if(c.type!=i)return!1;if(t){let n=c.lastChild&&c.lastChild.type==d.type,r=a.HY.from(n?i.create():null),o=new a.p2(a.HY.from(i.create(null,a.HY.from(d.type.create(null,r)))),n?3:1,0),h=s.start,u=s.end;t(e.tr.step(new l.FC(h-(n?3:1),u,h,u,o,1,!0)).scrollIntoView())}return!0})(t,n)},splitBlock:({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:i,editor:s})=>{let{selection:o,doc:a}=t,{$from:d,$to:c}=o,h=eU(s.extensionManager.attributes,d.node().type.name,d.node().attrs);if(o instanceof r.qv&&o.node.isBlock)return!!(d.parentOffset&&(0,l.Ax)(a,d.pos))&&(i&&(e&&eZ(n,s.extensionManager.splittableMarks),t.split(d.pos).scrollIntoView()),!0);if(!d.parent.isBlock)return!1;let u=c.parentOffset===c.parent.content.size,p=0===d.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(d.node(-1).contentMatchAt(d.indexAfter(-1))),f=u&&p?[{type:p,attrs:h}]:void 0,m=(0,l.Ax)(t.doc,t.mapping.map(d.pos),1,f);if(!f&&!m&&(0,l.Ax)(t.doc,t.mapping.map(d.pos),1,p?[{type:p}]:void 0)&&(m=!0,f=p?[{type:p,attrs:h}]:void 0),i){if(m&&(o instanceof r.Bs&&t.deleteSelection(),t.split(t.mapping.map(d.pos),1,f),p&&!u&&!d.parentOffset&&d.parent.type!==p)){let e=t.mapping.map(d.before()),n=t.doc.resolve(e);d.node(-1).canReplaceWith(n.index(),n.index()+1,p)&&t.setNodeMarkup(t.mapping.map(d.before()),p)}e&&eZ(n,s.extensionManager.splittableMarks),t.scrollIntoView()}return m},splitListItem:(e,t={})=>({tr:n,state:i,dispatch:s,editor:o})=>{var d;let c=Z(e,i.schema),{$from:h,$to:u}=i.selection,p=i.selection.node;if(p&&p.isBlock||h.depth<2||!h.sameParent(u))return!1;let f=h.node(-1);if(f.type!==c)return!1;let m=o.extensionManager.attributes;if(0===h.parent.content.size&&h.node(-1).childCount===h.indexAfter(-1)){if(2===h.depth||h.node(-3).type!==c||h.index(-2)!==h.node(-2).childCount-1)return!1;if(s){let e=a.HY.empty,i=h.index(-1)?1:h.index(-2)?2:3;for(let t=h.depth-i;t>=h.depth-3;t-=1)e=a.HY.from(h.node(t).copy(e));let s=h.indexAfter(-1)<h.node(-2).childCount?1:h.indexAfter(-2)<h.node(-3).childCount?2:3,o={...eU(m,h.node().type.name,h.node().attrs),...t},l=(null===(d=c.contentMatch.defaultType)||void 0===d?void 0:d.createAndFill(o))||void 0;e=e.append(a.HY.from(c.createAndFill(null,l)||void 0));let u=h.before(h.depth-(i-1));n.replace(u,h.after(-s),new a.p2(e,4-i,0));let p=-1;n.doc.nodesBetween(u,n.doc.content.size,(e,t)=>{if(p>-1)return!1;e.isTextblock&&0===e.content.size&&(p=t+1)}),p>-1&&n.setSelection(r.Bs.near(n.doc.resolve(p))),n.scrollIntoView()}return!0}let g=u.pos===h.end()?f.contentMatchAt(0).defaultType:null,v={...eU(m,f.type.name,f.attrs),...t},b={...eU(m,h.node().type.name,h.node().attrs),...t};n.delete(h.pos,u.pos);let y=g?[{type:c,attrs:v},{type:g,attrs:b}]:[{type:c,attrs:v}];if(!(0,l.Ax)(n.doc,h.pos,2))return!1;if(s){let{selection:e,storedMarks:t}=i,{splittableMarks:r}=o.extensionManager,a=t||e.$to.parentOffset&&e.$from.marks();if(n.split(h.pos,2,y).scrollIntoView(),!a||!s)return!0;let l=a.filter(e=>r.includes(e.type.name));n.ensureMarks(l)}return!0},toggleList:(e,t,n,i={})=>({editor:r,tr:s,state:o,dispatch:a,chain:l,commands:d,can:c})=>{let{extensions:h,splittableMarks:u}=r.extensionManager,p=Z(e,o.schema),f=Z(t,o.schema),{selection:m,storedMarks:g}=o,{$from:v,$to:b}=m,y=v.blockRange(b),x=g||m.$to.parentOffset&&m.$from.marks();if(!y)return!1;let w=ez(e=>e$(e.type.name,h))(m);if(y.depth>=1&&w&&y.depth-w.depth<=1){if(w.node.type===p)return d.liftListItem(f);if(e$(w.node.type.name,h)&&p.validContent(w.node.content)&&a)return l().command(()=>(s.setNodeMarkup(w.pos,p),!0)).command(()=>eq(s,p)).command(()=>eK(s,p)).run()}return n&&x&&a?l().command(()=>{let e=c().wrapInList(p,i),t=x.filter(e=>u.includes(e.type.name));return s.ensureMarks(t),!!e||d.clearNodes()}).wrapInList(p,i).command(()=>eq(s,p)).command(()=>eK(s,p)).run():l().command(()=>!!c().wrapInList(p,i)||d.clearNodes()).wrapInList(p,i).command(()=>eq(s,p)).command(()=>eK(s,p)).run()},toggleMark:(e,t={},n={})=>({state:i,commands:r})=>{let{extendEmptyMarkRange:s=!1}=n,o=eE(e,i.schema);return eV(i,o,t)?r.unsetMark(o,{extendEmptyMarkRange:s}):r.setMark(o,t)},toggleNode:(e,t,n={})=>({state:i,commands:r})=>{let s;let o=Z(e,i.schema),a=Z(t,i.schema),l=eR(i,o,n);return(i.selection.$anchor.sameParent(i.selection.$head)&&(s=i.selection.$anchor.parent.attrs),l)?r.setNode(a,s):r.setNode(o,{...s,...n})},toggleWrap:(e,t={})=>({state:n,commands:i})=>{let r=Z(e,n.schema);return eR(n,r,t)?i.lift(r):i.wrapIn(r,t)},undoInputRule:()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let i=0;i<n.length;i+=1){let r;let s=n[i];if(s.spec.isInputRules&&(r=s.getState(e))){if(t){let t=e.tr,n=r.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(r.text){let n=t.doc.resolve(r.from).marks();t.replaceWith(r.from,r.to,e.schema.text(r.text,n))}else t.delete(r.from,r.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:i,ranges:r}=n;return!!i||(t&&r.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0)},unsetMark:(e,t={})=>({tr:n,state:i,dispatch:r})=>{var s;let{extendEmptyMarkRange:o=!1}=t,{selection:a}=n,l=eE(e,i.schema),{$from:d,empty:c,ranges:h}=a;if(!r)return!0;if(c&&o){let{from:e,to:t}=a,i=null===(s=d.marks().find(e=>e.type===l))||void 0===s?void 0:s.attrs,r=eS(d,l,i);r&&(e=r.from,t=r.to),n.removeMark(e,t,l)}else h.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,l)});return n.removeStoredMark(l),!0},updateAttributes:(e,t={})=>({tr:n,state:i,dispatch:r})=>{let s=null,o=null,a=eL("string"==typeof e?e:e.name,i.schema);return!!a&&("node"===a&&(s=Z(e,i.schema)),"mark"===a&&(o=eE(e,i.schema)),r&&n.selection.ranges.forEach(e=>{let r,a,l,d;let c=e.$from.pos,h=e.$to.pos;n.selection.empty?i.doc.nodesBetween(c,h,(e,t)=>{s&&s===e.type&&(l=Math.max(t,c),d=Math.min(t+e.nodeSize,h),r=t,a=e)}):i.doc.nodesBetween(c,h,(e,i)=>{i<c&&s&&s===e.type&&(l=Math.max(i,c),d=Math.min(i+e.nodeSize,h),r=i,a=e),i>=c&&i<=h&&(s&&s===e.type&&n.setNodeMarkup(i,void 0,{...e.attrs,...t}),o&&e.marks.length&&e.marks.forEach(r=>{if(o===r.type){let s=Math.max(i,c),a=Math.min(i+e.nodeSize,h);n.addMark(s,a,o.create({...r.attrs,...t}))}}))}),a&&(void 0!==r&&n.setNodeMarkup(r,void 0,{...a.attrs,...t}),o&&a.marks.length&&a.marks.forEach(e=>{o===e.type&&n.addMark(l,d,o.create({...e.attrs,...t}))}))}),!0)},wrapIn:(e,t={})=>({state:n,dispatch:i})=>(function(e,t=null){return function(n,i){let{$from:r,$to:s}=n.selection,o=r.blockRange(s),a=o&&(0,l.nd)(o,e,t);return!!a&&(i&&i(n.tr.wrap(o,a).scrollIntoView()),!0)}})(Z(e,n.schema),t)(n,i),wrapInList:(e,t={})=>({state:n,dispatch:i})=>(function(e,t=null){return function(n,i){let{$from:r,$to:s}=n.selection,o=r.blockRange(s);if(!o)return!1;let d=i?n.tr:null;return!!function(e,t,n,i=null){let r=!1,s=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=o.resolve(t.start-2);s=new a.Ts(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new a.Ts(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),r=!0}let d=(0,l.nd)(s,n,i,t);return!!d&&(e&&function(e,t,n,i,r){let s=a.HY.empty;for(let e=n.length-1;e>=0;e--)s=a.HY.from(n[e].type.create(n[e].attrs,s));e.step(new l.FC(t.start-(i?2:0),t.end,t.start,t.end,new a.p2(s,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==r&&(o=e+1);let d=n.length-o,c=t.start+n.length-(i?2:0),h=t.parent;for(let n=t.startIndex,i=t.endIndex,r=!0;n<i;n++,r=!1)!r&&(0,l.Ax)(e.doc,c,d)&&(e.split(c,d),c+=2*d),c+=h.child(n).nodeSize;}(e,t,d,r,n),!0)}(d,o,e,t)&&(i&&i(d.scrollIntoView()),!0)}})(Z(e,n.schema),t)(n,i)});let eX=eg.create({name:"commands",addCommands:()=>({...eY})}),eJ=eg.create({name:"drop",addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("tiptapDrop"),props:{handleDrop:(e,t,n,i)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:i})}}})]}}),eQ=eg.create({name:"editable",addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("editable"),props:{editable:()=>this.editor.options.editable}})]}}),e0=new r.H$("focusEvents"),e1=eg.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return[new r.Sy({key:e0,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let i=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1},blur:(t,n)=>{e.isFocused=!1;let i=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1}}}})]}}),e2=eg.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:i}=t,{empty:s,$anchor:o}=n,{pos:a,parent:l}=o,d=o.parent.isTextblock&&a>0?t.doc.resolve(a-1):o,c=d.parent.type.spec.isolating,h=o.pos-o.parentOffset,u=c&&1===d.parent.childCount?h===o.pos:r.Y1.atStart(i).from===a;return!!s&&!!l.type.isTextblock&&!l.textContent.length&&!!u&&(!u||"paragraph"!==o.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},s={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return eT()||eN()?s:i},addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;let i=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),s=e.some(e=>e.getMeta("preventClearDocument"));if(!i||s)return;let{empty:o,from:a,to:l}=t.selection,d=r.Y1.atStart(t.doc).from,c=r.Y1.atEnd(t.doc).to;if(o||!(a===d&&l===c)||!eW(n.doc))return;let h=n.tr,u=H({state:n,transaction:h}),{commands:p}=new U({editor:this.editor,state:u});if(p.clearNodes(),!!h.steps.length)return h}})]}}),e5=eg.create({name:"paste",addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),e3=eg.create({name:"tabindex",addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class e4{get name(){return this.node.type.name}constructor(e,t,n=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return null!==(e=this.actualDepth)&&void 0!==e?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1);return new e4(this.resolvedPos.doc.resolve(e),this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new e4(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new e4(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,n)=>{let i=t.isBlock&&!t.isTextblock,r=t.isAtom&&!t.isText,s=this.pos+n+(r?0:1),o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;let a=new e4(o,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new e4(o,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,i=this.parent;for(;i&&!n;){if(i.node.type.name===e){if(Object.keys(t).length>0){let e=i.node.attrs,n=Object.keys(t);for(let i=0;i<n.length;i+=1){let r=n[i];if(e[r]!==t[r])break}}else n=i}i=i.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let i=[];if(!this.children||0===this.children.length)return i;let r=Object.keys(t);return this.children.forEach(s=>{if(n&&i.length>0)return;if(s.node.type.name===e&&r.every(e=>t[e]===s.node.attrs[e])&&i.push(s),!n||!(i.length>0))i=i.concat(s.querySelectorAll(e,t,n))}),i}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}let e6=`.ProseMirror {
|
|
|
position: relative;
|
|
|
}
|
|
|
|
|
|
.ProseMirror {
|
|
|
word-wrap: break-word;
|
|
|
white-space: pre-wrap;
|
|
|
white-space: break-spaces;
|
|
|
-webkit-font-variant-ligatures: none;
|
|
|
font-variant-ligatures: none;
|
|
|
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
|
}
|
|
|
|
|
|
.ProseMirror [contenteditable="false"] {
|
|
|
white-space: normal;
|
|
|
}
|
|
|
|
|
|
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
|
white-space: pre-wrap;
|
|
|
}
|
|
|
|
|
|
.ProseMirror pre {
|
|
|
white-space: pre-wrap;
|
|
|
}
|
|
|
|
|
|
img.ProseMirror-separator {
|
|
|
display: inline !important;
|
|
|
border: none !important;
|
|
|
margin: 0 !important;
|
|
|
width: 0 !important;
|
|
|
height: 0 !important;
|
|
|
}
|
|
|
|
|
|
.ProseMirror-gapcursor {
|
|
|
display: none;
|
|
|
pointer-events: none;
|
|
|
position: absolute;
|
|
|
margin: 0;
|
|
|
}
|
|
|
|
|
|
.ProseMirror-gapcursor:after {
|
|
|
content: "";
|
|
|
display: block;
|
|
|
position: absolute;
|
|
|
top: -2px;
|
|
|
width: 20px;
|
|
|
border-top: 1px solid black;
|
|
|
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
|
}
|
|
|
|
|
|
@keyframes ProseMirror-cursor-blink {
|
|
|
to {
|
|
|
visibility: hidden;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.ProseMirror-hideselection *::selection {
|
|
|
background: transparent;
|
|
|
}
|
|
|
|
|
|
.ProseMirror-hideselection *::-moz-selection {
|
|
|
background: transparent;
|
|
|
}
|
|
|
|
|
|
.ProseMirror-hideselection * {
|
|
|
caret-color: transparent;
|
|
|
}
|
|
|
|
|
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
|
display: block;
|
|
|
}
|
|
|
|
|
|
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
|
opacity: 0
|
|
|
}`;class e8 extends V{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on("paste",({event:e,slice:t})=>this.options.onPaste(e,t)),window.setTimeout(()=>{if(!this.isDestroyed)this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(e,t,n){let i=document.querySelector("style[data-tiptap-style]");if(null!==i)return i;let r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}(e6,this.options.injectNonce))}setOptions(e={}){if(this.options={...this.options,...e},!!this.view&&!!this.state&&!this.isDestroyed)this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state)}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){let n=Y(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t="string"==typeof e?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[eQ,ey.configure({blockSeparator:null===(t=null===(e=this.options.coreExtensionOptions)||void 0===e?void 0:e.clipboardTextSerializer)||void 0===t?void 0:t.blockSeparator}),eX,e1,e2,e3,eJ,e5].filter(e=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[e.name]):[],...this.options.extensions].filter(e=>["extension","node","mark"].includes(null==e?void 0:e.type));this.extensionManager=new em(n,this)}createCommandManager(){this.commandManager=new U({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=ej(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>"collaboration"!==e.name),this.createExtensionManager()}}),t=ej(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let n=ek(t,this.options.autofocus);this.view=new s.tk(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...null===(e=this.options.editorProps)||void 0===e?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:r.yy.create({doc:t,selection:n||void 0})});let i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass(),this.view.dom.editor=this}createNodeViews(){if(!this.view.isDestroyed)this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>{var t;return null===(t=this.capturedTransaction)||void 0===t?void 0:t.step(e)});return}let t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});let i=e.getMeta("focus"),r=e.getMeta("blur");if(i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),r&&this.emit("blur",{editor:this,event:r.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate")))this.emit("update",{editor:this,transaction:e})}getAttributes(e){return function(e,t){let n=eL("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){let n=Z(t,e.schema),{from:i,to:r}=e.selection,s=[];e.doc.nodesBetween(i,r,e=>{s.push(e)});let o=s.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}(e,t):"mark"===n?eF(e,t):{}}(this.state,e)}isActive(e,t){let n="string"==typeof e?e:null,i="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return eR(e,null,n)||eV(e,null,n);let i=eL(t,e.schema);return"node"===i?eR(e,t,n):"mark"===i&&eV(e,t,n)}(this.state,n,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return en(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){let n={from:0,to:e.content.size};return ev(e,n,t)}(this.state.doc,{blockSeparator:t,textSerializers:{...eb(this.schema),...n}})}get isEmpty(){return eW(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(null===(e=this.view)||void 0===e?void 0:e.docView)}$node(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelectorAll(e,t))||null}$pos(e){return new e4(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}}function e7(e){return new es({find:e.find,handler:({state:t,range:n,match:i})=>{let r=X(e.getAttributes,void 0,i);if(!1===r||null===r)return null;let{tr:s}=t,o=i[i.length-1],a=i[0];if(o){let i=a.search(/\S/),l=n.from+a.indexOf(o),d=l+o.length;if(eH(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>l).length)return null;d<n.to&&s.delete(d,n.to),l>n.from&&s.delete(n.from+i,l);let c=n.from+i+o.length;s.addMark(n.from+i,c,e.type.create(r||{})),s.removeStoredMark(e.type)}}})}function e9(e){return new es({find:e.find,handler:({state:t,range:n,match:i})=>{let r=X(e.getAttributes,void 0,i)||{},{tr:s}=t,o=n.from,a=n.to,l=e.type.create(r);if(i[1]){let e=o+i[0].lastIndexOf(i[1]);e>a?e=a:a=e+i[1].length;let t=i[0][i[0].length-1];s.insertText(t,o+i[0].length-1),s.replaceWith(e,a,l)}else if(i[0]){let t=e.type.isInline?o:o-1;s.insert(t,e.type.create(r)).delete(s.mapping.map(o),s.mapping.map(a))}s.scrollIntoView()}})}function te(e){return new es({find:e.find,handler:({state:t,range:n,match:i})=>{let r=t.doc.resolve(n.from),s=X(e.getAttributes,void 0,i)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,s)}})}function tt(e){return new es({find:e.find,handler:({state:t,range:n,match:i,chain:r})=>{let s=X(e.getAttributes,void 0,i)||{},o=t.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),d=a&&(0,l.nd)(a,e.type,s);if(!d)return null;if(o.wrap(a,d),e.keepMarks&&e.editor){let{selection:n,storedMarks:i}=t,{splittableMarks:r}=e.editor.extensionManager,s=i||n.$to.parentOffset&&n.$from.marks();if(s){let e=s.filter(e=>r.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";r().updateAttributes(t,s).run()}let c=o.doc.resolve(n.from-1).nodeBefore;c&&c.type===e.type&&(0,l.Mn)(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(i,c))&&o.join(n.from-1)}})}class tn{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=X($(this,"addOptions",{name:this.name}))),this.storage=X($(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new tn(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>ed(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new tn(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=X($(t,"addOptions",{name:t.name})),t.storage=X($(t,"addStorage",{name:t.name,options:t.options})),t}}function ti(e){return new eh({find:e.find,handler:({state:t,range:n,match:i,pasteEvent:r})=>{let s=X(e.getAttributes,void 0,i,r);if(!1===s||null===s)return null;let{tr:o}=t,a=i[i.length-1],l=i[0],d=n.to;if(a){let i=l.search(/\S/),r=n.from+l.indexOf(a),c=r+a.length;if(eH(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>r).length)return null;c<n.to&&o.delete(c,n.to),r>n.from&&o.delete(n.from+i,r),d=n.from+i+a.length,o.addMark(n.from+i,d,e.type.create(s||{})),o.removeStoredMark(e.type)}}})}},550745:function(e,t,n){"use strict";n.d(t,{ZP:function(){return s}});var i=n(453203);let r=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,s=i.NB.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{}}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",(0,i.P1)(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[(0,i.x2)({find:r,type:this.type,getAttributes:e=>{let[,,t,n,i]=e;return{src:n,alt:t,title:i}}})]}})},778681:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});var i=n(453203);let r=i.NB.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute("colwidth");return t?t.split(",").map(e=>parseInt(e,10)):null}}}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:e}){return["td",(0,i.P1)(this.options.HTMLAttributes,e),0]}})},357962:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});var i=n(453203);let r=i.NB.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute("colwidth");return t?t.split(",").map(e=>parseInt(e,10)):null}}}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:e}){return["th",(0,i.P1)(this.options.HTMLAttributes,e),0]}})},76049:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});var i=n(453203);let r=i.NB.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:e}){return["tr",(0,i.P1)(this.options.HTMLAttributes,e),0]}})},481265:function(e,t,n){"use strict";n.d(t,{ZP:()=>eh});var i,r,s=n("453203"),o=n("871738"),a=n("153737"),l=n("661763"),d=n("132308"),c=n("240554");if("undefined"!=typeof WeakMap){let e=new WeakMap;i=t=>e.get(t),r=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;i=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},r=(n,i)=>(10==t&&(t=0),e[t++]=n,e[t++]=i)}var h=class{constructor(e,t,n,i){this.width=e,this.height=t,this.map=n,this.problems=i}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let i=t%this.width,r=t/this.width|0,s=i+1,o=r+1;for(let e=1;s<this.width&&this.map[t+e]==n;e++)s++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:i,top:r,right:s,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:i,right:r,top:s,bottom:o}=this.findCell(e);if("horiz"==t)return(n<0?0==i:r==this.width)?null:this.map[s*this.width+(n<0?i-1:r)];return(n<0?0==s:o==this.height)?null:this.map[i+this.width*(n<0?s-1:o)]}rectBetween(e,t){let{left:n,right:i,top:r,bottom:s}=this.findCell(e),{left:o,right:a,top:l,bottom:d}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(r,l),right:Math.max(i,a),bottom:Math.max(s,d)}}cellsInRect(e){let t=[],n={};for(let i=e.top;i<e.bottom;i++)for(let r=e.left;r<e.right;r++){let s=i*this.width+r,o=this.map[s];if(!n[o]){if(n[o]=!0,r==e.left&&r&&this.map[s-1]==o||i==e.top&&i&&this.map[s-this.width]==o)continue;t.push(o)}}return t}positionAt(e,t,n){for(let i=0,r=0;;i++){let s=r+n.child(i).nodeSize;if(i==e){let n=t+e*this.width,i=(e+1)*this.width;for(;n<i&&this.map[n]<r;)n++;return n==i?s-1:this.map[n]}r=s}}static get(e){return i(e)||r(e,function(e){if("table"!=e.type.spec.tableRole)throw RangeError("Not a table node: "+e.type.name);let t=function(e){let t=-1,n=!1;for(let i=0;i<e.childCount;i++){let r=e.child(i),s=0;if(n)for(let t=0;t<i;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let r=n.child(e);t+r.attrs.rowspan>i&&(s+=r.attrs.colspan)}}for(let e=0;e<r.childCount;e++){let t=r.child(e);s+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=s:t!=s&&(t=Math.max(t,s))}return t}(e),n=e.childCount,i=[],r=0,s=null,o=[];for(let e=0,r=t*n;e<r;e++)i[e]=0;for(let a=0,l=0;a<n;a++){let d=e.child(a);l++;for(let e=0;;e++){for(;r<i.length&&0!=i[r];)r++;if(e==d.childCount)break;let c=d.child(e),{colspan:h,rowspan:u,colwidth:p}=c.attrs;for(let e=0;e<u;e++){if(e+a>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:l,n:u-e});break}let d=r+e*t;for(let e=0;e<h;e++){0==i[d+e]?i[d+e]=l:(s||(s=[])).push({type:"collision",row:a,pos:l,n:h-e});let n=p&&p[e];if(n){let i=(d+e)%t*2,r=o[i];null==r||r!=n&&1==o[i+1]?(o[i]=n,o[i+1]=1):r==n&&o[i+1]++}}}r+=h,l+=c.nodeSize}let c=(a+1)*t,h=0;for(;r<c;)0==i[r++]&&h++;h&&(s||(s=[])).push({type:"missing",row:a,n:h}),l++}(0===t||0===n)&&(s||(s=[])).push({type:"zero_sized"});let a=new h(t,n,i,s),l=!1;for(let e=0;!l&&e<o.length;e+=2)null!=o[e]&&o[e+1]<n&&(l=!0);return l&&function(e,t,n){!e.problems&&(e.problems=[]);let i={};for(let r=0;r<e.map.length;r++){let s=e.map[r];if(i[s])continue;i[s]=!0;let o=n.nodeAt(s);if(!o)throw RangeError(`No cell with offset ${s} found`);let a=null,l=o.attrs;for(let n=0;n<l.colspan;n++){let i=t[2*((r+n)%e.width)];null!=i&&(!l.colwidth||l.colwidth[n]!=i)&&((a||(a=function(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}(l)))[n]=i)}a&&e.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:a})}}(a,o,e),a}(e))}};function u(e){let t=e.cached.tableNodeTypes;if(!t)for(let n in t=e.cached.tableNodeTypes={},e.nodes){let i=e.nodes[n],r=i.spec.tableRole;r&&(t[r]=i)}return t}var p=new o.H$("selectingCells");function f(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function m(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function g(e){let t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;let n=f(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let i=t.type.spec.tableRole;if("cell"==i||"header_cell"==i)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let i=t.type.spec.tableRole;if("cell"==i||"header_cell"==i)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function v(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function b(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function y(e,t,n){let i=e.node(-1),r=h.get(i),s=e.start(-1),o=r.nextCell(e.pos-s,t,n);return null==o?null:e.node(0).resolve(s+o)}function x(e,t,n=1){let i={...e,colspan:e.colspan-n};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(t,n),!i.colwidth.some(e=>e>0)&&(i.colwidth=null)),i}function w(e,t,n=1){let i={...e,colspan:e.colspan+n};if(i.colwidth){i.colwidth=i.colwidth.slice();for(let e=0;e<n;e++)i.colwidth.splice(t,0,0)}return i}var _=class e extends o.Y1{constructor(e,t=e){let n=e.node(-1),i=h.get(n),r=e.start(-1),s=i.rectBetween(e.pos-r,t.pos-r),a=e.node(0),l=i.cellsInRect(s).filter(e=>e!=t.pos-r);l.unshift(t.pos-r);let d=l.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let i=r+e+1;return new o.xm(a.resolve(i),a.resolve(i+t.content.size))});super(d[0].$from,d[0].$to,d),this.$anchorCell=e,this.$headCell=t}map(t,n){let i=t.resolve(n.map(this.$anchorCell.pos)),r=t.resolve(n.map(this.$headCell.pos));if(v(i)&&v(r)&&b(i,r)){let t=this.$anchorCell.node(-1)!=i.node(-1);return t&&this.isRowSelection()?e.rowSelection(i,r):t&&this.isColSelection()?e.colSelection(i,r):new e(i,r)}return o.Bs.between(i,r)}content(){let e=this.$anchorCell.node(-1),t=h.get(e),n=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),r={},s=[];for(let n=i.top;n<i.bottom;n++){let o=[];for(let s=n*t.width+i.left,a=i.left;a<i.right;a++,s++){let n=t.map[s];if(r[n])continue;r[n]=!0;let a=t.findCell(n),l=e.nodeAt(n);if(!l)throw RangeError(`No cell with offset ${n} found`);let d=i.left-a.left,c=a.right-i.right;if(d>0||c>0){let e=l.attrs;if(d>0&&(e=x(e,0,d)),c>0&&(e=x(e,e.colspan-c,c)),a.left<i.left){if(!(l=l.type.createAndFill(e)))throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else l=l.type.create(e,l.content)}if(a.top<i.top||a.bottom>i.bottom){let e={...l.attrs,rowspan:Math.min(a.bottom,i.bottom)-Math.max(a.top,i.top)};l=a.top<i.top?l.type.createAndFill(e):l.type.create(e,l.content)}o.push(l)}s.push(e.child(n).copy(a.HY.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:s;return new a.p2(a.HY.from(o),1,1)}replace(e,t=a.p2.empty){let n=e.steps.length,i=this.ranges;for(let r=0;r<i.length;r++){let{$from:s,$to:o}=i[r],l=e.mapping.slice(n);e.replace(l.map(s.pos),l.map(o.pos),r?a.p2.empty:t)}let r=o.Y1.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new a.p2(a.HY.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=h.get(t),i=this.$anchorCell.start(-1),r=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let n=0;n<r.length;n++)e(t.nodeAt(r[n]),i+r[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan;return Math.max(n,t+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let i=t.node(-1),r=h.get(i),s=t.start(-1),o=r.findCell(t.pos-s),a=r.findCell(n.pos-s),l=t.node(0);return o.top<=a.top?(o.top>0&&(t=l.resolve(s+r.map[o.left])),a.bottom<r.height&&(n=l.resolve(s+r.map[r.width*(r.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(s+r.map[a.left])),o.bottom<r.height&&(t=l.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=h.get(e),n=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-n),r=t.colCount(this.$headCell.pos-n);if(Math.min(i,r)>0)return!1;let s=i+this.$anchorCell.nodeAfter.attrs.colspan;return Math.max(s,r+this.$headCell.nodeAfter.attrs.colspan)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let i=t.node(-1),r=h.get(i),s=t.start(-1),o=r.findCell(t.pos-s),a=r.findCell(n.pos-s),l=t.node(0);return o.left<=a.left?(o.left>0&&(t=l.resolve(s+r.map[o.top*r.width])),a.right<r.width&&(n=l.resolve(s+r.map[r.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(s+r.map[a.top*r.width])),o.right<r.width&&(t=l.resolve(s+r.map[r.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,i=n){return new e(t.resolve(n),t.resolve(i))}getBookmark(){return new S(this.$anchorCell.pos,this.$headCell.pos)}};_.prototype.visible=!1,o.Y1.jsonID("cell",_);var S=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&b(t,n)?new _(t,n):o.Y1.near(n,1)}};function E(e){if(!(e.selection instanceof _))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(l.p.node(n,n+e.nodeSize,{class:"selectedCell"}))}),l.EH.create(e.doc,t)}var C=new o.H$("fix-tables");function A(e,t){let n;let i=(t,i)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,i){let r,s;let o=h.get(t);if(!o.problems)return i;!i&&(i=e.tr);let a=[];for(let e=0;e<o.height;e++)a.push(0);for(let e=0;e<o.problems.length;e++){let r=o.problems[e];if("collision"==r.type){let e=t.nodeAt(r.pos);if(!e)continue;let s=e.attrs;for(let e=0;e<s.rowspan;e++)a[r.row+e]+=r.n;i.setNodeMarkup(i.mapping.map(n+1+r.pos),null,x(s,s.colspan-r.n,r.n))}else if("missing"==r.type)a[r.row]+=r.n;else if("overlong_rowspan"==r.type){let e=t.nodeAt(r.pos);if(!e)continue;i.setNodeMarkup(i.mapping.map(n+1+r.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-r.n})}else if("colwidth mismatch"==r.type){let e=t.nodeAt(r.pos);if(!e)continue;i.setNodeMarkup(i.mapping.map(n+1+r.pos),null,{...e.attrs,colwidth:r.colwidth})}else if("zero_sized"==r.type){let e=i.mapping.map(n);i.delete(e,e+t.nodeSize)}}for(let e=0;e<a.length;e++)a[e]&&(null==r&&(r=e),s=e);for(let l=0,d=n+1;l<o.height;l++){let n=t.child(l),o=d+n.nodeSize,c=a[l];if(c>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<c;n++){let n=u(e.schema)[t].createAndFill();n&&a.push(n)}let h=(0==l||r==l-1)&&s==l?d+1:o-1;i.insert(i.mapping.map(h),a)}d=o}return i.setMeta(C,{fixTables:!0})}(e,t,i,n))};return t?t.doc!=e.doc&&!function e(t,n,i,r){let s=t.childCount,o=n.childCount;e:for(let a=0,l=0;a<o;a++){let o=n.child(a);for(let e=l,n=Math.min(s,a+3);e<n;e++)if(t.child(e)==o){l=e+1,i+=o.nodeSize;continue e}r(o,i),l<s&&t.child(l).sameMarkup(o)?e(t.child(l),o,i+1,r):o.nodesBetween(0,o.content.size,r,i+1),i+=o.nodeSize}}(t.doc,e.doc,0,i):e.doc.descendants(i),n}function k(e){let t=e.selection,n=g(e),i=n.node(-1),r=n.start(-1),s=h.get(i);return{...t instanceof _?s.rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r):s.findCell(n.pos-r),tableStart:r,map:s,table:i}}function T(e,{map:t,tableStart:n,table:i},r){let s=r>0?-1:0;(function(e,t,n){let i=u(t.type.schema).header_cell;for(let r=0;r<e.height;r++)if(t.nodeAt(e.map[n+r*e.width]).type!=i)return!1;return!0})(t,i,r+s)&&(s=0==r||r==t.width?null:0);for(let o=0;o<t.height;o++){let a=o*t.width+r;if(r>0&&r<t.width&&t.map[a-1]==t.map[a]){let s=t.map[a],l=i.nodeAt(s);e.setNodeMarkup(e.mapping.map(n+s),null,w(l.attrs,r-t.colCount(s))),o+=l.attrs.rowspan-1}else{let l=null==s?u(i.type.schema).cell:i.nodeAt(t.map[a+s]).type,d=t.positionAt(o,r,i);e.insert(e.mapping.map(n+d),l.createAndFill())}}return e}function M(e,{map:t,tableStart:n,table:i},r){var s;let o=n;for(let e=0;e<r;e++)o+=i.child(e).nodeSize;let a=[],l=r>0?-1:0;(function(e,t,n){var i;let r=u(t.type.schema).header_cell;for(let s=0;s<e.width;s++)if((null==(i=t.nodeAt(e.map[s+n*e.width]))?void 0:i.type)!=r)return!1;return!0})(t,i,r+l)&&(l=0==r||r==t.height?null:0);for(let o=0,d=t.width*r;o<t.width;o++,d++)if(r>0&&r<t.height&&t.map[d]==t.map[d-t.width]){let r=t.map[d],s=i.nodeAt(r).attrs;e.setNodeMarkup(n+r,null,{...s,rowspan:s.rowspan+1}),o+=s.colspan-1}else{let e=null==l?u(i.type.schema).cell:null==(s=i.nodeAt(t.map[d+l*t.width]))?void 0:s.type,n=null==e?void 0:e.createAndFill();n&&a.push(n)}return e.insert(o,u(i.type.schema).row.create(null,a)),e}function D(e){let t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function O(e,t){let n=e.selection;if(!(n instanceof _)||n.$anchorCell.pos==n.$headCell.pos)return!1;let i=k(e),{map:r}=i;if(function({width:e,height:t,map:n},i){let r=i.top*e+i.left,s=r,o=(i.bottom-1)*e+i.left,a=r+(i.right-i.left-1);for(let t=i.top;t<i.bottom;t++){if(i.left>0&&n[s]==n[s-1]||i.right<e&&n[a]==n[a+1])return!0;s+=e,a+=e}for(let s=i.left;s<i.right;s++){if(i.top>0&&n[r]==n[r-e]||i.bottom<t&&n[o]==n[o+e])return!0;r++,o++}return!1}(r,i))return!1;if(t){let n,s;let o=e.tr,l={},d=a.HY.empty;for(let e=i.top;e<i.bottom;e++)for(let t=i.left;t<i.right;t++){let a=r.map[e*r.width+t],c=i.table.nodeAt(a);if(!l[a]&&c){if(l[a]=!0,null==n)n=a,s=c;else{!D(c)&&(d=d.append(c.content));let e=o.mapping.map(a+i.tableStart);o.delete(e,e+c.nodeSize)}}}if(null==n||null==s)return!0;if(o.setNodeMarkup(n+i.tableStart,null,{...w(s.attrs,s.attrs.colspan,i.right-i.left-s.attrs.colspan),rowspan:i.bottom-i.top}),d.size){let e=n+1+s.content.size,t=D(s)?n+1:e;o.replaceWith(t+i.tableStart,e+i.tableStart,d)}o.setSelection(new _(o.doc.resolve(n+i.tableStart))),t(o)}return!0}function I(e,t){let n=u(e.schema);return(function(e){return(t,n)=>{var i;let r,s;let o=t.selection;if(o instanceof _){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;r=o.$anchorCell.nodeAfter,s=o.$anchorCell.pos}else{if(!(r=function(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(o.$from)))return!1;s=null==(i=f(o.$from))?void 0:i.pos}if(null==r||null==s||1==r.attrs.colspan&&1==r.attrs.rowspan)return!1;if(n){let i,a=r.attrs,l=[],d=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});let c=k(t),h=t.tr;for(let e=0;e<c.right-c.left;e++)l.push(d?{...a,colwidth:d&&d[e]?[d[e]]:null}:a);for(let t=c.top;t<c.bottom;t++){let n=c.map.positionAt(t,c.left,c.table);t==c.top&&(n+=r.nodeSize);for(let s=c.left,o=0;s<c.right;s++,o++)(s!=c.left||t!=c.top)&&h.insert(i=h.mapping.map(n+c.tableStart,1),e({node:r,row:t,col:s}).createAndFill(l[o]))}h.setNodeMarkup(s,e({node:r,row:c.top,col:c.left}),l[0]),o instanceof _&&h.setSelection(new _(h.doc.resolve(o.$anchorCell.pos),i?h.doc.resolve(i):void 0)),n(h)}return!0}})(({node:e})=>n[e.type.spec.tableRole])(e,t)}function N(e,t,n){let i=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<i.length;e++){let r=t.table.nodeAt(i[e]);if(r&&r.type!==n.header_cell)return!1}return!0}function R(e,t){if((t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic){var n;return n=e,function(e,t){if(!m(e))return!1;if(t){let i=u(e.schema),r=k(e),s=e.tr,o=r.map.cellsInRect("column"==n?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==n?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),a=o.map(e=>r.table.nodeAt(e));for(let e=0;e<o.length;e++)a[e].type==i.header_cell&&s.setNodeMarkup(r.tableStart+o[e],i.cell,a[e].attrs);if(0==s.steps.length)for(let e=0;e<o.length;e++)s.setNodeMarkup(r.tableStart+o[e],i.header_cell,a[e].attrs);t(s)}return!0}}return function(t,n){if(!m(t))return!1;if(n){let i=u(t.schema),r=k(t),s=t.tr,o=N("row",r,i),a=N("column",r,i),l=("column"===e?o:"row"===e&&a)?1:0,d="column"==e?{left:0,top:l,right:1,bottom:r.map.height}:"row"==e?{left:l,top:0,right:r.map.width,bottom:1}:r,c="column"==e?a?i.cell:i.header_cell:"row"==e?o?i.cell:i.header_cell:i.cell;r.map.cellsInRect(d).forEach(e=>{let t=e+r.tableStart,n=s.doc.nodeAt(t);n&&s.setNodeMarkup(t,c,n.attrs)}),n(s)}return!0}}R("row",{useDeprecatedLogic:!0}),R("column",{useDeprecatedLogic:!0});var L=R("cell",{useDeprecatedLogic:!0});function P(e){return function(t,n){if(!m(t))return!1;let i=function(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let i=e.node(-1).child(t),r=i.lastChild;if(r)return n-1-r.nodeSize;n-=i.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),i=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return i+1;i+=e.nodeSize}}return null}(g(t),e);if(null==i)return!1;if(n){var r;let e=t.doc.resolve(i);n(t.tr.setSelection(o.Bs.between(e,(r=e).node(0).resolve(r.pos+r.nodeAfter.nodeSize))).scrollIntoView())}return!0}}function j(e,t){let n=e.selection;if(!(n instanceof _))return!1;if(t){let i=e.tr,r=u(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{!e.content.eq(r)&&i.replace(i.mapping.map(t+1),i.mapping.map(t+e.nodeSize-1),new a.p2(r,0,0))}),i.docChanged&&t(i)}return!0}function F(e,t){let n=e.createAndFill();return new c.wx(n).replace(0,n.content.size,t).doc}function B(e,t,n,i,r,s,o,a){if(0==o||o==t.height)return!1;let l=!1;for(let d=r;d<s;d++){let r=o*t.width+d,s=t.map[r];if(t.map[r-t.width]==s){l=!0;let r=n.nodeAt(s),{top:c,left:h}=t.findCell(s);e.setNodeMarkup(e.mapping.slice(a).map(s+i),null,{...r.attrs,rowspan:o-c}),e.insert(e.mapping.slice(a).map(t.positionAt(o,h,n)),r.type.createAndFill({...r.attrs,rowspan:c+r.attrs.rowspan-o})),d+=r.attrs.colspan-1}}return l}function z(e,t,n,i,r,s,o,a){if(0==o||o==t.width)return!1;let l=!1;for(let d=r;d<s;d++){let r=d*t.width+o,s=t.map[r];if(t.map[r-1]==s){l=!0;let r=n.nodeAt(s),c=t.colCount(s),h=e.mapping.slice(a).map(s+i);e.setNodeMarkup(h,null,x(r.attrs,o-c,r.attrs.colspan-(o-c))),e.insert(h+r.nodeSize,r.type.createAndFill(x(r.attrs,0,o-c))),d+=r.attrs.rowspan-1}}return l}function H(e,t,n,i,r){let s=n?e.doc.nodeAt(n-1):e.doc;if(!s)throw Error("No table found");let o=h.get(s),{top:l,left:d}=i,c=d+r.width,p=l+r.height,f=e.tr,m=0;function g(){if(!(s=n?f.doc.nodeAt(n-1):f.doc))throw Error("No table found");o=h.get(s),m=f.mapping.maps.length}(function(e,t,n,i,r,s,o){let l,d;let c=u(e.doc.type.schema);if(r>t.width)for(let s=0,a=0;s<t.height;s++){let h;let u=n.child(s);a+=u.nodeSize;let p=[];h=null==u.lastChild||u.lastChild.type==c.cell?l||(l=c.cell.createAndFill()):d||(d=c.header_cell.createAndFill());for(let e=t.width;e<r;e++)p.push(h);e.insert(e.mapping.slice(o).map(a-1+i),p)}if(s>t.height){let h=[];for(let e=0,i=(t.height-1)*t.width;e<Math.max(t.width,r);e++){let r=!(e>=t.width)&&n.nodeAt(t.map[i+e]).type==c.header_cell;h.push(r?d||(d=c.header_cell.createAndFill()):l||(l=c.cell.createAndFill()))}let u=c.row.create(null,a.HY.from(h)),p=[];for(let e=t.height;e<s;e++)p.push(u);e.insert(e.mapping.slice(o).map(i+n.nodeSize-2),p)}return!!(l||d)})(f,o,s,n,c,p,0)&&g(),B(f,o,s,n,d,c,l,m)&&g(),B(f,o,s,n,d,c,p,m)&&g(),z(f,o,s,n,l,p,d,m)&&g(),z(f,o,s,n,l,p,c,m)&&g();for(let e=l;e<p;e++){let t=o.positionAt(e,d,s),i=o.positionAt(e,c,s);f.replace(f.mapping.slice(m).map(t+n),f.mapping.slice(m).map(i+n),new a.p2(r.rows[e-l],0,0))}g(),f.setSelection(new _(f.doc.resolve(n+o.positionAt(l,d,s)),f.doc.resolve(n+o.positionAt(p-1,c-1,s)))),t(f)}var U=(0,d.$)({ArrowLeft:$("horiz",-1),ArrowRight:$("horiz",1),ArrowUp:$("vert",-1),ArrowDown:$("vert",1),"Shift-ArrowLeft":W("horiz",-1),"Shift-ArrowRight":W("horiz",1),"Shift-ArrowUp":W("vert",-1),"Shift-ArrowDown":W("vert",1),Backspace:j,"Mod-Backspace":j,Delete:j,"Mod-Delete":j});function V(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function $(e,t){return(n,i,r)=>{if(!r)return!1;let s=n.selection;if(s instanceof _)return V(n,i,o.Y1.near(s.$headCell,t));if("horiz"!=e&&!s.empty)return!1;let a=K(r,e,t);if(null==a)return!1;if("horiz"==e)return V(n,i,o.Y1.near(n.doc.resolve(s.head+t),t));{let r;let s=n.doc.resolve(a),l=y(s,e,t);return r=l?o.Y1.near(l,1):t<0?o.Y1.near(n.doc.resolve(s.before(-1)),-1):o.Y1.near(n.doc.resolve(s.after(-1)),1),V(n,i,r)}}}function W(e,t){return(n,i,r)=>{let s;if(!r)return!1;let o=n.selection;if(o instanceof _)s=o;else{let i=K(r,e,t);if(null==i)return!1;s=new _(n.doc.resolve(i))}let a=y(s.$headCell,e,t);return!!a&&V(n,i,new _(s.$anchorCell,a))}}function G(e,t){let n=f(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new _(n))),!0)}function Z(e,t,n){if(!m(e.state))return!1;let i=function(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:i}=e;for(;1==t.childCount&&(n>0&&i>0||"table"==t.child(0).type.spec.tableRole);)n--,i--,t=t.child(0).content;let r=t.child(0),s=r.type.spec.tableRole,o=r.type.schema,l=[];if("row"==s)for(let e=0;e<t.childCount;e++){let r=t.child(e).content,s=e?0:Math.max(0,n-1),d=e<t.childCount-1?0:Math.max(0,i-1);(s||d)&&(r=F(u(o).row,new a.p2(r,s,d)).content),l.push(r)}else{if("cell"!=s&&"header_cell"!=s)return null;l.push(n||i?F(u(o).row,new a.p2(t,n,i)).content:t)}return function(e,t){let n=[];for(let e=0;e<t.length;e++){let i=t[e];for(let t=i.childCount-1;t>=0;t--){let{rowspan:r,colspan:s}=i.child(t).attrs;for(let t=e;t<e+r;t++)n[t]=(n[t]||0)+s}}let i=0;for(let e=0;e<n.length;e++)i=Math.max(i,n[e]);for(let r=0;r<n.length;r++)if(r>=t.length&&t.push(a.HY.empty),n[r]<i){let s=u(e).cell.createAndFill(),o=[];for(let e=n[r];e<i;e++)o.push(s);t[r]=t[r].append(a.HY.from(o))}return{height:t.length,width:i,rows:t}}(o,l)}(n),r=e.state.selection;if(r instanceof _){!i&&(i={width:1,height:1,rows:[a.HY.from(F(u(e.state.schema).cell,n))]});let t=r.$anchorCell.node(-1),s=r.$anchorCell.start(-1),o=h.get(t).rectBetween(r.$anchorCell.pos-s,r.$headCell.pos-s);return i=function({width:e,height:t,rows:n},i,r){if(e!=i){let t=[],r=[];for(let e=0;e<n.length;e++){let s=n[e],o=[];for(let n=t[e]||0,r=0;n<i;r++){let a=s.child(r%s.childCount);n+a.attrs.colspan>i&&(a=a.type.createChecked(x(a.attrs,a.attrs.colspan,n+a.attrs.colspan-i),a.content)),o.push(a),n+=a.attrs.colspan;for(let n=1;n<a.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+a.attrs.colspan}r.push(a.HY.from(o))}n=r,e=i}if(t!=r){let e=[];for(let i=0,s=0;i<r;i++,s++){let o=[],l=n[s%t];for(let e=0;e<l.childCount;e++){let t=l.child(e);i+t.attrs.rowspan>r&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,r-t.attrs.rowspan)},t.content)),o.push(t)}e.push(a.HY.from(o))}n=e,t=r}return{width:e,height:t,rows:n}}(i,o.right-o.left,o.bottom-o.top),H(e.state,e.dispatch,s,o,i),!0}if(!i)return!1;{let t=g(e.state),n=t.start(-1);return H(e.state,e.dispatch,n,h.get(t.node(-1)).findCell(t.pos-n),i),!0}}function q(e,t){var n;let i;if(t.ctrlKey||t.metaKey)return;let r=Y(e,t.target);if(t.shiftKey&&e.state.selection instanceof _)s(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(i=f(e.state.selection.$anchor))&&(null==(n=X(e,t))?void 0:n.pos)!=i.pos)s(i,t),t.preventDefault();else if(!r)return;function s(t,n){let i=X(e,n),r=null==p.getState(e.state);if(!i||!b(t,i)){if(!r)return;i=t}let s=new _(t,i);if(r||!e.state.selection.eq(s)){let n=e.state.tr.setSelection(s);r&&n.setMeta(p,t.pos),e.dispatch(n)}}function o(){e.root.removeEventListener("mouseup",o),e.root.removeEventListener("dragstart",o),e.root.removeEventListener("mousemove",a),null!=p.getState(e.state)&&e.dispatch(e.state.tr.setMeta(p,-1))}function a(n){let i;let a=p.getState(e.state);if(null!=a)i=e.state.doc.resolve(a);else if(Y(e,n.target)!=r&&!(i=X(e,t)))return o();i&&s(i,n)}e.root.addEventListener("mouseup",o),e.root.addEventListener("dragstart",o),e.root.addEventListener("mousemove",a)}function K(e,t,n){if(!(e.state.selection instanceof o.Bs))return null;let{$head:i}=e.state.selection;for(let r=i.depth-1;r>=0;r--){let s=i.node(r);if((n<0?i.index(r):i.indexAfter(r))!=(n<0?0:s.childCount))break;if("cell"==s.type.spec.tableRole||"header_cell"==s.type.spec.tableRole){let s=i.before(r),o="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(o)?s:null}}return null}function Y(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function X(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});return n?n?f(e.state.doc.resolve(n.pos)):null:null}var J=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Q(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,Q(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Q(e,t,n,i,r,s){var o;let a=0,l=!0,d=t.firstChild,c=e.firstChild;if(c){for(let e=0,n=0;e<c.childCount;e++){let{colspan:o,colwidth:h}=c.child(e).attrs;for(let e=0;e<o;e++,n++){let o=r==n?s:h&&h[e],c=o?o+"px":"";if(a+=o||i,!o&&(l=!1),d)d.style.width!=c&&(d.style.width=c),d=d.nextSibling;else{let e=document.createElement("col");e.style.width=c,t.appendChild(e)}}}for(;d;){let e=d.nextSibling;null==(o=d.parentNode)||o.removeChild(d),d=e}l?(n.style.width=a+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=a+"px")}}var ee=new o.H$("tableColumnResizing"),et=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=t.getMeta(ee);if(n&&null!=n.setHandle)return new e(n.setHandle,!1);if(n&&void 0!==n.setDragging)return new e(this.activeHandle,n.setDragging);if(this.activeHandle>-1&&t.docChanged){let n=t.mapping.map(this.activeHandle,-1);return!v(t.doc.resolve(n))&&(n=-1),new e(n,this.dragging)}return this}};function en(e,t,n,i){let r=e.posAtCoords({left:t.clientX+("right"==n?-i:i),top:t.clientY});if(!r)return -1;let{pos:s}=r,o=f(e.state.doc.resolve(s));if(!o)return -1;if("right"==n)return o.pos;let a=h.get(o.node(-1)),l=o.start(-1),d=a.map.indexOf(o.pos-l);return d%a.width==0?-1:l+a.map[d-1]}function ei(e,t,n){let i=t.clientX-e.startX;return Math.max(n,e.startWidth+i)}function er(e,t){e.dispatch(e.state.tr.setMeta(ee,{setHandle:t}))}function es(e,t,n,i){let r=e.state.doc.resolve(t),s=r.node(-1),o=r.start(-1),a=h.get(s).colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=e.domAtPos(r.start(-1)).node;for(;l&&"TABLE"!=l.nodeName;)l=l.parentNode;l&&Q(s,l.firstChild,l,i,a,n)}function eo(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function ea(e,t,n,i,r,s){var o;let a=0,l=!0,d=t.firstChild,c=e.firstChild;if(null!==c)for(let e=0,n=0;e<c.childCount;e+=1){let{colspan:o,colwidth:h}=c.child(e).attrs;for(let e=0;e<o;e+=1,n+=1){let o=r===n?s:h&&h[e],c=o?`${o}px`:"";if(a+=o||i,!o&&(l=!1),d){if(d.style.width!==c){let[e,t]=eo(i,o);d.style.setProperty(e,t)}d=d.nextSibling}else{let e=document.createElement("col"),[n,r]=eo(i,o);e.style.setProperty(n,r),t.appendChild(e)}}}for(;d;){let e=d.nextSibling;null===(o=d.parentNode)||void 0===o||o.removeChild(d),d=e}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class el{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ea(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type===this.node.type&&(this.node=e,ea(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||this.colgroup.contains(e.target))}}function ed(e,t){return t?e.createChecked(null,t):e.createAndFill()}let ec=({editor:e})=>{let{selection:t}=e.state;if(!(t instanceof _))return!1;let n=0,i=(0,s.qv)(t.ranges[0].$from,e=>"table"===e.type.name);return null==i||i.node.descendants(e=>{if("table"===e.type.name)return!1;["tableCell","tableHeader"].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)},eh=s.NB.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:el,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:i,tableMinWidth:r}=function(e,t,n,i){let r=0,s=!0,o=[],a=e.firstChild;if(!a)return{};for(let e=0,n=0;e<a.childCount;e+=1){let{colspan:i,colwidth:l}=a.child(e).attrs;for(let e=0;e<i;e+=1,n+=1){let i=void 0===n?void 0:l&&l[e];r+=i||t,!i&&(s=!1);let[a,d]=eo(t,i);o.push(["col",{style:`${a}: ${d}`}])}}let l=s?`${r}px`:"";return{colgroup:["colgroup",{},...o],tableWidth:l,tableMinWidth:s?"":`${r}px`}}(e,this.options.cellMinWidth);return["table",(0,s.P1)(this.options.HTMLAttributes,t,{style:i?`width: ${i}`:`min-width: ${r}`}),n,["tbody",0]]},addCommands:()=>({insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:i,dispatch:r,editor:s})=>{let a=function(e,t,n,i,r){let s=function(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let i=e.nodes[n];i.spec.tableRole&&(t[i.spec.tableRole]=i)}),e.cached.tableNodeTypes=t,t}(e),o=[],a=[];for(let e=0;e<n;e+=1){let e=ed(s.cell,void 0);if(e&&a.push(e),i){let e=ed(s.header_cell,r);e&&o.push(e)}}let l=[];for(let e=0;e<t;e+=1)l.push(s.row.createChecked(null,i&&0===e?o:a));return s.table.createChecked(null,l)}(s.schema,e,t,n);if(r){let e=i.selection.from+1;i.replaceSelectionWith(a).scrollIntoView().setSelection(o.Bs.near(i.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e);t(T(e.tr,n,n.left))}return!0})(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e);t(T(e.tr,n,n.right))}return!0})(e,t),deleteColumn:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e),i=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;!function(e,{map:t,table:n,tableStart:i},r){let s=e.mapping.maps.length;for(let o=0;o<t.height;){let a=o*t.width+r,l=t.map[a],d=n.nodeAt(l),c=d.attrs;if(r>0&&t.map[a-1]==l||r<t.width-1&&t.map[a+1]==l)e.setNodeMarkup(e.mapping.slice(s).map(i+l),null,x(c,r-t.colCount(l)));else{let t=e.mapping.slice(s).map(i+l);e.delete(t,t+d.nodeSize)}o+=c.rowspan}}(i,n,e),e!=n.left;e--){;let e=n.tableStart?i.doc.nodeAt(n.tableStart-1):i.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=h.get(e)}t(i)}return!0})(e,t),addRowBefore:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e);t(M(e.tr,n,n.top))}return!0})(e,t),addRowAfter:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e);t(M(e.tr,n,n.bottom))}return!0})(e,t),deleteRow:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e),i=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;!function(e,{map:t,table:n,tableStart:i},r){let s=0;for(let e=0;e<r;e++)s+=n.child(e).nodeSize;let o=s+n.child(r).nodeSize,a=e.mapping.maps.length;e.delete(s+i,o+i);let l=new Set;for(let s=0,o=r*t.width;s<t.width;s++,o++){let d=t.map[o];if(!l.has(d)){if(l.add(d),r>0&&d==t.map[o-t.width]){let t=n.nodeAt(d).attrs;e.setNodeMarkup(e.mapping.slice(a).map(d+i),null,{...t,rowspan:t.rowspan-1}),s+=t.colspan-1}else if(r<t.height&&d==t.map[o+t.width]){let o=n.nodeAt(d),l=o.attrs,c=o.type.create({...l,rowspan:o.attrs.rowspan-1},o.content),h=t.positionAt(r+1,s,n);e.insert(e.mapping.slice(a).map(i+h),c),s+=l.colspan-1}}}}(i,n,e),e!=n.top;e--){;let e=n.tableStart?i.doc.nodeAt(n.tableStart-1):i.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=h.get(n.table)}t(i)}return!0})(e,t),deleteTable:()=>({state:e,dispatch:t})=>(function(e,t){let n=e.selection.$anchor;for(let i=n.depth;i>0;i--)if("table"==n.node(i).type.spec.tableRole)return t&&t(e.tr.delete(n.before(i),n.after(i)).scrollIntoView()),!0;return!1})(e,t),mergeCells:()=>({state:e,dispatch:t})=>O(e,t),splitCell:()=>({state:e,dispatch:t})=>I(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>R("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>R("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>L(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>!!O(e,t)||I(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:i})=>{var r,s;return(r=e,s=t,function(e,t){if(!m(e))return!1;let n=g(e);if(n.nodeAfter.attrs[r]===s)return!1;if(t){let i=e.tr;e.selection instanceof _?e.selection.forEachCell((e,t)=>{e.attrs[r]!==s&&i.setNodeMarkup(t,null,{...e.attrs,[r]:s})}):i.setNodeMarkup(n.pos,null,{...n.nodeAfter.attrs,[r]:s}),t(i)}return!0})(n,i)},goToNextCell:()=>({state:e,dispatch:t})=>P(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>P(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&A(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=_.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ec,"Mod-Backspace":ec,Delete:ec,"Mod-Delete":ec}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[function({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:i=J,lastColumnResizable:r=!0}={}){let s=new o.Sy({key:ee,state:{init(e,t){var r,o;let a=null==(o=null==(r=s.spec)?void 0:r.props)?void 0:o.nodeViews,l=u(t.schema).table.name;return i&&a&&(a[l]=(e,t)=>new i(e,n,t)),new et(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{let t=ee.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{(function(e,t,n,i){if(!e.editable)return;let r=ee.getState(e.state);if(r&&!r.dragging){let s=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target),o=-1;if(s){let{left:i,right:r}=s.getBoundingClientRect();t.clientX-i<=n?o=en(e,t,"left",n):r-t.clientX<=n&&(o=en(e,t,"right",n))}if(o!=r.activeHandle){if(!i&&-1!==o){let t=e.state.doc.resolve(o),n=t.node(-1),i=h.get(n),r=t.start(-1);if(i.colCount(t.pos-r)+t.nodeAfter.attrs.colspan-1==i.width-1)return}er(e,o)}}})(t,n,e,r)},mouseleave:e=>{(function(e){if(!e.editable)return;let t=ee.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&er(e,-1)})(e)},mousedown:(e,i)=>{(function(e,t,n,i){var r;if(!e.editable)return;let s=null!=(r=e.dom.ownerDocument.defaultView)?r:window,o=ee.getState(e.state);if(!o||-1==o.activeHandle||o.dragging)return;let a=e.state.doc.nodeAt(o.activeHandle),l=function(e,t,{colspan:n,colwidth:i}){let r=i&&i[i.length-1];if(r)return r;let s=e.domAtPos(t),o=s.node.childNodes[s.offset].offsetWidth,a=n;if(i)for(let e=0;e<n;e++)i[e]&&(o-=i[e],a--);return o/a}(e,o.activeHandle,a.attrs);function d(t){s.removeEventListener("mouseup",d),s.removeEventListener("mousemove",c);let i=ee.getState(e.state);(null==i?void 0:i.dragging)&&(function(e,t,n){let i=e.state.doc.resolve(t),r=i.node(-1),s=h.get(r),o=i.start(-1),a=s.colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,l=e.state.tr;for(let e=0;e<s.height;e++){let t=e*s.width+a;if(e&&s.map[t]==s.map[t-s.width])continue;let i=s.map[t],d=r.nodeAt(i).attrs,c=1==d.colspan?0:a-s.colCount(i);if(d.colwidth&&d.colwidth[c]==n)continue;let h=d.colwidth?d.colwidth.slice():function(e){return Array(e).fill(0)}(d.colspan);h[c]=n,l.setNodeMarkup(o+i,null,{...d,colwidth:h})}l.docChanged&&e.dispatch(l)}(e,i.activeHandle,ei(i.dragging,t,n)),e.dispatch(e.state.tr.setMeta(ee,{setDragging:null})))}function c(t){if(!t.which)return d(t);let r=ee.getState(e.state);if(r&&r.dragging){let s=ei(r.dragging,t,n);es(e,r.activeHandle,s,i)}}e.dispatch(e.state.tr.setMeta(ee,{setDragging:{startX:t.clientX,startWidth:l}})),es(e,o.activeHandle,l,i),s.addEventListener("mouseup",d),s.addEventListener("mousemove",c),t.preventDefault()})(e,i,t,n)}},decorations:e=>{let t=ee.getState(e);if(t&&t.activeHandle>-1)return function(e,t){var n;let i=[],r=e.doc.resolve(t),s=r.node(-1);if(!s)return l.EH.empty;let o=h.get(s),a=r.start(-1),d=o.colCount(r.pos-a)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<o.height;t++){let r=d+t*o.width;if((d==o.width-1||o.map[r]!=o.map[r+1])&&(0==t||o.map[r]!=o.map[r-o.width])){let t=o.map[r],d=a+t+s.nodeAt(t).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=ee.getState(e))?void 0:n.dragging)&&i.push(l.p.node(a+t,a+t+s.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),i.push(l.p.widget(d,c))}}return l.EH.create(e.doc,i)}(e,t.activeHandle)},nodeViews:{}}});return s}({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],function({allowTableNodeSelection:e=!1}={}){return new o.Sy({key:p,state:{init:()=>null,apply(e,t){let n=e.getMeta(p);if(null!=n)return -1==n?null:n;if(null==t||!e.docChanged)return t;let{deleted:i,pos:r}=e.mapping.mapResult(t);return i?null:r}},props:{decorations:E,handleDOMEvents:{mousedown:q},createSelectionBetween:e=>null!=p.getState(e.state)?e.state.selection:null,handleTripleClick:G,handleKeyDown:U,handlePaste:Z},appendTransaction:(t,n,i)=>(function(e,t,n){let i,r;let s=(t||e).selection,a=(t||e).doc;if(s instanceof o.qv&&(r=s.node.type.spec.tableRole)){if("cell"==r||"header_cell"==r)i=_.create(a,s.from);else if("row"==r){let e=a.resolve(s.from+1);i=_.rowSelection(e,e)}else if(!n){let e=h.get(s.node),t=s.from+1,n=t+e.map[e.width*e.height-1];i=_.create(a,t+1,n)}}else s instanceof o.Bs&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,i=t.pos,r=e.depth;for(;r>=0&&!(e.after(r+1)<e.end(r));r--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,i--);return n==i&&/row|table/.test(e.node(r).type.spec.tableRole)}(s)?i=o.Bs.create(a,s.from):s instanceof o.Bs&&function({$from:e,$to:t}){let n,i;for(let t=e.depth;t>0;t--){let i=e.node(t);if("cell"===i.type.spec.tableRole||"header_cell"===i.type.spec.tableRole){n=i;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){i=n;break}}return n!==i&&0===t.parentOffset}(s)&&(i=o.Bs.create(a,s.$from.start(),s.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t})(i,A(i,n),e)})}({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:(0,s.nU)((0,s.Nl)(e,"tableRole",t))}}})},707291:function(e,t,n){"use strict";n.d(t,{jE:function(){return A},kg:function(){return g}});var i,r,s,o=n(455069),a=n(921463),l=n(453203),d={exports:{}},c={};d.exports=function(){if(r)return c;r=1;var e="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},t=o.useState,n=o.useEffect,i=o.useLayoutEffect,s=o.useDebugValue;function a(t){var n=t.getSnapshot;t=t.value;try{var i=n();return!e(t,i)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,r){var o=r(),l=t({inst:{value:o,getSnapshot:r}}),d=l[0].inst,c=l[1];return i(function(){d.value=o,d.getSnapshot=r,a(d)&&c({inst:d})},[e,o,r]),n(function(){return a(d)&&c({inst:d}),e(function(){a(d)&&c({inst:d})})},[e]),s(o),o};return c.useSyncExternalStore=void 0!==o.useSyncExternalStore?o.useSyncExternalStore:l,c}();var h=d.exports;let u=(...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})},p=({contentComponent:e})=>{let t=h.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return o.createElement(o.Fragment,null,Object.values(t))};class f extends o.Component{constructor(e){var t;super(e),this.editorContentRef=o.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(null===(t=e.editor)||void 0===t?void 0:t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=function(){let e=new Set,t={};return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>t,getServerSnapshot:()=>t,setRenderer(n,i){t={...t,[n]:a.createPortal(i.reactElement,i.element,n)},e.forEach(e=>e())},removeRenderer(n){let i={...t};delete i[n],t=i,e.forEach(e=>e())}}}(),!this.state.hasContentComponentInitialized&&(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){let e=this.props.editor;if(!e)return;if(this.initialized=!1,!e.isDestroyed&&e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!e.options.element.firstChild)return;let t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){let{editor:e,innerRef:t,...n}=this.props;return o.createElement(o.Fragment,null,o.createElement("div",{ref:u(t,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&o.createElement(p,{contentComponent:e.contentComponent}))}}let m=(0,o.forwardRef)((e,t)=>{let n=o.useMemo(()=>Math.floor(0xffffffff*Math.random()).toString(),[e.editor]);return o.createElement(f,{key:n,innerRef:t,...e})}),g=o.memo(m);var v=(i=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;for(r of t.entries())if(!e(r[1],n.get(r[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(t[r]!==n[r])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((i=(s=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=i;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,s[r]))return!1;for(r=i;0!=r--;){var i,r,s,o=s[r];if("_owner"!==o||!t.$$typeof){if(!e(t[o],n[o]))return!1}}return!0}return t!=t&&n!=n},i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default"))?i.default:i,b={exports:{}},y={};b.exports=function(){if(s)return y;s=1;var e="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},t=h.useSyncExternalStore,n=o.useRef,i=o.useEffect,r=o.useMemo,a=o.useDebugValue;return y.useSyncExternalStoreWithSelector=function(s,o,l,d,c){var h=n(null);if(null===h.current){var u={hasValue:!1,value:null};h.current=u}else u=h.current;var p=t(s,(h=r(function(){function t(t){if(!r){if(r=!0,n=t,t=d(t),void 0!==c&&u.hasValue){var s=u.value;if(c(s,t))return i=s}return i=t}if(s=i,e(n,t))return s;var o=d(t);return void 0!==c&&c(s,o)?s:(n=t,i=o)}var n,i,r=!1,s=void 0===l?null:l;return[function(){return t(o())},null===s?void 0:function(){return t(s())}]},[o,l,d,c]))[0],h[1]);return i(function(){u.hasValue=!0,u.value=p},[p]),a(p),p},y}();var x=b.exports;let w="undefined"!=typeof window?o.useLayoutEffect:o.useEffect;class _{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}}let S="undefined"==typeof window,E=S||!!("undefined"!=typeof window&&window.next);class C{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return S||E?null:this.createEditor();this.options.current.immediatelyRender;return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){let e={...this.options.current,onBeforeCreate:(...e)=>{var t,n;return null===(n=(t=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(t,...e)},onBlur:(...e)=>{var t,n;return null===(n=(t=this.options.current).onBlur)||void 0===n?void 0:n.call(t,...e)},onCreate:(...e)=>{var t,n;return null===(n=(t=this.options.current).onCreate)||void 0===n?void 0:n.call(t,...e)},onDestroy:(...e)=>{var t,n;return null===(n=(t=this.options.current).onDestroy)||void 0===n?void 0:n.call(t,...e)},onFocus:(...e)=>{var t,n;return null===(n=(t=this.options.current).onFocus)||void 0===n?void 0:n.call(t,...e)},onSelectionUpdate:(...e)=>{var t,n;return null===(n=(t=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(t,...e)},onTransaction:(...e)=>{var t,n;return null===(n=(t=this.options.current).onTransaction)||void 0===n?void 0:n.call(t,...e)},onUpdate:(...e)=>{var t,n;return null===(n=(t=this.options.current).onUpdate)||void 0===n?void 0:n.call(t,...e)},onContentError:(...e)=>{var t,n;return null===(n=(t=this.options.current).onContentError)||void 0===n?void 0:n.call(t,...e)},onDrop:(...e)=>{var t,n;return null===(n=(t=this.options.current).onDrop)||void 0===n?void 0:n.call(t,...e)},onPaste:(...e)=>{var t,n;return null===(n=(t=this.options.current).onPaste)||void 0===n?void 0:n.call(t,...e)}};return new l.ML(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>{if(["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n))return!0;if("extensions"===n&&e.extensions&&t.extensions)return e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>{var i;return e===(null===(i=t.extensions)||void 0===i?void 0:i[n])&&!0});return e[n]===t[n]&&!0})}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===e.length?!C.compareOptions(this.options.current,this.editor.options)&&this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function A(e={},t=[]){let n=(0,o.useRef)(e);n.current=e;let[i]=(0,o.useState)(()=>new C(n)),r=h.useSyncExternalStore(i.subscribe,i.getEditor,i.getServerSnapshot);return(0,o.useDebugValue)(r),(0,o.useEffect)(i.onRender(t)),!function(e){var t;let[n]=(0,o.useState)(()=>new _(e.editor)),i=x.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!==(t=e.equalityFn)&&void 0!==t?t:v);w(()=>n.watch(e.editor),[e.editor,n]),(0,o.useDebugValue)(i)}({editor:r,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),r}(0,o.createContext)({editor:null}).Consumer;let k=(0,o.createContext)({onDragStart:void 0}),T=()=>(0,o.useContext)(k);o.forwardRef((e,t)=>{let{onDragStart:n}=T(),i=e.as||"div";return o.createElement(i,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})})},724830:function(e,t,n){"use strict";n.d(t,{Z:()=>ev});var i=n("453203");let r=/^\s*>\s$/,s=i.NB.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return["blockquote",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[(0,i.S0)({find:r,type:this.type})]}}),o=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,a=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,l=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,d=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,c=i.vc.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[(0,i.Cf)({find:o,type:this.type}),(0,i.Cf)({find:l,type:this.type})]},addPasteRules(){return[(0,i.K9)({find:a,type:this.type}),(0,i.K9)({find:d,type:this.type})]}}),h="textStyle",u=/^\s*([-+*])\s$/,p=i.NB.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(h)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=(0,i.S0)({find:u,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=(0,i.S0)({find:u,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(h),editor:this.editor})),[e]}}),f=/(^|[^`])`([^`]+)`(?!`)/,m=/(^|[^`])`([^`]+)`(?!`)/g,g=i.vc.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[(0,i.Cf)({find:f,type:this.type})]},addPasteRules(){return[(0,i.K9)({find:m,type:this.type})]}});var v=n("871738");let b=/^```([a-z]+)?[\s\n]$/,y=/^~~~([a-z]+)?[\s\n]$/,x=i.NB.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;let{languageClassPrefix:n}=this.options,i=[...(null===(t=e.firstElementChild)||void 0===t?void 0:t.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return i?i:null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:t}){return["pre",(0,i.P1)(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=1===t.pos;return!!e&&t.parent.type.name===this.name&&(!!n||!t.parent.textContent.length)&&this.editor.commands.clearNodes()},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:i,empty:r}=n;if(!r||i.parent.type!==this.type)return!1;let s=i.parentOffset===i.parent.nodeSize-2,o=i.parent.textContent.endsWith("\n\n");return!!s&&!!o&&e.chain().command(({tr:e})=>(e.delete(i.pos-2,i.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:i}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type||r.parentOffset!==r.parent.nodeSize-2)return!1;let o=r.after();return void 0!==o&&(i.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(v.Y1.near(i.resolve(o))),!0)):e.commands.exitCode())}}},addInputRules(){return[(0,i.zK)({find:b,type:this.type,getAttributes:e=>({language:e[1]})}),(0,i.zK)({find:y,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new v.Sy({key:new v.H$("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData("text/plain"),i=t.clipboardData.getData("vscode-editor-data"),r=i?JSON.parse(i):void 0,s=null==r?void 0:r.mode;if(!n||!s)return!1;let{tr:o,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,"\n"));return o.replaceSelectionWith(this.type.create({language:s},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(v.Bs.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),e.dispatch(o),!0}}})]}}),w=i.NB.create({name:"doc",topNode:!0,content:"block+"});var _=n("240554");class S{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t,n=this.editorView.state.doc.resolve(this.cursorPos),i=!n.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),a=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(i){let e=n.nodeBefore,t=n.nodeAfter;if(e||t){let n=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(n){let i=n.getBoundingClientRect(),s=e?i.bottom:i.top;e&&t&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let o=this.width/2*l;r={left:i.left,right:i.right,top:s-o,bottom:s+o}}}}if(!r){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;r={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let d=this.editorView.dom.offsetParent;if(!this.element&&(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",i),this.element.classList.toggle("prosemirror-dropcursor-inline",!i),d&&(d!=document.body||"static"!=getComputedStyle(d).position)){let n=d.getBoundingClientRect(),i=n.width/d.offsetWidth,r=n.height/d.offsetHeight;e=n.left-d.scrollLeft*i,t=n.top-d.scrollTop*r}else e=-pageXOffset,t=-pageYOffset;this.element.style.left=(r.left-e)/a+"px",this.element.style.top=(r.top-t)/l+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,r="function"==typeof i?i(this.editorView,t,e):i;if(t&&!r){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=(0,_.nj)(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){!this.editorView.dom.contains(e.relatedTarget)&&this.setCursor(null)}}let E=i.hj.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[function(e={}){return new v.Sy({view:t=>new S(t,e)})}(this.options)]}});var C=n("132308"),A=n("153737"),k=n("661763");class T extends v.Y1{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return T.valid(n)?new T(n):v.Y1.near(n)}content(){return A.p2.empty}eq(e){return e instanceof T&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for GapCursor.fromJSON");return new T(e.resolve(t.pos))}getBookmark(){return new M(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),i=e.node(t);if(0==n){if(i.type.spec.isolating)return!0;continue}for(let e=i.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),i=e.node(t);if(n==i.childCount){if(i.type.spec.isolating)return!0;continue}for(let e=i.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){t:for(;;){if(!n&&T.valid(e))return e;let i=e.pos,r=null;for(let n=e.depth;;n--){let s=e.node(n);if(t>0?e.indexAfter(n)<s.childCount:e.index(n)>0){r=s.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;i+=t;let o=e.doc.resolve(i);if(T.valid(o))return o}for(;;){let s=t>0?r.firstChild:r.lastChild;if(!s){if(r.isAtom&&!r.isText&&!v.qv.isSelectable(r)){e=e.doc.resolve(i+r.nodeSize*t),n=!1;continue t}break}r=s,i+=t;let o=e.doc.resolve(i);if(T.valid(o))return o}return null}}}T.prototype.visible=!1,T.findFrom=T.findGapCursorFrom,v.Y1.jsonID("gapcursor",T);class M{constructor(e){this.pos=e}map(e){return new M(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return T.valid(t)?new T(t):v.Y1.near(t)}}let D=(0,C.$)({ArrowLeft:O("horiz",-1),ArrowRight:O("horiz",1),ArrowUp:O("vert",-1),ArrowDown:O("vert",1)});function O(e,t){let n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,i,r){let s=e.selection,o=t>0?s.$to:s.$from,a=s.empty;if(s instanceof v.Bs){if(!r.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=e.doc.resolve(t>0?o.after():o.before())}let l=T.findGapCursorFrom(o,t,a);return!!l&&(i&&i(e.tr.setSelection(new T(l))),!0)}}function I(e,t,n){if(!e||!e.editable)return!1;let i=e.state.doc.resolve(t);if(!T.valid(i))return!1;let r=e.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&v.qv.isSelectable(e.state.doc.nodeAt(r.inside)))&&(e.dispatch(e.state.tr.setSelection(new T(i))),!0)}function N(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof T))return!1;let{$from:n}=e.state.selection,i=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!i)return!1;let r=A.HY.empty;for(let e=i.length-1;e>=0;e--)r=A.HY.from(i[e].createAndFill(null,r));let s=e.state.tr.replace(n.pos,n.pos,new A.p2(r,0,0));return s.setSelection(v.Bs.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function R(e){if(!(e.selection instanceof T))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",k.EH.create(e.doc,[k.p.widget(e.selection.head,t,{key:"gapcursor"})])}let L=i.hj.create({name:"gapCursor",addProseMirrorPlugins:()=>[new v.Sy({props:{decorations:R,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&T.valid(n)?new T(n):null,handleClick:I,handleKeyDown:D,handleDOMEvents:{beforeinput:N}}})],extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:null!==(t=(0,i.nU)((0,i.Nl)(e,"allowGapCursor",n)))&&void 0!==t?t:null}}}),P=i.NB.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",(0,i.P1)(this.options.HTMLAttributes,e)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:i})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:r}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:o}=i.extensionManager,a=r||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&a&&s){let t=a.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),j=i.NB.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){let n=this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0];return[`h${n}`,(0,i.P1)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.setNode(this.name,e),toggleHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>(0,i.zK)({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var F=function(){};F.prototype.append=function(e){return e.length?(e=F.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},F.prototype.prepend=function(e){return e.length?F.from(e).append(this):this},F.prototype.appendInner=function(e){return new z(this,e)},F.prototype.slice=function(e,t){return(void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t)?F.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},F.prototype.get=function(e){if(!(e<0)&&!(e>=this.length))return this.getInner(e)},F.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},F.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var i=[];return this.forEach(function(t,n){return i.push(e(t,n))},t,n),i},F.from=function(e){return e instanceof F?e:e&&e.length?new B(e):F.empty};var B=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,i){for(var r=t;r<n;r++)if(!1===e(this.values[r],i+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,i){for(var r=t-1;r>=n;r--)if(!1===e(this.values[r],i+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(F);F.empty=new B([]);var z=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,i){var r=this.left.length;if(t<r&&!1===this.left.forEachInner(e,t,Math.min(n,r),i)||n>r&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,i+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,i){var r=this.left.length;if(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,i+r)||n<r&&!1===this.left.forEachInvertedInner(e,Math.min(t,r),n,i))return!1},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(F);class H{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){let n,i,r,s;if(0==this.eventCount)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}t&&(i=(n=this.remapping(o,this.items.length)).maps.length);let a=e.tr,l=[],d=[];return this.items.forEach((e,t)=>{if(!e.step){!n&&(i=(n=this.remapping(o,t+1)).maps.length),i--,d.push(e);return}if(n){d.push(new U(e.map));let t=e.step.map(n.slice(i)),r;t&&a.maybeStep(t).doc&&(r=a.mapping.maps[a.mapping.maps.length-1],l.push(new U(r,void 0,void 0,l.length+d.length))),i--,r&&n.appendMap(r,i)}else a.maybeStep(e.step);if(e.selection)return r=n?e.selection.map(n.slice(i)):e.selection,s=new H(this.items.slice(0,o).append(d.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:s,transform:a,selection:r}}addTransform(e,t,n,i){let r=[],s=this.eventCount,o=this.items,a=!i&&o.length?o.get(o.length-1):null;for(let n=0;n<e.steps.length;n++){let l=e.steps[n].invert(e.docs[n]),d=new U(e.mapping.maps[n],l,t),c;(c=a&&a.merge(d))&&(d=c,n?r.pop():o=o.slice(0,o.length-1)),r.push(d),t&&(s++,t=void 0),!i&&(a=d)}let l=s-n.depth;return l>$&&(o=function(e,t){let n;return e.forEach((e,i)=>{if(e.selection&&0==t--)return n=i,!1}),e.slice(n)}(o,l),s-=l),new H(o.append(r),s)}remapping(e,t){let n=new _.vs;return this.items.forEach((t,i)=>{let r=null!=t.mirrorOffset&&i-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)},e,t),n}addMaps(e){return 0==this.eventCount?this:new H(this.items.append(e.map(e=>new U(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),r=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(e=>{e.selection&&o--},i);let a=t;this.items.forEach(t=>{let i=r.getMirror(--a);if(null==i)return;s=Math.min(s,i);let l=r.maps[i];if(t.step){let s=e.steps[i].invert(e.docs[i]),d=t.selection&&t.selection.map(r.slice(a+1,i));d&&o++,n.push(new U(l,s,d))}else n.push(new U(l))},i);let l=[];for(let e=t;e<s;e++)l.push(new U(r.maps[e]));let d=new H(this.items.slice(0,i).append(l).append(n),o);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{!t.step&&e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],r=0;return this.items.forEach((s,o)=>{if(o>=e)i.push(s),s.selection&&r++;else if(s.step){let e=s.step.map(t.slice(n)),o=e&&e.getMap();if(n--,o&&t.appendMap(o,n),e){let a=s.selection&&s.selection.map(t.slice(n));a&&r++;let l=new U(o.invert(),e,a),d,c=i.length-1;(d=i.length&&i[c].merge(l))?i[c]=d:i.push(l)}}else s.map&&n--},this.items.length,0),new H(F.from(i.reverse()),r)}}H.empty=new H(F.empty,0);class U{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new U(t.getMap().invert(),t,this.selection)}}}class V{constructor(e,t,n,i,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=r}}let $=20;function W(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,i,r)=>t.push(i,r));return t}function G(e,t){if(!e)return null;let n=[];for(let i=0;i<e.length;i+=2){let r=t.map(e[i],1),s=t.map(e[i+1],-1);r<=s&&n.push(r,s)}return n}let Z=!1,q=null;function K(e){let t=e.plugins;if(q!=t){Z=!1,q=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Z=!0;break}}return Z}let Y=new v.H$("history"),X=new v.H$("closeHistory");function J(e,t){return(n,i)=>{let r=Y.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(i){let s=function(e,t,n){let i=K(t),r=Y.get(t).spec.config,s=(n?e.undone:e.done).popEvent(t,i);if(!s)return null;let o=s.selection.resolve(s.transform.doc),a=(n?e.done:e.undone).addTransform(s.transform,t.selection.getBookmark(),r,i),l=new V(n?a:s.remaining,n?s.remaining:a,null,0,-1);return s.transform.setSelection(o).setMeta(Y,{redo:n,historyState:l})}(r,n,e);s&&i(t?s.scrollIntoView():s)}return!0}}let Q=J(!1,!0),ee=J(!0,!0);J(!1,!1),J(!0,!1);let et=i.hj.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>Q(e,t),redo:()=>({state:e,dispatch:t})=>ee(e,t)}),addProseMirrorPlugins(){return[function(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new v.Sy({key:Y,state:{init:()=>new V(H.empty,H.empty,null,0,-1),apply:(t,n,i)=>(function(e,t,n,i){let r=n.getMeta(Y),s;if(r)return r.historyState;n.getMeta(X)&&(e=new V(e.done,e.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(o&&o.getMeta(Y))return o.getMeta(Y).redo?new V(e.done.addTransform(n,void 0,i,K(t)),e.undone,W(n.mapping.maps),e.prevTime,e.prevComposition):new V(e.done,e.undone.addTransform(n,void 0,i,K(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory")){if(s=n.getMeta("rebased"))return new V(e.done.rebased(n,s),e.undone.rebased(n,s),G(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new V(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),G(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}else{let r=n.getMeta("composition"),s=0==e.prevTime||!o&&e.prevComposition!=r&&(e.prevTime<(n.time||0)-i.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,i)=>{for(let r=0;r<t.length;r+=2)e<=t[r+1]&&i>=t[r]&&(n=!0)}),n}(n,e.prevRanges)),a=o?G(e.prevRanges,n.mapping):W(n.mapping.maps);return new V(e.done.addTransform(n,s?t.selection.getBookmark():void 0,i,K(t)),H.empty,a,n.time,null==r?e.prevComposition:r)}})(n,i,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i="historyUndo"==n?Q:"historyRedo"==n?ee:null;return!!i&&(t.preventDefault(),i(e.state,e.dispatch))}}}})}(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),en=i.NB.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",(0,i.P1)(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{let{selection:n}=t,{$from:r,$to:s}=n,o=e();return 0===r.parentOffset?o.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):(0,i.EG)(n)?o.insertContentAt(s.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:e,dispatch:t})=>{var n;if(t){let{$to:t}=e.selection,i=t.end();if(t.nodeAfter)t.nodeAfter.isTextblock?e.setSelection(v.Bs.create(e.doc,t.pos+1)):t.nodeAfter.isBlock?e.setSelection(v.qv.create(e.doc,t.pos)):e.setSelection(v.Bs.create(e.doc,t.pos));else{let r=null===(n=t.parent.type.contentMatch.defaultType)||void 0===n?void 0:n.create();r&&(e.insert(i,r),e.setSelection(v.Bs.create(e.doc,i+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,i.x2)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ei=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,er=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,es=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,eo=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ea=i.vc.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[(0,i.Cf)({find:ei,type:this.type}),(0,i.Cf)({find:es,type:this.type})]},addPasteRules(){return[(0,i.K9)({find:er,type:this.type}),(0,i.K9)({find:eo,type:this.type})]}}),el=i.NB.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",(0,i.P1)(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ed="textStyle",ec=/^(\d+)\.\s$/,eh=i.NB.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return 1===t?["ol",(0,i.P1)(this.options.HTMLAttributes,n),0]:["ol",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(ed)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=(0,i.S0)({find:ec,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=(0,i.S0)({find:ec,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(ed)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),eu=i.NB.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ep=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,ef=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,em=i.vc.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[(0,i.Cf)({find:ep,type:this.type})]},addPasteRules(){return[(0,i.K9)({find:ef,type:this.type})]}}),eg=i.NB.create({name:"text",group:"inline"}),ev=i.hj.create({name:"starterKit",addExtensions(){let e=[];return!1!==this.options.bold&&e.push(c.configure(this.options.bold)),!1!==this.options.blockquote&&e.push(s.configure(this.options.blockquote)),!1!==this.options.bulletList&&e.push(p.configure(this.options.bulletList)),!1!==this.options.code&&e.push(g.configure(this.options.code)),!1!==this.options.codeBlock&&e.push(x.configure(this.options.codeBlock)),!1!==this.options.document&&e.push(w.configure(this.options.document)),!1!==this.options.dropcursor&&e.push(E.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&e.push(L.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&e.push(P.configure(this.options.hardBreak)),!1!==this.options.heading&&e.push(j.configure(this.options.heading)),!1!==this.options.history&&e.push(et.configure(this.options.history)),!1!==this.options.horizontalRule&&e.push(en.configure(this.options.horizontalRule)),!1!==this.options.italic&&e.push(ea.configure(this.options.italic)),!1!==this.options.listItem&&e.push(el.configure(this.options.listItem)),!1!==this.options.orderedList&&e.push(eh.configure(this.options.orderedList)),!1!==this.options.paragraph&&e.push(eu.configure(this.options.paragraph)),!1!==this.options.strike&&e.push(em.configure(this.options.strike)),!1!==this.options.text&&e.push(eg.configure(this.options.text)),e}})},734083:function(e,t,n){"use strict";n.d(t,{J:function(){return s}});var i=Object.prototype.hasOwnProperty;function r(e,t,n){for(n of e.keys())if(s(n,t))return n}function s(e,t){var n,o,a;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&s(e[o],t[o]););return -1===o}if(n===Set){if(e.size!==t.size)return!1;for(o of e)if((a=o)&&"object"==typeof a&&!(a=r(t,a))||!t.has(a))return!1;return!0}if(n===Map){if(e.size!==t.size)return!1;for(o of e)if((a=o[0])&&"object"==typeof a&&!(a=r(t,a))||!s(o[1],t.get(a)))return!1;return!0}if(n===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(n===DataView){if((o=e.byteLength)===t.byteLength)for(;o--&&e.getInt8(o)===t.getInt8(o););return -1===o}if(ArrayBuffer.isView(e)){if((o=e.byteLength)===t.byteLength)for(;o--&&e[o]===t[o];);return -1===o}if(!n||"object"==typeof e){for(n in o=0,e)if(i.call(e,n)&&++o&&!i.call(t,n)||!(n in t)||!s(e[n],t[n]))return!1;return Object.keys(t).length===o}}return e!=e&&t!=t}},59160:function(e,t,n){"use strict";function i(e){var t=!1;return{promise:new Promise(function(n,i){e.then(function(e){return!t&&n(e)}).catch(function(e){return!t&&i(e)})}),cancel:function(){t=!0}}}n.d(t,{Z:function(){return i}})},213898:function(e,t,n){"use strict";n.d(t,{ZP:function(){return s}});var i=function(e,t,n){if(n||2==arguments.length)for(var i,r=0,s=t.length;r<s;r++)(i||!(r in t))&&(!i&&(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},r=i(i(i(i(i(i(i(i(i(i(i(i(i(i(i(i(i(i([],["onCopy","onCut","onPaste"],!0),["onCompositionEnd","onCompositionStart","onCompositionUpdate"],!0),["onFocus","onBlur"],!0),["onInput","onInvalid","onReset","onSubmit"],!0),["onLoad","onError"],!0),["onKeyDown","onKeyPress","onKeyUp"],!0),["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],!0),["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],!0),["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],!0),["onSelect"],!0),["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],!0),["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],!0),["onScroll"],!0),["onWheel"],!0),["onAnimationStart","onAnimationEnd","onAnimationIteration"],!0),["onTransitionEnd"],!0),["onChange"],!0),["onToggle"],!0);function s(e,t){var n={};return r.forEach(function(i){var r=e[i];if(!!r)t?n[i]=function(e){return r(e,t(i))}:n[i]=r}),n}},262941:function(e,t,n){"use strict";let i;n.r(t),n.d(t,{AbortException:function(){return nV},AnnotationEditorLayer:function(){return n$},AnnotationEditorParamsType:function(){return nW},AnnotationEditorType:function(){return nG},AnnotationEditorUIManager:function(){return nZ},AnnotationLayer:function(){return nq},AnnotationMode:function(){return nK},CMapCompressionType:function(){return nY},ColorPicker:function(){return nX},DOMSVGFactory:function(){return nJ},DrawLayer:function(){return nQ},FeatureTest:function(){return n0},GlobalWorkerOptions:function(){return n1},ImageKind:function(){return n2},InvalidPDFException:function(){return n5},MissingPDFException:function(){return n3},OPS:function(){return n4},Outliner:function(){return n6},PDFDataRangeTransport:function(){return n8},PDFDateString:function(){return n7},PDFWorker:function(){return n9},PasswordResponses:function(){return ie},PermissionFlag:function(){return it},PixelsPerInch:function(){return ii},RenderingCancelledException:function(){return ir},TextLayer:function(){return is},UnexpectedResponseException:function(){return io},Util:function(){return ia},VerbosityLevel:function(){return il},XfaLayer:function(){return id},build:function(){return ic},createValidAbsoluteUrl:function(){return ih},fetchData:function(){return iu},getDocument:function(){return ip},getFilenameFromUrl:function(){return im},getPdfFilenameFromUrl:function(){return ig},getXfaPageViewport:function(){return iv},isDataScheme:function(){return ib},isPdfFile:function(){return iy},noContextMenu:function(){return ix},normalizeUnicode:function(){return iw},renderTextLayer:function(){return i_},setLayerDimensions:function(){return iS},shadow:function(){return iE},updateTextLayer:function(){return iC},version:function(){return iA}});var r={};r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s=globalThis.pdfjsLib={};r.d(s,{AbortException:()=>P,AnnotationEditorLayer:()=>nH,AnnotationEditorParamsType:()=>u,AnnotationEditorType:()=>h,AnnotationEditorUIManager:()=>eM,AnnotationLayer:()=>nM,AnnotationMode:()=>c,CMapCompressionType:()=>y,ColorPicker:()=>nj,DOMSVGFactory:()=>er,DrawLayer:()=>nU,FeatureTest:()=>z,GlobalWorkerOptions:()=>tt,ImageKind:()=>m,InvalidPDFException:()=>I,MissingPDFException:()=>N,OPS:()=>x,Outliner:()=>nI,PDFDataRangeTransport:()=>tZ,PDFDateString:()=>em,PDFWorker:()=>tJ,PasswordResponses:()=>w,PermissionFlag:()=>p,PixelsPerInch:()=>ee,RenderingCancelledException:()=>eo,TextLayer:()=>tP,UnexpectedResponseException:()=>R,Util:()=>U,VerbosityLevel:()=>b,XfaLayer:()=>t9,build:()=>t4,createValidAbsoluteUrl:()=>k,fetchData:()=>et,getDocument:()=>t$,getFilenameFromUrl:()=>ed,getPdfFilenameFromUrl:()=>ec,getXfaPageViewport:()=>eg,isDataScheme:()=>ea,isPdfFile:()=>el,noContextMenu:()=>ep,normalizeUnicode:()=>W,renderTextLayer:()=>tj,setLayerDimensions:()=>ex,shadow:()=>T,updateTextLayer:()=>tF,version:()=>t3});let o="object"==typeof process&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&"browser"!==process.type),a=[1,0,0,1,0,0],l=[.001,0,0,.001,0,0],d={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},c={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},h={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},u={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},p={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},f={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},m={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},g={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},v={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},b={ERRORS:0,WARNINGS:1,INFOS:5},y={NONE:0,BINARY:1},x={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91},w={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},_=b.WARNINGS;function S(e){_>=b.INFOS&&console.log(`Info: ${e}`)}function E(e){_>=b.WARNINGS&&console.log(`Warning: ${e}`)}function C(e){throw Error(e)}function A(e,t){!e&&C(t)}function k(e,t=null,n=null){if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){let t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=function(e){return decodeURIComponent(escape(e))}(e)}catch{}}let i=t?new URL(e,t):new URL(e);if(function(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch{}return null}function T(e,t,n,i=!1){return Object.defineProperty(e,t,{value:n,enumerable:!i,configurable:!0,writable:!1}),n}let M=function(){function e(t,n){this.constructor===e&&C("Cannot initialize BaseException."),this.message=t,this.name=n}return e.prototype=Error(),e.constructor=e,e}();class D extends M{constructor(e,t){super(e,"PasswordException"),this.code=t}}class O extends M{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class I extends M{constructor(e){super(e,"InvalidPDFException")}}class N extends M{constructor(e){super(e,"MissingPDFException")}}class R extends M{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}}class L extends M{constructor(e){super(e,"FormatError")}}class P extends M{constructor(e){super(e,"AbortException")}}function j(e){("object"!=typeof e||e?.length===void 0)&&C("Invalid argument for bytesToString");let t=e.length;if(t<8192)return String.fromCharCode.apply(null,e);let n=[];for(let i=0;i<t;i+=8192){let r=Math.min(i+8192,t),s=e.subarray(i,r);n.push(String.fromCharCode.apply(null,s))}return n.join("")}function F(e){"string"!=typeof e&&C("Invalid argument for stringToBytes");let t=e.length,n=new Uint8Array(t);for(let i=0;i<t;++i)n[i]=255&e.charCodeAt(i);return n}function B(e){let t=Object.create(null);for(let[n,i]of e)t[n]=i;return t}class z{static get isLittleEndian(){return T(this,"isLittleEndian",function(){let e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return T(this,"isEvalSupported",function(){try{return Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return T(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?T(this,"platform",{isMac:navigator.platform.includes("Mac")}):T(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return T(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}let H=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,"0"));class U{static makeHexColor(e,t,n){return`#${H[e]}${H[t]}${H[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[1],t[1]=n,n=t[2],t[2]=t[3],t[3]=n,e[1]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){let n=e[0]*t[0]+e[1]*t[2]+t[4];return[n,e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){let n=t[0]*t[3]-t[1]*t[2],i=(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n;return[i,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){let n=this.applyTransform(e,t),i=this.applyTransform(e.slice(2,4),t),r=this.applyTransform([e[0],e[3]],t),s=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],i[0],r[0],s[0]),Math.min(n[1],i[1],r[1],s[1]),Math.max(n[0],i[0],r[0],s[0]),Math.max(n[1],i[1],r[1],s[1])]}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){let t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],i=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],s=e[2]*t[1]+e[3]*t[3],o=(n+s)/2,a=Math.sqrt((n+s)**2-4*(n*s-r*i))/2;return[Math.sqrt(o+a||1),Math.sqrt(o-a||1)]}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>i)return null;let r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),s=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>s?null:[n,r,i,s]}static #e(e,t,n,i,r,s,o,a,l,d){if(l<=0||l>=1)return;let c=1-l,h=l*l,u=h*l,p=c*(c*(c*e+3*l*t)+3*h*n)+u*i,f=c*(c*(c*r+3*l*s)+3*h*o)+u*a;d[0]=Math.min(d[0],p),d[1]=Math.min(d[1],f),d[2]=Math.max(d[2],p),d[3]=Math.max(d[3],f)}static #t(e,t,n,i,r,s,o,a,l,d,c,h){if(1e-12>Math.abs(l)){Math.abs(d)>=1e-12&&this.#e(e,t,n,i,r,s,o,a,-c/d,h);return}let u=d**2-4*c*l;if(u<0)return;let p=Math.sqrt(u),f=2*l;this.#e(e,t,n,i,r,s,o,a,(-d+p)/f,h),this.#e(e,t,n,i,r,s,o,a,(-d-p)/f,h)}static bezierBoundingBox(e,t,n,i,r,s,o,a,l){return l?(l[0]=Math.min(l[0],e,o),l[1]=Math.min(l[1],t,a),l[2]=Math.max(l[2],e,o),l[3]=Math.max(l[3],t,a)):l=[Math.min(e,o),Math.min(t,a),Math.max(e,o),Math.max(t,a)],this.#t(e,n,r,o,t,i,s,a,3*(-e+3*(n-r)+o),6*(e-2*n+r),3*(n-e),l),this.#t(e,n,r,o,t,i,s,a,3*(-t+3*(i-s)+a),6*(t-2*i+s),3*(i-t),l),l}}let V=null,$=null;function W(e){return!V&&(V=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,$=new Map([["ſt","ſt"]])),e.replaceAll(V,(e,t,n)=>t?t.normalize("NFKC"):$.get(n))}let G="pdfjs_internal_id_",Z={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};class q{constructor(){this.constructor===q&&C("Cannot initialize BaseFilterFactory.")}addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,n,i,r){return"none"}destroy(e=!1){}}class K{#n=!1;constructor({enableHWA:e=!1}={}){this.constructor===K&&C("Cannot initialize BaseCanvasFactory."),this.#n=e}create(e,t){if(e<=0||t<=0)throw Error("Invalid canvas size");let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!this.#n})}}reset(e,t,n){if(!e.canvas)throw Error("Canvas is not specified");if(t<=0||n<=0)throw Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){C("Abstract method `_createCanvas` called.")}}class Y{constructor({baseUrl:e=null,isCompressed:t=!0}){this.constructor===Y&&C("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!e)throw Error("CMap name must be specified.");let t=this.baseUrl+e+(this.isCompressed?".bcmap":""),n=this.isCompressed?y.BINARY:y.NONE;return this._fetchData(t,n).catch(e=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)})}_fetchData(e,t){C("Abstract method `_fetchData` called.")}}class X{constructor({baseUrl:e=null}){this.constructor===X&&C("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!e)throw Error("Font filename must be specified.");let t=`${this.baseUrl}${e}`;return this._fetchData(t).catch(e=>{throw Error(`Unable to load font data at: ${t}`)})}_fetchData(e){C("Abstract method `_fetchData` called.")}}class J{constructor(){this.constructor===J&&C("Cannot initialize BaseSVGFactory.")}create(e,t,n=!1){if(e<=0||t<=0)throw Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),!n&&(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if("string"!=typeof e)throw Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){C("Abstract method `_createSVG` called.")}}let Q="http://www.w3.org/2000/svg";class ee{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function et(e,t="text"){if(eu(e,document.baseURI)){let n=await fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise((n,i)=>{let r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){switch(t){case"arraybuffer":case"blob":case"json":n(r.response);return}n(r.responseText);return}i(Error(r.statusText))}},r.send(null)})}class en extends Y{_fetchData(e,t){return et(e,this.isCompressed?"arraybuffer":"text").then(e=>({cMapData:e instanceof ArrayBuffer?new Uint8Array(e):F(e),compressionType:t}))}}class ei extends X{_fetchData(e){return et(e,"arraybuffer").then(e=>new Uint8Array(e))}}class er extends J{_createSVG(e){return document.createElementNS(Q,e)}}class es{constructor({viewBox:e,scale:t,rotation:n,offsetX:i=0,offsetY:r=0,dontFlip:s=!1}){let o,a,l,d,c,h,u,p;this.viewBox=e,this.scale=t,this.rotation=n,this.offsetX=i,this.offsetY=r;let f=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((n%=360)<0&&(n+=360),n){case 180:o=-1,a=0,l=0,d=1;break;case 90:o=0,a=1,l=1,d=0;break;case 270:o=0,a=-1,l=-1,d=0;break;case 0:o=1,a=0,l=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}s&&(l=-l,d=-d),0===o?(c=Math.abs(m-e[1])*t+i,h=Math.abs(f-e[0])*t+r,u=(e[3]-e[1])*t,p=(e[2]-e[0])*t):(c=Math.abs(f-e[0])*t+i,h=Math.abs(m-e[1])*t+r,u=(e[2]-e[0])*t,p=(e[3]-e[1])*t),this.transform=[o*t,a*t,l*t,d*t,c-o*t*f-l*t*m,h-a*t*f-d*t*m],this.width=u,this.height=p}get rawDims(){let{viewBox:e}=this;return T(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:n=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new es({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}convertToViewportPoint(e,t){return U.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=U.applyTransform([e[0],e[1]],this.transform),n=U.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return U.applyInverseTransform([e,t],this.transform)}}class eo extends M{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function ea(e){let t=e.length,n=0;for(;n<t&&""===e[n].trim();)n++;return"data:"===e.substring(n,n+5).toLowerCase()}function el(e){return"string"==typeof e&&/\.pdf$/i.test(e)}function ed(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf("/")+1)}function ec(e,t="document.pdf"){if("string"!=typeof e)return t;if(ea(e))return E('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e),r=n.exec(i[1])||n.exec(i[2])||n.exec(i[3]);if(r&&(r=r[0]).includes("%"))try{r=n.exec(decodeURIComponent(r))[0]}catch{}return r||t}class eh{started=Object.create(null);times=[];time(e){e in this.started&&E(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){!(e in this.started)&&E(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){let e=[],t=0;for(let{name:e}of this.times)t=Math.max(e.length,t);for(let{name:n,start:i,end:r}of this.times)e.push(`${n.padEnd(t)} ${r-i}ms
|
|
|
`);return e.join("")}}function eu(e,t){try{let{protocol:n}=t?new URL(e,t):new URL(e);return"http:"===n||"https:"===n}catch{return!1}}function ep(e){e.preventDefault()}function ef(e){console.log("Deprecated API usage: "+e)}class em{static toDateObject(e){if(!e||"string"!=typeof e)return null;let t=(i||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?")).exec(e);if(!t)return null;let n=parseInt(t[1],10),r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let s=parseInt(t[3],10);s=s>=1&&s<=31?s:1;let o=parseInt(t[4],10);o=o>=0&&o<=23?o:0;let a=parseInt(t[5],10);a=a>=0&&a<=59?a:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;let d=t[7]||"Z",c=parseInt(t[8],10);c=c>=0&&c<=23?c:0;let h=parseInt(t[9],10)||0;return h=h>=0&&h<=59?h:0,"-"===d?(o+=c,a+=h):"+"===d&&(o-=c,a-=h),new Date(Date.UTC(n,r,s,o,a,l))}}function eg(e,{scale:t=1,rotation:n=0}){let{width:i,height:r}=e.attributes.style;return new es({viewBox:[0,0,parseInt(i),parseInt(r)],scale:t,rotation:n})}function ev(e){if(e.startsWith("#")){let t=parseInt(e.slice(1),16);return[(0xff0000&t)>>16,(65280&t)>>8,255&t]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map(e=>parseInt(e)):e.startsWith("rgba(")?e.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(E(`Not a valid color format: "${e}"`),[0,0,0])}function eb(e){let{a:t,b:n,c:i,d:r,e:s,f:o}=e.getTransform();return[t,n,i,r,s,o]}function ey(e){let{a:t,b:n,c:i,d:r,e:s,f:o}=e.getTransform().invertSelf();return[t,n,i,r,s,o]}function ex(e,t,n=!1,i=!0){if(t instanceof es){let{pageWidth:i,pageHeight:r}=t.rawDims,{style:s}=e,o=z.isCSSRoundSupported,a=`var(--scale-factor) * ${i}px`,l=`var(--scale-factor) * ${r}px`,d=o?`round(${a}, 1px)`:`calc(${a})`,c=o?`round(${l}, 1px)`:`calc(${l})`;n&&t.rotation%180!=0?(s.width=c,s.height=d):(s.width=d,s.height=c)}i&&e.setAttribute("data-main-rotation",t.rotation)}class ew{#i=null;#r=null;#s;#o=null;constructor(e){this.#s=e}render(){let e=this.#i=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar");let t=this.#s._uiManager._signal;e.addEventListener("contextmenu",ep,{signal:t}),e.addEventListener("pointerdown",ew.#a,{signal:t});let n=this.#o=document.createElement("div");n.className="buttons",e.append(n);let i=this.#s.toolbarPosition;if(i){let{style:t}=e,n="ltr"===this.#s._uiManager.direction?1-i[0]:i[0];t.insetInlineEnd=`${100*n}%`,t.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#l(),e}static #a(e){e.stopPropagation()}#d(e){this.#s._focusEventsAllowed=!1,e.preventDefault(),e.stopPropagation()}#c(e){this.#s._focusEventsAllowed=!0,e.preventDefault(),e.stopPropagation()}#h(e){let t=this.#s._uiManager._signal;e.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",ep,{signal:t})}hide(){this.#i.classList.add("hidden"),this.#r?.hideDropdown()}show(){this.#i.classList.remove("hidden")}#l(){let e=document.createElement("button");e.className="delete",e.tabIndex=0,e.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#s.editorType}-button`),this.#h(e),e.addEventListener("click",e=>{this.#s._uiManager.delete()},{signal:this.#s._uiManager._signal}),this.#o.append(e)}get #u(){let e=document.createElement("div");return e.className="divider",e}addAltTextButton(e){this.#h(e),this.#o.prepend(e,this.#u)}addColorPicker(e){this.#r=e;let t=e.renderButton();this.#h(t),this.#o.prepend(t,this.#u)}remove(){this.#i.remove(),this.#r?.destroy(),this.#r=null}}class e_{#o=null;#i=null;#p;constructor(e){this.#p=e}#f(){let e=this.#i=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",ep,{signal:this.#p._signal});let t=this.#o=document.createElement("div");return t.className="buttons",e.append(t),this.#m(),e}#g(e,t){let n=0,i=0;for(let r of e){let e=r.y+r.height;if(e<n)continue;let s=r.x+(t?r.width:0);if(e>n){i=s,n=e;continue}t?s>i&&(i=s):s<i&&(i=s)}return[t?1-i:i,n]}show(e,t,n){let[i,r]=this.#g(t,n),{style:s}=this.#i||=this.#f();e.append(this.#i),s.insetInlineEnd=`${100*i}%`,s.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#i.remove()}#m(){let e=document.createElement("button");e.className="highlightButton",e.tabIndex=0,e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let t=document.createElement("span");e.append(t),t.className="visuallyHidden",t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let n=this.#p._signal;e.addEventListener("contextmenu",ep,{signal:n}),e.addEventListener("click",()=>{this.#p.highlightSelection("floating_button")},{signal:n}),this.#o.append(e)}}function eS(e,t,n){for(let i of n)t.addEventListener(i,e[i].bind(e))}class eE{#v=0;get id(){return`pdfjs_internal_editor_${this.#v++}`}}class eC{#b=(function(){if("undefined"!=typeof crypto&&"function"==typeof crypto?.randomUUID)return crypto.randomUUID();let e=new Uint8Array(32);if("undefined"!=typeof crypto&&"function"==typeof crypto?.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<32;t++)e[t]=Math.floor(255*Math.random());return j(e)})();#v=0;#y=null;static get _isSVGFittingCanvas(){let e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),t=new Image;return t.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',T(this,"_isSVGFittingCanvas",t.decode().then(()=>(e.drawImage(t,0,0,1,1,0,0,1,3),0===new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0])))}async #x(e,t){this.#y||=new Map;let n=this.#y.get(e);if(null===n)return null;if(n?.bitmap)return n.refCounter+=1,n;try{let e;if(n||={bitmap:null,id:`image_${this.#b}_${this.#v++}`,refCounter:0,isSvg:!1},"string"==typeof t?(n.url=t,e=await et(t,"blob")):e=n.file=t,"image/svg+xml"===e.type){let t=eC._isSVGFittingCanvas,i=new FileReader,r=new Image,s=new Promise((e,s)=>{r.onload=()=>{n.bitmap=r,n.isSvg=!0,e()},i.onload=async()=>{let e=n.svgUrl=i.result;r.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e},r.onerror=i.onerror=s});i.readAsDataURL(e),await s}else n.bitmap=await createImageBitmap(e);n.refCounter=1}catch(e){console.error(e),n=null}return this.#y.set(e,n),n&&this.#y.set(n.id,n),n}async getFromFile(e){let{lastModified:t,name:n,size:i,type:r}=e;return this.#x(`${t}_${n}_${i}_${r}`,e)}async getFromUrl(e){return this.#x(e,e)}async getFromId(e){this.#y||=new Map;let t=this.#y.get(e);return t?t.bitmap?(t.refCounter+=1,t):t.file?this.getFromFile(t.file):this.getFromUrl(t.url):null}getSvgUrl(e){let t=this.#y.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#y||=new Map;let t=this.#y.get(e);if(!t)return;if(t.refCounter-=1,0===t.refCounter)t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#b}_`)}}class eA{#w=[];#_=!1;#S;#E=-1;constructor(e=128){this.#S=e}add({cmd:e,undo:t,post:n,mustExec:i,type:r=NaN,overwriteIfSameType:s=!1,keepUndo:o=!1}){if(i&&e(),this.#_)return;let a={cmd:e,undo:t,post:n,type:r};if(-1===this.#E){this.#w.length>0&&(this.#w.length=0),this.#E=0,this.#w.push(a);return}if(s&&this.#w[this.#E].type===r){o&&(a.undo=this.#w[this.#E].undo),this.#w[this.#E]=a;return}let l=this.#E+1;l===this.#S?this.#w.splice(0,1):(this.#E=l,l<this.#w.length&&this.#w.splice(l)),this.#w.push(a)}undo(){if(-1===this.#E)return;this.#_=!0;let{undo:e,post:t}=this.#w[this.#E];e(),t?.(),this.#_=!1,this.#E-=1}redo(){if(this.#E<this.#w.length-1){this.#E+=1,this.#_=!0;let{cmd:e,post:t}=this.#w[this.#E];e(),t?.(),this.#_=!1}}hasSomethingToUndo(){return -1!==this.#E}hasSomethingToRedo(){return this.#E<this.#w.length-1}destroy(){this.#w=null}}class ek{constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:t}=z.platform;for(let[n,i,r={}]of e)for(let e of n){let n=e.startsWith("mac+");t&&n?(this.callbacks.set(e.slice(4),{callback:i,options:r}),this.allKeys.add(e.split("+").at(-1))):!t&&!n&&(this.callbacks.set(e,{callback:i,options:r}),this.allKeys.add(e.split("+").at(-1)))}}#C(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);let t=this.buffer.join("+");return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;let n=this.callbacks.get(this.#C(t));if(!n)return;let{callback:i,options:{bubbles:r=!1,args:s=[],checker:o=null}}=n;if(!o||!!o(e,t))i.bind(e,...s,t)(),!r&&(t.stopPropagation(),t.preventDefault())}}class eT{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let e=new Map([["CanvasText",null],["Canvas",null]]);return!function(e){let t=document.createElement("span");for(let n of(t.style.visibility="hidden",document.body.append(t),e.keys())){t.style.color=n;let i=window.getComputedStyle(t).color;e.set(n,ev(i))}t.remove()}(e),T(this,"_colors",e)}convert(e){let t=ev(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(let[e,n]of this._colors)if(n.every((e,n)=>e===t[n]))return eT._colorsMapping.get(e);return t}getHexCode(e){let t=this._colors.get(e);return t?U.makeHexColor(...t):e}}class eM{#A=new AbortController;#k=null;#T=new Map;#M=new Map;#D=null;#O=null;#I=null;#N=new eA;#R=0;#L=new Set;#P=null;#j=null;#F=new Set;#B=!1;#z=null;#H=null;#U=null;#V=!1;#$=null;#W=new eE;#G=!1;#Z=!1;#q=null;#K=null;#Y=null;#X=h.NONE;#J=new Set;#Q=null;#ee=null;#et=null;#en=this.blur.bind(this);#ei=this.focus.bind(this);#er=this.copy.bind(this);#es=this.cut.bind(this);#eo=this.paste.bind(this);#ea=this.keydown.bind(this);#el=this.keyup.bind(this);#ed=this.onEditingAction.bind(this);#ec=this.onPageChanging.bind(this);#eh=this.onScaleChanging.bind(this);#eu=this.onRotationChanging.bind(this);#ep={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ef=[0,0];#em=null;#eg=null;#ev=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let e=eM.prototype,t=e=>e.#eg.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&e.hasSomethingToControl(),n=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return"text"!==e&&"number"!==e}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return T(this,"_keyboardManager",new ek([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],e.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:n}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:n}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#eg.contains(t)&&!e.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#eg.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:t}]]))}constructor(e,t,n,i,r,s,o,a,l){this._signal=this.#A.signal,this.#eg=e,this.#ev=t,this.#D=n,this._eventBus=i,this._eventBus._on("editingaction",this.#ed),this._eventBus._on("pagechanging",this.#ec),this._eventBus._on("scalechanging",this.#eh),this._eventBus._on("rotationchanging",this.#eu),this.#eb(),this.#ey(),this.#ex(),this.#O=r.annotationStorage,this.#z=r.filterFactory,this.#ee=s,this.#U=o||null,this.#B=a,this.#Y=l||null,this.viewParameters={realScale:ee.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){for(let e of(this.#A?.abort(),this.#A=null,this._signal=null,this._eventBus._off("editingaction",this.#ed),this._eventBus._off("pagechanging",this.#ec),this._eventBus._off("scalechanging",this.#eh),this._eventBus._off("rotationchanging",this.#eu),this.#M.values()))e.destroy();this.#M.clear(),this.#T.clear(),this.#F.clear(),this.#k=null,this.#J.clear(),this.#N.destroy(),this.#D?.destroy(),this.#$?.hide(),this.#$=null,this.#H&&(clearTimeout(this.#H),this.#H=null),this.#em&&(clearTimeout(this.#em),this.#em=null)}async mlGuess(e){return this.#Y?.guess(e)||null}get hasMLManager(){return!!this.#Y}get hcmFilter(){return T(this,"hcmFilter",this.#ee?this.#z.addHCMFilter(this.#ee.foreground,this.#ee.background):"none")}get direction(){return T(this,"direction",getComputedStyle(this.#eg).direction)}get highlightColors(){return T(this,"highlightColors",this.#U?new Map(this.#U.split(",").map(e=>e.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return T(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setMainHighlightColorPicker(e){this.#K=e}editAltText(e){this.#D?.editAltText(this,e)}onPageChanging({pageNumber:e}){this.#R=e-1}focusMainContainer(){this.#eg.focus()}findParent(e,t){for(let n of this.#M.values()){let{x:i,y:r,width:s,height:o}=n.div.getBoundingClientRect();if(e>=i&&e<=i+s&&t>=r&&t<=r+o)return n}return null}disableUserSelect(e=!1){this.#ev.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#F.add(e)}removeShouldRescale(e){this.#F.delete(e)}onScaleChanging({scale:e}){for(let t of(this.commitOrRemove(),this.viewParameters.realScale=e*ee.PDF_TO_CSS_UNITS,this.#F))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#ew({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}highlightSelection(e=""){let t=document.getSelection();if(!t||t.isCollapsed)return;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=t,o=t.toString(),a=this.#ew(t).closest(".textLayer"),l=this.getSelectionBoxes(a);if(!!l){for(let d of(t.empty(),this.#X===h.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:h.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0)),this.#M.values()))if(d.hasTextLayer(a)){d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s,text:o});break}}}#e_(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=this.#ew(e).closest(".textLayer"),n=this.getSelectionBoxes(t);if(!!n)this.#$||=new e_(this),this.#$.show(t,n,"ltr"===this.direction)}addToAnnotationStorage(e){!e.isEmpty()&&this.#O&&!this.#O.has(e.id)&&this.#O.setValue(e.id,e)}#eS(){let e=document.getSelection();if(!e||e.isCollapsed){this.#Q&&(this.#$?.hide(),this.#Q=null,this.#eE({hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===this.#Q)return;if(!this.#ew(e).closest(".textLayer")){this.#Q&&(this.#$?.hide(),this.#Q=null,this.#eE({hasSelectedText:!1}));return}if(this.#$?.hide(),this.#Q=t,this.#eE({hasSelectedText:!0}),this.#X===h.HIGHLIGHT||this.#X===h.NONE){if(this.#X===h.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#V=this.isShiftKeyDown,!this.isShiftKeyDown){let e=this._signal,t=e=>{if("pointerup"!==e.type||0===e.button)window.removeEventListener("pointerup",t),window.removeEventListener("blur",t),"pointerup"===e.type&&this.#eC("main_toolbar")};window.addEventListener("pointerup",t,{signal:e}),window.addEventListener("blur",t,{signal:e})}}}#eC(e=""){this.#X===h.HIGHLIGHT?this.highlightSelection(e):this.#B&&this.#e_()}#eb(){document.addEventListener("selectionchange",this.#eS.bind(this),{signal:this._signal})}#eA(){let e=this._signal;window.addEventListener("focus",this.#ei,{signal:e}),window.addEventListener("blur",this.#en,{signal:e})}#ek(){window.removeEventListener("focus",this.#ei),window.removeEventListener("blur",this.#en)}blur(){if(this.isShiftKeyDown=!1,this.#V&&(this.#V=!1,this.#eC("main_toolbar")),!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#J)if(t.div.contains(e)){this.#q=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#q)return;let[e,t]=this.#q;this.#q=null,t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#ex(){let e=this._signal;window.addEventListener("keydown",this.#ea,{signal:e}),window.addEventListener("keyup",this.#el,{signal:e})}#eT(){window.removeEventListener("keydown",this.#ea),window.removeEventListener("keyup",this.#el)}#eM(){let e=this._signal;document.addEventListener("copy",this.#er,{signal:e}),document.addEventListener("cut",this.#es,{signal:e}),document.addEventListener("paste",this.#eo,{signal:e})}#eD(){document.removeEventListener("copy",this.#er),document.removeEventListener("cut",this.#es),document.removeEventListener("paste",this.#eo)}#ey(){let e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#ex(),this.#eM()}removeEditListeners(){this.#eT(),this.#eD()}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of this.#j)if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of this.#j)if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#k?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of this.#J){let n=e.serialize(!0);n&&t.push(n)}if(0!==t.length)e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of this.#j)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(e){E(`paste: "${e.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let i=this.currentLayer;try{let e=[];for(let t of n){let n=i.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)this.#eO(t);this.#eI(e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){E(`paste: "${e.message}".`)}}keydown(e){!this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!0),this.#X!==h.NONE&&!this.isEditorHandlingKeyboard&&eM._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!1,this.#V&&(this.#V=!1,this.#eC("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#eE(e){Object.entries(e).some(([e,t])=>this.#ep[e]!==t)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#ep,e)}),this.#X===h.HIGHLIGHT&&!1===e.hasSelectedEditor&&this.#eN([[u.HIGHLIGHT_FREE,!0]]))}#eN(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#eA(),this.#eM(),this.#eE({isEditing:this.#X!==h.NONE,isEmpty:this.#eR(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ek(),this.#eD(),this.#eE({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#j)for(let t of(this.#j=e,this.#j))this.#eN(t.defaultPropertiesToUpdate)}getId(){return this.#W.id}get currentLayer(){return this.#M.get(this.#R)}getLayer(e){return this.#M.get(e)}get currentPageIndex(){return this.#R}addLayer(e){this.#M.set(e.pageIndex,e),this.#G?e.enable():e.disable()}removeLayer(e){this.#M.delete(e.pageIndex)}updateMode(e,t=null,n=!1){if(this.#X===e)return;if(this.#X=e,e===h.NONE){this.setEditingState(!1),this.#eL();return}for(let t of(this.setEditingState(!0),this.#eP(),this.unselectAll(),this.#M.values()))t.updateMode(e);if(!t&&n){this.addNewEditorFromKeyboard();return}if(!!t){for(let e of this.#T.values())if(e.annotationElementId===t){this.setSelected(e),e.enterInEditMode();break}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){if(e!==this.#X)this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(!!this.#j){switch(e){case u.CREATE:this.currentLayer.addNewEditor();return;case u.HIGHLIGHT_DEFAULT_COLOR:this.#K?.updateColor(t);break;case u.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#et||=new Map).set(e,t),this.showAllEditors("highlight",t)}for(let n of this.#J)n.updateParams(e,t);for(let n of this.#j)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(let n of this.#T.values())n.editorType===e&&n.show(t);(this.#et?.get(u.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#eN([[u.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#Z!==e)for(let t of(this.#Z=e,this.#M.values()))e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}#eP(){if(!this.#G){for(let e of(this.#G=!0,this.#M.values()))e.enable();for(let e of this.#T.values())e.enable()}}#eL(){if(this.unselectAll(),this.#G){for(let e of(this.#G=!1,this.#M.values()))e.disable();for(let e of this.#T.values())e.disable()}}getEditors(e){let t=[];for(let n of this.#T.values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return this.#T.get(e)}addEditor(e){this.#T.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#H&&clearTimeout(this.#H),this.#H=setTimeout(()=>{this.focusMainContainer(),this.#H=null},0)),this.#T.delete(e.id),this.unselect(e),(!e.annotationElementId||!this.#L.has(e.annotationElementId))&&this.#O?.remove(e.id)}addDeletedAnnotationElement(e){this.#L.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#L.has(e)}removeDeletedAnnotationElement(e){this.#L.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#eO(e){let t=this.#M.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){if(this.#k!==e)this.#k=e,e&&this.#eN(e.propertiesToUpdate)}get #ej(){let e=null;for(e of this.#J);return e}updateUI(e){this.#ej===e&&this.#eN(e.propertiesToUpdate)}toggleSelected(e){if(this.#J.has(e)){this.#J.delete(e),e.unselect(),this.#eE({hasSelectedEditor:this.hasSelection});return}this.#J.add(e),e.select(),this.#eN(e.propertiesToUpdate),this.#eE({hasSelectedEditor:!0})}setSelected(e){for(let t of this.#J)t!==e&&t.unselect();this.#J.clear(),this.#J.add(e),e.select(),this.#eN(e.propertiesToUpdate),this.#eE({hasSelectedEditor:!0})}isSelected(e){return this.#J.has(e)}get firstSelectedEditor(){return this.#J.values().next().value}unselect(e){e.unselect(),this.#J.delete(e),this.#eE({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#J.size}get isEnterHandled(){return 1===this.#J.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#eE({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#eR()})}redo(){this.#N.redo(),this.#eE({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#eR()})}addCommands(e){this.#N.add(e),this.#eE({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#eR()})}#eR(){if(0===this.#T.size)return!0;if(1===this.#T.size)for(let e of this.#T.values())return e.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...this.#J];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)this.#eO(t)},mustExec:!0})}commitOrRemove(){this.#k?.commitOrRemove()}hasSomethingToControl(){return this.#k||this.hasSelection}#eI(e){for(let e of this.#J)e.unselect();for(let t of(this.#J.clear(),e)){if(!t.isEmpty())this.#J.add(t),t.select()}this.#eE({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#J)e.commit();this.#eI(this.#T.values())}unselectAll(){if((!this.#k||(this.#k.commitOrRemove(),this.#X===h.NONE))&&!!this.hasSelection){for(let e of this.#J)e.unselect();this.#J.clear(),this.#eE({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(!n&&this.commitOrRemove(),!this.hasSelection)return;this.#ef[0]+=e,this.#ef[1]+=t;let[i,r]=this.#ef,s=[...this.#J];for(let n of(this.#em&&clearTimeout(this.#em),this.#em=setTimeout(()=>{this.#em=null,this.#ef[0]=this.#ef[1]=0,this.addCommands({cmd:()=>{for(let e of s)this.#T.has(e.id)&&e.translateInPage(i,r)},undo:()=>{for(let e of s)this.#T.has(e.id)&&e.translateInPage(-i,-r)},mustExec:!1})},1e3),s))n.translateInPage(e,t)}setUpDragSession(){if(!!this.hasSelection)for(let e of(this.disableUserSelect(!0),this.#P=new Map,this.#J))this.#P.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#P)return!1;this.disableUserSelect(!1);let e=this.#P;this.#P=null;let t=!1;for(let[{x:n,y:i,pageIndex:r},s]of e)s.newX=n,s.newY=i,s.newPageIndex=r,t||=n!==s.savedX||i!==s.savedY||r!==s.savedPageIndex;if(!t)return!1;let n=(e,t,n,i)=>{if(this.#T.has(e.id)){let r=this.#M.get(i);r?e._setParentAndPosition(r,t,n):(e.pageIndex=i,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:i,newY:r,newPageIndex:s}]of e)n(t,i,r,s)},undo:()=>{for(let[t,{savedX:i,savedY:r,savedPageIndex:s}]of e)n(t,i,r,s)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(!!this.#P)for(let n of this.#P.keys())n.drag(e,t)}rebuild(e){if(null===e.parent){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#J.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#k===e}getActive(){return this.#k}getMode(){return this.#X}get imageManager(){return T(this,"imageManager",new eC)}getSelectionBoxes(e){let t;if(!e)return null;let n=document.getSelection();for(let t=0,i=n.rangeCount;t<i;t++)if(!e.contains(n.getRangeAt(t).commonAncestorContainer))return null;let{x:i,y:r,width:s,height:o}=e.getBoundingClientRect();switch(e.getAttribute("data-main-rotation")){case"90":t=(e,t,n,a)=>({x:(t-r)/o,y:1-(e+n-i)/s,width:a/o,height:n/s});break;case"180":t=(e,t,n,a)=>({x:1-(e+n-i)/s,y:1-(t+a-r)/o,width:n/s,height:a/o});break;case"270":t=(e,t,n,a)=>({x:1-(t+a-r)/o,y:(e-i)/s,width:a/o,height:n/s});break;default:t=(e,t,n,a)=>({x:(e-i)/s,y:(t-r)/o,width:n/s,height:a/o})}let a=[];for(let e=0,i=n.rangeCount;e<i;e++){let i=n.getRangeAt(e);if(!i.collapsed)for(let{x:e,y:n,width:r,height:s}of i.getClientRects()){if(0!==r&&0!==s)a.push(t(e,n,r,s))}}return 0===a.length?null:a}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#I||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#I?.delete(e)}renderAnnotationElement(e){let t=this.#I?.get(e.data.id);if(!t)return;let n=this.#O.getRawValue(t);if(!!n&&(this.#X!==h.NONE||!!n.hasBeenModified))n.renderAnnotationElement(e)}}class eD{#eF="";#eB=!1;#ez=null;#eH=null;#eU=null;#eV=!1;#s=null;static _l10nPromise=null;constructor(e){this.#s=e}static initialize(e){eD._l10nPromise||=e}async render(){let e=this.#ez=document.createElement("button");e.className="altText";let t=await eD._l10nPromise.get("pdfjs-editor-alt-text-button-label");e.textContent=t,e.setAttribute("aria-label",t),e.tabIndex="0";let n=this.#s._uiManager._signal;e.addEventListener("contextmenu",ep,{signal:n}),e.addEventListener("pointerdown",e=>e.stopPropagation(),{signal:n});let i=e=>{e.preventDefault(),this.#s._uiManager.editAltText(this.#s)};return e.addEventListener("click",i,{capture:!0,signal:n}),e.addEventListener("keydown",t=>{t.target===e&&"Enter"===t.key&&(this.#eV=!0,i(t))},{signal:n}),await this.#e$(),e}finish(){if(!!this.#ez)this.#ez.focus({focusVisible:this.#eV}),this.#eV=!1}isEmpty(){return!this.#eF&&!this.#eB}get data(){return{altText:this.#eF,decorative:this.#eB}}set data({altText:e,decorative:t}){if(this.#eF!==e||this.#eB!==t)this.#eF=e,this.#eB=t,this.#e$()}toggle(e=!1){if(!!this.#ez)!e&&this.#eU&&(clearTimeout(this.#eU),this.#eU=null),this.#ez.disabled=!e}destroy(){this.#ez?.remove(),this.#ez=null,this.#eH=null}async #e$(){let e=this.#ez;if(!e)return;if(!this.#eF&&!this.#eB){e.classList.remove("done"),this.#eH?.remove();return}e.classList.add("done"),eD._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(t=>{e.setAttribute("aria-label",t)});let t=this.#eH;if(!t){this.#eH=t=document.createElement("span"),t.className="tooltip",t.setAttribute("role","tooltip");let n=t.id=`alt-text-tooltip-${this.#s.id}`;e.setAttribute("aria-describedby",n);let i=this.#s._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#eU),this.#eU=null},{once:!0}),e.addEventListener("mouseenter",()=>{this.#eU=setTimeout(()=>{this.#eU=null,this.#eH.classList.add("show"),this.#s._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),e.addEventListener("mouseleave",()=>{this.#eU&&(clearTimeout(this.#eU),this.#eU=null),this.#eH?.classList.remove("show")},{signal:i})}t.innerText=this.#eB?await eD._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#eF,!t.parentNode&&e.append(t);let n=this.#s.getImageForAltText();n?.setAttribute("aria-describedby",t.id)}}class eO{#eW=null;#eG=null;#eF=null;#eZ=!1;#eq=!1;#eK=null;#eY=null;#eX=this.focusin.bind(this);#eJ=this.focusout.bind(this);#eQ=null;#e0="";#e1=!1;#e2=null;#e5=!1;#e3=!1;#e4=!1;#e6=null;#e8=0;#e7=0;#e9=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#te=!1;#tt=eO._zIndex++;static _borderLineWidth=-1;static _colorManager=new eT;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let e=eO.prototype._resizeWithKeyboard,t=eM.TRANSLATE_SMALL,n=eM.TRANSLATE_BIG;return T(this,"_resizerKeyboardManager",new ek([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,n]}],[["Escape","mac+Escape"],eO.prototype._stopResizingWithKeyboard]]))}constructor(e){this.constructor===eO&&C("Cannot initialize AnnotationEditor."),this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;let{rotation:t,rawDims:{pageWidth:n,pageHeight:i,pageX:r,pageY:s}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,i],this.pageTranslation=[r,s];let[o,a]=this.parentDimensions;this.x=e.x/o,this.y=e.y/a,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return T(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){let t=new eI({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t,n){if(eO._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(t=>[t,e.get(t.replaceAll(/([A-Z])/g,e=>`-${e.toLowerCase()}`))])),n?.strings)for(let t of n.strings)eO._l10nPromise.set(t,e.get(t));if(-1!==eO._borderLineWidth)return;let i=getComputedStyle(document.documentElement);eO._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){C("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#te}set _isDraggable(e){this.#te=e,this.div?.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(2*e),this.y+=this.width*e/(2*t);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(2*e),this.y-=this.width*e/(2*t);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#tt}setParent(e){null!==e?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):this.#tn(),this.parent=e}focusin(e){if(!!this._focusEventsAllowed)this.#e1?this.#e1=!1:this.parent.setSelected(this)}focusout(e){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let t=e.relatedTarget;if(!t?.closest(`#${this.id}`))e.preventDefault(),!this.parent?.isMultipleSelection&&this.commitOrRemove()}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,i){let[r,s]=this.parentDimensions;[n,i]=this.screenToPageTranslation(n,i),this.x=(e+n)/r,this.y=(t+i)/s,this.fixAndSetPosition()}#ti([e,t],n,i){[n,i]=this.screenToPageTranslation(n,i),this.x+=n/e,this.y+=i/t,this.fixAndSetPosition()}translate(e,t){this.#ti(this.parentDimensions,e,t)}translateInPage(e,t){this.#e2||=[this.x,this.y],this.#ti(this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){this.#e2||=[this.x,this.y];let[n,i]=this.parentDimensions;if(this.x+=e/n,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:s}=this,[o,a]=this.getBaseTranslation();r+=o,s+=a,this.div.style.left=`${(100*r).toFixed(2)}%`,this.div.style.top=`${(100*s).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#e2&&(this.#e2[0]!==this.x||this.#e2[1]!==this.y)}getBaseTranslation(){let[e,t]=this.parentDimensions,{_borderLineWidth:n}=eO,i=n/e,r=n/t;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let[t,n]=this.pageDimensions,{x:i,y:r,width:s,height:o}=this;if(s*=t,o*=n,i*=t,r*=n,this._mustFixPosition)switch(e){case 0:i=Math.max(0,Math.min(t-s,i)),r=Math.max(0,Math.min(n-o,r));break;case 90:i=Math.max(0,Math.min(t-o,i)),r=Math.min(n,Math.max(s,r));break;case 180:i=Math.min(t,Math.max(s,i)),r=Math.min(n,Math.max(o,r));break;case 270:i=Math.min(t,Math.max(o,i)),r=Math.max(0,Math.min(n-s,r))}this.x=i/=t,this.y=r/=n;let[a,l]=this.getBaseTranslation();i+=a,r+=l;let{style:d}=this.div;d.left=`${(100*i).toFixed(2)}%`,d.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static #tr(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(e,t){return eO.#tr(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return eO.#tr(e,t,360-this.parentRotation)}#ts(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this,i=t*e,r=n*e;return z.isCSSRoundSupported?[Math.round(i),Math.round(r)]:[i,r]}setDims(e,t){let[n,i]=this.parentDimensions;this.div.style.width=`${(100*e/n).toFixed(2)}%`,!this.#eq&&(this.div.style.height=`${(100*t/i).toFixed(2)}%`)}fixDims(){let{style:e}=this.div,{height:t,width:n}=e,i=n.endsWith("%"),r=!this.#eq&&t.endsWith("%");if(i&&r)return;let[s,o]=this.parentDimensions;!i&&(e.width=`${(100*parseFloat(n)/s).toFixed(2)}%`),!this.#eq&&!r&&(e.height=`${(100*parseFloat(t)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#to(){if(this.#eK)return;this.#eK=document.createElement("div"),this.#eK.classList.add("resizers");let e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(let n of e){let e=document.createElement("div");this.#eK.append(e),e.classList.add("resizer",n),e.setAttribute("data-resizer-name",n),e.addEventListener("pointerdown",this.#ta.bind(this,n),{signal:t}),e.addEventListener("contextmenu",ep,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#eK)}#ta(e,t){t.preventDefault();let{isMac:n}=z.platform;if(0!==t.button||t.ctrlKey&&n)return;this.#eF?.toggle(!1);let i=this.#tl.bind(this,e),r=this._isDraggable;this._isDraggable=!1;let s=this._uiManager._signal,o={passive:!0,capture:!0,signal:s};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,o),window.addEventListener("contextmenu",ep,{signal:s});let a=this.x,l=this.y,d=this.width,c=this.height,h=this.parent.div.style.cursor,u=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let p=()=>{this.parent.togglePointerEvents(!0),this.#eF?.toggle(!0),this._isDraggable=r,window.removeEventListener("pointerup",p),window.removeEventListener("blur",p),window.removeEventListener("pointermove",i,o),window.removeEventListener("contextmenu",ep),this.parent.div.style.cursor=h,this.div.style.cursor=u,this.#td(a,l,d,c)};window.addEventListener("pointerup",p,{signal:s}),window.addEventListener("blur",p,{signal:s})}#td(e,t,n,i){let r=this.x,s=this.y,o=this.width,a=this.height;if(r!==e||s!==t||o!==n||a!==i)this.addCommands({cmd:()=>{this.width=o,this.height=a,this.x=r,this.y=s;let[e,t]=this.parentDimensions;this.setDims(e*o,t*a),this.fixAndSetPosition()},undo:()=>{this.width=n,this.height=i,this.x=e,this.y=t;let[r,s]=this.parentDimensions;this.setDims(r*n,s*i),this.fixAndSetPosition()},mustExec:!0})}#tl(e,t){let n,i,r,s;let[o,a]=this.parentDimensions,l=this.x,d=this.y,c=this.width,h=this.height,u=eO.MIN_SIZE/o,p=eO.MIN_SIZE/a,f=e=>Math.round(1e4*e)/1e4,m=this.#ts(this.rotation),g=(e,t)=>[m[0]*e+m[2]*t,m[1]*e+m[3]*t],v=this.#ts(360-this.rotation),b=!1,y=!1;switch(e){case"topLeft":b=!0,n=(e,t)=>[0,0],i=(e,t)=>[e,t];break;case"topMiddle":n=(e,t)=>[e/2,0],i=(e,t)=>[e/2,t];break;case"topRight":b=!0,n=(e,t)=>[e,0],i=(e,t)=>[0,t];break;case"middleRight":y=!0,n=(e,t)=>[e,t/2],i=(e,t)=>[0,t/2];break;case"bottomRight":b=!0,n=(e,t)=>[e,t],i=(e,t)=>[0,0];break;case"bottomMiddle":n=(e,t)=>[e/2,t],i=(e,t)=>[e/2,0];break;case"bottomLeft":b=!0,n=(e,t)=>[0,t],i=(e,t)=>[e,0];break;case"middleLeft":y=!0,n=(e,t)=>[0,t/2],i=(e,t)=>[e,t/2]}let x=n(c,h),w=i(c,h),_=g(...w),S=f(l+_[0]),E=f(d+_[1]),C=1,A=1,[k,T]=this.screenToPageTranslation(t.movementX,t.movementY);if([k,T]=(r=k/o,s=T/a,[v[0]*r+v[2]*s,v[1]*r+v[3]*s]),b){let e=Math.hypot(c,h);C=A=Math.max(Math.min(Math.hypot(w[0]-x[0]-k,w[1]-x[1]-T)/e,1/c,1/h),u/c,p/h)}else y?C=Math.max(u,Math.min(1,Math.abs(w[0]-x[0]-k)))/c:A=Math.max(p,Math.min(1,Math.abs(w[1]-x[1]-T)))/h;let M=f(c*C),D=f(h*A),O=S-(_=g(...i(M,D)))[0],I=E-_[1];this.width=M,this.height=D,this.x=O,this.y=I,this.setDims(o*M,a*D),this.fixAndSetPosition()}altTextFinish(){this.#eF?.finish()}async addEditToolbar(){return this.#eQ||this.#e3?this.#eQ:(this.#eQ=new ew(this),this.div.append(this.#eQ.render()),this.#eF&&this.#eQ.addAltTextButton(await this.#eF.render()),this.#eQ)}removeEditToolbar(){if(!!this.#eQ)this.#eQ.remove(),this.#eQ=null,this.#eF?.destroy()}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){if(!this.#eF)eD.initialize(eO._l10nPromise),this.#eF=new eD(this),this.#eW&&(this.#eF.data=this.#eW,this.#eW=null),await this.addEditToolbar()}get altTextData(){return this.#eF?.data}set altTextData(e){if(!!this.#eF)this.#eF.data=e}hasAltText(){return!this.#eF?.isEmpty()}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#eZ?-1:0,!this._isVisible&&this.div.classList.add("hidden"),this.setInForeground();let e=this._uiManager._signal;this.div.addEventListener("focusin",this.#eX,{signal:e}),this.div.addEventListener("focusout",this.#eJ,{signal:e});let[t,n]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*n/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/n).toFixed(2)}%`);let[i,r]=this.getInitialTranslation();return this.translate(i,r),eS(this,this.div,["pointerdown"]),this.div}pointerdown(e){let{isMac:t}=z.platform;if(0!==e.button||e.ctrlKey&&t){e.preventDefault();return}if(this.#e1=!0,this._isDraggable){this.#tc(e);return}this.#th(e)}#th(e){let{isMac:t}=z.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#tc(e){let t,n;let i=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let r=this._uiManager._signal;i&&(this.div.classList.add("moving"),t={passive:!0,capture:!0,signal:r},this.#e8=e.clientX,this.#e7=e.clientY,n=e=>{let{clientX:t,clientY:n}=e,[i,r]=this.screenToPageTranslation(t-this.#e8,n-this.#e7);this.#e8=t,this.#e7=n,this._uiManager.dragSelectedEditors(i,r)},window.addEventListener("pointermove",n,t));let s=()=>{window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),i&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",n,t)),this.#e1=!1,!this._uiManager.endDragSession()&&this.#th(e)};window.addEventListener("pointerup",s,{signal:r}),window.addEventListener("blur",s,{signal:r})}moveInDOM(){this.#e6&&clearTimeout(this.#e6),this.#e6=setTimeout(()=>{this.#e6=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition()}getRect(e,t,n=this.rotation){let i=this.parentScale,[r,s]=this.pageDimensions,[o,a]=this.pageTranslation,l=e/i,d=t/i,c=this.x*r,h=this.y*s,u=this.width*r,p=this.height*s;switch(n){case 0:return[c+l+o,s-h-d-p+a,c+l+u+o,s-h-d+a];case 90:return[c+d+o,s-h+l+a,c+d+p+o,s-h+l+u+a];case 180:return[c-l-u+o,s-h+d+a,c-l+o,s-h+d+p+a];case 270:return[c-d-p+o,s-h-l-u+a,c-d+o,s-h-l+a];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[n,i,r,s]=e,o=r-n,a=s-i;switch(this.rotation){case 0:return[n,t-s,o,a];case 90:return[n,t-i,a,o];case 180:return[r,t-i,o,a];case 270:return[r,t-s,a,o];default:throw Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#e3=!0}disableEditMode(){this.#e3=!1}isInEditMode(){return this.#e3}shouldGetKeyboardEvents(){return this.#e4}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){let e=this._uiManager._signal;this.div?.addEventListener("focusin",this.#eX,{signal:e}),this.div?.addEventListener("focusout",this.#eJ,{signal:e})}rotate(e){}serialize(e=!1,t=null){C("An editor must be serializable")}static deserialize(e,t,n){let i=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});i.rotation=e.rotation,i.#eW=e.accessibilityData;let[r,s]=i.pageDimensions,[o,a,l,d]=i.getRectInCurrentCoords(e.rect,s);return i.x=o/r,i.y=a/s,i.width=l/r,i.height=d/s,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.div.removeEventListener("focusin",this.#eX),this.div.removeEventListener("focusout",this.#eJ),!this.isEmpty()&&this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#e6&&(clearTimeout(this.#e6),this.#e6=null),this.#tn(),this.removeEditToolbar(),this.#e9){for(let e of this.#e9.values())clearTimeout(e);this.#e9=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#to(),this.#eK.classList.remove("hidden"),eS(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),this.#eY={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let t=this.#eK.children;if(!this.#eG){this.#eG=Array.from(t);let e=this.#tu.bind(this),n=this.#tp.bind(this),i=this._uiManager._signal;for(let t of this.#eG){let r=t.getAttribute("data-resizer-name");t.setAttribute("role","spinbutton"),t.addEventListener("keydown",e,{signal:i}),t.addEventListener("blur",n,{signal:i}),t.addEventListener("focus",this.#tf.bind(this,r),{signal:i}),eO._l10nPromise.get(`pdfjs-editor-resizer-label-${r}`).then(e=>t.setAttribute("aria-label",e))}}let n=this.#eG[0],i=0;for(let e of t){if(e===n)break;i++}let r=(360-this.rotation+this.parentRotation)%360/90*(this.#eG.length/4);if(r!==i){if(r<i)for(let e=0;e<i-r;e++)this.#eK.append(this.#eK.firstChild);else if(r>i)for(let e=0;e<r-i;e++)this.#eK.firstChild.before(this.#eK.lastChild);let e=0;for(let n of t){let t=this.#eG[e++].getAttribute("data-resizer-name");eO._l10nPromise.get(`pdfjs-editor-resizer-label-${t}`).then(e=>n.setAttribute("aria-label",e))}}this.#tm(0),this.#e4=!0,this.#eK.firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#tu(e){eO._resizerKeyboardManager.exec(this,e)}#tp(e){this.#e4&&e.relatedTarget?.parentNode!==this.#eK&&this.#tn()}#tf(e){this.#e0=this.#e4?e:""}#tm(e){if(!!this.#eG)for(let t of this.#eG)t.tabIndex=e}_resizeWithKeyboard(e,t){if(!!this.#e4)this.#tl(this.#e0,{movementX:e,movementY:t})}#tn(){if(this.#e4=!1,this.#tm(-1),this.#eY){let{savedX:e,savedY:t,savedWidth:n,savedHeight:i}=this.#eY;this.#td(e,t,n,i),this.#eY=null}}_stopResizingWithKeyboard(){this.#tn(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this.#eQ){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#eQ?.show()});return}this.#eQ?.show()}unselect(){this.#eK?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#eQ?.hide()}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#e5}set isEditing(e){if(this.#e5=e,!!this.parent)e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null)}setAspectRatio(e,t){this.#eq=!0;let{style:n}=this.div;n.aspectRatio=e/t,n.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){this.#e9||=new Map;let{action:t}=e,n=this.#e9.get(t);n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(e),this.#e9.delete(t),0===this.#e9.size&&(this.#e9=null)},eO._telemetryTimeout),this.#e9.set(t,n);return}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#eZ=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#eZ=!0}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");if(t){if("CANVAS"===t.nodeName){let e=t;(t=document.createElement("div")).classList.add("annotationContent",this.editorType),e.before(t)}}else(t=document.createElement("div")).classList.add("annotationContent",this.editorType),e.container.prepend(t);return t}resetAnnotationElement(e){let{firstChild:t}=e.container;"DIV"===t.nodeName&&t.classList.contains("annotationContent")&&t.remove()}}class eI extends eO{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}class eN{constructor(e){this.h1=e?0xffffffff&e:0xc3d2e1f0,this.h2=e?0xffffffff&e:0xc3d2e1f0}update(e){let t,n;if("string"==typeof e){t=new Uint8Array(2*e.length),n=0;for(let i=0,r=e.length;i<r;i++){let r=e.charCodeAt(i);r<=255?t[n++]=r:(t[n++]=r>>>8,t[n++]=255&r)}}else if(ArrayBuffer.isView(e))n=(t=e.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let i=n>>2,r=n-4*i,s=new Uint32Array(t.buffer,0,i),o=0,a=0,l=this.h1,d=this.h2,c=11601,h=13715;for(let e=0;e<i;e++)1&e?(l^=o=0x1b873593*(o=(o=0xcc9e2d51*(o=s[e])&0xffff0000|o*c&65535)<<15|o>>>17)&0xffff0000|o*h&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(d^=a=0x1b873593*(a=(a=0xcc9e2d51*(a=s[e])&0xffff0000|a*c&65535)<<15|a>>>17)&0xffff0000|a*h&65535,d=5*(d=d<<13|d>>>19)+0xe6546b64);switch(o=0,r){case 3:o^=t[4*i+2]<<16;case 2:o^=t[4*i+1]<<8;case 1:o^=t[4*i],o=0x1b873593*(o=(o=0xcc9e2d51*o&0xffff0000|o*c&65535)<<15|o>>>17)&0xffff0000|o*h&65535,1&i?l^=o:d^=o}this.h1=l,this.h2=d}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,t=0xff51afd7*t&0xffff0000|((t<<16|(e=0xed558ccd*e&0xffff0000|36045*e&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,e^=t>>>1,t=0xc4ceb9fe*t&0xffff0000|((t<<16|(e=0x1a85ec53*e&0xffff0000|60499*e&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((e^=t>>>1)>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}let eR=Object.freeze({map:null,hash:"",transfer:void 0});class eL{#tg=!1;#tv=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let n=this.#tv.get(e);return void 0===n?t:Object.assign(t,n)}getRawValue(e){return this.#tv.get(e)}remove(e){if(this.#tv.delete(e),0===this.#tv.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let e of this.#tv.values())if(e instanceof eO)return;this.onAnnotationEditor(null)}}setValue(e,t){let n=this.#tv.get(e),i=!1;if(void 0!==n)for(let[e,r]of Object.entries(t))n[e]!==r&&(i=!0,n[e]=r);else i=!0,this.#tv.set(e,t);i&&this.#tb(),t instanceof eO&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#tv.has(e)}getAll(){return this.#tv.size>0?B(this.#tv):null}setAll(e){for(let[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return this.#tv.size}#tb(){!this.#tg&&(this.#tg=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#tg&&(this.#tg=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new eP(this)}get serializable(){if(0===this.#tv.size)return eR;let e=new Map,t=new eN,n=[],i=Object.create(null),r=!1;for(let[n,s]of this.#tv){let o=s instanceof eO?s.serialize(!1,i):s;o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),r||=!!o.bitmap)}if(r)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:eR}get editorStats(){let e=null,t=new Map;for(let n of this.#tv.values()){if(!(n instanceof eO))continue;let i=n.telemetryFinalData;if(!i)continue;let{type:r}=i;!t.has(r)&&t.set(r,Object.getPrototypeOf(n).constructor),e||=Object.create(null);let s=e[r]||=new Map;for(let[e,t]of Object.entries(i)){if("type"===e)continue;let n=s.get(e);!n&&(n=new Map,s.set(e,n));let i=n.get(t)??0;n.set(t,i+1)}}for(let[n,i]of t)e[n]=i.computeTelemetryFinalData(e[n]);return e}}class eP extends eL{#ty;constructor(e){super();let{map:t,hash:n,transfer:i}=e.serializable,r=structuredClone(t,i?{transfer:i}:null);this.#ty={map:r,hash:n,transfer:i}}get print(){C("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ty}}class ej{#tx=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){!this.styleElement&&(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#tx.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(!(!e||this.#tx.has(e.loadedName))){if(A(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:i,style:r}=e,s=new FontFace(n,i,r);this.addNativeFontFace(s);try{await s.load(),this.#tx.add(n),t?.(e)}catch{E(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(s)}return}C("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw E(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){return T(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let e=!1;return o?e=!0:"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)&&(e=!0),T(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){let{loadingRequests:t}=this,n={done:!1,complete:function(){for(A(!n.done,"completeRequest() cannot be called twice."),n.done=!0;t.length>0&&t[0].done;)setTimeout(t.shift().callback,0)},callback:e};return t.push(n),n}get _loadTestFont(){return T(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t){var n;let i,r;function s(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function o(e,t,n,i){let r=e.substring(0,t);return r+i+e.substring(t+n)}let a=this._document.createElement("canvas");a.width=1,a.height=1;let l=a.getContext("2d"),d=0,c=`lt${Date.now()}${this.loadTestFontId++}`,h=this._loadTestFont;h=o(h,976,c.length,c);let u=s(h,16);for(i=0,r=c.length-3;i<r;i+=4)u=u-0x58585858+s(c,i)|0;i<c.length&&(u=u-0x58585858+s(c+"XXX",i)|0),h=o(h,16,4,String.fromCharCode((n=u)>>24&255,n>>16&255,n>>8&255,255&n));let p=`url(data:font/opentype;base64,${btoa(h)});`,f=`@font-face {font-family:"${c}";src:${p}}`;this.insertRule(f);let m=this._document.createElement("div");for(let t of(m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px",[e.loadedName,c])){let e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=t,m.append(e)}this._document.body.append(m),!function e(t,n){if(++d>30){E("Load test font never loaded."),n();return}if(l.font="30px "+t,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){n();return}setTimeout(e.bind(null,t,n))}(c,()=>{m.remove(),t.complete()})}}class eF{constructor(e,{disableFontFace:t=!1,inspectFont:n=null}){for(let t in this.compiledGlyphs=Object.create(null),e)this[t]=e[t];this.disableFontFace=!0===t,this._inspectFont=n}createNativeFontFace(){let e;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),e}createFontFaceRule(){let e;if(!this.data||this.disableFontFace)return null;let t=j(this.data),n=`url(data:${this.mimetype};base64,${btoa(t)});`;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${n}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${n}}`;return this._inspectFont?.(this,n),e}getPathGenerator(e,t){let n;if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];try{n=e.get(this.loadedName+"_path_"+t)}catch(e){E(`getPathGenerator - ignoring character: "${e}".`)}if(!Array.isArray(n)||0===n.length)return this.compiledGlyphs[t]=function(e,t){};let i=[];for(let e=0,t=n.length;e<t;)switch(n[e++]){case Z.BEZIER_CURVE_TO:{let[t,r,s,o,a,l]=n.slice(e,e+6);i.push(e=>e.bezierCurveTo(t,r,s,o,a,l)),e+=6}break;case Z.MOVE_TO:{let[t,r]=n.slice(e,e+2);i.push(e=>e.moveTo(t,r)),e+=2}break;case Z.LINE_TO:{let[t,r]=n.slice(e,e+2);i.push(e=>e.lineTo(t,r)),e+=2}break;case Z.QUADRATIC_CURVE_TO:{let[t,r,s,o]=n.slice(e,e+4);i.push(e=>e.quadraticCurveTo(t,r,s,o)),e+=4}break;case Z.RESTORE:i.push(e=>e.restore());break;case Z.SAVE:i.push(e=>e.save());break;case Z.SCALE:A(2===i.length,"Scale command is only valid at the third position.");break;case Z.TRANSFORM:{let[t,r,s,o,a,l]=n.slice(e,e+6);i.push(e=>e.transform(t,r,s,o,a,l)),e+=6}break;case Z.TRANSLATE:{let[t,r]=n.slice(e,e+2);i.push(e=>e.translate(t,r)),e+=2}}return this.compiledGlyphs[t]=function(e,t){i[0](e),i[1](e),e.scale(t,-t);for(let t=2,n=i.length;t<n;t++)i[t](e)}}}if(o){var eB=Promise.withResolvers(),ez=null;(async()=>{let e,t;let n=await import("fs"),i=await import("http"),r=await import("https");return new Map(Object.entries({fs:n,http:i,https:r,url:await import("url"),canvas:e,path2d:t}))})().then(e=>{ez=e,eB.resolve()},e=>{E(`loadPackages: ${e}`),ez=new Map,eB.resolve()})}class eH{static get promise(){return eB.promise}static get(e){return ez?.get(e)}}let eU=function(e){return eH.get("fs").promises.readFile(e).then(e=>new Uint8Array(e))},eV={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function e$(e,t){if(!t)return;let n=t[2]-t[0],i=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],n,i),e.clip(r)}class eW{constructor(){this.constructor===eW&&C("Cannot initialize BaseShadingPattern.")}getPattern(){C("Abstract method `getPattern` called.")}}class eG extends eW{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;for(let n of("axial"===this._type?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))t.addColorStop(n[0],n[1]);return t}getPattern(e,t,n,i){let r;if(i===eV.STROKE||i===eV.FILL){let s=t.current.getClippedPathBoundingBox(i,eb(e))||[0,0,0,0],o=Math.ceil(s[2]-s[0])||1,a=Math.ceil(s[3]-s[1])||1,l=t.cachedCanvases.getCanvas("pattern",o,a,!0),d=l.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-s[0],-s[1]),n=U.transform(n,[1,0,0,1,s[0],s[1]]),d.transform(...t.baseTransform),this.matrix&&d.transform(...this.matrix),e$(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),r=e.createPattern(l.canvas,"no-repeat");let c=new DOMMatrix(n);r.setTransform(c)}else e$(e,this._bbox),r=this._createGradient(e);return r}}function eZ(e,t,n,i,r,s,o,a){let l,d,c,h,u,p,f,m,g;let v=t.coords,b=t.colors,y=e.data,x=4*e.width;v[n+1]>v[i+1]&&(l=n,n=i,i=l,l=s,s=o,o=l),v[i+1]>v[r+1]&&(l=i,i=r,r=l,l=o,o=a,a=l),v[n+1]>v[i+1]&&(l=n,n=i,i=l,l=s,s=o,o=l);let w=(v[n]+t.offsetX)*t.scaleX,_=(v[n+1]+t.offsetY)*t.scaleY,S=(v[i]+t.offsetX)*t.scaleX,E=(v[i+1]+t.offsetY)*t.scaleY,C=(v[r]+t.offsetX)*t.scaleX,A=(v[r+1]+t.offsetY)*t.scaleY;if(_>=A)return;let k=b[s],T=b[s+1],M=b[s+2],D=b[o],O=b[o+1],I=b[o+2],N=b[a],R=b[a+1],L=b[a+2],P=Math.round(_),j=Math.round(A);for(let e=P;e<=j;e++){let t;if(e<E){let t=e<_?0:(_-e)/(_-E);d=w-(w-S)*t,c=k-(k-D)*t,h=T-(T-O)*t,u=M-(M-I)*t}else{let t;d=S-(S-C)*(t=e>A?1:E===A?0:(E-e)/(E-A)),c=D-(D-N)*t,h=O-(O-R)*t,u=I-(I-L)*t}p=w-(w-C)*(t=e<_?0:e>A?1:(_-e)/(_-A)),f=k-(k-N)*t,m=T-(T-R)*t,g=M-(M-L)*t;let n=Math.round(Math.min(d,p)),i=Math.round(Math.max(d,p)),r=x*e+4*n;for(let e=n;e<=i;e++)(t=(d-e)/(d-p))<0?t=0:t>1&&(t=1),y[r++]=c-(c-f)*t|0,y[r++]=h-(h-m)*t|0,y[r++]=u-(u-g)*t|0,y[r++]=255}}class eq extends eW{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,n){let i=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),s=Math.ceil(this._bounds[2])-i,o=Math.ceil(this._bounds[3])-r,a=Math.min(Math.ceil(Math.abs(s*e[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(o*e[1]*1.1)),3e3),d=s/a,c=o/l,h={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-r,scaleX:1/d,scaleY:1/c},u=a+4,p=l+4,f=n.getCanvas("mesh",u,p,!1),m=f.context,g=m.createImageData(a,l);if(t){let e=g.data;for(let n=0,i=e.length;n<i;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=255}for(let e of this._figures)!function(e,t,n){let i,r;let s=t.coords,o=t.colors;switch(t.type){case"lattice":let a=t.verticesPerRow,l=Math.floor(s.length/a)-1,d=a-1;for(i=0;i<l;i++){let t=i*a;for(let i=0;i<d;i++,t++)eZ(e,n,s[t],s[t+1],s[t+a],o[t],o[t+1],o[t+a]),eZ(e,n,s[t+a+1],s[t+1],s[t+a],o[t+a+1],o[t+1],o[t+a])}break;case"triangles":for(i=0,r=s.length;i<r;i+=3)eZ(e,n,s[i],s[i+1],s[i+2],o[i],o[i+1],o[i+2]);break;default:throw Error("illegal figure")}}(g,e,h);return m.putImageData(g,2,2),{canvas:f.canvas,offsetX:i-2*d,offsetY:r-2*c,scaleX:d,scaleY:c}}getPattern(e,t,n,i){let r;if(e$(e,this._bbox),i===eV.SHADING)r=U.singularValueDecompose2dScale(eb(e));else if(r=U.singularValueDecompose2dScale(t.baseTransform),this.matrix){let e=U.singularValueDecompose2dScale(this.matrix);r=[r[0]*e[0],r[1]*e[1]]}let s=this._createMeshCanvas(r,i===eV.SHADING?null:this._background,t.cachedCanvases);return i!==eV.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(s.offsetX,s.offsetY),e.scale(s.scaleX,s.scaleY),e.createPattern(s.canvas,"no-repeat")}}class eK extends eW{getPattern(){return"hotpink"}}let eY={COLORED:1,UNCOLORED:2};class eX{static MAX_PATTERN_SIZE=3e3;constructor(e,t,n,i,r){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=t,this.ctx=n,this.canvasGraphicsFactory=i,this.baseTransform=r}createPatternCanvas(e){let t=this.operatorList,n=this.bbox,i=this.xstep,r=this.ystep,s=this.paintType,o=this.tilingType,a=this.color,l=this.canvasGraphicsFactory;S("TilingType: "+o);let d=n[0],c=n[1],h=n[2],u=n[3],p=U.singularValueDecompose2dScale(this.matrix),f=U.singularValueDecompose2dScale(this.baseTransform),m=[p[0]*f[0],p[1]*f[1]],g=this.getSizeAndScale(i,this.ctx.canvas.width,m[0]),v=this.getSizeAndScale(r,this.ctx.canvas.height,m[1]),b=e.cachedCanvases.getCanvas("pattern",g.size,v.size,!0),y=b.context,x=l.createCanvasGraphics(y);x.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(x,s,a);let w=d,_=c,E=h,C=u;return d<0&&(w=0,E+=Math.abs(d)),c<0&&(_=0,C+=Math.abs(c)),y.translate(-(g.scale*w),-(v.scale*_)),x.transform(g.scale,0,0,v.scale,0,0),y.save(),this.clipBbox(x,w,_,E,C),x.baseTransform=eb(x.ctx),x.executeOperatorList(t),x.endDrawing(),{canvas:b.canvas,scaleX:g.scale,scaleY:v.scale,offsetX:w,offsetY:_}}getSizeAndScale(e,t,n){e=Math.abs(e);let i=Math.max(eX.MAX_PATTERN_SIZE,t),r=Math.ceil(e*n);return r>=i?r=i:n=r/e,{scale:n,size:r}}clipBbox(e,t,n,i,r){let s=i-t,o=r-n;e.ctx.rect(t,n,s,o),e.current.updateRectMinMax(eb(e.ctx),[t,n,i,r]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){let i=e.ctx,r=e.current;switch(t){case eY.COLORED:let s=this.ctx;i.fillStyle=s.fillStyle,i.strokeStyle=s.strokeStyle,r.fillColor=s.fillStyle,r.strokeColor=s.strokeStyle;break;case eY.UNCOLORED:let o=U.makeHexColor(n[0],n[1],n[2]);i.fillStyle=o,i.strokeStyle=o,r.fillColor=o,r.strokeColor=o;break;default:throw new L(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,i){let r=n;i!==eV.SHADING&&(r=U.transform(r,t.baseTransform),this.matrix&&(r=U.transform(r,this.matrix)));let s=this.createPatternCanvas(t),o=new DOMMatrix(r);o=(o=o.translate(s.offsetX,s.offsetY)).scale(1/s.scaleX,1/s.scaleY);let a=e.createPattern(s.canvas,"repeat");return a.setTransform(o),a}}class eJ{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let i;return void 0!==this.cache[e]?(i=this.cache[e],this.canvasFactory.reset(i,t,n)):(i=this.canvasFactory.create(t,n),this.cache[e]=i),i}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function eQ(e,t,n,i,r,s,o,a,l,d){let[c,h,u,p,f,m]=eb(e);if(0===h&&0===u){let g=Math.round(o*c+f),v=Math.round(a*p+m),b=Math.abs(Math.round((o+l)*c+f)-g)||1,y=Math.abs(Math.round((a+d)*p+m)-v)||1;return e.setTransform(Math.sign(c),0,0,Math.sign(p),g,v),e.drawImage(t,n,i,r,s,0,0,b,y),e.setTransform(c,h,u,p,f,m),[b,y]}if(0===c&&0===p){let g=Math.round(a*u+f),v=Math.round(o*h+m),b=Math.abs(Math.round((a+d)*u+f)-g)||1,y=Math.abs(Math.round((o+l)*h+m)-v)||1;return e.setTransform(0,Math.sign(h),Math.sign(u),0,g,v),e.drawImage(t,n,i,r,s,0,0,y,b),e.setTransform(c,h,u,p,f,m),[y,b]}return e.drawImage(t,n,i,r,s,o,a,l,d),[Math.hypot(c,h)*l,Math.hypot(u,p)*d]}class e0{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=a,this.textMatrixScale=1,this.fontMatrix=l,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=f.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=U.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){let n=U.applyTransform(t,e),i=U.applyTransform(t.slice(2),e),r=U.applyTransform([t[0],t[3]],e),s=U.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,n[0],i[0],r[0],s[0]),this.minY=Math.min(this.minY,n[1],i[1],r[1],s[1]),this.maxX=Math.max(this.maxX,n[0],i[0],r[0],s[0]),this.maxY=Math.max(this.maxY,n[1],i[1],r[1],s[1])}updateScalingPathMinMax(e,t){U.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,i,r,s,o,a,l,d){let c=U.bezierBoundingBox(t,n,i,r,s,o,a,l,d);if(!d)this.updateRectMinMax(e,c)}getPathBoundingBox(e=eV.FILL,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===eV.STROKE){!t&&C("Stroke bounding box must include transform.");let e=U.singularValueDecompose2dScale(t),i=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=i,n[1]-=r,n[2]+=i,n[3]+=r}return n}updateClipFromPath(){let e=U.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=eV.FILL,t=null){return U.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function e1(e,t){let n,i,r,s;if("undefined"!=typeof ImageData&&t instanceof ImageData){e.putImageData(t,0,0);return}let o=t.height,a=t.width,l=o%16,d=(o-l)/16,c=0===l?d:d+1,h=e.createImageData(a,16),u=0,p,f=t.data,g=h.data;if(t.kind===m.GRAYSCALE_1BPP){let t=f.byteLength,s=new Uint32Array(g.buffer,0,g.byteLength>>2),o=s.length,m=a+7>>3,v=z.isLittleEndian?0xff000000:255;for(n=0;n<c;n++){for(i=0,r=n<d?16:l,p=0;i<r;i++){let e=t-u,n=0,i=e>m?a:8*e-7,r=-8&i,o=0,l=0;for(;n<r;n+=8)l=f[u++],s[p++]=128&l?0xffffffff:v,s[p++]=64&l?0xffffffff:v,s[p++]=32&l?0xffffffff:v,s[p++]=16&l?0xffffffff:v,s[p++]=8&l?0xffffffff:v,s[p++]=4&l?0xffffffff:v,s[p++]=2&l?0xffffffff:v,s[p++]=1&l?0xffffffff:v;for(;n<i;n++)0===o&&(l=f[u++],o=128),s[p++]=l&o?0xffffffff:v,o>>=1}for(;p<o;)s[p++]=0;e.putImageData(h,0,16*n)}}else if(t.kind===m.RGBA_32BPP){for(n=0,i=0,s=64*a;n<d;n++)g.set(f.subarray(u,u+s)),u+=s,e.putImageData(h,0,i),i+=16;n<c&&(s=a*l*4,g.set(f.subarray(u,u+s)),e.putImageData(h,0,i))}else if(t.kind===m.RGB_24BPP)for(n=0,s=a*(r=16);n<c;n++){for(n>=d&&(s=a*(r=l)),p=0,i=s;i--;)g[p++]=f[u++],g[p++]=f[u++],g[p++]=f[u++],g[p++]=255;e.putImageData(h,0,16*n)}else throw Error(`bad image kind: ${t.kind}`)}function e2(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let n=t.height,i=t.width,r=n%16,s=(n-r)/16,o=0===r?s:s+1,a=e.createImageData(i,16),l=0,d=t.data,c=a.data;for(let t=0;t<o;t++){let n=t<s?16:r;({srcPos:l}=function({src:e,srcPos:t=0,dest:n,width:i,height:r,nonBlackColor:s=0xffffffff,inverseDecode:o=!1}){let a=z.isLittleEndian?0xff000000:255,[l,d]=o?[s,a]:[a,s],c=i>>3,h=7&i,u=e.length;n=new Uint32Array(n.buffer);let p=0;for(let i=0;i<r;i++){for(let i=t+c;t<i;t++){let i=t<u?e[t]:255;n[p++]=128&i?d:l,n[p++]=64&i?d:l,n[p++]=32&i?d:l,n[p++]=16&i?d:l,n[p++]=8&i?d:l,n[p++]=4&i?d:l,n[p++]=2&i?d:l,n[p++]=1&i?d:l}if(0===h)continue;let i=t<u?e[t++]:255;for(let e=0;e<h;e++)n[p++]=i&1<<7-e?d:l}return{srcPos:t,destPos:p}}({src:d,srcPos:l,dest:c,width:i,height:n,nonBlackColor:0})),e.putImageData(a,0,16*t)}}function e5(e,t){for(let n of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==e[n]&&(t[n]=e[n]);void 0!==e.setLineDash&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function e3(e){if(e.strokeStyle=e.fillStyle="#000000",e.fillRule="nonzero",e.globalAlpha=1,e.lineWidth=1,e.lineCap="butt",e.lineJoin="miter",e.miterLimit=10,e.globalCompositeOperation="source-over",e.font="10px sans-serif",void 0!==e.setLineDash&&(e.setLineDash([]),e.lineDashOffset=0),!o){let{filter:t}=e;"none"!==t&&""!==t&&(e.filter="none")}}function e4(e,t){if(t)return!0;let n=U.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);let i=Math.fround((globalThis.devicePixelRatio||1)*ee.PDF_TO_CSS_UNITS);return n[0]<=i&&n[1]<=i}let e6=["butt","round","square"],e8=["miter","round","bevel"],e7={},e9={};class te{constructor(e,t,n,i,r,{optionalContentConfig:s,markedContentStack:o=null},a,l){this.ctx=e,this.current=new e0(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=i,this.filterFactory=r,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=s,this.cachedCanvases=new eJ(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=a,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:i=null}){let r=this.ctx.canvas.width,s=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,s),this.ctx.fillStyle=o,n){let e=this.cachedCanvases.getCanvas("transparent",r,s);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...eb(this.compositeCtx))}this.ctx.save(),e3(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=eb(this.ctx)}executeOperatorList(e,t,n,i){let r;let s=e.argsArray,o=e.fnArray,a=t||0,l=s.length;if(l===a)return a;let d=l-a>10&&"function"==typeof n,c=d?Date.now()+15:0,h=0,u=this.commonObjs,p=this.objs;for(;;){if(void 0!==i&&a===i.nextBreakPoint)return i.breakIt(a,n),a;if((r=o[a])!==x.dependency)this[r].apply(this,s[a]);else for(let e of s[a]){let t=e.startsWith("g_")?u:p;if(!t.has(e))return t.get(e,n),a}if(++a===l)return a;if(d&&++h>10){if(Date.now()>c)return n(),a;h=0}}}#tw(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){for(let e of(this.#tw(),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#t_()}#t_(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){let n,i;let r=e.width,s=e.height,o=Math.max(Math.hypot(t[0],t[1]),1),a=Math.max(Math.hypot(t[2],t[3]),1),l=r,d=s,c="prescale1";for(;o>2&&l>1||a>2&&d>1;){let t=l,r=d;o>2&&l>1&&(t=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),o/=l/t),a>2&&d>1&&(r=d>=16384?Math.floor(d/2)-1||1:Math.ceil(d)/2,a/=d/r),(i=(n=this.cachedCanvases.getCanvas(c,t,r)).context).clearRect(0,0,t,r),i.drawImage(e,0,0,l,d,0,0,t,r),e=n.canvas,l=t,d=r,c="prescale1"===c?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:d}}_createMaskCanvas(e){let t,n,i,r;let s=this.ctx,{width:o,height:a}=e,l=this.current.fillColor,d=this.current.patternFill,c=eb(s);if((e.bitmap||e.data)&&e.count>1){let r=e.bitmap||e.data.buffer;n=JSON.stringify(d?c:[c.slice(0,4),l]),!(t=this._cachedBitmapsMap.get(r))&&(t=new Map,this._cachedBitmapsMap.set(r,t));let s=t.get(n);if(s&&!d){let e=Math.round(Math.min(c[0],c[2])+c[4]);return{canvas:s,offsetX:e,offsetY:Math.round(Math.min(c[1],c[3])+c[5])}}i=s}!i&&e2((r=this.cachedCanvases.getCanvas("maskCanvas",o,a)).context,e);let h=U.transform(c,[1/o,0,0,-1/a,0,0]);h=U.transform(h,[1,0,0,1,0,-a]);let[u,p,f,m]=U.getAxialAlignedBoundingBox([0,0,o,a],h),g=Math.round(f-u)||1,v=Math.round(m-p)||1,b=this.cachedCanvases.getCanvas("fillCanvas",g,v),y=b.context;y.translate(-u,-p),y.transform(...h),!i&&(i=(i=this._scaleImage(r.canvas,ey(y))).img,t&&d&&t.set(n,i)),y.imageSmoothingEnabled=e4(eb(y),e.interpolate),eQ(y,i,0,0,i.width,i.height,0,0,o,a),y.globalCompositeOperation="source-in";let x=U.transform(ey(y),[1,0,0,1,-u,-p]);return y.fillStyle=d?l.getPattern(s,this,x,eV.FILL):l,y.fillRect(0,0,o,a),t&&!d&&(this.cachedCanvases.delete("fillCanvas"),t.set(n,b.canvas)),{canvas:b.canvas,offsetX:Math.round(u),offsetY:Math.round(p)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=e6[e]}setLineJoin(e){this.ctx.lineJoin=e8[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,t=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=i.context;let r=this.ctx;r.setTransform(...eb(this.suspendedCtx)),e5(this.suspendedCtx,r),!function(e,t){if(e._removeMirroring)throw Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,i,r,s,o){t.transform(e,n,i,r,s,o),this.__originalTransform(e,n,i,r,s,o)},e.setTransform=function(e,n,i,r,s,o){t.setTransform(e,n,i,r,s,o),this.__originalSetTransform(e,n,i,r,s,o)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,i,r,s,o){t.bezierCurveTo(e,n,i,r,s,o),this.__originalBezierCurveTo(e,n,i,r,s,o)},e.rect=function(e,n,i,r){t.rect(e,n,i,r),this.__originalRect(e,n,i,r)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),e5(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,n,i){let r=i[0],s=i[1],o=i[2]-r,a=i[3]-s;if(0!==o&&0!==a)this.genericComposeSMask(t.context,n,o,a,t.subtype,t.backdrop,t.transferMap,r,s,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore()}genericComposeSMask(e,t,n,i,r,s,o,a,l,d,c){let h=e.canvas,u=a-d,p=l-c;if(s){if(u<0||p<0||u+n>h.width||p+i>h.height){let e=this.cachedCanvases.getCanvas("maskExtension",n,i),t=e.context;t.drawImage(h,-u,-p),s.some(e=>0!==e)&&(t.globalCompositeOperation="destination-atop",t.fillStyle=U.makeHexColor(...s),t.fillRect(0,0,n,i),t.globalCompositeOperation="source-over"),h=e.canvas,u=p=0}else if(s.some(e=>0!==e)){e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let t=new Path2D;t.rect(u,p,n,i),e.clip(t),e.globalCompositeOperation="destination-atop",e.fillStyle=U.makeHexColor(...s),e.fillRect(u,p,n,i),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),"Alpha"===r&&o?t.filter=this.filterFactory.addAlphaFilter(o):"Luminosity"===r&&(t.filter=this.filterFactory.addLuminosityFilter(o));let f=new Path2D;f.rect(a,l,n,i),t.clip(f),t.globalCompositeOperation="destination-in",t.drawImage(h,u,p,n,i,a,l,n,i),t.restore()}save(){this.inSMaskMode?(e5(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),e5(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,i,r,s){this.ctx.transform(e,t,n,i,r,s),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){let i,r;let s=this.ctx,o=this.current,a=o.x,l=o.y,d=eb(s),c=0===d[0]&&0===d[3]||0===d[1]&&0===d[2],h=c?n.slice(0):null;for(let n=0,u=0,p=e.length;n<p;n++)switch(0|e[n]){case x.rectangle:a=t[u++],l=t[u++];let p=t[u++],f=t[u++],m=a+p,g=l+f;s.moveTo(a,l),0===p||0===f?s.lineTo(m,g):(s.lineTo(m,l),s.lineTo(m,g),s.lineTo(a,g)),!c&&o.updateRectMinMax(d,[a,l,m,g]),s.closePath();break;case x.moveTo:a=t[u++],l=t[u++],s.moveTo(a,l),!c&&o.updatePathMinMax(d,a,l);break;case x.lineTo:a=t[u++],l=t[u++],s.lineTo(a,l),!c&&o.updatePathMinMax(d,a,l);break;case x.curveTo:i=a,r=l,a=t[u+4],l=t[u+5],s.bezierCurveTo(t[u],t[u+1],t[u+2],t[u+3],a,l),o.updateCurvePathMinMax(d,i,r,t[u],t[u+1],t[u+2],t[u+3],a,l,h),u+=6;break;case x.curveTo2:i=a,r=l,s.bezierCurveTo(a,l,t[u],t[u+1],t[u+2],t[u+3]),o.updateCurvePathMinMax(d,i,r,a,l,t[u],t[u+1],t[u+2],t[u+3],h),a=t[u+2],l=t[u+3],u+=4;break;case x.curveTo3:i=a,r=l,a=t[u+2],l=t[u+3],s.bezierCurveTo(t[u],t[u+1],a,l,a,l),o.updateCurvePathMinMax(d,i,r,t[u],t[u+1],a,l,a,l,h),u+=4;break;case x.closePath:s.closePath()}c&&o.updateScalingPathMinMax(d,h),o.setCurrentPoint(a,l)}closePath(){this.ctx.closePath()}stroke(e=!0){let t=this.ctx,n=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof n&&n?.getPattern?(t.save(),t.strokeStyle=n.getPattern(t,this,ey(t),eV.STROKE),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){let t=this.ctx,n=this.current.fillColor,i=this.current.patternFill,r=!1;i&&(t.save(),t.fillStyle=n.getPattern(t,this,ey(t),eV.FILL),r=!0);let s=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==s&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),r&&t.restore(),e&&this.consumePath(s)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=e7}eoClip(){this.pendingClip=e9}beginText(){this.current.textMatrix=a,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let e=this.pendingTextPaths,t=this.ctx;if(void 0===e){t.beginPath();return}for(let n of(t.save(),t.beginPath(),e))t.setTransform(...n.transform),t.translate(n.x,n.y),n.addToPath(t,n.fontSize);t.restore(),t.clip(),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){let n=this.commonObjs.get(e),i=this.current;if(!n)throw Error(`Can't find font for ${e}`);if(i.fontMatrix=n.fontMatrix||l,(0===i.fontMatrix[0]||0===i.fontMatrix[3])&&E("Invalid font matrix for font "+e),t<0?(t=-t,i.fontDirection=-1):i.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;let r=n.loadedName||"sans-serif",s=n.systemFontInfo?.css||`"${r}", ${n.fallbackName}`,o="normal";n.black?o="900":n.bold&&(o="bold");let a=n.italic?"italic":"normal",d=t;t<16?d=16:t>100&&(d=100),this.current.fontSizeScale=t/d,this.ctx.font=`${a} ${o} ${d}px ${s}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,i,r,s){this.current.textMatrix=[e,t,n,i,r,s],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,n,i){let r;let s=this.ctx,o=this.current,a=o.font,l=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,c=l&f.FILL_STROKE_MASK,h=!!(l&f.ADD_TO_PATH_FLAG),u=o.patternFill&&!a.missingFile;(a.disableFontFace||h||u)&&(r=a.getPathGenerator(this.commonObjs,e)),a.disableFontFace||u?(s.save(),s.translate(t,n),s.beginPath(),r(s,d),i&&s.setTransform(...i),(c===f.FILL||c===f.FILL_STROKE)&&s.fill(),(c===f.STROKE||c===f.FILL_STROKE)&&s.stroke(),s.restore()):((c===f.FILL||c===f.FILL_STROKE)&&s.fillText(e,t,n),(c===f.STROKE||c===f.FILL_STROKE)&&s.strokeText(e,t,n)),h&&(this.pendingTextPaths||=[]).push({transform:eb(s),x:t,y:n,fontSize:d,addToPath:r})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);let t=e.getImageData(0,0,10,10).data,n=!1;for(let e=3;e<t.length;e+=4)if(t[e]>0&&t[e]<255){n=!0;break}return T(this,"isFontSubpixelAAEnabled",n)}showText(e){let t;let n=this.current,i=n.font;if(i.isType3Font)return this.showType3Text(e);let r=n.fontSize;if(0===r)return;let s=this.ctx,o=n.fontSizeScale,a=n.charSpacing,l=n.wordSpacing,d=n.fontDirection,c=n.textHScale*d,h=e.length,u=i.vertical,p=u?1:-1,m=i.defaultVMetrics,g=r*n.fontMatrix[0],v=n.textRenderingMode===f.FILL&&!i.disableFontFace&&!n.patternFill;if(s.save(),s.transform(...n.textMatrix),s.translate(n.x,n.y+n.textRise),d>0?s.scale(c,-1):s.scale(c,1),n.patternFill){s.save();let e=n.fillColor.getPattern(s,this,ey(s),eV.FILL);t=eb(s),s.restore(),s.fillStyle=e}let b=n.lineWidth,y=n.textMatrixScale;if(0===y||0===b){let e=n.textRenderingMode&f.FILL_STROKE_MASK;(e===f.STROKE||e===f.FILL_STROKE)&&(b=this.getSinglePixelWidth())}else b/=y;if(1!==o&&(s.scale(o,o),b/=o),s.lineWidth=b,i.isInvalidPDFjsFont){let t=[],i=0;for(let n of e)t.push(n.unicode),i+=n.width;s.fillText(t.join(""),0,0),n.x+=i*g*c,s.restore(),this.compose();return}let x=0,w;for(w=0;w<h;++w){let n,c;let h=e[w];if("number"==typeof h){x+=p*h*r/1e3;continue}let f=!1,b=(h.isSpace?l:0)+a,y=h.fontChar,_=h.accent,S=h.width;if(u){let e=h.vmetric||m,t=-(h.vmetric?e[1]:.5*S)*g,i=e[2]*g;S=e?-e[0]:S,n=t/o,c=(x+i)/o}else n=x/o,c=0;if(i.remeasure&&S>0){let e=1e3*s.measureText(y).width/r*o;if(S<e&&this.isFontSubpixelAAEnabled){let t=S/e;f=!0,s.save(),s.scale(t,1),n/=t}else S!==e&&(n+=(S-e)/2e3*r/o)}if(this.contentVisible&&(h.isInFont||i.missingFile)){if(v&&!_)s.fillText(y,n,c);else if(this.paintChar(y,n,c,t),_){let e=n+r*_.offset.x/o,i=c-r*_.offset.y/o;this.paintChar(_.fontChar,e,i,t)}}x+=u?S*g-b*d:S*g+b*d,f&&s.restore()}u?n.y-=x:n.x+=x*c,s.restore(),this.compose()}showType3Text(e){let t,n,i,r;let s=this.ctx,o=this.current,a=o.font,d=o.fontSize,c=o.fontDirection,h=a.vertical?1:-1,u=o.charSpacing,p=o.wordSpacing,m=o.textHScale*c,g=o.fontMatrix||l,v=e.length;if(o.textRenderingMode!==f.INVISIBLE&&0!==d){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),s.transform(...o.textMatrix),s.translate(o.x,o.y),s.scale(m,c),t=0;t<v;++t){if("number"==typeof(n=e[t])){r=h*n*d/1e3,this.ctx.translate(r,0),o.x+=r*m;continue}let l=(n.isSpace?p:0)+u,c=a.charProcOperatorList[n.operatorListId];if(!c){E(`Type3 character "${n.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=n,this.save(),s.scale(d,d),s.transform(...g),this.executeOperatorList(c),this.restore()),i=U.applyTransform([n.width,0],g)[0]*d+l,s.translate(i,0),o.x+=i*m}s.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,i,r,s){this.ctx.rect(n,i,r-n,s-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let t;if("TilingPattern"===e[0]){let n=e[1],i=this.baseTransform||eb(this.ctx);t=new eX(e,n,this.ctx,{createCanvasGraphics:e=>new te(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},i)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){let i=U.makeHexColor(e,t,n);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(e,t,n){let i=U.makeHexColor(e,t,n);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=function(e){switch(e[0]){case"RadialAxial":return new eG(e);case"Mesh":return new eq(e);case"Dummy":return new eK}throw Error(`Unknown IR type: ${e[0]}`)}(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save();let n=this._getPattern(e);t.fillStyle=n.getPattern(t,this,ey(t),eV.SHADING);let i=ey(t);if(i){let{width:e,height:n}=t.canvas,[r,s,o,a]=U.getAxialAlignedBoundingBox([0,0,e,n],i);this.ctx.fillRect(r,s,o-r,a-s)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){C("Should not call beginInlineImage")}beginImageData(){C("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(!!this.contentVisible){if(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=eb(this.ctx),t){let e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax(eb(this.ctx),t),this.clip(),this.endPath()}}}paintFormXObjectEnd(){if(!!this.contentVisible)this.restore(),this.baseTransform=this.baseTransformStack.pop()}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let t=this.ctx;!e.isolated&&S("TODO: Support non-isolated groups."),e.knockout&&E("Knockout groups not supported.");let n=eb(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw Error("Bounding box is required.");let i=U.getAxialAlignedBoundingBox(e.bbox,eb(t)),r=[0,0,t.canvas.width,t.canvas.height],s=Math.floor((i=U.intersect(i,r)||[0,0,0,0])[0]),o=Math.floor(i[1]),a=Math.max(Math.ceil(i[2])-s,1),l=Math.max(Math.ceil(i[3])-o,1);this.current.startNewPathAndClipBox([0,0,a,l]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);let c=this.cachedCanvases.getCanvas(d,a,l),h=c.context;h.translate(-s,-o),h.transform(...n),e.smask?this.smaskStack.push({canvas:c.canvas,context:h,offsetX:s,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(s,o),t.save()),e5(t,h),this.ctx=h,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let t=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let e=eb(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);let n=U.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,i,r){if(this.#tw(),e3(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){let i=t[2]-t[0],s=t[3]-t[1];if(r&&this.annotationCanvasMap){n=n.slice(),n[4]-=t[0],n[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=i,t[3]=s;let[r,o]=U.singularValueDecompose2dScale(eb(this.ctx)),{viewportScale:a}=this,l=Math.ceil(i*this.outputScaleX*a),d=Math.ceil(s*this.outputScaleY*a);this.annotationCanvas=this.canvasFactory.create(l,d);let{canvas:c,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,c),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(r,0,0,-o,0,s*o),e3(this.ctx)}else e3(this.ctx),this.ctx.rect(t[0],t[1],i,s),this.ctx.clip(),this.endPath()}this.current=new e0(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#t_(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;(e=this.getObject(e.data,e)).count=t;let n=this.ctx,i=this.processingType3;if(i&&(void 0===i.compiled&&(i.compiled=function(e){let t,n,i;let{width:r,height:s}=e;if(r>1e3||s>1e3)return null;let o=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=r+1,l=new Uint8Array(a*(s+1)),d=r+7&-8,c=new Uint8Array(d*s),h=0;for(let t of e.data){let e=128;for(;e>0;)c[h++]=t&e?0:255,e>>=1}let u=0;for(0!==c[h=0]&&(l[0]=1,++u),n=1;n<r;n++)c[h]!==c[h+1]&&(l[n]=c[h]?2:1,++u),h++;for(0!==c[h]&&(l[n]=2,++u),t=1;t<s;t++){h=t*d,i=t*a,c[h-d]!==c[h]&&(l[i]=c[h]?1:8,++u);let e=(c[h]?4:0)+(c[h-d]?8:0);for(n=1;n<r;n++)o[e=(e>>2)+(c[h+1]?4:0)+(c[h-d+1]?8:0)]&&(l[i+n]=o[e],++u),h++;if(c[h-d]!==c[h]&&(l[i+n]=c[h]?2:4,++u),u>1e3)return null}for(h=d*(s-1),i=t*a,0!==c[h]&&(l[i]=8,++u),n=1;n<r;n++)c[h]!==c[h+1]&&(l[i+n]=c[h]?4:8,++u),h++;if(0!==c[h]&&(l[i+n]=4,++u),u>1e3)return null;let p=new Int32Array([0,a,-1,0,-a,0,0,0,1]),f=new Path2D;for(t=0;u&&t<=s;t++){let e=t*a,n=e+r;for(;e<n&&!l[e];)e++;if(e===n)continue;f.moveTo(e%a,t);let i=e,s=l[e];do{let t=p[s];do e+=t;while(!l[e]);let n=l[e];5!==n&&10!==n?(s=n,l[e]=0):(s=n&51*s>>4,l[e]&=s>>2|s<<2),f.lineTo(e%a,e/a|0),!l[e]&&--u}while(i!==e);--t}return c=null,l=null,function(e){e.save(),e.scale(1/r,-1/s),e.translate(0,-s),e.fill(f),e.beginPath(),e.restore()}}(e)),i.compiled)){i.compiled(n);return}let r=this._createMaskCanvas(e),s=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(s,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,i=0,r,s){if(!this.contentVisible)return;e=this.getObject(e.data,e);let o=this.ctx;o.save();let a=eb(o);o.transform(t,n,i,r,0,0);let l=this._createMaskCanvas(e);o.setTransform(1,0,0,1,l.offsetX-a[4],l.offsetY-a[5]);for(let e=0,d=s.length;e<d;e+=2){let d=U.transform(a,[t,n,i,r,s[e],s[e+1]]),[c,h]=U.applyTransform([0,0],d);o.drawImage(l.canvas,c,h)}o.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;let t=this.ctx,n=this.current.fillColor,i=this.current.patternFill;for(let r of e){let{data:e,width:s,height:o,transform:a}=r,l=this.cachedCanvases.getCanvas("maskCanvas",s,o),d=l.context;d.save(),e2(d,this.getObject(e,r)),d.globalCompositeOperation="source-in",d.fillStyle=i?n.getPattern(d,this,ey(t),eV.FILL):n,d.fillRect(0,0,s,o),d.restore(),t.save(),t.transform(...a),t.scale(1,-1),eQ(t,l.canvas,0,0,s,o,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);if(!t){E("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t)}paintImageXObjectRepeat(e,t,n,i){if(!this.contentVisible)return;let r=this.getObject(e);if(!r){E("Dependent image isn't ready yet");return}let s=r.width,o=r.height,a=[];for(let e=0,r=i.length;e<r;e+=2)a.push({transform:[t,0,0,n,i[e],i[e+1]],x:0,y:0,w:s,h:o});this.paintInlineImageXObjectGroup(r,a)}applyTransferMapsToCanvas(e){return"none"!==this.current.transferMaps&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if("none"===this.current.transferMaps)return e.bitmap;let{bitmap:t,width:n,height:i}=e,r=this.cachedCanvases.getCanvas("inlineImage",n,i),s=r.context;return s.filter=this.current.transferMaps,s.drawImage(t,0,0),s.filter="none",r.canvas}paintInlineImageXObject(e){let t;if(!this.contentVisible)return;let n=e.width,i=e.height,r=this.ctx;if(this.save(),!o){let{filter:e}=r;"none"!==e&&""!==e&&(r.filter="none")}if(r.scale(1/n,-1/i),e.bitmap)t=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)t=e;else{let r=this.cachedCanvases.getCanvas("inlineImage",n,i).context;e1(r,e),t=this.applyTransferMapsToCanvas(r)}let s=this._scaleImage(t,ey(r));r.imageSmoothingEnabled=e4(eb(r),e.interpolate),eQ(r,s.img,0,0,s.paintWidth,s.paintHeight,0,-i,n,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){let n;if(!this.contentVisible)return;let i=this.ctx;if(e.bitmap)n=e.bitmap;else{let t=e.width,i=e.height,r=this.cachedCanvases.getCanvas("inlineImage",t,i).context;e1(r,e),n=this.applyTransferMapsToCanvas(r)}for(let e of t)i.save(),i.transform(...e.transform),i.scale(1,-1),eQ(i,n,e.x,e.y,e.w,e.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){if(!!this.contentVisible)this.ctx.fillRect(0,0,1,1),this.compose()}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),!this.pendingClip&&this.compose(e);let n=this.ctx;this.pendingClip&&(!t&&(this.pendingClip===e9?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=eb(this.ctx);if(0===e[1]&&0===e[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),i=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,i)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let e,t;let{lineWidth:n}=this.current,{a:i,b:r,c:s,d:o}=this.ctx.getTransform();if(0===r&&0===s){let r=Math.abs(i),s=Math.abs(o);if(r===s){if(0===n)e=t=1/r;else{let i=r*n;e=t=i<1?1/i:1}}else if(0===n)e=1/r,t=1/s;else{let i=r*n,o=s*n;e=i<1?1/i:1,t=o<1?1/o:1}}else{let a=Math.abs(i*o-r*s),l=Math.hypot(i,r),d=Math.hypot(s,o);if(0===n)e=d/a,t=l/a;else{let i=n*a;e=d>i?d/i:1,t=l>i?l/i:1}}this._cachedScaleForStroking[0]=e,this._cachedScaleForStroking[1]=t}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:n}=this.current,[i,r]=this.getScaleForStroking();if(t.lineWidth=n||1,1===i&&1===r){t.stroke();return}let s=t.getLineDash();if(e&&t.save(),t.scale(i,r),s.length>0){let e=Math.max(i,r);t.setLineDash(s.map(t=>t/e)),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}for(let e in x)void 0!==te.prototype[e]&&(te.prototype[x[e]]=te.prototype[e]);class tt{static #tS=null;static #tE="";static get workerPort(){return this.#tS}static set workerPort(e){if(!("undefined"!=typeof Worker&&e instanceof Worker)&&null!==e)throw Error("Invalid `workerPort` type.");this.#tS=e}static get workerSrc(){return this.#tE}static set workerSrc(e){if("string"!=typeof e)throw Error("Invalid `workerSrc` type.");this.#tE=e}}let tn={DATA:1,ERROR:2},ti={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function tr(e){switch(!(e instanceof Error||"object"==typeof e&&null!==e)&&C('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new P(e.message);case"MissingPDFException":return new N(e.message);case"PasswordException":return new D(e.message,e.code);case"UnexpectedResponseException":return new R(e.message,e.status);case"UnknownErrorException":return new O(e.message,e.details);default:return new O(e.message,e.toString())}}class ts{constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=e=>{let t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream){this.#tC(t);return}if(t.callback){let e=t.callbackId,n=this.callbackCapabilities[e];if(!n)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===tn.DATA)n.resolve(t.data);else if(t.callback===tn.ERROR)n.reject(tr(t.reason));else throw Error("Unexpected callback case");return}let i=this.actionHandler[t.action];if(!i)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let e=this.sourceName,r=t.sourceName;new Promise(function(e){e(i(t.data))}).then(function(i){n.postMessage({sourceName:e,targetName:r,callback:tn.DATA,callbackId:t.callbackId,data:i})},function(i){n.postMessage({sourceName:e,targetName:r,callback:tn.ERROR,callbackId:t.callbackId,reason:tr(i)})});return}if(t.streamId){this.#tA(t);return}i(t.data)},n.addEventListener("message",this._onComObjOnMessage)}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},n)}catch(e){r.reject(e)}return r.promise}sendWithStream(e,t,n,i){let r=this.streamId++,s=this.sourceName,o=this.targetName,a=this.comObj;return new ReadableStream({start:n=>{let l=Promise.withResolvers();return this.streamControllers[r]={controller:n,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},a.postMessage({sourceName:s,targetName:o,action:e,streamId:r,data:t,desiredSize:n.desiredSize},i),l.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[r].pullCall=t,a.postMessage({sourceName:s,targetName:o,stream:ti.PULL,streamId:r,desiredSize:e.desiredSize}),t.promise},cancel:e=>{A(e instanceof Error,"cancel must have a valid reason");let t=Promise.withResolvers();return this.streamControllers[r].cancelCall=t,this.streamControllers[r].isClosed=!0,a.postMessage({sourceName:s,targetName:o,stream:ti.CANCEL,streamId:r,reason:tr(e)}),t.promise}},n)}#tA(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,s=this,o=this.actionHandler[e.action],a={enqueue(e,s=1,o){if(this.isCancelled)return;let a=this.desiredSize;this.desiredSize-=s,a>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:n,targetName:i,stream:ti.ENQUEUE,streamId:t,chunk:e},o)},close(){if(!this.isCancelled)this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:ti.CLOSE,streamId:t}),delete s.streamSinks[t]},error(e){if(A(e instanceof Error,"error must have a valid reason"),!this.isCancelled)this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:ti.ERROR,streamId:t,reason:tr(e)})},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};a.sinkCapability.resolve(),a.ready=a.sinkCapability.promise,this.streamSinks[t]=a,new Promise(function(t){t(o(e.data,a))}).then(function(){r.postMessage({sourceName:n,targetName:i,stream:ti.START_COMPLETE,streamId:t,success:!0})},function(e){r.postMessage({sourceName:n,targetName:i,stream:ti.START_COMPLETE,streamId:t,reason:tr(e)})})}#tC(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,s=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case ti.START_COMPLETE:e.success?s.startCall.resolve():s.startCall.reject(tr(e.reason));break;case ti.PULL_COMPLETE:e.success?s.pullCall.resolve():s.pullCall.reject(tr(e.reason));break;case ti.PULL:if(!o){r.postMessage({sourceName:n,targetName:i,stream:ti.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,new Promise(function(e){e(o.onPull?.())}).then(function(){r.postMessage({sourceName:n,targetName:i,stream:ti.PULL_COMPLETE,streamId:t,success:!0})},function(e){r.postMessage({sourceName:n,targetName:i,stream:ti.PULL_COMPLETE,streamId:t,reason:tr(e)})});break;case ti.ENQUEUE:if(A(s,"enqueue should have stream controller"),s.isClosed)break;s.controller.enqueue(e.chunk);break;case ti.CLOSE:if(A(s,"close should have stream controller"),s.isClosed)break;s.isClosed=!0,s.controller.close(),this.#tk(s,t);break;case ti.ERROR:A(s,"error should have stream controller"),s.controller.error(tr(e.reason)),this.#tk(s,t);break;case ti.CANCEL_COMPLETE:e.success?s.cancelCall.resolve():s.cancelCall.reject(tr(e.reason)),this.#tk(s,t);break;case ti.CANCEL:if(!o)break;new Promise(function(t){t(o.onCancel?.(tr(e.reason)))}).then(function(){r.postMessage({sourceName:n,targetName:i,stream:ti.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){r.postMessage({sourceName:n,targetName:i,stream:ti.CANCEL_COMPLETE,streamId:t,reason:tr(e)})}),o.sinkCapability.reject(tr(e.reason)),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error("Unexpected stream case")}}async #tk(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class to{#tT;#tM;constructor({parsedData:e,rawData:t}){this.#tT=e,this.#tM=t}getRaw(){return this.#tM}get(e){return this.#tT.get(e)??null}getAll(){return B(this.#tT)}has(e){return this.#tT.has(e)}}let ta=Symbol("INTERNAL");class tl{#tD=!1;#tO=!1;#tI=!1;#tN=!0;constructor(e,{name:t,intent:n,usage:i}){this.#tD=!!(e&d.DISPLAY),this.#tO=!!(e&d.PRINT),this.name=t,this.intent=n,this.usage=i}get visible(){if(this.#tI)return this.#tN;if(!this.#tN)return!1;let{print:e,view:t}=this.usage;return this.#tD?t?.viewState!=="OFF":!this.#tO||e?.printState!=="OFF"}_setVisible(e,t,n=!1){e!==ta&&C("Internal method `_setVisible` called."),this.#tI=n,this.#tN=t}}class td{#tR=null;#tL=new Map;#tP=null;#tj=null;constructor(e,t=d.DISPLAY){if(this.renderingIntent=t,this.name=null,this.creator=null,null===e)return;for(let n of(this.name=e.name,this.creator=e.creator,this.#tj=e.order,e.groups))this.#tL.set(n.id,new tl(t,n));if("OFF"===e.baseState)for(let e of this.#tL.values())e._setVisible(ta,!1);for(let t of e.on)this.#tL.get(t)._setVisible(ta,!0);for(let t of e.off)this.#tL.get(t)._setVisible(ta,!1);this.#tP=this.getHash()}#tF(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let i=1;i<t;i++){let t;let r=e[i];if(Array.isArray(r))t=this.#tF(r);else{if(!this.#tL.has(r))return E(`Optional content group not found: ${r}`),!0;t=this.#tL.get(r).visible}switch(n){case"And":if(!t)return!1;break;case"Or":if(t)return!0;break;case"Not":return!t;default:return!0}}return"And"===n}isVisible(e){if(0===this.#tL.size)return!0;if(!e)return S("Optional content group not defined."),!0;if("OCG"===e.type)return this.#tL.has(e.id)?this.#tL.get(e.id).visible:(E(`Optional content group not found: ${e.id}`),!0);if("OCMD"===e.type){if(e.expression)return this.#tF(e.expression);if(e.policy&&"AnyOn"!==e.policy){if("AllOn"===e.policy){for(let t of e.ids){if(!this.#tL.has(t)){E(`Optional content group not found: ${t}`);break}if(!this.#tL.get(t).visible)return!1}return!0}else if("AnyOff"===e.policy){for(let t of e.ids){if(!this.#tL.has(t))return E(`Optional content group not found: ${t}`),!0;if(!this.#tL.get(t).visible)return!0}return!1}else if("AllOff"===e.policy){for(let t of e.ids){if(!this.#tL.has(t)){E(`Optional content group not found: ${t}`);break}if(this.#tL.get(t).visible)return!1}return!0}}else{for(let t of e.ids){if(!this.#tL.has(t))return E(`Optional content group not found: ${t}`),!0;if(this.#tL.get(t).visible)return!0}return!1}return E(`Unknown optional content policy ${e.policy}.`),!0}return E(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0){let n=this.#tL.get(e);if(!n){E(`Optional content group not found: ${e}`);return}n._setVisible(ta,!!t,!0),this.#tR=null}setOCGState({state:e,preserveRB:t}){let n;for(let t of e){switch(t){case"ON":case"OFF":case"Toggle":n=t;continue}let e=this.#tL.get(t);if(!!e)switch(n){case"ON":e._setVisible(ta,!0);break;case"OFF":e._setVisible(ta,!1);break;case"Toggle":e._setVisible(ta,!e.visible)}}this.#tR=null}get hasInitialVisibility(){return null===this.#tP||this.getHash()===this.#tP}getOrder(){return this.#tL.size?this.#tj?this.#tj.slice():[...this.#tL.keys()]:null}getGroups(){return this.#tL.size>0?B(this.#tL):null}getGroup(e){return this.#tL.get(e)||null}getHash(){if(null!==this.#tR)return this.#tR;let e=new eN;for(let[t,n]of this.#tL)e.update(`${t}:${n.visible}`);return this.#tR=e.hexdigest()}}class tc{constructor(e,{disableRange:t=!1,disableStream:n=!1}){A(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:i,initialData:r,progressiveDone:s,contentDispositionFilename:o}=e;if(this._queuedChunks=[],this._progressiveDone=s,this._contentDispositionFilename=o,r?.length>0){let e=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!t,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((e,t)=>{this._onReceiveData({begin:e,chunk:t})}),e.addProgressListener((e,t)=>{this._onProgress({loaded:e,total:t})}),e.addProgressiveReadListener(e=>{this._onReceiveData({chunk:e})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:t}){let n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;void 0===e?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):A(this._rangeReaders.some(function(t){return t._begin===e&&(t._enqueue(n),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){void 0===e.total?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){A(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let e=this._queuedChunks;return this._queuedChunks=null,new th(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new tu(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){for(let t of(this._fullRequestReader?.cancel(e),this._rangeReaders.slice(0)))t.cancel(e);this._pdfDataRangeTransport.abort()}}class th{constructor(e,t,n=!1,i=null){for(let r of(this._stream=e,this._done=n||!1,this._filename=el(i)?i:null,this._queuedChunks=t||[],this._loaded=0,this._queuedChunks))this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){if(!this._done)this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){for(let e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){if(!this._done)this._done=!0}}class tu{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{for(let t of(this._requests.shift().resolve({value:e,done:!1}),this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){for(let e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function tp({getResponseHeader:e,isHttp:t,rangeChunkSize:n,disableRange:i}){let r={allowRangeRequests:!1,suggestedLength:void 0},s=parseInt(e("Content-Length"),10);return Number.isInteger(s)?(r.suggestedLength=s,s<=2*n||i||!t||"bytes"!==e("Accept-Ranges")||"identity"!==(e("Content-Encoding")||"identity"))?r:(r.allowRangeRequests=!0,r):r}function tf(e){let t=e("Content-Disposition");if(t){let e=function(e){let t=!0,n=i("filename\\*","i").exec(e);if(n){let e=o(n=n[1]);return s(e=l(e=a(e=unescape(e))))}if(n=function(e){let t;let n=[],r=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(t=r.exec(e));){let[,e,i,r]=t;if((e=parseInt(e,10))in n){if(0===e)break;continue}n[e]=[i,r]}let s=[];for(let e=0;e<n.length&&e in n;++e){;let[t,i]=n[e];i=o(i),t&&(i=unescape(i),0===e&&(i=a(i))),s.push(i)}return s.join("")}(e))return s(l(n));if(n=i("filename","i").exec(e)){let e=o(n=n[1]);return s(e=l(e))}function i(e,t){return RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function r(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{let i=new TextDecoder(e,{fatal:!0}),r=F(n);n=i.decode(r),t=!1}catch{}}return n}function s(e){return t&&/[\x80-\xff]/.test(e)&&(e=r("utf-8",e),t&&(e=r("iso-8859-1",e))),e}function o(e){if(e.startsWith('"')){let t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){let n=t[e].indexOf('"');-1!==n&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function a(e){let t=e.indexOf("'");if(-1===t)return e;let n=e.slice(0,t);return r(n,e.slice(t+1).replace(/^[^']*'/,""))}function l(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(e,t,n,i){if("q"===n||"Q"===n)return r(t,i=(i=i.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}));try{i=atob(i)}catch{}return r(t,i)})}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(el(e))return e}return null}function tm(e,t){return 404===e||0===e&&t.startsWith("file:")?new N('Missing PDF "'+t+'".'):new R(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function tg(e){return 200===e||206===e}function tv(e,t,n){return{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function tb(e){let t=new Headers;for(let n in e){let i=e[n];if(void 0!==i)t.append(n,i)}return t}function ty(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(E(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}class tx{constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return A(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new tw(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new t_(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){for(let t of(this._fullRequestReader?.cancel(e),this._rangeRequestReaders.slice(0)))t.cancel(e)}}class tw{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;let t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._headers=tb(this._stream.httpHeaders);let n=t.url;fetch(n,tv(this._headers,this._withCredentials,this._abortController)).then(e=>{if(!tg(e.status))throw tm(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();let t=t=>e.headers.get(t),{allowRangeRequests:i,suggestedLength:r}=tp({getResponseHeader:t,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=r||this._contentLength,this._filename=tf(t),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new P("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:ty(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class t_{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;let i=e.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=tb(this._stream.httpHeaders),this._headers.append("Range",`bytes=${t}-${n-1}`);let r=i.url;fetch(r,tv(this._headers,this._withCredentials,this._abortController)).then(e=>{if(!tg(e.status))throw tm(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:ty(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class tS{constructor(e,t={}){this.url=e,this.isHttp=/^https?:/i.test(e),this.httpHeaders=this.isHttp&&t.httpHeaders||Object.create(null),this.withCredentials=t.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(e,t,n){let i={begin:e,end:t};for(let e in n)i[e]=n[e];return this.request(i)}requestFull(e){return this.request(e)}request(e){let t=new XMLHttpRequest,n=this.currXhrId++,i=this.pendingRequests[n]={xhr:t};for(let e in t.open("GET",this.url),t.withCredentials=this.withCredentials,this.httpHeaders){let n=this.httpHeaders[e];if(void 0!==n)t.setRequestHeader(e,n)}return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.expectedStatus=206):i.expectedStatus=200,t.responseType="arraybuffer",e.onError&&(t.onerror=function(n){e.onError(t.status)}),t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),i.onHeadersReceived=e.onHeadersReceived,i.onDone=e.onDone,i.onError=e.onError,i.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){let n=this.pendingRequests[e];if(!!n)n.onProgress?.(t)}onStateChange(e,t){let n=this.pendingRequests[e];if(!n)return;let i=n.xhr;if(i.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),4!==i.readyState||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===i.status&&this.isHttp){n.onError?.(i.status);return}let r=i.status||200;if(!(200===r&&206===n.expectedStatus)&&r!==n.expectedStatus){n.onError?.(i.status);return}let s=function(e){let t=e.response;return"string"!=typeof t?t:F(t).buffer}(i);if(206===r){let e=i.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);n.onDone({begin:parseInt(t[1],10),chunk:s})}else s?n.onDone({begin:0,chunk:s}):n.onError?.(i.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}class tE{constructor(e){this._source=e,this._manager=new tS(e.url,{httpHeaders:e.httpHeaders,withCredentials:e.withCredentials}),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return A(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new tC(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let n=new tA(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){for(let t of(this._fullRequestReader?.cancel(e),this._rangeRequestReaders.slice(0)))t.cancel(e)}}class tC{constructor(e,t){this._manager=e;let n={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._fullRequestId=e.requestFull(n),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e),n=e=>t.getResponseHeader(e),{allowRangeRequests:i,suggestedLength:r}=tp({getResponseHeader:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=tf(n),this._isRangeSupported&&this._manager.abortRequest(e),this._headersReceivedCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){for(let t of(this._storedError=tm(e,this._url),this._headersReceivedCapability.reject(this._storedError),this._requests))t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){for(let t of(this._done=!0,this._headersReceivedCapability.reject(e),this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class tA{constructor(e,t,n){this._manager=e;let i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._requestId=e.requestRange(t,n,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(e){let t=e.chunk;for(let e of(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){for(let t of(this._storedError=tm(e,this._url),this._requests))t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){!this.isStreamingSupported&&this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){for(let e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}let tk=/^file:\/\/\/[a-zA-Z]:\//;class tT{constructor(e){this.source=e,this.url=function(e){let t=eH.get("url"),n=t.parse(e);return"file:"===n.protocol||n.host?n:/^[a-z]:[/\\]/i.test(e)?t.parse(`file:///${e}`):(!n.host&&(n.protocol="file:"),n)}(e.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return A(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new tR(this):new tI(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=this.isFsUrl?new tL(this,e,t):new tN(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){for(let t of(this._fullRequestReader?.cancel(e),this._rangeRequestReaders.slice(0)))t.cancel(e)}}class tM{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new P("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class tD{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function tO(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class tI extends tM{constructor(e){super(e);let t=t=>{if(404===t.statusCode){let e=new N(`Missing PDF "${this._url}".`);this._storedError=e,this._headersCapability.reject(e);return}this._headersCapability.resolve(),this._setReadableStream(t);let n=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:i,suggestedLength:r}=tp({getResponseHeader:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=r||this._contentLength,this._filename=tf(n)};if(this._request=null,"http:"===this._url.protocol){let n=eH.get("http");this._request=n.request(tO(this._url,e.httpHeaders),t)}else{let n=eH.get("https");this._request=n.request(tO(this._url,e.httpHeaders),t)}this._request.on("error",e=>{this._storedError=e,this._headersCapability.reject(e)}),this._request.end()}}class tN extends tD{constructor(e,t,n){for(let t in super(e),this._httpHeaders={},e.httpHeaders){let n=e.httpHeaders[t];if(void 0!==n)this._httpHeaders[t]=n}this._httpHeaders.Range=`bytes=${t}-${n-1}`;let i=e=>{if(404===e.statusCode){let e=new N(`Missing PDF "${this._url}".`);this._storedError=e;return}this._setReadableStream(e)};if(this._request=null,"http:"===this._url.protocol){let e=eH.get("http");this._request=e.request(tO(this._url,this._httpHeaders),i)}else{let e=eH.get("https");this._request=e.request(tO(this._url,this._httpHeaders),i)}this._request.on("error",e=>{this._storedError=e}),this._request.end()}}class tR extends tM{constructor(e){super(e);let t=decodeURIComponent(this._url.path);tk.test(this._url.href)&&(t=t.replace(/^\//,""));let n=eH.get("fs");n.promises.lstat(t).then(e=>{this._contentLength=e.size,this._setReadableStream(n.createReadStream(t)),this._headersCapability.resolve()},e=>{"ENOENT"===e.code&&(e=new N(`Missing PDF "${t}".`)),this._storedError=e,this._headersCapability.reject(e)})}}class tL extends tD{constructor(e,t,n){super(e);let i=decodeURIComponent(this._url.path);tk.test(this._url.href)&&(i=i.replace(/^\//,""));let r=eH.get("fs");this._setReadableStream(r.createReadStream(i,{start:t,end:n-1}))}}class tP{#tB=Promise.withResolvers();#eg=null;#tz=!1;#tH=!!globalThis.FontInspector?.enabled;#tU=null;#tV=null;#t$=0;#tW=0;#tG=null;#tZ=null;#tq=0;#tK=0;#tY=Object.create(null);#tX=[];#tJ=null;#tQ=[];#t0=new WeakMap;#t1=null;static #t2=new Map;static #t5=new Map;static #t3=null;static #t4=new Set;constructor({textContentSource:e,container:t,viewport:n}){if(e instanceof ReadableStream)this.#tJ=e;else if("object"==typeof e)this.#tJ=new ReadableStream({start(t){t.enqueue(e),t.close()}});else throw Error('No "textContentSource" parameter specified.');this.#eg=this.#tZ=t,this.#tK=n.scale*(globalThis.devicePixelRatio||1),this.#tq=n.rotation,this.#tV={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};let{pageWidth:i,pageHeight:r,pageX:s,pageY:o}=n.rawDims;this.#t1=[1,0,0,-1,-s,o+r],this.#tW=i,this.#t$=r,tP.#t6(),ex(t,n),this.#tB.promise.catch(()=>{}).then(()=>{tP.#t4.delete(this),this.#tV=null,this.#tY=null})}render(){let e=()=>{this.#tG.read().then(({value:t,done:n})=>{if(n){this.#tB.resolve();return}this.#tU??=t.lang,Object.assign(this.#tY,t.styles),this.#t8(t.items),e()},this.#tB.reject)};return this.#tG=this.#tJ.getReader(),tP.#t4.add(this),e(),this.#tB.promise}update({viewport:e,onBefore:t=null}){let n=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==this.#tq&&(t?.(),this.#tq=i,ex(this.#tZ,{rotation:i})),n!==this.#tK){t?.(),this.#tK=n;let e={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:tP.#t7(this.#tU)};for(let t of this.#tQ)e.properties=this.#t0.get(t),e.div=t,this.#t9(e)}}cancel(){let e=new P("TextLayer task cancelled.");this.#tG?.cancel(e).catch(()=>{}),this.#tG=null,this.#tB.reject(e)}get textDivs(){return this.#tQ}get textContentItemsStr(){return this.#tX}#t8(e){if(this.#tz)return;this.#tV.ctx??=tP.#t7(this.#tU);let t=this.#tQ,n=this.#tX;for(let i of e){if(t.length>1e5){E("Ignoring additional textDivs for performance reasons."),this.#tz=!0;return}if(void 0===i.str){if("beginMarkedContentProps"===i.type||"beginMarkedContent"===i.type){let e=this.#eg;this.#eg=document.createElement("span"),this.#eg.classList.add("markedContent"),null!==i.id&&this.#eg.setAttribute("id",`${i.id}`),e.append(this.#eg)}else"endMarkedContent"===i.type&&(this.#eg=this.#eg.parentNode);continue}n.push(i.str),this.#ne(i)}}#ne(e){let t,n;let i=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#tQ.push(i);let s=U.transform(this.#t1,e.transform),o=Math.atan2(s[1],s[0]),a=this.#tY[e.fontName];a.vertical&&(o+=Math.PI/2);let l=this.#tH&&a.fontSubstitution||a.fontFamily,d=Math.hypot(s[2],s[3]),c=d*tP.#nt(l,this.#tU);0===o?(t=s[4],n=s[5]-c):(t=s[4]+c*Math.sin(o),n=s[5]-c*Math.cos(o));let h="calc(var(--scale-factor)*",u=i.style;this.#eg===this.#tZ?(u.left=`${(100*t/this.#tW).toFixed(2)}%`,u.top=`${(100*n/this.#t$).toFixed(2)}%`):(u.left=`${h}${t.toFixed(2)}px)`,u.top=`${h}${n.toFixed(2)}px)`),u.fontSize=`${h}${(tP.#t3*d).toFixed(2)}px)`,u.fontFamily=l,r.fontSize=d,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#tH&&(i.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),0!==o&&(r.angle=180/Math.PI*o);let p=!1;if(e.str.length>1)p=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){let t=Math.abs(e.transform[0]),n=Math.abs(e.transform[3]);t!==n&&Math.max(t,n)/Math.min(t,n)>1.5&&(p=!0)}if(p&&(r.canvasWidth=a.vertical?e.height:e.width),this.#t0.set(i,r),this.#tV.div=i,this.#tV.properties=r,this.#t9(this.#tV),r.hasText&&this.#eg.append(i),r.hasEOL){let e=document.createElement("br");e.setAttribute("role","presentation"),this.#eg.append(e)}}#t9(e){let{div:t,properties:n,ctx:i,prevFontSize:r,prevFontFamily:s}=e,{style:o}=t,a="";if(tP.#t3>1&&(a=`scale(${1/tP.#t3})`),0!==n.canvasWidth&&n.hasText){let{fontFamily:l}=o,{canvasWidth:d,fontSize:c}=n;(r!==c||s!==l)&&(i.font=`${c*this.#tK}px ${l}`,e.prevFontSize=c,e.prevFontFamily=l);let{width:h}=i.measureText(t.textContent);h>0&&(a=`scaleX(${d*this.#tK/h}) ${a}`)}0!==n.angle&&(a=`rotate(${n.angle}deg) ${a}`),a.length>0&&(o.transform=a)}static cleanup(){if(!(this.#t4.size>0)){for(let{canvas:e}of(this.#t2.clear(),this.#t5.values()))e.remove();this.#t5.clear()}}static #t7(e=null){let t=this.#t5.get(e||="");if(!t){let n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=e,document.body.append(n),t=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#t5.set(e,t)}return t}static #t6(){if(null!==this.#t3)return;let e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.textContent="X",document.body.append(e),this.#t3=e.getBoundingClientRect().height,e.remove()}static #nt(e,t){let n=this.#t2.get(e);if(n)return n;let i=this.#t7(t),r=i.font;i.canvas.width=i.canvas.height=30,i.font=`30px ${e}`;let s=i.measureText(""),o=s.fontBoundingBoxAscent,a=Math.abs(s.fontBoundingBoxDescent);if(o){let t=o/(o+a);return this.#t2.set(e,t),i.canvas.width=i.canvas.height=0,i.font=r,t}i.strokeStyle="red",i.clearRect(0,0,30,30),i.strokeText("g",0,0);let l=i.getImageData(0,0,30,30).data;a=0;for(let e=l.length-1-3;e>=0;e-=4)if(l[e]>0){a=Math.ceil(e/4/30);break}i.clearRect(0,0,30,30),i.strokeText("A",0,30),l=i.getImageData(0,0,30,30).data,o=0;for(let e=0,t=l.length;e<t;e+=4)if(l[e]>0){o=30-Math.floor(e/4/30);break}i.canvas.width=i.canvas.height=0,i.font=r;let d=o?o/(o+a):.8;return this.#t2.set(e,d),d}}function tj(){ef("`renderTextLayer`, please use `TextLayer` instead.");let{textContentSource:e,container:t,viewport:n,...i}=arguments[0],r=Object.keys(i);r.length>0&&E("Ignoring `renderTextLayer` parameters: "+r.join(", "));let s=new tP({textContentSource:e,container:t,viewport:n}),{textDivs:o,textContentItemsStr:a}=s;return{promise:s.render(),textDivs:o,textContentItemsStr:a}}function tF(){ef("`updateTextLayer`, please use `TextLayer` instead.")}class tB{static textContent(e){let t=[],n={items:t,styles:Object.create(null)};return!function e(n){if(!n)return;let i=null,r=n.name;if("#text"===r)i=n.value;else{if(!tB.shouldBuildText(r))return;n?.attributes?.textContent?i=n.attributes.textContent:n.value&&(i=n.value)}if(null!==i&&t.push({str:i}),!!n.children)for(let t of n.children)e(t)}(e),n}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}let tz=o?class e extends K{_createCanvas(e,t){return eH.get("canvas").createCanvas(e,t)}}:class e extends K{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}={}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement("canvas");return n.width=e,n.height=t,n}},tH=o?class e extends Y{_fetchData(e,t){return eU(e).then(e=>({cMapData:e,compressionType:t}))}}:en,tU=o?class e extends q{}:class e extends q{#nn;#ni;#nr;#ns;#no;#v=0;constructor({docId:e,ownerDocument:t=globalThis.document}={}){super(),this.#nr=e,this.#ns=t}get #y(){return this.#nn||=new Map}get #na(){return this.#no||=new Map}get #nl(){if(!this.#ni){let e=this.#ns.createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;let n=this.#ns.createElementNS(Q,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#ni=this.#ns.createElementNS(Q,"defs"),e.append(n),n.append(this.#ni),this.#ns.body.append(e)}return this.#ni}#nd(e){if(1===e.length){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let i=n.join(",");return[i,i,i]}let[t,n,i]=e,r=Array(256),s=Array(256),o=Array(256);for(let e=0;e<256;e++)r[e]=t[e]/255,s[e]=n[e]/255,o[e]=i[e]/255;return[r.join(","),s.join(","),o.join(",")]}addFilter(e){if(!e)return"none";let t=this.#y.get(e);if(t)return t;let[n,i,r]=this.#nd(e),s=1===e.length?n:`${n}${i}${r}`;if(t=this.#y.get(s))return this.#y.set(e,t),t;let o=`g_${this.#nr}_transfer_map_${this.#v++}`,a=`url(#${o})`;this.#y.set(e,a),this.#y.set(s,a);let l=this.#nc(o);return this.#nh(n,i,r,l),a}addHCMFilter(e,t){let n=`${e}-${t}`,i="base",r=this.#na.get(i);if(r?.key===n)return r.url;if(r?(r.filter?.remove(),r.key=n,r.url="none",r.filter=null):(r={key:n,url:"none",filter:null},this.#na.set(i,r)),!e||!t)return r.url;let s=this.#nu(e);e=U.makeHexColor(...s);let o=this.#nu(t);if(t=U.makeHexColor(...o),this.#nl.style.color="","#000000"===e&&"#ffffff"===t||e===t)return r.url;let a=Array(256);for(let e=0;e<=255;e++){let t=e/255;a[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}let l=a.join(","),d=`g_${this.#nr}_hcm_filter`,c=r.filter=this.#nc(d);this.#nh(l,l,l,c),this.#np(c);let h=(e,t)=>{let n=s[e]/255,i=o[e]/255,r=Array(t+1);for(let e=0;e<=t;e++)r[e]=n+e/t*(i-n);return r.join(",")};return this.#nh(h(0,5),h(1,5),h(2,5),c),r.url=`url(#${d})`,r.url}addAlphaFilter(e){let t=this.#y.get(e);if(t)return t;let[n]=this.#nd([e]),i=`alpha_${n}`;if(t=this.#y.get(i))return this.#y.set(e,t),t;let r=`g_${this.#nr}_alpha_map_${this.#v++}`,s=`url(#${r})`;this.#y.set(e,s),this.#y.set(i,s);let o=this.#nc(r);return this.#nf(n,o),s}addLuminosityFilter(e){let t,n,i=this.#y.get(e||"luminosity");if(i)return i;if(e?([t]=this.#nd([e]),n=`luminosity_${t}`):n="luminosity",i=this.#y.get(n))return this.#y.set(e,i),i;let r=`g_${this.#nr}_luminosity_map_${this.#v++}`,s=`url(#${r})`;this.#y.set(e,s),this.#y.set(n,s);let o=this.#nc(r);return this.#nm(o),e&&this.#nf(t,o),s}addHighlightHCMFilter(e,t,n,i,r){let s=`${t}-${n}-${i}-${r}`,o=this.#na.get(e);if(o?.key===s)return o.url;if(o?(o.filter?.remove(),o.key=s,o.url="none",o.filter=null):(o={key:s,url:"none",filter:null},this.#na.set(e,o)),!t||!n)return o.url;let[a,l]=[t,n].map(this.#nu.bind(this)),d=Math.round(.2126*a[0]+.7152*a[1]+.0722*a[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[h,u]=[i,r].map(this.#nu.bind(this));c<d&&([d,c,h,u]=[c,d,u,h]),this.#nl.style.color="";let p=(e,t,n)=>{let i=Array(256),r=(c-d)/n,s=e/255,o=(t-e)/(255*n),a=0;for(let e=0;e<=n;e++){let t=Math.round(d+e*r),n=s+e*o;for(let e=a;e<=t;e++)i[e]=n;a=t+1}for(let e=a;e<256;e++)i[e]=i[a-1];return i.join(",")},f=`g_${this.#nr}_hcm_${e}_filter`,m=o.filter=this.#nc(f);return this.#np(m),this.#nh(p(h[0],u[0],5),p(h[1],u[1],5),p(h[2],u[2],5),m),o.url=`url(#${f})`,o.url}destroy(e=!1){if(!e||0===this.#na.size)this.#ni&&(this.#ni.parentNode.parentNode.remove(),this.#ni=null),this.#nn&&(this.#nn.clear(),this.#nn=null),this.#v=0}#nm(e){let t=this.#ns.createElementNS(Q,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(t)}#np(e){let t=this.#ns.createElementNS(Q,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)}#nc(e){let t=this.#ns.createElementNS(Q,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#nl.append(t),t}#ng(e,t,n){let i=this.#ns.createElementNS(Q,t);i.setAttribute("type","discrete"),i.setAttribute("tableValues",n),e.append(i)}#nh(e,t,n,i){let r=this.#ns.createElementNS(Q,"feComponentTransfer");i.append(r),this.#ng(r,"feFuncR",e),this.#ng(r,"feFuncG",t),this.#ng(r,"feFuncB",n)}#nf(e,t){let n=this.#ns.createElementNS(Q,"feComponentTransfer");t.append(n),this.#ng(n,"feFuncA",e)}#nu(e){return this.#nl.style.color=e,ev(getComputedStyle(this.#nl).getPropertyValue("color"))}},tV=o?class e extends X{_fetchData(e){return eU(e)}}:ei;function t$(e={}){var t;"string"==typeof e||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let n=new tG,{docId:i}=n,r=e.url?function(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(o&&"string"==typeof e)return e}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url):null,s=e.data?function(e){if(o&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return F(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,a=e.httpHeaders||null,l=!0===e.withCredentials,d=e.password??null,c=e.range instanceof tZ?e.range:null,h=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:65536,u=e.worker instanceof tJ?e.worker:null,p=e.verbosity,f="string"!=typeof e.docBaseUrl||ea(e.docBaseUrl)?null:e.docBaseUrl,m="string"==typeof e.cMapUrl?e.cMapUrl:null,g=!1!==e.cMapPacked,v=e.CMapReaderFactory||tH,b="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,y=e.StandardFontDataFactory||tV,x=!0!==e.stopAtErrors,w=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,S=!1!==e.isEvalSupported,E="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!o,C=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,A="boolean"==typeof e.disableFontFace?e.disableFontFace:o,k=!0===e.fontExtraProperties,T=!0===e.enableXfa,M=e.ownerDocument||globalThis.document,D=!0===e.disableRange,O=!0===e.disableStream,I=!0===e.disableAutoFetch,N=!0===e.pdfBug,R=!0===e.enableHWA,L=c?c.length:e.length??NaN,P="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!o&&!A,j="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:v===en&&y===ei&&m&&b&&eu(m,document.baseURI)&&eu(b,document.baseURI),B=e.canvasFactory||new tz({ownerDocument:M,enableHWA:R}),z=e.filterFactory||new tU({docId:i,ownerDocument:M});Number.isInteger(t=p)&&(_=t);let H={canvasFactory:B,filterFactory:z};if(!j&&(H.cMapReaderFactory=new v({baseUrl:m,isCompressed:g}),H.standardFontDataFactory=new y({baseUrl:b})),!u){let e={verbosity:p,port:tt.workerPort};u=e.port?tJ.fromPort(e):new tJ(e),n._worker=u}let U={docId:i,apiVersion:"4.4.168",data:s,password:d,disableAutoFetch:I,rangeChunkSize:h,length:L,docBaseUrl:f,enableXfa:T,evaluatorOptions:{maxImageSize:w,disableFontFace:A,ignoreErrors:x,isEvalSupported:S,isOffscreenCanvasSupported:E,canvasMaxAreaInBytes:C,fontExtraProperties:k,useSystemFonts:P,cMapUrl:j?m:null,standardFontDataUrl:j?b:null}},V={disableFontFace:A,fontExtraProperties:k,ownerDocument:M,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:T}};return u.promise.then(function(){let e;if(n.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let t=u.messageHandler.sendWithPromise("GetDocRequest",U,s?[s.buffer]:null);if(c)e=new tc(c,{disableRange:D,disableStream:O});else if(!s){var d;if(!r)throw Error("getDocument - no `url` parameter provided.");d={url:r,length:L,httpHeaders:a,withCredentials:l,rangeChunkSize:h,disableRange:D,disableStream:O},e=o?"undefined"!=typeof fetch&&"undefined"!=typeof Response&&"body"in Response.prototype&&eu(d.url)?new tx(d):new tT(d):eu(d.url)?new tx(d):new tE(d)}return t.then(t=>{if(n.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let r=new ts(i,t,u.port),s=new tQ(r,n,e,V,H);n._transport=s,r.send("Ready",null)})}).catch(n._capability.reject),n}function tW(e){return"object"==typeof e&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0}class tG{static #nr=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${tG.#nr++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}class tZ{constructor(e,t,n=!1,i=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(let n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(let n of this._progressListeners)n(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(let t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){C("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class tq{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return T(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class tK{#nv=null;#nb=!1;constructor(e,t,n,i=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=i?new eh:null,this._pdfBug=i,this.commonObjs=n.commonObjs,this.objs=new t1,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:i=0,dontFlip:r=!1}={}){return new es({viewBox:this.view,scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}getAnnotations({intent:e="display"}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return T(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n="display",annotationMode:i=c.ENABLE,transform:r=null,background:s=null,optionalContentConfigPromise:o=null,annotationCanvasMap:a=null,pageColors:l=null,printAnnotationStorage:h=null}){this._stats?.time("Overall");let u=this._transport.getRenderingIntent(n,i,h),{renderingIntent:p,cacheKey:f}=u;this.#nb=!1,this.#ny(),o||=this._transport.getOptionalContentConfig(p);let m=this._intentStates.get(f);!m&&(m=Object.create(null),this._intentStates.set(f,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);let g=!!(p&d.PRINT);!m.displayReadyCapability&&(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));let v=e=>{m.renderTasks.delete(b),(this._maybeCleanupAfterRender||g)&&(this.#nb=!0),this.#nx(!g),e?(b.capability.reject(e),this._abortOperatorList({intentState:m,reason:e instanceof Error?e:Error(e)})):b.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},b=new t5({callback:v,params:{canvasContext:e,viewport:t,transform:r,background:s},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:a,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!g,pdfBug:this._pdfBug,pageColors:l});(m.renderTasks||=new Set).add(b);let y=b.task;return Promise.all([m.displayReadyCapability.promise,o]).then(([e,t])=>{if(this.destroyed){v();return}if(this._stats?.time("Rendering"),!(t.renderingIntent&p))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");b.initializeGraphics({transparency:e,optionalContentConfig:t}),b.operatorListChanged()}).catch(v),y}getOperatorList({intent:e="display",annotationMode:t=c.ENABLE,printAnnotationStorage:n=null}={}){let i;let r=this._transport.getRenderingIntent(e,t,n,!0),s=this._intentStates.get(r.cacheKey);return!s&&(s=Object.create(null),this._intentStates.set(r.cacheKey,s)),!s.opListReadCapability&&((i=Object.create(null)).operatorListChanged=function(){s.operatorList.lastChunk&&(s.opListReadCapability.resolve(s.operatorList),s.renderTasks.delete(i))},s.opListReadCapability=Promise.withResolvers(),(s.renderTasks||=new Set).add(i),s.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),s.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(e=>tB.textContent(e));let t=this.streamTextContent(e);return new Promise(function(e,n){let i=t.getReader(),r={items:[],styles:Object.create(null),lang:null};!function t(){i.read().then(function({value:n,done:i}){if(i){e(r);return}r.lang??=n.lang,Object.assign(r.styles,n.styles),r.items.push(...n.items),t()},n)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values()){if(this._abortOperatorList({intentState:t,reason:Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel()}return this.objs.clear(),this.#nb=!1,this.#ny(),Promise.all(e)}cleanup(e=!1){this.#nb=!0;let t=this.#nx(!1);return e&&t&&(this._stats&&=new eh),t}#nx(e=!1){if(this.#ny(),!this.#nb||this.destroyed)return!1;if(e)return this.#nv=setTimeout(()=>{this.#nv=null,this.#nx(!1)},5e3),!1;for(let{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#nb=!1,!0}#ny(){this.#nv&&(clearTimeout(this.#nv),this.#nv=null)}_startRenderPage(e,t){let n=this._intentStates.get(t);if(!!n)this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(e)}_renderPageChunk(e,t){for(let n=0,i=e.length;n<i;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);for(let n of(t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots,t.renderTasks))n.operatorListChanged();e.lastChunk&&this.#nx(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n}){let{map:i,transfer:r}=n,s=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:i},r).getReader(),o=this._intentStates.get(t);o.streamReader=s;let a=()=>{s.read().then(({value:e,done:t})=>{if(t){o.streamReader=null;return}if(!this._transport.destroyed)this._renderPageChunk(e,o),a()},e=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){for(let e of(o.operatorList.lastChunk=!0,o.renderTasks))e.operatorListChanged();this.#nx(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(e);else if(o.opListReadCapability)o.opListReadCapability.reject(e);else throw e}})};a()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(!e.streamReader)return;if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof eo){let n=100;t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},n);return}}if(e.streamReader.cancel(new P(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}get stats(){return this._stats}}class tY{#nw=new Set;#n_=Promise.resolve();postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};this.#n_.then(()=>{for(let e of this.#nw)e.call(this,n)})}addEventListener(e,t){this.#nw.add(t)}removeEventListener(e,t){this.#nw.delete(t)}terminate(){this.#nw.clear()}}let tX={isWorkerDisabled:!1,fakeWorkerId:0};o&&(tX.isWorkerDisabled=!0,tt.workerSrc||="./pdf.worker.mjs"),tX.isSameOrigin=function(e,t){let n;try{if(!(n=new URL(e)).origin||"null"===n.origin)return!1}catch{return!1}let i=new URL(t,n);return n.origin===i.origin},tX.createCDNWrapper=function(e){let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};class tJ{static #nS;constructor({name:e=null,port:t=null,verbosity:n=_}={}){if(this.name=e,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if(tJ.#nS?.has(t))throw Error("Cannot use more than one PDFWorker per port.");(tJ.#nS||=new WeakMap).set(t,this),this._initializeFromPort(t);return}this._initialize()}get promise(){return o?Promise.all([eH.promise,this._readyCapability.promise]):this._readyCapability.promise}#nE(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new ts("main","worker",e),this._messageHandler.on("ready",function(){}),this.#nE()}_initialize(){if(tX.isWorkerDisabled||tJ.#nC){this._setupFakeWorker();return}let{workerSrc:e}=tJ;try{!tX.isSameOrigin(window.location.href,e)&&(e=tX.createCDNWrapper(new URL(e,window.location).href));let t=new Worker(e,{type:"module"}),n=new ts("main","worker",t),i=()=>{r.abort(),n.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;t.addEventListener("error",()=>{!this._webWorker&&i()},{signal:r.signal}),n.on("test",e=>{if(r.abort(),this.destroyed||!e){i();return}this._messageHandler=n,this._port=t,this._webWorker=t,this.#nE()}),n.on("ready",e=>{if(r.abort(),this.destroyed){i();return}try{s()}catch{this._setupFakeWorker()}});let s=()=>{let e=new Uint8Array;n.send("test",e,[e.buffer])};s();return}catch{S("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){!tX.isWorkerDisabled&&(E("Setting up fake worker."),tX.isWorkerDisabled=!0),tJ._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(Error("Worker was destroyed"));return}let t=new tY;this._port=t;let n=`fake${tX.fakeWorkerId++}`,i=new ts(n+"_worker",n,t);e.setup(i,t),this._messageHandler=new ts(n,n+"_worker",t),this.#nE()}).catch(e=>{this._readyCapability.reject(Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),tJ.#nS?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(e){if(!e?.port)throw Error("PDFWorker.fromPort - invalid method signature.");let t=this.#nS?.get(e.port);if(t){if(t._pendingDestroy)throw Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new tJ(e)}static get workerSrc(){if(tt.workerSrc)return tt.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #nC(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return T(this,"_setupFakeWorkerGlobal",(async()=>this.#nC?this.#nC:(await import(this.workerSrc)).WorkerMessageHandler)())}}class tQ{#nA=new Map;#nk=new Map;#nT=new Map;#nM=new Map;#nD=null;constructor(e,t,n,i,r){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new t1,this.fontLoader=new ej({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#nO(e,t=null){let n=this.#nA.get(e);if(n)return n;let i=this.messageHandler.sendWithPromise(e,t);return this.#nA.set(e,i),i}get annotationStorage(){return T(this,"annotationStorage",new eL)}getRenderingIntent(e,t=c.ENABLE,n=null,i=!1){let r=d.DISPLAY,s=eR;switch(e){case"any":r=d.ANY;break;case"display":break;case"print":r=d.PRINT;break;default:E(`getRenderingIntent - invalid intent: ${e}`)}switch(t){case c.DISABLE:r+=d.ANNOTATIONS_DISABLE;break;case c.ENABLE:break;case c.ENABLE_FORMS:r+=d.ANNOTATIONS_FORMS;break;case c.ENABLE_STORAGE:s=((r+=d.ANNOTATIONS_STORAGE)&d.PRINT&&n instanceof eP?n:this.annotationStorage).serializable;break;default:E(`getRenderingIntent - invalid annotationMode: ${t}`)}return i&&(r+=d.OPLIST),{renderingIntent:r,cacheKey:`${r}_${s.hash}`,annotationStorageSerializable:s}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#nD?.reject(Error("Worker was destroyed during onPassword callback"));let e=[];for(let t of this.#nk.values())e.push(t._destroy());this.#nk.clear(),this.#nT.clear(),this.#nM.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#nA.clear(),this.filterFactory.destroy(),tP.cleanup(),this._networkStream?.cancelAllRequests(new P("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(e,t)=>{A(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then(function({value:e,done:n}){if(n){t.close();return}A(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),e.on("ReaderHeadersReady",e=>{let n=Promise.withResolvers(),i=this._fullReader;return i.headersReady.then(()=>{(!i.isStreamingSupported||!i.isRangeSupported)&&(this._lastProgress&&t.onProgress?.(this._lastProgress),i.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}),n.resolve({isStreamingSupported:i.isStreamingSupported,isRangeSupported:i.isRangeSupported,contentLength:i.contentLength})},n.reject),n.promise}),e.on("GetRangeReader",(e,t)=>{A(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(e.begin,e.end);if(!n){t.close();return}t.onPull=()=>{n.read().then(function({value:e,done:n}){if(n){t.close();return}A(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{n.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),e.on("GetDoc",({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new tq(e,this))}),e.on("DocException",function(e){let n;switch(e.name){case"PasswordException":n=new D(e.message,e.code);break;case"InvalidPDFException":n=new I(e.message);break;case"MissingPDFException":n=new N(e.message);break;case"UnexpectedResponseException":n=new R(e.message,e.status);break;case"UnknownErrorException":n=new O(e.message,e.details);break;default:C("DocException - expected a valid Error.")}t._capability.reject(n)}),e.on("PasswordRequest",e=>{if(this.#nD=Promise.withResolvers(),t.onPassword)try{t.onPassword(e=>{e instanceof Error?this.#nD.reject(e):this.#nD.resolve({password:e})},e.code)}catch(e){this.#nD.reject(e)}else this.#nD.reject(new D(e.message,e.code));return this.#nD.promise}),e.on("DataLoaded",e=>{t.onProgress?.({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)}),e.on("StartRenderPage",e=>{if(!this.destroyed)this.#nk.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}),e.on("commonobj",([t,n,i])=>{if(this.destroyed||this.commonObjs.has(t))return null;switch(n){case"Font":let{disableFontFace:r,fontExtraProperties:s,pdfBug:o}=this._params;if("error"in i){let e=i.error;E(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}let a=new eF(i,{disableFontFace:r,inspectFont:o&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null});this.fontLoader.bind(a).catch(()=>e.sendWithPromise("FontFallback",{id:t})).finally(()=>{!s&&a.data&&(a.data=null),this.commonObjs.resolve(t,a)});break;case"CopyLocalImage":let{imageRef:l}=i;for(let e of(A(l,"The imageRef must be defined."),this.#nk.values()))for(let[,n]of e.objs){if(n?.ref===l){if(!n.dataLen)return null;return this.commonObjs.resolve(t,structuredClone(n)),n.dataLen}}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,i);break;default:throw Error(`Got unknown common object type ${n}`)}return null}),e.on("obj",([e,t,n,i])=>{if(this.destroyed)return;let r=this.#nk.get(t);if(!r.objs.has(e)){if(0===r._intentStates.size){i?.bitmap?.close();return}switch(n){case"Image":r.objs.resolve(e,i),i?.dataLen>1e7&&(r._maybeCleanupAfterRender=!0);break;case"Pattern":r.objs.resolve(e,i);break;default:throw Error(`Got unknown object type ${n}`)}}}),e.on("DocProgress",e=>{if(!this.destroyed)t.onProgress?.({loaded:e.loaded,total:e.total})}),e.on("FetchBuiltInCMap",e=>this.destroyed?Promise.reject(Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(e):Promise.reject(Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),e.on("FetchStandardFontData",e=>this.destroyed?Promise.reject(Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(e):Promise.reject(Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&E("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(Error("Invalid page request."));let t=e-1,n=this.#nT.get(t);if(n)return n;let i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(n=>{if(this.destroyed)throw Error("Transport destroyed");n.refStr&&this.#nM.set(n.refStr,e);let i=new tK(t,n,this,this._params.pdfBug);return this.#nk.set(t,i),i});return this.#nT.set(t,i),i}getPageIndex(e){return tW(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return this.#nO("GetFieldObjects")}hasJSActions(){return this.#nO("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#nO("GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return this.#nO("GetOptionalContentConfig").then(t=>new td(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let e="GetMetadata",t=this.#nA.get(e);if(t)return t;let n=this.messageHandler.sendWithPromise(e,null).then(e=>({info:e[0],metadata:e[1]?new to(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#nA.set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){for(let e of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#nk.values()))if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),!e&&this.fontLoader.clear(),this.#nA.clear(),this.filterFactory.destroy(!0),tP.cleanup()}}cachedPageNumber(e){if(!tW(e))return null;let t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`;return this.#nM.get(t)??null}}let t0=Symbol("INITIAL_DATA");class t1{#nI=Object.create(null);#nN(e){return this.#nI[e]||={...Promise.withResolvers(),data:t0}}get(e,t=null){if(t){let n=this.#nN(e);return n.promise.then(()=>t(n.data)),null}let n=this.#nI[e];if(!n||n.data===t0)throw Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=this.#nI[e];return!!t&&t.data!==t0}resolve(e,t=null){let n=this.#nN(e);n.data=t,n.resolve()}clear(){for(let e in this.#nI){let{data:t}=this.#nI[e];t?.bitmap?.close()}this.#nI=Object.create(null)}*[Symbol.iterator](){for(let e in this.#nI){let{data:t}=this.#nI[e];if(t!==t0)yield[e,t]}}}class t2{#nR=null;constructor(e){this.#nR=e,this.onContinue=null}get promise(){return this.#nR.capability.promise}cancel(e=0){this.#nR.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this.#nR.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this.#nR;return e.form||e.canvas&&t?.size>0}}class t5{#nL=null;static #nP=new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:i,annotationCanvasMap:r,operatorList:s,pageIndex:o,canvasFactory:a,filterFactory:l,useRequestAnimationFrame:d=!1,pdfBug:c=!1,pageColors:h=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=s,this._pageIndex=o,this.canvasFactory=a,this.filterFactory=l,this._pdfBug=c,this.pageColors=h,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===d&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new t2(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(t5.#nP.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");t5.#nP.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:n,viewport:i,transform:r,background:s}=this.params;this.gfx=new te(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:i,transparency:e,background:s}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#nL&&(window.cancelAnimationFrame(this.#nL),this.#nL=null),t5.#nP.delete(this._canvas),this.callback(e||new eo(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}if(this.stepper?.updateOperatorList(this.operatorList),!this.running)this._continue()}_continue(){if(this.running=!0,!this.cancelled)this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext()}_scheduleNext(){this._useRequestAnimationFrame?this.#nL=window.requestAnimationFrame(()=>{this.#nL=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(!this.cancelled)this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),t5.#nP.delete(this._canvas),this.callback()))}}let t3="4.4.168",t4="19fbc8998";function t6(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}function t8(e){return Math.max(0,Math.min(255,255*e))}class t7{static CMYK_G([e,t,n,i]){return["G",1-Math.min(1,.3*e+.59*n+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return[e=t8(e),e,e]}static G_HTML([e]){let t=t6(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return["G",.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(t8)}static RGB_HTML(e){return`#${e.map(t6).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,n+i),1-Math.min(1,t+i)]}static CMYK_rgb([e,t,n,i]){return[t8(1-Math.min(1,e+i)),t8(1-Math.min(1,n+i)),t8(1-Math.min(1,t+i))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let i=1-e,r=1-t,s=1-n,o=Math.min(i,r,s);return["CMYK",i,r,s,o]}}class t9{static setupStorage(e,t,n,i,r){let s=i.getValue(t,{value:null});switch(n.name){case"textarea":if(null!==s.value&&(e.textContent=s.value),"print"===r)break;e.addEventListener("input",e=>{i.setValue(t,{value:e.target.value})});break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(s.value===n.attributes.xfaOn?e.setAttribute("checked",!0):s.value===n.attributes.xfaOff&&e.removeAttribute("checked"),"print"===r)break;e.addEventListener("change",e=>{i.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})})}else{if(null!==s.value&&e.setAttribute("value",s.value),"print"===r)break;e.addEventListener("input",e=>{i.setValue(t,{value:e.target.value})})}break;case"select":if(null!==s.value)for(let t of(e.setAttribute("value",s.value),n.children))t.attributes.value===s.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected;e.addEventListener("input",e=>{let n=e.target.options,r=-1===n.selectedIndex?"":n[n.selectedIndex].value;i.setValue(t,{value:r})})}}static setAttributes({html:e,element:t,storage:n=null,intent:i,linkService:r}){let{attributes:s}=t,o=e instanceof HTMLAnchorElement;for(let[t,n]of("radio"===s.type&&(s.name=`${s.name}-${i}`),Object.entries(s))){if(null!=n)switch(t){case"class":n.length&&e.setAttribute(t,n.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",n);break;case"style":Object.assign(e.style,n);break;case"textContent":e.textContent=n;break;default:(!o||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,n)}}o&&r.addLinkAttributes(e,s.href,s.newWindow),n&&s.dataId&&this.setupStorage(e,s.dataId,t,n)}static render(e){let t=e.annotationStorage,n=e.linkService,i=e.xfaHtml,r=e.intent||"display",s=document.createElement(i.name);i.attributes&&this.setAttributes({html:s,element:i,intent:r,linkService:n});let o="richText"!==r,a=e.div;if(a.append(s),e.viewport){let t=`matrix(${e.viewport.transform.join(",")})`;a.style.transform=t}o&&a.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===i.children.length){if(i.value){let e=document.createTextNode(i.value);s.append(e),o&&tB.shouldBuildText(i.name)&&l.push(e)}return{textDivs:l}}let d=[[i,-1,s]];for(;d.length>0;){let[e,i,s]=d.at(-1);if(i+1===e.children.length){d.pop();continue}let a=e.children[++d.at(-1)[1]];if(null===a)continue;let{name:c}=a;if("#text"===c){let e=document.createTextNode(a.value);l.push(e),s.append(e);continue}let h=a?.attributes?.xmlns?document.createElementNS(a.attributes.xmlns,c):document.createElement(c);if(s.append(h),a.attributes&&this.setAttributes({html:h,element:a,storage:t,intent:r,linkService:n}),a.children?.length>0)d.push([a,-1,h]);else if(a.value){let e=document.createTextNode(a.value);o&&tB.shouldBuildText(c)&&l.push(e),h.append(e)}}for(let e of a.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:l}}static update(e){let t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}let ne=new WeakSet;function nt(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class nn{static create(e){switch(e.data.annotationType){case g.LINK:return new nr(e);case g.TEXT:return new ns(e);case g.WIDGET:switch(e.data.fieldType){case"Tx":return new na(e);case"Btn":if(e.data.radioButton)return new nc(e);if(e.data.checkBox)return new nd(e);return new nh(e);case"Ch":return new nu(e);case"Sig":return new nl(e)}return new no(e);case g.POPUP:return new np(e);case g.FREETEXT:return new nm(e);case g.LINE:return new ng(e);case g.SQUARE:return new nv(e);case g.CIRCLE:return new nb(e);case g.POLYLINE:return new ny(e);case g.CARET:return new nw(e);case g.INK:return new n_(e);case g.POLYGON:return new nx(e);case g.HIGHLIGHT:return new nS(e);case g.UNDERLINE:return new nE(e);case g.SQUIGGLY:return new nC(e);case g.STRIKEOUT:return new nA(e);case g.STAMP:return new nk(e);case g.FILEATTACHMENT:return new nT(e);default:return new ni(e)}}}class ni{#nj=null;#nF=!1;#nB=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get hasPopupData(){return ni._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#nj||={rect:this.data.rect.slice(0)};let{rect:t}=e;t&&this.#nz(t),this.#nB?.popup.updateEdited(e)}resetEdited(){if(!!this.#nj)this.#nz(this.#nj.rect),this.#nB?.popup.resetEdited(),this.#nj=null}#nz(e){let{container:{style:t},data:{rect:n,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:s,pageX:o,pageY:a}}}}=this;n?.splice(0,4,...e);let{width:l,height:d}=nt(e);t.left=`${100*(e[0]-o)/r}%`,t.top=`${100*(s-e[3]+a)/s}%`,0===i?(t.width=`${100*l/r}%`,t.height=`${100*d/s}%`):this.setRotation(i)}_createContainer(e){let{data:t,parent:{page:n,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),!(this instanceof no)&&(r.tabIndex=1e3);let{style:s}=r;if(s.zIndex=this.parent.zIndex++,t.popupRef&&r.setAttribute("aria-haspopup","dialog"),t.alternativeText&&(r.title=t.alternativeText),t.noRotate&&r.classList.add("norotate"),!t.rect||this instanceof np){let{rotation:e}=t;return!t.hasOwnCanvas&&0!==e&&this.setRotation(e,r),r}let{width:o,height:a}=nt(t.rect);if(!e&&t.borderStyle.width>0){s.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;if(e>0||n>0){let t=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;s.borderRadius=t}else if(this instanceof nc){let e=`calc(${o}px * var(--scale-factor)) / calc(${a}px * var(--scale-factor))`;s.borderRadius=e}switch(t.borderStyle.style){case v.SOLID:s.borderStyle="solid";break;case v.DASHED:s.borderStyle="dashed";break;case v.BEVELED:E("Unimplemented border style: beveled");break;case v.INSET:E("Unimplemented border style: inset");break;case v.UNDERLINE:s.borderBottomStyle="solid"}let i=t.borderColor||null;i?(this.#nF=!0,s.borderColor=U.makeHexColor(0|i[0],0|i[1],0|i[2])):s.borderWidth=0}let l=U.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:d,pageHeight:c,pageX:h,pageY:u}=i.rawDims;s.left=`${100*(l[0]-h)/d}%`,s.top=`${100*(l[1]-u)/c}%`;let{rotation:p}=t;return t.hasOwnCanvas||0===p?(s.width=`${100*o/d}%`,s.height=`${100*a/c}%`):this.setRotation(p,r),r}setRotation(e,t=this.container){let n,i;if(!this.data.rect)return;let{pageWidth:r,pageHeight:s}=this.parent.viewport.rawDims,{width:o,height:a}=nt(this.data.rect);e%180==0?(n=100*o/r,i=100*a/s):(n=100*a/r,i=100*o/s),t.style.width=`${n}%`,t.style.height=`${i}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let i=n.detail[e],r=i[0],s=i.slice(1);n.target.style[t]=t7[`${r}_HTML`](s),this.annotationStorage.setValue(this.data.id,{[t]:t7[`${r}_rgb`](s)})};return T(this,"_commonActions",{display:e=>{let{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:1===t||2===t})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:t}=e.detail;this.container.style.visibility=t?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let i of Object.keys(t.detail)){let r=e[i]||n[i];r?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[i,r]of Object.entries(t)){let s=n[i];s&&(s({detail:{[i]:r},target:e}),delete t[i])}}_createQuadrilaterals(){let e;if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[n,i,r,s]=this.data.rect.map(e=>Math.fround(e));if(8===t.length){let[e,o,a,l]=t.subarray(2,6);if(r===e&&s===o&&n===a&&i===l)return}let{style:o}=this.container;if(this.#nF){let{borderColor:t,borderWidth:n}=o;o.borderWidth=0,e=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${n}">`],this.container.classList.add("hasBorder")}let a=r-n,l=s-i,{svgFactory:d}=this,c=d.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);let h=d.createElement("defs");c.append(h);let u=d.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),h.append(u);for(let i=2,r=t.length;i<r;i+=8){let r=t[i],o=t[i+1],c=t[i+2],h=t[i+3],p=d.createElement("rect"),f=(c-n)/a,m=(s-o)/l,g=(r-c)/a,v=(o-h)/l;p.setAttribute("x",f),p.setAttribute("y",m),p.setAttribute("width",g),p.setAttribute("height",v),u.append(p),e?.push(`<rect vector-effect="non-scaling-stroke" x="${f}" y="${m}" width="${g}" height="${v}"/>`)}this.#nF&&(e.push("</g></svg>')"),o.backgroundImage=e.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(){let{container:e,data:t}=this;e.setAttribute("aria-haspopup","dialog");let n=this.#nB=new np({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(n.render())}render(){C("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let i=this._fieldObjects[e];if(i)for(let{page:e,id:r,exportValues:s}of i){if(-1===e||r===t)continue;let i="string"==typeof s?s:null,o=document.querySelector(`[data-element-id="${r}"]`);if(o&&!ne.has(o)){E(`_getElementsByName - element not allowed: ${r}`);continue}n.push({id:r,exportValue:i,domElement:o})}return n}for(let i of document.getElementsByName(e)){let{exportValue:e}=i,r=i.getAttribute("data-element-id");if(r!==t&&!!ne.has(i))n.push({id:r,exportValue:e,domElement:i})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})})}}class nr extends ni{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let i=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),i=!0):e.action?(this._bindNamedAction(n,e.action),i=!0):e.attachment?(this.#nH(n,e.attachment,e.attachmentDest),i=!0):e.setOCGState?(this.#nU(n,e.setOCGState),i=!0):e.dest?(this._bindLink(n,e.dest),i=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),i=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(n,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(n),this.container}#nV(){this.container.setAttribute("data-internal-link","")}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||""===t)&&this.#nV()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#nV()}#nH(e,t,n=null){e.href=this.linkService.getAnchorUrl(""),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,n),!1),this.#nV()}#nU(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#nV()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let i of Object.keys(t.actions)){let r=n.get(i);if(!!r)e[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:i}}),!1)}!e.onclick&&(e.onclick=()=>!1),this.#nV()}_bindResetFormAction(e,t){let n=e.onclick;if(!n&&(e.href=this.linkService.getAnchorUrl("")),this.#nV(),!this._fieldObjects){E('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),!n&&(e.onclick=()=>!1);return}e.onclick=()=>{n?.();let{fields:e,refs:i,include:r}=t,s=[];if(0!==e.length||0!==i.length){let t=new Set(i);for(let n of e)for(let{id:e}of this._fieldObjects[n]||[])t.add(e);for(let e of Object.values(this._fieldObjects))for(let n of e)t.has(n.id)===r&&s.push(n)}else for(let e of Object.values(this._fieldObjects))s.push(...e);let o=this.annotationStorage,a=[];for(let e of s){let{id:t}=e;switch(a.push(t),e.type){case"text":{let n=e.defaultValue||"";o.setValue(t,{value:n});break}case"checkbox":case"radiobutton":{let n=e.defaultValue===e.exportValues;o.setValue(t,{value:n});break}case"combobox":case"listbox":{let n=e.defaultValue||"";o.setValue(t,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${t}"]`);if(!!n){if(!ne.has(n)){E(`_bindResetFormAction - element not allowed: ${t}`);continue}n.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:a,name:"ResetForm"}}),!1}}}class ns extends ni{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class no extends ni{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&(e.previousSibling?.nodeName==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return z.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,i,r){n.includes("mouse")?e.addEventListener(n,e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(n,e=>{if("blur"===n){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if("focus"===n){if(t.focused)return;t.focused=!0}if(!!r)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(e)}})})}_setEventListeners(e,t,n,i){for(let[r,s]of n)("Action"===s||this.data.actions?.[s])&&(("Focus"===s||"Blur"===s)&&(t||={focused:!1}),this._setEventListener(e,t,r,s,i),"Focus"!==s||this.data.actions?.Blur?"Blur"===s&&!this.data.actions?.Focus&&this._setEventListener(e,t,"focus","Focus",null):this._setEventListener(e,t,"blur","Blur",null))}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":U.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t;let{fontColor:n}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,r=e.style,s=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),n=Math.round(e/(1.35*i))||1;t=Math.min(i,s(e/n/1.35))}else t=Math.min(i,s(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));r.fontSize=`calc(${t}px * var(--scale-factor))`,r.color=U.makeHexColor(n[0],n[1],n[2]),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class na extends no{constructor(e){super(e,{isRenderable:e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,n,i){let r=this.annotationStorage;for(let s of this._getElementsByName(e.name,e.id))s.domElement&&(s.domElement[t]=n),r.setValue(s.id,{[i]:n})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){let i=e.getValue(t,{value:this.data.fieldValue}),r=i.value||"",s=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;s&&r.length>s&&(r=r.slice(0,s));let o=i.formattedValue||this.data.textContent?.join("\n")||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));let a={userValue:r,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((n=document.createElement("textarea")).textContent=o??r,this.data.doNotScroll&&(n.style.overflowY="hidden")):((n=document.createElement("input")).type="text",n.setAttribute("value",o??r),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),ne.add(n),n.setAttribute("data-element-id",t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=1e3,this._setRequired(n,this.data.required),s&&(n.maxLength=s),n.addEventListener("input",i=>{e.setValue(t,{value:i.target.value}),this.setPropertyOnSiblings(n,"value",i.target.value,"value"),a.formattedValue=null}),n.addEventListener("resetform",e=>{let t=this.data.defaultFieldValue??"";n.value=a.userValue=t,a.formattedValue=null});let l=e=>{let{formattedValue:t}=a;null!=t&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",e=>{if(a.focused)return;let{target:t}=e;a.userValue&&(t.value=a.userValue),a.lastCommittedValue=t.value,a.commitKey=1,!this.data.actions?.Focus&&(a.focused=!0)}),n.addEventListener("updatefromsandbox",n=>{this.showElementAndHideCanvas(n.target);this._dispatchEventFromSandbox({value(n){a.userValue=n.detail.value??"",e.setValue(t,{value:a.userValue.toString()}),n.target.value=a.userValue},formattedValue(n){let{formattedValue:i}=n.detail;a.formattedValue=i,null!=i&&n.target!==document.activeElement&&(n.target.value=i),e.setValue(t,{formattedValue:i})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{let{charLimit:i}=n.detail,{target:r}=n;if(0===i){r.removeAttribute("maxLength");return}r.setAttribute("maxLength",i);let s=a.userValue;if(!!s&&!(s.length<=i))s=s.slice(0,i),r.value=a.userValue=s,e.setValue(t,{value:s}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}})}},n)}),n.addEventListener("keydown",e=>{a.commitKey=1;let n=-1;if("Escape"===e.key?n=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(a.commitKey=3):n=2,-1===n)return;let{value:i}=e.target;if(a.lastCommittedValue!==i)a.lastCommittedValue=i,a.userValue=i,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:i,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})});let i=l;l=null,n.addEventListener("blur",e=>{if(!a.focused||!e.relatedTarget)return;!this.data.actions?.Blur&&(a.focused=!1);let{value:n}=e.target;a.userValue=n,a.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:a.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),i(e)}),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",e=>{a.lastCommittedValue=null;let{data:n,target:i}=e,{value:r,selectionStart:s,selectionEnd:o}=i,l=s,d=o;switch(e.inputType){case"deleteWordBackward":{let e=r.substring(0,s).match(/\w*[^\w]*$/);e&&(l-=e[0].length);break}case"deleteWordForward":{let e=r.substring(s).match(/^[^\w]*\w*/);e&&(d+=e[0].length);break}case"deleteContentBackward":s===o&&(l-=1);break;case"deleteContentForward":s===o&&(d+=1)}e.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,change:n||"",willCommit:!1,selStart:l,selEnd:d}})}),this._setEventListeners(n,a,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.value)}if(l&&n.addEventListener("blur",l),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/s;n.classList.add("comb"),n.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else(n=document.createElement("div")).textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class nl extends no{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class nd extends no{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,e.setValue(n,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return ne.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=1e3,r.addEventListener("change",i=>{let{name:r,checked:s}=i.target;for(let i of this._getElementsByName(r,n)){let n=s&&i.exportValue===t.exportValue;i.domElement&&(i.domElement.checked=n),e.setValue(i.id,{value:n})}e.setValue(n,{value:s})}),r.addEventListener("resetform",e=>{let n=t.defaultFieldValue||"Off";e.target.checked=n===t.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({value(t){t.target.checked="Off"!==t.detail.value,e.setValue(n,{value:t.target.checked})}},t)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class nc extends no{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;if("string"==typeof i&&(i=i!==t.buttonValue,e.setValue(n,{value:i})),i)for(let i of this._getElementsByName(t.fieldName,n))e.setValue(i.id,{value:!1});let r=document.createElement("input");if(ne.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=1e3,r.addEventListener("change",t=>{let{name:i,checked:r}=t.target;for(let t of this._getElementsByName(i,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:r})}),r.addEventListener("resetform",e=>{let n=t.defaultFieldValue;e.target.checked=null!=n&&n===t.buttonValue}),this.enableScripting&&this.hasJSActions){let i=t.buttonValue;r.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({value:t=>{let r=i===t.detail.value;for(let i of this._getElementsByName(t.target.name)){let t=r&&i.id===n;i.domElement&&(i.domElement.checked=t),e.setValue(i.id,{value:t})}}},t)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class nh extends nr{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({},e)})),e}}class nu extends no{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");ne.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=1e3;let r=this.data.combo&&this.data.options.length>0;for(let e of(!this.data.combo&&(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",e=>{let t=this.data.defaultFieldValue;for(let e of i.options)e.selected=e.value===t}),this.data.options)){let t=document.createElement("option");t.textContent=e.displayValue,t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute("selected",!0),r=!1),i.append(t)}let s=null;if(r){let e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),i.prepend(e),s=()=>{e.remove(),i.removeEventListener("input",s),s=null},i.addEventListener("input",s)}let o=e=>{let t=e?"value":"textContent",{options:n,multiple:r}=i;return r?Array.prototype.filter.call(n,e=>e.selected).map(e=>e[t]):-1===n.selectedIndex?null:n[n.selectedIndex][t]},a=o(!1),l=e=>{let t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.textContent,exportValue:e.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",n=>{this._dispatchEventFromSandbox({value(n){s?.();let r=n.detail.value,l=new Set(Array.isArray(r)?r:[r]);for(let e of i.options)e.selected=l.has(e.value);e.setValue(t,{value:o(!0)}),a=o(!1)},multipleSelection(e){i.multiple=!0},remove(n){let r=i.options,s=n.detail.remove;r[s].selected=!1,i.remove(s),r.length>0&&-1===Array.prototype.findIndex.call(r,e=>e.selected)&&(r[0].selected=!0),e.setValue(t,{value:o(!0),items:l(n)}),a=o(!1)},clear(n){for(;0!==i.length;)i.remove(0);e.setValue(t,{value:null,items:[]}),a=o(!1)},insert(n){let{index:r,displayValue:s,exportValue:d}=n.detail.insert,c=i.children[r],h=document.createElement("option");h.textContent=s,h.value=d,c?c.before(h):i.append(h),e.setValue(t,{value:o(!0),items:l(n)}),a=o(!1)},items(n){let{items:r}=n.detail;for(;0!==i.length;)i.remove(0);for(let e of r){let{displayValue:t,exportValue:n}=e,r=document.createElement("option");r.textContent=t,r.value=n,i.append(r)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:o(!0),items:l(n)}),a=o(!1)},indices(n){let i=new Set(n.detail.indices);for(let e of n.target.options)e.selected=i.has(e.index);e.setValue(t,{value:o(!0)}),a=o(!1)},editable(e){e.target.disabled=!e.detail.editable}},n)}),i.addEventListener("input",n=>{let i=o(!0),r=o(!1);e.setValue(t,{value:i}),n.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,change:r,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],e=>e.target.value)):i.addEventListener("input",function(n){e.setValue(t,{value:o(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class np extends ni{constructor(e){let{data:t,elements:n}=e;super(e,{isRenderable:ni._hasPopupData(t)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");let e=this.popup=new nf({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(let n of this.elements)n.popup=e,t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",t.map(e=>`${G}${e}`).join(",")),this.container}}class nf{#n$=this.#nW.bind(this);#nG=this.#nZ.bind(this);#nq=this.#nK.bind(this);#nY=this.#nX.bind(this);#nJ=null;#eg=null;#nQ=null;#n0=null;#n1=null;#n2=null;#n5=null;#n3=!1;#n4=null;#E=null;#n6=null;#n8=null;#n7=null;#nj=null;#n9=!1;constructor({container:e,color:t,elements:n,titleObj:i,modificationDate:r,contentsObj:s,richText:o,parent:a,rect:l,parentRect:d,open:c}){for(let c of(this.#eg=e,this.#n7=i,this.#nQ=s,this.#n8=o,this.#n2=a,this.#nJ=t,this.#n6=l,this.#n5=d,this.#n1=n,this.#n0=em.toDateObject(r),this.trigger=n.flatMap(e=>e.getElementsToTriggerPopup()),this.trigger))c.addEventListener("click",this.#nY),c.addEventListener("mouseenter",this.#nq),c.addEventListener("mouseleave",this.#nG),c.classList.add("popupTriggerArea");for(let e of n)e.container?.addEventListener("keydown",this.#n$);this.#eg.hidden=!0,c&&this.#nX()}render(){if(this.#n4)return;let e=this.#n4=document.createElement("div");if(e.className="popup",this.#nJ){let t=e.style.outlineColor=U.makeHexColor(...this.#nJ);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`:e.style.backgroundColor=U.makeHexColor(...this.#nJ.map(e=>Math.floor(.7*(255-e)+e)))}let t=document.createElement("span");t.className="header";let n=document.createElement("h1");if(t.append(n),{dir:n.dir,str:n.textContent}=this.#n7,e.append(t),this.#n0){let e=document.createElement("span");e.classList.add("popupDate"),e.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),e.setAttribute("data-l10n-args",JSON.stringify({date:this.#n0.toLocaleDateString(),time:this.#n0.toLocaleTimeString()})),t.append(e)}let i=this.#ie;if(i)t9.render({xfaHtml:i,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{let t=this._formatContents(this.#nQ);e.append(t)}this.#eg.append(e)}get #ie(){let e=this.#n8,t=this.#nQ;return e?.str&&(!t?.str||t.str===e.str)&&this.#n8.html||null}get #it(){return this.#ie?.attributes?.style?.fontSize||0}get #ii(){return this.#ie?.attributes?.style?.color||null}#ir(e){let t=[],n={style:{color:this.#ii,fontSize:this.#it?`calc(${this.#it}px * var(--scale-factor))`:""}};for(let i of e.split("\n"))t.push({name:"span",value:i,attributes:n});return{str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}}}_formatContents({str:e,dir:t}){let n=document.createElement("p");n.classList.add("popupContent"),n.dir=t;let i=e.split(/(?:\r\n?|\n)/);for(let e=0,t=i.length;e<t;++e){let r=i[e];n.append(document.createTextNode(r)),e<t-1&&n.append(document.createElement("br"))}return n}#nW(e){if(!e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey)("Enter"===e.key||"Escape"===e.key&&this.#n3)&&this.#nX()}updateEdited({rect:e,popupContent:t}){this.#nj||={contentsObj:this.#nQ,richText:this.#n8},e&&(this.#E=null),t&&(this.#n8=this.#ir(t),this.#nQ=null),this.#n4?.remove(),this.#n4=null}resetEdited(){if(!!this.#nj)({contentsObj:this.#nQ,richText:this.#n8}=this.#nj),this.#nj=null,this.#n4?.remove(),this.#n4=null,this.#E=null}#is(){if(null!==this.#E)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:i,pageY:r}}}=this.#n2,s=!!this.#n5,o=s?this.#n5:this.#n6;for(let e of this.#n1)if(!o||null!==U.intersect(e.data.rect,o)){o=e.data.rect,s=!0;break}let a=U.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),l=s?o[2]-o[0]+5:0,d=a[0]+l,c=a[1];this.#E=[100*(d-i)/t,100*(c-r)/n];let{style:h}=this.#eg;h.left=`${this.#E[0]}%`,h.top=`${this.#E[1]}%`}#nX(){this.#n3=!this.#n3,this.#n3?(this.#nK(),this.#eg.addEventListener("click",this.#nY),this.#eg.addEventListener("keydown",this.#n$)):(this.#nZ(),this.#eg.removeEventListener("click",this.#nY),this.#eg.removeEventListener("keydown",this.#n$))}#nK(){!this.#n4&&this.render(),this.isVisible?this.#n3&&this.#eg.classList.add("focused"):(this.#is(),this.#eg.hidden=!1,this.#eg.style.zIndex=parseInt(this.#eg.style.zIndex)+1e3)}#nZ(){if(this.#eg.classList.remove("focused"),!this.#n3&&!!this.isVisible)this.#eg.hidden=!0,this.#eg.style.zIndex=parseInt(this.#eg.style.zIndex)-1e3}forceHide(){if(this.#n9=this.isVisible,!!this.#n9)this.#eg.hidden=!0}maybeShow(){if(!!this.#n9)!this.#n4&&this.#nK(),this.#n9=!1,this.#eg.hidden=!1}get isVisible(){return!1===this.#eg.hidden}}class nm extends ni{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=h.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let e=document.createElement("div");for(let t of(e.classList.add("annotationTextContent"),e.setAttribute("role","comment"),this.textContent)){let n=document.createElement("span");n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class ng extends ni{#io=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let e=this.data,{width:t,height:n}=nt(e.rect),i=this.svgFactory.create(t,n,!0),r=this.#io=this.svgFactory.createElement("svg:line");return r.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),r.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),r.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),r.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),r.setAttribute("stroke-width",e.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#io}addHighlightArea(){this.container.classList.add("highlightArea")}}class nv extends ni{#ia=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let e=this.data,{width:t,height:n}=nt(e.rect),i=this.svgFactory.create(t,n,!0),r=e.borderStyle.width,s=this.#ia=this.svgFactory.createElement("svg:rect");return s.setAttribute("x",r/2),s.setAttribute("y",r/2),s.setAttribute("width",t-r),s.setAttribute("height",n-r),s.setAttribute("stroke-width",r||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),i.append(s),this.container.append(i),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ia}addHighlightArea(){this.container.classList.add("highlightArea")}}class nb extends ni{#il=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let e=this.data,{width:t,height:n}=nt(e.rect),i=this.svgFactory.create(t,n,!0),r=e.borderStyle.width,s=this.#il=this.svgFactory.createElement("svg:ellipse");return s.setAttribute("cx",t/2),s.setAttribute("cy",n/2),s.setAttribute("rx",t/2-r/2),s.setAttribute("ry",n/2-r/2),s.setAttribute("stroke-width",r||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),i.append(s),this.container.append(i),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#il}addHighlightArea(){this.container.classList.add("highlightArea")}}class ny extends ni{#id=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,vertices:t,borderStyle:n,popupRef:i}}=this;if(!t)return this.container;let{width:r,height:s}=nt(e),o=this.svgFactory.create(r,s,!0),a=[];for(let n=0,i=t.length;n<i;n+=2){let i=t[n]-e[0],r=e[3]-t[n+1];a.push(`${i},${r}`)}a=a.join(" ");let l=this.#id=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",a),l.setAttribute("stroke-width",n.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),o.append(l),this.container.append(o),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#id}addHighlightArea(){this.container.classList.add("highlightArea")}}class nx extends ny{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class nw extends ni{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class n_ extends ni{#ic=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=h.INK}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,inkLists:t,borderStyle:n,popupRef:i}}=this,{width:r,height:s}=nt(e),o=this.svgFactory.create(r,s,!0);for(let r of t){let t=[];for(let n=0,i=r.length;n<i;n+=2){let i=r[n]-e[0],s=e[3]-r[n+1];t.push(`${i},${s}`)}t=t.join(" ");let s=this.svgFactory.createElement(this.svgElementName);this.#ic.push(s),s.setAttribute("points",t),s.setAttribute("stroke-width",n.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),!i&&this.hasPopupData&&this._createPopup(),o.append(s)}return this.container.append(o),this.container}getElementsToTriggerPopup(){return this.#ic}addHighlightArea(){this.container.classList.add("highlightArea")}}class nS extends ni{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class nE extends ni{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class nC extends ni{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class nA extends ni{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class nk extends ni{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class nT extends ni{#ih=null;constructor(e){super(e,{isRenderable:!0});let{file:t}=this.data;this.filename=t.filename,this.content=t.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...t})}render(){let e;this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:n}=this;n.hasAppearance||0===n.fillAlpha?e=document.createElement("div"):((e=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(n.name)?"paperclip":"pushpin"}.svg`,n.fillAlpha&&n.fillAlpha<1&&(e.style=`filter: opacity(${Math.round(100*n.fillAlpha)}%);`)),e.addEventListener("dblclick",this.#iu.bind(this)),this.#ih=e;let{isMac:i}=z.platform;return t.addEventListener("keydown",e=>{"Enter"===e.key&&(i?e.metaKey:e.ctrlKey)&&this.#iu()}),!n.popupRef&&this.hasPopupData?this._createPopup():e.classList.add("popupTriggerArea"),t.append(e),t}getElementsToTriggerPopup(){return this.#ih}addHighlightArea(){this.container.classList.add("highlightArea")}#iu(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class nM{#ip=null;#im=null;#ig=new Map;constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:i,page:r,viewport:s}){this.div=e,this.#ip=t,this.#im=n,this.page=r,this.viewport=s,this.zIndex=0,this._annotationEditorUIManager=i}#iv(e,t){let n=e.firstChild||e;n.id=`${G}${t}`,this.div.append(e),this.#ip?.moveElementInDOM(this.div,e,n,!1)}async render(e){let{annotations:t}=e,n=this.div;ex(n,this.viewport);let i=new Map,r={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new er,annotationStorage:e.annotationStorage||new eL,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let e of t){if(e.noHTML)continue;let t=e.annotationType===g.POPUP;if(t){let t=i.get(e.id);if(!t)continue;r.elements=t}else{let{width:t,height:n}=nt(e.rect);if(t<=0||n<=0)continue}r.data=e;let n=nn.create(r);if(!n.isRenderable)continue;if(!t&&e.popupRef){let t=i.get(e.popupRef);t?t.push(n):i.set(e.popupRef,[n])}let s=n.render();e.hidden&&(s.style.visibility="hidden"),this.#iv(s,e.id),n.annotationEditorType>0&&(this.#ig.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}this.#ib()}update({viewport:e}){let t=this.div;this.viewport=e,ex(t,{rotation:e.rotation}),this.#ib(),t.hidden=!1}#ib(){if(!this.#im)return;let e=this.div;for(let[t,n]of this.#im){let i=e.querySelector(`[data-annotation-id="${t}"]`);if(!i)continue;n.className="annotationContent";let{firstChild:r}=i;r?"CANVAS"===r.nodeName?r.replaceWith(n):r.classList.contains("annotationContent")?r.after(n):r.before(n):i.append(n)}this.#im.clear()}getEditableAnnotations(){return Array.from(this.#ig.values())}getEditableAnnotation(e){return this.#ig.get(e)}}let nD=/\r\n?|\n/g;class nO extends eO{#iy=this.editorDivBlur.bind(this);#ix=this.editorDivFocus.bind(this);#iw=this.editorDivInput.bind(this);#i_=this.editorDivKeydown.bind(this);#iS=this.editorDivPaste.bind(this);#nJ;#iE="";#iC=`${this.id}-editor`;#it;#iA=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let e=nO.prototype,t=e=>e.isEmpty(),n=eM.TRANSLATE_SMALL,i=eM.TRANSLATE_BIG;return T(this,"_keyboardManager",new ek([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[n,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[i,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:t}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,n],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,i],checker:t}]]))}static _type="freetext";static _editorType=h.FREETEXT;constructor(e){super({...e,name:"freeTextEditor"}),this.#nJ=e.color||nO._defaultColor||eO._defaultLineColor,this.#it=e.fontSize||nO._defaultFontSize}static initialize(e,t){eO.initialize(e,t,{strings:["pdfjs-free-text-default-content"]});let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case u.FREETEXT_SIZE:nO._defaultFontSize=t;break;case u.FREETEXT_COLOR:nO._defaultColor=t}}updateParams(e,t){switch(e){case u.FREETEXT_SIZE:this.#ik(t);break;case u.FREETEXT_COLOR:this.#iT(t)}}static get defaultPropertiesToUpdate(){return[[u.FREETEXT_SIZE,nO._defaultFontSize],[u.FREETEXT_COLOR,nO._defaultColor||eO._defaultLineColor]]}get propertiesToUpdate(){return[[u.FREETEXT_SIZE,this.#it],[u.FREETEXT_COLOR,this.#nJ]]}#ik(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-this.#it)*this.parentScale),this.#it=e,this.#iM()},n=this.#it;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#iT(e){let t=e=>{this.#nJ=this.editorDiv.style.color=e},n=this.#nJ;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let e=this.parentScale;return[-nO._internalPadding*e,-(nO._internalPadding+this.#it)*e]}rebuild(){if(!this.parent)return;if(super.rebuild(),null!==this.div)!this.isAttachedToDOM&&this.parent.add(this)}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(h.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");let e=this._uiManager._signal;this.editorDiv.addEventListener("keydown",this.#i_,{signal:e}),this.editorDiv.addEventListener("focus",this.#ix,{signal:e}),this.editorDiv.addEventListener("blur",this.#iy,{signal:e}),this.editorDiv.addEventListener("input",this.#iw,{signal:e}),this.editorDiv.addEventListener("paste",this.#iS,{signal:e})}disableEditMode(){if(!!this.isInEditMode())this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#iC),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#i_),this.editorDiv.removeEventListener("focus",this.#ix),this.editorDiv.removeEventListener("blur",this.#iy),this.editorDiv.removeEventListener("input",this.#iw),this.editorDiv.removeEventListener("paste",this.#iS),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing")}focusin(e){if(!!this._focusEventsAllowed)super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus()}onceAdded(){if(!this.width)this.enableEditMode(),this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#iD(){let e=[];for(let t of(this.editorDiv.normalize(),this.editorDiv.childNodes))e.push(nO.#iO(t));return e.join("\n")}#iM(){let e;let[t,n]=this.parentDimensions;if(this.isAttachedToDOM)e=this.div.getBoundingClientRect();else{let{currentLayer:t,div:n}=this,i=n.style.display,r=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",t.div.append(this.div),e=n.getBoundingClientRect(),n.remove(),n.style.display=i,n.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=e.width/t,this.height=e.height/n):(this.width=e.height/t,this.height=e.width/n),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=this.#iE,t=this.#iE=this.#iD().trimEnd();if(e===t)return;let n=e=>{if(this.#iE=e,!e){this.remove();return}this.#iI(),this._uiManager.rebuild(this),this.#iM()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),this.#iM()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){nO._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){let e,t;if(this.div)return this.div;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#iC),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),eO._l10nPromise.get("pdfjs-free-text-default-content").then(e=>this.editorDiv?.setAttribute("default-content",e)),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#it}px * var(--scale-factor))`,n.color=this.#nJ,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),eS(this,this.div,["dblclick","keydown"]),this.width){let[n,i]=this.parentDimensions;if(this.annotationElementId){let r,s;let{position:o}=this.#iA,[a,l]=this.getInitialTranslation();[a,l]=this.pageTranslationToScreen(a,l);let[d,c]=this.pageDimensions,[h,u]=this.pageTranslation;switch(this.rotation){case 0:r=e+(o[0]-h)/d,s=t+this.height-(o[1]-u)/c;break;case 90:r=e+(o[0]-h)/d,s=t-(o[1]-u)/c,[a,l]=[l,-a];break;case 180:r=e-this.width+(o[0]-h)/d,s=t-(o[1]-u)/c,[a,l]=[-a,-l];break;case 270:r=e+(o[0]-h-this.height*c)/d,s=t+(o[1]-u-this.width*d)/c,[a,l]=[-l,a]}this.setAt(r*n,s*i,a,l)}else this.setAt(e*n,t*i,this.width*n,this.height*i);this.#iI(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #iO(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(nD,"")}editorDivPaste(e){let t=e.clipboardData||window.clipboardData,{types:n}=t;if(1===n.length&&"text/plain"===n[0])return;e.preventDefault();let i=nO.#iN(t.getData("text")||"").replaceAll(nD,"\n");if(!i)return;let r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();let s=r.getRangeAt(0);if(!i.includes("\n")){s.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),r.collapseToStart();return}let{startContainer:o,startOffset:a}=s,l=[],d=[];if(o.nodeType===Node.TEXT_NODE){let e=o.parentElement;if(d.push(o.nodeValue.slice(a).replaceAll(nD,"")),e!==this.editorDiv){let t=l;for(let n of this.editorDiv.childNodes){if(n===e){t=d;continue}t.push(nO.#iO(n))}}l.push(o.nodeValue.slice(0,a).replaceAll(nD,""))}else if(o===this.editorDiv){let e=l,t=0;for(let n of this.editorDiv.childNodes)t++===a&&(e=d),e.push(nO.#iO(n))}this.#iE=`${l.join("\n")}${i}${d.join("\n")}`,this.#iI();let c=new Range,h=l.reduce((e,t)=>e+t.length,0);for(let{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){let t=e.nodeValue.length;if(h<=t){c.setStart(e,h),c.setEnd(e,h);break}h-=t}r.removeAllRanges(),r.addRange(c)}#iI(){if(this.editorDiv.replaceChildren(),!!this.#iE)for(let e of this.#iE.split("\n")){let t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}}#iR(){return this.#iE.replaceAll("\xa0"," ")}static #iN(e){return e.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}static deserialize(e,t,n){let i=null;if(e instanceof nm){let{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:r,rotation:s,id:o},textContent:a,textPosition:l,parent:{page:{pageNumber:d}}}=e;if(!a||0===a.length)return null;i=e={annotationType:h.FREETEXT,color:Array.from(n),fontSize:t,value:a.join("\n"),position:l,pageIndex:d-1,rect:r.slice(0),rotation:s,id:o,deleted:!1}}let r=super.deserialize(e,t,n);return r.#it=e.fontSize,r.#nJ=U.makeHexColor(...e.color),r.#iE=nO.#iN(e.value),r.annotationElementId=e.id||null,r.#iA=i,r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};let t=nO._internalPadding*this.parentScale,n=this.getRect(t,t),i=eO._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#nJ),r={annotationType:h.FREETEXT,color:i,fontSize:this.#it,value:this.#iR(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?r:this.annotationElementId&&!this.#iL(r)?null:(r.id=this.annotationElementId,r)}#iL(e){let{value:t,fontSize:n,color:i,pageIndex:r}=this.#iA;return this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some((e,t)=>e!==i[t])||e.pageIndex!==r}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);if(this.deleted)return t;let{style:n}=t;for(let e of(n.fontSize=`calc(${this.#it}px * var(--scale-factor))`,n.color=this.#nJ,t.replaceChildren(),this.#iE.split("\n"))){let n=document.createElement("div");n.append(e?document.createTextNode(e):document.createElement("br")),t.append(n)}let i=nO._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(i,i),popupContent:this.#iE}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}}class nI{#iP;#ij=[];#iF=[];constructor(e,t=0,n=0,i=!0){let r=1/0,s=-1/0,o=1/0,a=-1/0;for(let{x:n,y:i,width:l,height:d}of e){let e=1e-4*Math.floor((n-t)/1e-4),c=1e-4*Math.ceil((n+l+t)/1e-4),h=1e-4*Math.floor((i-t)/1e-4),u=1e-4*Math.ceil((i+d+t)/1e-4),p=[e,h,u,!0],f=[c,h,u,!1];this.#ij.push(p,f),r=Math.min(r,e),s=Math.max(s,c),o=Math.min(o,h),a=Math.max(a,u)}let l=s-r+2*n,d=a-o+2*n,c=r-n,h=o-n,u=this.#ij.at(i?-1:-2),p=[u[0],u[2]];for(let e of this.#ij){let[t,n,i]=e;e[0]=(t-c)/l,e[1]=(n-h)/d,e[2]=(i-h)/d}this.#iP={x:c,y:h,width:l,height:d,lastPoint:p}}getOutlines(){this.#ij.sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of this.#ij)t[3]?(e.push(...this.#iB(t)),this.#iz(t)):(this.#iH(t),e.push(...this.#iB(t)));return this.#iU(e)}#iU(e){let t;let n=[],i=new Set;for(let t of e){let[e,i,r]=t;n.push([e,i,t],[e,r,t])}n.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,t=n.length;e<t;e+=2){let t=n[e][2],r=n[e+1][2];t.push(r),r.push(t),i.add(t),i.add(r)}let r=[];for(;i.size>0;){let e=i.values().next().value,[n,s,o,a,l]=e;i.delete(e);let d=n,c=s;for(t=[n,o],r.push(t);;){let e;if(i.has(a))e=a;else if(i.has(l))e=l;else break;i.delete(e),[n,s,o,a,l]=e,d!==n&&(t.push(d,c,n,c===s?s:o),d=n),c=c===s?o:s}t.push(d,c)}return new nR(r,this.#iP)}#iV(e){let t=this.#iF,n=0,i=t.length-1;for(;n<=i;){let r=n+i>>1,s=t[r][0];if(s===e)return r;s<e?n=r+1:i=r-1}return i+1}#iz([,e,t]){let n=this.#iV(e);this.#iF.splice(n,0,[e,t])}#iH([,e,t]){let n=this.#iV(e);for(let i=n;i<this.#iF.length;i++){let[n,r]=this.#iF[i];if(n!==e)break;if(n===e&&r===t){this.#iF.splice(i,1);return}}for(let i=n-1;i>=0;i--){let[n,r]=this.#iF[i];if(n!==e)break;if(n===e&&r===t){this.#iF.splice(i,1);return}}}#iB(e){let[t,n,i]=e,r=[[t,n,i]],s=this.#iV(i);for(let e=0;e<s;e++){let[n,i]=this.#iF[e];for(let e=0,s=r.length;e<s;e++){let[,o,a]=r[e];if(!(i<=o)&&!(a<=n)){if(o>=n){if(a>i)r[e][1]=i;else{if(1===s)return[];r.splice(e,1),e--,s--}continue}r[e][2]=n,a>i&&r.push([t,i,a])}}}return r}}class nN{toSVGPath(){throw Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw Error("Abstract getter `box` must be implemented.")}serialize(e,t){throw Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof nP}}class nR extends nN{#iP;#i$;constructor(e,t){super(),this.#i$=e,this.#iP=t}toSVGPath(){let e=[];for(let t of this.#i$){let[n,i]=t;e.push(`M${n} ${i}`);for(let r=2;r<t.length;r+=2){let s=t[r],o=t[r+1];s===n?(e.push(`V${o}`),i=o):o===i&&(e.push(`H${s}`),n=s)}e.push("Z")}return e.join(" ")}serialize([e,t,n,i],r){let s=[],o=n-e,a=i-t;for(let t of this.#i$){let n=Array(t.length);for(let r=0;r<t.length;r+=2)n[r]=e+t[r]*o,n[r+1]=i-t[r+1]*a;s.push(n)}return s}get box(){return this.#iP}}class nL{#iP;#iW=[];#iG;#iZ;#iq=[];#iK=new Float64Array(18);#iY;#iX;#iJ;#iQ;#i0;#i1;#i2=[];static #i5=8;static #i3=2;static #i4=nL.#i5+nL.#i3;constructor({x:e,y:t},n,i,r,s,o=0){this.#iP=n,this.#i1=r*i,this.#iZ=s,this.#iK.set([NaN,NaN,NaN,NaN,e,t],6),this.#iG=o,this.#iQ=nL.#i5*i,this.#iJ=nL.#i4*i,this.#i0=i,this.#i2.push(e,t)}get free(){return!0}isEmpty(){return isNaN(this.#iK[8])}#i6(){let e=this.#iK.subarray(4,6),t=this.#iK.subarray(16,18),[n,i,r,s]=this.#iP;return[(this.#iY+(e[0]-t[0])/2-n)/r,(this.#iX+(e[1]-t[1])/2-i)/s,(this.#iY+(t[0]-e[0])/2-n)/r,(this.#iX+(t[1]-e[1])/2-i)/s]}add({x:e,y:t}){this.#iY=e,this.#iX=t;let[n,i,r,s]=this.#iP,[o,a,l,d]=this.#iK.subarray(8,12),c=e-l,h=t-d,u=Math.hypot(c,h);if(u<this.#iJ)return!1;let p=u-this.#iQ,f=p/u,m=f*c,g=f*h,v=o,b=a;o=l,a=d,l+=m,d+=g,this.#i2?.push(e,t);let y=-g/p*this.#i1,x=m/p*this.#i1;return(this.#iK.set(this.#iK.subarray(2,8),0),this.#iK.set([l+y,d+x],4),this.#iK.set(this.#iK.subarray(14,18),12),this.#iK.set([l-y,d-x],16),isNaN(this.#iK[6]))?(0===this.#iq.length&&(this.#iK.set([o+y,a+x],2),this.#iq.push(NaN,NaN,NaN,NaN,(o+y-n)/r,(a+x-i)/s),this.#iK.set([o-y,a-x],14),this.#iW.push(NaN,NaN,NaN,NaN,(o-y-n)/r,(a-x-i)/s)),this.#iK.set([v,b,o,a,l,d],6),!this.isEmpty()):(this.#iK.set([v,b,o,a,l,d],6),Math.abs(Math.atan2(b-a,v-o)-Math.atan2(g,m))<Math.PI/2)?([o,a,l,d]=this.#iK.subarray(2,6),this.#iq.push(NaN,NaN,NaN,NaN,((o+l)/2-n)/r,((a+d)/2-i)/s),[o,a,v,b]=this.#iK.subarray(14,18),this.#iW.push(NaN,NaN,NaN,NaN,((v+o)/2-n)/r,((b+a)/2-i)/s),!0):([v,b,o,a,l,d]=this.#iK.subarray(0,6),this.#iq.push(((v+5*o)/6-n)/r,((b+5*a)/6-i)/s,((5*o+l)/6-n)/r,((5*a+d)/6-i)/s,((o+l)/2-n)/r,((a+d)/2-i)/s),[l,d,o,a,v,b]=this.#iK.subarray(12,18),this.#iW.push(((v+5*o)/6-n)/r,((b+5*a)/6-i)/s,((5*o+l)/6-n)/r,((5*a+d)/6-i)/s,((o+l)/2-n)/r,((a+d)/2-i)/s),!0)}toSVGPath(){if(this.isEmpty())return"";let e=this.#iq,t=this.#iW,n=this.#iK.subarray(4,6),i=this.#iK.subarray(16,18),[r,s,o,a]=this.#iP,[l,d,c,h]=this.#i6();if(isNaN(this.#iK[6])&&!this.isEmpty())return`M${(this.#iK[2]-r)/o} ${(this.#iK[3]-s)/a} L${(this.#iK[4]-r)/o} ${(this.#iK[5]-s)/a} L${l} ${d} L${c} ${h} L${(this.#iK[16]-r)/o} ${(this.#iK[17]-s)/a} L${(this.#iK[14]-r)/o} ${(this.#iK[15]-s)/a} Z`;let u=[];u.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?u.push(`L${e[t+4]} ${e[t+5]}`):u.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);u.push(`L${(n[0]-r)/o} ${(n[1]-s)/a} L${l} ${d} L${c} ${h} L${(i[0]-r)/o} ${(i[1]-s)/a}`);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?u.push(`L${t[e+4]} ${t[e+5]}`):u.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return u.push(`L${t[4]} ${t[5]} Z`),u.join(" ")}getOutlines(){let e=this.#iq,t=this.#iW,n=this.#iK,i=n.subarray(4,6),r=n.subarray(16,18),[s,o,a,l]=this.#iP,d=new Float64Array((this.#i2?.length??0)+2);for(let e=0,t=d.length-2;e<t;e+=2)d[e]=(this.#i2[e]-s)/a,d[e+1]=(this.#i2[e+1]-o)/l;d[d.length-2]=(this.#iY-s)/a,d[d.length-1]=(this.#iX-o)/l;let[c,h,u,p]=this.#i6();if(isNaN(n[6])&&!this.isEmpty()){let e=new Float64Array(36);return e.set([NaN,NaN,NaN,NaN,(n[2]-s)/a,(n[3]-o)/l,NaN,NaN,NaN,NaN,(n[4]-s)/a,(n[5]-o)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,(n[16]-s)/a,(n[17]-o)/l,NaN,NaN,NaN,NaN,(n[14]-s)/a,(n[15]-o)/l],0),new nP(e,d,this.#iP,this.#i0,this.#iG,this.#iZ)}let f=new Float64Array(this.#iq.length+24+this.#iW.length),m=e.length;for(let t=0;t<m;t+=2){if(isNaN(e[t])){f[t]=f[t+1]=NaN;continue}f[t]=e[t],f[t+1]=e[t+1]}f.set([NaN,NaN,NaN,NaN,(i[0]-s)/a,(i[1]-o)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,(r[0]-s)/a,(r[1]-o)/l],m),m+=24;for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2){if(isNaN(t[e+n])){f[m]=f[m+1]=NaN,m+=2;continue}f[m]=t[e+n],f[m+1]=t[e+n+1],m+=2}return f.set([NaN,NaN,NaN,NaN,t[4],t[5]],m),new nP(f,d,this.#iP,this.#i0,this.#iG,this.#iZ)}}class nP extends nN{#iP;#i8=null;#iG;#iZ;#i2;#i0;#i7;constructor(e,t,n,i,r,s){super(),this.#i7=e,this.#i2=t,this.#iP=n,this.#i0=i,this.#iG=r,this.#iZ=s,this.#i9(s);let{x:o,y:a,width:l,height:d}=this.#i8;for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-o)/l,e[t+1]=(e[t+1]-a)/d;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-o)/l,t[e+1]=(t[e+1]-a)/d}toSVGPath(){let e=[`M${this.#i7[4]} ${this.#i7[5]}`];for(let t=6,n=this.#i7.length;t<n;t+=6){if(isNaN(this.#i7[t])){e.push(`L${this.#i7[t+4]} ${this.#i7[t+5]}`);continue}e.push(`C${this.#i7[t]} ${this.#i7[t+1]} ${this.#i7[t+2]} ${this.#i7[t+3]} ${this.#i7[t+4]} ${this.#i7[t+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,t,n,i],r){let s,o;let a=n-e,l=i-t;switch(r){case 0:s=this.#re(this.#i7,e,i,a,-l),o=this.#re(this.#i2,e,i,a,-l);break;case 90:s=this.#rt(this.#i7,e,t,a,l),o=this.#rt(this.#i2,e,t,a,l);break;case 180:s=this.#re(this.#i7,n,t,-a,l),o=this.#re(this.#i2,n,t,-a,l);break;case 270:s=this.#rt(this.#i7,n,i,-a,-l),o=this.#rt(this.#i2,n,i,-a,-l)}return{outline:Array.from(s),points:[Array.from(o)]}}#re(e,t,n,i,r){let s=new Float64Array(e.length);for(let o=0,a=e.length;o<a;o+=2)s[o]=t+e[o]*i,s[o+1]=n+e[o+1]*r;return s}#rt(e,t,n,i,r){let s=new Float64Array(e.length);for(let o=0,a=e.length;o<a;o+=2)s[o]=t+e[o+1]*i,s[o+1]=n+e[o]*r;return s}#i9(e){let t=this.#i7,n=t[4],i=t[5],r=n,s=i,o=n,a=i,l=n,d=i,c=e?Math.max:Math.min;for(let e=6,h=t.length;e<h;e+=6){if(isNaN(t[e]))r=Math.min(r,t[e+4]),s=Math.min(s,t[e+5]),o=Math.max(o,t[e+4]),a=Math.max(a,t[e+5]),d<t[e+5]?(l=t[e+4],d=t[e+5]):d===t[e+5]&&(l=c(l,t[e+4]));else{let h=U.bezierBoundingBox(n,i,...t.slice(e,e+6));r=Math.min(r,h[0]),s=Math.min(s,h[1]),o=Math.max(o,h[2]),a=Math.max(a,h[3]),d<h[3]?(l=h[2],d=h[3]):d===h[3]&&(l=c(l,h[2]))}n=t[e+4],i=t[e+5]}let h=r-this.#iG,u=s-this.#iG,p=o-r+2*this.#iG,f=a-s+2*this.#iG;this.#i8={x:h,y:u,width:p,height:f,lastPoint:[l,d]}}get box(){return this.#i8}getNewOutline(e,t){let{x:n,y:i,width:r,height:s}=this.#i8,[o,a,l,d]=this.#iP,c=r*l,h=s*d,u=n*l+o,p=i*d+a,f=new nL({x:this.#i2[0]*c+u,y:this.#i2[1]*h+p},this.#iP,this.#i0,e,this.#iZ,t??this.#iG);for(let e=2;e<this.#i2.length;e+=2)f.add({x:this.#i2[e]*c+u,y:this.#i2[e+1]*h+p});return f.getOutlines()}}class nj{#n$=this.#nW.bind(this);#rn=this.#a.bind(this);#ri=null;#rr=null;#rs;#ro=null;#ra=!1;#rl=!1;#s=null;#rd;#p=null;#rc;static get _keyboardManager(){return T(this,"_keyboardManager",new ek([[["Escape","mac+Escape"],nj.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],nj.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],nj.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],nj.prototype._moveToPrevious],[["Home","mac+Home"],nj.prototype._moveToBeginning],[["End","mac+End"],nj.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){e?(this.#rl=!1,this.#rc=u.HIGHLIGHT_COLOR,this.#s=e):(this.#rl=!0,this.#rc=u.HIGHLIGHT_DEFAULT_COLOR),this.#p=e?._uiManager||t,this.#rd=this.#p._eventBus,this.#rs=e?.color||this.#p?.highlightColors.values().next().value||"#FFFF98"}renderButton(){let e=this.#ri=document.createElement("button");e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);let t=this.#p._signal;e.addEventListener("click",this.#rh.bind(this),{signal:t}),e.addEventListener("keydown",this.#n$,{signal:t});let n=this.#rr=document.createElement("span");return n.className="swatch",n.setAttribute("aria-hidden",!0),n.style.backgroundColor=this.#rs,e.append(n),e}renderMainDropdown(){let e=this.#ro=this.#ru();return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}#ru(){let e=document.createElement("div"),t=this.#p._signal;for(let[n,i]of(e.addEventListener("contextmenu",ep,{signal:t}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#p.highlightColors)){let r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=n,r.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${n}`);let s=document.createElement("span");r.append(s),s.className="swatch",s.style.backgroundColor=i,r.setAttribute("aria-selected",i===this.#rs),r.addEventListener("click",this.#rp.bind(this,i),{signal:t}),e.append(r)}return e.addEventListener("keydown",this.#n$,{signal:t}),e}#rp(e,t){t.stopPropagation(),this.#rd.dispatch("switchannotationeditorparams",{source:this,type:this.#rc,value:e})}_colorSelectFromKeyboard(e){if(e.target===this.#ri){this.#rh(e);return}let t=e.target.getAttribute("data-color");if(!!t)this.#rp(t,e)}_moveToNext(e){if(!this.#rf){this.#rh(e);return}if(e.target===this.#ri){this.#ro.firstChild?.focus();return}e.target.nextSibling?.focus()}_moveToPrevious(e){if(e.target===this.#ro?.firstChild||e.target===this.#ri){this.#rf&&this._hideDropdownFromKeyboard();return}!this.#rf&&this.#rh(e),e.target.previousSibling?.focus()}_moveToBeginning(e){if(!this.#rf){this.#rh(e);return}this.#ro.firstChild?.focus()}_moveToEnd(e){if(!this.#rf){this.#rh(e);return}this.#ro.lastChild?.focus()}#nW(e){nj._keyboardManager.exec(this,e)}#rh(e){if(this.#rf){this.hideDropdown();return}if(this.#ra=0===e.detail,window.addEventListener("pointerdown",this.#rn,{signal:this.#p._signal}),this.#ro){this.#ro.classList.remove("hidden");return}let t=this.#ro=this.#ru();this.#ri.append(t)}#a(e){if(!this.#ro?.contains(e.target))this.hideDropdown()}hideDropdown(){this.#ro?.classList.add("hidden"),window.removeEventListener("pointerdown",this.#rn)}get #rf(){return this.#ro&&!this.#ro.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#rl){if(!this.#rf){this.#s?.unselect();return}this.hideDropdown(),this.#ri.focus({preventScroll:!0,focusVisible:this.#ra})}}updateColor(e){if(this.#rr&&(this.#rr.style.backgroundColor=e),!this.#ro)return;let t=this.#p.highlightColors.values();for(let n of this.#ro.children)n.setAttribute("aria-selected",t.next().value===e)}destroy(){this.#ri?.remove(),this.#ri=null,this.#rr=null,this.#ro?.remove(),this.#ro=null}}class nF extends eO{#rm=null;#rg=0;#rv;#rb=null;#r=null;#ry=null;#rx=null;#rw=0;#r_=null;#rS=null;#v=null;#rE=!1;#ea=this.#rC.bind(this);#rA=null;#rk;#rT=null;#rM="";#i1;#rD="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _l10nPromise;static _type="highlight";static _editorType=h.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let e=nF.prototype;return T(this,"_keyboardManager",new ek([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:"highlightEditor"}),this.color=e.color||nF._defaultColor,this.#i1=e.thickness||nF._defaultThickness,this.#rk=e.opacity||nF._defaultOpacity,this.#rv=e.boxes||null,this.#rD=e.methodOfCreation||"",this.#rM=e.text||"",this._isDraggable=!1,e.highlightId>-1?(this.#rE=!0,this.#rO(e),this.#rI()):(this.#rm=e.anchorNode,this.#rg=e.anchorOffset,this.#rx=e.focusNode,this.#rw=e.focusOffset,this.#rN(),this.#rI(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#rE?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#i1,methodOfCreation:this.#rD}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}#rN(){let e=new nI(this.#rv,.001);this.#rS=e.getOutlines(),{x:this.x,y:this.y,width:this.width,height:this.height}=this.#rS.box;let t=new nI(this.#rv,.0025,.001,"ltr"===this._uiManager.direction);this.#ry=t.getOutlines();let{lastPoint:n}=this.#ry.box;this.#rA=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#rO({highlightOutlines:e,highlightId:t,clipPathId:n}){this.#rS=e;if(this.#ry=e.getNewOutline(this.#i1/2+1.5,.0025),t>=0)this.#v=t,this.#rb=n,this.parent.drawLayer.finalizeLine(t,e),this.#rT=this.parent.drawLayer.highlightOutline(this.#ry);else if(this.parent){let t=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#v,e),this.parent.drawLayer.updateBox(this.#v,nF.#rR(this.#rS.box,(t-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#rT,this.#ry),this.parent.drawLayer.updateBox(this.#rT,nF.#rR(this.#ry.box,t))}let{x:i,y:r,width:s,height:o}=e.box;switch(this.rotation){case 0:this.x=i,this.y=r,this.width=s,this.height=o;break;case 90:{let[e,t]=this.parentDimensions;this.x=r,this.y=1-i,this.width=s*t/e,this.height=o*e/t;break}case 180:this.x=1-i,this.y=1-r,this.width=s,this.height=o;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-r,this.y=i,this.width=s*t/e,this.height=o*e/t}}let{lastPoint:a}=this.#ry.box;this.#rA=[(a[0]-i)/s,(a[1]-r)/o]}static initialize(e,t){eO.initialize(e,t),nF._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case u.HIGHLIGHT_DEFAULT_COLOR:nF._defaultColor=t;break;case u.HIGHLIGHT_THICKNESS:nF._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#rA}updateParams(e,t){switch(e){case u.HIGHLIGHT_COLOR:this.#iT(t);break;case u.HIGHLIGHT_THICKNESS:this.#rL(t)}}static get defaultPropertiesToUpdate(){return[[u.HIGHLIGHT_DEFAULT_COLOR,nF._defaultColor],[u.HIGHLIGHT_THICKNESS,nF._defaultThickness]]}get propertiesToUpdate(){return[[u.HIGHLIGHT_COLOR,this.color||nF._defaultColor],[u.HIGHLIGHT_THICKNESS,this.#i1||nF._defaultThickness],[u.HIGHLIGHT_FREE,this.#rE]]}#iT(e){let t=e=>{this.color=e,this.parent?.drawLayer.changeColor(this.#v,e),this.#r?.updateColor(e)},n=this.color;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)}#rL(e){let t=this.#i1,n=e=>{this.#i1=e,this.#rP(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)}async addEditToolbar(){let e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(this.#r=new nj({editor:this}),e.addColorPicker(this.#r)),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#rj())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#rj())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#rF(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),null!==this.div)this.#rI(),!this.isAttachedToDOM&&this.parent.add(this)}setParent(e){let t=!1;this.parent&&!e?this.#rF():e&&(this.#rI(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),this.show(this._isVisible),t&&this.select()}#rP(e){if(!this.#rE)return;this.#rO({highlightOutlines:this.#rS.getNewOutline(e/2)}),this.fixAndSetPosition();let[t,n]=this.parentDimensions;this.setDims(this.width*t,this.height*n)}#rF(){if(null!==this.#v&&!!this.parent)this.parent.drawLayer.remove(this.#v),this.#v=null,this.parent.drawLayer.remove(this.#rT),this.#rT=null}#rI(e=this.parent){if(null===this.#v)({id:this.#v,clipPathId:this.#rb}=e.drawLayer.highlight(this.#rS,this.color,this.#rk)),this.#rT=e.drawLayer.highlightOutline(this.#ry),this.#r_&&(this.#r_.style.clipPath=this.#rb)}static #rR({x:e,y:t,width:n,height:i},r){switch(r){case 90:return{x:1-t-i,y:e,width:i,height:n};case 180:return{x:1-e-n,y:1-t-i,width:n,height:i};case 270:return{x:t,y:1-e-n,width:i,height:n}}return{x:e,y:t,width:n,height:i}}rotate(e){let t;let{drawLayer:n}=this.parent;this.#rE?(e=(e-this.rotation+360)%360,t=nF.#rR(this.#rS.box,e)):t=nF.#rR(this,e),n.rotate(this.#v,e),n.rotate(this.#rT,e),n.updateBox(this.#v,t),n.updateBox(this.#rT,nF.#rR(this.#ry.box,e))}render(){if(this.div)return this.div;let e=super.render();this.#rM&&(e.setAttribute("aria-label",this.#rM),e.setAttribute("role","mark")),this.#rE?e.classList.add("free"):this.div.addEventListener("keydown",this.#ea,{signal:this._uiManager._signal});let t=this.#r_=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal",t.style.clipPath=this.#rb;let[n,i]=this.parentDimensions;return this.setDims(this.width*n,this.height*i),eS(this,this.#r_,["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.parent.drawLayer.addClass(this.#rT,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#rT,"hovered")}#rC(e){nF._keyboardManager.exec(this,e)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#rB(!0);break;case 1:case 3:this.#rB(!1)}}#rB(e){if(!this.#rm)return;let t=window.getSelection();e?t.setPosition(this.#rm,this.#rg):t.setPosition(this.#rx,this.#rw)}select(){if(super.select(),!!this.#rT)this.parent?.drawLayer.removeClass(this.#rT,"hovered"),this.parent?.drawLayer.addClass(this.#rT,"selected")}unselect(){if(super.unselect(),!!this.#rT)this.parent?.drawLayer.removeClass(this.#rT,"selected"),!this.#rE&&this.#rB(!1)}get _mustFixPosition(){return!this.#rE}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(this.#v,e),this.parent.drawLayer.show(this.#rT,e))}#rj(){return this.#rE?this.rotation:0}#rz(){if(this.#rE)return null;let[e,t]=this.pageDimensions,n=this.#rv,i=new Float32Array(8*n.length),r=0;for(let{x:s,y:o,width:a,height:l}of n){let n=s*e,d=(1-o-l)*t;i[r]=i[r+4]=n,i[r+1]=i[r+3]=d,i[r+2]=i[r+6]=n+a*e,i[r+5]=i[r+7]=d+l*t,r+=8}return i}#rH(e){return this.#rS.serialize(e,this.#rj())}static startHighlighting(e,t,{target:n,x:i,y:r}){let{x:s,y:o,width:a,height:l}=n.getBoundingClientRect(),d=t=>{this.#rU(e,t)},c=e._signal,h={capture:!0,passive:!1,signal:c},u=e=>{e.preventDefault(),e.stopPropagation()},p=t=>{n.removeEventListener("pointermove",d),window.removeEventListener("blur",p),window.removeEventListener("pointerup",p),window.removeEventListener("pointerdown",u,h),window.removeEventListener("contextmenu",ep),this.#rV(e,t)};window.addEventListener("blur",p,{signal:c}),window.addEventListener("pointerup",p,{signal:c}),window.addEventListener("pointerdown",u,h),window.addEventListener("contextmenu",ep,{signal:c}),n.addEventListener("pointermove",d,{signal:c}),this._freeHighlight=new nL({x:i,y:r},[s,o,a,l],e.scale,this._defaultThickness/2,t,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static #rU(e,t){this._freeHighlight.add(t)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static #rV(e,t){this._freeHighlight.isEmpty()?e.drawLayer.removeFreeHighlight(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static deserialize(e,t,n){let i=super.deserialize(e,t,n),{rect:[r,s,o,a],color:l,quadPoints:d}=e;i.color=U.makeHexColor(...l),i.#rk=e.opacity;let[c,h]=i.pageDimensions;i.width=(o-r)/c,i.height=(a-s)/h;let u=i.#rv=[];for(let e=0;e<d.length;e+=8)u.push({x:(d[4]-o)/c,y:(a-(1-d[e+5]))/h,width:(d[e+2]-d[e])/c,height:(d[e+5]-d[e+1])/h});return i.#rN(),i}serialize(e=!1){if(this.isEmpty()||e)return null;let t=this.getRect(0,0),n=eO._colorManager.convert(this.color);return{annotationType:h.HIGHLIGHT,color:n,opacity:this.#rk,thickness:this.#i1,quadPoints:this.#rz(),outlines:this.#rH(t),pageIndex:this.pageIndex,rect:t,rotation:this.#rj(),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}}class nB extends eO{#r$=0;#rW=0;#rG=this.canvasPointermove.bind(this);#rZ=this.canvasPointerleave.bind(this);#rq=this.canvasPointerup.bind(this);#rK=this.canvasPointerdown.bind(this);#rY=null;#rX=new Path2D;#rJ=!1;#rQ=!1;#r0=!1;#r1=null;#r2=0;#r5=0;#r3=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=h.INK;constructor(e){super({...e,name:"inkEditor"}),this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(e,t){eO.initialize(e,t)}static updateDefaultParams(e,t){switch(e){case u.INK_THICKNESS:nB._defaultThickness=t;break;case u.INK_COLOR:nB._defaultColor=t;break;case u.INK_OPACITY:nB._defaultOpacity=t/100}}updateParams(e,t){switch(e){case u.INK_THICKNESS:this.#rL(t);break;case u.INK_COLOR:this.#iT(t);break;case u.INK_OPACITY:this.#r4(t)}}static get defaultPropertiesToUpdate(){return[[u.INK_THICKNESS,nB._defaultThickness],[u.INK_COLOR,nB._defaultColor||eO._defaultLineColor],[u.INK_OPACITY,Math.round(100*nB._defaultOpacity)]]}get propertiesToUpdate(){return[[u.INK_THICKNESS,this.thickness||nB._defaultThickness],[u.INK_COLOR,this.color||nB._defaultColor||eO._defaultLineColor],[u.INK_OPACITY,Math.round(100*(this.opacity??nB._defaultOpacity))]]}#rL(e){let t=e=>{this.thickness=e,this.#r6()},n=this.thickness;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#iT(e){let t=e=>{this.color=e,this.#r8()},n=this.color;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#r4(e){let t=e=>{this.opacity=e,this.#r8()};e/=100;let n=this.opacity;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){if(!this.parent)return;if(super.rebuild(),null!==this.div)!this.canvas&&(this.#r7(),this.#r9()),!this.isAttachedToDOM&&(this.parent.add(this),this.#se()),this.#r6()}remove(){if(null!==this.canvas)!this.isEmpty()&&this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#rY&&(clearTimeout(this.#rY),this.#rY=null),this.#r1?.disconnect(),this.#r1=null,super.remove()}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&null===e&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){let[e,t]=this.parentDimensions,n=this.width*e,i=this.height*t;this.setDimensions(n,i)}enableEditMode(){if(!this.#rJ&&null!==this.canvas)super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#rK,{signal:this._uiManager._signal})}disableEditMode(){if(!!this.isInEditMode()&&null!==this.canvas)super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",this.#rK)}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}#st(){let{parentRotation:e,parentDimensions:[t,n]}=this;switch(e){case 90:return[0,n,n,t];case 180:return[t,n,t,n];case 270:return[t,0,n,t];default:return[0,0,t,n]}}#sn(){let{ctx:e,color:t,opacity:n,thickness:i,parentScale:r,scaleFactor:s}=this;e.lineWidth=i*r/s,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${t}${Math.round(Math.min(255,Math.max(1,255*n))).toString(16).padStart(2,"0")}`}#si(e,t){let n=this._uiManager._signal;this.canvas.addEventListener("contextmenu",ep,{signal:n}),this.canvas.addEventListener("pointerleave",this.#rZ,{signal:n}),this.canvas.addEventListener("pointermove",this.#rG,{signal:n}),this.canvas.addEventListener("pointerup",this.#rq,{signal:n}),this.canvas.removeEventListener("pointerdown",this.#rK),this.isEditing=!0,!this.#r0&&(this.#r0=!0,this.#se(),this.thickness||=nB._defaultThickness,this.color||=nB._defaultColor||eO._defaultLineColor,this.opacity??=nB._defaultOpacity),this.currentPath.push([e,t]),this.#rQ=!1,this.#sn(),this.#r3=()=>{this.#sr(),this.#r3&&window.requestAnimationFrame(this.#r3)},window.requestAnimationFrame(this.#r3)}#ss(e,t){let[n,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===n&&t===i)return;let r=this.currentPath,s=this.#rX;if(r.push([e,t]),this.#rQ=!0,r.length<=2){s.moveTo(...r[0]),s.lineTo(e,t);return}3===r.length&&(this.#rX=s=new Path2D,s.moveTo(...r[0])),this.#so(s,...r.at(-3),...r.at(-2),e,t)}#sa(){if(0===this.currentPath.length)return;let e=this.currentPath.at(-1);this.#rX.lineTo(...e)}#sl(e,t){let n;if(this.#r3=null,e=Math.min(Math.max(e,0),this.canvas.width),t=Math.min(Math.max(t,0),this.canvas.height),this.#ss(e,t),this.#sa(),1!==this.currentPath.length)n=this.#sd();else{let i=[e,t];n=[[i,i.slice(),i.slice(),i]]}let i=this.#rX,r=this.currentPath;this.currentPath=[],this.#rX=new Path2D;this.addCommands({cmd:()=>{this.allRawPaths.push(r),this.paths.push(n),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(!this.canvas&&(this.#r7(),this.#r9()),this.#r6())},mustExec:!0})}#sr(){if(!this.#rQ)return;this.#rQ=!1,this.thickness,this.parentScale;let e=this.currentPath.slice(-3);e.map(e=>e[0]),e.map(e=>e[1]);let{ctx:t}=this;for(let e of(t.save(),t.clearRect(0,0,this.canvas.width,this.canvas.height),this.bezierPath2D))t.stroke(e);t.stroke(this.#rX),t.restore()}#so(e,t,n,i,r,s,o){let a=(t+i)/2,l=(n+r)/2,d=(i+s)/2,c=(r+o)/2;e.bezierCurveTo(a+2*(i-a)/3,l+2*(r-l)/3,d+2*(i-d)/3,c+2*(r-c)/3,d,c)}#sd(){let e;let t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];let n=[],[i,r]=t[0];for(e=1;e<t.length-2;e++){let[s,o]=t[e],[a,l]=t[e+1],d=(s+a)/2,c=(o+l)/2,h=[i+2*(s-i)/3,r+2*(o-r)/3],u=[d+2*(s-d)/3,c+2*(o-c)/3];n.push([[i,r],h,u,[d,c]]),[i,r]=[d,c]}let[s,o]=t[e],[a,l]=t[e+1],d=[i+2*(s-i)/3,r+2*(o-r)/3];return n.push([[i,r],d,[a+2*(s-a)/3,l+2*(o-l)/3],[a,l]]),n}#r8(){if(this.isEmpty()){this.#sc();return}this.#sn();let{canvas:e,ctx:t}=this;for(let n of(t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.width,e.height),this.#sc(),this.bezierPath2D))t.stroke(n)}commit(){if(!this.#rJ)super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),this.#rJ=!0,this.div.classList.add("disabled"),this.#r6(!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0})}focusin(e){if(!!this._focusEventsAllowed)super.focusin(e),this.enableEditMode()}canvasPointerdown(e){if(0===e.button&&!!this.isInEditMode()&&!this.#rJ)this.setInForeground(),e.preventDefault(),!this.div.contains(document.activeElement)&&this.div.focus({preventScroll:!0}),this.#si(e.offsetX,e.offsetY)}canvasPointermove(e){e.preventDefault(),this.#ss(e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),this.#sh(e)}canvasPointerleave(e){this.#sh(e)}#sh(e){this.canvas.removeEventListener("pointerleave",this.#rZ),this.canvas.removeEventListener("pointermove",this.#rG),this.canvas.removeEventListener("pointerup",this.#rq),this.canvas.addEventListener("pointerdown",this.#rK,{signal:this._uiManager._signal}),this.#rY&&clearTimeout(this.#rY),this.#rY=setTimeout(()=>{this.#rY=null,this.canvas.removeEventListener("contextmenu",ep)},10),this.#sl(e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#r7(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#r9(){this.#r1=new ResizeObserver(e=>{let t=e[0].contentRect;t.width&&t.height&&this.setDimensions(t.width,t.height)}),this.#r1.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#r1?.disconnect(),this.#r1=null},{once:!0})}get isResizable(){return!this.isEmpty()&&this.#rJ}render(){let e,t;if(this.div)return this.div;this.width&&(e=this.x,t=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");let[n,i,r,s]=this.#st();if(this.setAt(n,i,0,0),this.setDims(r,s),this.#r7(),this.width){let[n,i]=this.parentDimensions;this.setAspectRatio(this.width*n,this.height*i),this.setAt(e*n,t*i,this.width*n,this.height*i),this.#r0=!0,this.#se(),this.setDims(this.width*n,this.height*i),this.#r8(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#r9(),this.div}#se(){if(!this.#r0)return;let[e,t]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*t),this.#sc()}setDimensions(e,t){let n=Math.round(e),i=Math.round(t);if(this.#r2===n&&this.#r5===i)return;this.#r2=n,this.#r5=i,this.canvas.style.visibility="hidden";let[r,s]=this.parentDimensions;this.width=e/r,this.height=t/s,this.fixAndSetPosition(),this.#rJ&&this.#su(e,t),this.#se(),this.#r8(),this.canvas.style.visibility="visible",this.fixDims()}#su(e,t){let n=this.#sp(),i=(e-n)/this.#rW,r=(t-n)/this.#r$;this.scaleFactor=Math.min(i,r)}#sc(){let e=this.#sp()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)}static #sf(e){let t=new Path2D;for(let n=0,i=e.length;n<i;n++){let[i,r,s,o]=e[n];0===n&&t.moveTo(...i),t.bezierCurveTo(r[0],r[1],s[0],s[1],o[0],o[1])}return t}static #sm(e,t,n){let[i,r,s,o]=t;switch(n){case 0:for(let t=0,n=e.length;t<n;t+=2)e[t]+=i,e[t+1]=o-e[t+1];break;case 90:for(let t=0,n=e.length;t<n;t+=2){let n=e[t];e[t]=e[t+1]+i,e[t+1]=n+r}break;case 180:for(let t=0,n=e.length;t<n;t+=2)e[t]=s-e[t],e[t+1]+=r;break;case 270:for(let t=0,n=e.length;t<n;t+=2){let n=e[t];e[t]=s-e[t+1],e[t+1]=o-n}break;default:throw Error("Invalid rotation")}return e}static #sg(e,t,n){let[i,r,s,o]=t;switch(n){case 0:for(let t=0,n=e.length;t<n;t+=2)e[t]-=i,e[t+1]=o-e[t+1];break;case 90:for(let t=0,n=e.length;t<n;t+=2){let n=e[t];e[t]=e[t+1]-r,e[t+1]=n-i}break;case 180:for(let t=0,n=e.length;t<n;t+=2)e[t]=s-e[t],e[t+1]-=r;break;case 270:for(let t=0,n=e.length;t<n;t+=2){let n=e[t];e[t]=o-e[t+1],e[t+1]=s-n}break;default:throw Error("Invalid rotation")}return e}#sv(e,t,n,i){let r=[],s=this.thickness/2,o=e*t+s,a=e*n+s;for(let t of this.paths){let n=[],s=[];for(let i=0,r=t.length;i<r;i++){let[l,d,c,h]=t[i];if(l[0]===h[0]&&l[1]===h[1]&&1===r){let t=e*l[0]+o,i=e*l[1]+a;n.push(t,i),s.push(t,i);break}let u=e*l[0]+o,p=e*l[1]+a,f=e*d[0]+o,m=e*d[1]+a,g=e*c[0]+o,v=e*c[1]+a,b=e*h[0]+o,y=e*h[1]+a;0===i&&(n.push(u,p),s.push(u,p)),n.push(f,m,g,v,b,y),s.push(f,m),i===r-1&&s.push(b,y)}r.push({bezier:nB.#sm(n,i,this.rotation),points:nB.#sm(s,i,this.rotation)})}return r}#sb(){let e=1/0,t=-1/0,n=1/0,i=-1/0;for(let r of this.paths)for(let[s,o,a,l]of r){let r=U.bezierBoundingBox(...s,...o,...a,...l);e=Math.min(e,r[0]),n=Math.min(n,r[1]),t=Math.max(t,r[2]),i=Math.max(i,r[3])}return[e,n,t,i]}#sp(){return this.#rJ?Math.ceil(this.thickness*this.parentScale):0}#r6(e=!1){if(this.isEmpty())return;if(!this.#rJ){this.#r8();return}let t=this.#sb(),n=this.#sp();this.#rW=Math.max(eO.MIN_SIZE,t[2]-t[0]),this.#r$=Math.max(eO.MIN_SIZE,t[3]-t[1]);let i=Math.ceil(n+this.#rW*this.scaleFactor),r=Math.ceil(n+this.#r$*this.scaleFactor),[s,o]=this.parentDimensions;this.width=i/s,this.height=r/o,this.setAspectRatio(i,r);let a=this.translationX,l=this.translationY;this.translationX=-t[0],this.translationY=-t[1],this.#se(),this.#r8(),this.#r2=i,this.#r5=r,this.setDims(i,r);let d=e?n/this.scaleFactor/2:0;this.translate(a-this.translationX-d,l-this.translationY-d)}static deserialize(e,t,n){if(e instanceof n_)return null;let i=super.deserialize(e,t,n);i.thickness=e.thickness,i.color=U.makeHexColor(...e.color),i.opacity=e.opacity;let[r,s]=i.pageDimensions,o=i.width*r,a=i.height*s,l=i.parentScale,d=e.thickness/2;i.#rJ=!0,i.#r2=Math.round(o),i.#r5=Math.round(a);let{paths:c,rect:h,rotation:u}=e;for(let{bezier:e}of c){e=nB.#sg(e,h,u);let t=[];i.paths.push(t);let n=l*(e[0]-d),r=l*(e[1]-d);for(let i=2,s=e.length;i<s;i+=6){let s=l*(e[i]-d),o=l*(e[i+1]-d),a=l*(e[i+2]-d),c=l*(e[i+3]-d),h=l*(e[i+4]-d),u=l*(e[i+5]-d);t.push([[n,r],[s,o],[a,c],[h,u]]),n=h,r=u}let s=this.#sf(t);i.bezierPath2D.push(s)}let p=i.#sb();return i.#rW=Math.max(eO.MIN_SIZE,p[2]-p[0]),i.#r$=Math.max(eO.MIN_SIZE,p[3]-p[1]),i.#su(o,a),i}serialize(){if(this.isEmpty())return null;let e=this.getRect(0,0),t=eO._colorManager.convert(this.ctx.strokeStyle);return{annotationType:h.INK,color:t,thickness:this.thickness,opacity:this.opacity,paths:this.#sv(this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}class nz extends eO{#sy=null;#sx=null;#sw=null;#s_=null;#sS=null;#sE="";#sC=null;#r1=null;#sA=null;#sk=!1;#sT=!1;static _type="stamp";static _editorType=h.STAMP;constructor(e){super({...e,name:"stampEditor"}),this.#s_=e.bitmapUrl,this.#sS=e.bitmapFile}static initialize(e,t){eO.initialize(e,t)}static get supportedTypes(){return T(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return T(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor(h.STAMP,{bitmapFile:e.getAsFile()})}#sM(e,t=!1){if(!e){this.remove();return}this.#sy=e.bitmap,!t&&(this.#sx=e.id,this.#sk=e.isSvg),e.file&&(this.#sE=e.file.name),this.#r7()}#sD(){this.#sw=null,this._uiManager.enableWaiting(!1),this.#sC&&this.div.focus()}#sO(){if(this.#sx){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#sx).then(e=>this.#sM(e,!0)).finally(()=>this.#sD());return}if(this.#s_){let e=this.#s_;this.#s_=null,this._uiManager.enableWaiting(!0),this.#sw=this._uiManager.imageManager.getFromUrl(e).then(e=>this.#sM(e)).finally(()=>this.#sD());return}if(this.#sS){let e=this.#sS;this.#sS=null,this._uiManager.enableWaiting(!0),this.#sw=this._uiManager.imageManager.getFromFile(e).then(e=>this.#sM(e)).finally(()=>this.#sD());return}let e=document.createElement("input");e.type="file",e.accept=nz.supportedTypesStr;let t=this._uiManager._signal;this.#sw=new Promise(n=>{e.addEventListener("change",async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);let t=await this._uiManager.imageManager.getFromFile(e.files[0]);this.#sM(t)}else this.remove();n()},{signal:t}),e.addEventListener("cancel",()=>{this.remove(),n()},{signal:t})}).finally(()=>this.#sD()),e.click()}remove(){this.#sx&&(this.#sy=null,this._uiManager.imageManager.deleteId(this.#sx),this.#sC?.remove(),this.#sC=null,this.#r1?.disconnect(),this.#r1=null,this.#sA&&(clearTimeout(this.#sA),this.#sA=null)),super.remove()}rebuild(){if(!this.parent){this.#sx&&this.#sO();return}if(super.rebuild(),null!==this.div)this.#sx&&null===this.#sC&&this.#sO(),!this.isAttachedToDOM&&this.parent.add(this)}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#sw||this.#sy||this.#s_||this.#sS||this.#sx)}get isResizable(){return!0}render(){let e,t;if(this.div)return this.div;if(this.width&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#sy?this.#r7():this.#sO(),this.width){let[n,i]=this.parentDimensions;this.setAt(e*n,t*i,this.width*n,this.height*i)}return this.div}#r7(){let{div:e}=this,{width:t,height:n}=this.#sy,[i,r]=this.pageDimensions;if(this.width)t=this.width*i,n=this.height*r;else if(t>.75*i||n>.75*r){let e=Math.min(.75*i/t,.75*r/n);t*=e,n*=e}let[s,o]=this.parentDimensions;this.setDims(t*s/i,n*o/r),this._uiManager.enableWaiting(!1);let a=this.#sC=document.createElement("canvas");e.append(a),e.hidden=!1,this.#sI(t,n),this.#r9(),!this.#sT&&(this.parent.addUndoableEditor(this),this.#sT=!0),this._reportTelemetry({action:"inserted_image"}),this.#sE&&a.setAttribute("aria-label",this.#sE)}#sN(e,t){let[n,i]=this.parentDimensions;this.width=e/n,this.height=t/i,this.setDims(e,t),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==this.#sA&&clearTimeout(this.#sA);this.#sA=setTimeout(()=>{this.#sA=null,this.#sI(e,t)},200)}#sR(e,t){let{width:n,height:i}=this.#sy,r=n,s=i,o=this.#sy;for(;r>2*e||s>2*t;){let n=r,i=s;r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),s>2*t&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2));let a=new OffscreenCanvas(r,s);a.getContext("2d").drawImage(o,0,0,n,i,0,0,r,s),o=a.transferToImageBitmap()}return o}#sI(e,t){e=Math.ceil(e),t=Math.ceil(t);let n=this.#sC;if(!n||n.width===e&&n.height===t)return;n.width=e,n.height=t;let i=this.#sk?this.#sy:this.#sR(e,t);if(this._uiManager.hasMLManager&&!this.hasAltText()){let n=new OffscreenCanvas(e,t).getContext("2d");n.drawImage(i,0,0,i.width,i.height,0,0,e,t),this._uiManager.mlGuess({service:"image-to-text",request:{data:n.getImageData(0,0,e,t).data,width:e,height:t,channels:4}}).then(e=>{let t=e?.output||"";this.parent&&t&&!this.hasAltText()&&(this.altTextData={altText:t,decorative:!1})})}let r=n.getContext("2d");r.filter=this._uiManager.hcmFilter,r.drawImage(i,0,0,i.width,i.height,0,0,e,t)}getImageForAltText(){return this.#sC}#sL(e){if(e){if(this.#sk){let e=this._uiManager.imageManager.getSvgUrl(this.#sx);if(e)return e}let e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#sy,e.getContext("2d").drawImage(this.#sy,0,0),e.toDataURL()}if(this.#sk){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*ee.PDF_TO_CSS_UNITS),i=Math.round(this.height*t*ee.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(n,i);return r.getContext("2d").drawImage(this.#sy,0,0,this.#sy.width,this.#sy.height,0,0,n,i),r.transferToImageBitmap()}return structuredClone(this.#sy)}#r9(){if(!!this._uiManager._signal)this.#r1=new ResizeObserver(e=>{let t=e[0].contentRect;t.width&&t.height&&this.#sN(t.width,t.height)}),this.#r1.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#r1?.disconnect(),this.#r1=null},{once:!0})}static deserialize(e,t,n){if(e instanceof nk)return null;let i=super.deserialize(e,t,n),{rect:r,bitmapUrl:s,bitmapId:o,isSvg:a,accessibilityData:l}=e;o&&n.imageManager.isValidId(o)?i.#sx=o:i.#s_=s,i.#sk=a;let[d,c]=i.pageDimensions;return i.width=(r[2]-r[0])/d,i.height=(r[3]-r[1])/c,l&&(i.altTextData=l),i}serialize(e=!1,t=null){if(this.isEmpty())return null;let n={annotationType:h.STAMP,bitmapId:this.#sx,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#sk,structTreeParentId:this._structTreeParentId};if(e)return n.bitmapUrl=this.#sL(!0),n.accessibilityData=this.altTextData,n;let{decorative:i,altText:r}=this.altTextData;if(!i&&r&&(n.accessibilityData={type:"Figure",alt:r}),null===t)return n;t.stamps||=new Map;let s=this.#sk?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#sx)){if(this.#sk){let e=t.stamps.get(this.#sx);s>e.area&&(e.area=s,e.serialized.bitmap.close(),e.serialized.bitmap=this.#sL(!1))}}else t.stamps.set(this.#sx,{area:s,serialized:n}),n.bitmap=this.#sL(!1);return n}}class nH{#ip;#sP=!1;#sj=null;#sF=null;#sB=null;#sz=null;#sH=null;#sU=new Map;#sV=!1;#s$=!1;#sW=!1;#sG=null;#p;static _initialized=!1;static #j=new Map([nO,nB,nz,nF].map(e=>[e._editorType,e]));constructor({uiManager:e,pageIndex:t,div:n,accessibilityManager:i,annotationLayer:r,drawLayer:s,textLayer:o,viewport:a,l10n:l}){let d=[...nH.#j.values()];if(!nH._initialized)for(let t of(nH._initialized=!0,d))t.initialize(l,e);e.registerEditorTypes(d),this.#p=e,this.pageIndex=t,this.div=n,this.#ip=i,this.#sj=r,this.viewport=a,this.#sG=o,this.drawLayer=s,this.#p.addLayer(this)}get isEmpty(){return 0===this.#sU.size}get isInvisible(){return this.isEmpty&&this.#p.getMode()===h.NONE}updateToolbar(e){this.#p.updateToolbar(e)}updateMode(e=this.#p.getMode()){switch(this.#sZ(),e){case h.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case h.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case h.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;for(let n of nH.#j.values())t.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){return e===this.#sG?.div}addInkEditorIfNeeded(e){if(this.#p.getMode()===h.INK){if(!e){for(let e of this.#sU.values())if(e.isEmpty()){e.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(e){this.#p.setEditingState(e)}addCommands(e){this.#p.addCommands(e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#sj?.div.classList.toggle("disabled",!e)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);let e=new Set;for(let t of this.#sU.values())t.enableEditing(),t.show(!0),t.annotationElementId&&(this.#p.removeChangedExistingAnnotation(t),e.add(t.annotationElementId));if(!!this.#sj)for(let t of this.#sj.getEditableAnnotations()){if(t.hide(),this.#p.isDeletedAnnotationElement(t.data.id)||e.has(t.data.id))continue;let n=this.deserialize(t);if(!!n)this.addOrRebuild(n),n.enableEditing()}}disable(){this.#sW=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let e=new Map,t=new Map;for(let n of this.#sU.values()){if(n.disableEditing(),!!n.annotationElementId){if(null!==n.serialize()){e.set(n.annotationElementId,n);continue}t.set(n.annotationElementId,n);this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()}}if(this.#sj)for(let n of this.#sj.getEditableAnnotations()){let{id:i}=n.data;if(this.#p.isDeletedAnnotationElement(i))continue;let r=t.get(i);if(r){r.resetAnnotationElement(n),r.show(!1),n.show();continue}(r=e.get(i))&&(this.#p.addChangedExistingAnnotation(r),r.renderAnnotationElement(n),r.show(!1)),n.show()}this.#sZ(),this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let e of nH.#j.values())n.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#sW=!1}getEditableAnnotation(e){return this.#sj?.getEditableAnnotation(e)||null}setActiveEditor(e){if(this.#p.getActive()!==e)this.#p.setActiveEditor(e)}enableTextSelection(){this.div.tabIndex=-1,this.#sG?.div&&!this.#sz&&(this.#sz=this.#sq.bind(this),this.#sG.div.addEventListener("pointerdown",this.#sz,{signal:this.#p._signal}),this.#sG.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#sG?.div&&this.#sz&&(this.#sG.div.removeEventListener("pointerdown",this.#sz),this.#sz=null,this.#sG.div.classList.remove("highlighting"))}#sq(e){if(this.#p.unselectAll(),e.target===this.#sG.div){let{isMac:t}=z.platform;if(0===e.button&&(!e.ctrlKey||!t))this.#p.showAllEditors("highlight",!0,!0),this.#sG.div.classList.add("free"),nF.startHighlighting(this,"ltr"===this.#p.direction,e),this.#sG.div.addEventListener("pointerup",()=>{this.#sG.div.classList.remove("free")},{once:!0,signal:this.#p._signal}),e.preventDefault()}}enableClick(){if(this.#sB)return;let e=this.#p._signal;this.#sB=this.pointerdown.bind(this),this.#sF=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#sB,{signal:e}),this.div.addEventListener("pointerup",this.#sF,{signal:e})}disableClick(){if(!!this.#sB)this.div.removeEventListener("pointerdown",this.#sB),this.div.removeEventListener("pointerup",this.#sF),this.#sB=null,this.#sF=null}attach(e){this.#sU.set(e.id,e);let{annotationElementId:t}=e;t&&this.#p.isDeletedAnnotationElement(t)&&this.#p.removeDeletedAnnotationElement(e)}detach(e){this.#sU.delete(e.id),this.#ip?.removePointerInTextLayer(e.contentDiv),!this.#sW&&e.annotationElementId&&this.#p.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#p.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1,!this.#s$&&this.addInkEditorIfNeeded(!1)}changeParent(e){if(e.parent!==this)e.parent&&e.annotationElementId&&(this.#p.addDeletedAnnotationElement(e.annotationElementId),eO.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div))}add(e){if(e.parent!==this||!e.isAttachedToDOM){if(this.changeParent(e),this.#p.addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(),this.#p.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;e.div.contains(t)&&!this.#sH&&(e._focusEventsAllowed=!1,this.#sH=setTimeout(()=>{this.#sH=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#p._signal}),t.focus())},0)),e._structTreeParentId=this.#ip?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return this.#p.getId()}get #sK(){return nH.#j.get(this.#p.getMode())}get _signal(){return this.#p._signal}#sY(e){let t=this.#sK;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#sK?.canCreateNewEmptyEditor()}pasteEditor(e,t){this.#p.updateToolbar(e),this.#p.updateMode(e);let{offsetX:n,offsetY:i}=this.#sX(),r=this.getNextId(),s=this.#sY({parent:this,id:r,x:n,y:i,uiManager:this.#p,isCentered:!0,...t});s&&this.add(s)}deserialize(e){return nH.#j.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#p)||null}createAndAddNewEditor(e,t,n={}){let i=this.getNextId(),r=this.#sY({parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:this.#p,isCentered:t,...n});return r&&this.add(r),r}#sX(){let{x:e,y:t,width:n,height:i}=this.div.getBoundingClientRect(),r=Math.max(0,e),s=Math.max(0,t),o=Math.min(window.innerWidth,e+n),a=Math.min(window.innerHeight,t+i),l=(r+o)/2-e,d=(s+a)/2-t,[c,h]=this.viewport.rotation%180==0?[l,d]:[d,l];return{offsetX:c,offsetY:h}}addNewEditor(){this.createAndAddNewEditor(this.#sX(),!0)}setSelected(e){this.#p.setSelected(e)}toggleSelected(e){this.#p.toggleSelected(e)}isSelected(e){return this.#p.isSelected(e)}unselect(e){this.#p.unselect(e)}pointerup(e){let{isMac:t}=z.platform;if(0===e.button&&(!e.ctrlKey||!t)&&e.target===this.div&&!!this.#sV){if(this.#sV=!1,!this.#sP){this.#sP=!0;return}if(this.#p.getMode()===h.STAMP){this.#p.unselectAll();return}this.createAndAddNewEditor(e,!1)}}pointerdown(e){if(this.#p.getMode()===h.HIGHLIGHT&&this.enableTextSelection(),this.#sV){this.#sV=!1;return}let{isMac:t}=z.platform;if(0!==e.button||e.ctrlKey&&t||e.target!==this.div)return;this.#sV=!0;let n=this.#p.getActive();this.#sP=!n||n.isEmpty()}findNewParent(e,t,n){let i=this.#p.findParent(t,n);return null!==i&&i!==this&&(i.changeParent(e),!0)}destroy(){for(let e of(this.#p.getActive()?.parent===this&&(this.#p.commitOrRemove(),this.#p.setActiveEditor(null)),this.#sH&&(clearTimeout(this.#sH),this.#sH=null),this.#sU.values()))this.#ip?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#sU.clear(),this.#p.removeLayer(this)}#sZ(){for(let e of(this.#s$=!0,this.#sU.values()))e.isEmpty()&&e.remove();this.#s$=!1}render({viewport:e}){for(let t of(this.viewport=e,ex(this.div,e),this.#p.getEditors(this.pageIndex)))this.add(t),t.rebuild();this.updateMode()}update({viewport:e}){this.#p.commitOrRemove(),this.#sZ();let t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,ex(this.div,{rotation:n}),t!==n)for(let e of this.#sU.values())e.rotate(n);this.addInkEditorIfNeeded(!1)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#p.viewParameters.realScale}}class nU{#n2=null;#v=0;#sJ=new Map;#sQ=new Map;constructor({pageIndex:e}){this.pageIndex=e}setParent(e){if(!this.#n2){this.#n2=e;return}if(this.#n2!==e){if(this.#sJ.size>0)for(let t of this.#sJ.values())t.remove(),e.append(t);this.#n2=e}}static get _svgFactory(){return T(this,"_svgFactory",new er)}static #s0(e,{x:t=0,y:n=0,width:i=1,height:r=1}={}){let{style:s}=e;s.top=`${100*n}%`,s.left=`${100*t}%`,s.width=`${100*i}%`,s.height=`${100*r}%`}#s1(e){let t=nU._svgFactory.create(1,1,!0);return this.#n2.append(t),t.setAttribute("aria-hidden",!0),nU.#s0(t,e),t}#s2(e,t){let n=nU._svgFactory.createElement("clipPath");e.append(n);let i=`clip_${t}`;n.setAttribute("id",i),n.setAttribute("clipPathUnits","objectBoundingBox");let r=nU._svgFactory.createElement("use");return n.append(r),r.setAttribute("href",`#${t}`),r.classList.add("clip"),i}highlight(e,t,n,i=!1){let r=this.#v++,s=this.#s1(e.box);s.classList.add("highlight"),e.free&&s.classList.add("free");let o=nU._svgFactory.createElement("defs");s.append(o);let a=nU._svgFactory.createElement("path");o.append(a);let l=`path_p${this.pageIndex}_${r}`;a.setAttribute("id",l),a.setAttribute("d",e.toSVGPath()),i&&this.#sQ.set(r,a);let d=this.#s2(o,l),c=nU._svgFactory.createElement("use");return s.append(c),s.setAttribute("fill",t),s.setAttribute("fill-opacity",n),c.setAttribute("href",`#${l}`),this.#sJ.set(r,s),{id:r,clipPathId:`url(#${d})`}}highlightOutline(e){let t;let n=this.#v++,i=this.#s1(e.box);i.classList.add("highlightOutline");let r=nU._svgFactory.createElement("defs");i.append(r);let s=nU._svgFactory.createElement("path");r.append(s);let o=`path_p${this.pageIndex}_${n}`;if(s.setAttribute("id",o),s.setAttribute("d",e.toSVGPath()),s.setAttribute("vector-effect","non-scaling-stroke"),e.free){i.classList.add("free");let e=nU._svgFactory.createElement("mask");r.append(e),t=`mask_p${this.pageIndex}_${n}`,e.setAttribute("id",t),e.setAttribute("maskUnits","objectBoundingBox");let s=nU._svgFactory.createElement("rect");e.append(s),s.setAttribute("width","1"),s.setAttribute("height","1"),s.setAttribute("fill","white");let a=nU._svgFactory.createElement("use");e.append(a),a.setAttribute("href",`#${o}`),a.setAttribute("stroke","none"),a.setAttribute("fill","black"),a.setAttribute("fill-rule","nonzero"),a.classList.add("mask")}let a=nU._svgFactory.createElement("use");i.append(a),a.setAttribute("href",`#${o}`),t&&a.setAttribute("mask",`url(#${t})`);let l=a.cloneNode();return i.append(l),a.classList.add("mainOutline"),l.classList.add("secondaryOutline"),this.#sJ.set(n,i),n}finalizeLine(e,t){let n=this.#sQ.get(e);this.#sQ.delete(e),this.updateBox(e,t.box),n.setAttribute("d",t.toSVGPath())}updateLine(e,t){this.#sJ.get(e).firstChild.firstChild.setAttribute("d",t.toSVGPath())}removeFreeHighlight(e){this.remove(e),this.#sQ.delete(e)}updatePath(e,t){this.#sQ.get(e).setAttribute("d",t.toSVGPath())}updateBox(e,t){nU.#s0(this.#sJ.get(e),t)}show(e,t){this.#sJ.get(e).classList.toggle("hidden",!t)}rotate(e,t){this.#sJ.get(e).setAttribute("data-main-rotation",t)}changeColor(e,t){this.#sJ.get(e).setAttribute("fill",t)}changeOpacity(e,t){this.#sJ.get(e).setAttribute("fill-opacity",t)}addClass(e,t){this.#sJ.get(e).classList.add(t)}removeClass(e,t){this.#sJ.get(e).classList.remove(t)}remove(e){if(null!==this.#n2)this.#sJ.get(e).remove(),this.#sJ.delete(e)}destroy(){for(let e of(this.#n2=null,this.#sJ.values()))e.remove();this.#sJ.clear()}}var nV=s.AbortException,n$=s.AnnotationEditorLayer,nW=s.AnnotationEditorParamsType,nG=s.AnnotationEditorType,nZ=s.AnnotationEditorUIManager,nq=s.AnnotationLayer,nK=s.AnnotationMode,nY=s.CMapCompressionType,nX=s.ColorPicker,nJ=s.DOMSVGFactory,nQ=s.DrawLayer,n0=s.FeatureTest,n1=s.GlobalWorkerOptions,n2=s.ImageKind,n5=s.InvalidPDFException,n3=s.MissingPDFException,n4=s.OPS,n6=s.Outliner,n8=s.PDFDataRangeTransport,n7=s.PDFDateString,n9=s.PDFWorker,ie=s.PasswordResponses,it=s.PermissionFlag,ii=s.PixelsPerInch,ir=s.RenderingCancelledException,is=s.TextLayer,io=s.UnexpectedResponseException,ia=s.Util,il=s.VerbosityLevel,id=s.XfaLayer,ic=s.build,ih=s.createValidAbsoluteUrl,iu=s.fetchData,ip=s.getDocument,im=s.getFilenameFromUrl,ig=s.getPdfFilenameFromUrl,iv=s.getXfaPageViewport,ib=s.isDataScheme,iy=s.isPdfFile,ix=s.noContextMenu,iw=s.normalizeUnicode,i_=s.renderTextLayer,iS=s.setLayerDimensions,iE=s.shadow,iC=s.updateTextLayer,iA=s.version},132308:function(e,t,n){"use strict";n.d(t,{$:function(){return d},h:function(){return l}});var i=n(896433),r=n(871738);let s="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),o="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function a(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function l(e){return new r.Sy({props:{handleKeyDown:d(e)}})}function d(e){let t=function(e){let t=Object.create(null);for(let n in e)t[function(e){let t,n,i,r,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"==a&&(a=" ");for(let e=0;e<o.length-1;e++){let a=o[e];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))t=!0;else if(/^(c|ctrl|control)$/i.test(a))n=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))s?r=!0:n=!0;else throw Error("Unrecognized modifier name: "+a)}return t&&(a="Alt-"+a),n&&(a="Ctrl-"+a),r&&(a="Meta-"+a),i&&(a="Shift-"+a),a}(n)]=e[n];return t}(e);return function(e,n){let r=(0,i.YG)(n),s,l=t[a(r,n)];if(l&&l(e.state,e.dispatch,e))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let i=t[a(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(o&&n.ctrlKey&&n.altKey)&&(s=i.ue[n.keyCode])&&s!=r){let i=t[a(s,n)];if(i&&i(e.state,e.dispatch,e))return!0}}return!1}}},153737:function(e,t,n){"use strict";function i(e){this.content=e}n.d(t,{aw:()=>H,NB:()=>S,p2:()=>c,Ts:()=>w,ZU:()=>F,e4:()=>d,vc:()=>l,PW:()=>Y,HY:()=>r,V_:()=>B}),i.prototype={constructor:i,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return -1},get:function(e){var t=this.find(e);return -1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,s=r.find(e),o=r.content.slice();return -1==s?o.push(n||e,t):(o[s+1]=t,n&&(o[s]=n)),new i(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new i(n)},addToStart:function(e,t){return new i([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new i(n)},addBefore:function(e,t,n){var r=this.remove(t),s=r.content.slice(),o=r.find(e);return s.splice(-1==o?s.length:o,0,t,n),new i(s)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=i.from(e)).size?new i(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=i.from(e)).size?new i(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=i.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},i.from=function(e){if(e instanceof i)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new i(t)};class r{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,i=0,r){for(let s=0,o=0;o<t;s++){let a=this.content[s],l=o+a.nodeSize;if(l>e&&!1!==n(a,i+o,r||null,s)&&a.content.size){let r=o+1;a.nodesBetween(Math.max(0,e-r),Math.min(a.content.size,t-r),n,i+r)}o=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let r="",s=!0;return this.nodesBetween(e,t,(o,a)=>{let l=o.isText?o.text.slice(Math.max(e,a)-a,t-a):o.isLeaf?i?"function"==typeof i?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&l||o.isTextblock)&&n&&(s?s=!1:r+=n),r+=l},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new r(i,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],i=0;if(t>e)for(let r=0,s=0;s<t;r++){let o=this.content[r],a=s+o.nodeSize;a>e&&((s<e||a>t)&&(o=o.isText?o.cut(Math.max(0,e-s),Math.min(o.text.length,t-s)):o.cut(Math.max(0,e-s-1),Math.min(o.content.size,t-s-1))),n.push(o),i+=o.nodeSize),s=a}return new r(n,i)}cutByIndex(e,t){return e==t?r.empty:0==e&&t==this.content.length?this:new r(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new r(i,s)}addToStart(e){return new r([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new r(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return function e(t,n,i){for(let r=0;;r++){if(r==t.childCount||r==n.childCount)return t.childCount==n.childCount?null:i;let s=t.child(r),o=n.child(r);if(s==o){i+=s.nodeSize;continue}if(!s.sameMarkup(o))return i;if(s.isText&&s.text!=o.text){for(let e=0;s.text[e]==o.text[e];e++)i++;return i}if(s.content.size||o.content.size){let t=e(s.content,o.content,i+1);if(null!=t)return t}i+=s.nodeSize}}(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return function e(t,n,i,r){for(let s=t.childCount,o=n.childCount;;){if(0==s||0==o)return s==o?null:{a:i,b:r};let a=t.child(--s),l=n.child(--o),d=a.nodeSize;if(a==l){i-=d,r-=d;continue}if(!a.sameMarkup(l))return{a:i,b:r};if(a.isText&&a.text!=l.text){let e=0,t=Math.min(a.text.length,l.text.length);for(;e<t&&a.text[a.text.length-e-1]==l.text[l.text.length-e-1];)e++,i--,r--;return{a:i,b:r}}if(a.content.size||l.content.size){let t=e(a.content,l.content,i-1,r-1);if(t)return t}i-=d,r-=d}}(this,e,t,n)}findIndex(e,t=-1){if(0==e)return o(0,e);if(e==this.size)return o(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,i=0;;n++){let r=i+this.child(n).nodeSize;if(r>=e){if(r==e||t>0)return o(n+1,r);return o(n,i)}i=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return r.empty;if(!Array.isArray(t))throw RangeError("Invalid input for Fragment.fromJSON");return new r(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return r.empty;let t,n=0;for(let i=0;i<e.length;i++){let r=e[i];n+=r.nodeSize,i&&r.isText&&e[i-1].sameMarkup(r)?(!t&&(t=e.slice(0,i)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new r(t||e,n)}static from(e){if(!e)return r.empty;if(e instanceof r)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new r([e],e.nodeSize);throw RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}r.empty=new r([],0);let s={index:0,offset:0};function o(e,t){return s.index=e,s.offset=t,s}function a(e,t){if(e===t)return!0;if(!(e&&"object"==typeof e)||!(t&&"object"==typeof t))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!a(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!a(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class l{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let r=e[i];if(this.eq(r))return e;if(this.type.excludes(r.type))!t&&(t=e.slice(0,i));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(!t&&(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(r)}}return!t&&(t=e.slice()),!n&&t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&a(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return l.none;if(e instanceof l)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}l.none=[];class d extends Error{}class c{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=function e(t,n,i,r){let{index:s,offset:o}=t.findIndex(n),a=t.maybeChild(s);if(o==n||a.isText)return r&&!r.canReplace(s,s,i)?null:t.cut(0,n).append(i).append(t.cut(n));let l=e(a.content,n-o-1,i);return l&&t.replaceChild(s,a.copy(l))}(this.content,e+this.openStart,t);return n&&new c(n,this.openStart,this.openEnd)}removeBetween(e,t){return new c(function e(t,n,i){let{index:r,offset:s}=t.findIndex(n),o=t.maybeChild(r),{index:a,offset:l}=t.findIndex(i);if(s==n||o.isText){if(l!=i&&!t.child(a).isText)throw RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(i))}if(r!=a)throw RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(e(o.content,n-s-1,i-s-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return c.empty;let n=t.openStart||0,i=t.openEnd||0;if("number"!=typeof n||"number"!=typeof i)throw RangeError("Invalid input for Slice.fromJSON");return new c(r.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)i++;return new c(e,n,i)}}c.empty=new c(r.empty,0,0);function h(e,t){if(!t.type.compatibleContent(e.type))throw new d("Cannot join "+t.type.name+" onto "+e.type.name)}function u(e,t,n){let i=e.node(n);return h(i,t.node(n)),i}function p(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function f(e,t,n,i){let r=(t||e).node(n),s=0,o=t?t.index(n):r.childCount;e&&(s=e.index(n),e.depth>n?s++:e.textOffset&&(p(e.nodeAfter,i),s++));for(let e=s;e<o;e++)p(r.child(e),i);t&&t.depth==n&&t.textOffset&&p(t.nodeBefore,i)}function m(e,t){return e.type.checkContent(t),e.copy(t)}function g(e,t,n){let i=[];return f(null,e,n,i),e.depth>n&&p(m(u(e,t,n+1),g(e,t,n+1)),i),f(t,null,n,i),new r(i)}class v{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],i=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)i+=n.child(t).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return l.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let e=n;n=i,i=e}let r=n.marks;for(var s=0;s<r.length;s++)!1===r[s].type.spec.inclusive&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var r=0;r<n.length;r++)!1===n[r].type.spec.inclusive&&(!i||!n[r].isInSet(i.marks))&&(n=n[r--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new w(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw RangeError("Position "+t+" out of range");let n=[],i=0,r=t;for(let t=e;;){let{index:e,offset:s}=t.content.findIndex(r),o=r-s;if(n.push(t,e,i+s),!o||(t=t.child(e)).isText)break;r=o-1,i+=s+1}return new v(t,n,r)}static resolveCached(e,t){let n=x.get(e);if(n)for(let e=0;e<n.elts.length;e++){let i=n.elts[e];if(i.pos==t)return i}else x.set(e,n=new b);let i=n.elts[n.i]=v.resolve(e,t);return n.i=(n.i+1)%y,i}}class b{constructor(){this.elts=[],this.i=0}}let y=12,x=new WeakMap;class w{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let _=Object.create(null);class S{constructor(e,t,n,i=l.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||r.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&a(this.attrs,t||e.defaultAttrs||_)&&l.sameSet(this.marks,n||l.none)}copy(e=null){return e==this.content?this:new S(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new S(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return c.empty;let i=this.resolve(e),r=this.resolve(t),s=n?0:i.sharedDepth(t),o=i.start(s);return new c(i.node(s).content.cut(i.pos-o,r.pos-o),i.depth-s,r.depth-s)}replace(e,t,n){return function(e,t,n){if(n.openStart>e.depth)throw new d("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new d("Inconsistent open depths");return function e(t,n,i,s){let o=t.index(s),a=t.node(s);if(o==n.index(s)&&s<t.depth-i.openStart){let r=e(t,n,i,s+1);return a.copy(a.content.replaceChild(o,r))}if(!i.content.size)return m(a,g(t,n,s));if(i.openStart||i.openEnd||t.depth!=s||n.depth!=s){let{start:e,end:o}=function(e,t){let n=t.depth-e.openStart,i=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)i=t.node(e).copy(r.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}(i,t);return m(a,function e(t,n,i,s,o){let a=t.depth>o&&u(t,n,o+1),l=s.depth>o&&u(i,s,o+1),d=[];return f(null,t,o,d),a&&l&&n.index(o)==i.index(o)?(h(a,l),p(m(a,e(t,n,i,s,o+1)),d)):(a&&p(m(a,g(t,n,o+1)),d),f(n,i,o,d),l&&p(m(l,g(i,s,o+1)),d)),f(s,null,o,d),new r(d)}(t,e,o,n,s))}else{let e=t.parent,r=e.content;return m(e,r.cut(0,t.parentOffset).append(i.content).append(r.cut(n.parentOffset)))}}(e,t,n,0)}(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(!(t=t.maybeChild(n)))return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return v.resolveCached(this,e)}resolveNoCache(e){return v.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),C(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=r.empty,i=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,s),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let e=i;e<s;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let r=this.contentMatchAt(e).matchType(n),s=r&&r.matchFragment(this.content,t);return!!s&&s.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=l.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!l.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){let n;if(!t)throw RangeError("Invalid input for Node.fromJSON");if(t.marks){if(!Array.isArray(t.marks))throw RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=r.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,n);return s.type.checkAttrs(s.attrs),s}}S.prototype.text=void 0;class E extends S{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):C(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new E(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new E(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function C(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class A{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new k(e,t);if(null==n.next)return A.empty;let i=T(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return function n(i){let r=[];i.forEach(t=>{e[t].forEach(({term:t,to:n})=>{let i;if(t){for(let e=0;e<r.length;e++)r[e][0]==t&&(i=r[e][1]);O(e,n).forEach(e=>{!i&&r.push([t,i=[]]),-1==i.indexOf(e)&&i.push(e)})}})});let s=t[i.join(",")]=new A(i.indexOf(e.length-1)>-1);for(let e=0;e<r.length;e++){let i=r[e][1].sort(D);s.next.push({type:r[e][0],next:t[i.join(",")]||n(i)})}return s}(O(e,0))}(function(e){let t=[[]];return r(function e(t,s){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,s)),[]);if("seq"==t.type)for(let i=0;;i++){let o=e(t.exprs[i],s);if(i==t.exprs.length-1)return o;r(o,s=n())}else if("star"==t.type){let o=n();return i(s,o),r(e(t.expr,o),o),[i(o)]}else if("plus"==t.type){let o=n();return r(e(t.expr,s),o),r(e(t.expr,o),o),[i(o)]}else if("opt"==t.type)return[i(s)].concat(e(t.expr,s));else if("range"==t.type){let o=s;for(let i=0;i<t.min;i++){let i=n();r(e(t.expr,o),i),o=i}if(-1==t.max)r(e(t.expr,o),o);else for(let s=t.min;s<t.max;s++){let s=n();i(o,s),r(e(t.expr,o),s),o=s}return[i(o)]}else if("name"==t.type)return[i(s,void 0,t.value)];else throw Error("Unknown expr type")}(e,0),n()),t;function n(){return t.push([])-1}function i(e,n,i){let r={term:i,to:n};return t[e].push(r),r}function r(e,t){e.forEach(e=>e.to=t)}}(i));return function(e,t){for(let n=0,i=[e];n<i.length;n++){let e=i[n],r=!e.validEnd,s=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];s.push(n.name),r&&!(n.isText||n.hasRequiredAttrs())&&(r=!1),-1==i.indexOf(o)&&i.push(o)}r&&t.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let r=t;i&&r<n;r++)i=i.matchType(e.child(r).type);return i}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];return function s(o,a){let l=o.matchFragment(e,n);if(l&&(!t||l.validEnd))return r.from(a.map(e=>e.createAndFill()));for(let e=0;e<o.next.length;e++){let{type:t,next:n}=o.next[e];if(!(t.isText||t.hasRequiredAttrs())&&-1==i.indexOf(n)){i.push(n);let e=s(n,a.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),r=i.match;if(r.matchType(e)){let e=[];for(let t=i;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<r.next.length;e++){let{type:s,next:o}=r.next[e];!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in t)&&(!i.type||o.validEnd)&&(n.push({match:s.contentMatch,type:s,via:i}),t[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return!function t(n){e.push(n);for(let i=0;i<n.next.length;i++)-1==e.indexOf(n.next[i].next)&&t(n.next[i].next)}(this),e.map((t,n)=>{let i=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)i+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return i}).join("\n")}}A.empty=new A(!0);class k{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+" (in content expression '"+this.string+"')")}}function T(e){let t=[];do t.push(function(e){let t=[];do t.push(function(e){let t=function(e){if(e.eat("(")){let t=T(e);return!e.eat(")")&&e.err("Missing closing paren"),t}if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=(function(e,t){let n=e.nodeTypes,i=n[t];if(i)return[i];let r=[];for(let e in n){let i=n[e];i.isInGroup(t)&&r.push(i)}return 0==r.length&&e.err("No node type or group '"+t+"' found"),r})(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=function(e,t){let n=M(e),i=n;return e.eat(",")&&(i="}"!=e.next?M(e):-1),!e.eat("}")&&e.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:t}}(e,t);else break;return t}(e));while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}(e));while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function M(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function D(e,t){return t-e}function O(e,t){let n=[];return function t(i){let r=e[i];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(i);for(let e=0;e<r.length;e++){let{term:i,to:s}=r[e];!i&&-1==n.indexOf(s)&&t(s)}}(t),n.sort(D)}function I(e){let t=Object.create(null);for(let n in e){let i=e[n];if(!i.hasDefault)return null;t[n]=i.default}return t}function N(e,t){let n=Object.create(null);for(let i in e){let r=t&&t[i];if(void 0===r){let t=e[i];if(t.hasDefault)r=t.default;else throw RangeError("No value supplied for attribute "+i)}n[i]=r}return n}function R(e,t,n,i){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let n in e){let i=e[n];i.validate&&i.validate(t[n])}}function L(e,t){let n=Object.create(null);if(t)for(let i in t)n[i]=new j(e,i,t[i]);return n}class P{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=L(e,n.attrs),this.defaultAttrs=I(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==A.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:N(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new S(this,this.computeAttrs(e),r.from(t),l.setFrom(n))}createChecked(e=null,t,n){return t=r.from(t),this.checkContent(t),new S(this,this.computeAttrs(e),t,l.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=r.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(r.empty,!0);return s?new S(this,e,t.append(s),l.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){R(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){let t;if(null==this.markSet)return e;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):!t&&(t=e.slice(0,n));return t?t.length?t:l.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,i)=>n[e]=new P(e,t,i));let i=t.spec.topNode||"doc";if(!n[i])throw RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw RangeError("The text node type should not have attributes");return n}}class j{constructor(e,t,n){var i,r;let s;this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default;this.validate="string"==typeof n.validate?(i=e,r=t,s=n.validate.split("|"),e=>{let t=null===e?"null":typeof e;if(0>s.indexOf(t))throw RangeError(`Expected value of type ${s} for attribute ${r} on type ${i}, got ${t}`)}):n.validate}get isRequired(){return!this.hasDefault}}class F{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=L(e,i.attrs),this.excluded=null;let r=I(this.attrs);this.instance=r?new l(this,r):null}create(e=null){return!e&&this.instance?this.instance:new l(this,N(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((e,r)=>n[e]=new F(e,i++,t,r)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){R(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class B{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=i.from(e.nodes),t.marks=i.from(e.marks||{}),this.nodes=P.compile(this.spec.nodes,this),this.marks=F.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],i=t.spec.content||"",r=t.spec.marks;if(t.contentMatch=n[i]||(n[i]=A.parse(i,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==r?null:r?z(this,r.split(" ")):""!=r&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:z(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if("string"==typeof e)e=this.nodeType(e);else if(e instanceof P){if(e.schema!=this)throw RangeError("Node type from different schema used ("+e.name+")")}else throw RangeError("Invalid node type: "+e);return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new E(n,n.defaultAttrs,e,l.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return S.fromJSON(this,e)}markFromJSON(e){return l.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError("Unknown node type: "+e);return t}}function z(e,t){let n=[];for(let i=0;i<t.length;i++){let r=t[i],s=e.marks[r],o=s;if(s)n.push(s);else for(let t in e.marks){let i=e.marks[t];("_"==r||i.spec.group&&i.spec.group.split(" ").indexOf(r)>-1)&&n.push(o=i)}if(!o)throw SyntaxError("Unknown mark type: '"+t[i]+"'")}return n}class H{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(null!=e.tag)this.tags.push(e);else if(null!=e.style){let t=/[^=]*/.exec(e.style)[0];0>n.indexOf(t)&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Z(this,t,!1);return n.addAll(e,l.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Z(this,t,!0);return n.addAll(e,l.none,t.from,t.to),c.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let n=this.tags[i];if(function(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,i){for(let r=i?this.styles.indexOf(i)+1:0;r<this.styles.length;r++){let i=this.styles[r],s=i.style;if(0==s.indexOf(e)&&(!i.context||n.matchesContext(i.context))&&(!(s.length>e.length)||61==s.charCodeAt(e.length)&&s.slice(e.length+1)==t)){if(i.getAttrs){let e=i.getAttrs(t);if(!1===e)continue;i.attrs=e||void 0}return i}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,i=0;for(;i<t.length;i++){let e=t[i];if((null==e.priority?50:e.priority)<n)break}t.splice(i,0,e)}for(let t in e.marks){let i=e.marks[t].spec.parseDOM;i&&i.forEach(e=>{n(e=q(e)),!(e.mark||e.ignore||e.clearMark)&&(e.mark=t)})}for(let t in e.nodes){let i=e.nodes[t].spec.parseDOM;i&&i.forEach(e=>{n(e=q(e)),!(e.node||e.ignore||e.mark)&&(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new H(e,H.schemaRules(e)))}}let U={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},V={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},$={ol:!0,ul:!0};function W(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class G{constructor(e,t,n,i,r,s){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=s,this.content=[],this.activeMarks=l.none,this.match=r||(4&s?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(r.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e=this.content[this.content.length-1],t;e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))&&(e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=e.withText(e.text.slice(0,e.text.length-t[0].length)))}let t=r.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(r.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!U.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Z{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,r,s=W(null,t.preserveWhitespace,0)|(n?4:0);r=i?new G(i.type,i.attrs,l.none,!0,t.topMatch||i.type.contentMatch,s):n?new G(null,null,l.none,!0,null,s):new G(e.schema.topNodeType,null,l.none,!0,null,s),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,r=2&i.options?"full":this.localPreserveWS||(1&i.options)>0;if("full"===r||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)n="full"!==r?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=i.content[i.content.length-1],r=e.previousSibling;(!t||r&&"BR"==r.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;$.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&$.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));n:if(a?a.ignore:V.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,i=this.needsBlock;if(U.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,!r.type&&(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break n}let o=a&&a.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(r),this.needsBlock=i}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?o:void 0)}this.localPreserveWS=i}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"==e.nodeName&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let i=this.parser.matchedStyles[e],r=n.getPropertyValue(i);if(r)for(let e;;){let n=this.parser.matchStyle(i,r,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1===n.consuming)e=n;else break}}return t}addElementByRule(e,t,n,i){let r,s;if(t.node){if((s=this.parser.schema.nodes[t.node]).isLeaf)!this.insertNode(s.create(t.attrs),n,"BR"==e.nodeName)&&this.leafFallback(e,n);else{let e=this.enter(s,t.attrs||null,n,t.preserveWhitespace);e&&(r=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let i=e;"string"==typeof t.contentElement?i=e.querySelector(t.contentElement):"function"==typeof t.contentElement?i=t.contentElement(e):t.contentElement&&(i=t.contentElement),this.findAround(e,i,!0),this.addAll(i,n),this.findAround(e,i,!1)}r&&this.sync(o)&&this.open--}addAll(e,t,n,i){let r=n||0;for(let s=n?e.childNodes[n]:e.firstChild,o=null==i?null:e.childNodes[i];s!=o;s=s.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(s,t);this.findAtPoint(e,r)}findPlace(e,t,n){let i,r;for(let t=this.open,s=0;t>=0;t--){let o=this.nodes[t],a=o.findWrapping(e);if(a&&(!i||i.length>a.length+s)&&(i=a,r=o,!a.length))break;if(o.solid){if(n)break;s+=2}}if(!i)return null;this.sync(r);for(let e=0;e<i.length;e++)t=this.enterInner(i[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=l.none;for(let r of i.concat(e.marks))(t.type?t.type.allowsMarkType(r.type):K(r.type,e.type))&&(n=r.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,i){let r=this.findPlace(e.create(t),n,!1);return r&&(r=this.enterInner(e,t,n,!0,i)),r}enterInner(e,t,n,i=!1,r){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=W(e,r,s.options);4&s.options&&0==s.content.length&&(o|=4);let a=l.none;return n=n.filter(t=>(s.type?!s.type.allowsMarkType(t.type):!K(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new G(e,t,a,i,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)null==this.find[i].pos&&1==e.nodeType&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),r=-(n?n.depth+1:0)+(i?0:1),s=(e,o)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;o>=r;o--)if(s(e-1,o))return!0;return!1}{let e=o>0||0==o&&i?this.nodes[o].type:n&&o>=r?n.node(o-r).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;o--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function q(e){let t={};for(let n in e)t[n]=e[n];return t}function K(e,t){let n=t.schema.nodes;for(let i in n){let r=n[i];if(!r.allowsMarkType(e))continue;let s=[],o=e=>{s.push(e);for(let n=0;n<e.edgeCount;n++){let{type:i,next:r}=e.edge(n);if(i==t||0>s.indexOf(r)&&o(r))return!0}};if(o(r.contentMatch))return!0}}class Y{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){!n&&(n=J(t).createDocumentFragment());let i=n,r=[];return e.forEach(e=>{if(r.length||e.marks.length){let n=0,s=0;for(;n<r.length&&s<e.marks.length;){let t=e.marks[s];if(!this.marks[t.type.name]){s++;continue}if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,s++}for(;n<r.length;)i=r.pop()[1];for(;s<e.marks.length;){let n=e.marks[s++],o=this.serializeMark(n,e.isInline,t);o&&(r.push([n,i]),i.appendChild(o.dom),i=o.contentDOM||o.dom)}}i.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:i}=ee(J(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&ee(J(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return ee(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Y(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=X(e.nodes);return!t.text&&(t.text=e=>e.text),t}static marksFromSchema(e){return X(e.marks)}}function X(e){let t={};for(let n in e){let i=e[n].spec.toDOM;i&&(t[n]=i)}return t}function J(e){return e.document||window.document}let Q=new WeakMap;function ee(e,t,n,i){var r;let s,o;if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let a=t[0],l;if("string"!=typeof a)throw RangeError("Invalid array passed to renderSpec");if(i&&(r=i,void 0===(o=Q.get(r))&&Q.set(r,o=function(e){let t=null;return!function e(n){if(n&&"object"==typeof n){if(Array.isArray(n)){if("string"==typeof n[0])!t&&(t=[]),t.push(n);else for(let t=0;t<n.length;t++)e(n[t])}else for(let t in n)e(n[t])}}(e),t}(r)),l=o)&&l.indexOf(t)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let d=a.indexOf(" ");d>0&&(n=a.slice(0,d),a=a.slice(d+1));let c=n?e.createElementNS(n,a):e.createElement(a),h=t[1],u=1;if(h&&"object"==typeof h&&null==h.nodeType&&!Array.isArray(h)){for(let e in u=2,h)if(null!=h[e]){let t=e.indexOf(" ");t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),h[e]):c.setAttribute(e,h[e])}}for(let r=u;r<t.length;r++){let o=t[r];if(0===o){if(r<t.length-1||r>u)throw RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}{let{dom:t,contentDOM:r}=ee(e,o,n,i);if(c.appendChild(t),r){if(s)throw RangeError("Multiple content holes");s=r}}}return{dom:c,contentDOM:s}}},871738:function(e,t,n){"use strict";n.d(t,{Bs:function(){return c},C1:function(){return f},H$:function(){return k},Sy:function(){return E},Y1:function(){return o},qv:function(){return u},xm:function(){return a},yy:function(){return S}});var i=n(153737),r=n(240554);let s=Object.create(null);class o{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new a(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=i.p2.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:d}=o[a],c=e.mapping.slice(s);e.replaceRange(c.map(l.pos),c.map(d.pos),a?i.p2.empty:t),0==a&&v(e,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let r=0;r<i.length;r++){let{$from:s,$to:o}=i[r],a=e.mapping.slice(n),l=a.map(s.pos),d=a.map(o.pos);r?e.deleteRange(l,d):(e.replaceRangeWith(l,d,t),v(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new c(e):g(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let i=e.depth-1;i>=0;i--){let r=t<0?g(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):g(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new f(e.node(0))}static atStart(e){return g(e,e,0,0,1)||new f(e)}static atEnd(e){return g(e,e,e.content.size,e.childCount,-1)||new f(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError("Invalid input for Selection.fromJSON");let n=s[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in s)throw RangeError("Duplicate use of selection JSON ID "+e);return s[e]=t,t.prototype.jsonID=e,t}getBookmark(){return c.between(this.$anchor,this.$head).getBookmark()}}o.prototype.visible=!0;class a{constructor(e,t){this.$from=e,this.$to=t}}let l=!1;function d(e){!l&&!e.parent.inlineContent&&(l=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class c extends o{constructor(e,t=e){d(e),d(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return o.near(n);let i=e.resolve(t.map(this.anchor));return new c(i.parent.inlineContent?i:n,n)}replace(e,t=i.p2.empty){if(super.replace(e,t),t==i.p2.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof c&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new h(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new c(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let e=o.findFrom(t,n,!0)||o.findFrom(t,-n,!0);if(!e)return o.near(t,n);t=e.$head}return!e.parent.inlineContent&&(0==i?e=t:(e=(o.findFrom(e,-n,!0)||o.findFrom(e,n,!0)).$anchor).pos<t.pos!=i<0&&(e=t)),new c(e,t)}}o.jsonID("text",c);class h{constructor(e,t){this.anchor=e,this.head=t}map(e){return new h(e.map(this.anchor),e.map(this.head))}resolve(e){return c.between(e.resolve(this.anchor),e.resolve(this.head))}}class u extends o{constructor(e){let t=e.nodeAfter;super(e,e.node(0).resolve(e.pos+t.nodeSize)),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),r=e.resolve(i);return n?o.near(r):new u(r)}content(){return new i.p2(i.HY.from(this.node),0,0)}eq(e){return e instanceof u&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new p(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new u(e.resolve(t.anchor))}static create(e,t){return new u(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}u.prototype.visible=!1,o.jsonID("node",u);class p{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new h(n,n):new p(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&u.isSelectable(n)?new u(t):o.near(t)}}class f extends o{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=i.p2.empty){if(t==i.p2.empty){e.delete(0,e.doc.content.size);let t=o.atStart(e.doc);!t.eq(e.selection)&&e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new f(e)}map(e){return new f(e)}eq(e){return e instanceof f}getBookmark(){return m}}o.jsonID("all",f);let m={map(){return this},resolve:e=>new f(e)};function g(e,t,n,i,r,s=!1){if(t.inlineContent)return c.create(e,n);for(let o=i-(r>0?0:1);r>0?o<t.childCount:o>=0;o+=r){let i=t.child(o);if(i.isAtom){if(!s&&u.isSelectable(i))return u.create(e,n-(r<0?i.nodeSize:0))}else{let t=g(e,i,n+r,r<0?i.childCount:0,r,s);if(t)return t}n+=i.nodeSize*r}return null}function v(e,t,n){let i,s=e.steps.length-1;if(s<t)return;let a=e.steps[s];if(!!(a instanceof r.Pu||a instanceof r.FC))e.mapping.maps[s].forEach((e,t,n,r)=>{null==i&&(i=r)}),e.setSelection(o.near(e.doc.resolve(i),n))}class b extends r.wx{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return!i.vc.sameSet(this.storedMarks||this.selection.$from.marks(),e)&&this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||i.vc.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,r)),!this.selection.empty&&this.setSelection(o.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function y(e,t){return t&&e?e.bind(t):e}class x{constructor(e,t,n){this.name=e,this.init=y(t.init,n),this.apply=y(t.apply,n)}}let w=[new x("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new x("selection",{init:(e,t)=>e.selection||o.atStart(t.doc),apply:e=>e.selection}),new x("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,i)=>i.selection.$cursor?e.storedMarks:null}),new x("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class _{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=w.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new x(e.key,e.spec.state,e))})}}class S{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let r=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let a=i?i[s].n:0,l=i?i[s].state:this,d=a<t.length&&o.spec.appendTransaction.call(o,a?t.slice(a):t,l,n);if(d&&n.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let e=0;e<this.config.plugins.length;e++)i.push(e<s?{state:n,n:t.length}:{state:this,n:0})}t.push(d),n=n.applyInner(d),r=!0}i&&(i[s]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let t=new S(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let r=n[i];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new b(this)}static create(e){let t=new _(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new S(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new _(this.schema,e.plugins),n=t.fields,i=new S(t);for(let t=0;t<n.length;t++){let r=n[t].name;i[r]=this.hasOwnProperty(r)?this[r]:n[t].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],r=i.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let r=new _(e.schema,e.plugins),s=new S(r);return r.fields.forEach(r=>{if("doc"==r.name)s.doc=i.NB.fromJSON(e.schema,t.doc);else if("selection"==r.name)s.selection=o.fromJSON(s.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let o=n[i],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i)){s[r.name]=a.fromJSON.call(o,e,t[i],s);return}}s[r.name]=r.init(e,s)}}),s}}class E{constructor(e){this.spec=e,this.props={},e.props&&!function e(t,n,i){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(n):"handleDOMEvents"==r&&(s=e(s,n,{})),i[r]=s}return i}(e.props,this,this.props),this.key=e.key?e.key.key:A("plugin")}getState(e){return e[this.key]}}let C=Object.create(null);function A(e){return e in C?e+"$"+ ++C[e]:(C[e]=0,e+"$")}class k{constructor(e="key"){this.key=A(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}},240554:function(e,t,n){"use strict";n.d(t,{Ax:function(){return C},FC:function(){return v},GJ:function(){return T},Mn:function(){return A},Pu:function(){return g},dR:function(){return D},k9:function(){return x},nd:function(){return w},nj:function(){return M},vs:function(){return a},wx:function(){return H}});var i=n(153737);function r(e){return 65535&e}class s{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class o{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&o.empty)return o.empty}recover(e){var t;let n=0,i=65535&e;if(!this.inverted)for(let e=0;e<i;e++)n+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*i]+n+((t=e)-(65535&t))/65536}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,r=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let d=this.ranges[a+r],c=this.ranges[a+o],h=l+d;if(e<=h){let r=d?e==l?-1:e==h?1:t:t,o=l+i+(r<0?0:c);if(n)return o;let u=e==(t<0?l:h)?null:a/3+(e-l)*65536,p=e==l?2:e==h?1:4;return(t<0?e!=l:e!=h)&&(p|=8),new s(o,p,u)}i+=c-d}return n?e+i:new s(e+i,0,null)}touches(e,t){let n=0,i=65535&t,r=this.inverted?2:1,s=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let a=this.ranges[t+r];if(e<=o+a&&t==3*i)return!0;n+=this.ranges[t+s]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,r=0;i<this.ranges.length;i+=3){let s=this.ranges[i],o=s-(this.inverted?r:0),a=s+(this.inverted?0:r),l=this.ranges[i+t],d=this.ranges[i+n];e(o,o+l,a,a+d),r+=d-l}}invert(){return new o(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?o.empty:new o(e<0?[0,-e,0]:[0,0,e])}}o.empty=new o([]);class a{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new a(this._maps,this.mirror,e,t)}appendMap(e,t){!this.ownData&&(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],null!=i&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){!this.mirror&&(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=i&&i>t?n-i-1:void 0)}}invert(){let e=new a;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let n=this.from;n<this.to;n++){let r=this._maps[n].mapResult(e,t);if(null!=r.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(r.recover);continue}}i|=r.delInfo,e=r.pos}return n?e:new s(e,i,null)}}let l=Object.create(null);class d{getMap(){return o.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError("Invalid input for Step.fromJSON");let n=l[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in l)throw RangeError("Duplicate use of step JSON ID "+e);return l[e]=t,t.prototype.jsonID=e,t}}class c{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new c(e,null)}static fail(e){return new c(null,e)}static fromReplace(e,t,n,r){try{return c.ok(e.replace(t,n,r))}catch(e){if(e instanceof i.e4)return c.fail(e.message);throw e}}}function h(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let s=e.child(i);s.content.size&&(s=s.copy(h(s.content,t,s))),s.isInline&&(s=t(s,n,i)),r.push(s)}return i.HY.fromArray(r)}class u extends d{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),s=new i.p2(h(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return c.fromReplace(e,this.from,this.to,s)}invert(){return new p(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new u(t.pos,n.pos,this.mark)}merge(e){return e instanceof u&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new u(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new u(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("addMark",u);class p extends d{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new i.p2(h(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return c.fromReplace(e,this.from,this.to,n)}invert(){return new u(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new p(t.pos,n.pos,this.mark)}merge(e){return e instanceof p&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new p(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new p(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("removeMark",p);class f extends d{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return c.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return c.fromReplace(e,this.pos,this.pos+1,new i.p2(i.HY.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new f(this.pos,t.marks[n]);return new f(this.pos,this.mark)}}return new m(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new f(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new f(t.pos,e.markFromJSON(t.mark))}}d.jsonID("addNodeMark",f);class m extends d{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return c.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return c.fromReplace(e,this.pos,this.pos+1,new i.p2(i.HY.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new f(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new m(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new m(t.pos,e.markFromJSON(t.mark))}}d.jsonID("removeNodeMark",m);class g extends d{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&b(e,this.from,this.to)?c.fail("Structure replace would overwrite content"):c.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new o([this.from,this.to-this.from,this.slice.size])}invert(e){return new g(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new g(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof g)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;else{let t=this.slice.size+e.slice.size==0?i.p2.empty:new i.p2(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new g(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?i.p2.empty:new i.p2(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new g(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new g(t.from,t.to,i.p2.fromJSON(e,t.slice),!!t.structure)}}d.jsonID("replace",g);class v extends d{constructor(e,t,n,i,r,s,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=r,this.insert=s,this.structure=o}apply(e){if(this.structure&&(b(e,this.from,this.gapFrom)||b(e,this.gapTo,this.to)))return c.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return c.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?c.fromReplace(e,this.from,this.to,n):c.fail("Content does not fit in gap")}getMap(){return new o([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new v(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||r>n.pos?null:new v(t.pos,n.pos,i,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new v(t.from,t.to,t.gapFrom,t.gapTo,i.p2.fromJSON(e,t.slice),t.insert,!!t.structure)}}function b(e,t,n){let i=e.resolve(t),r=n-t,s=i.depth;for(;r>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,r--;if(r>0){let e=i.node(s).maybeChild(i.indexAfter(s));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}d.jsonID("replaceAround",v);function y(e,t,n,r=n.contentMatch,s=!0){let o=e.doc.nodeAt(t),a=[],l=t+1;for(let t=0;t<o.childCount;t++){let d=o.child(t),c=l+d.nodeSize,h=r.matchType(d.type);if(h){r=h;for(let t=0;t<d.marks.length;t++)!n.allowsMarkType(d.marks[t].type)&&e.step(new p(l,c,d.marks[t]));if(s&&d.isText&&"pre"!=n.whitespace){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(d.text);)!r&&(r=new i.p2(i.HY.from(n.schema.text(" ",n.allowedMarks(d.marks))),0,0)),a.push(new g(l+e.index,l+e.index+e[0].length,r))}}else a.push(new g(l,c,i.p2.empty));l=c}if(!r.validEnd){let t=r.fillBefore(i.HY.empty,!0);e.replace(l,l,new i.p2(t,0,0))}for(let t=a.length-1;t>=0;t--)e.step(a[t])}function x(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let s=e.depth;;--s){var n,i,r;let o=e.$from.node(s),a=e.$from.index(s),l=e.$to.indexAfter(s);if(s<e.depth&&o.canReplace(a,l,t))return s;if(0==s||o.type.spec.isolating||(n=o,i=a,r=l,!((0==i||n.canReplace(i,n.childCount))&&(r==n.childCount||n.canReplace(0,r)))))break}return null}function w(e,t,n=null,i=e){let r=function(e,t){let{parent:n,startIndex:i,endIndex:r}=e,s=n.contentMatchAt(i).findWrapping(t);if(!s)return null;let o=s.length?s[0]:t;return n.canReplaceWith(i,r,o)?s:null}(e,t),s=r&&function(e,t){let{parent:n,startIndex:i,endIndex:r}=e,s=n.child(i),o=t.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:t).contentMatch;for(let e=i;a&&e<r;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?o:null}(i,t);return s?r.map(_).concat({type:t,attrs:n}).concat(s.map(_)):null}function _(e){return{type:e,attrs:null}}function S(e,t,n,i){t.forEach((r,s)=>{if(r.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(r.text);){let r=e.mapping.slice(i).map(n+1+s+o.index);e.replaceWith(r,r+1,t.type.schema.linebreakReplacement.create())}}})}function E(e,t,n,i){t.forEach((r,s)=>{if(r.type==r.type.schema.linebreakReplacement){let r=e.mapping.slice(i).map(n+1+s);e.replaceWith(r,r+1,t.type.schema.text("\n"))}})}function C(e,t,n=1,i){let r=e.resolve(t),s=r.depth-n,o=i&&i[i.length-1]||r.parent;if(s<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!o.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>s;e--,t--){let n=r.node(e),s=r.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(s,n.childCount),a=i&&i[t+1];a&&(o=o.replaceChild(0,a.type.create(a.attrs)));let l=i&&i[t]||n;if(!n.canReplace(s+1,n.childCount)||!l.type.validContent(o))return!1}let a=r.indexAfter(s),l=i&&i[0];return r.node(s).canReplaceWith(a,a,l?l.type:r.node(s+1).type)}function A(e,t){let n=e.resolve(t),i=n.index();return k(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function k(e,t){return!!(e&&t&&!e.isLeaf&&function(e,t){!t.content.size&&e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:i}=e.type.schema;for(let r=0;r<t.childCount;r++){let s=t.child(r),o=s.type==i?e.type.schema.nodes.text:s.type;if(!(n=n.matchType(o))||!e.type.allowsMarks(s.marks))return!1}return n.validEnd}(e,t))}function T(e,t,n=-1){let i=e.resolve(t);for(let e=i.depth;;e--){let r,s,o=i.index(e);if(e==i.depth?(r=i.nodeBefore,s=i.nodeAfter):n>0?(r=i.node(e+1),o++,s=i.node(e).maybeChild(o)):(r=i.node(e).maybeChild(o-1),s=i.node(e+1)),r&&!r.isTextblock&&k(r,s)&&i.node(e).canReplace(o,o+1))return t;if(0==e)break;t=n<0?i.before(e):i.after(e)}}function M(e,t,n){let i=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e<n.openStart;e++)r=r.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=i.depth;t>=0;t--){let n=t==i.depth?0:i.pos<=(i.start(t+1)+i.end(t+1))/2?-1:1,s=i.index(t)+(n>0?1:0),o=i.node(t),a=!1;if(1==e)a=o.canReplace(s,s,r);else{let e=o.contentMatchAt(s).findWrapping(r.firstChild.type);a=e&&o.canReplaceWith(s,s,e[0])}if(a)return 0==n?i.pos:n<0?i.before(t+1):i.after(t+1)}return null}function D(e,t,n=t,r=i.p2.empty){if(t==n&&!r.size)return null;let s=e.resolve(t),o=e.resolve(n);return O(s,o,r)?new g(t,n,r):new I(s,o,r).fit()}function O(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class I{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=i.HY.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=i.HY.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let s=this.placed,o=n.depth,a=r.depth;for(;o&&a&&1==s.childCount;)s=s.firstChild.content,o--,a--;let l=new i.p2(s,o,a);return e>-1?new v(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new g(n.pos,r.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let r=t.firstChild;if(t.childCount>1&&(i=0),r.type.spec.isolating&&i<=n){e=n;break}t=r.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null,s=(e=n?(r=L(this.unplaced.content,n-1).firstChild).content:this.unplaced.content).firstChild;for(let e=this.depth;e>=0;e--){let{type:o,match:a}=this.frontier[e],l,d=null;if(1==t&&(s?a.matchType(s.type)||(d=a.fillBefore(i.HY.from(s),!1)):r&&o.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:d};if(2==t&&s&&(l=a.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:l};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=L(e,t);return!!r.childCount&&!r.firstChild.isLeaf&&(this.unplaced=new i.p2(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=L(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new i.p2(N(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new i.p2(N(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let e=0;e<s.length;e++)this.openFrontierNode(s[e]);let o=this.unplaced,a=n?n.content:o.content,l=o.openStart-e,d=0,c=[],{match:h,type:u}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));h=h.matchFragment(r)}let p=a.size+e-(o.content.size-o.openEnd);for(;d<a.childCount;){let e=a.child(d),t=h.matchType(e.type);if(!t)break;(++d>1||0==l||e.content.size)&&(h=t,c.push(function e(t,n,r){if(n<=0)return t;let s=t.content;return n>1&&(s=s.replaceChild(0,e(s.firstChild,n-1,1==s.childCount?r-1:0))),n>0&&(s=t.type.contentMatch.fillBefore(s).append(s),r<=0&&(s=s.append(t.type.contentMatch.matchFragment(s).fillBefore(i.HY.empty,!0)))),t.copy(s)}(e.mark(u.allowedMarks(e.marks)),1==d?l:0,d==a.childCount?p:-1)))}let f=d==a.childCount;!f&&(p=-1),this.placed=R(this.placed,t,i.HY.from(c)),this.frontier[t].match=h,f&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=a;e<p;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=f?0==e?i.p2.empty:new i.p2(N(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new i.p2(N(o.content,e,d),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!P(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return -1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){i:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=P(e,t,i,n,r);if(s){for(let n=t-1;n>=0;n--){let{match:t,type:i}=this.frontier[n],r=P(e,n,i,t,!0);if(!r||r.childCount)continue i}return{depth:t,fit:s,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=R(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),i=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,i)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=R(this.placed,this.depth,i.HY.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(i.HY.empty,!0);e.childCount&&(this.placed=R(this.placed,this.frontier.length,e))}}function N(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(N(e.firstChild.content,t-1,n)))}function R(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(R(e.lastChild.content,t-1,n)))}function L(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function P(e,t,n,i,r){let s=e.node(t),o=r?e.indexAfter(t):e.index(t);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let a=i.fillBefore(s.content,!0,o);return a&&!function(e,t,n){for(let i=n;i<t.childCount;i++)if(!e.allowsMarks(t.child(i).marks))return!0;return!1}(n,s.content,o)?a:null}function j(e,t){let n=[],i=Math.min(e.depth,t.depth);for(let r=i;r>=0;r--){let i=e.start(r);if(i<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(i==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==i-1)&&n.push(r)}return n}class F extends d{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return c.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return c.fromReplace(e,this.pos,this.pos+1,new i.p2(i.HY.from(r),0,t.isLeaf?0:1))}getMap(){return o.empty}invert(e){return new F(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new F(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new F(t.pos,t.attr,t.value)}}d.jsonID("attr",F);class B extends d{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return c.ok(n)}getMap(){return o.empty}invert(e){return new B(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new B(t.attr,t.value)}}d.jsonID("docAttr",B);let z=class extends Error{};(z=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype),z.prototype.constructor=z,z.prototype.name="TransformError";class H{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new a}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new z(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return!t.failed&&this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=i.p2.empty){let r=D(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new i.p2(i.HY.from(n),0,0))}delete(e,t){return this.replace(e,t,i.p2.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return!function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let s=e.doc.resolve(t),o=e.doc.resolve(n);if(O(s,o,r))return e.step(new g(t,n,r));let a=j(s,e.doc.resolve(n));0==a[a.length-1]&&a.pop();let l=-(s.depth+1);a.unshift(l);for(let e=s.depth,t=s.pos-1;e>0;e--,t--){let n=s.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;a.indexOf(e)>-1?l=e:s.before(e)==t&&a.splice(1,0,-e)}let d=a.indexOf(l),c=[],h=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=h-1;e>=0;e--){var u;let t=c[e],n=(u=t.type).spec.defining||u.spec.definingForContent;if(n&&!t.sameMarkup(s.node(Math.abs(l)-1)))h=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let l=(t+h+1)%(r.openStart+1),u=c[l];if(u)for(let t=0;t<a.length;t++){let c=a[(t+d)%a.length],h=!0;c<0&&(h=!1,c=-c);let p=s.node(c-1),f=s.index(c-1);if(p.canReplaceWith(f,f,u.type,u.marks))return e.replace(s.before(c),h?o.after(c):n,new i.p2(function e(t,n,r,s,o){if(n<r){let i=t.firstChild;t=t.replaceChild(0,i.copy(e(i.content,n+1,r,s,i)))}if(n>s){let e=o.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(i.HY.empty,!0))}return t}(r.content,0,r.openStart,l),l,r.openEnd))}}let p=e.steps.length;for(let i=a.length-1;i>=0&&(e.replace(t,n,r),!(e.steps.length>p));i--){;let e=a[i];!(e<0)&&(t=s.before(e),n=o.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return!function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=function(e,t,n){let i=e.resolve(t);if(i.parent.canReplaceWith(i.index(),i.index(),n))return t;if(0==i.parentOffset)for(let e=i.depth-1;e>=0;e--){let t=i.index(e);if(i.node(e).canReplaceWith(t,t,n))return i.before(e+1);if(t>0)return null}if(i.parentOffset==i.parent.content.size)for(let e=i.depth-1;e>=0;e--){let t=i.indexAfter(e);if(i.node(e).canReplaceWith(t,t,n))return i.after(e+1);if(t<i.node(e).childCount)break}return null}(e.doc,t,r.type);null!=i&&(t=n=i)}e.replaceRange(t,n,new i.p2(i.HY.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return!function(e,t,n){let i=e.doc.resolve(t),r=e.doc.resolve(n),s=j(i,r);for(let t=0;t<s.length;t++){let n=s[t],o=t==s.length-1;if(o&&0==n||i.node(n).type.contentMatch.validEnd)return e.delete(i.start(n),r.end(n));if(n>0&&(o||i.node(n-1).canReplace(i.index(n-1),r.indexAfter(n-1))))return e.delete(i.before(n),r.after(n))}for(let s=1;s<=i.depth&&s<=r.depth;s++)if(t-i.start(s)==i.depth-s&&n>i.end(s)&&r.end(s)-n!=r.depth-s&&i.start(s-1)==r.start(s-1)&&i.node(s-1).canReplace(i.index(s-1),r.index(s-1)))return e.delete(i.before(s),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return!function(e,t,n){let{$from:r,$to:s,depth:o}=t,a=r.before(o+1),l=s.after(o+1),d=a,c=l,h=i.HY.empty,u=0;for(let e=o,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,h=i.HY.from(r.node(e).copy(h)),u++):d--;let p=i.HY.empty,f=0;for(let e=o,t=!1;e>n;e--)t||s.after(e+1)<s.end(e)?(t=!0,p=i.HY.from(s.node(e).copy(p)),f++):c++;e.step(new v(d,c,a,l,new i.p2(h.append(p),u,f),h.size-u,!0))}(this,e,t),this}join(e,t=1){return!function(e,t,n){let r=null,{linebreakReplacement:s}=e.doc.type.schema,o=e.doc.resolve(t-n),a=o.node().type;if(s&&a.inlineContent){let e="pre"==a.whitespace,t=!!a.contentMatch.matchType(s);e&&!t?r=!1:!e&&t&&(r=!0)}let l=e.steps.length;if(!1===r){let i=e.doc.resolve(t+n);E(e,i.node(),i.before(),l)}a.inlineContent&&y(e,t+n-1,a,o.node().contentMatchAt(o.index()),null==r);let d=e.mapping.slice(l),c=d.map(t-n);if(e.step(new g(c,d.map(t+n,-1),i.p2.empty,!0)),!0===r){let t=e.doc.resolve(c);S(e,t.node(),t.before(),e.steps.length)};}(this,e,t),this}wrap(e,t){return!function(e,t,n){let r=i.HY.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=i.HY.from(n[e].type.create(n[e].attrs,r))}let s=t.start,o=t.end;e.step(new v(s,o,s,o,new i.p2(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return!function(e,t,n,r,s){if(!r.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let a="function"==typeof s?s(t):s;if(t.isTextblock&&!t.hasMarkup(r,a)&&function(e,t,n){let i=e.resolve(t),r=i.index();return i.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(o).map(n),r)){let s=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?s=!1:!e&&t&&(s=!0)}!1===s&&E(e,t,n,o),y(e,e.mapping.slice(o).map(n,1),r,void 0,null===s);let l=e.mapping.slice(o),d=l.map(n,1),c=l.map(n+t.nodeSize,1);return e.step(new v(d,c,d+1,c-1,new i.p2(i.HY.from(r.create(a,null,t.marks)),0,0),1,!0)),!0===s&&S(e,t,n,o),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return!function(e,t,n,r,s){let o=e.doc.nodeAt(t);if(!o)throw RangeError("No node at given position");!n&&(n=o.type);let a=n.create(r,null,s||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,a);if(!n.validContent(o.content))throw RangeError("Invalid content for node type "+n.name);e.step(new v(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new i.p2(i.HY.from(a),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new F(e,t,n)),this}setDocAttribute(e,t){return this.step(new B(e,t)),this}addNodeMark(e,t){return this.step(new f(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError("No node at position "+e);if(t instanceof i.vc)t.isInSet(n.marks)&&this.step(new m(e,t));else{let i=n.marks,r,s=[];for(;r=t.isInSet(i);)s.push(new m(e,r)),i=r.removeFromSet(i);for(let e=s.length-1;e>=0;e--)this.step(s[e])}return this}split(e,t=1,n){return!function(e,t,n=1,r){let s=e.doc.resolve(t),o=i.HY.empty,a=i.HY.empty;for(let e=s.depth,t=s.depth-n,l=n-1;e>t;e--,l--){o=i.HY.from(s.node(e).copy(o));let t=r&&r[l];a=i.HY.from(t?t.type.create(t.attrs,a):s.node(e).copy(a))}e.step(new g(t,t,new i.p2(o.append(a),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){var i,r,s,o;let a,l,d,c;return i=this,r=e,s=t,o=n,d=[],c=[],i.doc.nodesBetween(r,s,(e,t,n)=>{if(!e.isInline)return;let i=e.marks;if(!o.isInSet(i)&&n.type.allowsMarkType(o.type)){let n=Math.max(t,r),h=Math.min(t+e.nodeSize,s),f=o.addToSet(i);for(let e=0;e<i.length;e++)!i[e].isInSet(f)&&(a&&a.to==n&&a.mark.eq(i[e])?a.to=h:d.push(a=new p(n,h,i[e])));l&&l.to==n?l.to=h:c.push(l=new u(n,h,o))}}),d.forEach(e=>i.step(e)),c.forEach(e=>i.step(e)),this}removeMark(e,t,n){var r,s,o,a;let l,d;return r=this,s=e,o=t,a=n,l=[],d=0,r.doc.nodesBetween(s,o,(e,t)=>{if(!e.isInline)return;d++;let n=null;if(a instanceof i.ZU){let t=e.marks,i;for(;i=a.isInSet(t);)(n||(n=[])).push(i),t=i.removeFromSet(t)}else a?a.isInSet(e.marks)&&(n=[a]):n=e.marks;if(n&&n.length){let i=Math.min(t+e.nodeSize,o);for(let e=0;e<n.length;e++){let r=n[e],o;for(let e=0;e<l.length;e++){let t=l[e];t.step==d-1&&r.eq(l[e].style)&&(o=t)}o?(o.to=i,o.step=d):l.push({style:r,from:Math.max(t,s),to:i,step:d})}}}),l.forEach(e=>r.step(new p(e.from,e.to,e.style))),this}clearIncompatible(e,t,n){return y(this,e,t,n),this}}},661763:function(e,t,n){"use strict";n.d(t,{EH:function(){return tx},p:function(){return tv},tk:function(){return tV}});var i=n(871738),r=n(153737),s=n(240554);let o=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},a=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},l=null,d=function(e,t,n){let i=l||(l=document.createRange());return i.setEnd(e,null==n?e.nodeValue.length:n),i.setStart(e,t||0),i},c=function(){l=null},h=function(e,t,n,i){return n&&(p(e,t,n,i,-1)||p(e,t,n,i,1))},u=/^(img|br|input|textarea|hr)$/i;function p(e,t,n,i,r){for(var s;;){if(e==n&&t==i)return!0;if(t==(r<0?0:f(e))){let n=e.parentNode;if(!n||1!=n.nodeType||m(e)||u.test(e.nodeName)||"false"==e.contentEditable)return!1;t=o(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;let n=e.childNodes[t+(r<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(null===(s=n.pmViewDesc)||void 0===s||!s.ignoreForSelection)return!1;t+=r}else e=n,t=r<0?f(e):0}}}function f(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function m(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}let g=function(e){return e.focusNode&&h(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function v(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}let b="undefined"!=typeof navigator?navigator:null,y="undefined"!=typeof document?document:null,x=b&&b.userAgent||"",w=/Edge\/(\d+)/.exec(x),_=/MSIE \d/.exec(x),S=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(x),E=!!(_||S||w),C=_?document.documentMode:S?+S[1]:w?+w[1]:0,A=!E&&/gecko\/(\d+)/i.test(x);A&&(/Firefox\/(\d+)/.exec(x)||[0,0])[1];let k=!E&&/Chrome\/(\d+)/.exec(x),T=!!k,M=k?+k[1]:0,D=!E&&!!b&&/Apple Computer/.test(b.vendor),O=D&&(/Mobile\/\w+/.test(x)||!!b&&b.maxTouchPoints>2),I=O||!!b&&/Mac/.test(b.platform),N=!!b&&/Win/.test(b.platform),R=/Android \d/.test(x),L=!!y&&"webkitFontSmoothing"in y.documentElement.style,P=L?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function j(e,t){return"number"==typeof e?e:e[t]}function F(e,t,n){let i=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,s=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(1!=o.nodeType){o=a(o);continue}let e=o,n=e==s.body,l=n?function(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}(s):function(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,i=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*i}}(e),d=0,c=0;if(t.top<l.top+j(i,"top")?c=-(l.top-t.top+j(r,"top")):t.bottom>l.bottom-j(i,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+j(r,"top")-l.top:t.bottom-l.bottom+j(r,"bottom")),t.left<l.left+j(i,"left")?d=-(l.left-t.left+j(r,"left")):t.right>l.right-j(i,"right")&&(d=t.right-l.right+j(r,"right")),d||c){if(n)s.defaultView.scrollBy(d,c);else{let n=e.scrollLeft,i=e.scrollTop;c&&(e.scrollTop+=c),d&&(e.scrollLeft+=d);let r=e.scrollLeft-n,s=e.scrollTop-i;t={left:t.left-r,top:t.top-s,right:t.right-r,bottom:t.bottom-s}}}let h=n?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o="absolute"==h?o.offsetParent:a(o)}}function B(e){let t=[],n=e.ownerDocument;for(let i=e;i&&(t.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),e!=n);i=a(i));return t}function z(e,t){for(let n=0;n<e.length;n++){let{dom:i,top:r,left:s}=e[n];i.scrollTop!=r+t&&(i.scrollTop=r+t),i.scrollLeft!=s&&(i.scrollLeft=s)}}let H=null;function U(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function V(e){return e.top<e.bottom||e.left<e.right}function $(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(V(e))return e}return Array.prototype.find.call(n,V)||e.getBoundingClientRect()}let W=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function G(e,t,n){let{node:i,offset:r,atom:s}=e.docView.domFromPos(t,n<0?-1:1),o=L||A;if(3==i.nodeType){if(o&&(W.test(i.nodeValue)||(n<0?!r:r==i.nodeValue.length))){let e=$(d(i,r,r),n);if(A&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let t=$(d(i,r-1,r-1),-1);if(t.top==e.top){let n=$(d(i,r,r+1),-1);if(n.top!=e.top)return Z(n,n.left<t.left)}}return e}{let e=r,t=r,s=n<0?1:-1;return n<0&&!r?(t++,s=-1):n>=0&&r==i.nodeValue.length?(e--,s=1):n<0?e--:t++,Z($(d(i,e,t),s),s<0)}}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(null==s&&r&&(n<0||r==f(i))){let e=i.childNodes[r-1];if(1==e.nodeType)return q(e.getBoundingClientRect(),!1)}if(null==s&&r<f(i)){let e=i.childNodes[r];if(1==e.nodeType)return q(e.getBoundingClientRect(),!0)}return q(i.getBoundingClientRect(),n>=0)}if(null==s&&r&&(n<0||r==f(i))){let e=i.childNodes[r-1],t=3==e.nodeType?d(e,f(e)-(o?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Z($(t,1),!1)}if(null==s&&r<f(i)){let e=i.childNodes[r];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?d(e,0,o?0:1):1==e.nodeType?e:null:null;if(t)return Z($(t,-1),!0)}return Z($(3==i.nodeType?d(i):i,-n),n>=0)}function Z(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function q(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function K(e,t,n){let i=e.state,r=e.root.activeElement;i!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{i!=t&&e.updateState(i),r!=e.dom&&r&&r.focus()}}let Y=/[\u0590-\u08ac]/,X=null,J=null,Q=!1;class ee{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){let i;if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,i;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((i=n.pmViewDesc)&&i.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(i)+i.size:this.posAtStart}{let n,i;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((i=n.pmViewDesc)&&i.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(i):this.posAtEnd}}if(e==this.dom&&this.contentDOM)i=t>o(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!1;break}if(t.previousSibling)break}if(null==i&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!0;break}if(t.nextSibling)break}}return(null==i?n>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let r=this.getDesc(i),s;if(r&&(!t||r.node)){if(!n||!(s=r.nodeDOM)||(1==s.nodeType?s.contains(1==e.nodeType?e:e.parentNode):s==e))return r;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,n)}return -1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],r=n+i.size;if(n==e&&r!=n){for(;!i.border&&i.children.length;)for(let e=0;e<i.children.length;e++){let t=i.children[e];if(t.size){i=t;break}}return i}if(e<r)return i.descAt(e-n-i.border);n=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let t=0;n<this.children.length;n++){let r=this.children[n],s=t+r.size;if(s>e||r instanceof ea){i=e-t;break}t=s}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof et&&e.side>=0;n--);if(t<=0){let e,i=!0;for(;(e=n?this.children[n-1]:null)&&e.dom.parentNode!=this.contentDOM;n--,i=!1);return e&&t&&i&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?o(e.dom)+1:0}}{let e,i=!0;for(;(e=n<this.children.length?this.children[n]:null)&&e.dom.parentNode!=this.contentDOM;n++,i=!1);return e&&i&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?o(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,r=-1;for(let s=n,a=0;;a++){let n=this.children[a],l=s+n.size;if(-1==i&&e<=l){let r=s+n.border;if(e>=r&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=s;for(let t=a;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){i=o(n.dom)+1;break}e-=n.size}-1==i&&(i=0)}if(i>-1&&(l>t||a==this.children.length-1)){t=l;for(let e=a+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=o(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}s=l}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let r=Math.min(e,t),s=Math.max(e,t);for(let o=0,a=0;o<this.children.length;o++){let l=this.children[o],d=a+l.size;if(r>a&&s<d)return l.setSelection(e-a-l.border,t-a-l.border,n,i);a=d}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),d=n.root.getSelection(),c=n.domSelectionRange(),u=!1;if((A||D)&&e==t){let{node:e,offset:t}=a;if(3==e.nodeType){if((u=!!(t&&"\n"==e.nodeValue[t-1]))&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){"BR"==n.nodeName&&(a=l={node:n.parentNode,offset:o(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(A&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(i=!0)}if(!(i||u&&D)&&h(a.node,a.offset,c.anchorNode,c.anchorOffset)&&h(l.node,l.offset,c.focusNode,c.focusOffset))return;let p=!1;if((d.extend||e==t)&&!u){d.collapse(a.node,a.offset);try{e!=t&&d.extend(l.node,l.offset),p=!0}catch(e){}}if(!p){if(e>t){let e=a;a=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(a.node,a.offset),d.removeAllRanges(),d.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let r=this.children[i],s=n+r.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let i=n+r.border,o=s-r.border;if(e>=i&&t<=o){this.dirty=e==n||t==s?2:1,e==i&&t==o&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=3:r.markDirty(e-i,t-i);return}r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=s}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class et extends ee{constructor(e,t,n,i){let r,s=t.type.toDOM;if("function"==typeof s&&(s=s(n,()=>r?r.parent?r.parent.posBeforeChild(r):void 0:i)),!t.type.spec.raw){if(1!=s.nodeType){let e=document.createElement("span");e.appendChild(s),s=e}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class en extends ee{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class ei extends ee{constructor(e,t,n,i,r){super(e,[],n,i),this.mark=t,this.spec=r}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=r.PW.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new ei(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let i=ei.create(this.parent,this.mark,!0,n),r=this.children,s=this.size;t<s&&(r=eb(r,t,s,n)),e>0&&(r=eb(r,0,e,n));for(let e=0;e<r.length;e++)r[e].parent=i;return i.children=r,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class er extends ee{constructor(e,t,n,i,r,s,o,a,l){super(e,[],r,s),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=o}static create(e,t,n,i,s,o){let a=s.nodeViews[t.type.name],l,d=a&&a(t,s,()=>l?l.parent?l.parent.posBeforeChild(l):void 0:o,n,i),c=d&&d.dom,h=d&&d.contentDOM;if(t.isText){if(c){if(3!=c.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text)}else if(!c){let e=r.PW.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:h}=e)}!h&&!t.isText&&"BR"!=c.nodeName&&(!c.hasAttribute("contenteditable")&&(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return(c=ep(c,n,t),d)?l=new el(e,t,n,i,c,h||null,u,d,s,o+1):t.isText?new eo(e,t,n,i,c,u,s):new er(e,t,n,i,c,h||null,u,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM){if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}!e.contentElement&&(e.getContent=()=>r.HY.empty)}else e.contentElement=this.contentDOM}else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ef(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new eg(this,o&&o.node,e);(function(e,t,n,i){let r=t.locals(e),s=0;if(0==r.length){for(let n=0;n<e.childCount;n++){let o=e.child(n);i(o,r,t.forChild(s,o),n),s+=o.nodeSize}return}let o=0,a=[],l=null;for(let d=0;;){let c,h,u,p;for(;o<r.length&&r[o].to==s;){let e=r[o++];e.widget&&(c?(h||(h=[c])).push(e):c=e)}if(c){if(h){h.sort(ev);for(let e=0;e<h.length;e++)n(h[e],d,!!l)}else n(c,d,!!l)}if(l)p=-1,u=l,l=null;else if(d<e.childCount)p=d,u=e.child(d++);else break;for(let e=0;e<a.length;e++)a[e].to<=s&&a.splice(e--,1);for(;o<r.length&&r[o].from<=s&&r[o].to>s;)a.push(r[o++]);let f=s+u.nodeSize;if(u.isText){let e=f;o<r.length&&r[o].from<e&&(e=r[o].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=u.cut(e-s),u=u.cut(0,e-s),f=e,p=-1)}else for(;o<r.length&&r[o].to<f;)o++;let m=u.isInline&&!u.isLeaf?a.filter(e=>!e.inline):a.slice();i(u,m,t.forChild(s,u),p),s=f}})(this.node,this.innerDeco,(t,s,o)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!o&&l.syncToMarks(s==this.node.childCount?r.vc.none:this.node.child(s).marks,n,e),l.placeWidget(t,e,i)},(t,r,o,d)=>{let c;l.syncToMarks(t.marks,n,e),l.findNodeMatch(t,r,o,d)||a&&e.state.selection.from>i&&e.state.selection.to<i+t.nodeSize&&(c=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(t,r,o,c,e)||l.updateNextNode(t,r,o,e,d,i)||l.addNode(t,r,o,e,i),i+=t.nodeSize}),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(o&&this.protectLocalComposition(e,o),function e(t,n,i){let r=t.firstChild,s=!1;for(let o=0;o<n.length;o++){let a=n[o],l=a.dom;if(l.parentNode==t){for(;l!=r;)r=em(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(a instanceof ei){let n=r?r.previousSibling:t.lastChild;e(a.contentDOM,a.children,i),r=n?n.nextSibling:t.firstChild}}for(;r;)r=em(r),s=!0;s&&i.trackWrites==t&&(i.trackWrites=null)}(this.contentDOM,this.children,e),O&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof i.Bs)||n<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(!this.node.inlineContent)return{node:s,pos:-1,text:""};{let e=s.nodeValue,i=function(e,t,n,i){for(let r=0,s=0;r<e.childCount&&s<=i;){let o=e.child(r++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;r<e.childCount;){let t=e.child(r++);if(s+=t.nodeSize,!t.isText)break;l+=t.text}if(s>=n){if(s>=i&&l.slice(i-t.length-a,i-a)==t)return i-t.length;let e=a<i?l.lastIndexOf(t,i-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==i&&l.length>=i+t.length-a&&l.slice(i-a,i-a+t.length)==t)return i}}return -1}(this.node.content,e,n-t,r-t);return i<0?null:{node:s,pos:i,text:e}}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let s=new en(this,r,t,i);e.input.compositionNodes.push(s),this.children=eb(this.children,n,n+i.length,e,s)}update(e,t,n,i){return!!(3!=this.dirty&&e.sameMarkup(this.node))&&(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(ef(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=eu(this.dom,this.nodeDOM,eh(this.outerDeco,this.node,t),eh(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function es(e,t,n,i,r){ep(i,t,e);let s=new er(void 0,e,t,n,i,i,i,r,0);return s.contentDOM&&s.updateChildren(r,0),s}class eo extends er{constructor(e,t,n,i,r,s,o){super(e,t,n,i,r,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return!!(3!=this.dirty&&(0==this.dirty||this.inParent())&&e.sameMarkup(this.node))&&(this.updateOuterDeco(t),(0!=this.dirty||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let i=this.node.cut(e,t),r=document.createTextNode(i.text);return new eo(this.parent,i,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(0==e||t==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ea extends ee{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class el extends er{constructor(e,t,n,i,r,s,o,a,l,d){super(e,t,n,i,r,s,o,l,d),this.spec=a}update(e,t,n,i){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,i),r}if(!this.contentDOM&&!e.isLeaf)return!1;return super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}let ed=function(e){e&&(this.nodeName=e)};ed.prototype=Object.create(null);let ec=[new ed];function eh(e,t,n){if(0==e.length)return ec;let i=n?ec[0]:new ed,r=[i];for(let s=0;s<e.length;s++){let o=e[s].type.attrs;if(o)for(let e in o.nodeName&&r.push(i=new ed(o.nodeName)),o){let s=o[e];null!=s&&(n&&1==r.length&&r.push(i=new ed(t.isInline?"span":"div")),"class"==e?i.class=(i.class?i.class+" ":"")+s:"style"==e?i.style=(i.style?i.style+";":"")+s:"nodeName"!=e&&(i[e]=s))}}return r}function eu(e,t,n,i){if(n==ec&&i==ec)return t;let r=t;for(let t=0;t<i.length;t++){let s=i[t],o=n[t];if(t){let t;o&&o.nodeName==s.nodeName&&r!=e&&(t=r.parentNode)&&t.nodeName.toLowerCase()==s.nodeName||((t=document.createElement(s.nodeName)).pmIsDeco=!0,t.appendChild(r),o=ec[0]),r=t}(function(e,t,n){for(let i in t)"class"!=i&&"style"!=i&&"nodeName"!=i&&!(i in n)&&e.removeAttribute(i);for(let i in n)"class"!=i&&"style"!=i&&"nodeName"!=i&&n[i]!=t[i]&&e.setAttribute(i,n[i]);if(t.class!=n.class){let i=t.class?t.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.remove(i[t]);for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.add(r[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(t.style);)e.style.removeProperty(i[1])}n.style&&(e.style.cssText+=n.style)}})(r,o||ec[0],s)}return r}function ep(e,t,n){return eu(e,e,ec,eh(t,n,1!=e.nodeType))}function ef(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function em(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class eg{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,i=n.children.length,r=e.childCount,s=new Map,o=[];e:for(;r>0;){let a;for(;;)if(i){let e=n.children[i-1];if(e instanceof ei)n=e,i=e.children.length;else{a=e,i--;break}}else if(n==t)break e;else i=n.parent.children.indexOf(n),n=n.parent;let l=a.node;if(!!l){if(l!=e.child(r-1))break;--r,s.set(a,r),o.push(a)}}return{index:r,matched:s,matches:o.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let i=0,r=this.stack.length>>1,s=Math.min(r,e.length);for(;i<s&&(i==r-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let i=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[r])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let i=ei.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,i),this.top=i,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,n,i){let r=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))r=this.top.children.indexOf(s,this.index);else for(let i=this.index,s=Math.min(this.top.children.length,i+5);i<s;i++){let s=this.top.children[i];if(s.matchesNode(e,t,n)&&!this.preMatch.matched.has(s)){r=i;break}}return!(r<0)&&(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,n,i,r){let s=this.top.children[i];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(e,t,n,r)&&(this.destroyBetween(this.index,i),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return -1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return -1}e=t}}updateNextNode(e,t,n,i,r,s){for(let o=this.index;o<this.top.children.length;o++){let a=this.top.children[o];if(a instanceof er){let l=this.preMatch.matched.get(a);if(null!=l&&l!=r)return!1;let d=a.dom,c,h=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&ef(t,a.outerDeco));if(!h&&a.update(e,t,n,i))return this.destroyBetween(this.index,o),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(a,e,t,n,i,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(i,s+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,r,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ef(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=er.create(this.top,t,n,i,r,s);if(o.contentDOM)for(let t of(o.children=e.children,e.children=[],o.children))t.parent=o;return e.destroy(),o}addNode(e,t,n,i,r){let s=er.create(this.top,e,t,n,i,r);s.contentDOM&&s.updateChildren(i,r+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let i=new et(this.top,e,t,n);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ei;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof eo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((D||T)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let i=new ea(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function ev(e,t){return e.type.side-t.type.side}function eb(e,t,n,i,r){let s=[];for(let o=0,a=0;o<e.length;o++){let l=e[o],d=a,c=a+=l.size;d>=n||c<=t?s.push(l):(d<t&&s.push(l.slice(0,t-d,i)),r&&(s.push(r),r=void 0),c>n&&s.push(l.slice(n-d,l.size,i)))}return s}function ey(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),a=s&&0==s.size,l=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(l<0)return null;let d=r.resolve(l),c,h;if(g(n)){for(c=l;s&&!s.node;)s=s.parent;let e=s.node;if(s&&e.isAtom&&i.qv.isSelectable(e)&&s.parent&&!(e.isInline&&function(e,t,n){for(let i=0==t,r=t==f(e);i||r;){if(e==n)return!0;let t=o(e);if(!(e=e.parentNode))return!1;i=i&&0==t,r=r&&t==f(e)}}(n.focusNode,n.focusOffset,s.dom))){let e=s.posBefore;h=new i.qv(l==e?d:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=l,i=l;for(let r=0;r<n.rangeCount;r++){let s=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(s.startContainer,s.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(t<0)return null;[c,l]=i==e.state.selection.anchor?[i,t]:[t,i],d=r.resolve(l)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!h){let n="pointer"==t||e.state.selection.head<d.pos&&!a?1:-1;h=eT(e,u,d,n)}return h}function ex(e){return e.editable?e.hasFocus():eD(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ew(e,t=!1){let n=e.state.selection;if(eA(e,n),ex(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&T){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&h(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)(function(e){let t=e.domSelection(),n=document.createRange();if(!t)return;let i=e.cursorWrapper.dom,r="IMG"==i.nodeName;r?n.setStart(i.parentNode,o(i)+1):n.setStart(i,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!r&&!e.state.selection.visible&&E&&C<=11&&(i.disabled=!0,i.disabled=!1)})(e);else{let{anchor:r,head:s}=n,o,a;e_&&!(n instanceof i.Bs)&&(!n.$from.parent.inlineContent&&(o=eS(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=eS(e,n.to))),e.docView.setSelection(r,s,e,t),e_&&(o&&eC(o),a&&eC(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),i=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=i||n.anchorOffset!=r)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!ex(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}let e_=D||T&&M<63;function eS(e,t){let{node:n,offset:i}=e.docView.domFromPos(t,0),r=i<n.childNodes.length?n.childNodes[i]:null,s=i?n.childNodes[i-1]:null;if(D&&r&&"false"==r.contentEditable)return eE(r);if((!r||"false"==r.contentEditable)&&(!s||"false"==s.contentEditable)){if(r)return eE(r);if(s)return eE(s)}}function eE(e){return e.contentEditable="true",D&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function eC(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function eA(e,t){if(t instanceof i.qv){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ek(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ek(e)}function ek(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function eT(e,t,n,r){return e.someProp("createSelectionBetween",i=>i(e,t,n))||i.Bs.between(t,n,r)}function eM(e){return(!e.editable||!!e.hasFocus())&&eD(e)}function eD(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function eO(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),o=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return o&&i.Y1.findFrom(o,t)}function eI(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function eN(e,t,n){let r=e.state.selection;if(r instanceof i.Bs){if(n.indexOf("s")>-1){let{$head:n}=r,s=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=e.state.doc.resolve(n.pos+s.nodeSize*(t<0?-1:1));return eI(e,new i.Bs(r.$anchor,o))}if(!r.empty)return!1;else if(e.endOfTextblock(t>0?"forward":"backward")){let n=eO(e.state,t);return!!n&&n instanceof i.qv&&eI(e,n)}else if(!(I&&n.indexOf("m")>-1)){let n=r.$head,s=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,o;if(!s||s.isText)return!1;let a=t<0?n.pos-s.nodeSize:n.pos;return!!(s.isAtom||(o=e.docView.descAt(a))&&!o.contentDOM)&&(i.qv.isSelectable(s)?eI(e,new i.qv(t<0?e.state.doc.resolve(n.pos-s.nodeSize):n)):!!L&&eI(e,new i.Bs(e.state.doc.resolve(t<0?a:a+s.nodeSize))))}}else{if(r instanceof i.qv&&r.node.isInline)return eI(e,new i.Bs(t>0?r.$to:r.$from));let n=eO(e.state,t);return!!n&&eI(e,n)}}function eR(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function eL(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function eP(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;let r,s,a=!1;for(A&&1==n.nodeType&&i<eR(n)&&eL(n.childNodes[i],-1)&&(a=!0);;)if(i>0){if(1!=n.nodeType)break;{let e=n.childNodes[i-1];if(eL(e,-1))r=n,s=--i;else if(3==e.nodeType)i=(n=e).nodeValue.length;else break}}else if(ej(n))break;else{let t=n.previousSibling;for(;t&&eL(t,-1);)r=n.parentNode,s=o(t),t=t.previousSibling;if(t)i=eR(n=t);else{if((n=n.parentNode)==e.dom)break;i=0}}a?eF(e,n,i):r&&eF(e,r,s)}(e):function(e){let t,n,i=e.domSelectionRange(),r=i.focusNode,s=i.focusOffset;if(!r)return;let a=eR(r);for(;;)if(s<a){if(1!=r.nodeType)break;if(eL(r.childNodes[s],1))t=r,n=++s;else break}else if(ej(r))break;else{let i=r.nextSibling;for(;i&&eL(i,1);)t=i.parentNode,n=o(i)+1,i=i.nextSibling;if(i)s=0,a=eR(r=i);else{if((r=r.parentNode)==e.dom)break;s=a=0}}t&&eF(e,t,n)}(e)}function ej(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function eF(e,t,n){if(3!=t.nodeType){let e,i;(i=function(e,t){for(;e&&t==e.childNodes.length&&!m(e);)t=o(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=i,n=0):(e=function(e,t){for(;e&&!t&&!m(e);)t=o(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let i=e.domSelection();if(!i)return;if(g(i)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),i.removeAllRanges(),i.addRange(e)}else i.extend&&i.extend(t,n);e.domObserver.setCurSelection();let{state:r}=e;setTimeout(()=>{e.state==r&&ew(e)},50)}function eB(e,t){let n=e.state.doc.resolve(t);if(!(T||N)&&n.parent.inlineContent){let i=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),r=(n.top+n.bottom)/2;if(r>i.top&&r<i.bottom&&Math.abs(n.left-i.left)>1)return n.left<i.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),r=(n.top+n.bottom)/2;if(r>i.top&&r<i.bottom&&Math.abs(n.left-i.left)>1)return n.left>i.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function ez(e,t,n){let r=e.state.selection;if(r instanceof i.Bs&&!r.empty||n.indexOf("s")>-1||I&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=eO(e.state,t);if(n&&n instanceof i.qv)return eI(e,n)}if(!s.parent.inlineContent){let n=t<0?s:o,a=r instanceof i.C1?i.Y1.near(n,t):i.Y1.findFrom(n,t);return!!a&&eI(e,a)}return!1}function eH(e,t){if(!(e.state.selection instanceof i.Bs))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=e.state.tr;return t<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),e.dispatch(i),!0}return!1}function eU(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function eV(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:i,openStart:s,openEnd:o}=t;for(;s>1&&o>1&&1==i.childCount&&1==i.firstChild.childCount;){s--,o--;let e=i.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),i=e.content}let a=e.someProp("clipboardSerializer")||r.PW.fromSchema(e.state.schema),l=eX(),d=l.createElement("div");d.appendChild(a.serializeFragment(i,{document:l}));let c=d.firstChild,h,u=0;for(;c&&1==c.nodeType&&(h=eK[c.nodeName.toLowerCase()]);){for(let e=h.length-1;e>=0;e--){let t=l.createElement(h[e]);for(;d.firstChild;)t.appendChild(d.firstChild);d.appendChild(t),u++}c=d.firstChild}return c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${s} ${o}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:d,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function e$(e,t,n,i,s){let o,a,l=s.parent.type.spec.code;if(!n&&!t)return null;let d=t&&(i||l||!n);if(d){if(e.someProp("transformPastedText",n=>{t=n(t,l||i,e)}),l)return t?new r.p2(r.HY.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):r.p2.empty;let n=e.someProp("clipboardTextParser",n=>n(t,s,i,e));if(n)a=n;else{let n=s.marks(),{schema:i}=e.state,a=r.PW.fromSchema(i);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement("p"));e&&t.appendChild(a.serializeNode(i.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),o=function(e){var t;let n,i=/^(\s*<meta [^>]*>)*/.exec(e);i&&(e=e.slice(i[0].length));let r=eX().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(e),o;(o=s&&eK[s[1].toLowerCase()])&&(e=o.map(e=>"<"+e+">").join("")+e+o.map(e=>"</"+e+">").reverse().join(""));if(r.innerHTML=(t=e,(n=window.trustedTypes)?(!eJ&&(eJ=n.defaultPolicy||n.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),eJ.createHTML(t)):t),o)for(let e=0;e<o.length;e++)r=r.querySelector(o[e])||r;return r}(n),L&&function(e){let t=e.querySelectorAll(T?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let i=t[n];1==i.childNodes.length&&"\xa0"==i.textContent&&i.parentNode&&i.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),i)}}(o);let c=o&&o.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let e=+h[3];e>0;e--){let e=o.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;o=e}if(!a&&(a=(e.someProp("clipboardParser")||e.someProp("domParser")||r.aw.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(d||h),context:s,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||eW.test(e.parentNode.nodeName)?null:{ignore:!0}})),h)a=function(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,i;try{i=JSON.parse(t)}catch(t){return e}let{content:s,openStart:o,openEnd:a}=e;for(let e=i.length-2;e>=0;e-=2){let t=n.nodes[i[e]];if(!t||t.hasRequiredAttrs())break;s=r.HY.from(t.create(i[e+1],s)),o++,a++}return new r.p2(s,o,a)}(eq(a,+h[1],+h[2]),h[4]);else if((a=r.p2.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let i=t.node(n).contentMatchAt(t.index(n)),s,o=[];if(e.forEach(e=>{if(!o)return;let t=i.findWrapping(e.type),n;if(!t)return o=null;if(n=o.length&&s.length&&function e(t,n,i,s,o){if(o<t.length&&o<n.length&&t[o]==n[o]){let a=e(t,n,i,s.lastChild,o+1);if(a)return s.copy(s.content.replaceChild(s.childCount-1,a));if(s.contentMatchAt(s.childCount).matchType(o==t.length-1?i.type:t[o+1]))return s.copy(s.content.append(r.HY.from(eG(i,t,o+1))))}}(t,s,e,o[o.length-1],0))o[o.length-1]=n;else{o.length&&(o[o.length-1]=function e(t,n){if(0==n)return t;let i=t.content.replaceChild(t.childCount-1,e(t.lastChild,n-1)),s=t.contentMatchAt(t.childCount).fillBefore(r.HY.empty,!0);return t.copy(i.append(s))}(o[o.length-1],s.length));let n=eG(e,t);o.push(n),i=i.matchType(n.type),s=t}}),o)return r.HY.from(o)}return e}(a.content,s),!0)).openStart||a.openEnd){let e=0,t=0;for(let t=a.content.firstChild;e<a.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=a.content.lastChild;t<a.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);a=eq(a,e,t)}return e.someProp("transformPasted",t=>{a=t(a,e)}),a}let eW=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function eG(e,t,n=0){for(let i=t.length-1;i>=n;i--)e=t[i].create(null,r.HY.from(e));return e}function eZ(e,t,n,i,s,o){let a=t<0?e.firstChild:e.lastChild,l=a.content;return e.childCount>1&&(o=0),s<i-1&&(l=eZ(l,t,n,i,s+1,o)),s>=n&&(l=t<0?a.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(r.HY.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(l))}function eq(e,t,n){return t<e.openStart&&(e=new r.p2(eZ(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new r.p2(eZ(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}let eK={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},eY=null;function eX(){return eY||(eY=document.implementation.createHTMLDocument("title"))}let eJ=null,eQ={},e0={},e1={touchstart:!0,touchmove:!0};class e2{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function e5(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function e3(e){e.someProp("handleDOMEvents",t=>{for(let n in t)!e.input.eventHandlers[n]&&e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>e4(e,t))})}function e4(e,t){return e.someProp("handleDOMEvents",n=>{let i=n[t.type];return!!i&&(i(e,t)||t.defaultPrevented)})}function e6(e){return{left:e.clientX,top:e.clientY}}e0.keydown=(e,t)=>{if(e.input.shiftKey=16==t.keyCode||t.shiftKey,!tn(e,t)){if(e.input.lastKeyCode=t.keyCode,e.input.lastKeyCodeTime=Date.now(),!R||!T||13!=t.keyCode){if(229!=t.keyCode&&e.domObserver.forceFlush(),!O||13!=t.keyCode||t.ctrlKey||t.altKey||t.metaKey)e.someProp("handleKeyDown",n=>n(e,t))||function(e,t){var n;let i;let r=t.keyCode,s=(i="",(n=t).ctrlKey&&(i+="c"),n.metaKey&&(i+="m"),n.altKey&&(i+="a"),n.shiftKey&&(i+="s"),i);if(8==r||I&&72==r&&"c"==s)return eH(e,-1)||eP(e,-1);if(46==r&&!t.shiftKey||I&&68==r&&"c"==s)return eH(e,1)||eP(e,1);if(13==r||27==r)return!0;else if(37==r||I&&66==r&&"c"==s){let t=37==r?"ltr"==eB(e,e.state.selection.from)?-1:1:-1;return eN(e,t,s)||eP(e,t)}else if(39==r||I&&70==r&&"c"==s){let t=39==r?"ltr"==eB(e,e.state.selection.from)?1:-1:1;return eN(e,t,s)||eP(e,t)}else if(38==r||I&&80==r&&"c"==s)return ez(e,-1,s)||eP(e,-1);else if(40==r||I&&78==r&&"c"==s)return function(e){if(!D||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;eU(e,n,"true"),setTimeout(()=>eU(e,n,"false"),20)}return!1}(e)||ez(e,1,s)||eP(e,1);else if(s==(I?"m":"c")&&(66==r||73==r||89==r||90==r))return!0;return!1}(e,t)?t.preventDefault():e5(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,v(13,"Enter"))),e.input.lastIOSEnter=0)},200)}}}},e0.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},e0.keypress=(e,t)=>{if(tn(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||I&&t.metaKey)return;if(e.someProp("handleKeyPress",n=>n(e,t))){t.preventDefault();return}let n=e.state.selection;if(!(n instanceof i.Bs)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),r=()=>e.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!e.someProp("handleTextInput",t=>t(e,n.$from.pos,n.$to.pos,i,r))&&e.dispatch(r()),t.preventDefault()}};function e8(e,t,n,i,r){if(-1==i)return!1;let s=e.state.doc.resolve(i);for(let i=s.depth+1;i>0;i--)if(e.someProp(t,t=>i>s.depth?t(e,n,s.nodeAfter,s.before(i),r,!0):t(e,n,s.node(i),s.before(i),r,!1)))return!0;return!1}function e7(e,t,n){if(!e.focused&&e.focus(),e.state.selection.eq(t))return;let i=e.state.tr.setSelection(t);"pointer"==n&&i.setMeta("pointer",!0),e.dispatch(i)}function e9(e){return to(e)}let te=I?"metaKey":"ctrlKey";eQ.mousedown=(e,t)=>{var n,r;let s,o;e.input.shiftKey=t.shiftKey;let a=to(e),l=Date.now(),d="singleClick";if(l-e.input.lastClick.time<500&&(n=t,s=(r=e.input.lastClick).x-n.clientX,s*s+(o=r.y-n.clientY)*o<100)&&!t[te]&&e.input.lastClick.button==t.button)"singleClick"==e.input.lastClick.type?d="doubleClick":"doubleClick"==e.input.lastClick.type&&(d="tripleClick");e.input.lastClick={time:l,x:t.clientX,y:t.clientY,type:d,button:t.button};let c=e.posAtCoords(e6(t));c&&("singleClick"==d?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new tt(e,c,t,!!a)):("doubleClick"==d?function(e,t,n,i){return e8(e,"handleDoubleClickOn",t,n,i)||e.someProp("handleDoubleClick",n=>n(e,t,i))}:function(e,t,n,r){return e8(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(e7(e,i.Bs.create(r,0,r.content.size),"pointer"),!0);let s=r.resolve(t);for(let t=s.depth+1;t>0;t--){let n=t>s.depth?s.nodeAfter:s.node(t),o=s.before(t);if(n.inlineContent)e7(e,i.Bs.create(r,o+1,o+1+n.content.size),"pointer");else{if(!i.qv.isSelectable(n))continue;e7(e,i.qv.create(r,o),"pointer")}return!0}}(e,n,r)})(e,c.pos,c.inside,t)?t.preventDefault():e5(e,"pointer"))};class tt{constructor(e,t,n,r){let s,o;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[te],this.allowDefault=n.shiftKey,t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let n=e.state.doc.resolve(t.pos);s=n.parent,o=n.depth?n.before():0}let a=r?null:n.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:d}=e.state;(0==n.button&&s.type.spec.draggable&&!1!==s.type.spec.selectable||d instanceof i.qv&&d.from<=o&&d.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&A&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),e5(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ew(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;if(this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(e6(e))),this.updateAllowDefault(e),this.allowDefault||!t)e5(this.view,"pointer");else{var n,r,s,o,a;if(n=this.view,r=t.pos,s=t.inside,o=e,a=this.selectNode,e8(n,"handleClickOn",r,s,o)||n.someProp("handleClick",e=>e(n,r,o))||(a?function(e,t){if(-1==t)return!1;let n=e.state.selection,r,s;n instanceof i.qv&&(r=n.node);let o=e.state.doc.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e);if(i.qv.isSelectable(t)){s=r&&n.$from.depth>0&&e>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?o.before(n.$from.depth):o.before(e);break}}return null!=s&&(e7(e,i.qv.create(e.state.doc,s),"pointer"),!0)}(n,s):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&i.qv.isSelectable(r))&&(e7(e,new i.qv(n),"pointer"),!0)}(n,s)))e.preventDefault();else 0==e.button&&(this.flushed||D&&this.mightDrag&&!this.mightDrag.node.isAtom||T&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to)))?(e7(this.view,i.Y1.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):e5(this.view,"pointer")}}move(e){this.updateAllowDefault(e),e5(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function tn(e,t){return!!e.composing||!!(D&&500>Math.abs(t.timeStamp-e.input.compositionEndedAt))&&(e.input.compositionEndedAt=-2e8,!0)}eQ.touchstart=e=>{e.input.lastTouch=Date.now(),to(e),e5(e,"pointer")},eQ.touchmove=e=>{e.input.lastTouch=Date.now(),e5(e,"pointer")},eQ.contextmenu=e=>to(e);let ti=R?5e3:-1;function tr(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>to(e),t))}function ts(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}e0.compositionstart=e0.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof i.Bs&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)))e.markCursor=e.state.storedMarks||n.marks(),to(e,!0),e.markCursor=null;else if(to(e,!t.selection.empty),A&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,i=t.focusOffset;n&&1==n.nodeType&&0!=i;){let t=i<0?n.lastChild:n.childNodes[i-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,i=-1}}e.input.composing=!0}tr(e,ti)},e0.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,tr(e,20))};function to(e,t=!1){if(!R||!(e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ts(e),t||e.docView&&e.docView.dirty){let n=ey(e),i=e.state.selection;return n&&!n.eq(i)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}let ta=E&&C<15||O&&P<604;eQ.copy=e0.cut=(e,t)=>{let n=e.state.selection,i="cut"==t.type;if(n.empty)return;let r=ta?null:t.clipboardData,{dom:s,text:o}=eV(e,n.content());r?(t.preventDefault(),r.clearData(),r.setData("text/html",s.innerHTML),r.setData("text/plain",o)):!function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,s),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function tl(e,t,n,i,s){var o;let a=e$(e,t,n,i,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,s,a||r.p2.empty)))return!0;if(!a)return!1;let l=0==(o=a).openStart&&0==o.openEnd&&1==o.content.childCount?o.content.firstChild:null,d=l?e.state.tr.replaceSelectionWith(l,i):e.state.tr.replaceSelection(a);return e.dispatch(d.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function td(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}e0.paste=(e,t)=>{if(e.composing&&!R)return;let n=ta?null:t.clipboardData,i=e.input.shiftKey&&45!=e.input.lastKeyCode;n&&tl(e,td(n),n.getData("text/html"),i,t)?t.preventDefault():!function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,i=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));!n&&(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),i.parentNode&&i.parentNode.removeChild(i),n?tl(e,i.value,null,r,t):tl(e,i.textContent,i.innerHTML,r,t)},50)}(e,t)};class tc{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}let th=I?"altKey":"ctrlKey";function tu(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[th]}for(let e in eQ.dragstart=(e,t)=>{let n;let r=e.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=e.state.selection,o=s.empty?null:e.posAtCoords(e6(t));if(o&&o.pos>=s.from&&o.pos<=(s instanceof i.qv?s.to-1:s.to));else if(r&&r.mightDrag)n=i.qv.create(e.state.doc,r.mightDrag.pos);else if(t.target&&1==t.target.nodeType){let r=e.docView.nearestDesc(t.target,!0);r&&r.node.type.spec.draggable&&r!=e.docView&&(n=i.qv.create(e.state.doc,r.posBefore))}let a=(n||e.state.selection).content(),{dom:l,text:d,slice:c}=eV(e,a);(!t.dataTransfer.files.length||!T||M>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ta?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",!ta&&t.dataTransfer.setData("text/plain",d),e.dragging=new tc(c,tu(e,t),n)},eQ.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},e0.dragover=e0.dragenter=(e,t)=>t.preventDefault(),e0.drop=(e,t)=>{let n=e.dragging;if(e.dragging=null,!t.dataTransfer)return;let o=e.posAtCoords(e6(t));if(!o)return;let a=e.state.doc.resolve(o.pos),l=n&&n.slice;l?e.someProp("transformPasted",t=>{l=t(l,e)}):l=e$(e,td(t.dataTransfer),ta?null:t.dataTransfer.getData("text/html"),!1,a);let d=!!(n&&tu(e,t));if(e.someProp("handleDrop",n=>n(e,t,l||r.p2.empty,d))){t.preventDefault();return}if(!l)return;t.preventDefault();let c=l?(0,s.nj)(e.state.doc,a.pos,l):a.pos;null==c&&(c=a.pos);let h=e.state.tr;if(d){let{node:e}=n;e?e.replace(h):h.deleteSelection()}let u=h.mapping.map(c),p=0==l.openStart&&0==l.openEnd&&1==l.content.childCount,f=h.doc;if(p?h.replaceRangeWith(u,u,l.content.firstChild):h.replaceRange(u,u,l),h.doc.eq(f))return;let m=h.doc.resolve(u);if(p&&i.qv.isSelectable(l.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(l.content.firstChild))h.setSelection(new i.qv(m));else{let t=h.mapping.map(c);h.mapping.maps[h.mapping.maps.length-1].forEach((e,n,i,r)=>t=r),h.setSelection(eT(e,m,h.doc.resolve(t)))}e.focus(),e.dispatch(h.setMeta("uiEvent","drop"))},eQ.focus=e=>{e.input.lastFocus=Date.now(),!e.focused&&(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ew(e)},20))},eQ.blur=(e,t)=>{e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),t.relatedTarget&&e.dom.contains(t.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},eQ.beforeinput=(e,t)=>{if(T&&R&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,v(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}},e0)eQ[e]=e0[e];function tp(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class tf{constructor(e,t){this.toDOM=e,this.spec=t||ty,this.side=this.spec.side||0}map(e,t,n,i){let{pos:r,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new tv(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof tf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&tp(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class tm{constructor(e,t){this.attrs=e,this.spec=t||ty}map(e,t,n,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return r>=s?null:new tv(r,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof tm&&tp(this.attrs,e.attrs)&&tp(this.spec,e.spec)}static is(e){return e.type instanceof tm}destroy(){}}class tg{constructor(e,t){this.attrs=e,this.spec=t||ty}map(e,t,n,i){let r=e.mapResult(t.from+i,1);if(r.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=r.pos?null:new tv(r.pos-n,s.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),r;return i==t.from&&!(r=e.child(n)).isText&&i+r.nodeSize==t.to}eq(e){return this==e||e instanceof tg&&tp(this.attrs,e.attrs)&&tp(this.spec,e.spec)}destroy(){}}class tv{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new tv(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new tv(e,e,new tf(t,n))}static inline(e,t,n,i){return new tv(e,t,new tm(n,i))}static node(e,t,n,i){return new tv(e,t,new tg(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof tm}get widget(){return this.type instanceof tf}}let tb=[],ty={};class tx{constructor(e,t){this.local=e.length?e:tb,this.children=t.length?t:tb}static create(e,t){return t.length?tA(t,e,0,ty):tw}find(e,t,n){let i=[];return this.findInner(null==e?0:e,null==t?1e9:t,i,0,n),i}findInner(e,t,n,i,r){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=t&&o.to>=e&&(!r||r(o.spec))&&n.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,t-o,n,i+o,r)}}map(e,t,n){return this==tw||0==e.maps.length?this:this.mapInner(e,t,0,0,n||ty)}mapInner(e,t,n,i,r){let s;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(e,n,i);a&&a.type.valid(t,a)?(s||(s=[])).push(a):r.onRemove&&r.onRemove(this.local[o].spec)}return this.children.length?function(e,t,n,i,r,s,o){let a=e.slice();for(let e=0,t=s;e<n.maps.length;e++){let i=0;n.maps[e].forEach((e,n,r,s)=>{let o=s-r-(n-e);for(let r=0;r<a.length;r+=3){let s=a[r+1];if(s<0||e>s+t-i)continue;let l=a[r]+t-i;n>=l?a[r+1]=e<=l?-2:-1:e>=t&&o&&(a[r]+=o,a[r+1]+=o)}i+=o}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let d=n.map(e[t]+s),c=d-r;if(c<0||c>=i.content.size){l=!0;continue}let h=n.map(e[t+1]+s,-1)-r,{index:u,offset:p}=i.content.findIndex(c),f=i.maybeChild(u);if(f&&p==c&&p+f.nodeSize==h){let i=a[t+2].mapInner(n,f,d+1,e[t]+s+1,o);i!=tw?(a[t]=c,a[t+1]=h,a[t+2]=i):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=tA(function(e,t,n,i,r,s,o){for(let a=0;a<e.length;a+=3)-1==e[a+1]&&!function e(t,s){for(let e=0;e<t.local.length;e++){let a=t.local[e].map(i,r,s);a?n.push(a):o.onRemove&&o.onRemove(t.local[e].spec)}for(let n=0;n<t.children.length;n+=3)e(t.children[n+2],t.children[n]+s+1)}(e[a+2],t[a]+s+1);return n}(a,e,t,n,r,s,o),i,0,o);t=l.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<l.children.length;e+=3){let n=l.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,l.children[e],l.children[e+1],l.children[e+2])}}return new tx(t.sort(tk),a)}(this.children,s||[],e,t,n,i,r):s?new tx(s.sort(tk),tb):tw}add(e,t){return t.length?this==tw?tx.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,r=0;e.forEach((e,s)=>{let o=s+n,a;if(a=tE(t,e,o)){for(!i&&(i=this.children.slice());r<i.length&&i[r]<s;)r+=3;i[r]==s?i[r+2]=i[r+2].addInner(e,a,o+1):i.splice(r,0,s,s+e.nodeSize,tA(a,e,o+1,ty)),r+=3}});let s=tS(r?tC(t):t,-n);for(let t=0;t<s.length;t++)!s[t].type.valid(e,s[t])&&s.splice(t--,1);return new tx(s.length?this.local.concat(s).sort(tk):this.local,i||this.children)}remove(e){return 0==e.length||this==tw?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let i=0;i<n.length;i+=3){let r;let s=n[i]+t,o=n[i+1]+t;for(let t=0,n;t<e.length;t++)(n=e[t])&&n.from>s&&n.to<o&&(e[t]=null,(r||(r=[])).push(n));if(!r)continue;n==this.children&&(n=this.children.slice());let a=n[i+2].removeInner(r,s+1);a!=tw?n[i+2]=a:(n.splice(i,3),i-=3)}if(i.length){for(let n=0,r;n<e.length;n++)if(r=e[n])for(let e=0;e<i.length;e++)i[e].eq(r,t)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new tx(i,n):tw}forChild(e,t){let n,i;if(this==tw)return this;if(t.isLeaf)return tx.empty;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,s=r+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<s&&t.to>r&&t.type instanceof tm){let e=Math.max(r,t.from)-r,n=Math.min(s,t.to)-r;e<n&&(i||(i=[])).push(t.copy(e,n))}}if(i){let e=new tx(i.sort(tk),tb);return n?new t_([e,n]):e}return n||tw}eq(e){if(this==e)return!0;if(!(e instanceof tx)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return tT(this.localsInner(e))}localsInner(e){if(this==tw)return tb;if(e.inlineContent||!this.local.some(tm.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)!(this.local[e].type instanceof tm)&&t.push(this.local[e]);return t}forEachSet(e){e(this)}}tx.empty=new tx([],[]),tx.removeOverlap=tT;let tw=tx.empty;class t_{constructor(e){this.members=e}map(e,t){let n=this.members.map(n=>n.map(e,t,ty));return t_.from(n)}forChild(e,t){if(t.isLeaf)return tx.empty;let n=[];for(let i=0;i<this.members.length;i++){let r=this.members[i].forChild(e,t);r!=tw&&(r instanceof t_?n=n.concat(r.members):n.push(r))}return t_.from(n)}eq(e){if(!(e instanceof t_)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let r=this.members[i].localsInner(e);if(r.length){if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<r.length;e++)t.push(r[e])}else t=r}}return t?tT(n?t:t.sort(tk)):tb}static from(e){switch(e.length){case 0:return tw;case 1:return e[0];default:return new t_(e.every(e=>e instanceof tx)?e:e.reduce((e,t)=>e.concat(t instanceof tx?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function tS(e,t){if(!t||!e.length)return e;let n=[];for(let i=0;i<e.length;i++){let r=e[i];n.push(new tv(r.from+t,r.to+t,r.type))}return n}function tE(e,t,n){if(t.isLeaf)return null;let i=n+t.nodeSize,r=null;for(let t=0,s;t<e.length;t++)(s=e[t])&&s.from>n&&s.to<i&&((r||(r=[])).push(s),e[t]=null);return r}function tC(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function tA(e,t,n,i){let r=[],s=!1;t.forEach((t,o)=>{let a=tE(e,t,o+n);if(a){s=!0;let e=tA(a,t,n+o+1,i);e!=tw&&r.push(o,o+t.nodeSize,e)}});let o=tS(s?tC(e):e,-n).sort(tk);for(let e=0;e<o.length;e++)!o[e].type.valid(t,o[e])&&(i.onRemove&&i.onRemove(o[e].spec),o.splice(e--,1));return o.length||r.length?new tx(o,r):tw}function tk(e,t){return e.from-t.from||e.to-t.to}function tT(e){let t=e;for(let n=0;n<t.length-1;n++){let i=t[n];if(i.from!=i.to)for(let r=n+1;r<t.length;r++){let s=t[r];if(s.from==i.from){s.to!=i.to&&(t==e&&(t=e.slice()),t[r]=s.copy(s.from,i.to),tM(t,r+1,s.copy(i.to,s.to)));continue}s.from<i.to&&(t==e&&(t=e.slice()),t[n]=i.copy(i.from,s.from),tM(t,r,i.copy(s.from,i.to)));break}}return t}function tM(e,t,n){for(;t<e.length&&tk(n,e[t])>0;)t++;e.splice(t,0,n)}function tD(e){let t=[];return e.someProp("decorations",n=>{let i=n(e.state);i&&i!=tw&&t.push(i)}),e.cursorWrapper&&t.push(tx.create(e.state.doc,[e.cursorWrapper.deco])),t_.from(t)}let tO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},tI=E&&C<=11;class tN{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class tR{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new tN,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);E&&C<=11&&e.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),tI&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,tO)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(eM(this.view)){if(this.suppressingSelectionUpdates)return ew(this.view);if(E&&C<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&h(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=a(n))t.add(n);for(let i=e.anchorNode;i;i=a(i))if(t.has(i)){n=i;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:3==n.nodeType?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&eM(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,a=!1,l=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],l);n&&(s=s<0?n.from:Math.min(n.from,s),o=o<0?n.to:Math.max(n.to,o),n.typeOver&&(a=!0))}if(A&&l.length){let t=l.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let i of t){let t=i.parentNode;t&&"LI"==t.nodeName&&(!n||function(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}(e,n)!=t)&&i.remove()}}}let d=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&g(n)&&(d=ey(e))&&d.eq(i.Y1.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ew(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,o),function(e){if(!tL.has(e)&&(tL.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=A,!tP)console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),tP=!0}}(e)),this.handleDOMChange(s,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):!this.currentSelection.eq(n)&&ew(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let i=e.addedNodes[n];t.push(i),3==i.nodeType&&(this.lastChangedTextNode=i)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,r=e.nextSibling;if(E&&C<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:s}=e.addedNodes[t];(!n||0>Array.prototype.indexOf.call(e.addedNodes,n))&&(i=n),(!s||0>Array.prototype.indexOf.call(e.addedNodes,s))&&(r=s)}let s=i&&i.parentNode==e.target?o(i)+1:0,a=n.localPosFromDOM(e.target,s,-1),l=r&&r.parentNode==e.target?o(r):e.target.childNodes.length;return{from:a,to:n.localPosFromDOM(e.target,l,1)}}if("attributes"==e.type)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let tL=new WeakMap,tP=!1;function tj(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,s=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return h(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}function tF(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(D&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||D&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}let tB=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function tz(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:eT(e,t.resolve(n.anchor),t.resolve(n.head))}function tH(e,t,n){let i=e.depth,r=t?e.end():e.pos;for(;i>0&&(t||e.indexAfter(i)==e.node(i).childCount);)i--,r++,t=!1;if(n){let t=e.node(i).maybeChild(e.indexAfter(i));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}function tU(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class tV{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new e2,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(tq),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=tG(this),tW(this),this.nodeViews=tZ(this),this.docView=es(this.state.doc,t$(this),tD(this),this.dom,this),this.domObserver=new tR(this,(e,t,n,s)=>(function(e,t,n,s,o){let a,l,d,c,h=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ey(e,t);if(n&&!e.state.selection.eq(n)){if(T&&R&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,v(13,"Enter"))))return;let i=e.state.tr.setSelection(n);"pointer"==t?i.setMeta("pointer",!0):"key"==t&&i.scrollIntoView(),h&&i.setMeta("composition",h),e.dispatch(i)}return}let u=e.state.doc.resolve(t),p=u.sharedDepth(n);t=u.before(p+1),n=e.state.doc.resolve(n).after(p+1);let f=e.state.selection,m=function(e,t,n){let i,{node:s,fromOffset:o,toOffset:a,from:l,to:d}=e.docView.parseRange(t,n),c=e.domSelectionRange(),h=c.anchorNode;if(h&&e.dom.contains(1==h.nodeType?h:h.parentNode)&&(i=[{node:h,offset:c.anchorOffset}],!g(c)&&i.push({node:c.focusNode,offset:c.focusOffset})),T&&8===e.input.lastKeyCode)for(let e=a;e>o;e--){let t=s.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){a=e;break}if(!n||n.size)break}let u=e.state.doc,p=e.someProp("domParser")||r.aw.fromSchema(e.state.schema),f=u.resolve(l),m=null,v=p.parse(s,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:a,preserveWhitespace:"pre"!=f.parent.type.whitespace||"full",findPositions:i,ruleFromNode:tF,context:f});if(i&&null!=i[0].pos){let e=i[0].pos,t=i[1]&&i[1].pos;null==t&&(t=e),m={anchor:e+l,head:t+l}}return{doc:v,sel:m,from:l,to:d}}(e,t,n),b=e.state.doc,y=b.slice(m.from,m.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(a=e.state.selection.to,l="end"):(a=e.state.selection.from,l="start"),e.input.lastKeyCode=null;let x=function(e,t,n,i,r){let s=e.findDiffStart(t,n);if(null==s)return null;let{a:o,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==r){let e=Math.max(0,s-Math.min(o,a));i-=o+e-s}if(o<s&&e.size<t.size){let e=i<=s&&i>=o?s-i:0;(s-=e)&&s<t.size&&tU(t.textBetween(s-1,s+1))&&(s+=e?1:-1),a=s+(a-o),o=s}else if(a<s){let t=i<=s&&i>=a?s-i:0;(s-=t)&&s<e.size&&tU(e.textBetween(s-1,s+1))&&(s+=t?1:-1),o=s+(o-a),a=s}return{start:s,endA:o,endB:a}}(y.content,m.doc.content,m.from,a,l);if(x&&e.input.domChangeCount++,(O&&e.input.lastIOSEnter>Date.now()-225||R)&&o.some(e=>1==e.nodeType&&!tB.test(e.nodeName))&&(!x||x.endA>=x.endB)&&e.someProp("handleKeyDown",t=>t(e,v(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!x){if(s&&f instanceof i.Bs&&!f.empty&&f.$head.sameParent(f.$anchor)&&!e.composing&&!(m.sel&&m.sel.anchor!=m.sel.head))x={start:f.from,endA:f.to,endB:f.to};else{if(m.sel){let t=tz(e,e.state.doc,m.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);h&&n.setMeta("composition",h),e.dispatch(n)}}return}}e.state.selection.from<e.state.selection.to&&x.start==x.endB&&e.state.selection instanceof i.Bs&&(x.start>e.state.selection.from&&x.start<=e.state.selection.from+2&&e.state.selection.from>=m.from?x.start=e.state.selection.from:x.endA<e.state.selection.to&&x.endA>=e.state.selection.to-2&&e.state.selection.to<=m.to&&(x.endB+=e.state.selection.to-x.endA,x.endA=e.state.selection.to)),E&&C<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>m.from&&" \xa0"==m.doc.textBetween(x.start-m.from-1,x.start-m.from+1)&&(x.start--,x.endA--,x.endB--);let w=m.doc.resolveNoCache(x.start-m.from),_=m.doc.resolveNoCache(x.endB-m.from),S=b.resolve(x.start),A=w.sameParent(_)&&w.parent.inlineContent&&S.end()>=x.endA;if((O&&e.input.lastIOSEnter>Date.now()-225&&(!A||o.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!A&&w.pos<m.doc.content.size&&(!w.sameParent(_)||!w.parent.inlineContent)&&!/\S/.test(m.doc.textBetween(w.pos,_.pos,"",""))&&(d=i.Y1.findFrom(m.doc.resolve(w.pos+1),1,!0))&&d.head>w.pos)&&e.someProp("handleKeyDown",t=>t(e,v(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>x.start&&function(e,t,n,i,r){if(n-t<=r.pos-i.pos||tH(i,!0,!1)<r.pos)return!1;let s=e.resolve(t);if(!i.parent.isTextblock){let e=s.nodeAfter;return null!=e&&n==t+e.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=e.resolve(tH(s,!0,!0));return!(!o.parent.isTextblock||o.pos>n||tH(o,!0,!1)<n)&&i.parent.content.cut(i.parentOffset).eq(o.parent.content)}(b,x.start,x.endA,w,_)&&e.someProp("handleKeyDown",t=>t(e,v(8,"Backspace")))){R&&T&&e.domObserver.suppressSelectionUpdates();return}T&&x.endB==x.start&&(e.input.lastChromeDelete=Date.now()),R&&!A&&w.start()!=_.start()&&0==_.parentOffset&&w.depth==_.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==x.endA&&(x.endB-=2,_=m.doc.resolveNoCache(x.endB-m.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,v(13,"Enter"))})},20));let k=x.start,M=x.endA,D=t=>{let n=t||e.state.tr.replace(k,M,m.doc.slice(x.start-m.from,x.endB-m.from));if(m.sel){let t=tz(e,n.doc,m.sel);t&&!(T&&e.composing&&t.empty&&(x.start!=x.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==k||t.head==n.mapping.map(M)-1)||E&&t.empty&&t.head==k)&&n.setSelection(t)}return h&&n.setMeta("composition",h),n.scrollIntoView()};if(A){if(w.pos==_.pos){E&&C<=11&&0==w.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>ew(e),20));let t=D(e.state.tr.delete(k,M)),n=b.resolve(x.start).marksAcross(b.resolve(x.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(x.endA==x.endB&&(c=function(e,t){let n=e.firstChild.marks,i=t.firstChild.marks,s=n,o=i,a,l,d;for(let e=0;e<i.length;e++)s=i[e].removeFromSet(s);for(let e=0;e<n.length;e++)o=n[e].removeFromSet(o);if(1==s.length&&0==o.length)l=s[0],a="add",d=e=>e.mark(l.addToSet(e.marks));else{if(0!=s.length||1!=o.length)return null;l=o[0],a="remove",d=e=>e.mark(l.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(d(t.child(e)));if(r.HY.from(c).eq(e))return{mark:l,type:a}}(w.parent.content.cut(w.parentOffset,_.parentOffset),S.parent.content.cut(S.parentOffset,x.endA-S.start())))){let t=D(e.state.tr);"add"==c.type?t.addMark(k,M,c.mark):t.removeMark(k,M,c.mark),e.dispatch(t)}else if(w.parent.child(w.index()).isText&&w.index()==_.index()-(_.textOffset?0:1)){let t=w.parent.textBetween(w.parentOffset,_.parentOffset),n=()=>D(e.state.tr.insertText(t,k,M));!e.someProp("handleTextInput",i=>i(e,k,M,t,n))&&e.dispatch(n())}}else e.dispatch(D())})(this,e,t,n,s)),this.domObserver.start(),!function(e){for(let t in eQ){let n=eQ[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0})(e,t)&&!e4(e,t)&&(e.editable||!(t.type in e0))&&n(e,t)},e1[t]?{passive:!0}:void 0)}D&&e.dom.addEventListener("input",()=>null),e3(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;for(let t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&e3(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(tq),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];for(let n in t.state=this.state,e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n,i;let r=this.state,s=!1,a=!1;e.storedMarks&&this.composing&&(ts(this),a=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=tZ(this);(function(e,t){let n=0,i=0;for(let i in e){if(e[i]!=t[i])return!0;n++}for(let e in t)i++;return n!=i})(e,this.nodeViews)&&(this.nodeViews=e,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&e3(this),this.editable=tG(this),tW(this);let d=tD(this),c=t$(this),u=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",p=s||!this.docView.matchesNode(e.doc,c,d);(p||!e.selection.eq(r.selection))&&(a=!0);let g="preserve"==u&&a&&null==this.dom.style.overflowAnchor&&function(e){let t,n,i=e.dom.getBoundingClientRect(),r=Math.max(0,i.top);for(let s=(i.left+i.right)/2,o=r+1;o<Math.min(innerHeight,i.bottom);o+=5){let i=e.root.elementFromPoint(s,o);if(!i||i==e.dom||!e.dom.contains(i))continue;let a=i.getBoundingClientRect();if(a.top>=r-20){t=i,n=a.top;break}}return{refDOM:t,refTop:n,stack:B(e.dom)}}(this);if(a){;let t,n;this.domObserver.stop();let a=p&&(E||T)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(p){let t=T?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=f(e=e.childNodes[t-1])}else{if(!e.parentNode||m(e))return null;t=o(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),i=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||m(e))return null;t=o(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&i&&n!=i){let t=i.pmViewDesc,r=e.domObserver.lastChangedTextNode;if(n==r||i==r)return r;if(!t||!t.isText(i.nodeValue))return i;if(e.input.compositionNode==i){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return i}}return n||i}(this)),(s||!this.docView.update(e.doc,c,d,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=es(e.doc,c,d,this.dom,this)),t&&!this.trackWrites&&(a=!0)}if(a||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(i=this,t=i.docView.domFromPos(i.state.selection.anchor,0),n=i.domSelectionRange(),h(t.node,t.offset,n.anchorNode,n.anchorOffset))))ew(this,a);else eA(this,e.selection),this.domObserver.setCurSelection();this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==u?this.dom.scrollTop=0:"to selection"==u?this.scrollToSelection():g&&!function({refDOM:e,refTop:t,stack:n}){let i=e?e.getBoundingClientRect().top:0;z(n,0==i?0:i-t)}(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode)){if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof i.qv){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&F(this,t.getBoundingClientRect(),e)}else F(this,this.coordsAtPos(this.state.selection.head,1),e)}else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new tc(e.slice,e.move,r<0?void 0:i.qv.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],i;if(null!=n&&(i=t?t(n):n))return i;for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n].props[e];if(null!=r&&(i=t?t(r):r))return i}let r=this.state.plugins;if(r)for(let n=0;n<r.length;n++){let s=r[n].props[e];if(null!=s&&(i=t?t(s):s))return i}}hasFocus(){if(E){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&!function(e){if(e.setActive)return e.setActive();if(H)return e.focus(H);let t=B(e);e.focus(null==H?{get preventScroll(){return H={preventScroll:!0},!0}}:void 0),!H&&(H=!1,z(t,0))}(this.dom),ew(this),this.domObserver.start()}get root(){let e=this._root;if(null==e){for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return!e.getSelection&&(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return function(e,t){var n,i;let r,s,o=e.dom.ownerDocument,l,c=0,h=function(e,t,n){if(e.caretPositionFromPoint)try{let i=e.caretPositionFromPoint(t,n);if(i)return{node:i.offsetNode,offset:Math.min(f(i.offsetNode),i.offset)}}catch(e){}if(e.caretRangeFromPoint){let i=e.caretRangeFromPoint(t,n);if(i)return{node:i.startContainer,offset:Math.min(f(i.startContainer),i.startOffset)}}}(o,t.left,t.top);h&&({node:l,offset:c}=h);let u=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!u||!e.dom.contains(1!=u.nodeType?u.parentNode:u)){let n=e.dom.getBoundingClientRect();if(!U(t,n)||!(u=function e(t,n,i){let r=t.childNodes.length;if(r&&i.top<i.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(n.top-i.top)/(i.bottom-i.top))-2)),o=s;;){let i=t.childNodes[o];if(1==i.nodeType){let t=i.getClientRects();for(let r=0;r<t.length;r++){let s=t[r];if(U(n,s))return e(i,n,s)}}if((o=(o+1)%r)==s)break}return t}(e.dom,t,n)))return null}if(D)for(let e=u;l&&e;e=a(e))e.draggable&&(l=void 0);if(n=u,i=t,u=(r=n.parentNode)&&/^li$/i.test(r.nodeName)&&i.left<n.getBoundingClientRect().left?r:n,l){let n;if(A&&1==l.nodeType&&(c=Math.min(c,l.childNodes.length))<l.childNodes.length){let e=l.childNodes[c],n;"IMG"==e.nodeName&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&c++}L&&c&&1==l.nodeType&&1==(n=l.childNodes[c-1]).nodeType&&"false"==n.contentEditable&&n.getBoundingClientRect().top>=t.top&&c--,l==e.dom&&c==l.childNodes.length-1&&1==l.lastChild.nodeType&&t.top>l.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(0==c||1!=l.nodeType||"BR"!=l.childNodes[c-1].nodeName)&&(s=function(e,t,n,i){let r=-1;for(let n=t,s=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(1==t.dom.nodeType&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&(!s&&o.left>i.left||o.top>i.top?r=t.posBefore:(!s&&o.right<i.left||o.bottom<i.top)&&(r=t.posAfter),s=!0),!t.contentDOM&&r<0&&!t.node.isText))return(t.node.isBlock?i.top<(o.top+o.bottom)/2:i.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,-1)}(e,l,c,t))}null==s&&(s=function(e,t,n){let{node:i,offset:r}=function e(t,n){let i,r,s,o=2e8,a,l=0,c=n.top,h=n.top;for(let e=t.firstChild,u=0;e;e=e.nextSibling,u++){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=d(e).getClientRects()}for(let d=0;d<t.length;d++){let p=t[d];if(p.top<=c&&p.bottom>=h){c=Math.max(p.bottom,c),h=Math.min(p.top,h);let t=p.left>n.left?p.left-n.left:p.right<n.left?n.left-p.right:0;if(t<o){s=e,o=t,a=t&&3==s.nodeType?{left:p.right<n.left?p.right:p.left,top:n.top}:n,1==e.nodeType&&t&&(l=u+(n.left>=(p.left+p.right)/2?1:0));continue}}else p.top>n.top&&!i&&p.left<=n.left&&p.right>=n.left&&(i=e,r={left:Math.max(p.left,Math.min(p.right,n.left)),top:p.top});!s&&(n.left>=p.right&&n.top>=p.top||n.left>=p.left&&n.top>=p.bottom)&&(l=u+1)}}return(!s&&i&&(s=i,a=r,o=0),s&&3==s.nodeType)?function(e,t){let n=e.nodeValue.length,i=document.createRange();for(let r=0;r<n;r++){i.setEnd(e,r+1),i.setStart(e,r);let n=$(i,1);if(n.top!=n.bottom&&U(t,n))return{node:e,offset:r+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(s,a):!s||o&&1==s.nodeType?{node:t,offset:l}:e(s,a)}(t,n),s=-1;if(1==i.nodeType&&!i.firstChild){let e=i.getBoundingClientRect();s=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(i,r,s)}(e,u,t));let p=e.docView.nearestDesc(u,!0);return{pos:s,inside:p?p.posAtStart-p.border:-1}}(this,e)}coordsAtPos(e,t=1){return G(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(null==i)throw RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return function(e,t,n){var i,r,s;let o,a;if(X==t&&J==n)return Q;X=t,J=n;return Q="up"==n||"down"==n?(i=e,r=t,s=n,o=r.selection,a="up"==s?o.$from:o.$to,K(i,r,()=>{let{node:e}=i.docView.domFromPos(a.pos,"up"==s?-1:1);for(;;){let t=i.docView.nearestDesc(e,!0);if(!t)break;if(t.node.isBlock){e=t.contentDOM||t.dom;break}e=t.dom.parentNode}let t=G(i,a.pos,1);for(let n=e.firstChild;n;n=n.nextSibling){let e;if(1==n.nodeType)e=n.getClientRects();else{if(3!=n.nodeType)continue;e=d(n,0,n.nodeValue.length).getClientRects()}for(let n=0;n<e.length;n++){let i=e[n];if(i.bottom>i.top+1&&("up"==s?t.top-i.top>(i.bottom-t.top)*2:i.bottom-t.bottom>(t.bottom-i.top)*2))return!1}}return!0})):function(e,t,n){let{$head:i}=t.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,s=r==i.parent.content.size,o=e.domSelection();return o?Y.test(i.parent.textContent)&&o.modify?K(e,t,()=>{let{focusNode:t,focusOffset:r,anchorNode:s,anchorOffset:a}=e.domSelectionRange(),l=o.caretBidiLevel;o.modify("move",n,"character");let d=i.depth?e.docView.domAfterPos(i.before()):e.dom,{focusNode:c,focusOffset:h}=e.domSelectionRange(),u=c&&!d.contains(1==c.nodeType?c:c.parentNode)||t==c&&r==h;try{o.collapse(s,a),t&&(t!=s||r!=a)&&o.extend&&o.extend(t,r)}catch(e){}return null!=l&&(o.caretBidiLevel=l),u}):"left"==n||"backward"==n?!r:s:i.pos==i.start()||i.pos==i.end()}(e,t,n)}(this,t||this.state,e)}pasteHTML(e,t){return tl(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return tl(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return eV(this,e)}destroy(){this.docView&&(!function(e){for(let t in e.domObserver.stop(),e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],tD(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,c())}get isDestroyed(){return null==this.docView}dispatchEvent(e){var t,n;return t=this,void(!e4(t,n=e)&&eQ[n.type]&&(t.editable||!(n.type in e0))&&eQ[n.type](t,n))}domSelectionRange(){let e=this.domSelection();return e?D&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){let n;if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return tj(e,n)}function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",i,!0),n?tj(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function t$(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:!t[e]&&"contenteditable"!=e&&"nodeName"!=e&&(t[e]=String(n[e]))}),!t.translate&&(t.translate="no"),[tv.node(0,e.state.doc.content.size,t)]}function tW(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:tv.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function tG(e){return!e.someProp("editable",t=>!1===t(e.state))}tV.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function tZ(e){let t=Object.create(null);function n(e){for(let n in e)!Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function tq(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}},90265:function(e,t,n){"use strict";n.d(t,{Z:()=>_});var i=n("151064"),r=n("455069"),s=n("213898"),o=n("59160"),a=n("711281"),l=n("642844"),d=n("733216"),c=n("734083"),h=n("262941"),u=n("647405"),p=n("856667");class f{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(e){this.pdfDocument=e}setViewer(e){this.pdfViewer=e}setExternalLinkRel(e){this.externalLinkRel=e}setExternalLinkTarget(e){this.externalLinkTarget=e}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return(0,l.Z)(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(e){(0,l.Z)(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=e}get rotation(){return 0}set rotation(e){}goToDestination(e){return new Promise(t=>{(0,l.Z)(this.pdfDocument,"PDF document not loaded."),(0,l.Z)(e,"Destination is not specified."),"string"==typeof e?this.pdfDocument.getDestination(e).then(t):Array.isArray(e)?t(e):e.then(t)}).then(e=>{(0,l.Z)(Array.isArray(e),`"${e}" is not a valid destination array.`);let t=e[0];new Promise(e=>{(0,l.Z)(this.pdfDocument,"PDF document not loaded."),t instanceof Object?this.pdfDocument.getPageIndex(t).then(t=>{e(t)}).catch(()=>{(0,l.Z)(!1,`"${t}" is not a valid page reference.`)}):"number"==typeof t?e(t):(0,l.Z)(!1,`"${t}" is not a valid destination reference.`)}).then(t=>{let n=t+1;(0,l.Z)(this.pdfViewer,"PDF viewer is not initialized."),(0,l.Z)(n>=1&&n<=this.pagesCount,`"${n}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:t,pageNumber:n})})})}navigateTo(e){this.goToDestination(e)}goToPage(e){(0,l.Z)(this.pdfViewer,"PDF viewer is not initialized."),(0,l.Z)(e>=1&&e<=this.pagesCount,`"${e}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({pageIndex:e-1,pageNumber:e})}addLinkAttributes(e,t,n){e.href=t,e.rel=this.externalLinkRel||"noopener noreferrer nofollow",e.target=n?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}var m={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},g=n("411757"),v=n("71331"),b=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)0>t.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n};let{PDFDataRangeTransport:y}=h,x=(e,t)=>{switch(t){case m.NEED_PASSWORD:e(prompt("Enter the password to open this PDF file."));break;case m.INCORRECT_PASSWORD:e(prompt("Invalid password. Please try again."))}};function w(e){return"object"==typeof e&&null!==e&&("data"in e||"range"in e||"url"in e)}var _=(0,r.forwardRef)(function(e,t){var{children:n,className:m,error:_="Failed to load PDF file.",externalLinkRel:S,externalLinkTarget:E,file:C,inputRef:A,imageResourcesPath:k,loading:T="Loading PDF…",noData:M="No PDF file specified.",onItemClick:D,onLoadError:O,onLoadProgress:I,onLoadSuccess:N,onPassword:R=x,onSourceError:L,onSourceSuccess:P,options:j,renderMode:F,rotate:B}=e,z=b(e,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);let[H,U]=(0,v.Z)(),{value:V,error:$}=H,[W,G]=(0,v.Z)(),{value:Z,error:q}=W,K=(0,r.useRef)(new f),Y=(0,r.useRef)([]),X=(0,r.useRef)(void 0),J=(0,r.useRef)(void 0);C&&C!==X.current&&w(C)&&(d(!(0,c.J)(C,X.current),'File prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.'),X.current=C),j&&j!==J.current&&(d(!(0,c.J)(j,J.current),'Options prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.'),J.current=j);let Q=(0,r.useRef)({scrollPageIntoView:e=>{let{dest:t,pageNumber:n,pageIndex:i=n-1}=e;if(D){D({dest:t,pageIndex:i,pageNumber:n});return}let r=Y.current[i];if(r){r.scrollIntoView();return}d(!1,`An internal link leading to page ${n} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});(0,r.useImperativeHandle)(t,()=>({linkService:K,pages:Y,viewer:Q}),[]);(0,r.useEffect)(function(){U({type:"RESET"})},[C,U]);let ee=(0,r.useCallback)(()=>{var e,t,n,i;return e=this,t=void 0,n=void 0,i=function*(){if(!C)return null;if("string"==typeof C)return(0,g.gJ)(C)?{data:(0,g.us)(C)}:((0,g.tN)(),{url:C});if(C instanceof y)return{range:C};if((0,g.eP)(C))return{data:C};if(g.jU&&(0,g.Lj)(C))return{data:yield(0,g.eR)(C)};if((0,l.Z)("object"==typeof C,"Invalid parameter in file, need either Uint8Array, string or a parameter object"),(0,l.Z)(w(C),"Invalid parameter object: need either .data, .range or .url"),"url"in C&&"string"==typeof C.url){if((0,g.gJ)(C.url)){let{url:e}=C,t=b(C,["url"]);return Object.assign({data:(0,g.us)(e)},t)}(0,g.tN)()}return C},new(n||(n=Promise))(function(r,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})},[C]);(0,r.useEffect)(()=>{let e=(0,o.Z)(ee());return e.promise.then(e=>{U({type:"RESOLVE",value:e})}).catch(e=>{U({type:"REJECT",error:e})}),()=>{(0,g.LJ)(e)}},[ee,U]),(0,r.useEffect)(()=>{if(void 0!==V){if(!1===V){!function(){if(!!$)d(!1,$.toString()),L&&L($)}();return}P&&P()}},[V]);(0,r.useEffect)(function(){G({type:"RESET"})},[G,V]),(0,r.useEffect)(function(){if(!V)return;let e=j?Object.assign(Object.assign({},V),j):V,t=h.getDocument(e);I&&(t.onProgress=I),R&&(t.onPassword=R);let n=t.promise.then(e=>{G({type:"RESOLVE",value:e})}).catch(e=>{if(!t.destroyed)G({type:"REJECT",error:e})});return()=>{n.finally(()=>t.destroy())}},[j,G,V]),(0,r.useEffect)(()=>{if(void 0!==Z){if(!1===Z){!function(){if(!!q)d(!1,q.toString()),O&&O(q)}();return}!function(){if(!!Z)N&&N(Z),Y.current=Array(Z.numPages),K.current.setDocument(Z)}()}},[Z]),(0,r.useEffect)(function(){K.current.setViewer(Q.current),K.current.setExternalLinkRel(S),K.current.setExternalLinkTarget(E)},[S,E]);let et=(0,r.useCallback)((e,t)=>{Y.current[e]=t},[]),en=(0,r.useCallback)(e=>{delete Y.current[e]},[]),ei=(0,r.useMemo)(()=>({imageResourcesPath:k,linkService:K.current,onItemClick:D,pdf:Z,registerPage:et,renderMode:F,rotate:B,unregisterPage:en}),[k,D,Z,et,F,B,en]),er=(0,r.useMemo)(()=>(0,s.ZP)(z,()=>Z),[z,Z]);return(0,i.jsx)("div",Object.assign({className:(0,a.Z)("react-pdf__Document",m),ref:A,style:{"--scale-factor":"1"}},er,{children:C?null==Z?(0,i.jsx)(p.Z,{type:"loading",children:"function"==typeof T?T():T}):!1===Z?(0,i.jsx)(p.Z,{type:"error",children:"function"==typeof _?_():_}):(0,i.jsx)(u.Z.Provider,{value:ei,children:n}):(0,i.jsx)(p.Z,{type:"no-data",children:"function"==typeof M?M():M})}))})},647405:function(e,t,n){"use strict";let i=(0,n(455069).createContext)(null);t.Z=i},856667:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});var i=n(151064);function r({children:e,type:t}){return(0,i.jsx)("div",{className:`react-pdf__message react-pdf__message--${t}`,children:e})}},876945:function(e,t,n){"use strict";n.d(t,{Z:()=>D});var i=n("151064"),r=n("455069"),s=n("59160"),o=n("213898"),a=n("711281");function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(Boolean);return n.length<=1?n[0]||null:function(e){n.forEach(function(t){"function"==typeof t?t(e):t&&(t.current=e)})}}var d=n("642844"),c=n("733216");let h=(0,r.createContext)(null);var u=n("856667"),p=n("262941");let f={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},m=/^H(\d+)$/;function g(e){return"children"in e}function v(e){return!!g(e)&&1===e.children.length&&0 in e.children&&"id"in e.children[0]}function b({className:e,node:t}){let n=(0,r.useMemo)(()=>{var e;return(e=t)?Object.assign(Object.assign({},function(e){let t={};if(g(e)){let{role:n}=e,i=n.match(m);if(i)t.role="heading",t["aria-level"]=Number(i[1]);else if(n in f){let e=f[n];e&&(t.role=e)}}return t}(e)),function e(t){let n={};if(g(t)){if(void 0!==t.alt&&(n["aria-label"]=t.alt),void 0!==t.lang&&(n.lang=t.lang),v(t)){let[i]=t.children;if(i){let t=e(i);return Object.assign(Object.assign({},n),t)}}}else"id"in t&&(n["aria-owns"]=t.id);return n}(e)):null},[t]),s=(0,r.useMemo)(()=>!g(t)||v(t)?null:t.children.map((e,t)=>(0,i.jsx)(b,{node:e},t)),[t]);return(0,i.jsx)("span",Object.assign({className:e},n,{children:s}))}function y(){return(0,r.useContext)(h)}var x=n("71331"),w=n("411757");function _(){let e=y();(0,d.Z)(e,"Unable to find Page context.");let{onGetStructTreeError:t,onGetStructTreeSuccess:n}=e,[o,a]=(0,x.Z)(),{value:l,error:h}=o,{customTextRenderer:u,page:p}=e;return((0,r.useEffect)(function(){a({type:"RESET"})},[a,p]),(0,r.useEffect)(function(){if(u||!p)return;let e=(0,s.Z)(p.getStructTree());return e.promise.then(e=>{a({type:"RESOLVE",value:e})}).catch(e=>{a({type:"REJECT",error:e})}),()=>(0,w.LJ)(e)},[u,p,a]),(0,r.useEffect)(()=>{if(void 0!==l){if(!1===l){!function(){if(!!h)c(!1,h.toString()),t&&t(h)}();return}!function(){if(!!l)n&&n(l)}()}},[l]),l)?(0,i.jsx)(b,{className:"react-pdf__Page__structTree structTree",node:l}):null}let S=p.AnnotationMode;function E(e){let t=y();(0,d.Z)(t,"Unable to find Page context.");let{_className:n,canvasBackground:s,devicePixelRatio:o=(0,w.x_)(),onRenderError:a,onRenderSuccess:h,page:u,renderForms:p,renderTextLayer:f,rotate:m,scale:g}=Object.assign(Object.assign({},t),e),{canvasRef:v}=e;(0,d.Z)(u,"Attempted to render page canvas, but no page was specified.");let b=(0,r.useRef)(null);function x(e){if(!(0,w.DE)(e))c(!1,e.toString()),a&&a(e)}let E=(0,r.useMemo)(()=>u.getViewport({scale:g*o,rotation:m}),[o,u,m,g]),C=(0,r.useMemo)(()=>u.getViewport({scale:g,rotation:m}),[u,m,g]);(0,r.useEffect)(function(){if(!u)return;u.cleanup();let{current:e}=b;if(!e)return;e.width=E.width,e.height=E.height,e.style.width=`${Math.floor(C.width)}px`,e.style.height=`${Math.floor(C.height)}px`,e.style.visibility="hidden";let t={annotationMode:p?S.ENABLE_FORMS:S.ENABLE,canvasContext:e.getContext("2d",{alpha:!1}),viewport:E};s&&(t.background=s);let n=u.render(t);return n.promise.then(()=>{e.style.visibility="",!function(){if(!!u)h&&h((0,w.XZ)(u,g))}()}).catch(x),()=>(0,w.LJ)(n)},[s,u,p,E,C]);let A=(0,r.useCallback)(()=>{let{current:e}=b;e&&(e.width=0,e.height=0)},[]);return(0,r.useEffect)(()=>A,[A]),(0,i.jsx)("canvas",{className:`${n}__canvas`,dir:"ltr",ref:l(v,b),style:{display:"block",userSelect:"none"},children:f?(0,i.jsx)(_,{}):null})}function C(){let e=y();(0,d.Z)(e,"Unable to find Page context.");let{customTextRenderer:t,onGetTextError:n,onGetTextSuccess:o,onRenderTextLayerError:l,onRenderTextLayerSuccess:h,page:u,pageIndex:f,pageNumber:m,rotate:g,scale:v}=e;(0,d.Z)(u,"Attempted to load page text content, but no page was specified.");let[b,_]=(0,x.Z)(),{value:S,error:E}=b,C=(0,r.useRef)(null),A=(0,r.useRef)(void 0);c(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10),"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");(0,r.useEffect)(function(){_({type:"RESET"})},[u,_]),(0,r.useEffect)(function(){if(!u)return;let e=(0,s.Z)(u.getTextContent());return e.promise.then(e=>{_({type:"RESOLVE",value:e})}).catch(e=>{_({type:"REJECT",error:e})}),()=>(0,w.LJ)(e)},[u,_]),(0,r.useEffect)(()=>{if(void 0!==S){if(!1===S){!function(){if(!!E)c(!1,E.toString()),n&&n(E)}();return}!function(){if(!!S)o&&o(S)}()}},[S]);let k=(0,r.useCallback)(()=>{h&&h()},[h]),T=(0,r.useCallback)(e=>{c(!1,e.toString()),l&&l(e)},[l]),M=(0,r.useMemo)(()=>u.getViewport({scale:v,rotation:g}),[u,g,v]);return(0,r.useLayoutEffect)(function(){if(!u||!S)return;let{current:e}=C;if(!e)return;e.innerHTML="";let n=u.streamTextContent({includeMarkedContent:!0}),i=new p.TextLayer({container:e,textContentSource:n,viewport:M});return i.render().then(()=>{let n=document.createElement("div");n.className="endOfContent",e.append(n),A.current=n;let i=e.querySelectorAll('[role="presentation"]');if(t){let e=0;S.items.forEach((n,r)=>{if(!("str"in n))return;let s=i[e];if(!s)return;let o=t(Object.assign({pageIndex:f,pageNumber:m,itemIndex:r},n));s.innerHTML=o,e+=n.str&&n.hasEOL?2:1})}k()}).catch(T),()=>(0,w.LJ)(i)},[t,T,k,u,f,m,S,M]),(0,i.jsx)("div",{className:(0,a.Z)("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){let e=A.current;if(!!e)e.classList.remove("active")},onMouseDown:function(){let e=A.current;if(!!e)e.classList.add("active")},ref:C})}var A=n("647405");function k(){return(0,r.useContext)(A.Z)}function T(){let e=k(),t=y();(0,d.Z)(t,"Unable to find Page context.");let{imageResourcesPath:n,linkService:o,onGetAnnotationsError:l,onGetAnnotationsSuccess:h,onRenderAnnotationLayerError:u,onRenderAnnotationLayerSuccess:f,page:m,pdf:g,renderForms:v,rotate:b,scale:_=1}=Object.assign(Object.assign({},e),t);(0,d.Z)(g,"Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."),(0,d.Z)(m,"Attempted to load page annotations, but no page was specified."),(0,d.Z)(o,"Attempted to load page annotations, but no linkService was specified.");let[S,E]=(0,x.Z)(),{value:C,error:A}=S,T=(0,r.useRef)(null);c(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10),"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");(0,r.useEffect)(function(){E({type:"RESET"})},[E,m]),(0,r.useEffect)(function(){if(!m)return;let e=(0,s.Z)(m.getAnnotations());return e.promise.then(e=>{E({type:"RESOLVE",value:e})}).catch(e=>{E({type:"REJECT",error:e})}),()=>{(0,w.LJ)(e)}},[E,m]),(0,r.useEffect)(()=>{if(void 0!==C){if(!1===C){!function(){if(!!A)c(!1,A.toString()),l&&l(A)}();return}!function(){if(!!C)h&&h(C)}()}},[C]);let M=(0,r.useMemo)(()=>m.getViewport({scale:_,rotation:b}),[m,b,_]);return(0,r.useEffect)(function(){if(!g||!m||!o||!C)return;let{current:e}=T;if(!e)return;let t=M.clone({dontFlip:!0}),i={annotations:C,annotationStorage:g.annotationStorage,div:e,imageResourcesPath:n,linkService:o,page:m,renderForms:v,viewport:t};e.innerHTML="";try{new p.AnnotationLayer({accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:e,l10n:null,page:m,viewport:t}).render(i),f&&f()}catch(e){var r;r=e,c(!1,`${r}`),u&&u(r)}return()=>{}},[C,n,o,m,g,v,M]),(0,i.jsx)("div",{className:(0,a.Z)("react-pdf__Page__annotations","annotationLayer"),ref:T})}var M=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)0>t.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n};function D(e){let t=Object.assign(Object.assign({},k()),e),{_className:n="react-pdf__Page",_enableRegisterUnregisterPage:p=!0,canvasBackground:f,canvasRef:m,children:g,className:v,customRenderer:b,customTextRenderer:y,devicePixelRatio:_,error:S="Failed to load the page.",height:A,inputRef:D,loading:O="Loading page…",noData:I="No page specified.",onGetAnnotationsError:N,onGetAnnotationsSuccess:R,onGetStructTreeError:L,onGetStructTreeSuccess:P,onGetTextError:j,onGetTextSuccess:F,onLoadError:B,onLoadSuccess:z,onRenderAnnotationLayerError:H,onRenderAnnotationLayerSuccess:U,onRenderError:V,onRenderSuccess:$,onRenderTextLayerError:W,onRenderTextLayerSuccess:G,pageIndex:Z,pageNumber:q,pdf:K,registerPage:Y,renderAnnotationLayer:X=!0,renderForms:J=!1,renderMode:Q="canvas",renderTextLayer:ee=!0,rotate:et,scale:en=1,unregisterPage:ei,width:er}=t,es=M(t,["_className","_enableRegisterUnregisterPage","canvasBackground","canvasRef","children","className","customRenderer","customTextRenderer","devicePixelRatio","error","height","inputRef","loading","noData","onGetAnnotationsError","onGetAnnotationsSuccess","onGetStructTreeError","onGetStructTreeSuccess","onGetTextError","onGetTextSuccess","onLoadError","onLoadSuccess","onRenderAnnotationLayerError","onRenderAnnotationLayerSuccess","onRenderError","onRenderSuccess","onRenderTextLayerError","onRenderTextLayerSuccess","pageIndex","pageNumber","pdf","registerPage","renderAnnotationLayer","renderForms","renderMode","renderTextLayer","rotate","scale","unregisterPage","width"]),[eo,ea]=(0,x.Z)(),{value:el,error:ed}=eo,ec=(0,r.useRef)(null);(0,d.Z)(K,"Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.");let eh=(0,w.T8)(q)?q-1:null!=Z?Z:null,eu=null!=q?q:(0,w.T8)(Z)?Z+1:null,ep=null!=et?et:el?el.rotate:null,ef=(0,r.useMemo)(()=>{if(!el)return null;let e=1,t=null!=en?en:1;if(er||A){let t=el.getViewport({scale:1,rotation:ep});er?e=er/t.width:A&&(e=A/t.height)}return t*e},[A,el,ep,en,er]);(0,r.useEffect)(function(){return()=>{if(!!(0,w.T8)(eh))p&&ei&&ei(eh)}},[p,K,eh,ei]);(0,r.useEffect)(function(){ea({type:"RESET"})},[ea,K,eh]),(0,r.useEffect)(function(){if(!K||!eu)return;let e=(0,s.Z)(K.getPage(eu));return e.promise.then(e=>{ea({type:"RESOLVE",value:e})}).catch(e=>{ea({type:"REJECT",error:e})}),()=>(0,w.LJ)(e)},[ea,K,eu]),(0,r.useEffect)(()=>{if(void 0!==el){if(!1===el){!function(){if(!!ed)c(!1,ed.toString()),B&&B(ed)}();return}!function(){if(z){if(!el||!ef)return;z((0,w.XZ)(el,ef))}if(p&&Y){if(!(0,w.T8)(eh)||!ec.current)return;Y(eh,ec.current)}}()}},[el,ef]);let em=(0,r.useMemo)(()=>el&&(0,w.T8)(eh)&&eu&&(0,w.T8)(ep)&&(0,w.T8)(ef)?{_className:n,canvasBackground:f,customTextRenderer:y,devicePixelRatio:_,onGetAnnotationsError:N,onGetAnnotationsSuccess:R,onGetStructTreeError:L,onGetStructTreeSuccess:P,onGetTextError:j,onGetTextSuccess:F,onRenderAnnotationLayerError:H,onRenderAnnotationLayerSuccess:U,onRenderError:V,onRenderSuccess:$,onRenderTextLayerError:W,onRenderTextLayerSuccess:G,page:el,pageIndex:eh,pageNumber:eu,renderForms:J,renderTextLayer:ee,rotate:ep,scale:ef}:null,[n,f,y,_,N,R,L,P,j,F,H,U,V,$,W,G,el,eh,eu,J,ee,ep,ef]),eg=(0,r.useMemo)(()=>(0,o.ZP)(es,()=>el?ef?(0,w.XZ)(el,ef):void 0:el),[es,el,ef]),ev=`${eh}@${ef}/${ep}`;return(0,i.jsx)("div",Object.assign({className:(0,a.Z)(n,v),"data-page-number":eu,ref:l(D,ec),style:{"--scale-factor":`${ef}`,backgroundColor:f||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},eg,{children:eu?null===K||null==el?(0,i.jsx)(u.Z,{type:"loading",children:"function"==typeof O?O():O}):!1===K||!1===el?(0,i.jsx)(u.Z,{type:"error",children:"function"==typeof S?S():S}):(0,i.jsxs)(h.Provider,{value:em,children:[function(){switch(Q){case"custom":return(0,d.Z)(b,'renderMode was set to "custom", but no customRenderer was passed.'),(0,i.jsx)(b,{},`${ev}_custom`);case"none":return null;default:return(0,i.jsx)(E,{canvasRef:m},`${ev}_canvas`)}}(),ee?(0,i.jsx)(C,{},`${ev}_text`):null,X?(0,i.jsx)(T,{},`${ev}_annotations`):null,g]}):(0,i.jsx)(u.Z,{type:"no-data",children:"function"==typeof I?I():I})}))}},71331:function(e,t,n){"use strict";n.d(t,{Z:function(){return s}});var i=n(455069);function r(e,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return e}}function s(){return(0,i.useReducer)(r,{value:void 0,error:void 0})}},411757:function(e,t,n){"use strict";n.d(t,{DE:function(){return g},LJ:function(){return f},Lj:function(){return d},T8:function(){return a},XZ:function(){return m},eP:function(){return l},eR:function(){return v},gJ:function(){return c},jU:function(){return s},tN:function(){return p},us:function(){return h},x_:function(){return u}});var i=n(642844),r=n(733216);let s="undefined"!=typeof window,o=s&&"file:"===window.location.protocol;function a(e){return null!=e}function l(e){return e instanceof ArrayBuffer}function d(e){return(0,i.Z)(s,"isBlob can only be used in a browser environment"),e instanceof Blob}function c(e){return"string"==typeof e&&/^data:/.test(e)}function h(e){(0,i.Z)(c(e),"Invalid data URI.");let[t="",n=""]=e.split(",");return -1!==t.split(";").indexOf("base64")?atob(n):unescape(n)}function u(){return s&&window.devicePixelRatio||1}function p(){r(!o,"Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.")}function f(e){(null==e?void 0:e.cancel)&&e.cancel()}function m(e,t){return Object.defineProperty(e,"width",{get(){return this.view[2]*t},configurable:!0}),Object.defineProperty(e,"height",{get(){return this.view[3]*t},configurable:!0}),Object.defineProperty(e,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(e,"originalHeight",{get(){return this.view[3]},configurable:!0}),e}function g(e){return"RenderingCancelledException"===e.name}function v(e){return new Promise((t,n)=>{let i=new FileReader;i.onload=()=>{if(!i.result)return n(Error("Error while reading a file."));t(i.result)},i.onerror=e=>{if(!e.target)return n(Error("Error while reading a file."));let{error:t}=e.target;if(!t)return n(Error("Error while reading a file."));switch(t.code){case t.NOT_FOUND_ERR:return n(Error("Error while reading a file: File not found."));case t.SECURITY_ERR:return n(Error("Error while reading a file: Security error."));case t.ABORT_ERR:return n(Error("Error while reading a file: Aborted."));default:return n(Error("Error while reading a file."))}},i.readAsArrayBuffer(e)})}},642844:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});var i="Invariant failed";function r(e,t){var n;if(!e)throw Error(i)}},896433:function(e,t,n){"use strict";n.d(t,{YG:function(){return d},uY:function(){return r},ue:function(){return i}});for(var i={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},r={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},s="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),o="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),a=0;a<10;a++)i[48+a]=i[96+a]=String(a);for(var a=1;a<=24;a++)i[a+111]="F"+a;for(var a=65;a<=90;a++)i[a]=String.fromCharCode(a+32),r[a]=String.fromCharCode(a);for(var l in i)!r.hasOwnProperty(l)&&(r[l]=i[l]);function d(e){var t=!(s&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||o&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?r:i)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}}}]);
|
|
|
//# sourceMappingURL=5199.96ba1dc3.js.map |