@agile_jy/word-editor 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="canvas-editor-style",e.appendChild(document.createTextNode('.ce-select-control-popup{max-width:160px;min-width:69px;max-height:225px;position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;overflow-y:auto}.ce-select-control-popup ul{list-style:none;padding:3px 0;margin:0;box-sizing:border-box}.ce-select-control-popup ul li{font-size:13px;padding:0 20px;position:relative;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#666;height:36px;line-height:36px;box-sizing:border-box;cursor:pointer}.ce-select-control-popup ul li:hover{background-color:#eef2fd}.ce-select-control-popup ul li.active{color:var(--COLOR-HOVER, #5175f4);font-weight:700}.ce-calculator{position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;padding:8px;width:200px}.ce-calculator-display{width:100%;height:40px;line-height:40px;text-align:right;padding:0 10px;margin-bottom:8px;border:1px solid #e4e7ed;border-radius:4px;background-color:#f5f7fa;font-size:16px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis}.ce-calculator-buttons{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ce-calculator-button{width:100%;height:36px;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;font-size:14px;cursor:pointer;transition:all .2s;box-sizing:border-box}.ce-calculator-button:hover{background-color:#eef2fd;border-color:#c6d1ff}.ce-calculator-button:active{background-color:#e1e8ff}.ce-calculator-button.operator{background-color:#f5f7fa}.ce-calculator-button.operator:hover{background-color:#eef2fd}.ce-calculator-button.equal{background-color:var(--COLOR-HOVER, #5175f4);color:#fff;border-color:var(--COLOR-HOVER, #5175f4)}.ce-calculator-button.equal:hover{background-color:var(--COLOR-HOVER, #6a84ff);border-color:var(--COLOR-HOVER, #6a84ff)}.ce-calculator-button.utility{background-color:#f0f2f5}.ce-calculator-button.utility:hover{background-color:#e6e8eb}.ce-date-container{display:none;width:300px;overflow:hidden;left:0;right:0;position:absolute;z-index:1;color:#606266;background:#ffffff;border-radius:4px;padding:10px;user-select:none;border:1px solid #e4e7ed;box-shadow:0 2px 12px #0000001a}.ce-date-container.active{display:block}.ce-date-wrap{display:none}.ce-date-wrap.active{display:block}.ce-date-title{display:flex;justify-content:center;align-items:center;text-align:center;color:#606266;font-size:16px}.ce-date-title>span{display:inline-block}.ce-date-title>span:not(.ce-date-title__now){font-family:cursive;cursor:pointer}.ce-date-title>span:not(.ce-date-title__now):hover{color:#5175f4}.ce-date-title .ce-date-title__pre-year,.ce-date-title .ce-date-title__pre-month{width:15%}.ce-date-title .ce-date-title__now{width:40%}.ce-date-title .ce-date-title__next-year,.ce-date-title .ce-date-title__next-month{width:15%}.ce-date-week{width:100%;display:flex;justify-content:center;margin-top:15px;padding-bottom:5px;border-bottom:1px solid #e4e7ed}.ce-date-week>span{list-style:none;width:calc(100%/7);text-align:center;color:#606266;font-size:14px}.ce-date-day{width:100%;display:flex;flex-wrap:wrap;align-items:center;margin-top:5px}.ce-date-day>div{width:calc(100%/7);height:40px;text-align:center;color:#606266;font-size:14px;cursor:pointer;line-height:40px;border-radius:4px}.ce-date-day>div:hover{color:#5175f4;opacity:.8}.ce-date-day>div.active{color:#5175f4;font-weight:700}.ce-date-day>div.disable{color:#c0c4cc}.ce-date-day>div.select{color:#fff;background-color:#5175f4}.ce-time-wrap{display:none;padding:10px;height:286px}.ce-time-wrap ::-webkit-scrollbar{width:0}.ce-time-wrap.active{display:flex}.ce-time-wrap li{list-style:none}.ce-time-wrap>li{width:33.3%;height:100%;text-align:center}.ce-time-wrap>li>span{transform:translateY(-5px);display:inline-block}.ce-time-wrap>li>ol{height:calc(100% - 20px);overflow-y:auto;border:1px solid #e2e2e2;position:relative}.ce-time-wrap>li:first-child>ol{border-right:0}.ce-time-wrap>li:last-child>ol{border-left:0}.ce-time-wrap>li>ol>li{line-height:30px;cursor:pointer;transition:all .3s}.ce-time-wrap>li>ol>li:hover{background-color:#eaeaea}.ce-time-wrap>li>ol>li.active{color:#fff;background:#5175F4}.ce-date-menu{width:100%;height:28px;display:flex;justify-content:flex-end;align-items:center;padding-top:10px;position:relative;border-top:1px solid #e4e7ed}.ce-date-menu button{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#fff;border:1px solid #dcdfe6;color:#606266;appearance:none;text-align:center;box-sizing:border-box;outline:none;transition:.1s;font-weight:500;user-select:none;padding:7px 15px;font-size:12px;border-radius:3px;margin:0 0 0 10px}.ce-date-menu button:hover{color:#5175f4;border-color:#5175f4}.ce-date-menu button.ce-date-menu__time{border:1px solid transparent;position:absolute;left:0;margin-left:0}.ce-date-menu button.ce-date-menu__time:hover{color:#5175f4}.ce-block-item{position:absolute;z-index:0;background-color:#fff;border:1px solid rgb(235 236 240)}.ce-block-item .ce-resizer-selection{width:100%;height:100%}.ce-block-item .ce-resizer-mask{position:absolute;top:0;bottom:0;left:0;right:0;z-index:1;background-color:transparent}.ce-table-tool__row{position:absolute;width:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed}.ce-table-tool__row .ce-table-tool__row__item{width:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__row .ce-table-tool__row__item:after{content:"";position:absolute;bottom:0;left:2px;width:8px;height:1px;background-color:#c0c6cf}.ce-table-tool__row .ce-table-tool__row__item:hover{background-color:#dadce0}.ce-table-tool__row .ce-table-tool__row__item:last-child:after{display:none}.ce-table-tool__quick__add{width:16px;height:16px;position:absolute;border-radius:50%;background-color:#e2e6ed;cursor:pointer}.ce-table-tool__quick__add:after{content:"+";color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%,-55%)}.ce-table-tool__select{width:16px;height:18px;position:absolute;border-radius:3px;cursor:pointer}.ce-table-tool__select:hover{background-color:#e2e6ed}.ce-table-tool__select:after{content:":::";color:#aaaaab;position:absolute;top:50%;left:50%;transform:translate(-75%,-50%) rotate(-90deg)}.ce-table-tool__col{position:absolute;height:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed;display:flex}.ce-table-tool__col .ce-table-tool__col__item{height:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__col .ce-table-tool__col__item:after{content:"";position:absolute;top:2px;left:-1px;width:1px;height:8px;z-index:1;background-color:#c0c6cf}.ce-table-tool__col .ce-table-tool__col__item:hover{background-color:#dadce0}.ce-table-tool__col .ce-table-tool__col__item:first-child:after{display:none}.ce-table-tool__row .ce-table-tool__row__item.active,.ce-table-tool__col .ce-table-tool__col__item.active{background-color:#c4d7fa}.ce-table-tool__col .ce-table-tool__anchor{right:-5px;width:10px;height:12px;z-index:9;position:absolute;cursor:col-resize}.ce-table-tool__row .ce-table-tool__anchor{bottom:-5px;left:0;width:12px;height:10px;z-index:9;position:absolute;cursor:row-resize}.ce-table-anchor__line{z-index:9;position:absolute;border:1px dotted #000000}.ce-table-tool__border{position:absolute;z-index:1;background:transparent;pointer-events:none}.ce-table-tool__border__row{position:absolute;cursor:row-resize;pointer-events:auto}.ce-table-tool__border__col{position:absolute;cursor:col-resize;pointer-events:auto}.ce-resizer-selection{position:absolute;border:1px solid;pointer-events:none}.ce-resizer-selection .resizer-handle{position:absolute;z-index:9;width:10px;height:10px;box-shadow:0 1px 4px #0000004d;border-radius:5px;border:2px solid #ffffff;box-sizing:border-box;pointer-events:initial}.ce-resizer-selection .handle-0{cursor:nw-resize}.ce-resizer-selection .handle-1{cursor:n-resize}.ce-resizer-selection .handle-2{cursor:ne-resize}.ce-resizer-selection .handle-3{cursor:e-resize}.ce-resizer-selection .handle-4{cursor:se-resize}.ce-resizer-selection .handle-5{cursor:s-resize}.ce-resizer-selection .handle-6{cursor:sw-resize}.ce-resizer-selection .handle-7{cursor:w-resize}.ce-resizer-size-view{display:flex;align-items:center;height:20px;white-space:nowrap;position:absolute;z-index:9;top:-30px;left:0;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px}.ce-resizer-size-view span{color:#fff;font-size:12px}.ce-resizer-image{position:absolute;opacity:.5}.ce-image-previewer{position:fixed;left:0;top:0;z-index:1000;width:100%;height:100%;overflow:hidden;background:#f2f4f7;display:flex;align-items:center;justify-content:center;animation:previewerAnimation .3s}@keyframes previewerAnimation{0%{opacity:.1}to{opacity:1}}.ce-image-previewer .image-close{width:24px;height:24px;display:inline-block;position:absolute;right:50px;top:30px;z-index:99;cursor:pointer;background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIzLjk3IDdsMS40MTUgMS40MTQtNy43NzkgNy43NzggNy43NzkgNy43NzktMS40MTQgMS40MTQtNy43NzktNy43NzktNy43NzggNy43NzlMNyAyMy45N2w3Ljc3OC03Ljc3OUw3IDguNDE0IDguNDE0IDdsNy43NzggNy43NzhMMjMuOTcxIDd6IiBmaWxsPSIjM0Q0NzU3IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=) no-repeat;background-size:100% 100%;transition:all .3s;border-radius:50%}.ce-image-previewer .image-close:hover{background-color:#e2e6ed}.ce-image-previewer .ce-image-container{position:relative}.ce-image-previewer .ce-image-container img{cursor:move;position:relative}.ce-image-previewer .ce-image-menu{height:50px;position:absolute;bottom:50px;z-index:99;display:flex;align-items:center;justify-content:center}.ce-image-previewer .ce-image-menu i{width:32px;height:32px;margin:0 8px;cursor:pointer;display:inline-block;background-repeat:no-repeat;background-size:100% 100%;transition:all .3s;border-radius:50%}.ce-image-previewer .ce-image-menu i:hover{background-color:#e2e6ed}.ce-image-previewer .ce-image-menu i.zoom-in{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE0IDE0di00aDJ2NGg0djJoLTR2NGgtMnYtNGgtNHYtMmg0em04Ljc0OSAxMC4xNjNBMTEuOTUyIDExLjk1MiAwIDAxMTUgMjdDOC4zNzMgMjcgMyAyMS42MjcgMyAxNVM4LjM3MyAzIDE1IDNzMTIgNS4zNzMgMTIgMTJjMCAyLjk1NC0xLjA2NyA1LjY1OC0yLjgzNyA3Ljc0OWw0LjkwOCA0LjkwOC0xLjQxNCAxLjQxNC00LjkwOC00LjkwOHpNMTUgMjVjNS41MjMgMCAxMC00LjQ3NyAxMC0xMFMyMC41MjMgNSAxNSA1IDUgOS40NzcgNSAxNXM0LjQ3NyAxMCAxMCAxMHoiIGZpbGw9IiMzRDQ3NTciLz48L3N2Zz4=)}.ce-image-previewer .ce-image-menu i.zoom-out{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIyLjc0OSAyNC4xNjNBMTEuOTUyIDExLjk1MiAwIDAxMTUgMjdDOC4zNzMgMjcgMyAyMS42MjcgMyAxNVM4LjM3MyAzIDE1IDNzMTIgNS4zNzMgMTIgMTJjMCAyLjk1NC0xLjA2NyA1LjY1OC0yLjgzNyA3Ljc0OWw0LjkwOCA0LjkwOC0xLjQxNCAxLjQxNC00LjkwOC00LjkwOHpNMTUgMjVjNS41MjMgMCAxMC00LjQ3NyAxMC0xMFMyMC41MjMgNSAxNSA1IDUgOS40NzcgNSAxNXM0LjQ3NyAxMCAxMCAxMHptLTUtMTFoMTB2MkgxMHYtMnoiIGZpbGw9IiMzRDQ3NTciLz48L3N2Zz4=)}.ce-image-previewer .ce-image-menu i.rotate{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMTYgNGM2LjYyNyAwIDEyIDUuMzczIDEyIDEyYTExLjk3IDExLjk3IDAgMDEtNCA4Ljk0NFYyM2gtLjg2QTkuOTY4IDkuOTY4IDAgMDAyNiAxNmMwLTUuNTIzLTQuNDc3LTEwLTEwLTEwUzYgMTAuNDc3IDYgMTZjMCA1LjE4NSAzLjk0NyA5LjQ0OSA5IDkuOTV2Mi4wMDlDOC44NCAyNy40NTEgNCAyMi4yOTEgNCAxNiA0IDkuMzczIDkuMzczIDQgMTYgNHoiIGZpbGwtcnVsZT0ibm9uemVybyIvPjxwYXRoIGQ9Ik0xOS44NzkgMjcuMzI4bDEuNzY3LTYuNzE3IDQuOTUgNC45NXoiLz48L2c+PC9zdmc+)}.ce-image-previewer .ce-image-menu i.original-size{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgNGgyNHYyNEg0VjR6bTIgMnYyMGgyMFY2SDZ6bTQgNWgydjEwaC0yVjExem01IDJoMnYyaC0ydi0yem0wIDRoMnYyaC0ydi0yem01LTZoMnYxMGgtMlYxMXoiIGZpbGw9IiMzRDQ3NTciLz48L3N2Zz4=)}.ce-image-previewer .ce-image-menu i.image-download{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAxNXYzLjVoMTVWMTVIMjF2NUgzdi01aDEuNXptOC4yMzItMTEuMjI2djkuMTk2bDQuMDUtNC4wNSAxLjA2IDEuMDYtNS44MzQgNS44MzQtNS44MzMtNS44MzMgMS4wNi0xLjA2IDMuOTk4IDMuOTk2VjMuNzc0aDEuNXoiIGZpbGw9IiMzRDQ3NTciLz48L3N2Zz4=)}.ce-image-previewer .ce-image-menu .image-navigate{display:flex;align-items:center;justify-content:center}.ce-image-previewer .ce-image-menu i.image-pre{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyLjUgNC4wNjNMNi44NzUgMTBsNS42MjUgNS45MzgiIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==)}.ce-image-previewer .ce-image-menu i.image-next{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcuNSA0LjA2M0wxMy4xMjUgMTAgNy41IDE1LjkzOCIgc3Ryb2tlPSIjM0Q0NzU3IiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+)}.ce-image-previewer .ce-image-menu .image-count{color:#000;font-size:20px}.ce-image-previewer .ce-image-menu i.disabled{cursor:not-allowed;opacity:.5}.ce-contextmenu-container{z-index:9;position:fixed;display:none;padding:4px;overflow-x:hidden;overflow-y:auto;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px}.ce-contextmenu-content{display:flex;flex-direction:column}.ce-contextmenu-content .ce-contextmenu-sub-item:after{position:absolute;content:"";width:16px;height:16px;right:12px;background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMCAwaDE2djE2SDB6Ii8+PGcgZmlsbD0iIzc2N0M4NSI+PHBhdGggZD0iTTcgMTIuMjQzbC0uNzA3LS43MDcgNC4yNDMtNC4yNDMuNzA3LjcwN3oiLz48cGF0aCBkPSJNNi4yOTMgNC40NjRMNyAzLjc1NyAxMS4yNDMgOGwtLjcwNy43MDd6Ii8+PC9nPjwvZz48L3N2Zz4=)}.ce-contextmenu-content .ce-contextmenu-item{min-width:140px;padding:0 32px 0 16px;height:30px;display:flex;align-items:center;white-space:nowrap;box-sizing:border-box;cursor:pointer}.ce-contextmenu-content .ce-contextmenu-item.hover{background:rgba(25,55,88,.04)}.ce-contextmenu-content .ce-contextmenu-item span{max-width:300px;font-size:12px;color:#3d4757;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.ce-contextmenu-content .ce-contextmenu-item span.ce-shortcut{color:#767c85;height:30px;flex:1;text-align:right;line-height:30px;margin-left:20px}.ce-contextmenu-content .ce-contextmenu-item i{width:16px;height:16px;vertical-align:middle;display:inline-block;background-repeat:no-repeat;background-size:100% 100%;flex-shrink:0;margin-right:8px}.ce-contextmenu-divider{background-color:#e2e6ed;margin:4px 16px;height:1px}.ce-contextmenu-print{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjM0Q0NzU3IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0xMiA0aC0xVjJINXYySDRWMmExIDEgMCAwMTEtMWg2YTEgMSAwIDAxMSAxdjJ6bTAgNXY0YTEgMSAwIDAxLTEgMUg1YTEgMSAwIDAxLTEtMVY5aDF2NGg2VjloMXoiLz48cGF0aCBkPSJNMTIgMTJ2LTFoMlY1SDJ2NmgydjFIMmExIDEgMCAwMS0xLTFWNWExIDEgMCAwMTEtMWgxMmExIDEgMCAwMTEgMXY2YTEgMSAwIDAxLTEgMWgtMnoiLz48cGF0aCBkPSJNMyA4aDEwdjFIM3ptOC0yaDJ2MWgtMnoiLz48L2c+PC9zdmc+)}.ce-contextmenu-image{background-image:url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSLlm77lsYJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4PSIwIiB5PSIwIiB2aWV3Qm94PSIwIDAgMTYgMTYiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxzdHlsZT4uc3Qwe2ZpbGw6IzNkNDc1N308L3N0eWxlPjxnIGlkPSJfeDMwXzAt5YWs5YWxX3gyRl8wMuW3peWFt+agj194MkZf5o+S5YWl5Zu+54mHLTE2cHgtIj48ZyBpZD0iR3JvdXAtMTkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEgMSkiPjxwYXRoIGlkPSJDb21iaW5lZC1TaGFwZSIgY2xhc3M9InN0MCIgZD0iTTEgMGgxMmMuNiAwIDEgLjQgMSAxdjExYzAgLjYtLjQgMS0xIDFIMWMtLjYgMC0xLS40LTEtMVYxYzAtLjYuNC0xIDEtMXptMCAxdjExaDEyVjFIMXoiLz48Y2lyY2xlIGlkPSLmpK3lnIblvaIiIGNsYXNzPSJzdDAiIGN4PSIxMCIgY3k9IjQiIHI9IjEiLz48cGF0aCBpZD0iUGF0aCIgY2xhc3M9InN0MCIgZD0iTTguNSAxMS4ybC00LTQuMUwxIDEwLjdWOS4yYzEuNy0xLjYgMi43LTIuNSAzLTIuOC40LS41LjctLjQgMSAwTDguNSAxMCAxMSA3LjNjLjQtLjUuNi0uNSAxLS4xbDIgMi44djEuNWwtMi41LTMuNC0zIDMuMXoiLz48L2c+PC9nPjwvc3ZnPg==)}.ce-contextmenu-image-change{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyIDQpIiBmaWxsPSIjM0Q0NzU3Ij48Y2lyY2xlIGZpbGwtcnVsZT0ibm9uemVybyIgY3g9IjMiIGN5PSIxIiByPSIxIi8+PHBhdGggZD0iTTcuNDczIDguMjIzTDMuNDcgNC4xMDcgMCA3LjY2N3YtMS41QzEuNzE1IDQuNiAyLjcwNyAzLjY2NCAyLjk3NSAzLjM1OGMuNDAyLS40NTcuNjUxLS4zOSAxLjA0MiAwTDcuNDczIDcgOS45NiA0LjM0OWMuNDE0LS40NjIuNjItLjQ2MiAxLjAxMS0uMDcxTDEzIDcuMDZ2MS41bC0yLjUxLTMuNDEtMy4wMTcgMy4wNzJ6Ii8+PC9nPjxwYXRoIGQ9Ik02IDEuNUgxLjV2MTJoMTN2LTRWMTNhLjUuNSAwIDAxLS41LjVIMmEuNS41IDAgMDEtLjUtLjVWMmEuNS41IDAgMDEuNS0uNWg0em04LjUgOFY2bC0uNS41aDFsLS41LS41djMuNXpNNiAxLjVoNEw5LjUgMXYxbC41LS41SDZ6IiBzdHJva2U9IiMzRDQ3NTciLz48cGF0aCBkPSJNMTMuMDg1IDEuMzE2bC0zLjgxNCA0YTEgMSAwIDAwMS40NTggMS4zNjhsMy44MTUtNGExIDEgMCAxMC0xLjQ1OS0xLjM2OHoiIGZpbGw9IiMzRDQ3NTciIGZpbGwtcnVsZT0ibm9uemVybyIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-insert-row-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBzdHJva2U9IiMzRDQ3NTciIGQ9Ik04LjUgNS41aDZ2NGgtNnoiLz48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNNCA3djFoMlY3em0tMyAuNUw0IDV2NXpNMSAxaDEydjFIMXptMCAxMmgxMnYxSDF6Ii8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-insert-top-row{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNOCA1SDd2M2gxem0tLjUtM0wxMCA1SDV6Ii8+PHJlY3Qgc3Ryb2tlPSIjM0Q0NzU3IiB4PSIxLjUiIHk9IjEwLjUiIHdpZHRoPSIxMiIgaGVpZ2h0PSIzIiByeD0iMSIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-insert-bottom-row{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNNyAxMWgxVjhIN3ptLjUgM0w1IDExaDV6Ii8+PHJlY3Qgc3Ryb2tlPSIjM0Q0NzU3IiB4PSIxLjUiIHk9IjIuNSIgd2lkdGg9IjEyIiBoZWlnaHQ9IjMiIHJ4PSIxIi8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-insert-left-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNMTEgN3YxaDNWN3ptLTMgLjVMMTEgNXY1eiIvPjxyZWN0IHN0cm9rZT0iIzNENDc1NyIgdHJhbnNmb3JtPSJyb3RhdGUoOTAgNCA3LjUpIiB4PSItMiIgeT0iNiIgd2lkdGg9IjEyIiBoZWlnaHQ9IjMiIHJ4PSIxIi8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-insert-right-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNNSA4VjdIMnYxem0zLS41TDUgMTBWNXoiLz48cmVjdCBzdHJva2U9IiMzRDQ3NTciIHRyYW5zZm9ybT0icm90YXRlKDkwIDEyIDcuNSkiIHg9IjYiIHk9IjYiIHdpZHRoPSIxMiIgaGVpZ2h0PSIzIiByeD0iMSIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-delete-row-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBzdHJva2U9IiM5MjlBQTgiIGQ9Ik04LjUgNi41aDZ2MmgtNnoiLz48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNMiAxMmgxMXYxSDJ6TTIgMmgxMXYxSDJ6bS42MyAzTDcgOS4zNWwtLjYzNS42NUwyIDUuNjN6Ii8+PHBhdGggZmlsbD0iIzNENDc1NyIgZD0iTTIgOS4zNjNMNi4zNTUgNSA3IDUuNzA3IDIuNjk1IDEweiIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-delete-row{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBzdHJva2U9IiM5MjlBQTgiIGQ9Ik04LjUgNS41aDZ2NGgtNnoiLz48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNMSAxM2gxMnYxSDF6TTEgMWgxMnYxSDF6bTAgNGgxdjFIMXptMSAxaDF2MUgyem0xIDFoMXYxSDN6bTEtMWgxdjFINHptMS0xaDF2MUg1ek00IDhoMXYxSDR6TTIgOGgxdjFIMnptMyAxaDF2MUg1ek0xIDloMXYxSDF6Ii8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-delete-col{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBzdHJva2U9IiM5MjlBQTgiIGQ9Ik01LjUgNy41di02aDR2NnoiLz48cGF0aCBmaWxsPSIjM0Q0NzU3IiBkPSJNMTMgMTVWM2gxdjEyek0xIDE1VjNoMXYxMnptNCAwdi0xaDF2MXptMS0xdi0xaDF2MXptMS0xdi0xaDF2MXptLTEtMXYtMWgxdjF6bS0xLTF2LTFoMXYxem0zIDF2LTFoMXYxem0wIDJ2LTFoMXYxem0xLTN2LTFoMXYxem0wIDR2LTFoMXYxeiIvPjwvZz48L3N2Zz4=)}.ce-contextmenu-delete-table{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMTQgMTNoLTF2LTNIMnYzSDF2LTNhMSAxIDAgMDExLTFoMTFhMSAxIDAgMDExIDF2M3oiIGZpbGwtcnVsZT0ibm9uemVybyIvPjxwYXRoIGQ9Ik01LjYyNSAyTDEwIDYuMzc1IDkuMzc1IDcgNSAyLjYyNXoiLz48cGF0aCBkPSJNNSA2LjM3NUw5LjM3NSAybC42MjUuNjI1TDUuNjI1IDd6Ii8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-merge-cell{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNiAxdjFIMnYxMWg0djFIMmExIDEgMCAwMS0xLTFWMmExIDEgMCAwMTEtMWg0em0zIDBoNGExIDEgMCAwMTEgMXYxMWExIDEgMCAwMS0xIDFIOXYtMWg0VjJIOVYxeiIvPjxwYXRoIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTYgMWgxdjRINnptMiAwaDF2NEg4eiIvPjxwYXRoIGQ9Ik04IDcuNUwxMCA2djN6bS0xIDBMNSA2djN6Ii8+PHBhdGggZD0iTTkgN2gzdjFIOXpNMyA3aDN2MUgzeiIvPjxwYXRoIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTggMTBoMXY0SDh6bS0yIDBoMXY0SDZ6Ii8+PC9nPjwvc3ZnPg==)}.ce-contextmenu-merge-cancel-cell{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNNiAxdjFIMnYxMWg0djFIMmExIDEgMCAwMS0xLTFWMmExIDEgMCAwMTEtMWg0em0zIDBoNGExIDEgMCAwMTEgMXYxMWExIDEgMCAwMS0xIDFIOXYtMWg0VjJIOVYxeiIvPjxwYXRoIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTYgMWgxdjRINnptMiAwaDF2NEg4eiIvPjxwYXRoIGQ9Ik0zIDcuNUw1IDZ2M3ptOSAwTDEwIDZ2M3oiLz48cGF0aCBkPSJNNCA3aDN2MUg0em00IDBoM3YxSDh6Ii8+PHBhdGggZmlsbC1ydWxlPSJub256ZXJvIiBkPSJNOCAxMGgxdjRIOHptLTIgMGgxdjRINnoiLz48L2c+PC9zdmc+)}.ce-contextmenu-vertical-align{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHdpZHRoPSIxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMiAxM2gxMnYxSDJ6bTAtM2g4djFIMnptMC0zaDEydjFIMnptMC02aDEydjFIMnptMCAzaDh2MUgyeiIgZmlsbD0iIzNkNDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}.ce-contextmenu-vertical-align-top{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTggOEg3djZoMXptLS41LTNMMTAgOEg1ek0yIDNoMTF2MUgyeiIgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}.ce-contextmenu-vertical-align-middle{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAxMkg3djNoMXptLS41LTNsMi41IDNINXpNNyAzaDFWMEg3em0uNSAzTDUgM2g1ek0yIDdoMTF2MUgyeiIgZmlsbD0iIzNENDc1NyIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}.ce-contextmenu-vertical-align-bottom{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgOWgxVjNIN3ptLjUgM0w1IDloNXpNMiAxM2gxMXYxSDJ6IiBmaWxsPSIjM0Q0NzU3IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=)}.ce-contextmenu-border-all{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iIzNENDc1NyIvPjxwYXRoIGZpbGw9IiMzRDQ3NTciIGQ9Ik0zIDhoMTF2MUgzeiIvPjxwYXRoIGZpbGw9IiMzRDQ3NTciIGQ9Ik05IDN2MTFIOFYzeiIvPjwvc3ZnPg==)}.ce-contextmenu-border-empty{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMyAzaC0xVjJoMWExIDEgMCAwMTEgMXYxaC0xVjN6bS0zLTF2MUg4LjV2MmgtMVYzSDZWMmg0ek00IDJ2MUgzdjFIMlYzYTEgMSAwIDAxMS0xaDF6TTIgNmgxdjEuNWgydjFIM1YxMEgyVjZ6bTAgNmgxdjFoMXYxSDNhMSAxIDAgMDEtMS0xdi0xem00IDJ2LTFoMS41di0yaDF2MkgxMHYxSDZ6bTYgMHYtMWgxdi0xaDF2MWExIDEgMCAwMS0xIDFoLTF6bTItNGgtMVY4LjVoLTJ2LTFoMlY2aDF2NHpNOC41IDcuNXYtMWgtMXYxaC0xdjFoMXYxaDF2LTFoMXYtMWgtMXoiIGZpbGw9IiNBQUFDQjAiLz48L3N2Zz4=)}.ce-contextmenu-border-dash{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMyAzaC0xVjJoMWExIDEgMCAwMTEgMXYxaC0xVjN6bS0zLTF2MUg4LjV2MmgtMVYzSDZWMmg0ek00IDJ2MUgzdjFIMlYzYTEgMSAwIDAxMS0xaDF6TTIgNmgxdjEuNWgydjFIM1YxMEgyVjZ6bTAgNmgxdjFoMXYxSDNhMSAxIDAgMDEtMS0xdi0xem00IDJ2LTFoMS41di0yaDF2MkgxMHYxSDZ6bTYgMHYtMWgxdi0xaDF2MWExIDEgMCAwMS0xIDFoLTF6bTItNGgtMVY4LjVoLTJ2LTFoMlY2aDF2NHpNOC41IDcuNXYtMWgtMXYxaC0xdjFoMXYxaDF2LTFoMXYtMWgtMXoiIGZpbGw9IiMwMDAwMDAiLz48L3N2Zz4=)}.ce-contextmenu-border-external{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iIzNENDc1NyIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOSA1VjNIOHYyaDF6bTAgOXYtMkg4djJoMXpNNSA4SDN2MWgyVjh6bTkgMGgtMnYxaDJWOHpNOSA3djFoMXYxSDl2MUg4VjlIN1Y4aDFWN2gxeiIgZmlsbD0iI0FBQUNCMCIvPjwvc3ZnPg==)}.ce-contextmenu-border-internal{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOSA1VjNIOHYyaDF6bTAgOXYtMkg4djJoMXpNNSA4SDN2MWgyVjh6bTkgMGgtMnYxaDJWOHpNOSA3djFoMXYxSDl2MUg4VjlIN1Y4aDFWN2gxeiIgZmlsbD0iIzNENDc1NyIvPjwvc3ZnPg==)}.ce-contextmenu-border-td{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgZD0iTTguNSAyLjUgdjYgaC02Ii8+PC9zdmc+)}.ce-contextmenu-border-td-top{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIyIiBkPSJNMi41IDMgaDEyIi8+PC9zdmc+)}.ce-contextmenu-border-td-left{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIyIiBkPSJNMyAzIHYxMSIvPjwvc3ZnPg==)}.ce-contextmenu-border-td-bottom{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIyIiBkPSJNMi41IDE0IGgxMiIvPjwvc3ZnPg==)}.ce-contextmenu-border-td-right{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgc3Ryb2tlLXdpZHRoPSIyIiBkPSJNMTQgMyB2MTEiLz48L3N2Zz4=)}.ce-contextmenu-border-td-forward{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIgLz48cGF0aCBzdHJva2U9IiMzRDQ3NTciIGQ9Ik0xNCAzIGwtMTEgMTEiIC8+PC9zdmc+)}.ce-contextmenu-border-td-back{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIgLz48cGF0aCBzdHJva2U9IiMzRDQ3NTciIGQ9Ik0zIDMgbDExIDExIiAvPjwvc3ZnPg==)}.ce-hyperlink-popup{background:#fff;box-shadow:0 2px 12px #626b8433;border-radius:2px;color:#3d4757;padding:12px 16px;position:absolute;z-index:1;text-align:center;display:none}.ce-hyperlink-popup a{min-width:100px;max-width:300px;font-size:12px;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;color:#00f}.ce-zone-indicator>div{padding:3px 6px;color:#000;font-size:12px;background:rgb(218 231 252);position:absolute;transform-origin:0 0}.ce-zone-indicator-border__top,.ce-zone-indicator-border__bottom,.ce-zone-indicator-border__left,.ce-zone-indicator-border__right{display:block;position:absolute;z-index:0}.ce-zone-indicator-border__top{border-top:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__bottom{border-top:2px dashed rgb(238,238,238);width:100%}.ce-zone-indicator-border__left{border-left:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__right{border-right:2px dashed rgb(238,238,238)}.ce-zone-tip{display:none;align-items:center;height:30px;white-space:nowrap;position:fixed;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px;z-index:9;transition:all .3s;outline:none;user-select:none;pointer-events:none;transform:translate(10px,10px)}.ce-zone-tip.show{display:flex}.ce-zone-tip span{color:#fff;font-size:12px}.ce-inputarea{width:100px;height:30px;min-width:0;min-height:0;margin:0;padding:0;left:0;top:0;letter-spacing:0;font-size:12px;position:absolute;z-index:-1;outline:none;resize:none;border:none;overflow:hidden;color:transparent;user-select:none;caret-color:transparent;background-color:transparent}.ce-cursor{width:1px;height:20px;left:0;right:0;position:absolute;outline:none;background-color:#000;pointer-events:none}.ce-cursor.ce-cursor--animation{animation-duration:1s;animation-iteration-count:infinite;animation-name:cursorAnimation}@keyframes cursorAnimation{0%{opacity:1}13%{opacity:0}50%{opacity:0}63%{opacity:1}to{opacity:1}}.ce-float-image{position:absolute;opacity:.5;pointer-events:none}.dialog-mask{position:fixed;left:0;top:0;width:100%;height:100%;opacity:.5;background:#000000;z-index:99}.dialog-container{position:fixed;top:0;right:0;bottom:0;left:0;overflow:auto;z-index:999;margin:0;display:flex;justify-content:center;align-items:center}.dialog{position:absolute;padding:0 30px 30px;background:#ffffff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px}.dialog-title{position:relative;border-bottom:1px solid #e2e6ed;margin-bottom:30px;height:60px;display:flex;align-items:center;justify-content:space-between}.dialog-title i{width:16px;height:16px;cursor:pointer;display:inline-block;background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOC45IDguMTkybDQuMjQyIDQuMjQzLS43MDcuNzA3TDguMTkyIDguOSAzLjk1IDEzLjE0MmwtLjcwNy0uNzA3IDQuMjQyLTQuMjQzTDMuMjQzIDMuOTVsLjcwNy0uNzA3IDQuMjQyIDQuMjQyIDQuMjQzLTQuMjQyLjcwNy43MDdMOC45IDguMTkyeiIgZmlsbD0iIzZBNkE2QSIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+)}.dialog-option__item{margin-bottom:18px;display:flex;align-items:center;justify-content:space-between}.dialog-option__item span{margin-right:12px;font-size:14px;color:#3d4757;position:relative}.dialog-option__item input,.dialog-option__item textarea,.dialog-option__item select{width:276px;height:30px;border-radius:2px;border:1px solid #d3d3d3;min-height:30px;padding:5px;box-sizing:border-box;outline:none;appearance:none;user-select:none;font-family:inherit}.dialog-option__item input:focus,.dialog-option__item textarea:focus{border-color:#4991f2}.dialog-option__item--require:before{content:"*";color:#f56c6c;margin-right:4px;position:absolute;left:-8px}.dialog-menu{display:flex;align-items:center;justify-content:flex-end}.dialog-menu button{position:relative;display:inline-block;border:1px solid #e2e6ed;border-radius:2px;background:#ffffff;line-height:22px;padding:0 16px;white-space:nowrap;cursor:pointer}.dialog-menu button:hover{background:rgba(25,55,88,.04)}.dialog-menu__cancel{margin-right:16px}.dialog-menu button[type=submit]{color:#fff;background:#4991f2;border-color:#4991f2}.dialog-menu button[type=submit]:hover{background:#5b9cf3;border-color:#5b9cf3}')),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
2
- (function(c,Oe){typeof exports=="object"&&typeof module!="undefined"?Oe(exports):typeof define=="function"&&define.amd?define(["exports"],Oe):(c=typeof globalThis!="undefined"?globalThis:c||self,Oe(c["canvas-editor"]={}))})(this,function(c){"use strict";var Oe="";const Qe="0.0.7";c.MaxHeightRatio=void 0,function(s){s.HALF="half",s.ONE_THIRD="one-third",s.QUARTER="quarter"}(c.MaxHeightRatio||(c.MaxHeightRatio={})),c.NumberType=void 0,function(s){s.ARABIC="arabic",s.CHINESE="chinese"}(c.NumberType||(c.NumberType={})),c.ImageDisplay=void 0,function(s){s.INLINE="inline",s.BLOCK="block",s.SURROUND="surround",s.FLOAT_TOP="float-top",s.FLOAT_BOTTOM="float-bottom"}(c.ImageDisplay||(c.ImageDisplay={})),c.LocationPosition=void 0,function(s){s.BEFORE="before",s.AFTER="after",s.OUTER_BEFORE="outer-before",s.OUTER_AFTER="outer-after"}(c.LocationPosition||(c.LocationPosition={})),c.FlexDirection=void 0,function(s){s.ROW="row",s.COLUMN="column"}(c.FlexDirection||(c.FlexDirection={}));const y="\u200B",Mn=`
2
+ (function(c,Oe){typeof exports=="object"&&typeof module!="undefined"?Oe(exports):typeof define=="function"&&define.amd?define(["exports"],Oe):(c=typeof globalThis!="undefined"?globalThis:c||self,Oe(c["canvas-editor"]={}))})(this,function(c){"use strict";var Oe="";const Qe="0.0.8";c.MaxHeightRatio=void 0,function(s){s.HALF="half",s.ONE_THIRD="one-third",s.QUARTER="quarter"}(c.MaxHeightRatio||(c.MaxHeightRatio={})),c.NumberType=void 0,function(s){s.ARABIC="arabic",s.CHINESE="chinese"}(c.NumberType||(c.NumberType={})),c.ImageDisplay=void 0,function(s){s.INLINE="inline",s.BLOCK="block",s.SURROUND="surround",s.FLOAT_TOP="float-top",s.FLOAT_BOTTOM="float-bottom"}(c.ImageDisplay||(c.ImageDisplay={})),c.LocationPosition=void 0,function(s){s.BEFORE="before",s.AFTER="after",s.OUTER_BEFORE="outer-before",s.OUTER_AFTER="outer-after"}(c.LocationPosition||(c.LocationPosition={})),c.FlexDirection=void 0,function(s){s.ROW="row",s.COLUMN="column"}(c.FlexDirection||(c.FlexDirection={}));const y="\u200B",Mn=`
3
3
  `,Ce=" ",On="&nbsp;",Fi=["\xB7","\u3001",":","\uFF1A",",","\uFF0C",".","\u3002",";","\uFF1B","?","\uFF1F","!","\uFF01"],Sn={[c.MaxHeightRatio.HALF]:1/2,[c.MaxHeightRatio.ONE_THIRD]:1/3,[c.MaxHeightRatio.QUARTER]:1/4},Xn={ENGLISH:"A-Za-z",SPANISH:"A-Za-z\xC1\xC9\xCD\xD3\xDA\xE1\xE9\xED\xF3\xFA\xD1\xF1\xDC\xFC",FRENCH:"A-Za-z\xC0\xC2\xC7\xE0\xE2\xE7\xC9\xE9\xC8\xE8\xCA\xEA\xCB\xEB\xCE\xEE\xCF\xEF\xD4\xF4\xD9\xF9\xDB\xFB\u0178\xFF",GERMAN:"A-Za-z\xC4\xE4\xD6\xF6\xDC\xFC\xDF",RUSSIAN:"\u0410-\u042F\u0430-\u044F\u0401\u0451",PORTUGUESE:"A-Za-z\xC1\xC9\xCD\xD3\xDA\xE1\xE9\xED\xF3\xFA\xC3\xD5\xE3\xF5\xC7\xE7",ITALIAN:"A-Za-z\xC0\xE0\xC8\xE8\xC9\xE9\xCC\xEC\xCD\xED\xCE\xEE\xD3\xF3\xD2\xF2\xD9\xF9",DUTCH:"A-Za-z\xC0\xE0\xC1\xE1\xC2\xE2\xC4\xE4\xC8\xE8\xC9\xE9\xCA\xEA\xCB\xEB\xCC\xEC\xCD\xED\xCE\xEE\xCF\xEF\xD3\xF3\xD2\xF2\xD4\xF4\xD6\xF6\xD9\xF9\xDB\xFB\xDC\xFC",SWEDISH:"A-Za-z\xC5\xE5\xC4\xE4\xD6\xF6",GREEK:"\u0391\u03B1\u0392\u03B2\u0393\u03B3\u0394\u03B4\u0395\u03B5\u0396\u03B6\u0397\u03B7\u0398\u03B8\u0399\u03B9\u039A\u03BA\u039B\u03BB\u039C\u03BC\u039D\u03BD\u039E\u03BE\u039F\u03BF\u03A0\u03C0\u03A1\u03C1\u03A3\u03C3\u03C2\u03A4\u03C4\u03A5\u03C5\u03A6\u03C6\u03A7\u03C7\u03A8\u03C8\u03A9\u03C9"},Wi="\u4E2D";c.RowFlex=void 0,function(s){s.LEFT="left",s.CENTER="center",s.RIGHT="right",s.ALIGNMENT="alignment",s.JUSTIFY="justify"}(c.RowFlex||(c.RowFlex={}));const De=/[0-9.]/,pi=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,Vi=/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,Yi=new RegExp(`${Vi.source}|${pi.source}`,"g"),Zi=/[、,。?!;:……「」“”‘’*()【】〔〕〖〗〘〙〚〛《》———﹝﹞–—\\/·.,!?;:`~<>()[\]{}'"|]/,be=new RegExp(`^[${y}
4
4
  ]`),Ui=/[^0-9\+\-\.eE,]/,Ei=/\s/;function Qi(s,t){let e;return function(...n){e&&window.clearTimeout(e),e=window.setTimeout(()=>{s.apply(this,n)},t)}}function Ci(s,t){let e=0,n;return function(...i){const r=Date.now();r-e>=t?(window.clearTimeout(n),s.apply(this,i),e=r):(window.clearTimeout(n),n=window.setTimeout(()=>{s.apply(this,i),e=r},t))}}function Ke(s,t){if(!s||typeof s!="object")return s;let e={};return Array.isArray(s)?e=s.map(n=>Ke(n,t)):Object.keys(s).forEach(n=>{t.includes(n)||(e[n]=Ke(s[n],t))}),e}function _(s){if(typeof structuredClone=="function")return structuredClone(s);if(!s||typeof s!="object")return s;let t={};return Array.isArray(s)?t=s.map(e=>_(e)):Object.keys(s).forEach(e=>{t[e]=_(s[e])}),t}function ye(s){return s&&s.nodeType===1&&s.tagName.toLowerCase()==="body"}function Se(s,t,e){if(s&&!ye(s))for(s=e?s:s.parentNode;s;){if(!t||t(s)||ye(s))return t&&!t(s)&&ye(s)?null:s;s=s.parentNode}return null}function k(){function s(){return((1+Math.random())*65536|0).toString(16).substring(1)}return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}function pt(s){const t=[];if(Intl.Segmenter){const n=new Intl.Segmenter().segment(s);for(const{segment:i}of n)t.push(i)}else{const e=new Map;for(const i of s.matchAll(Yi))e.set(i.index,i[0]);let n=0;for(;n<s.length;){const i=e.get(n);i?(t.push(i),n+=i.length):(t.push(s[n]),n++)}}return t}function In(s,t){const e=document.createElement("a");e.href=s,e.download=t,e.click()}function Di(s,t){bi(3,s,t)}function bi(s,t,e){let n=0,i=0;const r=function(o){n=new Date().getTime()-i<300?n+1:0,i=new Date().getTime(),n>=s-1&&(e(o),n=0)};t.addEventListener("click",r)}function Xe(s){return Object.prototype.toString.call(s)==="[object Object]"}function we(s){return Array.isArray(s)}function He(s){return Object.prototype.toString.call(s)==="[object Number]"}function Ki(s){return Object.prototype.toString.call(s)==="[object String]"}function Nn(s,t){if(Xe(s)&&Xe(t)){const e=t;for(const[n,i]of Object.entries(s))e[n]?e[n]=Nn(i,e[n]):e[n]=i}else we(s)&&we(t)&&t.push(...s);return t}function Ge(s){setTimeout(()=>{s()},0)}function yi(s){const t=["\u96F6","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D","\u4E03","\u516B","\u4E5D"],e=["","\u5341","\u767E","\u5343","\u4E07","\u5341","\u767E","\u5343","\u4EBF","\u5341","\u767E","\u5343","\u4E07","\u5341","\u767E","\u5343","\u4EBF"];if(!s||isNaN(s))return"\u96F6";const n=s.toString().split("");let i="";for(let r=0;r<n.length;r++){const o=n.length-1-r;i=`${e[r]}${i}`,i=`${t[Number(n[o])]}${i}`}return i=i.replace(/零(千|百|十)/g,"\u96F6").replace(/十零/g,"\u5341"),i=i.replace(/零+/g,"\u96F6"),i=i.replace(/零亿/g,"\u4EBF").replace(/零万/g,"\u4E07"),i=i.replace(/亿万/g,"\u4EBF"),i=i.replace(/零+$/,""),i=i.replace(/^一十/g,"\u5341"),i}function Bt(s,t,e){for(let n=0;n<s.length;n++){const i=s[n],r=t[i];r!==void 0?e[i]=r:delete e[i]}}function fn(s,t){if(!(!t.length||!s.length))for(let e=s.length-1;e>=0;e--)t.includes(s[e])&&s.splice(e,1)}function mt(s,t){const e={};for(const n in s)t.includes(n)&&(e[n]=s[n]);return e}function bt(s,t){const e={};for(const n in s)t.includes(n)||(e[n]=s[n]);return e}function wi(s){const e=new TextEncoder().encode(s),n=Array.from(e,r=>String.fromCharCode(r));return window.btoa(n.join(""))}function Hi(s){let t=s.parentElement;for(;t;){const n=window.getComputedStyle(t).getPropertyValue("overflow-y");if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"))return t;t=t.parentElement}return document.documentElement}function mn(s,t){return s.length!==t.length?!1:!s.some(e=>!t.includes(e))}function Gi(s,t){if(!Xe(s)||!Xe(t))return!1;const e=Object.keys(s),n=Object.keys(t);return e.length!==n.length?!1:!e.some(i=>t[i]!==s[i])}function xi(s,t){const e=s.x,n=s.x+s.width,i=s.y,r=s.y+s.height,o=t.x,l=t.x+t.width,a=t.y,R=t.y+t.height;return!(e>l||n<o||i>R||r<a)}function Fn(s){return s==null}function Ie(s){return s.replace(/\r\n|\r/g,`
5
5
  `)}function Wn(s,t,e=0){const n=Math.max(0,Math.floor(e));if(n>=s.length)return typeof t=="string"&&t===""?{index:s.length,length:0}:{index:-1,length:0};if(typeof t=="string"){if(t==="")return{index:n,length:0};const a=s.indexOf(t,n);return a===-1?{index:-1,length:0}:{index:a,length:t.length}}const i=t.flags,r=i.includes("g")?i:i+"g",o=new RegExp(t.source,r);o.lastIndex=n;const l=o.exec(s);return l?{index:l.index,length:l[0].length}:{index:-1,length:0}}function pn(s,t){if(!t){s.scrollTop=0;return}const e=[];let n=t.offsetParent;for(;n&&s!==n&&s.contains(n);)e.push(n),n=n.offsetParent;const i=t.offsetTop+e.reduce((a,R)=>a+R.offsetTop,0),r=i+t.offsetHeight,o=s.scrollTop,l=o+s.clientHeight;i<o?s.scrollTop=i:r>l&&(s.scrollTop=r-s.clientHeight)}const Ji=12,vi={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},Kt="editor-component",x="ce",Ne=`${x}-clipboard`,xe={print:{imagePreviewerDisabled:!1,backgroundDisabled:!1},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1}};var dt;(function(s){s.UP="top",s.DOWN="down",s.LEFT="left",s.RIGHT="right"})(dt||(dt={}));const At=typeof navigator!="undefined"&&/Mac OS X/.test(navigator.userAgent),Bi=typeof navigator!="undefined"&&/iPad|iPhone/.test(navigator.userAgent),Ai=/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),ki=typeof navigator!="undefined"&&/Firefox/.test(navigator.userAgent);c.ElementType=void 0,function(s){s.TEXT="text",s.IMAGE="image",s.TABLE="table",s.HYPERLINK="hyperlink",s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.SEPARATOR="separator",s.PAGE_BREAK="pageBreak",s.CONTROL="control",s.AREA="area",s.CHECKBOX="checkbox",s.RADIO="radio",s.LATEX="latex",s.TAB="tab",s.DATE="date",s.BLOCK="block",s.TITLE="title",s.LIST="list",s.LABEL="label"}(c.ElementType||(c.ElementType={}));const Zt=["bold","color","highlight","font","size","italic","underline","strikeout","textDecoration"],kt=["rowFlex","rowMargin"],_i=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","url","areaId","hyperlinkId","dateId","dateFormat","groupIds","rowMargin","textDecoration"],zi=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","rowMargin","dashArray","trList","tableToolDisabled","borderType","borderColor","translateX","width","height","url","colgroup","valueList","control","checkbox","radio","dateFormat","block","level","title","listType","listStyle","listWrap","groupIds","conceptId","imgDisplay","imgFloatPosition","imgToolDisabled","imgPreviewDisabled","imgCrop","imgCaption","textDecoration","extension","externalId","areaId","area","hide","label","labelId","lineWidth","formInput"],$i=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],de=["tdId","trId","tableId"],Je=["level","titleId","title"],fe=["listId","listType","listStyle"],ve=["control","controlId","controlComponent"],yt=["font","size","bold","highlight","italic","strikeout"],jt=["areaId","area"],Vn=[...de,...Je,...fe,...jt],Ut=[c.ElementType.TEXT,c.ElementType.HYPERLINK,c.ElementType.SUBSCRIPT,c.ElementType.SUPERSCRIPT,c.ElementType.CONTROL,c.ElementType.DATE],ji=[c.ElementType.IMAGE,c.ElementType.LATEX],qi=[c.ElementType.BLOCK,c.ElementType.PAGE_BREAK,c.ElementType.SEPARATOR,c.ElementType.TABLE],to=["HR","TABLE","UL","OL"],eo=[c.ElementType.TITLE,c.ElementType.LIST],Be=class{constructor(s){this.element=s}_defineIframeProperties(s){Object.defineProperties(s,{parent:{get:()=>null},__POWERED_BY_CANVAS_EDITOR__:{get:()=>!0}})}render(s){const{iframeBlock:t}=this.element.block||{},e=document.createElement("iframe");e.setAttribute("data-id",this.element.id),e.sandbox.add(...(t==null?void 0:t.sandbox)||Be.sandbox),e.setAttribute("allow",[(t==null?void 0:t.allow)||Be.allow].join(" ")),e.style.border="none",e.style.width="100%",e.style.height="100%",t!=null&&t.src?e.src=t.src:t!=null&&t.srcdoc&&(e.srcdoc=t.srcdoc),s.append(e),this._defineIframeProperties(e.contentWindow)}};let he=Be;he.sandbox=["allow-scripts","allow-same-origin"],he.allow=["fullscreen"];class Yn{constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer(),this.imageCache=new Map,this.floatImageContainer=null,this.floatImage=null}getOriginalMainImageList(){const t=[],e=n=>{for(const i of n)if(i.type===c.ElementType.TABLE){const r=i.trList;for(let o=0;o<r.length;o++){const l=r[o];for(let a=0;a<l.tdList.length;a++){const R=l.tdList[a];e(R.value)}}}else i.type===c.ElementType.IMAGE&&t.push(i)};return e(this.draw.getOriginalMainElementList()),t}_countImagesBeforeTarget(t,e){let n=0;for(const i of t){if(i===e)break;if(i.type===c.ElementType.TABLE){const r=i.trList;for(const o of r)for(const l of o.tdList)n+=this._countImagesBeforeTarget(l.value,e)}else i.type===c.ElementType.IMAGE&&n++}return n}createFloatImage(t){const{scale:e}=this.options;let n=this.floatImageContainer,i=this.floatImage;n||(n=document.createElement("div"),n.classList.add(`${x}-float-image`),this.container.append(n),this.floatImageContainer=n),i||(i=document.createElement("img"),n.append(i),this.floatImage=i),n.style.display="none",i.style.width=`${t.width*e}px`,i.style.height=`${t.height*e}px`;const r=this.draw.getHeight(),o=this.draw.getPageGap(),l=this.draw.getPageNo()*(r+o),a=t.imgFloatPosition;n.style.left=`${a.x*e}px`,n.style.top=`${l+a.y*e}px`,i.src=t.value}dragFloatImage(t,e){if(!this.floatImageContainer)return;this.floatImageContainer.style.display="block";const n=parseFloat(this.floatImageContainer.style.left)+t,i=parseFloat(this.floatImageContainer.style.top)+e;this.floatImageContainer.style.left=`${n}px`,this.floatImageContainer.style.top=`${i}px`}destroyFloatImage(){this.floatImageContainer&&(this.floatImageContainer.style.display="none")}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const i=(t-Math.ceil(t/8)*8)/2,r=(e-Math.ceil(e/8)*8)/2,o=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
@@ -85,7 +85,7 @@ ${T||`${P+1}.`}${t(M)}${O?`
85
85
  `,r.append(a),l.selectNodeContents(r),o==null||o.removeAllRanges(),o==null||o.addRange(l),document.execCommand("copy"),r.remove()}Bo({text:s,elementList:e})}async function xn(s,t){const e=ee(s,t);document.body.append(e);const n=e.innerText;e.remove();const i=e.innerHTML;!n&&!i&&!s.length||await Ao(n,i,tt(s))}function ko(s){let t=!1;for(let e=0;e<s.items.length;e++)if(s.items[e].kind==="file"){t=!0;break}return t}function en(s,t){const e=s.getDraw();if(e.isReadonly()||e.isDisabled()||e.getControl().getIsDisabledPasteControl())return;const n=e.getRange(),{startIndex:i}=n.getRange(),r=e.getElementList();if(~i&&!n.getIsSelectAll()){const o=r[i];if((o==null?void 0:o.titleId)||(o==null?void 0:o.listId)){let l=0;for(;l<t.length;){const a=t[l];if(o.titleId&&/^\n/.test(a.value))break;if(eo.includes(a.type)){if(t.splice(l,1),a.valueList)for(let R=0;R<a.valueList.length;R++){const d=a.valueList[R];d.value===y||d.value===`
86
86
  `||(t.splice(l,0,d),l++)}l--}l++}}Ot(r,t,i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function Jn(s,t){const e=s.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=ne(t,{innerWidth:e.getOriginalInnerWidth()});en(s,n)}function nn(s,t){const e=s.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=e.getRange(),{startIndex:i}=n.getRange(),r=e.getElementList(),o=new FileReader;o.readAsDataURL(t),o.onload=()=>{const l=new Image,a=o.result;l.src=a,l.onload=()=>{const R={value:a,type:c.ElementType.IMAGE,width:l.width,height:l.height};~i&&Ot(r,[R],i,{editorOptions:e.getOptions()}),e.insertElementList([R])}}}function _o(s,t){const e=s.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=t.clipboardData;if(!n)return;const{paste:i}=e.getOverride();if(i){const o=i(t);if((o==null?void 0:o.preventDefault)!==!1)return}if(!ko(n)){const o=n.getData("text"),l=Hn();if(l&&Ie(o)===Ie(l.text)){en(s,l.elementList);return}}Gn();let r=!1;for(let o=0;o<n.items.length;o++)if(n.items[o].type==="text/html"){r=!0;break}for(let o=0;o<n.items.length;o++){const l=n.items[o];if(l.kind==="string"){if(l.type==="text/plain"&&!r){l.getAsString(a=>{s.input(a)});break}if(l.type==="text/html"&&r){l.getAsString(a=>{Jn(s,a)});break}}else if(l.kind==="file"&&l.type.includes("image")){const a=l.getAsFile();a&&nn(s,a)}}}async function zo(s,t){const e=s.getDraw();if(e.isReadonly()||e.isDisabled())return;const{paste:n}=e.getOverride();if(n){const o=n();if((o==null?void 0:o.preventDefault)!==!1)return}const i=await navigator.clipboard.readText(),r=Hn();if(r&&Ie(i)===Ie(r.text)){en(s,r.elementList);return}if(Gn(),t!=null&&t.isPlainText)i&&s.input(i);else{const o=await navigator.clipboard.read();let l=!1;for(const a of o)if(a.types.includes("text/html")){l=!0;break}for(const a of o)if(a.types.includes("text/plain")&&!l){const d=await(await a.getType("text/plain")).text();d&&s.input(d)}else if(a.types.includes("text/html")&&l){const d=await(await a.getType("text/html")).text();d&&Jn(s,d)}else if(a.types.some(R=>R.startsWith("image/"))){const R=a.types.find(u=>u.startsWith("image/")),d=await a.getType(R);nn(s,d)}}}class $o{constructor(t,e){this.draw=t,this.container=t.getContainer(),this.canvasEvent=e,this.eventBus=t.getEventBus();const n=document.createElement("textarea");n.autocomplete="off",n.classList.add(`${x}-inputarea`),n.innerText="",this.container.append(n),this.agentCursorDom=n,n.onkeydown=i=>this._keyDown(i),n.oninput=this._input.bind(this),n.onpaste=i=>this._paste(i),n.addEventListener("compositionstart",this._compositionstart.bind(this)),n.addEventListener("compositionend",this._compositionend.bind(this))}getAgentCursorDom(){return this.agentCursorDom}_keyDown(t){this.canvasEvent.keydown(t)}_input(t){const e=t.data;e&&this.canvasEvent.input(e),this.eventBus.isSubscribe("input")&&this.eventBus.emit("input",t)}_paste(t){this.draw.isReadonly()||!t.clipboardData||(_o(this.canvasEvent,t),t.preventDefault())}_compositionstart(){this.canvasEvent.compositionstart()}_compositionend(t){this.canvasEvent.compositionend(t)}}class jo{constructor(t,e){this.ANIMATION_CLASS=`${x}-cursor--animation`,this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${x}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new $o(t,e),this.blinkTimeout=null}getCursorDom(){return this.cursorDom}getAgentDom(){return this.cursorAgent.getAgentCursorDom()}getAgentIsActive(){return this.getAgentDom()===document.activeElement}getAgentDomValue(){return this.getAgentDom().value}clearAgentDomValue(){this.getAgentDom().value=""}getHitLineStartIndex(){return this.hitLineStartIndex}_blinkStart(){this.cursorDom.classList.add(this.ANIMATION_CLASS)}_blinkStop(){this.cursorDom.classList.remove(this.ANIMATION_CLASS)}_setBlinkTimeout(){this._clearBlinkTimeout(),this.blinkTimeout=window.setTimeout(()=>{this._blinkStart()},500)}_clearBlinkTimeout(){this.blinkTimeout&&(this._blinkStop(),window.clearTimeout(this.blinkTimeout),this.blinkTimeout=null)}focus(){if(Ai&&this.draw.isReadonly())return;const t=this.cursorAgent.getAgentCursorDom();document.activeElement!==t&&(t.focus(),t.setSelectionRange(0,0))}drawCursor(t){let e=this.position.getCursorPosition();if(!e)return;const{scale:n,cursor:i}=this.options,{color:r,width:o,isShow:l=!0,isBlink:a=!0,isFocus:R=!0,hitLineStartIndex:d}={...i,...t},u=this.draw.getHeight(),h=this.draw.getPageGap();this.hitLineStartIndex=d,d&&(e=this.position.getPositionList()[d]);const{metrics:g,coordinate:{leftTop:L,rightTop:T},ascent:M,pageNo:P}=e,I=(this.draw.getZone().isMainActive()?P:this.draw.getPageNo())*(u+h),f=Ji*n,S=Math.min(g.height/4,f),N=g.height+S*2,m=this.cursorAgent.getAgentCursorDom();R&&setTimeout(()=>{this.focus()});const W=g.boundingBoxDescent<0?0:g.boundingBoxDescent,Z=L[1]+M+W-(N-S)+I,U=d?L[0]:T[0];if(m.style.left=`${U}px`,m.style.top=`${Z+N-f}px`,!l){this.recoveryCursor();return}const Q=this.cursorDom.style.top,F=this.draw.isReadonly();this.cursorDom.style.width=`${o*n}px`,this.cursorDom.style.backgroundColor=r,this.cursorDom.style.left=`${U}px`,this.cursorDom.style.top=`${Z}px`,this.cursorDom.style.display=F?"none":"block",this.cursorDom.style.height=`${N}px`,a?this._setBlinkTimeout():this._clearBlinkTimeout(),Ge(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(Q)>Z?dt.UP:dt.DOWN})})}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:n}=t;if(!e||!n)return;const{pageNo:i,coordinate:{leftTop:r,leftBottom:o}}=e,l=Hi(this.container),a={left:0,right:0,top:0,bottom:0},R=l===document.documentElement;if(R)a.right=window.innerWidth,a.bottom=window.innerHeight;else{const{left:T,right:M,top:P,bottom:O}=l.getBoundingClientRect();a.left=T,a.right=M,a.top=P,a.bottom=O}const d=i*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,u=n===dt.UP,h=o[0]+(R?0:a.left),g=u?r[1]+d:o[1]+d,{maskMargin:L}=this.options;if(a.top+=L[0],a.bottom-=L[2],!(h>=a.left&&h<=a.right&&g>=a.top&&g<=a.bottom)){const{scrollLeft:T,scrollTop:M}=l;u?l.scroll(T,M-(a.top-g)):l.scroll(T,M+g-a.bottom)}}}var on;(function(s){s[s.LEFT=0]="LEFT",s[s.CENTER=1]="CENTER",s[s.RIGHT=2]="RIGHT"})(on||(on={}));function xt(s){return At?s.metaKey:s.ctrlKey}c.KeyMap=void 0,function(s){s.Delete="Delete",s.Backspace="Backspace",s.Enter="Enter",s.Left="ArrowLeft",s.Right="ArrowRight",s.Up="ArrowUp",s.Down="ArrowDown",s.ESC="Escape",s.TAB="Tab",s.META="Meta",s.LEFT_BRACKET="[",s.RIGHT_BRACKET="]",s.COMMA=",",s.PERIOD=".",s.LEFT_ANGLE_BRACKET="<",s.RIGHT_ANGLE_BRACKET=">",s.EQUAL="=",s.MINUS="-",s.PLUS="+",s.A="a",s.B="b",s.C="c",s.D="d",s.E="e",s.F="f",s.G="g",s.H="h",s.I="i",s.J="j",s.K="k",s.L="l",s.M="m",s.N="n",s.O="o",s.P="p",s.Q="q",s.R="r",s.S="s",s.T="t",s.U="u",s.V="v",s.W="w",s.X="x",s.Y="y",s.Z="z",s.A_UPPERCASE="A",s.B_UPPERCASE="B",s.C_UPPERCASE="C",s.D_UPPERCASE="D",s.E_UPPERCASE="E",s.F_UPPERCASE="F",s.G_UPPERCASE="G",s.H_UPPERCASE="H",s.I_UPPERCASE="I",s.J_UPPERCASE="J",s.K_UPPERCASE="K",s.L_UPPERCASE="L",s.M_UPPERCASE="M",s.N_UPPERCASE="N",s.O_UPPERCASE="O",s.P_UPPERCASE="P",s.Q_UPPERCASE="Q",s.R_UPPERCASE="R",s.S_UPPERCASE="S",s.T_UPPERCASE="T",s.U_UPPERCASE="U",s.V_UPPERCASE="V",s.W_UPPERCASE="W",s.X_UPPERCASE="X",s.Y_UPPERCASE="Y",s.Z_UPPERCASE="Z",s.ZERO="0",s.ONE="1",s.TWO="2",s.THREE="3",s.FOUR="4",s.FIVE="5",s.SIX="6",s.SEVEN="7",s.EIGHT="8",s.NINE="9"}(c.KeyMap||(c.KeyMap={}));class Ve{constructor(t,e){this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getCode(){var t;return((t=this.element.control)==null?void 0:t.code)||null}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),n=t[e],i=[];let r=e;for(;r>0;){const l=t[r];if(l.controlId!==n.controlId||l.controlComponent===c.ControlComponent.PREFIX||l.controlComponent===c.ControlComponent.PRE_TEXT)break;l.controlComponent===c.ControlComponent.VALUE&&i.unshift(l),r--}let o=e+1;for(;o<t.length;){const l=t[o];if(l.controlId!==n.controlId||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT)break;l.controlComponent===c.ControlComponent.VALUE&&i.push(l),o++}return i}setValue(){return-1}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:o}=e.range||this.control.getRange(),l=r[o];let a=o;for(;a>0;){const d=r[a];if(d.controlId!==l.controlId||d.controlComponent===c.ControlComponent.PREFIX||d.controlComponent===c.ControlComponent.PRE_TEXT)break;if(d.controlComponent===c.ControlComponent.CHECKBOX){const u=d.checkbox;u.value=t.includes(u.code)}a--}let R=o+1;for(;R<r.length;){const d=r[R];if(d.controlId!==l.controlId||d.controlComponent===c.ControlComponent.POSTFIX||d.controlComponent===c.ControlComponent.POST_TEXT)break;if(d.controlComponent===c.ControlComponent.CHECKBOX){const u=d.checkbox;u.value=t.includes(u.code)}R++}i.code=t.join(","),this.control.repaintControl({curIndex:o,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:i}=e;return t.key===c.KeyMap.Backspace||t.key===c.KeyMap.Delete?this.control.removeControl(n):i}cut(){return-1}}class sn extends Ve{setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,r=e.elementList||this.control.getElementList(),{startIndex:o}=e.range||this.control.getRange(),l=r[o];let a=o;for(;a>0;){const d=r[a];if(d.controlId!==l.controlId||d.controlComponent===c.ControlComponent.PREFIX||d.controlComponent===c.ControlComponent.PRE_TEXT)break;if(d.controlComponent===c.ControlComponent.RADIO){const u=d.radio;u.value=t.includes(u.code)}a--}let R=o+1;for(;R<r.length;){const d=r[R];if(d.controlId!==l.controlId||d.controlComponent===c.ControlComponent.POSTFIX||d.controlComponent===c.ControlComponent.POST_TEXT)break;if(d.controlComponent===c.ControlComponent.RADIO){const u=d.radio;u.value=t.includes(u.code)}R++}i.code=t.join(","),this.control.repaintControl({curIndex:o,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}}function vn(s){const t=s.getDraw(),e=t.getPosition(),n=t.getRange();s.isAllowDrag=!0,s.cacheRange=_(n.getRange()),s.cacheElementList=t.getElementList(),s.cachePositionList=e.getPositionList(),s.cachePositionContext=e.getPositionContext()}function Bn(s,t){const{checkbox:e,control:n}=s;if(!n)t.getCheckboxParticle().setSelect(s);else{const i=n!=null&&n.code?n.code.split(","):[];if(e!=null&&e.value){const o=i.findIndex(l=>l===e.code);i.splice(o,1)}else e!=null&&e.code&&i.push(e.code);const r=t.getControl().getActiveControl();r instanceof Ve&&r.setSelect(i)}}function An(s,t){const{radio:e,control:n}=s;if(!n)t.getRadioParticle().setSelect(s);else{const i=e!=null&&e.code?[e.code]:[],r=t.getControl().getActiveControl();r instanceof sn&&r.setSelect(i)}}function qo(s,t){var K,b;const e=t.getDraw();let n=e.isReadonly();const i=e.getRange(),r=e.getPosition(),o=i.getRange();if(s.button===on.RIGHT&&(o.isCrossRowCol||!i.getIsCollapsed()))return;if(!t.isAllowDrag&&!n&&o.startIndex!==o.endIndex&&i.getIsPointInRange(s.offsetX,s.offsetY)){vn(t);return}const a=s.target.dataset.index;a&&e.setPageNo(Number(a)),t.isAllowSelection=!0;const R=_(r.getPositionContext()),d=r.adjustPositionContext({x:s.offsetX,y:s.offsetY});if(!d)return;const{index:u,isDirectHit:h,isCheckbox:g,isRadio:L,isImage:T,isLabel:M,isTable:P,tdValueIndex:O,hitLineStartIndex:X}=d;t.mouseDownStartPosition={...d,index:P?O:u,x:s.offsetX,y:s.offsetY};const I=e.getElementList(),f=r.getPositionList(),S=P?O:u,N=I[S],m=!!(h&&T),W=!!(h&&g),Z=!!(h&&L),U=!!(h&&M);if(~u){let p=S,H=S;if(s.shiftKey){const{startIndex:w}=i.getRange();~w&&r.getPositionContext().tdId===R.tdId&&(S>w?p=w:H=w)}if(i.setRange(p,H),r.setCursorPosition(f[S]),n=e.isReadonly(),W&&!n)Bn(N,e);else if(Z&&!n)An(N,e);else if(N.controlComponent===c.ControlComponent.VALUE&&(((K=N.control)==null?void 0:K.type)===c.ControlType.CHECKBOX||((b=N.control)==null?void 0:b.type)===c.ControlType.RADIO)){let w=S;for(;w>0;){const D=I[w];if(D.controlComponent===c.ControlComponent.CHECKBOX){Bn(D,e);break}else if(D.controlComponent===c.ControlComponent.RADIO){An(D,e);break}w--}}else e.render({curIndex:S,isCompute:!1,isSubmitHistory:!1,isSetCursor:!m&&!W&&!Z});X&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:X})}const Q=e.getEventBus();U&&Q.isSubscribe("labelMousedown")&&Q.emit("labelMousedown",{evt:s,element:N});const F=e.getPreviewer();if(F.clearResizer(),m){const p={dragDisable:n||!N.controlId&&e.getMode()===c.EditorMode.FORM};N.type===c.ElementType.LATEX&&(p.mime="svg",p.srcKey="laTexSVG"),F.drawResizer(N,f[S],p),e.getCursor().drawCursor({isShow:!1}),vn(t),(N.imgDisplay===c.ImageDisplay.SURROUND||N.imgDisplay===c.ImageDisplay.FLOAT_TOP||N.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(N),Q.isSubscribe("imageMousedown")&&Q.emit("imageMousedown",{evt:s,element:N})}const E=e.getTableTool();E.dispose(),P&&!n&&e.getMode()!==c.EditorMode.FORM&&E.render();const V=e.getHyperlinkParticle();V.clearHyperlinkPopup(),N.type===c.ElementType.HYPERLINK&&(xt(s)?V.openHyperlink(N):V.drawHyperlinkPopup(N,f[S]));const Y=e.getDateParticle();Y.clearDatePicker(),N.type===c.ElementType.DATE&&!n&&Y.renderDatePicker(N,f[S])}function Ye(s){const t=k();return Reflect.set(s,"dragId",t),t}function Ze(s,t){return t.findIndex(e=>e.dragId===s)}function kn(s,t,e){const n=e.getDraw();if(s.imgDisplay===c.ImageDisplay.SURROUND||s.imgDisplay===c.ImageDisplay.FLOAT_TOP||s.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM){const i=t.offsetX-e.mouseDownStartPosition.x,r=t.offsetY-e.mouseDownStartPosition.y,o=s.imgFloatPosition;s.imgFloatPosition={x:o.x+i,y:o.y+r,pageNo:n.getPageNo()}}n.getImageParticle().destroyFloatImage()}function ts(s,t){var e,n,i,r,o,l;if(t.isAllowDrop){const a=t.getDraw();if(a.isReadonly()||a.isDisabled()){t.mousedown(s);return}const R=a.getPosition(),d=R.getPositionList(),u=R.getPositionContext(),h=a.getRange(),g=t.cacheRange,L=t.cacheElementList,T=t.cachePositionList,M=t.cachePositionContext,P=h.getRange(),O=g.startIndex===g.endIndex,X=O?g.startIndex-1:g.startIndex,I=g.endIndex;if(P.startIndex>=X&&P.endIndex<=I&&((e=t.cachePositionContext)==null?void 0:e.tdId)===u.tdId){a.clearSideEffect();let j=!1,$=!1;if(O){const Tt=L[I];if(Tt.type===c.ElementType.IMAGE||Tt.type===c.ElementType.LATEX){if(kn(Tt,s,t),Tt.imgDisplay===c.ImageDisplay.SURROUND||Tt.imgDisplay===c.ImageDisplay.FLOAT_TOP||Tt.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)a.getPreviewer().drawResizer(Tt),j=!0;else{const it=T[I];a.getPreviewer().drawResizer(Tt,it)}$=Tt.imgDisplay===c.ImageDisplay.SURROUND}}h.replaceRange({...g}),a.render({isCompute:$,isSubmitHistory:j,isSetCursor:!1});return}const f=L.slice(X+1,I+1),S=f.find(j=>j.controlId);if(S){const j=L[X+1],$=L[I];if(!((!j.controlId||j.controlComponent===c.ControlComponent.PREFIX)&&(!$.controlId||$.controlComponent===c.ControlComponent.POSTFIX)||j.controlId===$.controlId&&j.controlComponent===c.ControlComponent.PREFIX&&$.controlComponent===c.ControlComponent.POSTFIX||((n=j.control)==null?void 0:n.type)===c.ControlType.TEXT&&j.controlComponent===c.ControlComponent.VALUE&&((i=$.control)==null?void 0:i.type)===c.ControlType.TEXT&&$.controlComponent===c.ControlComponent.VALUE)){a.render({curIndex:P.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const N=a.getControl(),m=a.getElementList(),W=!S||!!m[P.startIndex].controlId||!N.getIsElementListContainFullControl(f),Z=a.getOptions(),U=f.map(j=>{if(!j.type||j.type===c.ElementType.TEXT){const $={value:j.value},Tt=Zt;return W||Tt.push(...ve),Tt.forEach(it=>{const et=j[it];et!==void 0&&($[it]=et)}),$}else{let $=_(j);return W&&($=bt($,ve)),ut([$],{isHandleFirstElement:!1,editorOptions:Z}),$}});Ot(m,U,P.startIndex,{editorOptions:a.getOptions()});const Q=L[X],F=T[X],E=Ye(L[X]),V=Ye(L[I]),Y=U.length;let K=P.startIndex,b=K+Y;const p=N.getActiveControl();if(p&&L[K].controlComponent!==c.ControlComponent.POSTFIX?(b=p.setValue(U),K=b-Y):a.spliceElementList(m,K+1,0,U),!~b){a.render({isSetCursor:!1});return}const H=Ye(m[K]),w=Ye(m[b]),D=Ze(E,L),J=Ze(V,L),v=L[J];if(v.controlId&&v.controlComponent!==c.ControlComponent.POSTFIX)h.replaceRange({...g,startIndex:D,endIndex:J}),(r=N.getActiveControl())==null||r.cut();else{let j=!0;if(M!=null&&M.isTable){const{tableId:$,trIndex:Tt,tdIndex:it}=M;j=!a.getOriginalElementList().some(C=>{var Qt,G,Me,ht;return C.id===$&&((ht=(Me=(G=(Qt=C==null?void 0:C.trList)==null?void 0:Qt[Tt])==null?void 0:G.tdList)==null?void 0:Me[it])==null?void 0:ht.deletable)===!1})}j&&a.spliceElementList(L,D+1,J-D)}const St=m[P.startIndex],ft=d[P.startIndex];let Xt=u.index;Xt&&(St.tableId&&!Q.tableId?F.index<Xt&&(Xt-=Y):!St.tableId&&Q.tableId&&ft.index<Xt&&(Xt+=Y),R.setPositionContext({...u,index:Xt}));const ct=Ze(H,m),nt=Ze(w,m);h.setRange(O?nt:ct,nt,P.tableId,P.startTdIndex,P.endTdIndex,P.startTrIndex,P.endTrIndex),a.clearSideEffect();let gt=null;if(O){const $=a.getElementList()[nt];($.type===c.ElementType.IMAGE||$.type===c.ElementType.LATEX)&&(kn($,s,t),gt=$)}if(a.render({isSetCursor:!1}),p?N.emitControlContentChange():Q.controlId&&N.emitControlContentChange({context:{range:g,elementList:L},controlElement:Q}),gt)if(gt.imgDisplay===c.ImageDisplay.SURROUND||gt.imgDisplay===c.ImageDisplay.FLOAT_TOP||gt.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)a.getPreviewer().drawResizer(gt);else{const $=R.getPositionList()[nt];a.getPreviewer().drawResizer(gt,$)}}else t.isAllowDrag&&((o=t.cacheRange)==null?void 0:o.startIndex)!==((l=t.cacheRange)==null?void 0:l.endIndex)&&t.mousedown(s)}function es(s,t){const e=t.getDraw();if(!e.getOptions().pageOuterSelectionDisable)return;const n=e.getPageContainer(),{x:i,y:r,width:o,height:l}=n.getBoundingClientRect();s.x>=i&&s.x<=i+o&&s.y>=r&&s.y<=r+l||t.setIsAllowSelection(!1)}function ns(s,t){var S;const e=t.getDraw();if(t.isAllowDrag){const N=s.offsetX,m=s.offsetY,{startIndex:W,endIndex:Z}=t.cacheRange,U=t.cachePositionList;for(let F=W+1;F<=Z;F++){const{coordinate:{leftTop:E,rightBottom:V}}=U[F];if(N>=E[0]&&N<=V[0]&&m>=E[1]&&m<=V[1])return}const Q=(S=t.cacheRange)==null?void 0:S.startIndex;if(Q){const F=t.cacheElementList[Q];(F==null?void 0:F.type)===c.ElementType.IMAGE&&(F.imgDisplay===c.ImageDisplay.SURROUND||F.imgDisplay===c.ImageDisplay.FLOAT_TOP||F.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)&&(e.getPreviewer().clearResizer(),e.getImageParticle().dragFloatImage(s.movementX,s.movementY))}t.dragover(s),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const i=s.target.dataset.index;i&&e.setPageNo(Number(i));const r=e.getPosition(),o=r.getPositionByXY({x:s.offsetX,y:s.offsetY});if(!~o.index)return;const{index:l,isTable:a,tdValueIndex:R,tdIndex:d,trIndex:u,tableId:h,trId:g,tdId:L}=o,{index:T,isTable:M,tdIndex:P,trIndex:O,tableId:X}=t.mouseDownStartPosition,I=a?R:l,f=e.getRange();if(a&&M&&(d!==P||u!==O))f.setRange(I,I,h,P,d,O,u),r.setPositionContext({isTable:a,index:l,trIndex:u,tdIndex:d,tdId:L,trId:g,tableId:h});else{let N=~I?I:0;if((M||a)&&X!==h)return;let m=T;if(m>N&&([m,N]=[N,m]),m===N)return;const W=e.getElementList(),Z=W[m+1],U=W[N];if((Z==null?void 0:Z.controlComponent)===c.ControlComponent.PLACEHOLDER&&(U==null?void 0:U.controlComponent)===c.ControlComponent.PLACEHOLDER&&Z.controlId===U.controlId)return;f.setRange(m,N)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function is(s){var l,a,R,d;const t=s.getDraw(),e=t.getRange(),n=e.getRange(),i=t.getElementList(),r=i[n.startIndex];if(!r.hide&&!((l=r.control)!=null&&l.hide)&&!((a=r.area)!=null&&a.hide))return;let o=n.startIndex;for(;o>0;){const u=i[o];let h=null;u.controlId?(h=t.getControl().removeControl(o),h!==null&&(o=h)):(t.spliceElementList(i,o,1),h=o-1,o--);const g=i[h];if(!g||!g.hide&&!((R=g.control)!=null&&R.hide)&&!((d=g.area)!=null&&d.hide)){if(h){n.startIndex=h,n.endIndex=h,e.replaceRange(n);const L=t.getPosition(),T=L.getPositionList();L.setCursorPosition(T[h])}break}}}function os(s,t){var R;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&is(t);const i=e.getControl(),{startIndex:r,endIndex:o,isCrossRowCol:l}=n.getRange();let a;if(l){const d=e.getTableParticle().getRangeRowCol();if(!d)return;let u=!1;for(let h=0;h<d.length;h++){const g=d[h];for(let L=0;L<g.length;L++){const T=g[L];T.value.length>1&&(e.spliceElementList(T.value,1,T.value.length-1),u=!0)}}a=u?0:null}else if(i.getActiveControl()&&i.getIsRangeCanCaptureEvent())a=i.keydown(s),a&&i.emitControlContentChange();else{const d=e.getPosition().getCursorPosition();if(!d)return;const{index:u}=d,h=n.getIsCollapsed(),g=e.getElementList();if(h&&u===0){const P=g[u];if(P.value===y){P.listId&&e.getListParticle().unsetList(),s.preventDefault();return}}const L=g[r];if(h&&L.rowFlex&&L.value===y){const P=n.getRangeRowElementList();if(P){const O=g[r-1];P.forEach(X=>{X.rowFlex=O==null?void 0:O.rowFlex})}}const T=L.value===y?g[r-1]:L,M=g[o+1];if((T==null?void 0:T.titleId)&&(M==null?void 0:M.titleId)&&T.level===M.level&&T.titleId!==M.titleId){const P=T.titleId,O=M.titleId;let X=o+1;for(;X<g.length&&((R=g[X])==null?void 0:R.titleId)===O;)g[X].titleId=P,X++}h?e.spliceElementList(g,u,1):e.spliceElementList(g,r+1,o-r),a=h?u-1:r}e.getGlobalEvent().setCanvasEventAbility(),a===null?(n.setRange(r,r),e.render({curIndex:r,isSubmitHistory:!1})):(n.setRange(a,a),e.render({curIndex:a}))}function ss(s){var l,a,R,d;const t=s.getDraw(),n=t.getRange().getRange(),i=t.getElementList(),r=i[n.startIndex+1];if(!r.hide&&!((l=r.control)!=null&&l.hide)&&!((a=r.area)!=null&&a.hide))return;const o=n.startIndex+1;for(;o<i.length;){const u=i[o];let h=null;u.controlId?h=t.getControl().removeControl(o):(t.spliceElementList(i,o,1),h=o);const g=i[h];if(!g||!g.hide&&!((R=g.control)!=null&&R.hide)&&!((d=g.area)!=null&&d.hide))break}}function rs(s,t){var d;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:r,isCrossRowCol:o}=n.getRange(),l=e.getElementList(),a=e.getControl();n.getIsCollapsed()&&ss(t);let R;if(o){const u=e.getTableParticle().getRangeRowCol();if(!u)return;let h=!1;for(let g=0;g<u.length;g++){const L=u[g];for(let T=0;T<L.length;T++){const M=L[T];M.value.length>1&&(e.spliceElementList(M.value,1,M.value.length-1),h=!0)}}R=h?0:null}else if(a.getActiveControl()&&a.getIsRangeWithinControl())R=a.keydown(s),R&&a.emitControlContentChange();else if((d=l[r+1])!=null&&d.controlId)R=a.removeControl(r+1);else{const u=e.getPosition(),h=u.getCursorPosition();if(!h)return;const{index:g}=h,L=u.getPositionContext();if(L.isDirectHit&&L.isImage)e.spliceElementList(l,g,1),R=g-1;else{const T=n.getIsCollapsed();if(!T)e.spliceElementList(l,i+1,r-i);else{if(!l[g+1])return;e.spliceElementList(l,g+1,1)}R=T?g:i}}e.getGlobalEvent().setCanvasEventAbility(),R===null?(n.setRange(i,i),e.render({curIndex:i,isSubmitHistory:!1})):(n.setRange(R,R),e.render({curIndex:R}))}function ls(s,t){var L,T,M,P,O,X,I;const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:r}=n.getRange(),o=n.getIsCollapsed(),l=e.getElementList(),a=l[i],R=l[r];if(o&&R.listId&&R.value===y&&((L=l[r+1])==null?void 0:L.listId)!==R.listId){e.getListParticle().unsetList();return}let d={value:y};if(s.shiftKey&&a.listId&&(d.listWrap=!0),Ot(l,[d],i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),s.shiftKey&&R.areaId&&R.areaId!==((T=l[r+1])==null?void 0:T.areaId)&&(d=bt(d,jt)),!(((M=l[i+1])==null?void 0:M.titleId)&&(!a.titleId||a.titleId!==((P=l[i+1])==null?void 0:P.titleId)))&&!(R.titleId&&R.titleId!==((O=l[r+1])==null?void 0:O.titleId))){const f=n.getRangeAnchorStyle(l,r);if(f){const S=[...kt];f.controlComponent!==c.ControlComponent.POSTFIX&&S.push(...Zt),S.forEach(N=>{const m=f[N];m!==void 0&&(d[N]=m)})}}const u=e.getControl(),h=u.getActiveControl();let g;if(h&&u.getIsRangeWithinControl())g=u.setValue([d]),u.emitControlContentChange();else{const S=e.getPosition().getCursorPosition();if(!S)return;const{index:N}=S;if(o){if(e.spliceElementList(l,N+1,0,[d]),R.titleId&&((X=l[N+2])==null?void 0:X.titleId)===R.titleId){const m=k();let W=N+2;for(;W<l.length&&((I=l[W])==null?void 0:I.titleId)===R.titleId;)l[W].titleId=m,W++}}else e.spliceElementList(l,i+1,r-i,[d]);g=N+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),s.preventDefault()}function as(s,t){var I,f,S;const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const o=i.getPositionContext(),{index:l}=r;if(l<=0&&!o.isTable)return;const a=e.getRange(),{startIndex:R,endIndex:d}=a.getRange(),u=a.getIsCollapsed(),h=e.getElementList(),g=e.getControl();if(e.getMode()===c.EditorMode.FORM&&g.getActiveControl()&&(((I=h[l])==null?void 0:I.controlComponent)===c.ControlComponent.PREFIX||((f=h[l])==null?void 0:f.controlComponent)===c.ControlComponent.PRE_TEXT)){g.initNextControl({direction:dt.UP});return}let L=1;if(xt(s)){const N=e.getLetterReg(),m=s.shiftKey&&!u&&R===(r==null?void 0:r.index)?d:R;if(N.test((S=h[m])==null?void 0:S.value)){let W=m-1;for(;W>0;){const Z=h[W];if(!N.test(Z.value))break;L++,W--}}}const T=R-L;let M=T,P=T;if(s.shiftKey&&r&&(R!==d?R===r.index?(M=R,P=d-L):(M=T,P=d):P=d),!s.shiftKey){const N=h[R];if(N.type===c.ElementType.TABLE){const m=N.trList,W=m.length-1,Z=m[W],U=Z.tdList.length-1,Q=Z.tdList[U];i.setPositionContext({isTable:!0,index:R,trIndex:W,tdIndex:U,tdId:Q.id,trId:Z.id,tableId:N.id}),M=Q.value.length-1,P=M,e.getTableTool().render()}else if(N.tableId&&R===0){const W=e.getOriginalElementList()[o.index].trList;t:for(let Z=0;Z<W.length;Z++){const U=W[Z];if(U.id!==N.trId)continue;const Q=U.tdList;for(let F=0;F<Q.length;F++)if(Q[F].id===N.tdId){if(Z===0&&F===0)i.setPositionContext({isTable:!1}),M=o.index-1,P=M,e.getTableTool().dispose();else{let V=Z,Y=F-1;Y<0&&(V=Z-1,Y=W[V].tdList.length-1);const K=W[V],b=K.tdList[Y];i.setPositionContext({isTable:!0,index:o.index,trIndex:V,tdIndex:Y,tdId:b.id,trId:K.id,tableId:N.tableId}),M=b.value.length-1,P=M,e.getTableTool().render()}break t}}}}if(!~M||!~P)return;const O=e.getElementList();M=ge(O,M),P=ge(O,P),a.setRange(M,P);const X=M===P;e.render({curIndex:X?M:void 0,isSetCursor:X,isSubmitHistory:!1,isCompute:!1}),s.preventDefault()}function Rs(s,t){var S,N,m;const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const{index:o}=r,l=i.getPositionList(),a=i.getPositionContext();if(o>l.length-1&&!a.isTable)return;const R=e.getRange(),{startIndex:d,endIndex:u}=R.getRange(),h=R.getIsCollapsed();let g=e.getElementList();const L=e.getControl();if(e.getMode()===c.EditorMode.FORM&&L.getActiveControl()&&(((S=g[o+1])==null?void 0:S.controlComponent)===c.ControlComponent.POSTFIX||((N=g[o+1])==null?void 0:N.controlComponent)===c.ControlComponent.POST_TEXT)){L.initNextControl({direction:dt.DOWN});return}let T=1;if(xt(s)){const W=e.getLetterReg(),Z=s.shiftKey&&!h&&d===(r==null?void 0:r.index)?u:d;if(W.test((m=g[Z+1])==null?void 0:m.value)){let U=Z+2;for(;U<g.length;){const Q=g[U];if(!W.test(Q.value))break;T++,U++}}}const M=u+T;let P=M,O=M;if(s.shiftKey&&r&&(d!==u?d===r.index?(P=d,O=M):(P=d+T,O=u):P=d),!s.shiftKey){const W=g[u],Z=g[u+1];if((Z==null?void 0:Z.type)===c.ElementType.TABLE){const Q=Z.trList[0],F=Q.tdList[0];i.setPositionContext({isTable:!0,index:u+1,trIndex:0,tdIndex:0,tdId:F.id,trId:Q.id,tableId:Z.id}),P=0,O=0,e.getTableTool().render()}else if(W.tableId&&!Z){const Q=e.getOriginalElementList()[a.index].trList;t:for(let F=0;F<Q.length;F++){const E=Q[F];if(E.id!==W.trId)continue;const V=E.tdList;for(let Y=0;Y<V.length;Y++)if(V[Y].id===W.tdId){if(F===Q.length-1&&Y===V.length-1)i.setPositionContext({isTable:!1}),P=a.index,O=P,g=e.getElementList(),e.getTableTool().dispose();else{let b=F,p=Y+1;p>V.length-1&&(b=F+1,p=0);const H=Q[b],w=H.tdList[p];i.setPositionContext({isTable:!0,index:a.index,trIndex:b,tdIndex:p,tdId:w.id,trId:H.id,tableId:W.tableId}),P=0,O=P,e.getTableTool().render()}break t}}}}const X=g.length-1;if(P>X||O>X)return;const I=e.getElementList();P=ge(I,P,c.LocationPosition.AFTER),O=ge(I,O,c.LocationPosition.AFTER),R.setRange(P,O);const f=P===O;e.render({curIndex:f?P:void 0,isSetCursor:f,isSubmitHistory:!1,isCompute:!1}),s.preventDefault()}function cs(s,t){const e=t.getDraw();if(e.isReadonly())return;s.preventDefault();const i=e.getControl();if(i.getActiveControl()&&i.getIsRangeWithinControl())i.initNextControl({direction:s.shiftKey?dt.UP:dt.DOWN});else{const o=e.getRange(),l=e.getElementList(),{startIndex:a,endIndex:R}=o.getRange(),d=o.getRangeAnchorStyle(l,R),h={...d?mt(d,Zt):null,type:c.ElementType.TAB,value:""};Ot(l,[h],a,{editorOptions:e.getOptions()}),e.insertElementList([h])}}function rn(s){const{positionList:t,index:e,isUp:n,rowNo:i,cursorX:r}=s;let o=-1;const l=[];if(n){let a=e-1;for(;a>=0;){const R=t[a];if(a--,R.rowNo!==i){if(l[0]&&l[0].rowNo!==R.rowNo)break;l.unshift(R)}}}else{let a=e+1;for(;a<t.length;){const R=t[a];if(a++,R.rowNo!==i){if(l[0]&&l[0].rowNo!==R.rowNo)break;l.push(R)}}}for(let a=0;a<l.length;a++){const R=l[a],{coordinate:{leftTop:[d],rightTop:[u]}}=R;if(a===l.length-1&&(o=R.index),!(r<d||r>u)){o=R.index;break}}return o}function ds(s,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),r=i.getCursorPosition();if(!r)return;const o=e.getRange(),{startIndex:l,endIndex:a}=o.getRange();let R=i.getPositionList();const d=s.key===c.KeyMap.Up;let u=-1,h=-1;const g=i.getPositionContext();if(!s.shiftKey&&g.isTable&&(d&&r.rowIndex===0||!d&&r.rowIndex===e.getRowCount()-1)){const{index:T,trIndex:M,tdIndex:P,tableId:O}=g;if(d)if(M===0)i.setPositionContext({isTable:!1}),u=T-1,h=u,e.getTableTool().dispose();else{let X=-1,I=-1;const S=e.getOriginalElementList()[T].trList,N=S[M].tdList[P].colIndex;t:for(let Z=M-1;Z>=0;Z--){const Q=S[Z].tdList;for(let F=0;F<Q.length;F++){const E=Q[F];if(E.colIndex===N||E.colIndex+E.colspan-1>=N&&E.colIndex<=N){X=Z,I=F;break t}}}if(!~X||!~I)return;const m=S[X],W=m.tdList[I];i.setPositionContext({isTable:!0,index:T,trIndex:X,tdIndex:I,tdId:W.id,trId:m.id,tableId:O}),u=W.value.length-1,h=u,e.getTableTool().render()}else{const I=e.getOriginalElementList()[T].trList;if(M===I.length-1)i.setPositionContext({isTable:!1}),u=T,h=u,e.getTableTool().dispose();else{let f=-1,S=-1;const N=I[M].tdList[P].colIndex;t:for(let Z=M+1;Z<I.length;Z++){const Q=I[Z].tdList;for(let F=0;F<Q.length;F++){const E=Q[F];if(E.colIndex===N||E.colIndex+E.colspan-1>=N&&E.colIndex<=N){f=Z,S=F;break t}}}if(!~f||!~S)return;const m=I[f],W=m.tdList[S];i.setPositionContext({isTable:!0,index:T,trIndex:f,tdIndex:S,tdId:W.id,trId:m.id,tableId:O}),u=W.value.length-1,h=u,e.getTableTool().render()}}}else{let T=r;s.shiftKey&&(l===r.index?T=R[a]:T=R[l]);const{index:M,rowNo:P,rowIndex:O,coordinate:{rightTop:[X]}}=T;if(d&&O===0||!d&&O===e.getRowCount()-1)return;const I=rn({positionList:R,index:M,rowNo:P,isUp:d,cursorX:X});if(I<0)return;u=I,h=I,s.shiftKey&&(l!==a?l===r.index?u=l:h=a:d?h=a:u=l);const S=e.getElementList()[I];if(S.type===c.ElementType.TABLE){const{scale:N}=e.getOptions(),m=e.getMargins(),W=S.trList;let Z=-1,U=-1,Q=-1;if(d){t:for(let F=W.length-1;F>=0;F--){const V=W[F].tdList;for(let Y=0;Y<V.length;Y++){const K=V[Y],b=K.x*N+m[3],p=K.width*N;if(X>=b&&X<=b+p){const H=K.positionList,w=H[H.length-1],D=rn({positionList:H,index:w.index+1,rowNo:w.rowNo-1,isUp:d,cursorX:X})||w.index;Z=F,U=Y,Q=D;break t}}}}else{t:for(let F=0;F<W.length;F++){const V=W[F].tdList;for(let Y=0;Y<V.length;Y++){const K=V[Y],b=K.x*N+m[3],p=K.width*N;if(X>=b&&X<=b+p){const H=K.positionList,w=rn({positionList:H,index:-1,rowNo:-1,isUp:d,cursorX:X})||0;Z=F,U=Y,Q=w;break t}}}}if(~Z&&~U&&~Q){const F=W[Z],E=F.tdList[U];i.setPositionContext({isTable:!0,index:I,trIndex:Z,tdIndex:U,tdId:E.id,trId:F.id,tableId:S.id}),u=Q,h=u,R=i.getPositionList(),e.getTableTool().render()}}}if(!~u||!~h)return;u>h&&([u,h]=[h,u]),o.setRange(u,h);const L=u===h;e.render({curIndex:L?u:void 0,isSetCursor:L,isSubmitHistory:!1,isCompute:!1}),L||e.getCursor().moveCursorToVisible({cursorPosition:R[d?u:h],direction:d?dt.UP:dt.DOWN})}function hs(s,t){if(t.isComposing)return;const e=t.getDraw();if(s.key===c.KeyMap.Backspace)os(s,t);else if(s.key===c.KeyMap.Delete)rs(s,t);else if(s.key===c.KeyMap.Enter)ls(s,t);else if(s.key===c.KeyMap.Left)as(s,t);else if(s.key===c.KeyMap.Right)Rs(s,t);else if(s.key===c.KeyMap.Up||s.key===c.KeyMap.Down)ds(s,t);else if(xt(s)&&s.key.toLocaleLowerCase()===c.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==c.EditorMode.FORM)return;e.getHistoryManager().undo(),s.preventDefault()}else if(xt(s)&&s.key.toLocaleLowerCase()===c.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==c.EditorMode.FORM)return;e.getHistoryManager().redo(),s.preventDefault()}else if(xt(s)&&s.key.toLocaleLowerCase()===c.KeyMap.C)t.copy(),s.preventDefault();else if(xt(s)&&s.key.toLocaleLowerCase()===c.KeyMap.X)t.cut(),s.preventDefault();else if(xt(s)&&s.key.toLocaleLowerCase()===c.KeyMap.A)t.selectAll(),s.preventDefault();else if(xt(s)&&s.key.toLocaleLowerCase()===c.KeyMap.S){if(e.isReadonly())return;const n=e.getListener();n.saved&&n.saved(e.getValue());const i=e.getEventBus();i.isSubscribe("saved")&&i.emit("saved",e.getValue()),s.preventDefault()}else if(s.key===c.KeyMap.ESC){t.clearPainterStyle();const n=e.getZone();n.isMainActive()||n.setZone(c.EditorZone.MAIN),s.preventDefault()}else s.key===c.KeyMap.TAB&&cs(s,t)}function ln(s,t){var N,m;const e=t.getDraw();if(e.isReadonly()||e.isDisabled())return;const i=e.getPosition().getCursorPosition();if(!s||!i)return;const r=t.isComposing;if(r&&((N=t.compositionInfo)==null?void 0:N.value)===s)return;const o=e.getRange();if(!o.getIsCanInput())return;const l=o.getDefaultStyle()||((m=t.compositionInfo)==null?void 0:m.defaultStyle)||null;_n(t),r||e.getCursor().clearAgentDomValue();const{TEXT:a,HYPERLINK:R,SUBSCRIPT:d,SUPERSCRIPT:u,DATE:h,TAB:g}=c.ElementType,L=s.replaceAll(`
87
87
  `,y),{startIndex:T,endIndex:M}=o.getRange(),P=e.getElementList(),O=o.getRangeAnchorStyle(P,M);if(!O)return;const X=e.isDesignMode(),I=pt(L).map(W=>{var U,Q;const Z={value:W};if(X||!((U=O.title)!=null&&U.disabled)&&!((Q=O.control)!=null&&Q.disabled)){const F=P[M+1];(!O.type||O.type===a||O.type===R&&(F==null?void 0:F.type)===R||O.type===h&&(F==null?void 0:F.type)===h||O.type===d&&(F==null?void 0:F.type)===d||O.type===u&&(F==null?void 0:F.type)===u)&&_i.forEach(E=>{if(E==="groupIds"&&!(F!=null&&F.groupIds))return;const V=O[E];V!==void 0&&(Z[E]=V)}),(l||O.type===g)&&Zt.forEach(E=>{const V=(l==null?void 0:l[E])||O[E];V!==void 0&&(Z[E]=V)}),r&&(Z.underline=!0)}return Z}),f=e.getControl();let S;if(f.getActiveControl()&&f.getIsRangeWithinControl())S=f.setValue(I),r||f.emitControlContentChange();else{const W=T+1;T!==M&&e.spliceElementList(P,W,M-T),Ot(P,I,T,{editorOptions:e.getOptions()}),e.spliceElementList(P,W,0,I),S=T+I.length}~S&&(o.setRange(S,S),e.render({curIndex:S,isSubmitHistory:!r})),r&&~S&&(t.compositionInfo={elementList:P,value:L,startIndex:S-I.length,endIndex:S,defaultStyle:l})}function _n(s){if(!s.compositionInfo)return;const{elementList:t,startIndex:e,endIndex:n}=s.compositionInfo;t.splice(e+1,n-e),s.getDraw().getRange().setRange(e,e),s.compositionInfo=null}async function us(s){const t=s.getDraw(),e=t.getRange(),{startIndex:n,endIndex:i}=e.getRange();if(!~n&&!~n||t.isReadonly()||!e.getIsCanInput())return;const r=t.getElementList();let o=n,l=i;if(n===i){const h=t.getPosition().getPositionList(),g=h[n],L=g.rowNo,T=g.pageNo,M=[];for(let O=0;O<h.length;O++){const X=h[O];if(X.pageNo>T)break;X.pageNo===T&&X.rowNo===L&&M.push(O)}const P=M[0]-1;o=P<0?0:P,l=M[M.length-1]}const a=t.getOptions();await xn(r.slice(o+1,l+1),a);const R=t.getControl();let d;R.getActiveControl()&&R.getIsRangeWithinControl()?(d=R.cut(),R.emitControlContentChange()):(t.spliceElementList(r,o+1,l-o),d=o),e.setRange(d,d),t.render({curIndex:d})}async function gs(s,t){const e=s.getDraw(),{copy:n}=e.getOverride();if(n){const l=n();if((l==null?void 0:l.preventDefault)!==!1)return}const i=e.getRange();let r=null;if(i.getRange().isCrossRowCol){const l=i.getRangeTableElement();if(!l)return;const a=e.getTableParticle().getRangeRowCol();if(!a)return;const R={type:c.ElementType.TABLE,value:"",colgroup:[],trList:[]},d=a[0],u=d[0].colIndex,h=d[d.length-1],g=h.colIndex+h.colspan-1;for(let L=u;L<=g;L++)R.colgroup.push(l.colgroup[L]);for(let L=0;L<a.length;L++){const T=a[L],M=l.trList[T[0].rowIndex],P={tdList:[],height:M.height,minHeight:M.minHeight};for(let O=0;O<T.length;O++)P.tdList.push(T[O]);R.trList.push(P)}r=tt([R])}else r=i.getIsCollapsed()?i.getRangeRowElementList():i.getSelectionElementList();(t==null?void 0:t.isPlainText)&&(r==null?void 0:r.length)&&(r=[{value:ie(r)}]),r!=null&&r.length&&await xn(r,e.getOptions())}function Ls(s,t){var r,o;const e=t.getDraw(),{drop:n}=e.getOverride();if(n){const l=n(s);if((l==null?void 0:l.preventDefault)!==!1)return}s.preventDefault();const i=(r=s.dataTransfer)==null?void 0:r.getData("text");if(i)t.input(i);else{const l=(o=s.dataTransfer)==null?void 0:o.files;if(!l)return;for(let a=0;a<l.length;a++){const R=l[a];R.type.startsWith("image")&&nn(t,R)}}}function zn(s){var h;if(!Intl.Segmenter)return null;const t=s.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const i=t.getRange().getRangeParagraphInfo();if(!i)return null;const r=((h=i==null?void 0:i.elementList)==null?void 0:h.map(g=>!g.type||g.type!==c.ElementType.CONTROL&&Ut.includes(g.type)?g.value:y).join(""))||"";if(!r)return null;const o=e.isFirstLetter||t.getCursor().getHitLineStartIndex()?e.index+1:e.index,l=i.startIndex,R=new Intl.Segmenter(void 0,{granularity:"word"}).segment(r);let d=-1,u=-1;for(const{segment:g,index:L,isWordLike:T}of R){const M=L+l;if(T&&o>=M&&o<M+g.length){d=M-1,u=d+g.length;break}}return~d&&~u?{startIndex:d,endIndex:u}:null}function Ts(s){const t=s.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:n,index:i}=e,r=t.getLetterReg();let o=0,l=0;const a=De.test(n);if(a||r.test(n)){const d=t.getElementList();let u=i-1;for(;u>0;){const g=d[u].value;if(a&&De.test(g)||!a&&r.test(g))o++,u--;else break}let h=i+1;for(;h<d.length;){const g=d[h].value;if(a&&De.test(g)||!a&&r.test(g))l++,h++;else break}}const R=i-o-1;return R<0?null:{startIndex:R,endIndex:i+l}}function Ps(s,t){const e=s.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(i.isImage&&i.isDirectHit){const l=e.getElementList(),a=e.getEventBus(),R=l[i.index];if(a.isSubscribe("imageDblclick")&&a.emit("imageDblclick",{evt:t,element:R}),R.formInput){const d=Reflect.get(window,"editor");if(console.log("curElement",R),R.formInput&&R.formInput.type==="checkbox"){d.showFormCheckboxConfig(R);return}if(R.formInput&&R.formInput.type==="radio"){d.showformRadioConfig(R);return}d.showFormInputConfig(R);return}if(R.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&!~i.index&&i.zone){e.getZone().setZone(i.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((i.isCheckbox||i.isRadio)&&i.isDirectHit)return;const r=e.getRange(),o=zn(s)||Ts(s);!o||(r.setRange(o.startIndex,o.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),r.setRangeStyle())}function Ms(s){var L,T;const t=s.getDraw(),e=t.getControl();if(e.getActiveControl()&&e.selectValue())return;const i=t.getPosition().getCursorPosition();if(!i)return;const{index:r}=i,o=t.getElementList();let l=0,a=0,R=r-1;for(;R>0;){const M=o[R],P=o[R-1];if(M.value===y&&!M.listWrap||M.listId!==(P==null?void 0:P.listId)||M.titleId!==(P==null?void 0:P.titleId))break;l++,R--}let d=r+1;for(;d<o.length;){const M=o[d],P=o[d+1];if(M.value===y&&!M.listWrap||M.listId!==(P==null?void 0:P.listId)||M.titleId!==(P==null?void 0:P.titleId))break;a++,d++}const u=t.getRange();let h=r-l-1;if(((L=o[h])==null?void 0:L.value)!==y&&(h-=1),h<0)return;let g=r+a+1;(((T=o[g])==null?void 0:T.value)===y||g>o.length-1)&&(g-=1),u.setRange(h,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}var $n={dblclick:Ps,threeClick:Ms};function Os(s){s.isComposing=!0}function Ss(s,t){s.isComposing=!1;const e=s.getDraw();if(t.data)ki?setTimeout(()=>{s.compositionInfo&&ln(t.data,s)},1):s.compositionInfo&&ln(t.data,s);else{_n(s);const i=e.getRange(),{endIndex:r}=i.getRange();e.render({curIndex:r,isSubmitHistory:!1})}e.getCursor().clearAgentDomValue()}var jn={compositionstart:Os,compositionend:Ss};function Xs(s,t){var X;const e=t.getDraw();if(e.isReadonly())return;s.preventDefault();const i=e.getPageContainer();if(!Se(s.target,I=>I===i,!0))return;const l=s.target.dataset.index;l&&e.setPageNo(Number(l));const a=e.getPosition(),R=a.adjustPositionContext({x:s.offsetX,y:s.offsetY});if(!R)return;const{isTable:d,tdValueIndex:u,index:h}=R,g=a.getPositionList(),L=d?u:h;~h&&(e.getRange().setRange(L,L),a.setCursorPosition(g[L]));const T=e.getCursor(),{cursor:{dragColor:M,dragWidth:P,dragFloatImageDisabled:O}}=e.getOptions();if(O){const I=(X=t.cacheElementList)==null?void 0:X[t.cacheRange.startIndex];if((I==null?void 0:I.type)===c.ElementType.IMAGE&&(I.imgDisplay===c.ImageDisplay.FLOAT_TOP||I.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM||I.imgDisplay===c.ImageDisplay.SURROUND))return}T.drawCursor({width:P,color:M,isBlink:!1,isFocus:!1})}var Is={dragover:Xs};class Ns{constructor(t){this.draw=t,this.pageContainer=t.getPageContainer(),this.pageList=t.getPageList(),this.range=this.draw.getRange(),this.position=this.draw.getPosition(),this.isAllowSelection=!1,this.isComposing=!1,this.compositionInfo=null,this.isAllowDrag=!1,this.isAllowDrop=!1,this.cacheRange=null,this.cacheElementList=null,this.cachePositionList=null,this.cachePositionContext=null,this.mouseDownStartPosition=null}getDraw(){return this.draw}register(){this.pageContainer.addEventListener("click",this.click.bind(this)),this.pageContainer.addEventListener("mousedown",this.mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this.mouseup.bind(this)),this.pageContainer.addEventListener("mouseleave",this.mouseleave.bind(this)),this.pageContainer.addEventListener("mousemove",this.mousemove.bind(this)),this.pageContainer.addEventListener("dblclick",this.dblclick.bind(this)),this.pageContainer.addEventListener("dragover",this.dragover.bind(this)),this.pageContainer.addEventListener("drop",this.drop.bind(this)),Di(this.pageContainer,this.threeClick.bind(this))}setIsAllowSelection(t){this.isAllowSelection=t,t||this.applyPainterStyle()}setIsAllowDrag(t){this.isAllowDrag=t,this.isAllowDrop=t}clearPainterStyle(){this.pageList.forEach(t=>{t.style.cursor="text"}),this.draw.setPainterStyle(null)}applyPainterStyle(){const t=this.draw.getPainterStyle();if(!t||this.draw.isReadonly()||this.draw.isDisabled())return;let n=this.range.getSelection();if(!n){const o=zn(this);o&&(n=this.draw.getElementList().slice(o.startIndex+1,o.endIndex+1))}if(!n)return;const i=Object.keys(t);n.forEach(o=>{i.forEach(l=>{const a=l;Reflect.set(o,a,t[a])})}),this.draw.render({isSetCursor:!1});const r=this.draw.getPainterOptions();(!r||!r.isDblclick)&&this.clearPainterStyle()}selectAll(){if(this.position.getPositionContext().isTable)this.draw.getTableOperate().tableSelectAll();else{const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}}mousemove(t){ns(t,this)}mousedown(t){qo(t,this)}click(){Bi&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){ts(t,this)}mouseleave(t){es(t,this)}keydown(t){hs(t,this)}dblclick(t){$n.dblclick(this,t)}threeClick(){$n.threeClick(this)}input(t){ln(t,this)}async cut(){await us(this)}async copy(t){await gs(this,t)}compositionstart(){jn.compositionstart(this)}compositionend(t){jn.compositionend(this,t)}drop(t){Ls(t,this)}dragover(t){Is.dragover(t,this)}}const qn={PAGE_SCALE:"pageScale"};class fs{constructor(t,e){this.clearSideEffect=n=>{if(!this.cursor)return;const i=(n==null?void 0:n.composedPath()[0])||n.target,r=this.draw.getPageList();if(Se(i,a=>r.includes(a),!0))return;if(Se(i,a=>!!a&&a.nodeType===1&&!!a.getAttribute(Kt),!0)){this.watchCursorActive();return}this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker(),this.imageParticle.destroyFloatImage()},this.setCanvasEventAbility=()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)},this.setPageScale=n=>{if(this.options.shortcutDisableKeys.includes(qn.PAGE_SCALE)||!n.ctrlKey)return;n.preventDefault();const{scale:i}=this.options;if(n.deltaY<0){const r=i*10+1;r<=30&&this.draw.setPageScale(r/10)}else{const r=i*10-1;r>=5&&this.draw.setPageScale(r/10)}},this._handleVisibilityChange=()=>{if(document.visibilityState==="visible"){const n=this.range.getRange(),i=!!~n.startIndex&&!!~n.endIndex&&n.startIndex===n.endIndex;this.range.replaceRange(n),this.draw.render({isSetCursor:i,isCompute:!1,isSubmitHistory:!1,curIndex:n.startIndex})}},this._handleDprChange=()=>{this.draw.setPageDevicePixel()},this.draw=t,this.options=t.getOptions(),this.canvasEvent=e,this.cursor=null,this.range=t.getRange(),this.previewer=t.getPreviewer(),this.tableTool=t.getTableTool(),this.hyperlinkParticle=t.getHyperlinkParticle(),this.dateParticle=t.getDateParticle(),this.imageParticle=t.getImageParticle(),this.control=t.getControl(),this.dprMediaQueryList=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)}register(){this.cursor=this.draw.getCursor(),this.addEvent()}addEvent(){window.addEventListener("blur",this.clearSideEffect),document.addEventListener("mousedown",this.clearSideEffect),document.addEventListener("mouseup",this.setCanvasEventAbility),document.addEventListener("wheel",this.setPageScale,{passive:!1}),document.addEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.addEventListener("change",this._handleDprChange)}removeEvent(){window.removeEventListener("blur",this.clearSideEffect),document.removeEventListener("mousedown",this.clearSideEffect),document.removeEventListener("mouseup",this.setCanvasEventAbility),document.removeEventListener("wheel",this.setPageScale),document.removeEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.removeEventListener("change",this._handleDprChange)}watchCursorActive(){!this.range.getIsCollapsed()||setTimeout(()=>{var t,e;(t=this.cursor)!=null&&t.getAgentIsActive()||(e=this.cursor)==null||e.drawCursor({isFocus:!1,isBlink:!1})})}}class ms{constructor(t){this.undoStack=[],this.redoStack=[],this.maxRecordCount=t.getOptions().historyMaxRecordCount+1}undo(){if(this.undoStack.length>1){const t=this.undoStack.pop();this.redoStack.push(t),this.undoStack.length&&this.undoStack[this.undoStack.length-1]()}}redo(){if(this.redoStack.length){const t=this.redoStack.pop();this.undoStack.push(t),t()}}execute(t){for(this.undoStack.push(t),this.redoStack.length&&(this.redoStack=[]);this.undoStack.length>this.maxRecordCount;)this.undoStack.shift()}isCanUndo(){return this.undoStack.length>1}isCanRedo(){return!!this.redoStack.length}isStackEmpty(){return!this.undoStack.length&&!this.redoStack.length}recovery(){this.undoStack=[],this.redoStack=[]}popUndo(){return this.undoStack.pop()}}class Fs{constructor(t){this.positionList=[],this.floatPositionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.eventBus=t.getEventBus(),this.options=t.getOptions()}getFloatPositionList(){return this.floatPositionList}getTablePositionList(t){const{index:e,trIndex:n,tdIndex:i}=this.positionContext;return t[e].trList[n].tdList[i].positionList||[]}getPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalElementList()):this.getOriginalPositionList()}getMainPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalMainElementList()):this.positionList}getOriginalPositionList(){const t=this.draw.getZone();return t.isHeaderActive()?this.draw.getHeader().getPositionList():t.isFooterActive()?this.draw.getFooter().getPositionList():this.positionList}getOriginalMainPositionList(){return this.positionList}getSelectionPositionList(){const{startIndex:t,endIndex:e}=this.draw.getRange().getRange();return t===e?null:this.getPositionList().slice(t+1,e+1)}setPositionList(t){this.positionList=t}setFloatPositionList(t){this.floatPositionList=t}computePageRowPosition(t){const{positionList:e,rowList:n,pageNo:i,startX:r,startY:o,startRowIndex:l,startIndex:a,innerWidth:R,zone:d}=t,{scale:u,table:{tdPadding:h}}=this.options;let g=r,L=o,T=a;for(let M=0;M<n.length;M++){const P=n[M];if(!P.isSurround){const I=P.width+(P.offsetX||0);P.rowFlex===c.RowFlex.CENTER?g+=(R-I)/2:P.rowFlex===c.RowFlex.RIGHT&&(g+=R-I)}g+=P.offsetX||0,L+=P.offsetY||0;const O=g,X=L;for(let I=0;I<P.elementList.length;I++){const f=P.elementList[I],S=f.metrics,N=!f.hide&&(f.imgDisplay!==c.ImageDisplay.INLINE&&f.type===c.ElementType.IMAGE||f.type===c.ElementType.LATEX)?P.ascent-S.height:P.ascent;f.left&&(g+=f.left),f.translateX&&(g+=f.translateX*u);const m={pageNo:i,index:T,value:f.value,rowIndex:l+M,rowNo:M,metrics:S,left:f.left||0,ascent:N,lineHeight:P.height,isFirstLetter:I===0,isLastLetter:I===P.elementList.length-1,coordinate:{leftTop:[g,L],leftBottom:[g,L+P.height],rightTop:[g+S.width,L],rightBottom:[g+S.width,L+P.height]}};if(f.imgDisplay===c.ImageDisplay.SURROUND||f.imgDisplay===c.ImageDisplay.FLOAT_TOP||f.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM){const W=e[e.length-1];W&&(m.metrics=W.metrics,m.coordinate=W.coordinate),f.imgFloatPosition||(f.imgFloatPosition={x:g,y:L,pageNo:i}),this.floatPositionList.push({pageNo:i,element:f,position:m,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:T,zone:d})}if(e.push(m),T++,g+=S.width,f.type===c.ElementType.TABLE&&!f.hide){const W=h[1]+h[3],Z=h[0]+h[2];for(let U=0;U<f.trList.length;U++){const Q=f.trList[U];for(let F=0;F<Q.tdList.length;F++){const E=Q.tdList[F];E.positionList=[];const V=E.rowList,Y=this.computePageRowPosition({positionList:E.positionList,rowList:V,pageNo:i,startRowIndex:0,startIndex:0,startX:(E.x+h[3])*u+O+(f.translateX||0)*u,startY:(E.y+h[0])*u+X,innerWidth:(E.width-W)*u,isTable:!0,index:T-1,tdIndex:F,trIndex:U,zone:d});if(E.verticalAlign===c.VerticalAlign.MIDDLE||E.verticalAlign===c.VerticalAlign.BOTTOM){const K=V.reduce((H,w)=>H+w.height,0),b=(E.height-Z)*u-K,p=E.verticalAlign===c.VerticalAlign.MIDDLE?b/2:b;Math.floor(p)>0&&E.positionList.forEach(H=>{const{coordinate:{leftTop:w,leftBottom:D,rightBottom:J,rightTop:v}}=H;w[1]+=p,D[1]+=p,J[1]+=p,v[1]+=p})}g=Y.x,L=Y.y}}g=O,L=X}}g=r,L+=P.height}return{x:g,y:L,index:T}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),n=this.draw.getMargins(),i=n[3],o=this.draw.getHeader().getExtraHeight(),l=n[0]+o;let a=0;for(let R=0;R<e.length;R++){const d=e[R];if(!(d!=null&&d.length))continue;const u=d[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:d,pageNo:R,startRowIndex:a,startIndex:u,startX:i,startY:l,innerWidth:t}),a+=d.length}}computeRowPosition(t){const{row:e,innerWidth:n}=t,i=[];return this.computePageRowPosition({positionList:i,innerWidth:n,rowList:[_(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),i}setCursorPosition(t){this.cursorPosition=t}getCursorPosition(){return this.cursorPosition}getPositionContext(){return this.positionContext}setPositionContext(t){this.eventBus.emit("positionContextChange",{value:t,oldValue:this.positionContext}),this.positionContext=t}getPositionByXY(t){var T,M,P,O,X;const{x:e,y:n,isTable:i}=t;let{elementList:r,positionList:o}=t;r||(r=this.draw.getOriginalElementList()),o||(o=this.getOriginalPositionList());const l=this.draw.getZone(),a=(T=t.pageNo)!=null?T:this.draw.getPageNo(),R=l.isMainActive(),d=R?a:0;if(!i){const I=this.getFloatPositionByXY({...t,imgDisplays:[c.ImageDisplay.FLOAT_TOP,c.ImageDisplay.SURROUND]});if(I)return I}for(let I=0;I<o.length;I++){const{index:f,pageNo:S,left:N,isFirstLetter:m,coordinate:{leftTop:W,rightTop:Z,leftBottom:U}}=o[I];if(d===S){if(S>d)break;if(W[0]-N<=e&&Z[0]>=e&&W[1]<=n&&U[1]>=n){let Q=I;const F=r[I];if(F.type===c.ElementType.TABLE)for(let V=0;V<F.trList.length;V++){const Y=F.trList[V];for(let K=0;K<Y.tdList.length;K++){const b=Y.tdList[K],p=this.getPositionByXY({x:e,y:n,td:b,pageNo:a,tablePosition:o[I],isTable:!0,elementList:b.value,positionList:b.positionList});if(~p.index){const{index:H,hitLineStartIndex:w}=p,D=b.value[H];return{index:f,isCheckbox:p.isCheckbox||D.type===c.ElementType.CHECKBOX||D.controlComponent===c.ControlComponent.CHECKBOX,isRadio:D.type===c.ElementType.RADIO||D.controlComponent===c.ControlComponent.RADIO,isControl:!!D.controlId,isImage:p.isImage,isDirectHit:p.isDirectHit,isTable:!0,tdIndex:K,trIndex:V,tdValueIndex:H,tdId:b.id,trId:Y.id,tableId:F.id,hitLineStartIndex:w}}}}if(F.type===c.ElementType.IMAGE||F.type===c.ElementType.LATEX)return{index:Q,isDirectHit:!0,isImage:!0};if(F.type===c.ElementType.CHECKBOX||F.controlComponent===c.ControlComponent.CHECKBOX)return{index:Q,isDirectHit:!0,isCheckbox:!0};if(F.type===c.ElementType.LABEL)return{index:Q,isDirectHit:!0,isLabel:!0};if(F.type===c.ElementType.TAB&&F.listStyle===c.ListStyle.CHECKBOX){let V=Q-1;for(;V>0;){const Y=r[V];if(Y.value===y&&Y.listStyle===c.ListStyle.CHECKBOX)break;V--}return{index:V,isDirectHit:!0,isCheckbox:!0}}if(F.type===c.ElementType.RADIO||F.controlComponent===c.ControlComponent.RADIO)return{index:Q,isDirectHit:!0,isRadio:!0};let E;if(r[f].value!==y){const V=Z[0]-W[0];e<W[0]+V/2&&(Q=I-1,m&&(E=I))}return{isDirectHit:!0,hitLineStartIndex:E,index:Q,isControl:!!F.controlId}}}}if(!i){const I=this.getFloatPositionByXY({...t,imgDisplays:[c.ImageDisplay.FLOAT_BOTTOM]});if(I)return I}let u=!1,h=-1,g;if(i){const{scale:I}=this.options,{td:f,tablePosition:S}=t;if(f&&S){const{leftTop:N}=S.coordinate,m=f.x*I+N[0],W=f.y*I+N[1],Z=f.width*I,U=f.height*I;if(!(m<e&&e<m+Z&&W<n&&n<W+U))return{index:h}}}const L=o.filter(I=>I.isLastLetter&&I.pageNo===d);for(let I=0;I<L.length;I++){const{index:f,rowNo:S,coordinate:{leftTop:N,leftBottom:m}}=L[I];if(n>N[1]&&n<=m[1]){const W=o.findIndex(F=>F.pageNo===d&&F.rowNo===S),Z=r[W],U=o[W],Q=Z.listStyle===c.ListStyle.CHECKBOX?this.draw.getMargins()[3]:U.coordinate.leftTop[0];if(e<Q)~W?U.value===y?h=W:(h=W-1,g=W):h=f;else{if(Z.listStyle===c.ListStyle.CHECKBOX&&e<N[0])return{index:W,isDirectHit:!0,isCheckbox:!0};h=f}u=!0;break}}if(!u){if(this.draw.getIsPagingMode()){const f=this.draw.getHeader(),S=f.getHeight(),N=f.getHeaderTop()+S,m=this.draw.getFooter(),Z=this.draw.getHeight()-(m.getFooterBottom()+m.getHeight());if(R){if(n<N)return{index:-1,zone:c.EditorZone.HEADER};if(n>Z)return{index:-1,zone:c.EditorZone.FOOTER}}else if(n<=Z&&n>=N)return{index:-1,zone:c.EditorZone.MAIN}}const I=this.draw.getMargins();if(n<=I[0])for(let f=0;f<o.length;f++){const S=o[f];if(S.pageNo!==d||S.rowNo!==0)continue;const{leftTop:N,rightTop:m}=S.coordinate;if(e<=I[3]||e>=N[0]&&e<=m[0]||((M=o[f+1])==null?void 0:M.rowNo)!==0)return{index:S.index}}else{const f=L[L.length-1];if(f){const S=f.rowNo;for(let N=0;N<o.length;N++){const m=o[N];if(m.pageNo!==d||m.rowNo!==S)continue;const{leftTop:W,rightTop:Z}=m.coordinate;if(e<=I[3]||e>=W[0]&&e<=Z[0]||((P=o[N+1])==null?void 0:P.rowNo)!==S)return{index:m.index}}}}return{index:((O=L[L.length-1])==null?void 0:O.index)||o.length-1}}return{hitLineStartIndex:g,index:h,isControl:!!((X=r[h])!=null&&X.controlId)}}getFloatPositionByXY(t){var l;const{x:e,y:n}=t,i=(l=t.pageNo)!=null?l:this.draw.getPageNo(),r=this.draw.getZone().getZone(),{scale:o}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:R,element:d,isTable:u,index:h,trIndex:g,tdIndex:L,tdValueIndex:T,zone:M,pageNo:P}=this.floatPositionList[a];if(i===P&&d.type===c.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!M||M===r)){const O=d.imgFloatPosition,X=O.x*o,I=O.y*o,f=d.width*o,S=d.height*o;if(e>=X&&e<=X+f&&n>=I&&n<=I+S)return u?{index:h,isDirectHit:!0,isImage:!0,isTable:u,trIndex:g,tdIndex:L,tdValueIndex:T,tdId:d.tdId,trId:d.trId,tableId:d.tableId}:{index:R.index,isDirectHit:!0,isImage:!0}}}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==c.EditorMode.READONLY){const{index:M,isTable:P,trIndex:O,tdIndex:X,tdValueIndex:I}=e,f=this.draw.getControl(),{newIndex:S}=f.moveCursor({index:M,isTable:P,trIndex:O,tdIndex:X,tdValueIndex:I});P?e.tdValueIndex=S:e.index=S}const{index:n,isCheckbox:i,isRadio:r,isControl:o,isImage:l,isLabel:a,isDirectHit:R,isTable:d,trIndex:u,tdIndex:h,tdId:g,trId:L,tableId:T}=e;return this.setPositionContext({isTable:d||!1,isCheckbox:i||!1,isRadio:r||!1,isControl:o||!1,isImage:l||!1,isLabel:a||!1,isDirectHit:R||!1,index:n,trIndex:u,tdIndex:h,tdId:g,trId:L,tableId:T}),e}setSurroundPosition(t){var u;const{scale:e}=this.options,{pageNo:n,row:i,rowElement:r,rowElementRect:o,surroundElementList:l,availableWidth:a}=t;let R=o.x,d=0;if(l.length&&!oe(r)&&!((u=r.control)!=null&&u.minWidth))for(let h=0;h<l.length;h++){const g=l[h],L=g.imgFloatPosition;if(L.pageNo!==n)continue;const T={...L,x:L.x*e,y:L.y*e,width:g.width*e,height:g.height*e};if(xi(o,T)){i.isSurround=!0;const M=T.width+T.x-o.x;if(r.left=M,i.width+=M,d+=M,R=T.x+T.width,i.width+r.metrics.width>a){r.left=0,i.width-=d;break}}}return{x:R,rowIncreaseWidth:d}}}class Ws{constructor(t){this.draw=t,this.options=t.getOptions(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.range={startIndex:-1,endIndex:-1},this.defaultStyle=null}getRange(){return this.range}clearRange(){this.setRange(-1,-1)}setDefaultStyle(t){t?this.defaultStyle={...this.defaultStyle,...t}:this.defaultStyle=null}getDefaultStyle(){return this.defaultStyle}getRangeAnchorStyle(t,e){const n=pe(t,e);return n?{...n,...this.defaultStyle}:null}getIsRangeChange(t,e,n,i,r,o,l){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==n||this.range.startTdIndex!==i||this.range.endTdIndex!==r||this.range.startTrIndex!==o||this.range.endTrIndex!==l}getIsCollapsed(){const{startIndex:t,endIndex:e}=this.range;return t===e}getIsSelection(){const{startIndex:t,endIndex:e}=this.range;return!~t&&!~e?!1:t!==e}getSelection(){var i;const{startIndex:t,endIndex:e}=this.range;if(t===e)return null;const n=this.draw.getElementList();return n.slice(((i=n[t])==null?void 0:i.value)===y?t:t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let n=0;n<t.length;n++){const i=t[n];for(let r=0;r<i.length;r++){const o=i[r];e.push(...o.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||Ut.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Ut.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=new Map;for(let r=t;r<e+1;r++){const{pageNo:o,rowNo:l}=n[r],a=i.get(o);a?a.has(l)||a.add(l):i.set(o,new Set([l]))}return i}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:n}=this.range;if(!~t&&!~e)return null;if(n)return this.getSelectionElementList();const i=this.getRangeRow();if(!i)return null;const r=this.position.getPositionList(),o=this.draw.getElementList(),l=[];for(let a=0;a<r.length;a++){const R=r[a],d=i.get(R.pageNo);!d||d.has(R.rowNo)&&l.push(o[a])}return l}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=this.draw.getElementList(),r=new Map;let o=t;for(;o>=0;){const{pageNo:R,rowNo:d}=n[o];let u=r.get(R);u||(u=[],r.set(R,u)),u.includes(d)||u.unshift(d);const h=i[o],g=i[o-1];if(h.value===y&&!h.listWrap||h.listId!==(g==null?void 0:g.listId)||h.titleId!==(g==null?void 0:g.titleId))break;o--}const l=t===e;if(!l){let R=t+1;for(;R<e;){const{pageNo:d,rowNo:u}=n[R];let h=r.get(d);h||(h=[],r.set(d,h)),h.includes(u)||h.push(u),R++}}let a=e;for(l&&i[t].value===y&&(a+=1);a<n.length;){const R=i[a],d=i[a+1];if(R.value===y&&!R.listWrap||R.listId!==(d==null?void 0:d.listId)||R.titleId!==(d==null?void 0:d.titleId))break;const{pageNo:u,rowNo:h}=n[a];let g=r.get(u);g||(g=[],r.set(u,g)),g.includes(h)||g.push(h),a++}return r}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let n=-1;const i=[],r=this.getRangeParagraph();if(!r)return null;const o=this.draw.getElementList(),l=this.position.getPositionList();for(let a=0;a<l.length;a++){const R=l[a],d=r.get(R.pageNo);!d||d.includes(R.rowNo)&&(~n||(n=R.index),i.push(o[a]))}return i.length?{elementList:i,startIndex:n}:null}getRangeParagraphElementList(){var t;return((t=this.getRangeParagraphInfo())==null?void 0:t.elementList)||null}getRangeTableElement(){const t=this.position.getPositionContext();return t.isTable?this.draw.getOriginalElementList()[t.index]:null}getIsSelectAll(){const t=this.draw.getElementList(),{startIndex:e,endIndex:n}=this.range;return e===0&&t.length-1===n&&!this.position.getPositionContext().isTable}getIsPointInRange(t,e){const{startIndex:n,endIndex:i}=this.range,r=this.position.getPositionList();for(let o=n+1;o<=i&&r[o];o++){const{coordinate:{leftTop:a,rightBottom:R}}=r[o];if(t>=a[0]&&t<=R[0]&&e>=a[1]&&e<=R[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),n=new Map;for(const r of e){const o=n.get(r.groupId);if(o)o.endIndex+=1;else{const{type:l,groupId:a,tableId:R,index:d,tdIndex:u,trIndex:h}=r,g={startIndex:d,endIndex:d};l===Gt.TABLE&&(g.tableId=R,g.startTdIndex=u,g.endTdIndex=u,g.startTrIndex=h,g.endTrIndex=h),n.set(a,g)}}const i=[];return n.forEach(r=>{i.push(r)}),i}getIsCanInput(){var o;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.draw.getElementList(),i=n[t];if(t===e)return(i.controlComponent!==c.ControlComponent.PRE_TEXT||((o=n[t+1])==null?void 0:o.controlComponent)!==c.ControlComponent.PRE_TEXT)&&i.controlComponent!==c.ControlComponent.POST_TEXT;const r=n[e];return!i.controlId&&!r.controlId||(!i.controlId||i.controlComponent===c.ControlComponent.POSTFIX)&&(!r.controlId||r.controlComponent===c.ControlComponent.POSTFIX)||!!i.controlId&&r.controlId===i.controlId&&r.controlComponent!==c.ControlComponent.PRE_TEXT&&r.controlComponent!==c.ControlComponent.POST_TEXT&&r.controlComponent!==c.ControlComponent.POSTFIX}setRange(t,e,n,i,r,o,l){this.getIsRangeChange(t,e,n,i,r,o,l)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=n,this.range.startTdIndex=i,this.range.endTdIndex=r,this.range.startTrIndex=o,this.range.endTrIndex=l,this.range.isCrossRowCol=!!(i||r||o||l),this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const R=this.draw.getControl();if(~t&&~e){const u=this.draw.getElementList()[t];if(u!=null&&u.controlId){R.initControl();return}}R.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}shrinkRange(){const{startIndex:t,endIndex:e}=this.range;t===e||!~t&&!~e||this.replaceRange({...this.range,startIndex:e})}setRangeStyle(){var E,V;const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:i,isCrossRowCol:r}=this.range;if(!~n&&!~i)return;let o;if(r){const Y=this.draw.getOriginalElementList(),K=this.position.getPositionContext();o=Y[K.index]}else{const Y=~i?i:0,K=this.draw.getElementList();o=this.getRangeAnchorStyle(K,Y)}if(!o)return;const l=this.getSelection()||[o],a=o.type||c.ElementType.TEXT,R=o.font||this.options.defaultFont,d=o.size||this.options.defaultSize,u=!~l.findIndex(Y=>!Y.bold),h=!~l.findIndex(Y=>!Y.italic),g=!~l.findIndex(Y=>{var K;return!Y.underline&&!((K=Y.control)!=null&&K.underline)}),L=!~l.findIndex(Y=>!Y.strikeout),T=o.color||null,M=o.highlight||null,P=o.rowFlex||null,O=(E=o.rowMargin)!=null?E:this.options.defaultRowMargin,X=o.dashArray||[],I=o.level||null,f=o.listType||null,S=o.listStyle||null,N=g&&o.textDecoration||null,m=!!this.draw.getPainterStyle(),W=this.historyManager.isCanUndo(),Z=this.historyManager.isCanRedo(),U=o.groupIds||null,Q=(V=o.extension)!=null?V:null,F={type:a,undo:W,redo:Z,painter:m,font:R,size:d,bold:u,italic:h,underline:g,strikeout:L,color:T,highlight:M,rowFlex:P,rowMargin:O,dashArray:X,level:I,listType:f,listStyle:S,groupIds:U,textDecoration:N,extension:Q};t&&t(F),e&&this.eventBus.emit("rangeStyleChange",F)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const n=this.options.defaultFont,i=this.options.defaultSize,r=this.options.defaultRowMargin,o=!!this.draw.getPainterStyle(),l=this.historyManager.isCanUndo(),a=this.historyManager.isCanRedo(),R={type:null,undo:l,redo:a,painter:o,font:n,size:i,bold:!1,italic:!1,underline:!1,strikeout:!1,color:null,highlight:null,rowFlex:null,rowMargin:r,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,extension:null};t&&t(R),e&&this.eventBus.emit("rangeStyleChange",R)}shrinkBoundary(t={}){const e=t.elementList||this.draw.getElementList(),n=t.range||this.getRange(),{startIndex:i,endIndex:r}=n;if(!~i&&!~r)return;const o=e[i],l=e[r];if(i===r){if(o.controlComponent===c.ControlComponent.PLACEHOLDER){let a=i-1;for(;a>0;){const R=e[a];if(R.controlId!==o.controlId||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT){n.startIndex=a,n.endIndex=a;break}a--}}}else{if(o.controlComponent===c.ControlComponent.PLACEHOLDER||l.controlComponent===c.ControlComponent.PLACEHOLDER){let a=r-1;for(;a>0;){const R=e[a];if(R.controlId!==l.controlId||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT){n.startIndex=a,n.endIndex=a;return}a--}}if(o.controlComponent===c.ControlComponent.PREFIX){let a=i+1;for(;a<e.length;){const R=e[a];if(R.controlId!==o.controlId||R.controlComponent===c.ControlComponent.VALUE){n.startIndex=a-1;break}else if(R.controlComponent===c.ControlComponent.PLACEHOLDER){n.startIndex=a-1,n.endIndex=a-1;return}a++}}if(l.controlComponent!==c.ControlComponent.VALUE){let a=i-1;for(;a>0;){const R=e[a];if(R.controlId!==o.controlId||R.controlComponent===c.ControlComponent.VALUE){n.startIndex=a;break}else if(R.controlComponent===c.ControlComponent.PLACEHOLDER){n.startIndex=a,n.endIndex=a;return}a--}}}}render(t,e,n,i,r){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,n,i,r),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(y,"g"),""):""}}class ps{constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,n,i){t.save(),t.fillStyle=e,t.fillRect(0,0,n,i),t.restore()}_drawImage(t,e,n,i){const{background:r,scale:o}=this.options;if(r.size===c.BackgroundSize.CONTAIN){const l=e.width*o,a=e.height*o;if(!r.repeat||r.repeat===c.BackgroundRepeat.NO_REPEAT)t.drawImage(e,0,0,l,a);else{let R=0,d=0;const u=r.repeat===c.BackgroundRepeat.REPEAT||r.repeat===c.BackgroundRepeat.REPEAT_X?Math.ceil(n*o/l):1,h=r.repeat===c.BackgroundRepeat.REPEAT||r.repeat===c.BackgroundRepeat.REPEAT_Y?Math.ceil(i*o/a):1;for(let g=0;g<u;g++){for(let L=0;L<h;L++)t.drawImage(e,R,d,l,a),d+=a;d=0,R+=l}}}else t.drawImage(e,0,0,n*o,i*o)}_renderBackgroundImage(t,e,n){const{background:i}=this.options,r=this.imageCache.get(i.image);if(r)this._drawImage(t,r,e,n);else{const o=new Image;o.setAttribute("crossOrigin","Anonymous"),o.src=i.image,o.onload=()=>{this.imageCache.set(i.image,o),this._drawImage(t,o,e,n),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:n,color:i,applyPageNumbers:r}}=this.options;if(n&&(!(r!=null&&r.length)||r.includes(e))){const{width:o,height:l}=this.options;this._renderBackgroundImage(t,o,l)}else{const o=this.draw.getCanvasWidth(e),l=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,i,o,l)}}}class an{constructor(){this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillDecorationStyle=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,n,i,r,o,l){const a=!this.fillRect.width;if(!a&&(this.fillColor!==o||this.fillDecorationStyle!==l)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,n,i,r,o,l);return}a&&(this.fillRect.x=e,this.fillRect.y=n),r&&this.fillRect.height<r&&(this.fillRect.height=r),this.fillRect.width+=i,this.fillColor=o,this.fillDecorationStyle=l}}class Vs extends an{constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:n,y:i,width:r,height:o}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(n,i,r,o),t.restore(),this.clearFillInfo()}}class Ys{constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:n,pageMode:i}=this.options,r=this.draw.getWidth(),o=i===c.PageMode.CONTINUITY?this.draw.getCanvasHeight(e)/this.draw.getPagePixelRatio():this.draw.getHeight(),l=this.draw.getMargins(),a=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=n,t.beginPath();const R=[l[3],l[0]],d=[r-l[1],l[0]],u=[l[3],o-l[2]],h=[r-l[1],o-l[2]];t.moveTo(R[0]-a,R[1]),t.lineTo(...R),t.lineTo(R[0],R[1]-a),t.moveTo(d[0]+a,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]-a),t.moveTo(u[0]-a,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]+a),t.moveTo(h[0]+a,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+a),t.stroke(),t.restore()}}class Zs{constructor(t){this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.searchNavigateIndex=null,this.searchOptions=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t,e){this.searchKeyword=t,this.searchNavigateIndex=null,this.searchOptions=e||null}searchNavigatePre(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex-1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===n)return null;this.searchNavigateIndex=this.searchMatchList.length-1-(this.searchKeyword.length-1)}}return this.searchNavigateIndex}searchNavigateNext(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex+1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===n)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:n,rightTop:i},pageNo:r}=t,o=this.draw.getHeight(),l=this.draw.getPageGap(),a=r*(o+l),R=document.createElement("div");R.style.position="absolute";const d=50;R.style.width=`${i[0]-e[0]+d}px`,R.style.height=`${n[1]-e[1]+d}px`,R.style.left=`${e[0]}px`,R.style.top=`${e[1]+a}px`,this.draw.getContainer().append(R),R.scrollIntoView(!1),R.remove()}getSearchNavigateIndexList(){return this.searchNavigateIndex===null||!this.searchKeyword?[]:new Array(this.searchKeyword.length).fill(this.searchNavigateIndex).map((t,e)=>t+e)}getSearchMatchList(){return this.searchMatchList}getSearchNavigateInfo(){if(!this.searchKeyword||!this.searchMatchList.length)return null;const t=this.searchNavigateIndex!==null?this.searchNavigateIndex/this.searchKeyword.length+1:0;let e=0,n=null;for(let i=0;i<this.searchMatchList.length;i++){const r=this.searchMatchList[i];n!==r.groupId&&(n=r.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const{isRegEnable:n=!1,isIgnoreCase:i=!0}=this.searchOptions||{},r=i?t.toLocaleLowerCase():t,o=[],l=[],a=e.length,R=[];for(let g=0;g<a;g++)e[g].type===c.ElementType.TABLE&&R.push(g);let d=0,u=0;for(;u<a-1;){const g=R.length?R[d]:a,L=e.slice(u,g);L.length&&l.push({index:u,type:Gt.PAGE,elementList:L});const T=e[g];T&&l.push({index:g,type:Gt.TABLE,elementList:[T]}),u=g+1,d++}function h(g,L,T,M){if(!g)return;let P=T.map(S=>{var N,m;return!S.type||Ut.includes(S.type)&&S.controlComponent!==c.ControlComponent.CHECKBOX&&S.controlComponent!==c.ControlComponent.RADIO&&!S.hide&&!((N=S.control)!=null&&N.hide)&&!((m=S.area)!=null&&m.hide)?S.value:y}).filter(Boolean).join("");i&&(P=P.toLocaleLowerCase());const O=[],X=n?new RegExp(g):g;let{index:I,length:f}=Wn(P,X);for(;I!==-1&&f!==0;){O.push({index:I,length:f});const S=Wn(P,X,I+f);I=S.index,f=S.length}for(let S=0;S<O.length;S++){const{index:N,length:m}=O[S],W=k();for(let Z=0;Z<m;Z++){const U=N+Z+((M==null?void 0:M.startIndex)||0);o.push({type:L,index:U,groupId:W,...M})}}}for(let g=0;g<l.length;g++){const L=l[g];if(L.type===Gt.TABLE){const T=L.elementList[0];for(let M=0;M<T.trList.length;M++){const P=T.trList[M];for(let O=0;O<P.tdList.length;O++){const X=P.tdList[O],I={tableId:T.id,tableIndex:L.index,trIndex:M,tdIndex:O,tdId:X.id};h(r,L.type,X.value,I)}}}else h(r,L.type,L.elementList,{startIndex:L.index})}return o}compute(t){var o;const e=((o=this.searchOptions)==null?void 0:o.isLimitSelection)&&!this.range.getIsCollapsed(),n=e?this.range.getSelectionElementList():this.draw.getOriginalElementList();if(!(n!=null&&n.length)||(this.searchMatchList=this.getMatchList(t,n),!e||!this.searchMatchList.length))return;const{startIndex:i}=this.range.getRange(),r=i+1;for(const l of this.searchMatchList)l.type===Gt.TABLE?l.tableIndex+=r:l.index+=r}render(t,e){var a,R;if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:n,searchMatchColor:i,searchNavigateMatchColor:r}=this.options,o=this.position.getOriginalPositionList(),l=this.draw.getOriginalElementList();t.save(),t.globalAlpha=n;for(let d=0;d<this.searchMatchList.length;d++){const u=this.searchMatchList[d];let h=null;if(u.type===Gt.TABLE){const{tableIndex:S,trIndex:N,tdIndex:m,index:W}=u;h=(R=(a=l[S])==null?void 0:a.trList[N].tdList[m])==null?void 0:R.positionList[W]}else h=o[u.index];if(!h)continue;const{coordinate:{leftTop:g,leftBottom:L,rightTop:T},pageNo:M}=h;if(M!==e)continue;if(this.getSearchNavigateIndexList().includes(d)){t.fillStyle=r;const S=this.searchMatchList[d-1];(!S||S.groupId!==u.groupId)&&this.searchNavigateScrollIntoView(h)}else t.fillStyle=i;const O=g[0],X=g[1],I=T[0]-g[0],f=L[1]-g[1];t.fillRect(O,X,I,f)}t.restore()}replace(t,e){var T,M,P,O;if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const r=e==null?void 0:e.index;if(He(r)){const X=[];i.forEach(I=>{const f=X[X.length-1];!f||f[0].groupId!==I.groupId?X.push([I]):f.push(I)}),i=X[r]}if(!(i!=null&&i.length))return;const o=this.draw.isDesignMode();let l=0,a=0,R="",d="",u=-1;const h=this.draw.getOriginalElementList();for(let X=0;X<i.length;X++){const I=i[X];if(I.type===Gt.TABLE){const{tableIndex:f,trIndex:S,tdIndex:N,index:m,tdId:W}=I;d&&W!==d&&(a=0),d=W;const Z=f+l,U=h[Z].trList[S].tdList[N].value,Q=m+a,F=U[Q];if(!o&&(((T=F==null?void 0:F.control)==null?void 0:T.deletable)===!1||((M=F==null?void 0:F.title)==null?void 0:M.deletable)===!1))continue;if(t===""){this.draw.spliceElementList(U,Q,1),a--,~u||(u=X);continue}if(R===I.groupId){this.draw.spliceElementList(U,Q,1),a--;continue}~u||(u=X);for(let E=0;E<t.length;E++){const V=t[E];E===0?F.value=V:(this.draw.spliceElementList(U,Q+E,0,[{...F,value:V}]),a++)}}else{const f=I.index+l,S=h[f];if(!o&&(((P=S==null?void 0:S.control)==null?void 0:P.deletable)===!1||((O=S==null?void 0:S.title)==null?void 0:O.deletable)===!1)||S.type===c.ElementType.CONTROL&&S.controlComponent!==c.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,f,1),l--,~u||(u=X);continue}if(~u||(u=X),R===I.groupId){this.draw.spliceElementList(h,f,1),l--;continue}for(let N=0;N<t.length;N++){const m=t[N];N===0?S.value=m:(this.draw.spliceElementList(h,f+N,0,[{...S,value:m}]),l++)}}R=I.groupId}if(!~u)return;const g=i[u],L=g.index+(t.length-1);if(g.type===Gt.TABLE){const{tableIndex:X,trIndex:I,tdIndex:f,index:S}=g,N=h[X].trList[I].tdList[f].value[S];this.position.setPositionContext({isTable:!0,index:X,trIndex:I,tdIndex:f,tdId:N.tdId,trId:N.trId,tableId:N.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(L,L),this.draw.render({curIndex:L})}}class Us extends an{constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{scale:e,strikeoutColor:n}=this.options,{x:i,y:r,width:o}=this.fillRect;t.save(),t.lineWidth=e,t.strokeStyle=n;const l=r+.5;t.beginPath(),t.moveTo(i,l),t.lineTo(i+o,l),t.stroke(),t.restore(),this.clearFillInfo()}}c.TextDecorationStyle=void 0,function(s){s.SOLID="solid",s.DOUBLE="double",s.DASHED="dashed",s.DOTTED="dotted",s.WAVY="wavy"}(c.TextDecorationStyle||(c.TextDecorationStyle={}));var se;(function(s){s.SOLID="solid",s.DASHED="dashed",s.DOTTED="dotted"})(se||(se={}));class Es extends an{constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,r){const o=e+i;switch(t.beginPath(),r){case se.DASHED:t.setLineDash([3,1]);break;case se.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(o,n),t.stroke()}_drawDouble(t,e,n,i){const o=e+i,l=n+3*this.options.scale;t.beginPath(),t.moveTo(e,n),t.lineTo(o,n),t.stroke(),t.beginPath(),t.moveTo(e,l),t.lineTo(o,l),t.stroke()}_drawWave(t,e,n,i){const{scale:r}=this.options,o=1.2*r,l=1/r,a=n+2*o;t.beginPath();for(let R=0;R<i;R++){const d=o*Math.sin(l*R);t.lineTo(e+R,a+d)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:i,y:r,width:o}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const l=Math.floor(r+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case c.TextDecorationStyle.WAVY:this._drawWave(t,i,l,o);break;case c.TextDecorationStyle.DOUBLE:this._drawDouble(t,i,l,o);break;case c.TextDecorationStyle.DASHED:this._drawLine(t,i,l,o,se.DASHED);break;case c.TextDecorationStyle.DOTTED:this._drawLine(t,i,l,o,se.DOTTED);break;default:this._drawLine(t,i,l,o);break}t.restore(),this.clearFillInfo()}}class Qs{constructor(t){this.draw=t,this.options=t.getOptions(),this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.cacheMeasureText=new Map}measureBasisWord(t,e){t.save(),t.font=e;const n=this.measureText(t,{value:Wi});return t.restore(),n}measureWord(t,e,n){const i=this.draw.getLetterReg();let r=0,o=null,l=n;for(;l<e.length;){const a=e[l];if(a.type&&a.type!==c.ElementType.TEXT||!i.test(a.value)){o=a;break}r+=this.measureText(t,a).width,l++}return{width:r,endElement:o}}measurePunctuationWidth(t,e){return!e||!Fi.includes(e.value)?0:(t.font=this.draw.getElementFont(e),this.measureText(t,e).width)}measureText(t,e){if(e.width){const o=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:o.actualBoundingBoxAscent,actualBoundingBoxDescent:o.actualBoundingBoxDescent,actualBoundingBoxLeft:o.actualBoundingBoxLeft,actualBoundingBoxRight:o.actualBoundingBoxRight,fontBoundingBoxAscent:o.fontBoundingBoxAscent,fontBoundingBoxDescent:o.fontBoundingBoxDescent}}const n=`${e.value}${t.font}`,i=this.cacheMeasureText.get(n);if(i)return i;const r=t.measureText(e.value);return this.cacheMeasureText.set(n,r),r}getBasisWordBoundingBoxAscent(t,e){return this.measureBasisWord(t,e).actualBoundingBoxAscent}complete(){this._render(),this.text=""}record(t,e,n,i){if(this.ctx=t,this.options.renderMode===c.RenderMode.COMPATIBILITY){this._setCurXY(n,i),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(n,i),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(n,i)),this.text+=e.value,this.curStyle=e.style,this.curColor=e.color}_setCurXY(t,e){this.curX=t,this.curY=e}_render(){!this.text||!~this.curX||!~this.curX||(this.ctx.save(),this.ctx.font=this.curStyle,this.ctx.fillStyle=this.curColor||this.options.defaultColor,this.ctx.fillText(this.text,this.curX,this.curY),this.ctx.restore())}}class re{constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const r=i===c.NumberType.CHINESE?yi(e):`${e}`;return t.replace(n,r)}render(t,e){const{scale:n,pageNumber:{size:i,font:r,color:o,rowFlex:l,numberType:a,format:R,startPageNo:d,fromPageNo:u}}=this.options;if(e<u)return;let h=R;const g=new RegExp(ue.PAGE_NO);g.test(h)&&(h=re.formatNumberPlaceholder(h,e+d-u,g,a));const L=new RegExp(ue.PAGE_COUNT);L.test(h)&&(h=re.formatNumberPlaceholder(h,this.draw.getPageCount()-u,L,a));const T=this.draw.getWidth(),M=this.draw.getHeight(),P=this.draw.getPageNumberBottom(),O=M-P;t.save(),t.fillStyle=o,t.font=`${i*n}px ${r}`;let X=0;const I=this.draw.getMargins(),{width:f}=t.measureText(h);l===c.RowFlex.CENTER?X=(T-f)/2:l===c.RowFlex.RIGHT?X=T-f-I[1]:X=I[3],t.fillText(h,X,O),t.restore()}}class Cs{constructor(t){this._observer=Qi(()=>{const{intersectionPageNo:e,visiblePageNoList:n}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(e),this.draw.setVisiblePageNoList(n)},150),this.draw=t,this.options=t.getOptions(),this.scrollContainer=this.getScrollContainer(),setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}getScrollContainer(){return this.options.scrollContainerSelector&&document.querySelector(this.options.scrollContainerSelector)||document}_addEvent(){this.scrollContainer.addEventListener("scroll",this._observer)}removeEvent(){this.scrollContainer.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),n=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,i=Math.min(e.bottom,n)-Math.max(e.top,0);return{intersectionHeight:i>0?i:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let n=0,i=0;for(let r=0;r<t.length;r++){const o=t[r],{intersectionHeight:l}=this.getElementVisibleInfo(o);if(i&&!l)break;l&&e.push(r),l>i&&(i=l,n=r)}return{intersectionPageNo:n,visiblePageNoList:e}}}class Ds{constructor(t){this.step=5,this.thresholdPoints=[70,40,10,20],this._mousedown=()=>{if(this.isMousedown=!0,this.clientWidth=this.selectionContainer instanceof Document?document.documentElement.clientWidth:this.selectionContainer.clientWidth,this.clientHeight=this.selectionContainer instanceof Document?document.documentElement.clientHeight:this.selectionContainer.clientHeight,!(this.selectionContainer instanceof Document)){const n=this.selectionContainer.getBoundingClientRect();this.containerRect=n}},this._mouseup=()=>{this.isMousedown=!1,this._stopMove()},this._mousemove=n=>{if(!this.isMousedown||this.rangeManager.getIsCollapsed())return;let{x:i,y:r}=n;this.containerRect&&(i=i-this.containerRect.x,r=r-this.containerRect.y),r<this.thresholdPoints[0]?this._startMove(dt.UP):this.clientHeight-r<=this.thresholdPoints[1]?this._startMove(dt.DOWN):i<this.thresholdPoints[2]?this._startMove(dt.LEFT):this.clientWidth-i<this.thresholdPoints[3]?this._startMove(dt.RIGHT):this._stopMove()},this.rangeManager=t.getRange();const{scrollContainerSelector:e}=t.getOptions();this.selectionContainer=e&&document.querySelector(e)||document,this.requestAnimationFrameId=null,this.isMousedown=!1,this.isMoving=!1,this.clientWidth=0,this.clientHeight=0,this.containerRect=null,this._addEvent()}_addEvent(){const t=this.selectionContainer;t.addEventListener("mousedown",this._mousedown),t.addEventListener("mousemove",this._mousemove),t.addEventListener("mouseup",this._mouseup),document.addEventListener("mouseleave",this._mouseup)}removeEvent(){const t=this.selectionContainer;t.removeEventListener("mousedown",this._mousedown),t.removeEventListener("mousemove",this._mousemove),t.removeEventListener("mouseup",this._mouseup),document.removeEventListener("mouseleave",this._mouseup)}_move(t){const e=this.selectionContainer instanceof Document?window:this.selectionContainer,n=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,i=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===dt.DOWN?e.scrollTo(n,i+this.step):t===dt.UP?e.scrollTo(n,i-this.step):t===dt.LEFT?e.scrollTo(n-this.step,i):e.scrollTo(n+this.step,i),this.requestAnimationFrameId=window.requestAnimationFrame(this._move.bind(this,t))}_startMove(t){this.isMoving||(this.isMoving=!0,this._move(t))}_stopMove(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=null,this.isMoving=!1)}}class bs{constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){var n;const e=_(t);for(let i=0;i<t.length;i++){const r=e[i];for(let o=r.tdList.length-1;o>=0;o--){const l=r.tdList[o],{rowspan:a,rowIndex:R,colIndex:d}=l,u=R+a-1;if(u!==o){const h=r.tdList.splice(o,1)[0];(n=e[u])==null||n.tdList.splice(d,0,h)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:r,startTdIndex:o,endTdIndex:l,startTrIndex:a,endTrIndex:R}=this.range.getRange(),h=this.draw.getOriginalElementList()[e].trList;if(!r)return[[h[n].tdList[i]]];let g=h[a].tdList[o],L=h[R].tdList[l];(g.x>L.x||g.y>L.y)&&([g,L]=[L,g]);const T=g.colIndex,M=L.colIndex+(L.colspan-1),P=g.rowIndex,O=L.rowIndex+(L.rowspan-1),X=[];for(let I=0;I<h.length;I++){const f=h[I],S=[];for(let N=0;N<f.tdList.length;N++){const m=f.tdList[N],W=m.colIndex,Z=m.rowIndex;W>=T&&W<=M&&Z>=P&&Z<=O&&S.push(m)}S.length&&X.push(S)}return X.length?X:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:i,width:r,height:o,isDrawFullBorder:l,borderExternalWidth:a}=t,{scale:R}=this.options,d=e.lineWidth;a&&(e.lineWidth=a*R),e.beginPath();const u=Math.round(n),h=Math.round(i);e.translate(.5,.5),l?e.rect(u,h,r,o):(e.moveTo(u,h+o),e.lineTo(u,h),e.lineTo(u+r,h)),e.stroke(),a&&(e.lineWidth=d),e.translate(-.5,-.5)}_drawSlash(t,e,n,i){var d,u;const{scale:r}=this.options;t.save();const o=e.width*r,l=e.height*r,a=Math.round(e.x*r+n),R=Math.round(e.y*r+i);(d=e.slashTypes)!=null&&d.includes(c.TdSlash.FORWARD)&&(t.moveTo(a+o,R),t.lineTo(a,R+l)),(u=e.slashTypes)!=null&&u.includes(c.TdSlash.BACK)&&(t.moveTo(a,R),t.lineTo(a+o,R+l)),t.stroke(),t.restore()}_drawBorder(t,e,n,i){var O,X,I,f,S,N;const{colgroup:r,trList:o,borderType:l,borderColor:a,borderWidth:R=1,borderExternalWidth:d}=e;if(!r||!o)return;const{scale:u,table:{defaultBorderColor:h}}=this.options,g=e.width*u,L=e.height*u,T=l===c.TableBorder.EMPTY,M=l===c.TableBorder.EXTERNAL,P=l===c.TableBorder.INTERNAL;t.save(),l===c.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=R*u,t.strokeStyle=a||h,!T&&!P&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:L,borderExternalWidth:d,isDrawFullBorder:M});for(let m=0;m<o.length;m++){const W=o[m];for(let Z=0;Z<W.tdList.length;Z++){const U=W.tdList[Z];if((O=U.slashTypes)!=null&&O.length&&this._drawSlash(t,U,n,i),!((X=U.borderTypes)!=null&&X.length)&&(T||M))continue;const Q=U.width*u,F=U.height*u,E=Math.round(U.x*u+n+Q),V=Math.round(U.y*u+i);if(t.translate(.5,.5),t.beginPath(),(I=U.borderTypes)!=null&&I.includes(c.TdBorder.TOP)&&(t.moveTo(E-Q,V),t.lineTo(E,V),t.stroke()),(f=U.borderTypes)!=null&&f.includes(c.TdBorder.RIGHT)&&(t.moveTo(E,V),t.lineTo(E,V+F),t.stroke()),(S=U.borderTypes)!=null&&S.includes(c.TdBorder.BOTTOM)&&(t.moveTo(E,V+F),t.lineTo(E-Q,V+F),t.stroke()),(N=U.borderTypes)!=null&&N.includes(c.TdBorder.LEFT)&&(t.moveTo(E-Q,V),t.lineTo(E-Q,V+F),t.stroke()),!T&&!M){if((!P||U.colIndex+U.colspan<r.length)&&(t.moveTo(E,V),t.lineTo(E,V+F),d&&d!==R&&U.colIndex+U.colspan===r.length)){const Y=t.lineWidth;t.lineWidth=d*u,t.stroke(),t.beginPath(),t.lineWidth=Y}if(!P||U.rowIndex+U.rowspan<o.length){const Y=d&&d!==R&&U.rowIndex+U.rowspan===o.length;if(Y&&(t.stroke(),t.beginPath()),t.moveTo(E,V+F),t.lineTo(E-Q,V+F),Y){const K=t.lineWidth;t.lineWidth=d*u,t.stroke(),t.beginPath(),t.lineWidth=K}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,i){const{trList:r}=e;if(!r)return;const{scale:o}=this.options;for(let l=0;l<r.length;l++){const a=r[l];for(let R=0;R<a.tdList.length;R++){const d=a.tdList[R];if(!d.backgroundColor)continue;t.save();const u=d.width*o,h=d.height*o,g=Math.round(d.x*o+n),L=Math.round(d.y*o+i);t.fillStyle=d.backgroundColor,t.fillRect(g,L,u,h),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,n)=>e+n.width,0)}getTableHeight(t){const e=t.trList;return e!=null&&e.length?this.getTdListByColIndex(e,0).reduce((n,i)=>n+i.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((n,i)=>n+i.rowspan,0)}getTdListByColIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const r=t[i].tdList;for(let o=0;o<r.length;o++){const l=r[o],a=l.colIndex,R=a+l.colspan-1;e>=a&&e<=R&&n.push(l)}}return n}getTdListByRowIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const r=t[i].tdList;for(let o=0;o<r.length;o++){const l=r[o],a=l.rowIndex,R=a+l.rowspan-1;e>=a&&e<=R&&n.push(l)}}return n}computeRowColInfo(t){const{colgroup:e,trList:n}=t;if(!e||!n)return;let i=0;for(let r=0;r<n.length;r++){const o=n[r],l=n.length-1===r;for(let a=0;a<o.tdList.length;a++){const R=o.tdList[a];let d=0;if(n.length>1&&r!==0){const P=o.tdList[a-1],O=P?P.colIndex+P.colspan:a;for(let X=O;X<e.length;X++)if(this.getRowCountByColIndex(n.slice(0,r),X)===r){d=X;let f=0;for(let S=0;S<X;S++)f+=e[S].width;i=f;break}}else{const P=o.tdList[a-1];P&&(d=P.colIndex+P.colspan)}let u=0;for(let P=0;P<R.colspan;P++)u+=e[P+d].width;let h=0;for(let P=0;P<R.rowspan;P++)h+=(n[P+r]||n[r]).height;const g=o.tdList.length-1===a;let L=l;if(!L&&R.rowspan>1){const P=n.length-1-r;L=R.rowspan-1===P}const T=l&&g;R.isLastRowTd=g,R.isLastColTd=L,R.isLastTd=T,R.x=i;let M=0;for(let P=0;P<r;P++){const O=n[P].tdList;for(let X=0;X<O.length;X++){const I=O[X];if(d>=I.colIndex&&d<I.colIndex+I.colspan){M+=I.height;break}}}R.y=M,R.width=u,R.height=h,R.rowIndex=r,R.colIndex=d,R.trIndex=r,R.tdIndex=a,i+=u,g&&!T&&(i=0)}}}drawRange(t,e,n,i){const{scale:r,rangeAlpha:o,rangeColor:l}=this.options,{type:a,trList:R}=e;if(!R||a!==c.ElementType.TABLE)return;const{isCrossRowCol:d,startTdIndex:u,endTdIndex:h,startTrIndex:g,endTrIndex:L}=this.range.getRange();if(!d)return;let T=R[g].tdList[u],M=R[L].tdList[h];(T.x>M.x||T.y>M.y)&&([T,M]=[M,T]);const P=T.colIndex,O=M.colIndex+(M.colspan-1),X=T.rowIndex,I=M.rowIndex+(M.rowspan-1);t.save();for(let f=0;f<R.length;f++){const S=R[f];for(let N=0;N<S.tdList.length;N++){const m=S.tdList[N],W=m.colIndex,Z=m.rowIndex;if(W>=P&&W<=O&&Z>=X&&Z<=I){const U=m.x*r,Q=m.y*r,F=m.width*r,E=m.height*r;t.globalAlpha=o,t.fillStyle=l,t.fillRect(U+n,Q+i,F,E)}}}t.restore()}render(t,e,n,i){this._drawBackgroundColor(t,e,n,i),this._drawBorder(t,e,n,i)}}var Jt;(function(s){s.ROW="row",s.COL="col"})(Jt||(Jt={}));class Ks{constructor(t){this.MIN_TD_WIDTH=20,this.ROW_COL_OFFSET=18,this.ROW_COL_QUICK_WIDTH=16,this.ROW_COL_QUICK_OFFSET=5,this.ROW_COL_QUICK_POSITION=this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2,this.BORDER_VALUE=4,this.TABLE_SELECT_OFFSET=20,this.draw=t,this.canvas=t.getPage(),this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.container=t.getContainer(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null,this.anchorLine=null,this.mousedownX=0,this.mousedownY=0}dispose(){var t,e,n,i,r,o;(t=this.toolRowContainer)==null||t.remove(),(e=this.toolRowAddBtn)==null||e.remove(),(n=this.toolColAddBtn)==null||n.remove(),(i=this.toolTableSelectBtn)==null||i.remove(),(r=this.toolColContainer)==null||r.remove(),(o=this.toolBorderContainer)==null||o.remove(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null}render(){const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.position.getPositionContext();if(!t)return;this.dispose();const r=this.draw.getOriginalElementList(),o=this.position.getOriginalPositionList(),l=r[e];if(l.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:a,table:{overflow:R}}=this.options,d=o[e],{colgroup:u,trList:h}=l,{coordinate:{leftTop:g}}=d,L=this.draw.getHeight(),T=this.draw.getPageGap(),M=this.draw.getPageNo()*(L+T),P=g[0],O=g[1]+M,X=l.trList[n].tdList[i],I=X.rowIndex,f=X.colIndex,S=l.height*a,N=l.width*a,m=document.createElement("div");m.classList.add(`${x}-table-tool__select`),m.style.height=`${S*a}`,m.style.left=`${P}px`,m.style.top=`${O}px`,m.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*a}px, ${-this.TABLE_SELECT_OFFSET*a}px)`,m.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(m),this.toolTableSelectBtn=m;const W=h.map(Y=>Y.height),Z=document.createElement("div");Z.classList.add(`${x}-table-tool__row`),Z.style.transform=`translateX(-${this.ROW_COL_OFFSET*a}px)`;for(let Y=0;Y<W.length;Y++){const K=W[Y]*a,b=document.createElement("div");b.classList.add(`${x}-table-tool__row__item`),Y===I&&b.classList.add("active"),b.onclick=()=>{const H=this.draw.getTableParticle().getTdListByRowIndex(h,Y),w=H[0],D=H[H.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:w.trIndex,tdIndex:w.tdIndex,tableId:l.id}),this.range.setRange(0,0,l.id,w.tdIndex,D.tdIndex,w.trIndex,D.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(Z,Y)};const p=document.createElement("div");p.classList.add(`${x}-table-tool__anchor`),p.onmousedown=H=>{this._mousedown({evt:H,element:l,index:Y,order:Jt.ROW})},b.append(p),b.style.height=`${K}px`,Z.append(b)}Z.style.left=`${P}px`,Z.style.top=`${O}px`,this.container.append(Z),this.toolRowContainer=Z;const U=document.createElement("div");U.classList.add(`${x}-table-tool__quick__add`),U.style.height=`${S*a}`,U.style.left=`${P}px`,U.style.top=`${O+S}px`,U.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*a}px, ${this.ROW_COL_QUICK_OFFSET*a}px)`,U.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:l.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(U),this.toolRowAddBtn=U;const Q=u.map(Y=>Y.width),F=document.createElement("div");F.classList.add(`${x}-table-tool__col`),F.style.transform=`translateY(-${this.ROW_COL_OFFSET*a}px)`;for(let Y=0;Y<Q.length;Y++){const K=Q[Y]*a,b=document.createElement("div");b.classList.add(`${x}-table-tool__col__item`),Y===f&&b.classList.add("active"),b.onclick=()=>{const H=this.draw.getTableParticle().getTdListByColIndex(h,Y),w=H[0],D=H[H.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:w.trIndex,tdIndex:w.tdIndex,tableId:l.id}),this.range.setRange(0,0,l.id,w.tdIndex,D.tdIndex,w.trIndex,D.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(F,Y)};const p=document.createElement("div");p.classList.add(`${x}-table-tool__anchor`),p.onmousedown=H=>{this._mousedown({evt:H,element:l,index:Y,order:Jt.COL})},b.append(p),b.style.width=`${K}px`,F.append(b)}F.style.left=`${P}px`,F.style.top=`${O}px`,this.container.append(F),this.toolColContainer=F;const E=document.createElement("div");E.classList.add(`${x}-table-tool__quick__add`),E.style.height=`${S*a}`,E.style.left=`${P+N}px`,E.style.top=`${O}px`,E.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*a}px, -${this.ROW_COL_QUICK_POSITION*a}px)`,E.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:l.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(E),this.toolColAddBtn=E;const V=document.createElement("div");V.classList.add(`${x}-table-tool__border`),V.style.height=`${S}px`,V.style.width=`${N}px`,V.style.left=`${P}px`,V.style.top=`${O}px`;for(let Y=0;Y<h.length;Y++){const K=h[Y];for(let b=0;b<K.tdList.length;b++){const p=K.tdList[b],H=document.createElement("div");H.classList.add(`${x}-table-tool__border__row`),H.style.width=`${p.width*a}px`,H.style.height=`${this.BORDER_VALUE}px`,H.style.top=`${(p.y+p.height)*a-this.BORDER_VALUE/2}px`,H.style.left=`${p.x*a}px`,H.onmousedown=D=>{this._mousedown({evt:D,element:l,index:p.rowIndex+p.rowspan-1,order:Jt.ROW})},V.appendChild(H);const w=document.createElement("div");if(w.classList.add(`${x}-table-tool__border__col`),w.style.width=`${this.BORDER_VALUE}px`,w.style.height=`${p.height*a}px`,w.style.top=`${p.y*a}px`,w.style.left=`${(p.x+p.width)*a-this.BORDER_VALUE/2}px`,w.onmousedown=D=>{this._mousedown({evt:D,element:l,index:p.colIndex+p.colspan-1,order:Jt.COL})},V.appendChild(w),R&&p.colIndex===0){const D=document.createElement("div");D.classList.add(`${x}-table-tool__border__col`),D.style.width=`${this.BORDER_VALUE}px`,D.style.height=`${p.height*a}px`,D.style.top=`${p.y*a}px`,D.style.left=`${p.x*a-this.BORDER_VALUE/2}px`,D.onmousedown=J=>{this._mousedown({evt:J,element:l,index:0,isLeftStartBorder:!0,order:Jt.COL})},V.appendChild(D)}}}this.container.append(V),this.toolBorderContainer=V}_setAnchorActive(t,e){const n=t.children;for(let i=0;i<n.length;i++){const r=n[i];i===e?r.classList.add("active"):r.classList.remove("active")}}_mousedown(t){const{evt:e,index:n,order:i,element:r,isLeftStartBorder:o}=t;this.canvas=this.draw.getPage();const{scale:l,table:{overflow:a}}=this.options,R=this.draw.getWidth(),d=this.draw.getHeight(),u=this.draw.getPageGap(),h=this.draw.getPageNo()*(d+u);this.mousedownX=e.x,this.mousedownY=e.y;const g=e.target,L=this.canvas.getBoundingClientRect(),T=window.getComputedStyle(g).cursor;document.body.style.cursor=T,this.canvas.style.cursor=T;let M=0,P=0;const O=document.createElement("div");O.classList.add(`${x}-table-anchor__line`),i===Jt.ROW?(O.classList.add(`${x}-table-anchor__line__row`),O.style.width=`${R}px`,M=0,P=h+this.mousedownY-L.top):(O.classList.add(`${x}-table-anchor__line__col`),O.style.height=`${d}px`,M=this.mousedownX-L.left,P=h),O.style.left=`${M}px`,O.style.top=`${P}px`,this.container.append(O),this.anchorLine=O;let X=0,I=0;const f=S=>{const N=this._mousemove(S,i,M,P);N&&(X=N.dx,I=N.dy)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",()=>{var N;let S=!1;if(i===Jt.ROW){const m=r.trList,W=m[n]||m[n-1],{defaultTrMinHeight:Z}=this.options.table;I<0&&W.height+I<Z&&(I=Z-W.height),I&&(W.height+=I,W.minHeight=W.height,S=!0)}else{const{colgroup:m}=r;if(m&&X)if(a&&o)m[n].width-X/l<=this.MIN_TD_WIDTH&&(X=(m[n].width-this.MIN_TD_WIDTH)*l),m[n].width-=X/l,r.width-=X/l,r.translateX=(r.translateX||0)+X/l,S=!0;else{const W=this.draw.getInnerWidth(),Z=m[n].width;X<0&&Z+X<this.MIN_TD_WIDTH&&(X=this.MIN_TD_WIDTH-Z);const U=(N=m[n+1])==null?void 0:N.width;X>0&&U&&U-X<this.MIN_TD_WIDTH&&(X=U-this.MIN_TD_WIDTH);const Q=Z+X;if(!a&&n===m.length-1){let F=0;for(let E=0;E<m.length;E++){const V=m[E];E===n+1&&(F-=X),E===n&&(F+=Q),E!==n&&(F+=V.width)}if(F>W){const E=r.width;X=W-E}}X&&(m.length-1!==n&&(m[n+1].width-=X/l),m[n].width+=X/l,S=!0)}}S&&this.draw.render({isSetCursor:!1}),O.remove(),document.removeEventListener("mousemove",f),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,i){if(!this.anchorLine)return null;const r=t.x-this.mousedownX,o=t.y-this.mousedownY;return e===Jt.ROW?this.anchorLine.style.top=`${i+o}px`:this.anchorLine.style.left=`${n+r}px`,t.preventDefault(),{dx:r,dy:o}}}class ys{constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:n}=this._createHyperlinkPopupDom();this.hyperlinkDom=n,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${x}-hyperlink-popup`);const e=document.createElement("a");return e.target="_blank",e.rel="noopener",t.append(e),this.container.append(t),{hyperlinkPopupContainer:t,hyperlinkDom:e}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[n,i]},lineHeight:r}=e,o=this.draw.getHeight(),l=this.draw.getPageGap(),a=this.draw.getPageNo()*(o+l);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${i+a+r}px`;const R=t.url||"#";this.hyperlinkDom.href=R,this.hyperlinkDom.title=R,this.hyperlinkDom.innerText=R}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,i){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),t.fillText(e.value,n,i),t.restore()}}class ws{constructor(t){this.options=t.getOptions()}render(t,e,n,i){var P,O,X,I;const{scale:r,label:{defaultBackgroundColor:o,defaultColor:l,defaultBorderRadius:a,defaultPadding:R}}=this.options,d=((P=e.label)==null?void 0:P.backgroundColor)||o,u=((O=e.label)==null?void 0:O.color)||l,h=((X=e.label)==null?void 0:X.borderRadius)||a,g=((I=e.label)==null?void 0:I.padding)||R;t.save(),t.font=e.style;const{width:L,height:T,boundingBoxAscent:M}=e.metrics;t.fillStyle=d,this._drawRoundedRect(t,n,i-M,L,T+(g[0]+g[3])*r,h*r),t.fill(),t.fillStyle=u,t.fillText(e.value,n+g[3]*r,i),t.restore()}_drawRoundedRect(t,e,n,i,r,o){t.beginPath(),t.moveTo(e+o,n),t.lineTo(e+i-o,n),t.quadraticCurveTo(e+i,n,e+i,n+o),t.lineTo(e+i,n+r-o),t.quadraticCurveTo(e+i,n+r,e+i-o,n+r),t.lineTo(e+o,n+r),t.quadraticCurveTo(e,n+r,e,n+r-o),t.lineTo(e,n+o),t.quadraticCurveTo(e,n,e+o,n),t.closePath()}}class Hs{constructor(t,e){this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth(),e=this.draw.getMargins(),n=tn(this.elementList);this.rowList=this.draw.computeRowList({startX:e[3],startY:this.getHeaderTop(),innerWidth:t,elementList:this.elementList,surroundElementList:n})}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],r=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:r,innerWidth:e,zone:c.EditorZone.HEADER})}getHeaderTop(){const{header:{top:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{header:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Sn[t])}getHeight(){if(this.options.header.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getHeaderTop()+e-t[0];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),r=[];let o=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(o+a.height>i)break;r.push(a),o+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:n,zone:c.EditorZone.HEADER}),t.restore()}}class Gs{getOffsetY(t){return-t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class xs{getOffsetY(t){return t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class Js{constructor(t){this.options=t.getOptions()}render(t,e,n,i){var R;t.save();const{scale:r,separator:{lineWidth:o,strokeStyle:l}}=this.options;t.lineWidth=(e.lineWidth||o)*r,t.strokeStyle=e.color||l,(R=e.dashArray)!=null&&R.length&&t.setLineDash(e.dashArray);const a=Math.round(i);t.translate(0,t.lineWidth/2),t.beginPath(),t.moveTo(n,a),t.lineTo(n+e.width*r,a),t.stroke(),t.restore()}}class vs{constructor(t){this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,n,i){const{pageBreak:{font:r,fontSize:o,lineDash:l}}=this.options,a=this.i18n.t("pageBreak.displayName"),{scale:R,defaultRowMargin:d}=this.options,u=o*R,h=e.width*R,g=this.draw.getDefaultBasicRowMarginHeight()*d;t.save(),t.font=`${u}px ${r}`;const L=t.measureText(a),T=(h-L.width)/2;t.setLineDash(l),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,i),t.lineTo(n+T,i),t.moveTo(n+T+L.width,i),t.lineTo(n+h,i),t.stroke(),t.fillText(a,n+T,i+L.actualBoundingBoxAscent-u/2),t.restore()}}class Bs{constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:n,opacity:i,font:r,size:o,color:l,repeat:a,gap:R,numberType:d},scale:u}=this.options,h=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=i,t.font=`${o*u}px ${r}`;let L=n;const T=new RegExp(ue.PAGE_NO);T.test(L)&&(L=re.formatNumberPlaceholder(L,e+1,T,d));const M=new RegExp(ue.PAGE_COUNT);M.test(L)&&(L=re.formatNumberPlaceholder(L,this.draw.getPageCount(),M,d));const P=t.measureText(L);if(a){const O=this.draw.getPagePixelRatio(),X=document.createElement("canvas"),I=X.getContext("2d"),f=P.width,S=P.actualBoundingBoxAscent+P.actualBoundingBoxDescent,N=Math.sqrt(Math.pow(f,2)+Math.pow(S,2)),m=N+2*R[0]*u,W=N+2*R[1]*u;X.width=m,X.height=W,X.style.width=`${m*O}px`,X.style.height=`${W*O}px`,I.translate(m/2,W/2),I.rotate(-45*Math.PI/180),I.translate(-m/2,-W/2),I.font=`${o*u}px ${r}`,I.fillStyle=l,I.fillText(L,(m-f)/2,(W-S)/2+P.actualBoundingBoxAscent);const Z=t.createPattern(X,"repeat");Z&&(t.fillStyle=Z,t.fillRect(0,0,h,g))}else{const O=h/2,X=g/2;t.fillStyle=l,t.translate(O,X),t.rotate(-45*Math.PI/180),t.fillText(L,-P.width/2,P.actualBoundingBoxAscent-o*u/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:n,data:i,opacity:r,repeat:o,gap:l},scale:a}=this.options;if(!this.imageCache.has(i)){const g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=i,g.onload=()=>{this.imageCache.set(i,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const R=this.draw.getWidth(),d=this.draw.getHeight(),u=e*a,h=n*a;if(t.save(),t.globalAlpha=r,o){const g=this.draw.getPagePixelRatio(),L=document.createElement("canvas"),T=L.getContext("2d"),M=Math.sqrt(Math.pow(u,2)+Math.pow(h,2)),P=M+2*l[0]*a,O=M+2*l[1]*a;L.width=P,L.height=O,L.style.width=`${P*g}px`,L.style.height=`${O*g}px`,T.translate(P/2,O/2),T.rotate(-45*Math.PI/180),T.translate(-P/2,-O/2),T.drawImage(this.imageCache.get(i),(P-u)/2,(O-h)/2,u,h);const X=t.createPattern(L,"repeat");X&&(t.fillStyle=X,t.fillRect(0,0,R,d))}else{const g=R/2,L=d/2;t.translate(g,L),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(i),-u/2,-h/2,u,h)}t.restore()}render(t,e){this.options.watermark.type===c.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class As{constructor(t){this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){var L,T;const{control:{activeBackgroundColor:n,disabledBackgroundColor:i,existValueBackgroundColor:r,noValueBackgroundColor:o}}=this.options,l=t[e],a=this.draw.isPrintMode(),R=(L=this.control.getActiveControl())==null?void 0:L.getElement();let d=!1,u=!1,h=!1,g=!1;return l.highlight||(d=!a&&!!n&&!!R&&l.controlId===R.controlId&&!this.control.getIsRangeInPostfix()),d||(u=!a&&!!i&&!!((T=l.control)!=null&&T.disabled)),u||(h=!a&&!!r&&!!l.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),h||(g=!a&&!!o&&!!l.controlId&&!this.control.getIsExistValueByElementListIndex(t,e)),(d?n:"")||(u?i:"")||(h?r:"")||(g?o:"")}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(n,i)=>{let r=0;for(;r<n.length;){const o=n[r];if(r++,o.type===c.ElementType.TABLE){const L=o.trList;for(let T=0;T<L.length;T++){const M=L[T];for(let P=0;P<M.tdList.length;P++){const O=M.tdList[P],X={tableId:o.id,tableIndex:r-1,trIndex:T,tdIndex:P,tdId:O.id};e(O.value,X)}}}const l=o==null?void 0:o.control;if(!l)continue;const a=this.highlightList.findIndex(L=>L.id===o.controlId||l.conceptId&&l.conceptId===L.conceptId);if(!~a)continue;const R=r;let d=r;for(;d<n.length&&n[d].controlId===o.controlId;)d++;r=d;const u=n.slice(R,d).map(L=>L.controlComponent===c.ControlComponent.VALUE?L:{value:y}),h=this.highlightList[a],{ruleList:g}=h;for(let L=0;L<g.length;L++){const T=g[L],M=t.getMatchList(T.keyword,u);this.highlightMatchResult.push(...M.map(P=>({...P,...T,...i,index:P.index+R})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){var l,a,R;if(!((l=this.highlightMatchResult)!=null&&l.length))return;const{searchMatchAlpha:n,searchMatchColor:i}=this.options,r=this.draw.getPosition().getOriginalPositionList(),o=this.draw.getOriginalElementList();t.save();for(let d=0;d<this.highlightMatchResult.length;d++){const u=this.highlightMatchResult[d];let h=null;if(u.tableId){const{tableIndex:f,trIndex:S,tdIndex:N,index:m}=u;h=(R=(a=o[f])==null?void 0:a.trList[S].tdList[N])==null?void 0:R.positionList[m]}else h=r[u.index];if(!h)continue;const{coordinate:{leftTop:g,leftBottom:L,rightTop:T},pageNo:M}=h;if(M!==e)continue;t.fillStyle=u.backgroundColor||i,t.globalAlpha=u.alpha||n;const P=g[0],O=g[1],X=T[0]-g[0],I=L[1]-g[1];t.fillRect(P,O,X,I)}t.restore()}}class ks{constructor(t){this.borderRect=this.clearBorderInfo(),this.options=t.getOptions()}clearBorderInfo(){return this.borderRect={x:0,y:0,width:0,height:0},this.borderRect}recordBorderInfo(t,e,n,i){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=i),this.borderRect.width+=n}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:n,borderColor:i}}=this.options,{x:r,y:o,width:l,height:a}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=n*e,t.strokeStyle=i,t.beginPath(),t.rect(r,o,l,a),t.stroke(),t.restore(),this.clearBorderInfo()}}class Le{constructor(t,e){this.VALUE_DELIMITER=",",this.DEFAULT_MULTI_SELECT_DELIMITER=",";const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.selectDom=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getCodes(){var t,e;return(e=(t=this.element)==null?void 0:t.control)!=null&&e.code?this.element.control.code.split(","):[]}getText(t){var o,l;if(!((o=this.element)!=null&&o.control))return null;const e=this.element.control;if(!((l=e.valueSets)!=null&&l.length))return null;const n=(e==null?void 0:e.multiSelectDelimiter)||this.DEFAULT_MULTI_SELECT_DELIMITER,i=e.valueSets,r=[];return t.forEach(a=>{const R=i.find(d=>d.code===a);R&&!Fn(R.value)&&r.push(R.value)}),r.join(n)||null}getValue(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:n}=t.range||this.control.getRange(),i=e[n],r=[];let o=n;for(;o>0;){const a=e[o];if(a.controlId!==i.controlId||a.controlComponent===c.ControlComponent.PREFIX||a.controlComponent===c.ControlComponent.PRE_TEXT)break;a.controlComponent===c.ControlComponent.VALUE&&r.unshift(a),o--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==i.controlId||a.controlComponent===c.ControlComponent.POSTFIX||a.controlComponent===c.ControlComponent.POST_TEXT)break;a.controlComponent===c.ControlComponent.VALUE&&r.push(a),l++}return r}setValue(t,e={},n={}){var h,g;if(!((g=(h=this.element.control)==null?void 0:h.selectExclusiveOptions)!=null&&g.inputAble)||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:o,endIndex:l}=r,a=this.control.getDraw();o!==l?a.spliceElementList(i,o+1,l-o):this.control.removePlaceholder(o,e);const R=i[o],d=R.type&&!Ut.includes(R.type)||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT?mt(R,["control","controlId",...yt]):bt(R,["type"]),u=r.startIndex+1;for(let L=0;L<t.length;L++){const T={...d,...t[L],controlComponent:c.ControlComponent.VALUE};Ot(i,[T],o,{editorOptions:this.options}),a.spliceElementList(i,u+L,0,[T])}return u+t.length-1}keydown(t){var R,d;if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,o=e[i],l=e[r],a=(d=(R=this.element.control)==null?void 0:R.selectExclusiveOptions)==null?void 0:d.inputAble;if(t.key===c.KeyMap.Backspace)return i!==r?a?(this.draw.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect():o.controlComponent===c.ControlComponent.PREFIX||o.controlComponent===c.ControlComponent.PRE_TEXT||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT||o.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):a?(this.draw.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1):this.clearSelect();if(t.key===c.KeyMap.Delete){if(i!==r)return a?(this.draw.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect();{const u=e[r+1];return(o.controlComponent===c.ControlComponent.PREFIX||o.controlComponent===c.ControlComponent.PRE_TEXT)&&u.controlComponent===c.ControlComponent.PLACEHOLDER||u.controlComponent===c.ControlComponent.POSTFIX||u.controlComponent===c.ControlComponent.POST_TEXT||o.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):a?(this.draw.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect()}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();return t===e?t:this.clearSelect()}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=t.elementList||this.control.getElementList(),{startIndex:o}=t.range||this.control.getRange(),l=r[o];let a=-1,R=-1,d=o;for(;d>0;){const g=r[d];if(g.controlId!==l.controlId||g.controlComponent===c.ControlComponent.PREFIX||g.controlComponent===c.ControlComponent.PRE_TEXT){a=d;break}d--}let u=o+1;for(;u<r.length;){const g=r[u];if(g.controlId!==l.controlId||g.controlComponent===c.ControlComponent.POSTFIX||g.controlComponent===c.ControlComponent.POST_TEXT){R=u-1;break}u++}return!~a||!~R?-1:(this.control.getDraw().spliceElementList(r,a+1,R-a,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(d,t),this.control.setControlProperties({code:null},{elementList:r,range:{startIndex:d,endIndex:d}}),d)}setSelect(t,e={},n={}){var I;if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),o=this.element.control,l=(t==null?void 0:t.split(this.VALUE_DELIMITER))||[],a=o.code,R=((I=o.code)==null?void 0:I.split(this.VALUE_DELIMITER))||[],d=o.isMultiSelect;if(!d&&t===a||d&&mn(R,l)){this.control.repaintControl({curIndex:r.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const u=o.valueSets;if(!Array.isArray(u)||!u.length)return;const h=this.getText(l);if(!h){if(a){const f=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~f&&(this.control.repaintControl({curIndex:f}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],L=g?mt(g,Zt):mt(i[r.startIndex],yt),T=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~T)return;a||this.control.removePlaceholder(T,e);const M=bt(i[T],Zt),P=T+1,O=pt(h),X=this.control.getDraw();for(let f=0;f<O.length;f++){const S={...L,...M,type:c.ElementType.TEXT,value:O[f],controlComponent:c.ControlComponent.VALUE};Ot(i,[S],T,{editorOptions:this.options}),X.spliceElementList(i,P+f,0,[S])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:T,endIndex:T}}),!e.range){const f=P+O.length-1;this.control.repaintControl({curIndex:f}),this.control.emitControlContentChange({context:e}),d||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const n=this.control.getPosition();if(!n)return;const i=document.createElement("div");i.classList.add(`${x}-select-control-popup`),i.setAttribute(Kt,c.EditorComponent.POPUP);const r=document.createElement("ul");let o=null;for(let h=0;h<e.length;h++){const g=e[h],L=document.createElement("li");let T=this.getCodes();T.includes(g.code)&&(L.classList.add("active"),o=L),L.onclick=()=>{const M=T.findIndex(P=>P===g.code);t.isMultiSelect?~M?T.splice(M,1):T.push(g.code):~M?T=[]:T=[g.code],this.setSelect(T.join(this.VALUE_DELIMITER))},L.append(document.createTextNode(g.value)),r.append(L)}i.append(r);const{coordinate:{leftTop:[l,a]},lineHeight:R}=n,d=this.control.getPreY();i.style.left=`${l}px`,i.style.top=`${a+d+R}px`,this.control.getContainer().append(i),this.selectDom=i,o&&pn(i,o)}awake(){var n;if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const{startIndex:t}=this.control.getRange();((n=this.control.getElementList()[t+1])==null?void 0:n.controlId)===this.element.controlId&&(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){var t;!this.isPopup||((t=this.selectDom)==null||t.remove(),this.isPopup=!1)}}class Rn{constructor(t,e){const n=e.getDraw();this.options=n.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:n}=t.range||this.control.getRange(),i=e[n],r=[];let o=n;for(;o>0;){const a=e[o];if(a.controlId!==i.controlId||a.controlComponent===c.ControlComponent.PREFIX||a.controlComponent===c.ControlComponent.PRE_TEXT)break;a.controlComponent===c.ControlComponent.VALUE&&r.unshift(a),o--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==i.controlId||a.controlComponent===c.ControlComponent.POSTFIX||a.controlComponent===c.ControlComponent.POST_TEXT)break;a.controlComponent===c.ControlComponent.VALUE&&r.push(a),l++}return r}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:o,endIndex:l}=r,a=this.control.getDraw();o!==l?a.spliceElementList(i,o+1,l-o,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(o,e);const R=i[o],d=R.type&&!Ut.includes(R.type)||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT?mt(R,["control","controlId",...yt]):bt(R,["type"]),u=r.startIndex+1;for(let h=0;h<t.length;h++){const g={...d,...t[h],controlComponent:c.ControlComponent.VALUE};Ot(i,[g],o,{editorOptions:this.options}),a.spliceElementList(i,u+h,0,[g])}return u+t.length-1}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange(),{startIndex:r,endIndex:o}=i;return this.control.getDraw().spliceElementList(n,r+1,o-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),this.getValue({range:i,elementList:n}).length||this.control.addPlaceholder(r,t),r}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,o=e[i],l=e[r],a=this.control.getDraw();if(t.key===c.KeyMap.Backspace)return i!==r?(a.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):o.controlComponent===c.ControlComponent.PREFIX||o.controlComponent===c.ControlComponent.PRE_TEXT||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT||o.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(a.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key===c.KeyMap.Delete){if(i!==r)return a.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i;{const R=e[r+1];return(o.controlComponent===c.ControlComponent.PREFIX||o.controlComponent===c.ControlComponent.PRE_TEXT)&&R.controlComponent===c.ControlComponent.PLACEHOLDER||R.controlComponent===c.ControlComponent.POSTFIX||R.controlComponent===c.ControlComponent.POST_TEXT||o.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(a.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}}class ti{constructor(t,e={}){this.draw=t,this.options=e,this.lang=this._getLang(),this.now=new Date,this.dom=this._createDom(),this.renderOptions=null,this.isDatePicker=!0,this.pickDate=null,this._bindEvent()}_createDom(){const t=document.createElement("div");t.classList.add(`${x}-date-container`),t.setAttribute(Kt,c.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${x}-date-wrap`);const n=document.createElement("div");n.classList.add(`${x}-date-title`);const i=document.createElement("span");i.classList.add(`${x}-date-title__pre-year`),i.innerText="<<";const r=document.createElement("span");r.classList.add(`${x}-date-title__pre-month`),r.innerText="<";const o=document.createElement("span");o.classList.add(`${x}-date-title__now`);const l=document.createElement("span");l.classList.add(`${x}-date-title__next-month`),l.innerText=">";const a=document.createElement("span");a.classList.add(`${x}-date-title__next-year`),a.innerText=">>",n.append(i),n.append(r),n.append(o),n.append(l),n.append(a);const R=document.createElement("div");R.classList.add(`${x}-date-week`);const{weeks:{sun:d,mon:u,tue:h,wed:g,thu:L,fri:T,sat:M}}=this.lang;[d,u,h,g,L,T,M].forEach(Q=>{const F=document.createElement("span");F.innerText=`${Q}`,R.append(F)});const O=document.createElement("div");O.classList.add(`${x}-date-day`),e.append(n),e.append(R),e.append(O);const X=document.createElement("ul");X.classList.add(`${x}-time-wrap`);let I,f,S;[this.lang.hour,this.lang.minute,this.lang.second].forEach((Q,F)=>{const E=document.createElement("li"),V=document.createElement("span");V.innerText=Q,E.append(V);const Y=document.createElement("ol"),K=F===0,b=F===1,p=K?24:60;for(let H=0;H<p;H++){const w=document.createElement("li");w.innerText=`${String(H).padStart(2,"0")}`,w.setAttribute("data-id",`${H}`),Y.append(w)}K?I=Y:b?f=Y:S=Y,E.append(Y),X.append(E)});const m=document.createElement("div");m.classList.add(`${x}-date-menu`);const W=document.createElement("button");W.classList.add(`${x}-date-menu__time`),W.innerText=this.lang.timeSelect;const Z=document.createElement("button");Z.classList.add(`${x}-date-menu__now`),Z.innerText=this.lang.now;const U=document.createElement("button");return U.classList.add(`${x}-date-menu__submit`),U.innerText=this.lang.confirm,m.append(W),m.append(Z),m.append(U),t.append(e),t.append(X),t.append(m),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:R,timeWrap:X,title:{preYear:i,preMonth:r,now:o,nextMonth:l,nextYear:a},day:O,time:{hour:I,minute:f,second:S},menu:{time:W,now:Z,submit:U}}}_bindEvent(){this.dom.title.preYear.onclick=()=>{this._preYear()},this.dom.title.preMonth.onclick=()=>{this._preMonth()},this.dom.title.nextMonth.onclick=()=>{this._nextMonth()},this.dom.title.nextYear.onclick=()=>{this._nextYear()},this.dom.menu.time.onclick=()=>{this.isDatePicker=!this.isDatePicker,this._toggleDateTimePicker()},this.dom.menu.now.onclick=()=>{this._now(),this._submit()},this.dom.menu.submit.onclick=()=>{this.dispose(),this._submit()},this.dom.time.hour.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;!n||(this.pickDate.setHours(Number(n)),this._setTimePick(!1))},this.dom.time.minute.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;!n||(this.pickDate.setMinutes(Number(n)),this._setTimePick(!1))},this.dom.time.second.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;!n||(this.pickDate.setSeconds(Number(n)),this._setTimePick(!1))}}_setPosition(){if(!this.renderOptions)return;const{position:{coordinate:{leftTop:[t,e]},lineHeight:n,pageNo:i}}=this.renderOptions,r=this.draw.getHeight(),o=this.draw.getPageGap(),a=(i!=null?i:this.draw.getPageNo())*(r+o);this.dom.container.style.left=`${t}px`,this.dom.container.style.top=`${e+a+n}px`}isInvalidDate(t){return t.toDateString()==="Invalid Date"}_setValue(){var e;const t=(e=this.renderOptions)==null?void 0:e.value;if(t){const n=new Date(t);this.now=this.isInvalidDate(n)?new Date:n}else this.now=new Date;this.pickDate=new Date(this.now)}_getLang(){const t=this.draw.getI18n(),e=t.t.bind(t);return{now:e("datePicker.now"),confirm:e("datePicker.confirm"),return:e("datePicker.return"),timeSelect:e("datePicker.timeSelect"),weeks:{sun:e("datePicker.weeks.sun"),mon:e("datePicker.weeks.mon"),tue:e("datePicker.weeks.tue"),wed:e("datePicker.weeks.wed"),thu:e("datePicker.weeks.thu"),fri:e("datePicker.weeks.fri"),sat:e("datePicker.weeks.sat")},year:e("datePicker.year"),month:e("datePicker.month"),hour:e("datePicker.hour"),minute:e("datePicker.minute"),second:e("datePicker.second")}}_setLangChange(){this.dom.menu.time.innerText=this.lang.timeSelect,this.dom.menu.now.innerText=this.lang.now,this.dom.menu.submit.innerText=this.lang.confirm;const{weeks:{sun:t,mon:e,tue:n,wed:i,thu:r,fri:o,sat:l}}=this.lang,a=[t,e,n,i,r,o,l];this.dom.datePickerWeek.childNodes.forEach((h,g)=>{const L=h;L.innerText=a[g]});const R=this.dom.time.hour.previousElementSibling;R.innerText=this.lang.hour;const d=this.dom.time.minute.previousElementSibling;d.innerText=this.lang.minute;const u=this.dom.time.second.previousElementSibling;u.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),n=t.getMonth()+1,i=t.getDate();let r=null,o=null,l=null;this.pickDate&&(r=this.pickDate.getFullYear(),o=this.pickDate.getMonth()+1,l=this.pickDate.getDate());const a=this.now.getFullYear(),R=this.now.getMonth()+1;this.dom.title.now.innerText=`${a}${this.lang.year} ${String(R).padStart(2,"0")}${this.lang.month}`;const u=new Date(a,R,0).getDate();let h=new Date(a,R-1,1).getDay();h===0&&(h=7);const g=new Date(a,R-1,0).getDate();this.dom.day.innerHTML="";const L=g-h+1;for(let M=L;M<=g;M++){const P=document.createElement("div");P.classList.add("disable"),P.innerText=`${M}`,P.onclick=()=>{const O=R-2;this.now=new Date(a,O,M),this._setDatePick(a,O,M)},this.dom.day.append(P)}for(let M=1;M<=u;M++){const P=document.createElement("div");e===a&&n===R&&i===M&&P.classList.add("active"),this.pickDate&&r===a&&o===R&&l===M&&P.classList.add("select"),P.innerText=`${M}`,P.onclick=O=>{const X=R-1;this.now=new Date(a,X,M),this._setDatePick(a,X,M),O.stopPropagation()},this.dom.day.append(P)}const T=6*7-h-u;for(let M=1;M<=T;M++){const P=document.createElement("div");P.classList.add("disable"),P.innerText=`${M}`,P.onclick=()=>{this.now=new Date(a,R,M),this._setDatePick(a,R,M)},this.dom.day.append(P)}}_toggleDateTimePicker(){this.isDatePicker?(this.dom.dateWrap.classList.add("active"),this.dom.timeWrap.classList.remove("active"),this.dom.menu.time.innerText=this.lang.timeSelect):(this.dom.dateWrap.classList.remove("active"),this.dom.timeWrap.classList.add("active"),this.dom.menu.time.innerText=this.lang.return,this._setTimePick())}_setDatePick(t,e,n){var i,r,o;this.now=new Date(t,e,n),(i=this.pickDate)==null||i.setFullYear(t),(r=this.pickDate)==null||r.setMonth(e),(o=this.pickDate)==null||o.setDate(n),this._update()}_setTimePick(t=!0){var d,u,h;const e=((d=this.pickDate)==null?void 0:d.getHours())||0,n=((u=this.pickDate)==null?void 0:u.getMinutes())||0,i=((h=this.pickDate)==null?void 0:h.getSeconds())||0,{hour:r,minute:o,second:l}=this.dom.time;[r,o,l].forEach(g=>{g.querySelectorAll("li").forEach(L=>L.classList.remove("active"))}),[[r,e],[o,n],[l,i]].forEach(([g,L])=>{const T=g.querySelector(`[data-id='${L}']`);T.classList.add("active"),t&&pn(g,T)})}_preMonth(){this.now.setMonth(this.now.getMonth()-1),this._update()}_nextMonth(){this.now.setMonth(this.now.getMonth()+1),this._update()}_preYear(){this.now.setFullYear(this.now.getFullYear()-1),this._update()}_nextYear(){this.now.setFullYear(this.now.getFullYear()+1),this._update()}_now(){this.pickDate=new Date,this.dispose()}_toggleVisible(t){t?this.dom.container.classList.add("active"):this.dom.container.classList.remove("active")}_submit(){var t;if(this.options.onSubmit&&this.pickDate){const e=(t=this.renderOptions)==null?void 0:t.dateFormat,n=this.formatDate(this.pickDate,e);this.options.onSubmit(n)}}formatDate(t,e="YYYY-MM-DD HH:mm:ss"){let n=e;const i=t.getFullYear().toString(),r=(t.getMonth()+1).toString(),o=t.getDate().toString(),l=t.getHours(),a=l%12===0?12:l%12,R=t.getMinutes().toString(),d=t.getSeconds().toString(),u=t.getMilliseconds().toString(),h={"y+":i,"Y+":i,"M+":r,"d+":o,"D+":o,"h+":a.toString(),"H+":l.toString(),"m+":R,"s+":d,"S+":u};for(const g in h){const L=new RegExp("("+g+")").exec(e),T=g;L&&(n=n.replace(L[1],L[1].length===1?h[T]:h[T].padStart(L[1].length,"0")))}return n}render(t){this.renderOptions=t,this.lang=this._getLang(),this._setLangChange(),this._setValue(),this._update(),this._setPosition(),this.isDatePicker=!0,this._toggleDateTimePicker(),this._toggleVisible(!0)}dispose(){this._toggleVisible(!1)}destroy(){this.dom.container.remove()}}class Te{constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:r,endIndex:o}=n;for(let l=r;l<=o;l++){const a=e[l];a.controlComponent===c.ControlComponent.VALUE&&i.push(a)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const{startIndex:o,endIndex:l}=r,a=this.control.getDraw();o!==l?a.spliceElementList(i,o+1,l-o):this.control.removePlaceholder(o,e);const R=i[o],d=R.type&&!Ut.includes(R.type)||R.controlComponent===c.ControlComponent.PREFIX||R.controlComponent===c.ControlComponent.PRE_TEXT?mt(R,["control","controlId",...yt]):bt(R,["type"]),u=r.startIndex+1;for(let h=0;h<t.length;h++){const g={...d,...t[h],controlComponent:c.ControlComponent.VALUE};Ot(i,[g],o,{editorOptions:this.options}),a.spliceElementList(i,u+h,0,[g])}return u+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const r=this.control.getValueRange(t);if(!r)return-1;const{startIndex:o,endIndex:l}=r;if(!~o||!~l)return-1;const a=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(a,o+1,l-o,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(o,t),o}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange(),o=this.getValue(e)[0],l=o?mt(o,Zt):mt(i[r.startIndex],yt),a=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~a)return;const R=bt(i[a],Zt),d=a+1,u=this.control.getDraw();for(let h=0;h<t.length;h++){const g={...l,...R,type:c.ElementType.TEXT,value:t[h],controlComponent:c.ControlComponent.VALUE};Ot(i,[g],a,{editorOptions:this.options}),u.spliceElementList(i,d+h,0,[g])}if(!e.range){const h=d+t.length-1;this.control.repaintControl({curIndex:h}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:r}=n,o=e[i],l=e[r],a=this.control.getDraw();if(t.key===c.KeyMap.Backspace)return i!==r?(a.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i):o.controlComponent===c.ControlComponent.PREFIX||o.controlComponent===c.ControlComponent.PRE_TEXT||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT||o.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(a.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key===c.KeyMap.Delete){if(i!==r)return a.spliceElementList(e,i+1,r-i),this.getValue().length||this.control.addPlaceholder(i),i;{const R=e[r+1];return(o.controlComponent===c.ControlComponent.PREFIX||o.controlComponent===c.ControlComponent.PRE_TEXT)&&R.controlComponent===c.ControlComponent.PLACEHOLDER||R.controlComponent===c.ControlComponent.POSTFIX||R.controlComponent===c.ControlComponent.POST_TEXT||o.controlComponent===c.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(a.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}}return r}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){var o,l;if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getPosition();if(!t)return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(((o=e[n+1])==null?void 0:o.controlId)!==this.element.controlId)return;this.datePicker=new ti(this.draw,{onSubmit:this._setDate.bind(this)});const i=this.getValue().map(a=>a.value).join("")||"",r=(l=this.element.control)==null?void 0:l.dateFormat;this.datePicker.render({value:i,position:t,dateFormat:r}),this.isPopup=!0}destroy(){var t;!this.isPopup||((t=this.datePicker)==null||t.destroy(),this.isPopup=!1)}_setDate(t){t?this.setSelect(t):this.clearSelect(),this.destroy()}}class _s{constructor(t){this.control=t.control,this.onCalculate=t.onCalculate,this.calculatorDom=null,this.currentExpression=""}createPopup(){const t=this.control.getPosition();if(!t)return;const e=document.createElement("div");e.classList.add(`${x}-calculator`),e.setAttribute(Kt,c.EditorComponent.POPUP);const n=document.createElement("div");n.classList.add(`${x}-calculator-display`),n.textContent="0";const i=document.createElement("div");i.classList.add(`${x}-calculator-buttons`),[[{text:"C",type:ot.UTILITY},{text:"\u2190",type:ot.UTILITY},{text:"%",type:ot.OPERATOR},{text:"/",type:ot.OPERATOR}],[{text:"7",type:ot.NUMBER},{text:"8",type:ot.NUMBER},{text:"9",type:ot.NUMBER},{text:"*",type:ot.OPERATOR}],[{text:"4",type:ot.NUMBER},{text:"5",type:ot.NUMBER},{text:"6",type:ot.NUMBER},{text:"-",type:ot.OPERATOR}],[{text:"1",type:ot.NUMBER},{text:"2",type:ot.NUMBER},{text:"3",type:ot.NUMBER},{text:"+",type:ot.OPERATOR}],[{text:"0",type:ot.NUMBER},{text:".",type:ot.NUMBER},{text:"=",type:ot.EQUAL,span:2}]].forEach(u=>{u.forEach(h=>{const g=document.createElement("button");g.classList.add(`${x}-calculator-button`),h.type===ot.OPERATOR?g.classList.add("operator"):h.type===ot.EQUAL?g.classList.add("equal"):h.type===ot.UTILITY&&g.classList.add("utility"),g.textContent=h.text,g.onclick=()=>{const L=h.text;if(L==="C")this.currentExpression="",n.textContent="0";else if(L==="\u2190")this.currentExpression=this.currentExpression.slice(0,-1),n.textContent=this.currentExpression||"0";else if(L==="="){const T=this.calculate(this.currentExpression);Number.isFinite(T)?(n.textContent=T.toString(),this.currentExpression=T.toString(),this.onCalculate(T)):(n.textContent="Error",this.currentExpression="")}else this.currentExpression+=L,n.textContent=this.currentExpression},h.span&&(g.style.gridColumn=`span ${h.span}`),i.appendChild(g)})}),e.appendChild(n),e.appendChild(i);const{coordinate:{leftTop:[o,l]},lineHeight:a}=t,R=this.control.getPreY();e.style.left=`${o}px`,e.style.top=`${l+R+a}px`,this.control.getContainer().appendChild(e),this.calculatorDom=e}destroy(){this.calculatorDom&&(this.calculatorDom.remove(),this.calculatorDom=null)}calculate(t){const e=Function("return "+t)();return!Number.isFinite(e)||Number.isInteger(e)?e:parseFloat(e.toFixed(10))}}class Pe extends Rn{constructor(t,e){super(t,e),this.isPopup=!1,this.calculator=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(u=>!yo(u)||Ui.test(u.value)))return-1;const i=e.elementList||this.control.getElementList(),r=e.range||this.control.getRange();this.control.shrinkBoundary(e);const o=_(t),{startIndex:l,endIndex:a}=r,R=i[l];if(this.control.getIsExistValueByElementListIndex(i,l)){let u=l;for(;u>0;){const g=i[u];if(g.controlId!==R.controlId||g.controlComponent===c.ControlComponent.PREFIX||g.controlComponent===c.ControlComponent.PRE_TEXT)break;o.unshift(g),u--}let h=a+1;for(;h<i.length;){const g=i[h];if(g.controlId!==R.controlId||g.controlComponent===c.ControlComponent.POSTFIX||g.controlComponent===c.ControlComponent.POST_TEXT)break;o.push(g),h++}}const d=wo(o);return Number.isNaN(Number(d))||!Number.isFinite(Number(d))?-1:super.setValue(t,e,n)}_setCalculatedValue(t){const e=super.clearValue({},{isAddPlaceholder:!1,isIgnoreDeletedRule:!0});if(!~e)return;const n=this.control.getElementList(),i=this.control.getRange(),r=this.getValue()[0],o=r?mt(r,Zt):mt(n[i.startIndex],yt),l=bt(n[e],Zt),a=t.toString(),R=[];for(let d=0;d<a.length;d++){const u={...o,...l,type:c.ElementType.TEXT,value:a[d],controlComponent:c.ControlComponent.VALUE};R.push(u)}this.setValue(R),this.control.repaintControl({curIndex:e+R.length}),this.control.emitControlContentChange(),this.destroy()}awake(){var i,r,o;const t=((r=(i=this.element.control)==null?void 0:i.numberExclusiveOptions)==null?void 0:r.calculatorDisabled)===!1;if(this.isPopup||!t||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const{startIndex:e}=this.control.getRange();((o=this.control.getElementList()[e+1])==null?void 0:o.controlId)===this.element.controlId&&(this.calculator=new _s({control:this.control,onCalculate:l=>{this._setCalculatedValue(l)}}),this.calculator.createPopup(),this.isPopup=!0)}destroy(){var t;!this.isPopup||((t=this.calculator)==null||t.destroy(),this.calculator=null,this.isPopup=!1)}}class zs{constructor(t){this.controlBorder=new ks(t),this.draw=t,this.range=t.getRange(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.controlSearch=new As(this),this.options=t.getOptions(),this.controlOptions=this.options.control,this.activeControl=null,this.activeControlValue=[],this.preElement=null}setHighlightList(t){this.controlSearch.setHighlightList(t)}computeHighlightList(){this.controlSearch.getHighlightList().length&&this.controlSearch.computeHighlightList()}renderHighlightList(t,e){this.controlSearch.getHighlightMatchResult().length&&this.controlSearch.renderHighlightList(t,e)}getDraw(){return this.draw}filterAssistElement(t){return t.filter((e,n)=>{var i,r,o;if(e.type===c.ElementType.TABLE){const l=e.trList;for(let a=0;a<l.length;a++){const R=l[a];for(let d=0;d<R.tdList.length;d++){const u=R.tdList[d];u.value=this.filterAssistElement(u.value)}}}if(!e.controlId)return!0;if((i=e.control)!=null&&i.minWidth){if(e.controlComponent===c.ControlComponent.PREFIX||e.controlComponent===c.ControlComponent.POSTFIX)return e.value="",!0}else{if(((r=e.control)==null?void 0:r.preText)&&e.controlComponent===c.ControlComponent.PRE_TEXT){let l=!1,a=n+1;for(;a<t.length;){const R=t[a];if(e.controlId!==R.controlId)break;if(R.controlComponent===c.ControlComponent.VALUE){l=!0;break}a++}return l}if(((o=e.control)==null?void 0:o.postText)&&e.controlComponent===c.ControlComponent.POST_TEXT){let l=!1,a=n-1;for(;a<t.length;){const R=t[a];if(e.controlId!==R.controlId)break;if(R.controlComponent===c.ControlComponent.VALUE){l=!0;break}a--}return l}}return e.controlComponent!==c.ControlComponent.PREFIX&&e.controlComponent!==c.ControlComponent.POSTFIX&&e.controlComponent!==c.ControlComponent.PLACEHOLDER})}getIsRangeCanCaptureEvent(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),i=n[t];if(t===e&&i.controlComponent===c.ControlComponent.POSTFIX)return!0;const r=n[e];return!!(i.controlId&&i.controlId===r.controlId&&r.controlComponent!==c.ControlComponent.POSTFIX)}getIsRangeInPostfix(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();return t!==e?!1:this.getElementList()[t].controlComponent===c.ControlComponent.POSTFIX}getIsRangeWithinControl(){const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const n=this.getElementList(),i=n[t],r=n[e];return!!((i==null?void 0:i.controlId)&&i.controlId===r.controlId&&r.controlComponent!==c.ControlComponent.POSTFIX)}getIsElementListContainFullControl(t){if(!t.some(i=>i.controlId))return!1;let e=0,n=0;for(let i=0;i<t.length;i++){const r=t[i];r.controlComponent===c.ControlComponent.PREFIX?e++:r.controlComponent===c.ControlComponent.POSTFIX&&n++}return!e||!n?!1:e===n}getIsDisabledControl(t={}){var i,r;if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:n}=t.range||this.range.getRange();return e===n&&~e&&~n&&(t.elementList||this.getElementList())[e].controlComponent===c.ControlComponent.POSTFIX?!1:!!((r=(i=this.activeControl.getElement())==null?void 0:i.control)!=null&&r.disabled)}getIsDisabledPasteControl(t={}){var i,r;if(this.draw.isDesignMode()||!this.activeControl)return!1;const{startIndex:e,endIndex:n}=t.range||this.range.getRange();return e===n&&~e&&~n&&(t.elementList||this.getElementList())[e].controlComponent===c.ControlComponent.POSTFIX?!1:!!((r=(i=this.activeControl.getElement())==null?void 0:i.control)!=null&&r.pasteDisabled)}getIsExistValueByElementListIndex(t,e){var i,r,o;const n=t[e];if(!n.controlId)return!1;if(((i=n.control)==null?void 0:i.type)===c.ControlType.CHECKBOX||((r=n.control)==null?void 0:r.type)===c.ControlType.RADIO)return!!((o=n.control)!=null&&o.code);if(n.controlComponent===c.ControlComponent.VALUE)return!0;if(n.controlComponent===c.ControlComponent.PLACEHOLDER)return!1;if(n.controlComponent===c.ControlComponent.PREFIX||n.controlComponent===c.ControlComponent.PRE_TEXT){let l=e+1;for(;l<t.length;){const a=t[l];if(a.controlId!==n.controlId)return!1;if(a.controlComponent===c.ControlComponent.VALUE)return!0;if(a.controlComponent===c.ControlComponent.PLACEHOLDER)return!1;l++}}if(n.controlComponent===c.ControlComponent.POSTFIX||n.controlComponent===c.ControlComponent.POST_TEXT){let l=e-1;for(;l>=0;){const a=t[l];if(a.controlId!==n.controlId)return!1;if(a.controlComponent===c.ControlComponent.VALUE)return!0;if(a.controlComponent===c.ControlComponent.PLACEHOLDER)return!1;l--}}return!1}getControlHighlight(t,e){return this.controlSearch.getControlHighlight(t,e)}getContainer(){return this.draw.getContainer()}getElementList(){return this.draw.getElementList()}getPosition(){const t=this.draw.getPosition().getPositionList(),{endIndex:e}=this.range.getRange();return t[e]||null}getPreY(){var i,r;const t=this.draw.getHeight(),e=this.draw.getPageGap();return((r=(i=this.getPosition())==null?void 0:i.pageNo)!=null?r:this.draw.getPageNo())*(t+e)}getRange(){return this.range.getRange()}getValueRange(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),i=e[n];let r=n;for(;r>0;){const l=e[r];if(l.controlId!==i.controlId||l.controlComponent===c.ControlComponent.PREFIX||l.controlComponent===c.ControlComponent.PRE_TEXT)break;r--}let o=n+1;for(;o<e.length;){const l=e[o];if(l.controlId!==i.controlId||l.controlComponent===c.ControlComponent.POSTFIX||l.controlComponent===c.ControlComponent.POST_TEXT)break;o++}return r===o?null:{startIndex:r,endIndex:o-1}}shrinkBoundary(t={}){this.range.shrinkBoundary(t)}getActiveControl(){return this.activeControl}getControlElementList(t={}){const e=t.elementList||this.getElementList(),{startIndex:n}=t.range||this.getRange(),i=e[n];if(!(i!=null&&i.controlId))return[];const r=[];let o=n;for(;o>0;){const a=e[o];if(a.controlId!==i.controlId)break;r.unshift(a),o--}let l=n+1;for(;l<e.length;){const a=e[l];if(a.controlId!==i.controlId)break;r.push(a),l++}return r}updateActiveControlValue(){this.activeControl&&(this.activeControlValue=this.getControlElementList())}emitControlChange(t){var l,a;if(!this.activeControl)return;const e=this.eventBus.isSubscribe("controlChange");if(!this.listener.controlChange&&!e)return;let n;const i=this.activeControlValue,r=this.activeControl.getElement();i!=null&&i.length?n=tt(i)[0].control:(n=te(_(r)).control,n.value=[]);const o={state:t,control:n,controlId:r.controlId};(a=(l=this.listener).controlChange)==null||a.call(l,o),e&&this.eventBus.emit("controlChange",o)}initControl(){var o,l;const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];if(this.activeControl){(this.activeControl instanceof Le||this.activeControl instanceof Te||this.activeControl instanceof Pe)&&(n.controlComponent===c.ControlComponent.POSTFIX?this.activeControl.destroy():this.activeControl.awake()),((o=this.preElement)==null?void 0:o.controlId)===n.controlId&&(n.controlComponent===c.ControlComponent.POSTFIX?this.emitControlChange(c.ControlState.INACTIVE):((l=this.preElement)==null?void 0:l.controlComponent)===c.ControlComponent.POSTFIX&&this.emitControlChange(c.ControlState.ACTIVE));const a=this.activeControl.getElement();if(n.controlId===a.controlId){this.updateActiveControlValue(),this.preElement=n;return}}if(this.destroyControl(),this.draw.isReadonly())return;const r=n.control;if(r.type===c.ControlType.TEXT)this.activeControl=new Rn(n,this);else if(r.type===c.ControlType.SELECT){const a=new Le(n,this);this.activeControl=a,a.awake()}else if(r.type===c.ControlType.CHECKBOX)this.activeControl=new Ve(n,this);else if(r.type===c.ControlType.RADIO)this.activeControl=new sn(n,this);else if(r.type===c.ControlType.DATE){const a=new Te(n,this);this.activeControl=a,a.awake()}else if(r.type===c.ControlType.NUMBER){const a=new Pe(n,this);this.activeControl=a,a.awake()}this.updateActiveControlValue(),this.preElement=n,n.controlComponent!==c.ControlComponent.POSTFIX&&this.emitControlChange(c.ControlState.ACTIVE)}destroyControl(t={}){var n;if(!this.activeControl)return;const{isEmitEvent:e=!0}=t;(this.activeControl instanceof Le||this.activeControl instanceof Te||this.activeControl instanceof Pe)&&this.activeControl.destroy(),e&&((n=this.preElement)==null?void 0:n.controlComponent)!==c.ControlComponent.POSTFIX&&this.emitControlChange(c.ControlState.INACTIVE),this.preElement=null,this.activeControl=null,this.activeControlValue=[]}repaintControl(t={}){const{curIndex:e,isCompute:n=!0,isSubmitHistory:i=!0,isSetCursor:r=!0}=t;e===void 0?(this.range.clearRange(),this.draw.render({isCompute:n,isSubmitHistory:i,isSetCursor:!1})):(this.range.setRange(e,e),this.draw.render({curIndex:e,isCompute:n,isSetCursor:r,isSubmitHistory:i}))}emitControlContentChange(t){var R,d,u,h,g,L;const e=this.eventBus.isSubscribe("controlContentChange");if(!e&&!this.listener.controlContentChange)return;const n=(t==null?void 0:t.controlElement)||((R=this.activeControl)==null?void 0:R.getElement());if(!n)return;const i=((d=t==null?void 0:t.context)==null?void 0:d.elementList)||this.getElementList(),{startIndex:r}=((u=t==null?void 0:t.context)==null?void 0:u.range)||this.getRange();if(!((h=i[r])!=null&&h.controlId))return;const o=(t==null?void 0:t.controlValue)||this.getControlElementList(t==null?void 0:t.context);let l;if(o!=null&&o.length?l=tt(o)[0].control:(l=n.control,l.value=[]),!l)return;const a={control:l,controlId:n.controlId};(L=(g=this.listener).controlContentChange)==null||L.call(g,a),e&&this.eventBus.emit("controlContentChange",a)}reAwakeControl(){if(!this.activeControl)return;const t=this.getElementList(),e=this.getRange(),n=t[e.startIndex];this.activeControl.setElement(n),(this.activeControl instanceof Te||this.activeControl instanceof Le||this.activeControl instanceof Pe)&&this.activeControl.getIsPopup()&&(this.activeControl.destroy(),this.activeControl.awake())}selectValue(){var o;const t=this.getElementList(),{startIndex:e}=this.getRange(),n=t[e];if(!(n!=null&&n.controlId)||n.controlComponent!==c.ControlComponent.VALUE&&((o=t[e+1])==null?void 0:o.controlComponent)===c.ControlComponent.VALUE)return!1;let i=e;for(;i>0&&t[i].controlComponent===c.ControlComponent.VALUE;)i--;let r=e+1;for(;r<t.length;){if(t[r].controlComponent!==c.ControlComponent.VALUE){r--;break}r++}if(i!==r){const l=this.range.getRange();return this.range.replaceRange({...l,startIndex:i,endIndex:r}),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),!0}return!1}moveCursor(t){var R,d;const{index:e,trIndex:n,tdIndex:i,tdValueIndex:r}=t;let o=this.draw.getOriginalElementList(),l;const a=t.isTable?r:e;if(t.isTable?(o=o[e].trList[n].tdList[i].value,l=o[r]):l=o[e],l.hide||((R=l.control)==null?void 0:R.hide)||((d=l.area)==null?void 0:d.hide)){const u=ge(o,a);return{newIndex:u,newElement:o[u]}}if(l.controlComponent===c.ControlComponent.VALUE)return{newIndex:a,newElement:l};if(l.controlComponent===c.ControlComponent.POSTFIX){let u=a+1;for(;u<o.length;){if(o[u].controlId!==l.controlId)return{newIndex:u-1,newElement:o[u-1]};if(u===o.length-1)return{newIndex:u,newElement:o[u]};u++}}else if(l.controlComponent===c.ControlComponent.PREFIX||l.controlComponent===c.ControlComponent.PRE_TEXT){let u=a+1;for(;u<o.length;){const h=o[u];if(h.controlId!==l.controlId||h.controlComponent!==c.ControlComponent.PREFIX&&h.controlComponent!==c.ControlComponent.PRE_TEXT)return{newIndex:u-1,newElement:o[u-1]};u++}}else if(l.controlComponent===c.ControlComponent.PLACEHOLDER||l.controlComponent===c.ControlComponent.POST_TEXT){let u=a-1;for(;u>0;){const h=o[u];if(h.controlId!==l.controlId||h.controlComponent===c.ControlComponent.VALUE||h.controlComponent===c.ControlComponent.PREFIX||h.controlComponent===c.ControlComponent.PRE_TEXT)return{newIndex:u,newElement:o[u]};u--}}return{newIndex:a,newElement:l}}removeControl(t,e={}){var R,d;const n=e.elementList||this.getElementList(),i=n[t];if(!this.draw.isDesignMode()&&!(i!=null&&i.hide)&&!((R=i==null?void 0:i.control)!=null&&R.hide)&&!((d=i==null?void 0:i.area)!=null&&d.hide)){const{deletable:u=!0}=i.control;if(!u)return null;const h=this.draw.getMode();if(h===c.EditorMode.FORM&&this.options.modeRule[h].controlDeletableDisabled)return null}let r=-1,o=-1,l=t;for(;l>0;){if(n[l].controlId!==i.controlId){r=l;break}l--}let a=t+1;for(;a<n.length;){if(n[a].controlId!==i.controlId){o=a-1;break}a++}return a===n.length&&(o=a-1),!~r&&!~o?t:(r=~r?r:0,this.draw.spliceElementList(n,r+1,o-r),r)}removePlaceholder(t,e={}){const n=e.elementList||this.getElementList(),i=n[t],r=n[t+1];if(i.controlComponent===c.ControlComponent.PLACEHOLDER||r.controlComponent===c.ControlComponent.PLACEHOLDER){let o=!1,l=t;for(;l<n.length;){const a=n[l];if(a.controlId!==i.controlId)break;a.controlComponent===c.ControlComponent.PLACEHOLDER?(o||(o=!0,this.draw.getHistoryManager().popUndo(),this.draw.submitHistory(t)),n.splice(l,1)):l++}}}addPlaceholder(t,e={}){const n=e.elementList||this.getElementList(),i=n[t],r=i.control;if(!r.placeholder)return;const o=pt(r.placeholder),l=mt(i,yt);for(let a=0;a<o.length;a++){const R=o[a],d={...l,value:R===`
88
- `?y:R,controlId:i.controlId,type:c.ElementType.CONTROL,control:i.control,controlComponent:c.ControlComponent.PLACEHOLDER,color:this.controlOptions.placeholderColor};Ot(n,[d],t,{editorOptions:this.options}),this.draw.spliceElementList(n,t+a+1,0,[d])}}setValue(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.setValue(t)}setControlProperties(t,e={}){const n=e.elementList||this.getElementList(),{startIndex:i}=e.range||this.getRange(),r=n[i];let o=i;for(;o>0;){const a=n[o];if(a.controlId!==r.controlId)break;a.control={...a.control,...t},o--}let l=i+1;for(;l<n.length;){const a=n[l];if(a.controlId!==r.controlId)break;a.control={...a.control,...t},l++}}keydown(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.keydown(t)}cut(){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.cut()}getValueById(t){const{id:e,groupId:n,conceptId:i,areaId:r}=t,o=[];if(!e&&!i&&!n)return o;const l=(R,d)=>{let u=0;for(;u<R.length;){const h=R[u];if(u++,h.type===c.ElementType.TABLE){const X=h.trList;for(let I=0;I<X.length;I++){const f=X[I];for(let S=0;S<f.tdList.length;S++){const N=f.tdList[S];l(N.value,d)}}}if(!h.control||n&&h.control.groupId!==n||e&&h.controlId!==e||i&&h.control.conceptId!==i||r&&h.areaId!==r)continue;const{type:g,code:L,valueSets:T}=h.control;let M=u,P="";const O=[];for(;M<R.length;){const X=R[M];if(X.controlId!==h.controlId)break;(g===c.ControlType.TEXT||g===c.ControlType.DATE||g===c.ControlType.NUMBER)&&X.controlComponent===c.ControlComponent.VALUE&&(P+=X.value,O.push(bt(X,ve))),M++}if(g===c.ControlType.TEXT||g===c.ControlType.DATE||g===c.ControlType.NUMBER)o.push({...h.control,zone:d,value:P||null,innerText:P||null,elementList:tt(O)});else if(g===c.ControlType.SELECT||g===c.ControlType.CHECKBOX||g===c.ControlType.RADIO){const X=L==null?void 0:L.split(",").map(I=>{var f;return(f=T==null?void 0:T.find(S=>S.code===I))==null?void 0:f.value}).filter(Boolean).join("");o.push({...h.control,zone:d,value:L||null,innerText:X||null})}u=M}},a=[{zone:c.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:c.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:c.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:R,elementList:d}of a)l(d,R);return o}setValueListById(t){if(!t.length)return;let e=!1,n=!1;const i=o=>{let l=0;for(;l<o.length;){const a=o[l];if(l++,a.type===c.ElementType.TABLE){const O=a.trList;for(let X=0;X<O.length;X++){const I=O[X];for(let f=0;f<I.tdList.length;f++){const S=I.tdList[f];i(S.value)}}}if(!a.control)continue;const R=t.find(O=>{var X;return(!O.groupId||O.groupId===((X=a.control)==null?void 0:X.groupId))&&(O.id&&a.controlId===O.id||O.conceptId&&a.control.conceptId===O.conceptId||O.areaId&&a.areaId===O.areaId)});if(!R)continue;const{value:d,isSubmitHistory:u=!0}=R;e=!0,u&&(n=!0);const{type:h}=a.control;let g=l;for(;g<o.length&&o[g].controlId===a.controlId;)g++;const T={range:{startIndex:l-1,endIndex:g-2},elementList:o},M={isIgnoreDisabledRule:!0,isIgnoreDeletedRule:!0};if(h===c.ControlType.TEXT){const O=Array.isArray(d)?d:d?[{value:d}]:[];O.length&&ut(O,{isHandleFirstElement:!1,editorOptions:this.options});const X=new Rn(a,this);this.activeControl=X,O.length?X.setValue(O,T,M):X.clearValue(T,M)}else if(h===c.ControlType.SELECT){if(Array.isArray(d))continue;const O=new Le(a,this);this.activeControl=O,d?O.setSelect(d,T,M):O.clearSelect(T,M)}else if(h===c.ControlType.CHECKBOX){if(Array.isArray(d))continue;const O=new Ve(a,this);this.activeControl=O;const X=d?d.split(","):[];O.setSelect(X,T,M)}else if(h===c.ControlType.RADIO){if(Array.isArray(d))continue;const O=new sn(a,this);this.activeControl=O;const X=d?[d]:[];O.setSelect(X,T,M)}else if(h===c.ControlType.DATE){const O=new Te(a,this);this.activeControl=O,we(d)?(d.length&&ut(d,{isHandleFirstElement:!1,editorOptions:this.options}),O.setValue(d,T,M)):Ki(d)?O.setSelect(d,T,M):O.clearSelect(T,M)}else if(h===c.ControlType.NUMBER){const O=Array.isArray(d)?d:d?[{value:d}]:[];O.length&&ut(O,{isHandleFirstElement:!1,editorOptions:this.options});const X=new Pe(a,this);this.activeControl=X,O.length?X.setValue(O,T,M):X.clearValue(T,M)}this.emitControlContentChange({context:T}),this.activeControl=null;let P=l;for(;P<o.length&&o[P].controlId===a.controlId;)P++;l=P}};this.destroyControl({isEmitEvent:!1});const r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const o of r)i(o);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}setExtensionListById(t){if(!t.length)return;const e=i=>{let r=0;for(;r<i.length;){const o=i[r];if(r++,o.type===c.ElementType.TABLE){const d=o.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];e(L.value)}}}if(!o.control)continue;const l=t.find(d=>{var u;return(!d.groupId||d.groupId===((u=o.control)==null?void 0:u.groupId))&&(d.id&&o.controlId===d.id||d.conceptId&&o.control.conceptId===d.conceptId||d.areaId&&o.areaId===d.areaId)});if(!l)continue;const{extension:a}=l;this.setControlProperties({extension:a},{elementList:i,range:{startIndex:r,endIndex:r}});let R=r;for(;R<i.length&&i[R].controlId===o.controlId;)R++;r=R}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i)}setPropertiesListById(t){if(!t.length)return;let e=!1,n=!1;const i=o=>{let l=0;for(;l<o.length;){const a=o[l];if(l++,a.type===c.ElementType.TABLE){const g=a.trList;for(let L=0;L<g.length;L++){const T=g[L];for(let M=0;M<T.tdList.length;M++){const P=T.tdList[M];i(P.value)}}}if(!a.control)continue;const R=t.find(g=>{var L;return(!g.groupId||g.groupId===((L=a.control)==null?void 0:L.groupId))&&(g.id&&a.controlId===g.id||g.conceptId&&a.control.conceptId===g.conceptId||g.areaId&&a.areaId===g.areaId)});if(!R)continue;const{properties:d,isSubmitHistory:u=!0}=R;e=!0,u&&(n=!0),this.setControlProperties({...a.control,...d,value:a.control.value},{elementList:o,range:{startIndex:l,endIndex:l}}),yt.forEach(g=>{const L=d[g];L&&Reflect.set(a,g,L)});let h=l;for(;h<o.length&&o[h].controlId===a.controlId;)h++;l=h}},r={header:this.draw.getHeaderElementList(),main:this.draw.getOriginalMainElementList(),footer:this.draw.getFooterElementList()};for(const o in r){const l=r[o];i(l)}if(!!e){for(const o in r){const l=o,a=tt(r[l],{isClassifyArea:!0,extraPickAttrs:["id"]});r[l]=a,ut(a,{editorOptions:this.options,isForceCompensation:!0})}this.draw.setEditorData(r),n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1})}}getList(){const t=[];function e(i){for(let r=0;r<i.length;r++){const o=i[r];if(o.type===c.ElementType.TABLE){const l=o.trList;for(let a=0;a<l.length;a++){const R=l[a];for(let d=0;d<R.tdList.length;d++){const h=R.tdList[d].value;e(h)}}}if(o.controlId){const l=bt(o,[...Je,...fe]);t.push(l)}}}const n=[this.draw.getHeader().getElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooter().getElementList()];for(const i of n)e(i);return tt(t,{extraPickAttrs:["controlId"]})}recordBorderInfo(t,e,n,i){this.controlBorder.recordBorderInfo(t,e,n,i)}drawBorder(t){this.controlBorder.render(t)}getPreControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(a,R){for(let d=R;d>0;d--){const u=a[d];if(u.type===c.ElementType.TABLE){const g=u.trList||[];for(let L=g.length-1;L>=0;L--){const T=g[L],M=T.tdList;for(let P=M.length-1;P>=0;P--){const O=M[P],X=i(O.value,O.value.length-1);if(X)return{positionContext:{isTable:!0,index:d,trIndex:L,tdIndex:P,tdId:O.id,trId:T.id,tableId:u.id},nextIndex:X.nextIndex}}}}if(!u.controlId||u.controlId===n.controlId)continue;let h=d;for(;h>0;){const g=a[h];if(g.controlComponent===c.ControlComponent.VALUE||g.controlComponent===c.ControlComponent.PREFIX||g.controlComponent===c.ControlComponent.PRE_TEXT)break;h--}return{positionContext:{isTable:!1},nextIndex:h}}return null}const{startIndex:r}=this.range.getRange(),o=this.getElementList(),l=i(o,r);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:R,trIndex:d,tdIndex:u}=e,h=a[R].trList;for(let L=d;L>=0;L--){const T=h[L],M=T.tdList;for(let P=M.length-1;P>=0;P--){if(d===L&&P>=u)continue;const O=M[P],X=i(O.value,O.value.length-1);if(X)return{positionContext:{isTable:!0,index:e.index,trIndex:L,tdIndex:P,tdId:O.id,trId:T.id,tableId:n.tableId},nextIndex:X.nextIndex}}}const g=i(a,R-1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}getNextControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(a,R){var d,u;for(let h=R;h<a.length;h++){const g=a[h];if(g.type===c.ElementType.TABLE){const L=g.trList||[];for(let T=0;T<L.length;T++){const M=L[T],P=M.tdList;for(let O=0;O<P.length;O++){const X=P[O],I=i(X.value,0);if(I)return{positionContext:{isTable:!0,index:h,trIndex:T,tdIndex:O,tdId:X.id,trId:M.id,tableId:g.id},nextIndex:I.nextIndex}}}}if(!(!g.controlId||g.controlId===n.controlId||((d=a[h+1])==null?void 0:d.controlComponent)===c.ControlComponent.PREFIX||((u=a[h+1])==null?void 0:u.controlComponent)===c.ControlComponent.PRE_TEXT))return{positionContext:{isTable:!1},nextIndex:h}}return null}const{endIndex:r}=this.range.getRange(),o=this.getElementList(),l=i(o,r);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:R,trIndex:d,tdIndex:u}=e,h=a[R].trList;for(let L=d;L<h.length;L++){const T=h[L],M=T.tdList;for(let P=0;P<M.length;P++){if(d===L&&P<=u)continue;const O=M[P],X=i(O.value,0);if(X)return{positionContext:{isTable:!0,index:e.index,trIndex:L,tdIndex:P,tdId:O.id,trId:T.id,tableId:n.tableId},nextIndex:X.nextIndex}}}const g=i(a,R+1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}initNextControl(t={}){const{direction:e=dt.DOWN}=t;let n=null;if(e===dt.UP?n=this.getPreControlContext():n=this.getNextControlContext(),!n)return;const{nextIndex:i,positionContext:r}=n;this.draw.getPosition().setPositionContext(r),this.draw.getRange().replaceRange({startIndex:i,endIndex:i}),this.draw.render({curIndex:i,isCompute:!1,isSetCursor:!0,isSubmitHistory:!1})}setMinWidthControlInfo(t){var d,u,h,g,L;const{row:e,rowElement:n,controlRealWidth:i,availableWidth:r}=t;if(!((d=n.control)!=null&&d.minWidth))return;const{scale:o}=this.options,l=n.control.minWidth*o;let a=null;if(((u=n.control)==null?void 0:u.minWidth)&&(((h=n.control)==null?void 0:h.rowFlex)===c.RowFlex.CENTER||((g=n.control)==null?void 0:g.rowFlex)===c.RowFlex.RIGHT)){let T=n.metrics.width,M=e.elementList.length-1;for(;M>=0;){const P=e.elementList[M];if(T+=P.metrics.width,((L=e.elementList[M-1])==null?void 0:L.controlComponent)===c.ControlComponent.PREFIX){a=P;break}M--}a&&T<l&&(n.control.rowFlex===c.RowFlex.CENTER?a.left=(l-T)/2:n.control.rowFlex===c.RowFlex.RIGHT&&(a.left=l-T-n.metrics.width))}const R=l-i;if(R>0){const T=(a==null?void 0:a.left)||0,M=r-e.width-n.metrics.width,P=Math.min(M,R);n.left=P-T,e.width+=P-T}}}class $s{constructor(t){this.draw=t,this.options=t.getOptions()}setSelect(t){const{checkbox:e}=t;e?e.value=!e.value:t.checkbox={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:i,row:r}=t;let{y:o}=t;const{checkbox:{gap:l,lineWidth:a,fillStyle:R,strokeStyle:d,verticalAlign:u},scale:h}=this.options,{metrics:g,checkbox:L}=r.elementList[i];if(u===c.VerticalAlign.TOP||u===c.VerticalAlign.MIDDLE){let X=i+1,I=null;for(;X<r.elementList.length&&(I=r.elementList[X],!(I.value!==y&&I.value!==Ce));)X++;if(I){const{metrics:{boundingBoxAscent:f,boundingBoxDescent:S}}=I,N=f+S;N>g.height&&(u===c.VerticalAlign.TOP?o-=f-g.height:u===c.VerticalAlign.MIDDLE&&(o-=(N-g.height)/2))}}const T=Math.round(n+l*h),M=Math.round(o-g.height+a),P=g.width-l*2*h,O=g.height;e.save(),e.beginPath(),e.translate(.5,.5),L!=null&&L.value?(e.lineWidth=a,e.strokeStyle="red",e.rect(T,M,P,O),e.stroke(),e.beginPath(),e.fillStyle=R,e.fillRect(T,M,P,O),e.beginPath(),e.strokeStyle=d,e.lineWidth=a*2*h,e.moveTo(T+2*h,M+O/2),e.lineTo(T+P/2,M+O-3*h),e.lineTo(T+P-2*h,M+3*h),e.stroke()):(e.lineWidth=a,e.strokeStyle="red",e.rect(T,M,P,O),e.stroke());debugger;e.closePath(),e.restore()}}class js{constructor(t){this.draw=t,this.options=t.getOptions()}setSelect(t){const{radio:e}=t;e?e.value=!e.value:t.radio={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:i,row:r}=t;let{y:o}=t;const{radio:{gap:l,lineWidth:a,fillStyle:R,strokeStyle:d,verticalAlign:u},scale:h}=this.options,{metrics:g,radio:L}=r.elementList[i];if(u===c.VerticalAlign.TOP||u===c.VerticalAlign.MIDDLE){let X=i+1,I=null;for(;X<r.elementList.length&&(I=r.elementList[X],!(I.value!==y&&I.value!==Ce));)X++;if(I){const{metrics:{boundingBoxAscent:f,boundingBoxDescent:S}}=I,N=f+S;N>g.height&&(u===c.VerticalAlign.TOP?o-=f-g.height:u===c.VerticalAlign.MIDDLE&&(o-=(N-g.height)/2))}}const T=Math.round(n+l*h),M=Math.round(o-g.height+a),P=g.width-l*2*h,O=g.height;e.save(),e.beginPath(),e.translate(.5,.5),e.strokeStyle=L!=null&&L.value?R:d,e.lineWidth=a,e.arc(T+P/2,M+O/2,P/2,0,Math.PI*2),e.stroke(),L!=null&&L.value&&(e.beginPath(),e.fillStyle=R,e.arc(T+P/2,M+O/2,P/3,0,Math.PI*2),e.fill()),e.closePath(),e.restore()}}const ei="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHA9Ilx1MjAwQiIsdT1gCmA7ZnVuY3Rpb24gYShpKXt2YXIgYyxmO2xldCBsPSIiLG49MDtmb3IoO248aS5sZW5ndGg7KXtjb25zdCB0PWlbbl07aWYodC50eXBlPT09InRhYmxlIil7aWYodC50ckxpc3QpZm9yKGxldCBzPTA7czx0LnRyTGlzdC5sZW5ndGg7cysrKXtjb25zdCBvPXQudHJMaXN0W3NdO2ZvcihsZXQgZT0wO2U8by50ZExpc3QubGVuZ3RoO2UrKyl7Y29uc3Qgcj1vLnRkTGlzdFtlXTtsKz1hKHIudmFsdWUpfX19ZWxzZSBpZih0LnR5cGU9PT0iaHlwZXJsaW5rIil7Y29uc3Qgcz10Lmh5cGVybGlua0lkLG89W107Zm9yKDtuPGkubGVuZ3RoOyl7Y29uc3QgZT1pW25dO2lmKHMhPT1lLmh5cGVybGlua0lkKXtuLS07YnJlYWt9ZGVsZXRlIGUudHlwZSxvLnB1c2goZSksbisrfWwrPWEobyl9ZWxzZSBpZih0LmNvbnRyb2xJZCl7aWYoISgoYz10LmNvbnRyb2wpIT1udWxsJiZjLmhpZGUpKXtjb25zdCBzPXQuY29udHJvbElkLG89W107Zm9yKDtuPGkubGVuZ3RoOyl7Y29uc3QgZT1pW25dO2lmKHMhPT1lLmNvbnRyb2xJZCl7bi0tO2JyZWFrfWUuY29udHJvbENvbXBvbmVudD09PSJ2YWx1ZSImJihkZWxldGUgZS5jb250cm9sSWQsby5wdXNoKGUpKSxuKyt9bCs9YShvKX19ZWxzZSghdC50eXBlfHx0LnR5cGU9PT0idGV4dCIpJiYhKChmPXQuYXJlYSkhPW51bGwmJmYuaGlkZSkmJihsKz10LnZhbHVlKTtuKyt9cmV0dXJuIGx9ZnVuY3Rpb24gaChpKXtjb25zdCBsPVtdLG49L1swLTldLyxjPS9bQS1aYS16XS8sZj0vXHMvO2xldCB0PSExLHM9ITEsbz0iIjtmdW5jdGlvbiBlKCl7byYmKGwucHVzaChvKSxvPSIiKX1mb3IoY29uc3QgciBvZiBpKWMudGVzdChyKT8odHx8ZSgpLG8rPXIsdD0hMCxzPSExKTpuLnRlc3Qocik/KHN8fGUoKSxvKz1yLHQ9ITEscz0hMCk6KGUoKSx0PSExLHM9ITEsZi50ZXN0KHIpfHxsLnB1c2gocikpO3JldHVybiBlKCksbH1vbm1lc3NhZ2U9aT0+e2NvbnN0IGw9aS5kYXRhLGM9YShsKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke3B9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChwLCJnIiksdSksZj1oKGMpO3Bvc3RNZXNzYWdlKGYubGVuZ3RoKX19KSgpOwo=",ni=typeof window!="undefined"&&window.Blob&&new Blob([atob(ei)],{type:"text/javascript;charset=utf-8"});function qs(){const s=ni&&(window.URL||window.webkitURL).createObjectURL(ni);try{return s?new Worker(s,{}):new Worker("data:application/javascript;base64,"+ei,{type:"module"})}finally{s&&(window.URL||window.webkitURL).revokeObjectURL(s)}}const ii="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGg9e2ZpcnN0OjEsc2Vjb25kOjIsdGhpcmQ6Myxmb3VydGg6NCxmaWZ0aDo1LHNpeHRoOjZ9LGI9WyJ0ZXh0IiwiaHlwZXJsaW5rIiwic3Vic2NyaXB0Iiwic3VwZXJzY3JpcHQiLCJjb250cm9sIiwiZGF0ZSIsImxhYmVsIl0sbT0iXHUyMDBCIjtmdW5jdGlvbiBJKGMpe3JldHVybiFjLnR5cGV8fGIuaW5jbHVkZXMoYy50eXBlKX1mdW5jdGlvbiBOKGMpe3ZhciBFO2NvbnN0e2VsZW1lbnRMaXN0OmcscG9zaXRpb25MaXN0OmR9PWMscD1bXTtsZXQgcj0wO2Zvcig7cjxnLmxlbmd0aDspe2NvbnN0IHQ9Z1tyXSxsPShlLG4scyk9Pntjb25zdCB1PWUudGl0bGVJZCxMPWUubGV2ZWwsaT17dHlwZToidGl0bGUiLHZhbHVlOiIiLGxldmVsOkwsdGl0bGVJZDp1LHBhZ2VObzpkW3JdLnBhZ2VOb30sbz1bXTtmb3IoO3M8bi5sZW5ndGg7KXtjb25zdCBhPW5bc107aWYodSE9PWEudGl0bGVJZCl7cy0tO2JyZWFrfW8ucHVzaChhKSxzKyt9cmV0dXJuIGkudmFsdWU9by5maWx0ZXIoYT0+SShhKSkubWFwKGE9PmEudmFsdWUpLmpvaW4oIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChtLCJnIiksIiIpLHtwb3NpdGlvbjpzLHRpdGxlRWxlbWVudDppfX07aWYodC50aXRsZUlkKXtjb25zdHtwb3NpdGlvbjplLHRpdGxlRWxlbWVudDpufT1sKHQsZyxyKTtyPWUscC5wdXNoKG4pfWlmKHQudHlwZT09PSJ0YWJsZSIpe2NvbnN0IGU9dC50ckxpc3Q7Zm9yKGxldCBuPTA7bjxlLmxlbmd0aDtuKyspe2NvbnN0IHM9ZVtuXTtmb3IobGV0IHU9MDt1PHMudGRMaXN0Lmxlbmd0aDt1Kyspe2NvbnN0IGk9cy50ZExpc3RbdV0udmFsdWU7aWYoaS5sZW5ndGg+MSl7bGV0IG89MTtmb3IoO288aS5sZW5ndGg7KXtpZigoRT1pW29dKSE9bnVsbCYmRS50aXRsZUlkKXtjb25zdHt0aXRsZUVsZW1lbnQ6YSxwb3NpdGlvbjp5fT1sKGlbb10saSxvKTtwLnB1c2goYSksbz15fW8rK319fX19cisrfWlmKCFwLmxlbmd0aClyZXR1cm4gbnVsbDtjb25zdCBmPSh0LGwpPT57Y29uc3QgZT1sLnN1YkNhdGFsb2dbbC5zdWJDYXRhbG9nLmxlbmd0aC0xXSxuPWhbZT09bnVsbD92b2lkIDA6ZS5sZXZlbF0scz1oW3QubGV2ZWxdO2UmJnM+bj9mKHQsZSk6bC5zdWJDYXRhbG9nLnB1c2goe2lkOnQudGl0bGVJZCxuYW1lOnQudmFsdWUsbGV2ZWw6dC5sZXZlbCxwYWdlTm86dC5wYWdlTm8sc3ViQ2F0YWxvZzpbXX0pfSx2PVtdO2ZvcihsZXQgdD0wO3Q8cC5sZW5ndGg7dCsrKXtjb25zdCBsPXBbdF0sZT12W3YubGVuZ3RoLTFdLG49aFtlPT1udWxsP3ZvaWQgMDplLmxldmVsXSxzPWhbbC5sZXZlbF07ZSYmcz5uP2YobCxlKTp2LnB1c2goe2lkOmwudGl0bGVJZCxuYW1lOmwudmFsdWUsbGV2ZWw6bC5sZXZlbCxwYWdlTm86bC5wYWdlTm8sc3ViQ2F0YWxvZzpbXX0pfXJldHVybiB2fW9ubWVzc2FnZT1jPT57Y29uc3QgZz1jLmRhdGEsZD1OKGcpO3Bvc3RNZXNzYWdlKGQpfX0pKCk7Cg==",oi=typeof window!="undefined"&&window.Blob&&new Blob([atob(ii)],{type:"text/javascript;charset=utf-8"});function tr(){const s=oi&&(window.URL||window.webkitURL).createObjectURL(oi);try{return s?new Worker(s,{}):new Worker("data:application/javascript;base64,"+ii,{type:"module"})}finally{s&&(window.URL||window.webkitURL).revokeObjectURL(s)}}const si="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHUoZSl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBlKXtpZihzLnR5cGU9PT0idGFibGUiKXtjb25zdCBvPXMudHJMaXN0O2ZvcihsZXQgbj0wO248by5sZW5ndGg7bisrKXtjb25zdCBjPW9bbl07Zm9yKGxldCByPTA7cjxjLnRkTGlzdC5sZW5ndGg7cisrKXtjb25zdCBpPWMudGRMaXN0W3JdO3QucHVzaCguLi51KGkudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgbyBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMobyl8fHQucHVzaChvKX1yZXR1cm4gdH1vbm1lc3NhZ2U9ZT0+e2NvbnN0IHQ9ZS5kYXRhLHM9dSh0KTtwb3N0TWVzc2FnZShzKX19KSgpOwo=",ri=typeof window!="undefined"&&window.Blob&&new Blob([atob(si)],{type:"text/javascript;charset=utf-8"});function er(){const s=ri&&(window.URL||window.webkitURL).createObjectURL(ri);try{return s?new Worker(s,{}):new Worker("data:application/javascript;base64,"+si,{type:"module"})}finally{s&&(window.URL||window.webkitURL).revokeObjectURL(s)}}const li="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBSPShlPT4oZS5IQUxGPSJoYWxmIixlLk9ORV9USElSRD0ib25lLXRoaXJkIixlLlFVQVJURVI9InF1YXJ0ZXIiLGUpKShSfHx7fSksZz0oZT0+KGUuQVJBQklDPSJhcmFiaWMiLGUuQ0hJTkVTRT0iY2hpbmVzZSIsZSkpKGd8fHt9KTtjb25zdCB2PSJcdTIwMEIiO1IuSEFMRisiIiwxLzIsUi5PTkVfVEhJUkQrIiIsMS8zLFIuUVVBUlRFUisiIiwxLzQ7ZnVuY3Rpb24gUyhlKXtpZih0eXBlb2Ygc3RydWN0dXJlZENsb25lPT0iZnVuY3Rpb24iKXJldHVybiBzdHJ1Y3R1cmVkQ2xvbmUoZSk7aWYoIWV8fHR5cGVvZiBlIT0ib2JqZWN0IilyZXR1cm4gZTtsZXQgbj17fTtyZXR1cm4gQXJyYXkuaXNBcnJheShlKT9uPWUubWFwKHU9PlModSkpOk9iamVjdC5rZXlzKGUpLmZvckVhY2godT0+e25bdV09UyhlW3VdKX0pLG59ZnVuY3Rpb24geShlLG4pe2NvbnN0IHU9e307Zm9yKGNvbnN0IGYgaW4gZSluLmluY2x1ZGVzKGYpJiYodVtmXT1lW2ZdKTtyZXR1cm4gdX1mdW5jdGlvbiBYKGUsbil7cmV0dXJuIGUubGVuZ3RoIT09bi5sZW5ndGg/ITE6IWUuc29tZSh1PT4hbi5pbmNsdWRlcyh1KSl9dmFyIGE9KGU9PihlLlRFWFQ9InRleHQiLGUuSU1BR0U9ImltYWdlIixlLlRBQkxFPSJ0YWJsZSIsZS5IWVBFUkxJTks9Imh5cGVybGluayIsZS5TVVBFUlNDUklQVD0ic3VwZXJzY3JpcHQiLGUuU1VCU0NSSVBUPSJzdWJzY3JpcHQiLGUuU0VQQVJBVE9SPSJzZXBhcmF0b3IiLGUuUEFHRV9CUkVBSz0icGFnZUJyZWFrIixlLkNPTlRST0w9ImNvbnRyb2wiLGUuQVJFQT0iYXJlYSIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUuUkFESU89InJhZGlvIixlLkxBVEVYPSJsYXRleCIsZS5UQUI9InRhYiIsZS5EQVRFPSJkYXRlIixlLkJMT0NLPSJibG9jayIsZS5USVRMRT0idGl0bGUiLGUuTElTVD0ibGlzdCIsZS5MQUJFTD0ibGFiZWwiLGUpKShhfHx7fSk7Y29uc3QgXz1bInJvd0ZsZXgiLCJyb3dNYXJnaW4iXSxCPVsidHlwZSIsImZvbnQiLCJzaXplIiwiYm9sZCIsImNvbG9yIiwiaXRhbGljIiwiaGlnaGxpZ2h0IiwidW5kZXJsaW5lIiwic3RyaWtlb3V0Iiwicm93RmxleCIsInJvd01hcmdpbiIsImRhc2hBcnJheSIsInRyTGlzdCIsInRhYmxlVG9vbERpc2FibGVkIiwiYm9yZGVyVHlwZSIsImJvcmRlckNvbG9yIiwidHJhbnNsYXRlWCIsIndpZHRoIiwiaGVpZ2h0IiwidXJsIiwiY29sZ3JvdXAiLCJ2YWx1ZUxpc3QiLCJjb250cm9sIiwiY2hlY2tib3giLCJyYWRpbyIsImRhdGVGb3JtYXQiLCJibG9jayIsImxldmVsIiwidGl0bGUiLCJsaXN0VHlwZSIsImxpc3RTdHlsZSIsImxpc3RXcmFwIiwiZ3JvdXBJZHMiLCJjb25jZXB0SWQiLCJpbWdEaXNwbGF5IiwiaW1nRmxvYXRQb3NpdGlvbiIsImltZ1Rvb2xEaXNhYmxlZCIsImltZ1ByZXZpZXdEaXNhYmxlZCIsImltZ0Nyb3AiLCJpbWdDYXB0aW9uIiwidGV4dERlY29yYXRpb24iLCJleHRlbnNpb24iLCJleHRlcm5hbElkIiwiYXJlYUlkIiwiYXJlYSIsImhpZGUiLCJsYWJlbCIsImxhYmVsSWQiLCJsaW5lV2lkdGgiLCJmb3JtSW5wdXQiXSxVPVsiY29uY2VwdElkIiwiZXh0ZW5zaW9uIiwiZXh0ZXJuYWxJZCIsInZlcnRpY2FsQWxpZ24iLCJiYWNrZ3JvdW5kQ29sb3IiLCJib3JkZXJUeXBlcyIsInNsYXNoVHlwZXMiLCJkaXNhYmxlZCIsImRlbGV0YWJsZSJdLHc9WyJmb250Iiwic2l6ZSIsImJvbGQiLCJoaWdobGlnaHQiLCJpdGFsaWMiLCJzdHJpa2VvdXQiXTthLlRFWFQsYS5IWVBFUkxJTkssYS5TVUJTQ1JJUFQsYS5TVVBFUlNDUklQVCxhLkNPTlRST0wsYS5EQVRFLGEuSU1BR0UsYS5MQVRFWCxhLkJMT0NLLGEuUEFHRV9CUkVBSyxhLlNFUEFSQVRPUixhLlRBQkxFLGEuVElUTEUsYS5MSVNUO3ZhciBQPShlPT4oZS5VTD0idWwiLGUuT0w9Im9sIixlKSkoUHx8e30pLE89KGU9PihlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuQ0hFQ0tCT1g9ImNoZWNrYm94IixlKSkoT3x8e30pLHA9KGU9PihlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuREVDSU1BTD0iZGVjaW1hbCIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUpKShwfHx7fSk7Ty5ESVNDKyIiLE8uQ0lSQ0xFKyIiLE8uU1FVQVJFKyIiLE8uQ0hFQ0tCT1grIiIsUC5PTCsiIixQLlVMKyIiLHAuRElTQysiIixwLkNJUkNMRSsiIixwLlNRVUFSRSsiIixwLkRFQ0lNQUwrIiIscC5DSEVDS0JPWCsiIjt2YXIgRT0oZT0+KGUuRklSU1Q9ImZpcnN0IixlLlNFQ09ORD0ic2Vjb25kIixlLlRISVJEPSJ0aGlyZCIsZS5GT1VSVEg9ImZvdXJ0aCIsZS5GSUZUSD0iZmlmdGgiLGUuU0lYVEg9InNpeHRoIixlKSkoRXx8e30pO0UuRklSU1QrIiIsRS5TRUNPTkQrIiIsRS5USElSRCsiIixFLkZPVVJUSCsiIixFLkZJRlRIKyIiLEUuU0lYVEgrIiIsRS5GSVJTVCsiIixFLlNFQ09ORCsiIixFLlRISVJEKyIiLEUuRk9VUlRIKyIiLEUuRklGVEgrIiIsRS5TSVhUSCsiIixFLkZJUlNULEUuU0VDT05ELEUuVEhJUkQsRS5GT1VSVEgsRS5GSUZUSCxFLlNJWFRIO3ZhciBBPShlPT4oZS5QUkVGSVg9InByZWZpeCIsZS5QT1NURklYPSJwb3N0Zml4IixlLlBSRV9URVhUPSJwcmVUZXh0IixlLlBPU1RfVEVYVD0icG9zdFRleHQiLGUuUExBQ0VIT0xERVI9InBsYWNlaG9sZGVyIixlLlZBTFVFPSJ2YWx1ZSIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUuUkFESU89InJhZGlvIixlKSkoQXx8e30pLEQ9KGU9PihlLkxFRlQ9ImxlZnQiLGUuQ0VOVEVSPSJjZW50ZXIiLGUuUklHSFQ9InJpZ2h0IixlLkFMSUdOTUVOVD0iYWxpZ25tZW50IixlLkpVU1RJRlk9Imp1c3RpZnkiLGUpKShEfHx7fSksTj0oZT0+KGUuQ09OVEFJTj0iY29udGFpbiIsZS5DT1ZFUj0iY292ZXIiLGUpKShOfHx7fSksaz0oZT0+KGUuUkVQRUFUPSJyZXBlYXQiLGUuTk9fUkVQRUFUPSJuby1yZXBlYXQiLGUuUkVQRUFUX1g9InJlcGVhdC14IixlLlJFUEVBVF9ZPSJyZXBlYXQteSIsZSkpKGt8fHt9KTtOLkNPVkVSLGsuTk9fUkVQRUFUO3ZhciBiPShlPT4oZS5UT1A9InRvcCIsZS5NSURETEU9Im1pZGRsZSIsZS5CT1RUT009ImJvdHRvbSIsZSkpKGJ8fHt9KTtiLkJPVFRPTSxSLkhBTEYsUi5IQUxGO2NvbnN0IEs9e1BBR0VfTk86IntwYWdlTm99IixQQUdFX0NPVU5UOiJ7cGFnZUNvdW50fSJ9O0QuQ0VOVEVSLEsuUEFHRV9OTyxnLkFSQUJJQyxiLkJPVFRPTTt2YXIgbT0oZT0+KGUuVEVYVD0idGV4dCIsZS5JTUFHRT0iaW1hZ2UiLGUpKShtfHx7fSk7bS5URVhULGcuQVJBQklDO3ZhciB4PShlPT4oZS5QQUdFPSJwYWdlIixlLkNPTlRJTlVJVFk9ImNvbnRpbnVpdHkiLGUpKSh4fHx7fSk7eC5DT05USU5VSVRZO2Z1bmN0aW9uIE0oZSxuKXtjb25zdCB1PU9iamVjdC5rZXlzKGUpLGY9T2JqZWN0LmtleXMobik7aWYodS5sZW5ndGghPT1mLmxlbmd0aClyZXR1cm4hMTtmb3IobGV0IEk9MDtJPHUubGVuZ3RoO0krKyl7Y29uc3QgbD11W0ldO2lmKGwhPT0idmFsdWUiJiYhKGw9PT0iZ3JvdXBJZHMiJiZBcnJheS5pc0FycmF5KGVbbF0pJiZBcnJheS5pc0FycmF5KG5bbF0pJiZYKGVbbF0sbltsXSkpJiZlW2xdIT09bltsXSlyZXR1cm4hMX1yZXR1cm4hMH1mdW5jdGlvbiBIKGUsbj17fSl7Y29uc3R7ZXh0cmFQaWNrQXR0cnM6dX09bixmPVsuLi5CXTt1JiZmLnB1c2goLi4udSk7Y29uc3QgST17dmFsdWU6ZS52YWx1ZT09PXY/YApgOmUudmFsdWV9O3JldHVybiBmLmZvckVhY2gobD0+e2NvbnN0IEM9ZVtsXTtDIT09dm9pZCAwJiYoSVtsXT1DKX0pLEl9ZnVuY3Rpb24gVChlLG49e30pe2NvbnN0e2V4dHJhUGlja0F0dHJzOnUsaXNDbGFzc2lmeUFyZWE6Zj0hMSxpc0Nsb25lOkk9ITB9PW4sbD1JP1MoZSk6ZSxDPVtdO2xldCBpPTA7Zm9yKDtpPGwubGVuZ3RoOyl7bGV0IHQ9bFtpXTtpZihpPT09MCYmdC52YWx1ZT09PXYmJiF0Lmxpc3RJZCYmKCF0LnR5cGV8fHQudHlwZT09PWEuVEVYVCkpe2krKztjb250aW51ZX1pZih0LmFyZWFJZCl7Y29uc3Qgcj10LmFyZWFJZCxkPXQuYXJlYSxjPVtdO2Zvcig7aTxsLmxlbmd0aDspe2NvbnN0IG89bFtpXTtpZihyIT09by5hcmVhSWQpe2ktLTticmVha31kZWxldGUgby5hcmVhLGRlbGV0ZSBvLmFyZWFJZCxjLnB1c2gobyksaSsrfWNvbnN0IHM9VChjLG4pO2lmKGYpe2NvbnN0IG89e3R5cGU6YS5BUkVBLHZhbHVlOiIiLGFyZWFJZDpyLGFyZWE6ZH07by52YWx1ZUxpc3Q9cyx0PW99ZWxzZXtDLnNwbGljZShpLDAsLi4ucyk7Y29udGludWV9fWVsc2UgaWYodC50aXRsZUlkJiZ0LmxldmVsKXtjb25zdCByPXQudGl0bGVJZDtpZihyKXtjb25zdCBkPXQubGV2ZWwsYz17dHlwZTphLlRJVExFLHRpdGxlOnQudGl0bGUsdGl0bGVJZDpyLHZhbHVlOiIiLGxldmVsOmR9LHM9W107Zm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgbz1sW2ldO2lmKHIhPT1vLnRpdGxlSWQpe2ktLTticmVha31kZWxldGUgby5sZXZlbCxkZWxldGUgby50aXRsZSxzLnB1c2gobyksaSsrfWMudmFsdWVMaXN0PVQocyxuKSx0PWN9fWVsc2UgaWYodC5saXN0SWQmJnQubGlzdFR5cGUpe2NvbnN0IHI9dC5saXN0SWQ7aWYocil7Y29uc3QgZD10Lmxpc3RUeXBlLGM9dC5saXN0U3R5bGUscz17dHlwZTphLkxJU1QsdmFsdWU6IiIsbGlzdElkOnIsbGlzdFR5cGU6ZCxsaXN0U3R5bGU6Y30sbz1bXTtmb3IoO2k8bC5sZW5ndGg7KXtjb25zdCBoPWxbaV07aWYociE9PWgubGlzdElkKXtpLS07YnJlYWt9ZGVsZXRlIGgubGlzdFR5cGUsZGVsZXRlIGgubGlzdFN0eWxlLG8ucHVzaChoKSxpKyt9cy52YWx1ZUxpc3Q9VChvLG4pLHQ9c319ZWxzZSBpZih0LnR5cGU9PT1hLlRBQkxFKXtpZih0LnBhZ2luZ0lkKXtsZXQgcj1pKzEsZD0wO2Zvcig7cjxsLmxlbmd0aDspe2NvbnN0IGM9bFtyXTtpZihjLnBhZ2luZ0lkPT09dC5wYWdpbmdJZCl0LmhlaWdodCs9Yy5oZWlnaHQsdC50ckxpc3QucHVzaCguLi5jLnRyTGlzdCkscisrLGQrKztlbHNlIGJyZWFrfWkrPWR9aWYodC50ckxpc3QpZm9yKGxldCByPTA7cjx0LnRyTGlzdC5sZW5ndGg7cisrKXtjb25zdCBkPXQudHJMaXN0W3JdO2RlbGV0ZSBkLmlkO2ZvcihsZXQgYz0wO2M8ZC50ZExpc3QubGVuZ3RoO2MrKyl7Y29uc3Qgcz1kLnRkTGlzdFtjXSxvPXtjb2xzcGFuOnMuY29sc3Bhbixyb3dzcGFuOnMucm93c3Bhbix2YWx1ZTpUKHMudmFsdWUsey4uLm4saXNDbGFzc2lmeUFyZWE6ITF9KX07VS5mb3JFYWNoKGg9Pntjb25zdCBMPXNbaF07TCE9PXZvaWQgMCYmKG9baF09TCl9KSxkLnRkTGlzdFtjXT1vfX19ZWxzZSBpZih0LnR5cGU9PT1hLkhZUEVSTElOSyl7Y29uc3Qgcj10Lmh5cGVybGlua0lkO2lmKHIpe2NvbnN0IGQ9e3R5cGU6YS5IWVBFUkxJTkssdmFsdWU6IiIsdXJsOnQudXJsfSxjPVtdO2Zvcig7aTxsLmxlbmd0aDspe2NvbnN0IHM9bFtpXTtpZihyIT09cy5oeXBlcmxpbmtJZCl7aS0tO2JyZWFrfWRlbGV0ZSBzLnR5cGUsZGVsZXRlIHMudXJsLGMucHVzaChzKSxpKyt9ZC52YWx1ZUxpc3Q9VChjLG4pLHQ9ZH19ZWxzZSBpZih0LnR5cGU9PT1hLkRBVEUpe2NvbnN0IHI9dC5kYXRlSWQ7aWYocil7Y29uc3QgZD17dHlwZTphLkRBVEUsdmFsdWU6IiIsZGF0ZUZvcm1hdDp0LmRhdGVGb3JtYXR9LGM9W107Zm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgcz1sW2ldO2lmKHIhPT1zLmRhdGVJZCl7aS0tO2JyZWFrfWRlbGV0ZSBzLnR5cGUsZGVsZXRlIHMuZGF0ZUZvcm1hdCxjLnB1c2gocyksaSsrfWQudmFsdWVMaXN0PVQoYyxuKSx0PWR9fWVsc2UgaWYodC5jb250cm9sSWQpe2NvbnN0IHI9dC5jb250cm9sSWQ7aWYodC5jb250cm9sQ29tcG9uZW50PT09QS5QUkVGSVgpe2NvbnN0IGQ9W107bGV0IGM9ITEscz1pO2Zvcig7czxsLmxlbmd0aDspe2NvbnN0IG89bFtzXTtpZihyIT09by5jb250cm9sSWQpYnJlYWs7by5jb250cm9sQ29tcG9uZW50PT09QS5WQUxVRSYmKGRlbGV0ZSBvLmNvbnRyb2wsZGVsZXRlIG8uY29udHJvbElkLGQucHVzaChvKSksby5jb250cm9sQ29tcG9uZW50PT09QS5QT1NURklYJiYoYz0hMCkscysrfWlmKGMpe2NvbnN0IG89eSh0LHcpLGg9ey4uLnQuY29udHJvbCwuLi5vfSxMPXsuLi55KHQsXyksdHlwZTphLkNPTlRST0wsdmFsdWU6IiIsY29udHJvbDpoLGNvbnRyb2xJZDpyfTtMLmNvbnRyb2wudmFsdWU9VChkLG4pLHQ9SChMLHtleHRyYVBpY2tBdHRyczp1fSksaSs9cy1pLTF9fWlmKHQuY29udHJvbENvbXBvbmVudCYmKGRlbGV0ZSB0LmNvbnRyb2wsZGVsZXRlIHQuY29udHJvbElkLHQuY29udHJvbENvbXBvbmVudCE9PUEuVkFMVUUmJnQuY29udHJvbENvbXBvbmVudCE9PUEuUFJFX1RFWFQmJnQuY29udHJvbENvbXBvbmVudCE9PUEuUE9TVF9URVhUKSl7aSsrO2NvbnRpbnVlfX1jb25zdCBGPUgodCx7ZXh0cmFQaWNrQXR0cnM6dX0pO2lmKCF0LnR5cGV8fHQudHlwZT09PWEuVEVYVHx8dC50eXBlPT09YS5TVUJTQ1JJUFR8fHQudHlwZT09PWEuU1VQRVJTQ1JJUFQpZm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgcj1sW2krMV07aWYoaSsrLHImJk0oRixIKHIse2V4dHJhUGlja0F0dHJzOnV9KSkpe2NvbnN0IGQ9ci52YWx1ZT09PXY/YApgOnIudmFsdWU7Ri52YWx1ZSs9ZH1lbHNlIGJyZWFrfWVsc2UgaSsrO0MucHVzaChGKX1yZXR1cm4gQ31vbm1lc3NhZ2U9ZT0+e2NvbnN0IG49ZS5kYXRhLHtvcHRpb25zOnUsZGF0YTpmfT1uLHtleHRyYVBpY2tBdHRyczpJPVtdfT11fHx7fSxsPXtoZWFkZXI6VChmLmhlYWRlcix7ZXh0cmFQaWNrQXR0cnM6SSxpc0Nsb25lOiExfSksbWFpbjpUKGYubWFpbix7ZXh0cmFQaWNrQXR0cnM6SSxpc0NsYXNzaWZ5QXJlYTohMCxpc0Nsb25lOiExfSksZm9vdGVyOlQoZi5mb290ZXIse2V4dHJhUGlja0F0dHJzOkksaXNDbG9uZTohMX0pfTtwb3N0TWVzc2FnZShsKX19KSgpOwo=",ai=typeof window!="undefined"&&window.Blob&&new Blob([atob(li)],{type:"text/javascript;charset=utf-8"});function nr(){const s=ai&&(window.URL||window.webkitURL).createObjectURL(ai);try{return s?new Worker(s,{}):new Worker("data:application/javascript;base64,"+li,{type:"module"})}finally{s&&(window.URL||window.webkitURL).revokeObjectURL(s)}}class ir{constructor(t){this.draw=t,this.wordCountWorker=new qs,this.catalogWorker=new tr,this.groupWorker=new er,this.valueWorker=new nr}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=i=>{t(i.data)},this.wordCountWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(n)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=r=>{t(r.data)},this.catalogWorker.onerror=r=>{e(r)};const n=this.draw.getOriginalMainElementList(),i=this.draw.getPosition().getOriginalMainPositionList();this.catalogWorker.postMessage({elementList:n,positionList:i})})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=i=>{t(i.data)},this.groupWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(n)})}getValue(t){return new Promise((e,n)=>{this.valueWorker.onmessage=i=>{e({version:Qe,data:i.data,options:_(this.draw.getOptions())})},this.valueWorker.onerror=i=>{n(i)},this.valueWorker.postMessage({data:this.draw.getOriginValue(t),options:t})})}}var bl="";class cn{constructor(t){this.options=t,this.mask=null,this.container=null,this.inputList=[],this._render()}_render(){var M;const{title:t,data:e,onClose:n,onCancel:i,onConfirm:r}=this.options,o=document.createElement("div");o.classList.add("dialog-mask"),o.setAttribute(Kt,c.EditorComponent.COMPONENT),document.body.append(o);const l=document.createElement("div");l.classList.add("dialog-container"),l.setAttribute(Kt,c.EditorComponent.COMPONENT);const a=document.createElement("div");a.classList.add("dialog"),l.append(a);const R=document.createElement("div");R.classList.add("dialog-title");const d=document.createElement("span");d.append(document.createTextNode(t));const u=document.createElement("i");u.onclick=()=>{n&&n(),this._dispose()},R.append(d),R.append(u),a.append(R);const h=document.createElement("div");h.classList.add("dialog-option");for(let P=0;P<e.length;P++){const O=e[P],X=document.createElement("div");if(X.classList.add("dialog-option__item"),O.label){const f=document.createElement("span");f.append(document.createTextNode(O.label)),X.append(f),O.required&&f.classList.add("dialog-option__item--require")}let I;if(O.type==="select")I=document.createElement("select"),(M=O.options)==null||M.forEach(f=>{const S=document.createElement("option");S.value=f.value,S.label=f.label,I.append(S)});else if(O.type==="textarea")I=document.createElement("textarea");else if(O.type==="color"){I=document.createElement("input"),I.type="text",I.onclick=function(){f.click()};const f=document.querySelector("#color");f.oninput=function(){I.value=f.value}}else I=document.createElement("input"),I.type=O.type;O.width&&(I.style.width=`${O.width}px`),O.height&&(I.style.height=`${O.height}px`),I.name=O.name,I.value=O.value||"",I instanceof HTMLSelectElement||(I.placeholder=O.placeholder||""),X.append(I),h.append(X),this.inputList.push(I)}a.append(h);const g=document.createElement("div");g.classList.add("dialog-menu");const L=document.createElement("button");L.classList.add("dialog-menu__cancel"),L.append(document.createTextNode("\u53D6\u6D88")),L.type="button",L.onclick=()=>{i&&i(),this._dispose()},g.append(L);const T=document.createElement("button");T.append(document.createTextNode("\u786E\u5B9A")),T.type="submit",T.onclick=()=>{if(r){const P=this.inputList.map(O=>({name:O.name,value:O.value}));r(P)}this._dispose()},g.append(T),a.append(g),document.body.append(l),this.container=l,this.mask=o}_dispose(){var t,e;(t=this.mask)==null||t.remove(),(e=this.container)==null||e.remove()}}function dn(s){const t={width:400,height:200,fontFamily:"Simsun",fontSize:20,color:"#ffffff",bold:!1,italic:!1,borderWidth:1,textBgColor:"#000000",borderColor:"#000000",text:"",...s};console.log("config",t);const e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height);let i="";t.bold&&(i+="bold "),t.italic&&(i+="italic ");let r=t.fontSize,o,l;do{const g=`${i}${r}px ${t.fontFamily}`;n.font=g;const L=n.measureText(t.text);if(o=L.width,l=L.actualBoundingBoxAscent+L.actualBoundingBoxDescent,(o>t.width||l>t.height)&&r>1)r--;else break}while(!0);const a=`${i}${r}px ${t.fontFamily}`;n.font=a;const R=n.measureText(t.text);o=R.width,l=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent;const d=(t.width-o)/2-4,u=(t.height-l)/2-4;n.fillStyle=t.textBgColor,n.fillRect(d,u,o+8,l+8),n.fillStyle=t.color,n.textAlign="center",n.textBaseline="middle",n.fillText(t.text,e.width/2,e.height/2);const h=t.borderWidth;return n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(h,h,t.width-h*2,t.height-h*2),e.toDataURL("image/png")}function hn(s){const t={checked:!1,width:100,height:40,label:"",fontSize:14,fontFamily:"SimSun",color:"#000000",borderColor:"#000000",checkColor:"#5175f4",boxSize:20,gap:8,borderWidth:1,...s},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=t.height/2,r=t.gap+t.borderWidth,o=i-t.boxSize/2;if(n.strokeStyle=t.borderColor,n.lineWidth=1.5,n.strokeRect(r,o,t.boxSize,t.boxSize),t.checked){n.fillStyle=t.checkColor,n.fillRect(r+2,o+2,t.boxSize-4,t.boxSize-4),n.beginPath(),n.strokeStyle="#ffffff",n.lineWidth=2,n.lineCap="round",n.lineJoin="round";const l=r+5,a=o+t.boxSize/2+2,R=r+t.boxSize/2-1,d=o+t.boxSize-6,u=r+t.boxSize-4,h=o+6;n.moveTo(l,a),n.lineTo(R,d),n.lineTo(u,h),n.stroke()}if(t.label){n.font=`${t.fontSize}px ${t.fontFamily}`,n.fillStyle=t.color,n.textAlign="left",n.textBaseline="middle";const l=r+t.boxSize+t.gap;n.fillText(t.label,l,i)}return e.toDataURL("image/png")}function un(s){const t={checked:!1,width:100,height:40,label:"",fontSize:14,fontFamily:"SimSun",color:"#000000",borderColor:"#000000",checkColor:"#5175f4",boxSize:20,gap:8,borderWidth:1,...s},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=t.height/2,r=t.gap+t.borderWidth,o=i-t.boxSize/2,l=r+t.boxSize/2,a=o+t.boxSize/2;if(n.strokeStyle=t.borderColor,n.lineWidth=1.5,n.beginPath(),n.arc(l,a,t.boxSize/2,0,Math.PI*2),n.stroke(),t.checked&&(n.fillStyle=t.checkColor,n.beginPath(),n.arc(l,a,t.boxSize/4,0,Math.PI*2),n.fill()),t.label){n.font=`${t.fontSize}px ${t.fontFamily}`,n.fillStyle=t.color,n.textAlign="left",n.textBaseline="middle";const R=r+t.boxSize+t.gap;n.fillText(t.label,R,i)}return e.toDataURL("image/png")}function Ri(s,t){var e,n,i,r,o,l,a,R,d,u,h,g,L,T,M;console.log("el",s),new cn({title:"\u8868\u5355\u590D\u9009\u6846",data:[{type:"select",label:"\u8868\u5355 Key",name:"key",required:!0,value:(n=(e=s==null?void 0:s.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355 Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=s==null?void 0:s.formInput)==null?void 0:i.width)!=null?r:"120"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(o=s==null?void 0:s.formInput)==null?void 0:o.height)!=null?l:"40"},{type:"select",label:"\u9ED8\u8BA4\u9009\u4E2D",name:"checked",required:!0,value:(a=s==null?void 0:s.formInput)!=null&&a.checked?"true":"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"text",label:"\u6807\u7B7E\u6587\u5B57",name:"label",required:!0,value:(d=(R=s==null?void 0:s.formInput)==null?void 0:R.label)!=null?d:"",placeholder:"\u8BF7\u8F93\u5165\u6807\u7B7E\u6587\u5B57"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(h=(u=s==null?void 0:s.formInput)==null?void 0:u.fontSize)!=null?h:"14"},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(L=(g=s==null?void 0:s.formInput)==null?void 0:g.color)!=null?L:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(M=(T=s==null?void 0:s.formInput)==null?void 0:T.fontFamily)!=null?M:"SimSun",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("formInputKeys")}],onConfirm:P=>{var E,V,Y,K,b,p,H,w;console.log("payload: ",P);const O=(E=P.find(D=>D.name==="key"))==null?void 0:E.value;if(!O)return;const X=(V=P.find(D=>D.name==="width"))==null?void 0:V.value;if(!X)return;const I=(Y=P.find(D=>D.name==="height"))==null?void 0:Y.value;if(!I)return;const f=((K=P.find(D=>D.name==="checked"))==null?void 0:K.value)==="true",S=((b=P.find(D=>D.name==="label"))==null?void 0:b.value)||"",N=(p=P.find(D=>D.name==="fontSize"))==null?void 0:p.value,m=(H=P.find(D=>D.name==="color"))==null?void 0:H.value,W=(w=P.find(D=>D.name==="fontFamily"))==null?void 0:w.value,U={key:O,width:X,height:I,checked:f,label:S,fontSize:N,fontFamily:W,color:m,type:"checkbox"},F={value:hn({checked:f,label:S,width:Number(X),height:Number(I),fontSize:Number(N),fontFamily:W,color:m}),type:c.ElementType.IMAGE,formInput:U,width:Number(X),height:Number(I)};if(s!=null&&s.id){const D={id:s.id,properties:F};console.log("deleteOpt12",D),t.command.executeUpdateElementById(D);return}t.command.executeInsertElementList([F])}})}function ci(s,t){var e,n,i,r,o,l,a,R,d,u,h,g,L,T,M;console.log("el",s),new cn({title:"\u8868\u5355\u5355\u9009\u6846",data:[{type:"text",label:"\u8868\u5355 Key",name:"key",required:!0,value:(n=(e=s==null?void 0:s.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355 Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=s==null?void 0:s.formInput)==null?void 0:i.width)!=null?r:"120"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(o=s==null?void 0:s.formInput)==null?void 0:o.height)!=null?l:"40"},{type:"select",label:"\u9ED8\u8BA4\u9009\u4E2D",name:"checked",required:!0,value:(a=s==null?void 0:s.formInput)!=null&&a.checked?"true":"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"text",label:"\u6807\u7B7E\u6587\u5B57",name:"label",required:!0,value:(d=(R=s==null?void 0:s.formInput)==null?void 0:R.label)!=null?d:"",placeholder:"\u8BF7\u8F93\u5165\u6807\u7B7E\u6587\u5B57"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(h=(u=s==null?void 0:s.formInput)==null?void 0:u.fontSize)!=null?h:"14"},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(L=(g=s==null?void 0:s.formInput)==null?void 0:g.color)!=null?L:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(M=(T=s==null?void 0:s.formInput)==null?void 0:T.fontFamily)!=null?M:"SimSun",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("formInputKeys")}],onConfirm:P=>{var E,V,Y,K,b,p,H,w;console.log("payload: ",P);const O=(E=P.find(D=>D.name==="key"))==null?void 0:E.value;if(!O)return;const X=(V=P.find(D=>D.name==="width"))==null?void 0:V.value;if(!X)return;const I=(Y=P.find(D=>D.name==="height"))==null?void 0:Y.value;if(!I)return;const f=((K=P.find(D=>D.name==="checked"))==null?void 0:K.value)==="true",S=((b=P.find(D=>D.name==="label"))==null?void 0:b.value)||"",N=(p=P.find(D=>D.name==="fontSize"))==null?void 0:p.value,m=(H=P.find(D=>D.name==="color"))==null?void 0:H.value,W=(w=P.find(D=>D.name==="fontFamily"))==null?void 0:w.value,U={key:O,width:X,height:I,checked:f,label:S,fontSize:N,fontFamily:W,color:m,type:"radio"},F={value:un({checked:f,label:S,width:Number(X),height:Number(I),fontSize:Number(N),fontFamily:W,color:m}),type:c.ElementType.IMAGE,formInput:U,width:Number(X),height:Number(I)};if(s!=null&&s.id){const D={id:s.id,properties:F};console.log("deleteOpt12",D),t.command.executeUpdateElementById(D);return}t.command.executeInsertElementList([F])}})}function di(s,t){var e,n,i,r,o,l,a,R,d,u,h,g,L,T,M,P;console.log("el",s),new cn({title:"\u8868\u5355\u6587\u672C\u6846",data:[{type:"select",label:"\u8868\u5355Key",name:"key",required:!0,value:(n=(e=s==null?void 0:s.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6(px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=s==null?void 0:s.formInput)==null?void 0:i.width)!=null?r:"100"},{type:"number",label:"\u9AD8\u5EA6(px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(o=s==null?void 0:s.formInput)==null?void 0:o.height)!=null?l:"50"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(R=(a=s==null?void 0:s.formInput)==null?void 0:a.fontSize)!=null?R:"10"},{type:"select",label:"\u662F\u5426\u52A0\u7C97",name:"bold",required:!0,value:(d=s==null?void 0:s.formInput)!=null&&d.bold?String((u=s==null?void 0:s.formInput)==null?void 0:u.bold):"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"select",label:"\u662F\u5426\u659C\u4F53",name:"italic",required:!0,value:(h=s==null?void 0:s.formInput)!=null&&h.italic?String((g=s==null?void 0:s.formInput)==null?void 0:g.italic):"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(T=(L=s==null?void 0:s.formInput)==null?void 0:L.color)!=null?T:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(P=(M=s==null?void 0:s.formInput)==null?void 0:M.fontFamily)!=null?P:"SimSun",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("formInputKeys")}],onConfirm:O=>{var V,Y,K,b,p,H,w,D;console.log("payload: ",O);const X=(V=O.find(J=>J.name==="key"))==null?void 0:V.value;if(!X)return;const I=(Y=O.find(J=>J.name==="width"))==null?void 0:Y.value;if(!I)return;const f=(K=O.find(J=>J.name==="height"))==null?void 0:K.value;if(!f)return;const S=(b=O.find(J=>J.name==="fontSize"))==null?void 0:b.value,N=((p=O.find(J=>J.name==="bold"))==null?void 0:p.value)==="true",m=((H=O.find(J=>J.name==="italic"))==null?void 0:H.value)==="true",W=(w=O.find(J=>J.name==="color"))==null?void 0:w.value,Z=(D=O.find(J=>J.name==="fontFamily"))==null?void 0:D.value,Q={key:X,width:I,height:f,fontSize:S,bold:N,italic:m,color:W,fontFamily:Z,type:"input"},E={value:dn({text:X,width:I,height:f}),type:c.ElementType.IMAGE,formInput:Q,width:Number(I),height:Number(f)};if(s!=null&&s.id){const J={id:s.id,properties:E};console.log("deleteOpt12",J),t.command.executeUpdateElementById(J);return}t.command.executeInsertElementList([E])}})}class or{constructor(t){this._keydown=()=>{this.resizerSelection.style.display==="block"&&(this.clearResizer(),document.removeEventListener("keydown",this._keydown))},this.container=t.getContainer(),this.canvas=t.getPage(),this.draw=t,this.options=t.getOptions(),this.curElement=null,this.curElementSrc="",this.previewerDrawOption={},this.curPosition=null,this.eventBus=t.getEventBus(),this.imageList=[],this.curShowElement=null,this.imageCount=null,this.imagePre=null,this.imageNext=null;const{resizerSelection:e,resizerHandleList:n,resizerImageContainer:i,resizerImage:r,resizerSize:o}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=n,this.resizerImageContainer=i,this.resizerImage=r,this.resizerSize=o,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.previewerContainer=null,this.previewerImage=null}_getElementPosition(t,e=null){var d;const{scale:n}=this.options;let i=0,r=0;const o=this.draw.getHeight(),l=this.draw.getPageGap(),R=((d=e==null?void 0:e.pageNo)!=null?d:this.draw.getPageNo())*(o+l);if(t.imgFloatPosition)i=t.imgFloatPosition.x*n,r=t.imgFloatPosition.y*n+R;else if(e){const{coordinate:{leftTop:[u,h]},ascent:g}=e;i=u,r=h+R+g}return{x:i,y:r}}_createResizerDom(){const{scale:t}=this.options,e=document.createElement("div");e.classList.add(`${x}-resizer-selection`),e.style.display="none",e.style.borderColor=this.options.resizerColor,e.style.borderWidth=`${t}px`;const n=[];for(let a=0;a<8;a++){const R=document.createElement("div");R.style.background=this.options.resizerColor,R.classList.add("resizer-handle"),R.classList.add(`handle-${a}`),R.setAttribute("data-index",String(a)),R.onmousedown=this._mousedown.bind(this),e.append(R),n.push(R)}this.container.append(e);const i=document.createElement("div");i.classList.add(`${x}-resizer-size-view`);const r=document.createElement("span");i.append(r),e.append(i);const o=document.createElement("div");o.classList.add(`${x}-resizer-image`),o.style.display="none";const l=document.createElement("img");return o.append(l),this.container.append(o),{resizerSelection:e,resizerHandleList:n,resizerImageContainer:o,resizerImage:l,resizerSize:r}}_mousedown(t){if(this.canvas=this.draw.getPage(),!this.curElement)return;const{scale:e}=this.options;this.mousedownX=t.x,this.mousedownY=t.y;const n=t.target;this.curHandleIndex=Number(n.dataset.index);const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,this.canvas.style.cursor=i,this.curElement.formInput&&(console.log("this.curElement.formInput",this.curElement.formInput),console.log("this.curElement.formInput.type",this.curElement.formInput.type),this.curElement.formInput.width=`${this.curElement.width*e}`,this.curElement.formInput.height=`${this.curElement.height*e}`,this.curElement.formInput.type=="checkbox"?this.curElementSrc=hn(this.curElement.formInput):this.curElement.formInput.type=="radio"?this.curElementSrc=un(this.curElement.formInput):this.curElementSrc=dn({text:this.curElement.formInput.key,width:this.curElement.formInput.width,height:this.curElement.formInput.height})),console.log(this.curElement),this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{x:r,y:o}=this._getElementPosition(this.curElement,this.curPosition);this.resizerImageContainer.style.left=`${r}px`,this.resizerImageContainer.style.top=`${o}px`,this.resizerImage.style.width=`${this.curElement.width*e}px`,this.resizerImage.style.height=`${this.curElement.height*e}px`;const l=this._mousemove.bind(this);document.addEventListener("mousemove",l),document.addEventListener("mouseup",()=>{var a;this.curElement&&!this.previewerDrawOption.dragDisable&&(this.curElement.width=this.width,this.curElement.height=this.height,this.curElement.formInput&&(this.curElement.formInput.width=`${this.width}`,this.curElement.formInput.height=`${this.height}`,this.curElement.formInput.type=="checkbox"?this.curElementSrc=hn(this.curElement.formInput):this.curElement.formInput.type=="radio"?this.curElementSrc=un(this.curElement.formInput):this.curElementSrc=dn({text:this.curElement.formInput.key,width:this.curElement.formInput.width,height:this.curElement.formInput.height}),this.curElement.value=this.curElementSrc),console.log("this.draw.render"),this.draw.render({isSetCursor:!0,curIndex:(a=this.curPosition)==null?void 0:a.index})),this.resizerImageContainer.style.display="none",document.removeEventListener("mousemove",l),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.curElement||this.previewerDrawOption.dragDisable)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const R=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 1:i=this.mousedownY-t.y;break;case 2:{const R=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 4:{const R=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const R=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 7:n=this.mousedownX-t.x;break}const r=this.curElement.width+n/e,o=this.curElement.height+i/e;if(r<=0||o<=0)return;this.width=r,this.height=o;const l=r*e,a=o*e;this.resizerImage.style.width=`${l}px`,this.resizerImage.style.height=`${a}px`,this._updateResizerRect(l,a),this._updateResizerSizeView(l,a),t.preventDefault(),this.eventBus.isSubscribe("imageSizeChange")&&this.eventBus.emit("imageSizeChange",{element:this.curElement})}_drawPreviewer(){const t=document.createElement("div");t.classList.add(`${x}-image-previewer`);const e=document.createElement("i");e.classList.add("image-close"),e.onclick=()=>{this._clearPreviewer()},t.append(e);const n=document.createElement("div");n.classList.add(`${x}-image-container`);const i=document.createElement("img");i.src=this.curElementSrc,i.draggable=!1,n.append(i),this.previewerImage=i,t.append(n);let r=0,o=0,l=1,a=0;const R=document.createElement("div");R.classList.add(`${x}-image-menu`);const d=document.createElement("div");d.classList.add("image-navigate");const u=document.createElement("i");u.classList.add("image-pre"),u.onclick=()=>{const S=this.imageList.findIndex(N=>{var m;return N.id===((m=this.curShowElement)==null?void 0:m.id)});S<=0||(this.curShowElement=this.imageList[S-1],i.src=this.curShowElement.value,this._updateImageNavigate())},d.append(u),this.imagePre=u;const h=document.createElement("span");h.classList.add("image-count"),this.imageCount=h,d.append(h);const g=document.createElement("i");g.classList.add("image-next"),g.onclick=()=>{const S=this.imageList.findIndex(N=>{var m;return N.id===((m=this.curShowElement)==null?void 0:m.id)});S>=this.imageList.length-1||(this.curShowElement=this.imageList[S+1],i.src=this.curShowElement.value,this._updateImageNavigate())},this.imageNext=g,d.append(g),R.append(d);const L=document.createElement("i");L.classList.add("zoom-in"),L.onclick=()=>{l+=.1,this._setPreviewerTransform(l,a,r,o)},R.append(L);const T=document.createElement("i");T.onclick=()=>{l-.1<=.1||(l-=.1,this._setPreviewerTransform(l,a,r,o))},T.classList.add("zoom-out"),R.append(T);const M=document.createElement("i");M.classList.add("rotate"),M.onclick=()=>{a+=1,this._setPreviewerTransform(l,a,r,o)},R.append(M);const P=document.createElement("i");P.classList.add("original-size"),P.onclick=()=>{r=0,o=0,l=1,a=0,this._setPreviewerTransform(l,a,r,o)},R.append(P);const O=document.createElement("i");O.classList.add("image-download"),O.onclick=()=>{var N;const{mime:S}=this.previewerDrawOption;In(i.src,`${(N=this.curElement)==null?void 0:N.id}.${S||"png"}`)},R.append(O),t.append(R),this.previewerContainer=t,document.body.append(t);let X=0,I=0,f=!1;i.onmousedown=S=>{f=!0,X=S.x,I=S.y,t.style.cursor="move"},t.onmousemove=S=>{!f||(r+=S.x-X,o+=S.y-I,X=S.x,I=S.y,this._setPreviewerTransform(l,a,r,o))},t.onmouseup=()=>{f=!1,t.style.cursor="auto"},t.onwheel=S=>{if(S.preventDefault(),S.stopPropagation(),S.deltaY<0)l+=.1;else{if(l-.1<=.1)return;l-=.1}this._setPreviewerTransform(l,a,r,o)},this._updateImageNavigate()}_updateImageNavigate(){const t=this.imageList.findIndex(e=>{var n;return e.id===((n=this.curShowElement)==null?void 0:n.id)});this.imageCount.innerText=`${t+1} / ${this.imageList.length}`,t<=0?this.imagePre.classList.add("disabled"):this.imagePre.classList.remove("disabled"),t>=this.imageList.length-1?this.imageNext.classList.add("disabled"):this.imageNext.classList.remove("disabled")}_setPreviewerTransform(t,e,n,i){!this.previewerImage||(this.previewerImage.style.left=`${n}px`,this.previewerImage.style.top=`${i}px`,this.previewerImage.style.transform=`scale(${t}) rotate(${e*90}deg)`)}_clearPreviewer(){var t;(t=this.previewerContainer)==null||t.remove(),this.previewerContainer=null,document.body.style.overflow="auto"}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options,r=this.draw.isReadonly();this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let o=0;o<8;o++){const l=o===0||o===6||o===7?-n:o===1||o===5?t/2:t-n,a=o===0||o===1||o===2?-n:o===3||o===7?e/2-n:e-n;this.resizerHandleList[o].style.transform=`scale(${i})`,this.resizerHandleList[o].style.left=`${l}px`,this.resizerHandleList[o].style.top=`${a}px`,this.resizerHandleList[o].style.display=r?"none":"block"}}_updateResizerSizeView(t,e){this.resizerSize.innerText=`${Math.round(t)} \xD7 ${Math.round(e)}`}render(){var e,n;const t=this.draw.getMode();!this.curElement||this.curElement.imgToolDisabled&&!this.draw.isDesignMode()||t===c.EditorMode.PRINT&&((e=this.options.modeRule[c.EditorMode.PRINT])==null?void 0:e.imagePreviewerDisabled)||t===c.EditorMode.READONLY&&((n=this.options.modeRule[c.EditorMode.READONLY])==null?void 0:n.imagePreviewerDisabled)||(this.imageList=this.draw.getImageParticle().getOriginalMainImageList(),this.curShowElement=this.curElement,this._drawPreviewer(),document.body.style.overflow="hidden")}drawResizer(t,e=null,n={}){var r,o;const i=this.draw.getMode();t.imgToolDisabled&&!this.draw.isDesignMode()||i===c.EditorMode.PRINT&&((r=this.options.modeRule[c.EditorMode.PRINT])==null?void 0:r.imagePreviewerDisabled)||i===c.EditorMode.READONLY&&((o=this.options.modeRule[c.EditorMode.READONLY])==null?void 0:o.imagePreviewerDisabled)||(this.previewerDrawOption=n,this.curElementSrc=t[n.srcKey||"value"]||"",this.updateResizer(t,e),document.addEventListener("keydown",this._keydown))}updateResizer(t,e=null){console.log(t);const{scale:n}=this.options,i=t.width*n,r=t.height*n;this._updateResizerSizeView(i,r);const{x:o,y:l}=this._getElementPosition(t,e);this.resizerSelection.style.left=`${o}px`,this.resizerSelection.style.top=`${l}px`,this.resizerSelection.style.borderWidth=`${n}px`,this._updateResizerRect(i,r),this.resizerSelection.style.display="block",this.curElement=t,this.curPosition=e,this.width=i,this.height=r}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}class sr{constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.datePicker=new ti(t,{onSubmit:this._setValue.bind(this)})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[n,i]=e,r=this.draw.getElementList(),o=r[n+1];this.draw.spliceElementList(r,n+1,i-n),this.range.setRange(n,n);const l={type:c.ElementType.DATE,value:"",dateFormat:o.dateFormat,valueList:[{value:t}]};Ot(r,[l],n,{editorOptions:this.options}),this.draw.insertElementList([l])}getDateElementRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=this.draw.getElementList(),o=r[n];if(o.type!==c.ElementType.DATE)return null;let l=n;for(;l>=0;){if(r[l].dateId!==o.dateId){t=l;break}l--}let a=n+1;for(;a<r.length;){if(r[a].dateId!==o.dateId){e=a-1;break}a++}return a===r.length&&(e=a-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const n=this.draw.getElementList(),i=this.getDateElementRange(),r=i?n.slice(i[0]+1,i[1]+1).map(o=>o.value).join(""):"";this.datePicker.render({value:r,position:e,dateFormat:t.dateFormat})}}class hi{constructor(t){this.element=t,this.videoCache=new Map}snapshot(t,e,n){return new Promise((i,r)=>{var l,a;const o=((a=(l=this.element.block)==null?void 0:l.videoBlock)==null?void 0:a.src)||"";if(this.videoCache.has(o)){const R=this.videoCache.get(o);t.drawImage(R,e,n,this.element.metrics.width,this.element.metrics.height),i(this.element)}else{const R=document.createElement("video");R.src=o,R.muted=!0,R.crossOrigin="anonymous",R.onloadeddata=()=>{t.drawImage(R,e,n,this.element.metrics.width,this.element.metrics.height),this.videoCache.set(o,R),i(this.element)},R.onerror=d=>{r(d)},R.play().then(()=>{R.pause()})}})}render(t){var i;const e=this.element.block,n=document.createElement("video");n.style.width="100%",n.style.height="100%",n.style.objectFit="contain",n.src=((i=e.videoBlock)==null?void 0:i.src)||"",n.controls=!0,t.append(n)}}class rr{constructor(t,e){this.draw=t.getDraw(),this.options=this.draw.getOptions(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null;const{blockItem:n,resizerMask:i,resizerSelection:r,resizerHandleList:o}=this._createBlockItem();this.blockItem=n,this.blockContainer.append(this.blockItem),this.blockCache=new Map,this.resizerMask=i,this.resizerSelection=r,this.resizerHandleList=o,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.isAllowResize=!1}getBlockElement(){return this.element}getBlockWidth(){return this.element.width||this.element.metrics.width}_createBlockItem(){const{scale:t,resizerColor:e}=this.options,n=document.createElement("div");n.classList.add(`${x}-block-item`);const i=document.createElement("div");i.style.display="none",i.classList.add(`${x}-resizer-selection`),i.style.borderColor=e,i.style.borderWidth=`${t}px`;const r=[];for(let l=0;l<8;l++){const a=document.createElement("div");a.style.background=e,a.classList.add("resizer-handle"),a.classList.add(`handle-${l}`),a.setAttribute("data-index",String(l)),a.onmousedown=this._mousedown.bind(this),i.append(a),r.push(a)}const o=document.createElement("div");return o.classList.add(`${x}-resizer-mask`),o.style.display="none",n.append(o),n.onmouseenter=()=>{if(this.draw.isReadonly())return;const{width:a,height:R}=this.element.metrics;this._updateResizerRect(a,R),i.style.display="block"},n.onmouseleave=()=>{this.isAllowResize||(i.style.display="none")},n.append(i),{blockItem:n,resizerMask:o,resizerSelection:i,resizerHandleList:r}}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options;this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let r=0;r<8;r++){const o=r===0||r===6||r===7?-n:r===1||r===5?t/2:t-n,l=r===0||r===1||r===2?-n:r===3||r===7?e/2-n:e-n;this.resizerHandleList[r].style.transform=`scale(${i})`,this.resizerHandleList[r].style.left=`${o}px`,this.resizerHandleList[r].style.top=`${l}px`}}_mousedown(t){const e=this.draw.getPage();this.mousedownX=t.x,this.mousedownY=t.y,this.isAllowResize=!0;const n=t.target;this.curHandleIndex=Number(n.dataset.index),this.resizerMask.style.display="block";const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,e.style.cursor=i;const r=this._mousemove.bind(this);document.addEventListener("mousemove",r),document.addEventListener("mouseup",()=>{this.element.width=Math.min(this.width,this.draw.getInnerWidth()),this.element.height=this.height,this.isAllowResize=!1,this.resizerSelection.style.display="none",this.resizerMask.style.display="none",document.removeEventListener("mousemove",r),document.body.style.cursor="",e.style.cursor="text",this.draw.render()},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.isAllowResize)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const R=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 1:i=this.mousedownY-t.y;break;case 2:{const R=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 4:{const R=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const R=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 7:n=this.mousedownX-t.x;break}const r=this.getBlockWidth()+n/e,o=this.element.height+i/e;if(r<=0||o<=0)return;this.width=r,this.height=o;const l=r*e,a=o*e;this._updateResizerRect(l,a),this.blockItem.style.width=`${l}px`,this.blockItem.style.height=`${a}px`,t.preventDefault()}snapshot(t,e,n){if(this.element.block.type===c.BlockType.VIDEO)if(this.blockItem.style.display="none",this.blockCache.has(this.element.id))this.blockCache.get(this.element.id).snapshot(t,e,n);else{this.block=new hi(this.element);const r=this.block.snapshot(t,e,n);this.draw.getImageObserver().add(r),this.blockCache.set(this.element.id,this.block)}}render(){const t=this.element.block;t.type===c.BlockType.IFRAME?(this.block=new he(this.element),this.block.render(this.blockItem)):t.type===c.BlockType.VIDEO&&(this.block=new hi(this.element),this.block.render(this.blockItem))}setClientRects(t,e,n){const i=this.draw.getHeight(),r=this.draw.getPageGap(),o=t*(i+r),{metrics:l}=this.element;this.blockItem.style.display="block",this.blockItem.style.width=`${l.width}px`,this.blockItem.style.height=`${l.height}px`,this.blockItem.style.left=`${e}px`,this.blockItem.style.top=`${o+n}px`}remove(){this.blockItem.remove()}}class lr{constructor(t){this.draw=t,this.container=t.getContainer(),this.blockMap=new Map,this.blockContainer=this._createBlockContainer(),this.container.append(this.blockContainer)}_createBlockContainer(){const t=document.createElement("div");return t.classList.add(`${x}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,n,i,r){const o=n.id;let l=this.blockMap.get(o);l||(l=new rr(this,n),l.render(),this.blockMap.set(o,l)),this.draw.isPrintMode()?l.snapshot(t,i,r):l.setClientRects(e,i,r)}clear(){if(!this.blockMap.size)return;const t=this.draw.getOriginalMainElementList(),e=[];for(let n=0;n<t.length;n++){const i=t[n];i.type===c.ElementType.BLOCK&&e.push(i.id)}this.blockMap.forEach(n=>{const i=n.getBlockElement().id;e.includes(i)||(n.remove(),this.blockMap.delete(i))})}}var gn={contextmenu:{global:{cut:"\u526A\u5207",copy:"\u590D\u5236",paste:"\u7C98\u8D34",selectAll:"\u5168\u9009",print:"\u6253\u5370"},control:{delete:"\u5220\u9664\u63A7\u4EF6"},hyperlink:{delete:"\u5220\u9664\u94FE\u63A5",cancel:"\u53D6\u6D88\u94FE\u63A5",edit:"\u7F16\u8F91\u94FE\u63A5"},image:{change:"\u66F4\u6539\u56FE\u7247",saveAs:"\u53E6\u5B58\u4E3A\u56FE\u7247",textWrap:"\u6587\u5B57\u73AF\u7ED5",textWrapType:{embed:"\u5D4C\u5165\u578B",upDown:"\u4E0A\u4E0B\u578B\u73AF\u7ED5",surround:"\u56DB\u5468\u578B\u73AF\u7ED5",floatTop:"\u6D6E\u4E8E\u6587\u5B57\u4E0A\u65B9",floatBottom:"\u886C\u4E8E\u6587\u5B57\u4E0B\u65B9"}},table:{insertRowCol:"\u63D2\u5165\u884C\u5217",insertTopRow:"\u4E0A\u65B9\u63D2\u51651\u884C",insertBottomRow:"\u4E0B\u65B9\u63D2\u51651\u884C",insertLeftCol:"\u5DE6\u4FA7\u63D2\u51651\u5217",insertRightCol:"\u53F3\u4FA7\u63D2\u51651\u5217",deleteRowCol:"\u5220\u9664\u884C\u5217",deleteRow:"\u5220\u96641\u884C",deleteCol:"\u5220\u96641\u5217",deleteTable:"\u5220\u9664\u6574\u4E2A\u8868\u683C",mergeCell:"\u5408\u5E76\u5355\u5143\u683C",mergeCancelCell:"\u53D6\u6D88\u5408\u5E76",verticalAlign:"\u5782\u76F4\u5BF9\u9F50",verticalAlignTop:"\u9876\u7AEF\u5BF9\u9F50",verticalAlignMiddle:"\u5782\u76F4\u5C45\u4E2D",verticalAlignBottom:"\u5E95\u7AEF\u5BF9\u9F50",border:"\u8868\u683C\u8FB9\u6846",borderAll:"\u6240\u6709\u6846\u7EBF",borderEmpty:"\u65E0\u6846\u7EBF",borderDash:"\u865A\u6846\u7EBF",borderExternal:"\u5916\u4FA7\u6846\u7EBF",borderInternal:"\u5185\u4FA7\u6846\u7EBF",borderTd:"\u5355\u5143\u683C\u8FB9\u6846",borderTdTop:"\u4E0A\u8FB9\u6846",borderTdRight:"\u53F3\u8FB9\u6846",borderTdBottom:"\u4E0B\u8FB9\u6846",borderTdLeft:"\u5DE6\u8FB9\u6846",borderTdForward:"\u6B63\u659C\u7EBF",borderTdBack:"\u53CD\u659C\u7EBF"}},datePicker:{now:"\u6B64\u523B",confirm:"\u786E\u5B9A",return:"\u8FD4\u56DE\u65E5\u671F",timeSelect:"\u65F6\u95F4\u9009\u62E9",weeks:{sun:"\u65E5",mon:"\u4E00",tue:"\u4E8C",wed:"\u4E09",thu:"\u56DB",fri:"\u4E94",sat:"\u516D"},year:"\u5E74",month:"\u6708",hour:"\u65F6",minute:"\u5206",second:"\u79D2"},frame:{header:"\u9875\u7709",footer:"\u9875\u811A"},pageBreak:{displayName:"\u5206\u9875\u7B26"},zone:{headerTip:"\u53CC\u51FB\u7F16\u8F91\u9875\u7709",footerTip:"\u53CC\u51FB\u7F16\u8F91\u9875\u811A"}},ar={contextmenu:{global:{cut:"Cut",copy:"Copy",paste:"Paste",selectAll:"Select all",print:"Print"},control:{delete:"Delete control"},hyperlink:{delete:"Delete hyperlink",cancel:"Cancel hyperlink",edit:"Edit hyperlink"},image:{change:"Change image",saveAs:"Save as image",textWrap:"Text wrap",textWrapType:{embed:"Embed",upDown:"Up down",surround:"Surround",floatTop:"Float above text",floatBottom:"Float below text"}},table:{insertRowCol:"Insert row col",insertTopRow:"Insert top 1 row",insertBottomRow:"Insert bottom 1 row",insertLeftCol:"Insert left 1 col",insertRightCol:"Insert right 1 col",deleteRowCol:"Delete row col",deleteRow:"Delete 1 row",deleteCol:"Delete 1 col",deleteTable:"Delete table",mergeCell:"Merge cell",mergeCancelCell:"Cancel merge cell",verticalAlign:"Vertical align",verticalAlignTop:"Top",verticalAlignMiddle:"Middle",verticalAlignBottom:"Bottom",border:"Table border",borderAll:"All",borderEmpty:"Empty",borderDash:"Dash",borderExternal:"External",borderInternal:"Internal",borderTd:"Table cell border",borderTdTop:"Top",borderTdRight:"Right",borderTdBottom:"Bottom",borderTdLeft:"Left",borderTdForward:"Forward",borderTdBack:"Back"}},datePicker:{now:"Now",confirm:"Confirm",return:"Return",timeSelect:"Time select",weeks:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},year:" ",month:" ",hour:"Hour",minute:"Minute",second:"Second"},frame:{header:"Header",footer:"Footer"},pageBreak:{displayName:"Page Break"},zone:{headerTip:"Double click to edit header",footerTip:"Double click to edit footer"}};class Rr{constructor(t){this.langMap=new Map([["zhCN",gn],["en",ar]]),this.currentLocale=t}registerLangMap(t,e){const n=this.langMap.get(t);this.langMap.set(t,Nn(n||gn,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||gn}t(t){const e=t.split(".");let n="",i=this.getLang();for(let r=0;r<e.length;r++){const o=e[r],l=Reflect.get(i,o);if(l)n=i=l;else return""}return n}}class cr{constructor(){this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class dr{constructor(t,e){this.draw=t,this.zone=e,this.i18n=t.getI18n(),this.container=t.getContainer(),this.pageContainer=t.getPageContainer();const{tipContainer:n,tipContent:i}=this._drawZoneTip();this.tipContainer=n,this.tipContent=i,this.isDisableMouseMove=!0,this.currentMoveZone=c.EditorZone.MAIN;const r=[],{header:o,footer:l}=t.getOptions();o.disabled||r.push(c.EditorZone.HEADER),l.disabled||r.push(c.EditorZone.FOOTER),r.length&&this._watchMouseMoveZoneChange(r)}_watchMouseMoveZoneChange(t){this.pageContainer.addEventListener("mousemove",Ci(e=>{if(!(this.isDisableMouseMove||!this.draw.getIsPagingMode())&&!!e.offsetY)if(e.target instanceof HTMLCanvasElement){const n=this.zone.getZoneByY(e.offsetY);if(!t.includes(n)){this._updateZoneTip(!1);return}this.currentMoveZone=n,this._updateZoneTip(this.zone.getZone()===c.EditorZone.MAIN&&(n===c.EditorZone.HEADER||n===c.EditorZone.FOOTER),e.x,e.y)}else this._updateZoneTip(!1)},250)),this.pageContainer.addEventListener("mouseenter",()=>{this.isDisableMouseMove=!1}),this.pageContainer.addEventListener("mouseleave",()=>{this.isDisableMouseMove=!0,this._updateZoneTip(!1)})}_drawZoneTip(){const t=document.createElement("div");t.classList.add(`${x}-zone-tip`);const e=document.createElement("span");return t.append(e),this.container.append(t),{tipContainer:t,tipContent:e}}_updateZoneTip(t,e,n){t?(this.tipContainer.classList.add("show"),this.tipContainer.style.left=`${e}px`,this.tipContainer.style.top=`${n}px`,this.tipContent.innerText=this.i18n.t(`zone.${this.currentMoveZone===c.EditorZone.HEADER?"headerTip":"footerTip"}`)):this.tipContainer.classList.remove("show")}}class hr{constructor(t){this.INDICATOR_PADDING=2,this.INDICATOR_TITLE_TRANSLATE=[20,5],this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=c.EditorZone.MAIN,this.indicatorContainer=null,this.options.zone.tipDisabled||new dr(t,this)}isHeaderActive(){return this.getZone()===c.EditorZone.HEADER}isMainActive(){return this.getZone()===c.EditorZone.MAIN}isFooterActive(){return this.getZone()===c.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){const{header:e,footer:n}=this.options;!e.editable&&t===c.EditorZone.HEADER||!n.editable&&t===c.EditorZone.FOOTER||this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),Ge(()=>{const i=this.draw.getListener();i.zoneChange&&i.zoneChange(t);const r=this.draw.getEventBus();r.isSubscribe("zoneChange")&&r.emit("zoneChange",t)}))}getZoneByY(t){const e=this.draw.getHeader(),n=e.getHeaderTop()+e.getHeight(),i=this.draw.getFooter(),o=this.draw.getHeight()-(i.getFooterBottom()+i.getHeight());return t<n?c.EditorZone.HEADER:t>o?c.EditorZone.FOOTER:c.EditorZone.MAIN}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[n,i]=this.INDICATOR_TITLE_TRANSLATE,r=this.draw.getPageList(),o=this.draw.getMargins(),l=this.draw.getInnerWidth(),a=this.draw.getHeight(),R=this.draw.getPageGap(),d=a+R;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${x}-zone-indicator`);const u=this.draw.getHeader(),h=this.draw.getFooter(),g=e?u.getHeight():h.getHeight(),L=e?u.getHeaderTop():a-h.getFooterBottom()-g;for(let T=0;T<r.length;T++){const M=d*T+L,P=o[3]-this.INDICATOR_PADDING,O=o[3]+l+this.INDICATOR_PADDING,X=e?M-this.INDICATOR_PADDING:M+g+this.INDICATOR_PADDING,I=e?M+g+this.INDICATOR_PADDING:M-this.INDICATOR_PADDING,f=document.createElement("div");f.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),f.style.top=`${I}px`,f.style.transform=`translate(${n*t}px, ${i*t}px) scale(${t})`,this.indicatorContainer.append(f);const S=document.createElement("span");S.classList.add(`${x}-zone-indicator-border__top`),S.style.top=`${X}px`,S.style.width=`${l}px`,S.style.marginLeft=`${o[3]}px`,this.indicatorContainer.append(S);const N=document.createElement("span");N.classList.add(`${x}-zone-indicator-border__left`),N.style.top=`${M}px`,N.style.height=`${g}px`,N.style.left=`${P}px`,this.indicatorContainer.append(N);const m=document.createElement("span");m.classList.add(`${x}-zone-indicator-border__bottom`),m.style.top=`${I}px`,this.indicatorContainer.append(m);const W=document.createElement("span");W.classList.add(`${x}-zone-indicator-border__right`),W.style.top=`${M}px`,W.style.height=`${g}px`,W.style.left=`${O}px`,this.indicatorContainer.append(W)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){var t;(t=this.indicatorContainer)==null||t.remove(),this.indicatorContainer=null}}class ur{constructor(t,e){this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(){const t=this.getFooterBottom(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],r=this.draw.getHeight(),o=this.getHeight(),l=r-t-o;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:l,innerWidth:e,zone:c.EditorZone.FOOTER})}getFooterBottom(){const{footer:{bottom:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{footer:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Sn[t])}getHeight(){if(this.options.footer.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getFooterBottom()+e-t[2];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isFooterActive()?1:this.options.footer.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),r=[];let o=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(o+a.height>i)break;r.push(a),o+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:n,zone:c.EditorZone.FOOTER}),t.restore()}}class gr{constructor(t){this.UN_COUNT_STYLE_WIDTH=20,this.MEASURE_BASE_TEXT="0",this.LIST_GAP=10,this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}setList(t,e){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:r}=this.range.getRange();if(!~i&&!~r)return;const o=this.range.getRangeParagraphElementList();if(!o||!o.length)return;if(o.find(u=>u.listType===t&&u.listStyle===e)||!t){this.unsetList();return}const a=k();o.forEach(u=>{u.listId=a,u.listType=t,u.listStyle=e});const R=i===r,d=R?r:i;this.draw.render({curIndex:d,isSetCursor:R})}unsetList(){var R;if(this.draw.isReadonly())return;const{startIndex:e,endIndex:n}=this.range.getRange();if(!~e&&!~n)return;const i=(R=this.range.getRangeParagraphElementList())==null?void 0:R.filter(d=>d.listId);if(!i||!i.length)return;const r=this.draw.getElementList(),o=r[n];if(o.listId){let d=n+1;for(;d<r.length;){const u=r[d];if(u.value===y&&!u.listWrap)break;if(u.listId!==o.listId){this.draw.spliceElementList(r,d,0,[{value:y}]);break}d++}}i.forEach(d=>{delete d.listId,delete d.listType,delete d.listStyle,delete d.listWrap});const l=e===n,a=l?n:e;this.draw.render({curIndex:a,isSetCursor:l})}computeListStyle(t,e){const n=new Map;let i=0,r=e[i].listId,o=[];const l=e.length;for(;i<l;){const a=e[i];if(r&&r===a.listId)o.push(a);else if(a.listId&&a.listId!==r){if(o.length){const R=this.getListStyleWidth(t,o);n.set(r,R)}r=a.listId,o=r?[a]:[]}i++}if(o.length){const a=this.getListStyleWidth(t,o);n.set(r,a)}return n}findStyledElement(t){let e=t[0];for(let n=1;n<t.length;n++){const i=t[n];if(i.font||i.size||i.bold||i.italic){e=i;break}}return e}getListFontStyle(t,e){if(this.options.list.inheritStyle){const n=this.findStyledElement(t);return this.draw.getElementFont(n,e)}else{const{defaultFont:n,defaultSize:i}=this.options;return`${i*e}px ${n}`}}getListStyleWidth(t,e){const{scale:n,checkbox:i}=this.options,r=e[0];if(r.listStyle&&r.listStyle!==c.ListStyle.DECIMAL)return r.listStyle===c.ListStyle.CHECKBOX?(i.width+this.LIST_GAP)*n:this.UN_COUNT_STYLE_WIDTH*n;const o=e.reduce((R,d)=>(d.value===y&&(R+=1),R),0);if(!o)return 0;t.save(),t.font=this.getListFontStyle(e,n);const l=`${this.MEASURE_BASE_TEXT.repeat(String(o).length)}${c.KeyMap.PERIOD}`,a=t.measureText(l);return t.restore(),Math.ceil((a.width+this.LIST_GAP)*n)}drawListStyle(t,e,n){var M;const{elementList:i,offsetX:r,listIndex:o,ascent:l}=e,a=i[0];if(a.value!==y||a.listWrap)return;let R=0;const{defaultTabWidth:d,scale:u}=this.options;for(let P=1;P<i.length;P++){const O=i[P];if((O==null?void 0:O.type)!==c.ElementType.TAB)break;R+=d*u}const{coordinate:{leftTop:[h,g]}}=n,L=h-r+R,T=g+l;if(a.listStyle===c.ListStyle.CHECKBOX){const{width:P,height:O,gap:X}=this.options.checkbox,I={...a,checkbox:{value:!!((M=a.checkbox)!=null&&M.value)},metrics:{...a.metrics,width:(P+X*2)*u,height:O*u}};this.draw.getCheckboxParticle().render({ctx:t,x:L-X*u,y:T,index:0,row:{...e,elementList:[I,...e.elementList]}})}else{let P="";if(a.listType===c.ListType.UL?P=_e[a.listStyle]||_e[_t.DISC]:P=`${o+1}${c.KeyMap.PERIOD}`,!P)return;t.save(),t.font=this.getListFontStyle(i,u),t.fillText(P,L,T),t.restore()}}}const ui=class{constructor(s){this.options=s.getOptions()}render(s,t,e,n){const{scale:i,lineBreak:{color:r,lineWidth:o}}=this.options;s.save(),s.beginPath();const l=n-ui.HEIGHT*i/2,a=e+t.metrics.width;s.translate(a,l),s.scale(i,i),s.strokeStyle=r,s.lineWidth=o,s.lineCap="round",s.lineJoin="round",s.beginPath(),s.moveTo(8,0),s.lineTo(12,0),s.lineTo(12,6),s.lineTo(3,6),s.moveTo(3,6),s.lineTo(6,3),s.moveTo(3,6),s.lineTo(6,9),s.stroke(),s.closePath(),s.restore()}};let le=ui;le.WIDTH=12,le.HEIGHT=9,le.GAP=3;class gi{constructor(t){this.draw=t,this.position=t.getPosition(),this.options=t.getOptions(),this.elementList=[],this.rowList=[],this.positionList=[]}_recovery(){this.elementList=[],this.rowList=[],this.positionList=[]}_compute(t){this._computeRowList(),this._computePositionList(t)}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(t){const{lineBreak:e,scale:n}=this.options,i=this.draw.getHeader().getExtraHeight(),r=this.draw.getInnerWidth(),o=this.draw.getMargins();let l=o[3];e.disabled||(l+=(le.WIDTH+le.GAP)*n);const a=(t==null?void 0:t.startY)||o[0]+i;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:l,startY:a,innerWidth:r})}render(t,e){const{placeholder:n=this.options.placeholder}=e||{},{data:i,font:r,size:o,color:l,opacity:a}=n;this._recovery(),this.elementList=[{value:i,font:r,size:o,color:l}],ut(this.elementList,{editorOptions:this.options,isForceCompensation:!0}),this._compute(e);const R=this.draw.getInnerWidth();t.save(),t.globalAlpha=a,this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:this.rowList,pageNo:0,startIndex:0,innerWidth:R,isDrawLineBreak:!1}),t.restore()}}class Lr{constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==c.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=k();return t.forEach(n=>{Array.isArray(n.groupIds)||(n.groupIds=[]),n.groupIds.push(e)}),this.draw.render({isSetCursor:!1,isCompute:!1}),e}getElementListByGroupId(t,e){var i,r;const n=[];for(let o=0;o<t.length;o++){const l=t[o];if(l.type===c.ElementType.TABLE){const a=l.trList;for(let R=0;R<a.length;R++){const d=a[R];for(let u=0;u<d.tdList.length;u++){const h=d.tdList[u],g=this.getElementListByGroupId(h.value,e);if(g.length)return n.push(...g),n}}}if((i=l==null?void 0:l.groupIds)!=null&&i.includes(e)){n.push(l);const a=t[o+1];if(!((r=a==null?void 0:a.groupIds)!=null&&r.includes(e)))break}}return n}deleteGroup(t){if(this.draw.isReadonly())return;const e=this.draw.getOriginalMainElementList(),n=this.getElementListByGroupId(e,t);if(!!n.length){for(let i=0;i<n.length;i++){const r=n[i],o=r.groupIds,l=o.findIndex(a=>a===t);o.splice(l,1),o.length||delete r.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){var n,i;for(let r=0;r<t.length;r++){const o=t[r];if(o.type===c.ElementType.TABLE){const a=o.trList;for(let R=0;R<a.length;R++){const d=a[R];for(let u=0;u<d.tdList.length;u++){const h=d.tdList[u],g=this.getContextByGroupId(h.value,e);if(g)return{...g,isTable:!0,index:r,trIndex:R,tdIndex:u,tdId:h.id,trId:d.id,tableId:o.tableId}}}}const l=t[r+1];if(((n=o.groupIds)==null?void 0:n.includes(e))&&!((i=l==null?void 0:l.groupIds)!=null&&i.includes(e)))return{isTable:!1,startIndex:r,endIndex:r}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,n,i,r){const o=t.groupIds;if(!!o)for(const l of o){const a=this.fillRectMap.get(l);a?a.width+=i:this.fillRectMap.set(l,{x:e,y:n,width:i,height:r})}}render(t){var R;if(!this.fillRectMap.size)return;const e=this.range.getRange(),i=(R=this.draw.getElementList()[e.endIndex])==null?void 0:R.groupIds,{group:{backgroundColor:r,opacity:o,activeOpacity:l,activeBackgroundColor:a}}=this.options;t.save(),this.fillRectMap.forEach((d,u)=>{const{x:h,y:g,width:L,height:T}=d;i!=null&&i.includes(u)?(t.globalAlpha=l,t.fillStyle=a):(t.globalAlpha=o,t.fillStyle=r),t.fillRect(h,g,L,T)}),t.restore(),this.clearFillInfo()}}class Tr{constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:r,whiteSpace:{color:o,radius:l}}=this.options,a=e.metrics;t.save(),t.fillStyle=o,t.beginPath(),t.arc(n+a.width/2,i,l*r,0,Math.PI*2),t.fill(),t.closePath(),t.restore()}}class Pr{constructor(t){this.draw=t,this.eventBus=this.draw.getEventBus(),this.pageContainer=this.draw.getPageContainer(),this.pageContainer.addEventListener("mousemove",this._mousemove.bind(this)),this.pageContainer.addEventListener("mouseenter",this._mouseenter.bind(this)),this.pageContainer.addEventListener("mouseleave",this._mouseleave.bind(this)),this.pageContainer.addEventListener("mousedown",this._mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this._mouseup.bind(this)),this.pageContainer.addEventListener("click",this._click.bind(this))}_mousemove(t){!this.eventBus.isSubscribe("mousemove")||this.eventBus.emit("mousemove",t)}_mouseenter(t){!this.eventBus.isSubscribe("mouseenter")||this.eventBus.emit("mouseenter",t)}_mouseleave(t){!this.eventBus.isSubscribe("mouseleave")||this.eventBus.emit("mouseleave",t)}_mousedown(t){!this.eventBus.isSubscribe("mousedown")||this.eventBus.emit("mousedown",t)}_mouseup(t){!this.eventBus.isSubscribe("mouseup")||this.eventBus.emit("mouseup",t)}_click(t){!this.eventBus.isSubscribe("click")||this.eventBus.emit("click",t)}}class Mr{constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:n,lineNumber:{color:i,size:r,font:o,right:l,type:a}}=this.options,R=this.draw.getTextParticle(),d=this.draw.getMargins(),u=this.draw.getPosition().getOriginalMainPositionList(),g=this.draw.getPageRowList()[e];t.save(),t.fillStyle=i,t.font=`${r*n}px ${o}`;for(let L=0;L<g.length;L++){const T=g[L],{coordinate:{leftBottom:M}}=u[T.startIndex],P=a===c.LineNumberType.PAGE?L+1:T.rowIndex+1,O=R.measureText(t,{value:`${P}`}),X=d[3]-(O.width+l)*n,I=M[1]-O.actualBoundingBoxAscent*n;t.fillText(`${P}`,X,I)}t.restore()}}class Or{constructor(t){this.draw=t,this.header=t.getHeader(),this.footer=t.getFooter(),this.options=t.getOptions()}render(t){const{scale:e,pageBorder:{color:n,lineWidth:i,padding:r}}=this.options;t.save(),t.translate(.5,.5),t.strokeStyle=n,t.lineWidth=i*e;const o=this.draw.getMargins(),l=o[3]-r[3]*e,a=o[0]+this.header.getExtraHeight()-r[0]*e,R=this.draw.getInnerWidth()+(r[1]+r[3])*e,d=this.draw.getHeight()-a-this.footer.getExtraHeight()-o[2]+r[2]*e;t.rect(l,a,R,d),t.stroke(),t.restore()}}function Sr(s,t){const{value:e,oldValue:n}=t;n.isTable&&!e.isTable&&s.getTableTool().dispose()}class Xr{constructor(t){this.draw=t,this.eventBus=t.getEventBus(),this.execute()}execute(){this.eventBus.on("positionContextChange",t=>{Sr(this.draw,t)})}}class Ir{constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.tableTool=t.getTableTool(),this.tableParticle=t.getTableParticle(),this.options=t.getOptions()}insertTable(t,e){var L;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{defaultTrMinHeight:r}=this.options.table,o=this.draw.getElementList();let l=0;if((L=o[n])!=null&&L.listId){const T=this.position.getPositionList(),{rowIndex:M}=T[n],O=this.draw.getRowList()[M];l=(O==null?void 0:O.offsetX)||0}const a=this.draw.getContextInnerWidth()-l,R=[],d=a/e;for(let T=0;T<e;T++)R.push({width:d});const u=[];for(let T=0;T<t;T++){const M=[],P={height:r,tdList:M};for(let O=0;O<e;O++)M.push({colspan:1,rowspan:1,value:[]});u.push(P)}const h={type:c.ElementType.TABLE,value:"",colgroup:R,trList:u};ut([h],{editorOptions:this.options}),Ot(o,[h],n,{editorOptions:this.options});const g=n+1;this.draw.spliceElementList(o,g,n===i?0:i-n,[h]),this.range.setRange(g,g),this.draw.render({curIndex:g,isSetCursor:!1})}insertTableTopRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=l[n];if(a.tdList.length<o.colgroup.length){const u=a.tdList[0].rowIndex;for(let h=0;h<n;h++){const g=l[h];for(let L=0;L<g.tdList.length;L++){const T=g.tdList[L];T.rowspan>1&&T.rowIndex+T.rowspan>=u+1&&(T.rowspan+=1)}}}const R=k(),d={height:a.height,id:R,tdList:[]};for(let u=0;u<a.tdList.length;u++){const h=a.tdList[u],g=k();d.tdList.push({id:g,rowspan:1,colspan:h.colspan,value:[{value:y,size:16,tableId:i,trId:R,tdId:g}]})}l.splice(n,0,d),this.position.setPositionContext({isTable:!0,index:e,trIndex:n,tdIndex:0,tdId:d.tdList[0].id,trId:d.id,tableId:i}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableBottomRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=l[n],R=l.length-1===n?a:l[n+1];if(R.tdList.length<o.colgroup.length){const h=R.tdList[0].rowIndex;for(let g=0;g<n+1;g++){const L=l[g];for(let T=0;T<L.tdList.length;T++){const M=L.tdList[T];M.rowspan>1&&M.rowIndex+M.rowspan>=h+1&&(M.rowspan+=1)}}}const d=k(),u={height:R.height,id:d,tdList:[]};for(let h=0;h<R.tdList.length;h++){const g=R.tdList[h],L=k();u.tdList.push({id:L,rowspan:1,colspan:g.colspan,value:[{value:y,size:16,tableId:i,trId:d,tdId:L}]})}l.splice(n+1,0,u),this.position.setPositionContext({isTable:!0,index:e,trIndex:n+1,tdIndex:0,tdId:u.tdList[0].id,trId:u.id,tableId:o.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}adjustColWidth(t){if(t.type!==c.ElementType.TABLE)return;const{defaultColMinWidth:e}=this.options.table,n=t.colgroup,i=n.reduce((o,l)=>o+l.width,0),r=this.draw.getOriginalInnerWidth();if(i>r){const o=n.filter(a=>a.width>e),l=(i-r)/o.length;for(let a=0;a<n.length;a++){const R=n[a];R.width-l>=e&&(R.width-=l)}}}insertTableLeftCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=n;for(let u=0;u<l.length;u++){const h=l[u],g=k();h.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:R}=this.options.table;o.colgroup.splice(a,0,{width:R}),this.adjustColWidth(o),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:i}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableRightCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=n+1;for(let u=0;u<l.length;u++){const h=l[u],g=k();h.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:R}=this.options.table;o.colgroup.splice(a,0,{width:R}),this.adjustColWidth(o),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:o.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}deleteTableRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tdIndex:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=l[n],R=a.tdList[i].rowIndex;if(l.length<=1&&o.pagingIndex===0){this.deleteTable();return}for(let d=0;d<R;d++){const h=l[d].tdList;for(let g=0;g<h.length;g++){const L=h[g];L.rowIndex+L.rowspan>R&&L.rowspan--}}for(let d=0;d<a.tdList.length;d++){const u=a.tdList[d];if(u.rowspan>1){const h=k(),g=l[n+1];g.tdList.splice(d,0,{id:h,rowspan:u.rowspan-1,colspan:u.colspan,value:[{value:y,size:16,tableId:o.id,trId:g.id,tdId:h}]})}}l.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.clearRange(),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTableCol(){var u;const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,R=l[i].tdList[n].colIndex;if(!l.find(h=>h.tdList.length>1)){this.deleteTable();return}for(let h=0;h<l.length;h++){const g=l[h];for(let L=0;L<g.tdList.length;L++){const T=g.tdList[L];T.colIndex<=R&&T.colIndex+T.colspan>R&&(T.colspan>1?T.colspan--:g.tdList.splice(L,1))}}(u=o.colgroup)==null||u.splice(R,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTable(){const t=this.position.getPositionContext();if(!t.isTable)return;const e=this.draw.getOriginalElementList(),n=e[t.index];let i=1,r=t.index;if(n.pagingId){r=t.index-n.pagingIndex;for(let l=r+1;l<e.length&&e[l].pagingId===n.pagingId;l++)i++}e.splice(r,i);const o=r-1;this.position.setPositionContext({isTable:!1,index:o}),this.range.setRange(o,o),this.draw.render({curIndex:o}),this.tableTool.dispose()}mergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{isCrossRowCol:e,startTdIndex:n,endTdIndex:i,startTrIndex:r,endTrIndex:o}=this.range.getRange();if(!e)return;const{index:l}=t,d=this.draw.getOriginalElementList()[l].trList;let u=d[r].tdList[n],h=d[o].tdList[i];(u.x>h.x||u.y>h.y)&&([u,h]=[h,u]);const g=u.colIndex,L=h.colIndex+(h.colspan-1),T=u.rowIndex,M=h.rowIndex+(h.rowspan-1),P=[];for(let F=0;F<d.length;F++){const E=d[F],V=[];for(let Y=0;Y<E.tdList.length;Y++){const K=E.tdList[Y],b=K.colIndex,p=K.rowIndex;b>=g&&b<=L&&p>=T&&p<=M&&V.push(K)}V.length&&P.push(V)}if(!P.length)return;const O=P[P.length-1],X=P[0][0],I=O[O.length-1],f=X.x,S=X.y,N=I.x+I.width,m=I.y+I.height;for(let F=0;F<P.length;F++){const E=P[F];for(let V=0;V<E.length;V++){const Y=E[V],K=Y.x,b=Y.y,p=K+Y.width,H=b+Y.height;if(f>K||S>b||N<p||m<H)return}}const W=[],Z=P[0][0],U=Z.value[0];for(let F=0;F<P.length;F++){const E=P[F];for(let V=0;V<E.length;V++){const Y=E[V];if(!(F===0&&V===0)){W.push(Y.id);const b=Y.value.length>1?0:1;for(let p=b;p<Y.value.length;p++){const H=Y.value[p];Bt(de,U,H),Z.value.push(H)}}F===0&&V!==0&&(Z.colspan+=Y.colspan),F!==0&&Z.colIndex===Y.colIndex&&(Z.rowspan+=Y.rowspan)}}for(let F=0;F<d.length;F++){const E=d[F];let V=0;for(;V<E.tdList.length;){const Y=E.tdList[V];W.includes(Y.id)&&(E.tdList.splice(V,1),V--),V++}}this.position.setPositionContext({...t,trIndex:Z.trIndex,tdIndex:Z.tdIndex});const Q=Z.value.length-1;this.range.setRange(Q,Q),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=l[i],R=a.tdList[n];if(R.rowspan===1&&R.colspan===1)return;const d=R.colspan;if(R.colspan>1){for(let h=1;h<R.colspan;h++){const g=k();a.tdList.splice(n+h,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:o.id,trId:a.id,tdId:g}]})}R.colspan=1}if(R.rowspan>1){for(let h=1;h<R.rowspan;h++){const g=l[i+h];for(let L=0;L<d;L++){const T=k();g.tdList.splice(R.colIndex,0,{id:T,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:o.id,trId:g.id,tdId:T}]})}}R.rowspan=1}const u=R.value.length-1;this.range.setRange(u,u),this.draw.render(),this.tableTool.render()}splitVerticalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:r}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,R=a[r],d=R.tdList[i];l.colgroup.splice(i+1,0,{width:this.options.table.defaultColMinWidth});for(let u=0;u<a.length;u++){const h=a[u];let g=0;for(;g<h.tdList.length;){const L=h.tdList[g];if(L.rowIndex!==d.rowIndex)L.colIndex<=d.colIndex&&L.colIndex+L.colspan>d.colIndex&&L.colspan++;else if(L.id===d.id){const T=k();R.tdList.splice(g+d.colspan,0,{id:T,rowspan:d.rowspan,colspan:1,value:[{value:y,size:16,tableId:l.id,trId:h.id,tdId:T}]}),g++}g++}}this.draw.render(),this.tableTool.render()}splitHorizontalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:r}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,d=a[r].tdList[i];let u=-1,h=0;for(;h<a.length;){if(h===u){h++;continue}const g=a[h];let L=0;for(;L<g.tdList.length;){const T=g.tdList[L];if(T.id===d.id){const M=k(),P=k();a.splice(h+d.rowspan,0,{id:M,height:this.options.table.defaultTrMinHeight,tdList:[{id:P,rowspan:1,colspan:d.colspan,value:[{value:y,size:16,tableId:l.id,trId:M,tdId:P}]}]}),u=h+d.rowspan}else T.rowIndex>=d.rowIndex&&T.rowIndex<d.rowIndex+d.rowspan&&T.rowIndex+T.rowspan>=d.rowIndex+d.rowspan&&T.rowspan++;L++}h++}this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const r=e[i];for(let o=0;o<r.length;o++){const l=r[o];!l||l.verticalAlign===t||!l.verticalAlign&&t===c.VerticalAlign.TOP||(l.verticalAlign=t)}}const{endIndex:n}=this.range.getRange();this.draw.render({curIndex:n})}tableBorderType(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,r=this.draw.getOriginalElementList()[n];if(!r.borderType&&t===c.TableBorder.ALL||r.borderType===t)return;r.borderType=t;const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o})}tableBorderColor(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,r=this.draw.getOriginalElementList()[n];if(!r.borderColor&&t===this.options.table.defaultBorderColor||r.borderColor===t)return;r.borderColor=t;const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o,isCompute:!1})}tableTdBorderType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(o=>{var l;return!((l=o.borderTypes)!=null&&l.includes(t))});n.forEach(o=>{o.borderTypes||(o.borderTypes=[]);const l=o.borderTypes.findIndex(a=>a===t);i?~l||o.borderTypes.push(t):~l&&o.borderTypes.splice(l,1),o.borderTypes.length||delete o.borderTypes});const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdSlashType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(o=>{var l;return!((l=o.slashTypes)!=null&&l.includes(t))});n.forEach(o=>{o.slashTypes||(o.slashTypes=[]);const l=o.slashTypes.findIndex(a=>a===t);i?~l||o.slashTypes.push(t):~l&&o.slashTypes.splice(l,1),o.slashTypes.length||delete o.slashTypes});const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdBackgroundColor(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const r=e[i];for(let o=0;o<r.length;o++){const l=r[o];l.backgroundColor=t}}const{endIndex:n}=this.range.getRange();this.range.setRange(n,n),this.draw.render({isCompute:!1})}tableSelectAll(){const t=this.position.getPositionContext(),{index:e,tableId:n,isTable:i}=t;if(!i||!n)return;const{startIndex:r,endIndex:o}=this.range.getRange(),a=this.draw.getOriginalElementList()[e].trList,R=a.length-1,d=a[R].tdList.length-1;this.range.replaceRange({startIndex:r,endIndex:o,tableId:n,startTdIndex:0,endTdIndex:d,startTrIndex:0,endTrIndex:R}),this.draw.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1})}}c.AreaMode=void 0,function(s){s.EDIT="edit",s.READONLY="readonly",s.FORM="form"}(c.AreaMode||(c.AreaMode={}));class Nr{constructor(t){this.areaInfoMap=new Map,this.draw=t,this.options=t.getOptions(),this.zone=t.getZone(),this.range=t.getRange(),this.position=t.getPosition()}getAreaInfo(){return this.areaInfoMap}getActiveAreaId(){if(!this.areaInfoMap.size)return null;const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];return(n==null?void 0:n.areaId)||null}getActiveAreaInfo(){const t=this.getActiveAreaId();return t&&this.areaInfoMap.get(t)||null}isReadonly(){const t=this.getActiveAreaInfo();if(!(t!=null&&t.area))return!1;switch(t.area.mode){case c.AreaMode.EDIT:return!1;case c.AreaMode.READONLY:return!0;case c.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:r,range:o}=t;if(this.zone.getZone()!==c.EditorZone.MAIN&&this.zone.setZone(c.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),o&&!this.getActiveAreaId()){const{startIndex:a,endIndex:R}=o,d=this.draw.getOriginalMainElementList();if(!d[a]||!d[R])return null;this.range.setRange(o.startIndex,o.endIndex)}else if(r===c.LocationPosition.BEFORE)this.range.setRange(0,0);else{const R=this.draw.getOriginalMainElementList().length-1;this.range.setRange(R,R)}const l=e||k();return this.draw.insertElementList([{type:c.ElementType.AREA,value:"",areaId:l,valueList:n,area:_(i)}]),l}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const r of this.areaInfoMap){const{area:o,positionList:l}=r[1];if((o==null?void 0:o.hide)||!(o!=null&&o.backgroundColor)&&!(o!=null&&o.borderColor)&&!(o!=null&&o.placeholder))continue;const a=l.filter(L=>L.pageNo===e);if(!a.length)continue;t.translate(.5,.5);const R=a[0],d=a[a.length-1],u=n[3],h=Math.ceil(R.coordinate.leftTop[1]),g=Math.ceil(d.coordinate.rightBottom[1]-h);o.backgroundColor&&(t.fillStyle=o.backgroundColor,t.fillRect(u,h,i,g)),o.borderColor&&(t.strokeStyle=o.borderColor,t.strokeRect(u,h,i,g)),o.placeholder&&l.length<=1&&new gi(this.draw).render(t,{placeholder:{...Dn,...o.placeholder},startY:R.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],r=i.areaId;if(r){const o=this.areaInfoMap.get(r);o?(o.elementList.push(i),o.positionList.push(e[n])):this.areaInfoMap.set(r,{id:r,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:tt(n.elementList)}:null}getContextByAreaId(t,e){var i,r,o;const n=this.draw.getOriginalMainElementList();for(let l=0;l<n.length;l++){const a=n[l];if((e==null?void 0:e.position)===c.LocationPosition.OUTER_BEFORE){if(((i=n[l+1])==null?void 0:i.areaId)!==t)continue}else if((e==null?void 0:e.position)===c.LocationPosition.AFTER){if(!(a.areaId===t&&((r=n[l+1])==null?void 0:r.areaId)!==t))continue}else if((e==null?void 0:e.position)===c.LocationPosition.OUTER_AFTER){if(!(a.areaId!==t&&((o=n[l-1])==null?void 0:o.areaId)===t))continue}else if(a.areaId!==t)continue;const R=this.position.getOriginalMainPositionList();return{range:{startIndex:l,endIndex:l},elementPosition:R[l]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const r=["top","hide"];Object.entries(t.properties).forEach(([o,l])=>{if(Fn(l))return;const a=o;n.area[a]=l,r.includes(a)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,r=this.draw.getOriginalMainElementList(),o=t.value;ut([{type:c.ElementType.AREA,value:"",valueList:o,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(r,i[0].index,i.length,o,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class fr{constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,i,r,o){if(this.imageCache.has(o)){const l=this.imageCache.get(o);t.drawImage(l,e,n,i,r)}else{const l=new Image;l.setAttribute("crossOrigin","Anonymous"),l.src=o,l.onload=()=>{this.imageCache.set(o,l),t.drawImage(l,e,n,i,r)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:r,top:o,width:l,height:a,value:R}=this.mainBadge,d=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),u=(r||i.left)*n,h=(o||i.top)*n+d;this._drawImage(t,u,h,l*n,a*n,R)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:r}=this.options;for(const o of n){const{positionList:l}=o[1],a=l[0];if(a.pageNo!==e)continue;const R=this.areaBadgeMap.get(o[0]);if(!R)continue;const{left:d,top:u,width:h,height:g,value:L}=R,T=(d||r.left)*i,M=(u||r.top)*i+a.coordinate.leftTop[1];this._drawImage(t,T,M,h*i,g*i,L)}}}}}class mr{constructor(t,e){this.isDrawing=!1,this.startStroke=null,this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){var R;if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const r=this.draw.getPageNo();let o=this.data.find(d=>d.pageNo===r);if(this.startStroke&&(o||(o={pageNo:r,strokes:[]},this.data.push(o)),o.strokes.push(this.startStroke),this.startStroke=null),!((R=o==null?void 0:o.strokes)!=null&&R.length))return;const{scale:l}=this.options;o.strokes[o.strokes.length-1].points.push(e/l,n/l),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){var l;const n=(l=this.data.find(a=>a.pageNo===e))==null?void 0:l.strokes;if(!(n!=null&&n.length))return;const{graffiti:{defaultLineColor:i,defaultLineWidth:r},scale:o}=this.options;t.save();for(let a=0;a<n.length;a++){const R=n[a];t.beginPath(),t.strokeStyle=R.lineColor||i,t.lineWidth=(R.lineWidth||r)*o,t.moveTo(R.points[0]*o,R.points[1]*o);for(let d=2;d<R.points.length;d+=2)t.lineTo(R.points[d]*o,R.points[d+1]*o);t.stroke()}t.restore()}}class Fr{constructor(t,e,n,i,r,o){this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.renderCount=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=n.main,this.listener=i,this.eventBus=r,this.override=o,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new Rr(e.locale),this.historyManager=new ms(this),this.position=new Fs(this),this.zone=new hr(this),this.range=new Ws(this),this.margin=new Ys(this),this.background=new ps(this),this.badge=new fr(this),this.search=new Zs(this),this.group=new Lr(this),this.area=new Nr(this),this.underline=new Es(this),this.strikeout=new Us(this),this.highlight=new Vs(this),this.previewer=new or(this),this.imageParticle=new Yn(this),this.laTexParticle=new En(this),this.textParticle=new Qs(this),this.tableParticle=new bs(this),this.tableTool=new Ks(this),this.tableOperate=new Ir(this),this.pageNumber=new re(this),this.lineNumber=new Mr(this),this.waterMark=new Bs(this),this.placeholder=new gi(this),this.header=new Hs(this,n.header),this.footer=new ur(this,n.footer),this.hyperlinkParticle=new ys(this),this.labelParticle=new ws(this),this.dateParticle=new sr(this),this.separatorParticle=new Js(this),this.pageBreakParticle=new vs(this),this.superscriptParticle=new Gs,this.subscriptParticle=new xs,this.checkboxParticle=new $s(this),this.radioParticle=new js(this),this.blockParticle=new lr(this),this.listParticle=new gr(this),this.lineBreakParticle=new le(this),this.whiteSpaceParticle=new Tr(this),this.control=new zs(this),this.pageBorder=new Or(this),this.graffiti=new mr(this,n.graffiti),this.scrollObserver=new Cs(this),this.selectionObserver=new Ds(this),this.imageObserver=new cr,new Pr(this),this.canvasEvent=new Ns(this),this.cursor=new jo(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new fs(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new ir(this),new Xr(this);const{letterClass:l}=e;this.LETTER_REG=new RegExp(`[${l.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${l.map(a=>`[^${a}][${a}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.mode===c.EditorMode.PRINT&&this.setPrintData(),this.render({isInit:!0,isSetCursor:!1,isFirstRender:!0})}setPrintData(){this.printModeData={header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()};const t=_(this.printModeData);["header","main","footer"].forEach(n=>{t[n]=this.control.filterAssistElement(t[n])}),this.setEditorData(t)}clearPrintData(){this.printModeData&&(this.setEditorData(this.printModeData),this.printModeData=null)}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}setMode(t){this.mode!==t&&(t===c.EditorMode.PRINT&&this.setPrintData(),this.mode===c.EditorMode.PRINT&&this.clearPrintData(),this.clearSideEffect(),this.range.clearRange(),this.mode=t,this.options.mode=t,this.render({isSetCursor:!1,isSubmitHistory:!1}))}isReadonly(){var t,e;if((e=(t=this.area.getActiveAreaInfo())==null?void 0:t.area)!=null&&e.mode)return this.area.isReadonly();switch(this.mode){case c.EditorMode.DESIGN:return!1;case c.EditorMode.READONLY:case c.EditorMode.PRINT:case c.EditorMode.GRAFFITI:return!0;case c.EditorMode.FORM:return!this.control.getIsRangeWithinControl();default:return!1}}isDisabled(){var r,o,l,a,R;if(this.mode===c.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if((r=this.getTd())!=null&&r.disabled)return!0;if(t===e){const d=n[t],u=n[t+1];return!!(((o=d==null?void 0:d.title)==null?void 0:o.disabled)&&((l=u==null?void 0:u.title)==null?void 0:l.disabled)&&d.titleId===u.titleId||((a=d==null?void 0:d.control)==null?void 0:a.disabled)&&((R=u==null?void 0:u.control)==null?void 0:R.disabled)&&d.controlId===u.controlId)}return n.slice(t+1,e+1).some(d=>{var u,h;return((u=d.title)==null?void 0:u.disabled)||((h=d.control)==null?void 0:h.disabled)})}isDesignMode(){return this.mode===c.EditorMode.DESIGN}isPrintMode(){return this.mode===c.EditorMode.PRINT}isGraffitiMode(){return this.mode===c.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===c.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===c.PaperDirection.VERTICAL?n:e}getWidth(){return Math.floor(this.getOriginalWidth()*this.options.scale)}getHeight(){return Math.floor(this.getOriginalHeight()*this.options.scale)}getMainHeight(){return this.getHeight()-this.getMainOuterHeight()}getMainOuterHeight(){const t=this.getMargins(),e=this.header.getExtraHeight(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}getCanvasWidth(t=-1){return this.getPage(t).width}getCanvasHeight(t=-1){return this.getPage(t).height}getInnerWidth(){const t=this.getWidth(),e=this.getMargins();return t-e[1]-e[3]}getOriginalInnerWidth(){const t=this.getOriginalWidth(),e=this.getOriginalMargins();return t-e[1]-e[3]}getContextInnerWidth(){const t=this.position.getPositionContext();if(t.isTable){const{index:e,trIndex:n,tdIndex:i}=t,o=this.getOriginalElementList()[e].trList[n].tdList[i],l=this.getTdPadding();return o.width-l[1]-l[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===c.PaperDirection.VERTICAL?t:[t[1],t[2],t[3],t[0]]}getPageGap(){return this.options.pageGap*this.options.scale}getOriginalPageGap(){return this.options.pageGap}getPageNumberBottom(){const{pageNumber:{bottom:t},scale:e}=this.options;return t*e}getMarginIndicatorSize(){return this.options.marginIndicatorSize*this.options.scale}getDefaultBasicRowMarginHeight(){return this.options.defaultBasicRowMarginHeight*this.options.scale}getHighlightMarginHeight(){return this.options.highlightMarginHeight*this.options.scale}getTdPadding(){const{table:{tdPadding:t},scale:e}=this.options;return t.map(n=>n*e)}getContainer(){return this.container}getPageContainer(){return this.pageContainer}getVisiblePageNoList(){return this.visiblePageNoList}setVisiblePageNoList(t){this.visiblePageNoList=t,this.listener.visiblePageNoListChange&&this.listener.visiblePageNoListChange(this.visiblePageNoList),this.eventBus.isSubscribe("visiblePageNoListChange")&&this.eventBus.emit("visiblePageNoListChange",this.visiblePageNoList)}getIntersectionPageNo(){return this.intersectionPageNo}setIntersectionPageNo(t){this.intersectionPageNo=t,this.listener.intersectionPageNoChange&&this.listener.intersectionPageNoChange(this.intersectionPageNo),this.eventBus.isSubscribe("intersectionPageNoChange")&&this.eventBus.emit("intersectionPageNoChange",this.intersectionPageNo)}getPageNo(){return this.pageNo}setPageNo(t){this.pageNo=t}getRenderCount(){return this.renderCount}getPage(t=-1){return this.pageList[~t?t:this.pageNo]}getPageList(){return this.pageList}getPageCount(){return this.pageList.length}getTableRowList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return t[n].trList[i].tdList[r].rowList}getOriginalRowList(){const t=this.getZone();return t.isHeaderActive()?this.header.getRowList():t.isFooterActive()?this.footer.getRowList():this.rowList}getRowList(){return this.position.getPositionContext().isTable?this.getTableRowList(this.getOriginalElementList()):this.getOriginalRowList()}getPageRowList(){return this.pageRowList}getCtx(){return this.ctxList[this.pageNo]}getOptions(){return this.options}getSearch(){return this.search}getGroup(){return this.group}getArea(){return this.area}getBadge(){return this.badge}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getLineBreakParticle(){return this.lineBreakParticle}getTextParticle(){return this.textParticle}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){var o;const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return((o=t[n].trList)==null?void 0:o[i].tdList[r].value)||[]}getElementList(){const t=this.position.getPositionContext(),e=this.getOriginalElementList();return t.isTable?this.getTableElementList(e):e}getMainElementList(){return this.position.getPositionContext().isTable?this.getTableElementList(this.elementList):this.elementList}getOriginalElementList(){const t=this.getZone();return t.isHeaderActive()?this.getHeaderElementList():t.isFooterActive()?this.getFooterElementList():this.elementList}getOriginalMainElementList(){return this.elementList}getFooterElementList(){return this.footer.getElementList()}getTd(){const t=this.position.getPositionContext(),{index:e,trIndex:n,tdIndex:i,isTable:r}=t;return r?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:r=!0}=e;ut(t,{isHandleFirstElement:!1,editorOptions:this.options});let o=-1,l=this.control.getActiveControl();if(!l&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),l=this.control.getActiveControl()),l&&this.control.getIsRangeWithinControl())o=l.setValue(t,void 0,{isIgnoreDisabledRule:!0}),this.control.emitControlContentChange();else{const a=this.getElementList(),R=n===i,d=n+1;R||this.spliceElementList(a,d,i-n),this.spliceElementList(a,d,0,t),o=n+t.length;const u=a[d-1];t[0].listId&&u&&!u.listId&&(u==null?void 0:u.value)===y&&(!u.type||u.type===c.ElementType.TEXT)&&(a.splice(n,1),o-=1)}~o&&(this.range.setRange(o,o),this.render({curIndex:o,isSubmitHistory:r}))}appendElementList(t,e={}){if(!t.length)return;ut(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:r=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:r})}spliceElementList(t,e,n,i,r){var R,d,u,h,g,L,T,M;const{isIgnoreDeletedRule:o=!1}=r||{},{group:l,modeRule:a}=this.options;if(n>0){const P=e+n,O=t[P],X=O==null?void 0:O.listId;if(X&&((R=t[e-1])==null?void 0:R.listId)!==X){let I=P;for(;I<t.length;){const f=t[I];if(f.listId!==X||f.value===y)break;delete f.listId,delete f.listType,delete f.listStyle,I++}}if(!o&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const I=(d=this.getTd())==null?void 0:d.deletable;let f=P-1;for(;f>=e;){const S=t[f];((S==null?void 0:S.hide)||((u=S==null?void 0:S.control)==null?void 0:u.hide)||((h=S==null?void 0:S.area)==null?void 0:h.hide)||I!==!1&&((g=S==null?void 0:S.control)==null?void 0:g.deletable)!==!1&&(!S.controlId||this.mode!==c.EditorMode.FORM||!a[this.mode].controlDeletableDisabled)&&((L=S==null?void 0:S.title)==null?void 0:L.deletable)!==!1&&(l.deletable!==!1||!((T=S.groupIds)!=null&&T.length))&&(((M=S==null?void 0:S.area)==null?void 0:M.deletable)!==!1||(S==null?void 0:S.areaIndex)!==0))&&t.splice(f,1),f--}}else t.splice(e,n)}if(i!=null&&i.length)for(let P=0;P<i.length;P++)t.splice(e+P,0,i[P])}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}getTableTool(){return this.tableTool}getTableOperate(){return this.tableOperate}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,r=!!n&&i!==n;r&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const o=this.pageList.map(l=>l.toDataURL());return e&&this.setPagePixelRatio(null),r&&this.setMode(i),o}getPainterStyle(){return this.painterStyle&&Object.keys(this.painterStyle).length?this.painterStyle:null}getPainterOptions(){return this.painterOptions}setPainterStyle(t,e){this.painterStyle=t,this.painterOptions=e||null,this.getPainterStyle()&&this.pageList.forEach(n=>n.style.cursor="copy")}setDefaultRange(){!this.elementList.length||setTimeout(()=>{const t=this.elementList.length-1;this.range.setRange(t,t),this.range.setRangeStyle()})}getIsPagingMode(){return this.options.pageMode===c.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===c.PageMode.PAGING){const{height:i}=this.options,r=this.getPagePixelRatio(),o=this.pageList[0];o.style.height=`${i}px`,o.height=i*r,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(c.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((o,l)=>{o.width=n*e,o.height=i*e,o.style.width=`${n}px`,o.style.height=`${i}px`,o.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[l])});const r=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!r,curIndex:r==null?void 0:r.index}),this.listener.pageScaleChange&&this.listener.pageScaleChange(t),this.eventBus.isSubscribe("pageScaleChange")&&this.eventBus.emit("pageScaleChange",t)}getPagePixelRatio(){return this.pagePixelRatio||window.devicePixelRatio}setPagePixelRatio(t){!this.pagePixelRatio&&t===window.devicePixelRatio||t===this.pagePixelRatio||(this.pagePixelRatio=t,this.setPageDevicePixel())}setPageDevicePixel(){const t=this.getPagePixelRatio(),e=this.getWidth(),n=this.getHeight();this.pageList.forEach((i,r)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),r=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((o,l)=>{o.width=i*n,o.height=r*n,o.style.width=`${i}px`,o.style.height=`${r}px`,this._initPageContext(this.ctxList[l])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,o)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,this._initPageContext(this.ctxList[o])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getOriginValue(t={}){const{pageNo:e}=t;let n=this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(n=this.pageRowList[e].flatMap(r=>r.elementList)),{header:this.getHeaderElementList(),main:n,footer:this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t),{extraPickAttrs:n}=t,i={header:tt(e.header,{extraPickAttrs:n}),main:tt(e.main,{extraPickAttrs:n,isClassifyArea:!0}),footer:tt(e.footer,{extraPickAttrs:n}),graffiti:e.graffiti};return{version:Qe,data:i,options:_(this.options)}}setValue(t,e){const{header:n,main:i,footer:r}=_(t);if(!n&&!i&&!r)return;const{isSetCursor:o=!1}=e||{};[n,i,r].forEach(R=>{!R||ut(R,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:r}),this.historyManager.recovery();const a=o?i!=null&&i.length?i.length-1:0:void 0;a!==void 0&&this.range.setRange(a,a),this.render({curIndex:a,isSetCursor:o,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_wrapContainer(t){const e=document.createElement("div");return t.append(e),e}_formatContainer(){this.container.style.position="relative",this.container.style.width=`${this.getWidth()}px`,this.container.setAttribute(Kt,c.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${x}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const r=this.getPagePixelRatio();i.width=e*r,i.height=n*r,i.style.cursor="text";const o=i.getContext("2d");this._initPageContext(o),this.pageList.push(i),this.ctxList.push(o)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}getElementFont(t,e=1){const{defaultSize:n,defaultFont:i}=this.options,r=t.font||i,o=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${o*e}px ${r}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){var a;const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:r}=this.options,o=t.size||e;let l=1;return o<12?l=o/12:o>30&&(l=1+(o-30)/30),n*l*((a=t.rowMargin)!=null?a:i)*r}computeRowList(t){var Q,F,E,V,Y,K,b,p,H,w,D,J,v,St,ft,Xt,ct,nt,gt,j,$,Tt;const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:r=!1,startX:o=0,startY:l=0,pageHeight:a=0,mainOuterHeight:R=0,surroundElementList:d=[]}=t,{defaultSize:u,scale:h,imgCaption:g,table:{tdPadding:L,defaultTrMinHeight:T},defaultTabWidth:M}=this.options,P=this.getDefaultBasicRowMarginHeight(),X=document.createElement("canvas").getContext("2d"),I=this.listParticle.computeListStyle(X,n),f=[];n.length&&f.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:((Q=n==null?void 0:n[0])==null?void 0:Q.rowFlex)||((F=n==null?void 0:n[1])==null?void 0:F.rowFlex)});let S=o,N=l,m=0,W,Z=0,U=0;for(let it=0;it<n.length;it++){const et=f[f.length-1],C=n[it],Qt=this.getElementRowMargin(C),G={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},Me=et.offsetX||C.listId&&I.get(C.listId)||0,ht=e-Me,Oi=et.elementList.length===1;if(S+=Oi?Me:0,N+=Oi&&et.offsetY||0,(C.hide||((E=C.control)==null?void 0:E.hide)||((V=C.area)==null?void 0:V.hide))&&!this.isDesignMode()){const B=et.elementList[et.elementList.length-1];G.height=(B==null?void 0:B.metrics.height)||this.options.defaultSize*h,G.boundingBoxAscent=(B==null?void 0:B.metrics.boundingBoxAscent)||0,G.boundingBoxDescent=(B==null?void 0:B.metrics.boundingBoxDescent)||0}else if(C.type===c.ElementType.IMAGE||C.type===c.ElementType.LATEX)if(C.imgDisplay===c.ImageDisplay.SURROUND||C.imgDisplay===c.ImageDisplay.FLOAT_TOP||C.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)G.width=0,G.height=0,G.boundingBoxDescent=0;else{const B=C.width*h,st=C.height*h;if(B>ht){const z=st*ht/B;C.width=ht/h,C.height=z/h,G.width=ht,G.height=z,G.boundingBoxDescent=z}else G.width=B,G.height=st,G.boundingBoxDescent=st;if((Y=C.imgCaption)!=null&&Y.value){const z=C.imgCaption.size||g.size,Pt=(K=C.imgCaption.top)!=null?K:g.top,zt=(z+Pt)*h;G.boundingBoxAscent+=zt}}else if(C.type===c.ElementType.TABLE){const B=L[1]+L[3],st=L[0]+L[2];if(C.pagingId){let rt=it+1,Mt=0;for(;rt<n.length;){const lt=n[rt];if(lt.pagingId===C.pagingId){const at=lt.trList.filter(Vt=>!Vt.pagingRepeat);C.trList.push(...at),C.height+=lt.height,rt++,Mt++}else break}Mt&&n.splice(it+1,Mt)}C.pagingIndex=(b=C.pagingIndex)!=null?b:0;const z=C.trList;for(let rt=0;rt<z.length;rt++){const Mt=z[rt];Mt.height=Mt.minHeight||T,Mt.minHeight=Mt.height}this.tableParticle.computeRowColInfo(C);for(let rt=0;rt<z.length;rt++){const Mt=z[rt];for(let lt=0;lt<Mt.tdList.length;lt++){const at=Mt.tdList[lt],Vt=this.computeRowList({innerWidth:(at.width-B)*h,elementList:at.value,isFromTable:!0,isPagingMode:i}),Rt=Vt.reduce((Nt,Dt)=>Nt+Dt.height,0);at.rowList=Vt;const Lt=Rt/h+st;if(at.height<Lt){const Nt=Lt-at.height,Dt=z[rt+at.rowspan-1];Dt.height+=Nt,Dt.tdList.forEach(vt=>{vt.height+=Nt,vt.realHeight?vt.realHeight+=Nt:vt.realHeight=vt.height})}let It=0,Yt=0,Ft=0;for(;Ft<at.rowspan;){const Nt=z[Ft+rt]||z[rt];It+=Nt.minHeight,Yt+=Nt.height,Ft++}at.realMinHeight=It,at.realHeight=Yt,at.mainHeight=Lt}}const Pt=this.tableParticle.getTrListGroupByCol(z);for(let rt=0;rt<Pt.length;rt++){const Mt=Pt[rt];let lt=-1;for(let at=0;at<Mt.tdList.length;at++){const Vt=Mt.tdList[at],Rt=Vt.realHeight,Lt=Vt.mainHeight,It=Vt.realMinHeight,Yt=Lt<It?Rt-It:Rt-Lt;(!~lt||Yt<lt)&&(lt=Yt)}if(lt>0){const at=z[rt];at.height-=lt,at.tdList.forEach(Vt=>{Vt.height-=lt,Vt.realHeight-=lt})}}this.tableParticle.computeRowColInfo(C);const zt=this.tableParticle.getTableHeight(C),mi=this.tableParticle.getTableWidth(C);C.width=mi,C.height=zt;const Dl=mi*h,Tn=zt*h;if(G.width=Dl,G.height=Tn,G.boundingBoxDescent=Tn,G.boundingBoxAscent=-Qt,((p=n[it+1])==null?void 0:p.type)===c.ElementType.TABLE&&(G.boundingBoxAscent-=Qt),i){const rt=this.getHeight(),Mt=this.getMainOuterHeight();let lt=Mt;for(let Rt=0;Rt<f.length;Rt++){const Lt=f[Rt],It=Lt.offsetY||0;Lt.height+lt+It>rt||((H=f[Rt-1])==null?void 0:H.isPageBreak)?lt=Mt+Lt.height+It:lt+=Lt.height+It}const at=Qt*2*h,Vt=C.trList[0].height*h;if((lt+Vt+at>rt||C.pagingIndex!==0&&C.trList[0].pagingRepeat||((w=n[it-1])==null?void 0:w.type)===c.ElementType.PAGE_BREAK)&&(lt=Mt),lt+at+Tn>rt){const Rt=C.trList;let Lt=0,It=0,Yt=0;if(Rt.length>1)for(let Ft=0;Ft<Rt.length;Ft++){const Nt=Rt[Ft],Dt=Nt.height*h;if(lt+at+Yt+Dt>rt){const vt=Nt.tdList.reduce(($t,Ee)=>$t+Ee.colspan,0);((D=C.colgroup)==null?void 0:D.length)!==vt&&(It=0);break}else Lt=Ft+1,It=Rt.length-Lt,Yt+=Dt}if(It){const Ft=Rt.splice(Lt,It),Nt=Ft.reduce((ce,Pn)=>ce+Pn.height,0),Dt=Nt*h,vt=C.pagingId||k();C.pagingId=vt,C.height-=Nt,G.height-=Dt,G.boundingBoxDescent-=Dt;const $t=_(C);$t.pagingId=vt,$t.pagingIndex=C.pagingIndex+1;const Ee=Rt.filter(ce=>ce.pagingRepeat);if(Ee.length){const ce=_(Ee);ce.forEach(Pn=>Pn.id=k()),Ft.unshift(...ce)}$t.trList=Ft,$t.id=k(),this.spliceElementList(n,it+1,0,[$t])}}if(C.pagingId){const Rt=this.position.getPositionContext();if(Rt.isTable){let Lt=-1,It=-1,Yt=it;for(;Yt<n.length;){const Ft=n[Yt];if(Ft.pagingId!==C.pagingId)break;const Nt=Ft.trList.findIndex(Dt=>Dt.id===Rt.trId);if(~Nt){Lt=Yt,It=Nt;break}Yt++}~Lt&&(Rt.index=Lt,Rt.trIndex=It,this.position.setPositionContext(Rt))}}}}else if(C.type===c.ElementType.SEPARATOR){const{separator:{lineWidth:B}}=this.options,st=C.lineWidth||B;C.width=ht/h,G.width=ht,G.height=st*h,G.boundingBoxAscent=-Qt,G.boundingBoxDescent=-Qt+G.height}else if(C.type===c.ElementType.PAGE_BREAK)C.width=ht/h,G.width=ht,G.height=u;else if(C.type===c.ElementType.RADIO||C.controlComponent===c.ControlComponent.RADIO){const{width:B,height:st,gap:z}=this.options.radio,Pt=B+z*2;C.width=Pt,G.width=Pt*h,G.height=st*h}else if(C.type===c.ElementType.CHECKBOX||C.controlComponent===c.ControlComponent.CHECKBOX){const{width:B,height:st,gap:z}=this.options.checkbox,Pt=B+z*2;C.width=Pt,G.width=Pt*h,G.height=st*h}else if(C.type===c.ElementType.TAB)G.width=M*h,G.height=u*h,G.boundingBoxDescent=0,G.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(X,X.font);else if(C.type===c.ElementType.BLOCK){if(!C.width)G.width=ht;else{const B=C.width*h;G.width=Math.min(B,ht)}G.height=C.height*h,G.boundingBoxDescent=G.height,G.boundingBoxAscent=0}else if(C.type===c.ElementType.LABEL){const{defaultSize:B,label:{defaultPadding:st}}=this.options;X.font=this.getElementFont(C);const z=this.textParticle.measureText(X,C);G.width=(z.width+st[1]+st[3])*h,G.height=(C.size||B)*h,G.boundingBoxDescent=0,G.boundingBoxAscent=(st[0]+z.actualBoundingBoxAscent)*h}else{const B=C.size||u;(C.type===c.ElementType.SUPERSCRIPT||C.type===c.ElementType.SUBSCRIPT)&&(C.actualSize=Math.ceil(B*.6)),G.height=(C.actualSize||B)*h,X.font=this.getElementFont(C);const st=this.textParticle.measureText(X,C);G.width=st.width*h,C.letterSpacing&&(G.width+=C.letterSpacing*h);const z=this.textParticle.measureBasisWord(X,C.font);G.boundingBoxAscent=z.actualBoundingBoxAscent*h,G.boundingBoxDescent=z.actualBoundingBoxDescent*h,C.type===c.ElementType.SUPERSCRIPT?G.boundingBoxAscent+=G.height/2:C.type===c.ElementType.SUBSCRIPT&&(G.boundingBoxDescent+=G.height/2)}const Si=!C.hide&&(C.imgDisplay!==c.ImageDisplay.INLINE&&C.type===c.ElementType.IMAGE||C.type===c.ElementType.LATEX)?G.height+Qt:G.boundingBoxAscent+Qt,Re=Qt+G.boundingBoxAscent+G.boundingBoxDescent+Qt,Ct=Object.assign(C,{metrics:G,left:0,style:this.getElementFont(C,h)});(J=Ct.control)!=null&&J.minWidth&&(Ct.controlComponent&&(U+=G.width),Ct.controlComponent===c.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:et,rowElement:Ct,availableWidth:ht,controlRealWidth:U}),U=0));const q=n[it-1];let Xi=n[it+1],Ue=et.width+G.width;if(this.options.wordBreak===c.WordBreak.BREAK_WORD&&(!(q!=null&&q.type)||(q==null?void 0:q.type)===c.ElementType.TEXT)&&(!C.type||C.type===c.ElementType.TEXT)){const B=`${(q==null?void 0:q.value)||""}${C.value}`;if(this.WORD_LIKE_REG.test(B)){const{width:z,endElement:Pt}=this.textParticle.measureWord(X,n,it),zt=z*h;Pt&&zt<=ht&&(Ue+=zt,Xi=Pt)}Ue+=this.textParticle.measurePunctuationWidth(X,Xi)*h}C.listId&&(C.listId!==W?Z=0:C.value===y&&!C.listWrap&&Z++),W=C.listId;const Ii=this.position.setSurroundPosition({pageNo:m,rowElement:Ct,row:et,rowElementRect:{x:S,y:N,height:Re,width:G.width},availableWidth:ht,surroundElementList:d});S=Ii.x,Ue+=Ii.rowIncreaseWidth,S+=G.width;const Ni=C.type===c.ElementType.SEPARATOR||C.type===c.ElementType.TABLE||(q==null?void 0:q.type)===c.ElementType.TABLE||(q==null?void 0:q.type)===c.ElementType.BLOCK||C.type===c.ElementType.BLOCK||(q==null?void 0:q.imgDisplay)===c.ImageDisplay.INLINE||C.imgDisplay===c.ImageDisplay.INLINE||(q==null?void 0:q.listId)!==C.listId||(q==null?void 0:q.areaId)!==C.areaId&&!((v=C.area)!=null&&v.hide)||((St=C.control)==null?void 0:St.flexDirection)===c.FlexDirection.COLUMN&&(C.controlComponent===c.ControlComponent.CHECKBOX||C.controlComponent===c.ControlComponent.RADIO)&&(q==null?void 0:q.controlComponent)===c.ControlComponent.VALUE||it!==0&&C.value===y&&!((ft=C.area)!=null&&ft.hide),fi=Ue>ht,Ln=Ni||fi;if(Ln){const B={width:G.width,height:Re,startIndex:it,elementList:[Ct],ascent:Si,rowIndex:et.rowIndex+1,rowFlex:((Xt=n[it])==null?void 0:Xt.rowFlex)||((ct=n[it+1])==null?void 0:ct.rowFlex),isPageBreak:C.type===c.ElementType.PAGE_BREAK};if(Ct.controlComponent!==c.ControlComponent.PREFIX&&((nt=Ct.control)==null?void 0:nt.indentation)===c.ControlIndentation.VALUE_START){const st=et.elementList.findIndex(z=>z.controlId===Ct.controlId&&z.controlComponent!==c.ControlComponent.PREFIX);if(~st){const Pt=this.position.computeRowPosition({row:et,innerWidth:this.getInnerWidth()})[st];Pt&&(B.offsetX=Pt.coordinate.leftTop[0])}}C.listId&&(B.isList=!0,B.offsetX=I.get(C.listId),B.listIndex=Z),B.offsetY=!r&&((gt=C.area)==null?void 0:gt.top)&&C.areaId!==((j=n[it-1])==null?void 0:j.areaId)?C.area.top*h:0,f.push(B)}else et.width+=G.width,it===0&&(oe(n[1])||!!(($=n[1])!=null&&$.areaId))?(et.height=P,et.ascent=P):et.height<Re&&(et.height=Re,et.ascent=Si),et.elementList.push(Ct);if((Ln||it===n.length-1)&&(et.isWidthNotEnough=fi&&!Ni,!et.isSurround&&((q==null?void 0:q.rowFlex)===c.RowFlex.JUSTIFY||(q==null?void 0:q.rowFlex)===c.RowFlex.ALIGNMENT&&et.isWidthNotEnough))){const B=((Tt=et.elementList[0])==null?void 0:Tt.value)===y?et.elementList.slice(1):et.elementList,st=(ht-et.width)/(B.length-1);for(let z=0;z<B.length-1;z++){const Pt=B[z];Pt.metrics.width+=st}et.width=ht}if(Ln){S=o,N+=et.height,i&&!r&&a&&(N-l+R+Re>a||C.type===c.ElementType.PAGE_BREAK)&&(N=l,vo(d,m),m+=1),Ct.left=0;const B=f[f.length-1];S=this.position.setSurroundPosition({pageNo:m,rowElement:Ct,row:B,rowElementRect:{x:S,y:N,height:Re,width:G.width},availableWidth:ht,surroundElementList:d}).x,S+=G.width}}return f}_computePageList(){var a;const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),r=this.getMainOuterHeight();let o=r,l=0;if(e===c.PageMode.CONTINUITY){t[0]=this.rowList,o+=this.rowList.reduce((h,g)=>h+g.height+(g.offsetY||0),0);const R=this.getPagePixelRatio(),d=this.pageList[0],u=Number(d.style.height.replace("px",""));if(o>u)d.style.height=`${o}px`,d.height=o*R;else{const h=o<i?i:o;d.style.height=`${h}px`,d.height=h*R}this._initPageContext(this.ctxList[0])}else for(let R=0;R<this.rowList.length;R++){const d=this.rowList[R],u=d.offsetY||0;if(d.height+u+o>i||((a=this.rowList[R-1])==null?void 0:a.isPageBreak)){if(Number.isInteger(n)&&l>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}o=r+d.height+u,t.push([d]),l++}else o+=d.height+u,t[l].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:r}=e,o=this.getDefaultBasicRowMarginHeight(),l=this.getHighlightMarginHeight();for(let a=0;a<n.length;a++){const R=n[a];for(let d=0;d<R.elementList.length;d++){const u=R.elementList[d],h=R.elementList[d-1],g=u.highlight||this.control.getControlHighlight(r,R.startIndex+d);if(g){h&&h.highlight&&h.highlight!==u.highlight&&this.highlight.render(t);const{coordinate:{leftTop:[L,T]}}=i[R.startIndex+d],M=u.left||0;this.highlight.recordFillInfo(t,L-M,T+o-l,u.metrics.width+M,R.height-2*o+2*l,g)}else h!=null&&h.highlight&&this.highlight.render(t)}this.highlight.render(t)}}drawRow(t,e){var f,S,N,m,W,Z,U,Q,F;debugger;this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:r,lineBreak:o,whiteSpace:l}=this.options,{rowList:a,pageNo:R,elementList:d,positionList:u,startIndex:h,zone:g,isDrawLineBreak:L=!o.disabled,isDrawWhiteSpace:T=!l.disabled}=e,M=this.isPrintMode(),P=this.isGraffitiMode(),{isCrossRowCol:O,tableId:X}=this.range.getRange();let I=h;for(let E=0;E<a.length;E++){const V=a[E],Y={x:0,y:0,width:0,height:0};let K=null;for(let b=0;b<V.elementList.length;b++){const p=V.elementList[b],H=p.metrics,{ascent:w,coordinate:{leftTop:[D,J]}}=u[V.startIndex+b],v=V.elementList[b-1];if((p.hide||((f=p.control)==null?void 0:f.hide)||((S=p.area)==null?void 0:S.hide))&&!this.isDesignMode())this.textParticle.complete();else if(p.type===c.ElementType.IMAGE)this.textParticle.complete(),p.imgDisplay!==c.ImageDisplay.SURROUND&&p.imgDisplay!==c.ImageDisplay.FLOAT_TOP&&p.imgDisplay!==c.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,p,D,J+w);else if(p.type===c.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,p,D,J+w);else if(p.type===c.ElementType.TABLE)O&&(Y.x=D,Y.y=J,K=p),this.tableParticle.render(t,p,D,J);else if(p.type===c.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,p,D,J+w);else if(p.type===c.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,p,D,J+w);else if(p.type===c.ElementType.DATE){const ct=V.elementList[b+1];(!v||v.dateId!==p.dateId)&&this.textParticle.complete(),this.textParticle.record(t,p,D,J+w),(!ct||ct.dateId!==p.dateId)&&this.textParticle.complete()}else p.type===c.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,p,D,J+w)):p.type===c.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,p,D,J+w)):p.type===c.ElementType.SEPARATOR?this.separatorParticle.render(t,p,D,J):p.type===c.ElementType.PAGE_BREAK?this.mode!==c.EditorMode.CLEAN&&!M&&this.pageBreakParticle.render(t,p,D,J):p.type===c.ElementType.CHECKBOX||p.controlComponent===c.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:D,y:J+w,index:b,row:V})):p.type===c.ElementType.RADIO||p.controlComponent===c.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x:D,y:J+w,index:b,row:V})):p.type===c.ElementType.TAB?this.textParticle.complete():p.rowFlex===c.RowFlex.ALIGNMENT||p.rowFlex===c.RowFlex.JUSTIFY?(this.textParticle.record(t,p,D,J+w),this.textParticle.complete()):p.type===c.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,R,p,D,J+w)):(p.left&&this.textParticle.complete(),this.textParticle.record(t,p,D,J+w),(p.width||p.letterSpacing||Zi.test(p.value))&&this.textParticle.complete());if(L&&!M&&this.mode!==c.EditorMode.CLEAN&&!V.isWidthNotEnough&&b===V.elementList.length-1&&this.lineBreakParticle.render(t,p,D,J+V.height/2),T&&Ei.test(p.value)&&this.whiteSpaceParticle.render(t,p,D,J+V.height/2),(N=p.control)!=null&&N.border){((m=v==null?void 0:v.control)==null?void 0:m.border)&&v.controlId!==p.controlId&&this.control.drawBorder(t);const ct=this.getElementRowMargin(p);this.control.recordBorderInfo(D,J+ct,p.metrics.width,V.height-2*ct)}else(W=v==null?void 0:v.control)!=null&&W.border&&this.control.drawBorder(t);if(p.underline||((Z=p.control)==null?void 0:Z.underline)){(v==null?void 0:v.type)===c.ElementType.SUBSCRIPT&&p.type!==c.ElementType.SUBSCRIPT&&this.underline.render(t);const ct=this.getElementRowMargin(p),nt=p.left||0;let gt=0;p.type===c.ElementType.SUBSCRIPT&&(gt=this.subscriptParticle.getOffsetY(p));const j=(U=p.control)!=null&&U.underline?this.options.underlineColor:p.color;this.underline.recordFillInfo(t,D-nt,J+V.height-ct+gt,H.width+nt,0,j,(Q=p.textDecoration)==null?void 0:Q.style)}else((v==null?void 0:v.underline)||((F=v==null?void 0:v.control)==null?void 0:F.underline))&&this.underline.render(t);if(p.strikeout){if(!p.type||Ut.includes(p.type)){v&&(v.type===c.ElementType.SUBSCRIPT&&p.type!==c.ElementType.SUBSCRIPT||v.type===c.ElementType.SUPERSCRIPT&&p.type!==c.ElementType.SUPERSCRIPT||this.getElementSize(v)!==this.getElementSize(p))&&this.strikeout.render(t);const ct=this.textParticle.measureBasisWord(t,this.getElementFont(p));let nt=J+w+ct.actualBoundingBoxDescent*n-H.height/2;p.type===c.ElementType.SUBSCRIPT?nt+=this.subscriptParticle.getOffsetY(p):p.type===c.ElementType.SUPERSCRIPT&&(nt+=this.superscriptParticle.getOffsetY(p)),this.strikeout.recordFillInfo(t,D,nt,H.width)}}else v!=null&&v.strikeout&&this.strikeout.render(t);const{zone:St,startIndex:ft,endIndex:Xt}=this.range.getRange();if(St===g&&ft!==Xt&&ft<=I&&I<=Xt){const ct=this.position.getPositionContext();if(!ct.isTable&&!p.tdId||ct.tdId===p.tdId)if(ft===I){const nt=d[ft+1];nt&&nt.value===y&&(Y.x=D+H.width,Y.y=J,Y.height=V.height,Y.width+=this.options.rangeMinWidth)}else{let nt=H.width;nt===0&&V.elementList.length===1&&(nt=this.options.rangeMinWidth),Y.width||(Y.x=D,Y.y=J,Y.height=V.height),Y.width+=nt}}if(!r.disabled&&p.groupIds&&this.group.recordFillInfo(p,D,J,H.width,V.height),I++,p.type===c.ElementType.TABLE&&!p.hide){const ct=i[1]+i[3];for(let nt=0;nt<p.trList.length;nt++){const gt=p.trList[nt];for(let j=0;j<gt.tdList.length;j++){const $=gt.tdList[j];this.drawRow(t,{elementList:$.value,positionList:$.positionList,rowList:$.rowList,pageNo:R,startIndex:0,innerWidth:($.width-ct)*n,zone:g,isDrawLineBreak:L})}}}}if(V.isList&&this.listParticle.drawListStyle(t,V,u[V.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!M&&!P){if(Y.width&&Y.height){const{x:b,y:p,width:H,height:w}=Y;this.range.render(t,b,p,H,w)}if(O&&K&&K.id===X){const{coordinate:{leftTop:[b,p]}}=u[V.startIndex];this.tableParticle.drawRange(t,K,b,p)}}}}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:r,pageNo:o}=e;for(let l=0;l<i.length;l++){const a=i[l],R=a.element;if((o===a.pageNo||a.zone===c.EditorZone.HEADER||a.zone==c.EditorZone.FOOTER)&&R.imgDisplay&&r.includes(R.imgDisplay)&&R.type===c.ElementType.IMAGE){const d=R.imgFloatPosition;this.imageParticle.render(t,R,d.x*n,d.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){var P,O,X;const{elementList:e,positionList:n,rowList:i,pageNo:r}=t,{inactiveAlpha:o,pageMode:l,header:a,footer:R,pageNumber:d,lineNumber:u,pageBorder:h}=this.options,g=this.mode===c.EditorMode.PRINT,L=this.getInnerWidth(),T=this.ctxList[r];T.globalAlpha=this.zone.isMainActive()?1:o,this._clearPage(r),(!g||!((P=this.options.modeRule[c.EditorMode.PRINT])!=null&&P.backgroundDisabled))&&this.background.render(T,r),g||this.area.render(T,r),l!==c.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(T,r),g||this.margin.render(T,r),this._drawFloat(T,{pageNo:r,imgDisplays:[c.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(T,r);const M=(O=i[0])==null?void 0:O.startIndex;this.drawRow(T,{elementList:e,positionList:n,rowList:i,pageNo:r,startIndex:M,innerWidth:L,zone:c.EditorZone.MAIN}),this.getIsPagingMode()&&(a.disabled||this.header.render(T,r),d.disabled||this.pageNumber.render(T,r),R.disabled||this.footer.render(T,r)),this._drawFloat(T,{pageNo:r,imgDisplays:[c.ImageDisplay.FLOAT_TOP,c.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(T,r),this.elementList.length<=1&&!((X=this.elementList[0])!=null&&X.listId)&&this.placeholder.render(T),u.disabled||this.lineNumber.render(T,r),h.disabled||this.pageBorder.render(T),this.badge.render(T,r),this.isGraffitiMode()&&this.graffiti.render(T,r)}_disconnectLazyRender(){var t;(t=this.lazyRenderIntersectionObserver)==null||t.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const r=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[r],pageNo:r})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){this.renderCount++;const{header:e,footer:n}=this.options,{isSubmitHistory:i=!0,isSetCursor:r=!0,isCompute:o=!0,isLazy:l=!0,isInit:a=!1,isSourceHistory:R=!1,isFirstRender:d=!1}=t||{};let{curIndex:u}=t||{};const h=this.getInnerWidth(),g=this.getIsPagingMode(),L=this.pageRowList.length;if(o){this.position.setFloatPositionList([]),g&&(e.disabled||this.header.compute(),n.disabled||this.footer.compute());const P=this.getMargins(),O=this.getHeight(),X=this.header.getExtraHeight(),I=this.getMainOuterHeight(),f=P[3],S=P[0]+X,N=tn(this.elementList);if(this.rowList=this.computeRowList({startX:f,startY:S,pageHeight:O,mainOuterHeight:I,isPagingMode:g,innerWidth:h,surroundElementList:N,elementList:this.elementList}),this.pageRowList=this._computePageList(),this.position.computePositionList(),this.area.compute(),!this.isPrintMode()){const m=this.search.getSearchKeyword();m&&this.search.compute(m),this.control.computeHighlightList()}this.isGraffitiMode()&&this.graffiti.compute()}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let P=0;P<this.pageRowList.length;P++)this.pageList[P]||this._createPage(P);const T=this.pageRowList.length,M=this.pageList.length;if(M>T){const P=M-T;this.ctxList.splice(T,P),this.pageList.splice(T,P).forEach(O=>O.remove())}l&&g?this._lazyRender():this._immediateRender(),r?u=this.setCursor(u):this.range.getIsSelection()&&this.cursor.focus(),(i&&!d||u!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(u),Ge(()=>{this.range.setRangeStyle(),o&&this.control.getActiveControl()&&this.control.reAwakeControl(),o&&!this.isReadonly()&&this.position.getPositionContext().isTable&&this.tableTool.render(),o&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),L!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(i||R)&&!a&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"))})}setCursor(t){var r;const e=this.position.getPositionContext(),n=this.position.getPositionList();if(e.isTable){const{index:o,trIndex:l,tdIndex:a}=e,d=(r=this.getOriginalElementList()[o].trList)==null?void 0:r[l].tdList[a].positionList;t===void 0&&d&&(t=d.length-1);const u=d==null?void 0:d[t];this.position.setCursorPosition(u||null)}else this.position.setCursorPosition(t!==void 0?n[t]:null);let i=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const l=this.getElementList()[t];if(ji.includes(l.type)){i=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(l,a)}}return this.cursor.drawCursor({isShow:i}),t}submitHistory(t){const e=this.position.getPositionContext(),n=qe(this.elementList),i=qe(this.header.getElementList()),r=qe(this.footer.getElementList()),o=_(this.range.getRange()),l=this.pageNo,a=_(e),R=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(R),this.setPageNo(l),this.position.setPositionContext(_(a)),this.header.setElementList(_(i)),this.footer.setElementList(_(r)),this.elementList=_(n),this.range.replaceRange(_(o)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}}class Li{constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeSize=t.size.bind(t),this.executeSizeAdd=t.sizeAdd.bind(t),this.executeSizeMinus=t.sizeMinus.bind(t),this.executeBold=t.bold.bind(t),this.executeItalic=t.italic.bind(t),this.executeUnderline=t.underline.bind(t),this.executeStrikeout=t.strikeout.bind(t),this.executeSuperscript=t.superscript.bind(t),this.executeSubscript=t.subscript.bind(t),this.executeColor=t.color.bind(t),this.executeHighlight=t.highlight.bind(t),this.executeTitle=t.title.bind(t),this.executeList=t.list.bind(t),this.executeRowFlex=t.rowFlex.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeJumpControl=t.jumpControl.bind(t)}}function Ti(s,t){let e=0;for(let n=1;n<t;n++){const i=s[n],r=s[n-1];(i.value===y&&!i.listWrap&&!i.listId||i.listId!==(r==null?void 0:r.listId)&&r.value!==y||i.titleId!==(r==null?void 0:r.titleId)&&r.value!==y)&&e++}return e}function Wr(s,t){return s===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:s===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:s===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${s}px`,height:`${t}px`}}function pr(s,t){const{width:e,height:n,direction:i=c.PaperDirection.VERTICAL}=t,r=document.createElement("iframe");r.style.visibility="hidden",r.style.position="absolute",r.style.left="0",r.style.top="0",r.style.width="0",r.style.height="0",r.style.border="none",document.body.append(r);const o=r.contentWindow,l=o.document;l.open();const a=document.createElement("div"),R=Wr(e,n);s.forEach(h=>{const g=document.createElement("img");g.style.width=i===c.PaperDirection.HORIZONTAL?R.height:R.width,g.style.height=i===c.PaperDirection.HORIZONTAL?R.width:R.height,g.src=h,a.append(g)});const d=document.createElement("style"),u=`
88
+ `?y:R,controlId:i.controlId,type:c.ElementType.CONTROL,control:i.control,controlComponent:c.ControlComponent.PLACEHOLDER,color:this.controlOptions.placeholderColor};Ot(n,[d],t,{editorOptions:this.options}),this.draw.spliceElementList(n,t+a+1,0,[d])}}setValue(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.setValue(t)}setControlProperties(t,e={}){const n=e.elementList||this.getElementList(),{startIndex:i}=e.range||this.getRange(),r=n[i];let o=i;for(;o>0;){const a=n[o];if(a.controlId!==r.controlId)break;a.control={...a.control,...t},o--}let l=i+1;for(;l<n.length;){const a=n[l];if(a.controlId!==r.controlId)break;a.control={...a.control,...t},l++}}keydown(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.keydown(t)}cut(){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.cut()}getValueById(t){const{id:e,groupId:n,conceptId:i,areaId:r}=t,o=[];if(!e&&!i&&!n)return o;const l=(R,d)=>{let u=0;for(;u<R.length;){const h=R[u];if(u++,h.type===c.ElementType.TABLE){const X=h.trList;for(let I=0;I<X.length;I++){const f=X[I];for(let S=0;S<f.tdList.length;S++){const N=f.tdList[S];l(N.value,d)}}}if(!h.control||n&&h.control.groupId!==n||e&&h.controlId!==e||i&&h.control.conceptId!==i||r&&h.areaId!==r)continue;const{type:g,code:L,valueSets:T}=h.control;let M=u,P="";const O=[];for(;M<R.length;){const X=R[M];if(X.controlId!==h.controlId)break;(g===c.ControlType.TEXT||g===c.ControlType.DATE||g===c.ControlType.NUMBER)&&X.controlComponent===c.ControlComponent.VALUE&&(P+=X.value,O.push(bt(X,ve))),M++}if(g===c.ControlType.TEXT||g===c.ControlType.DATE||g===c.ControlType.NUMBER)o.push({...h.control,zone:d,value:P||null,innerText:P||null,elementList:tt(O)});else if(g===c.ControlType.SELECT||g===c.ControlType.CHECKBOX||g===c.ControlType.RADIO){const X=L==null?void 0:L.split(",").map(I=>{var f;return(f=T==null?void 0:T.find(S=>S.code===I))==null?void 0:f.value}).filter(Boolean).join("");o.push({...h.control,zone:d,value:L||null,innerText:X||null})}u=M}},a=[{zone:c.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:c.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:c.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:R,elementList:d}of a)l(d,R);return o}setValueListById(t){if(!t.length)return;let e=!1,n=!1;const i=o=>{let l=0;for(;l<o.length;){const a=o[l];if(l++,a.type===c.ElementType.TABLE){const O=a.trList;for(let X=0;X<O.length;X++){const I=O[X];for(let f=0;f<I.tdList.length;f++){const S=I.tdList[f];i(S.value)}}}if(!a.control)continue;const R=t.find(O=>{var X;return(!O.groupId||O.groupId===((X=a.control)==null?void 0:X.groupId))&&(O.id&&a.controlId===O.id||O.conceptId&&a.control.conceptId===O.conceptId||O.areaId&&a.areaId===O.areaId)});if(!R)continue;const{value:d,isSubmitHistory:u=!0}=R;e=!0,u&&(n=!0);const{type:h}=a.control;let g=l;for(;g<o.length&&o[g].controlId===a.controlId;)g++;const T={range:{startIndex:l-1,endIndex:g-2},elementList:o},M={isIgnoreDisabledRule:!0,isIgnoreDeletedRule:!0};if(h===c.ControlType.TEXT){const O=Array.isArray(d)?d:d?[{value:d}]:[];O.length&&ut(O,{isHandleFirstElement:!1,editorOptions:this.options});const X=new Rn(a,this);this.activeControl=X,O.length?X.setValue(O,T,M):X.clearValue(T,M)}else if(h===c.ControlType.SELECT){if(Array.isArray(d))continue;const O=new Le(a,this);this.activeControl=O,d?O.setSelect(d,T,M):O.clearSelect(T,M)}else if(h===c.ControlType.CHECKBOX){if(Array.isArray(d))continue;const O=new Ve(a,this);this.activeControl=O;const X=d?d.split(","):[];O.setSelect(X,T,M)}else if(h===c.ControlType.RADIO){if(Array.isArray(d))continue;const O=new sn(a,this);this.activeControl=O;const X=d?[d]:[];O.setSelect(X,T,M)}else if(h===c.ControlType.DATE){const O=new Te(a,this);this.activeControl=O,we(d)?(d.length&&ut(d,{isHandleFirstElement:!1,editorOptions:this.options}),O.setValue(d,T,M)):Ki(d)?O.setSelect(d,T,M):O.clearSelect(T,M)}else if(h===c.ControlType.NUMBER){const O=Array.isArray(d)?d:d?[{value:d}]:[];O.length&&ut(O,{isHandleFirstElement:!1,editorOptions:this.options});const X=new Pe(a,this);this.activeControl=X,O.length?X.setValue(O,T,M):X.clearValue(T,M)}this.emitControlContentChange({context:T}),this.activeControl=null;let P=l;for(;P<o.length&&o[P].controlId===a.controlId;)P++;l=P}};this.destroyControl({isEmitEvent:!1});const r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const o of r)i(o);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}setExtensionListById(t){if(!t.length)return;const e=i=>{let r=0;for(;r<i.length;){const o=i[r];if(r++,o.type===c.ElementType.TABLE){const d=o.trList;for(let u=0;u<d.length;u++){const h=d[u];for(let g=0;g<h.tdList.length;g++){const L=h.tdList[g];e(L.value)}}}if(!o.control)continue;const l=t.find(d=>{var u;return(!d.groupId||d.groupId===((u=o.control)==null?void 0:u.groupId))&&(d.id&&o.controlId===d.id||d.conceptId&&o.control.conceptId===d.conceptId||d.areaId&&o.areaId===d.areaId)});if(!l)continue;const{extension:a}=l;this.setControlProperties({extension:a},{elementList:i,range:{startIndex:r,endIndex:r}});let R=r;for(;R<i.length&&i[R].controlId===o.controlId;)R++;r=R}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i)}setPropertiesListById(t){if(!t.length)return;let e=!1,n=!1;const i=o=>{let l=0;for(;l<o.length;){const a=o[l];if(l++,a.type===c.ElementType.TABLE){const g=a.trList;for(let L=0;L<g.length;L++){const T=g[L];for(let M=0;M<T.tdList.length;M++){const P=T.tdList[M];i(P.value)}}}if(!a.control)continue;const R=t.find(g=>{var L;return(!g.groupId||g.groupId===((L=a.control)==null?void 0:L.groupId))&&(g.id&&a.controlId===g.id||g.conceptId&&a.control.conceptId===g.conceptId||g.areaId&&a.areaId===g.areaId)});if(!R)continue;const{properties:d,isSubmitHistory:u=!0}=R;e=!0,u&&(n=!0),this.setControlProperties({...a.control,...d,value:a.control.value},{elementList:o,range:{startIndex:l,endIndex:l}}),yt.forEach(g=>{const L=d[g];L&&Reflect.set(a,g,L)});let h=l;for(;h<o.length&&o[h].controlId===a.controlId;)h++;l=h}},r={header:this.draw.getHeaderElementList(),main:this.draw.getOriginalMainElementList(),footer:this.draw.getFooterElementList()};for(const o in r){const l=r[o];i(l)}if(!!e){for(const o in r){const l=o,a=tt(r[l],{isClassifyArea:!0,extraPickAttrs:["id"]});r[l]=a,ut(a,{editorOptions:this.options,isForceCompensation:!0})}this.draw.setEditorData(r),n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1})}}getList(){const t=[];function e(i){for(let r=0;r<i.length;r++){const o=i[r];if(o.type===c.ElementType.TABLE){const l=o.trList;for(let a=0;a<l.length;a++){const R=l[a];for(let d=0;d<R.tdList.length;d++){const h=R.tdList[d].value;e(h)}}}if(o.controlId){const l=bt(o,[...Je,...fe]);t.push(l)}}}const n=[this.draw.getHeader().getElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooter().getElementList()];for(const i of n)e(i);return tt(t,{extraPickAttrs:["controlId"]})}recordBorderInfo(t,e,n,i){this.controlBorder.recordBorderInfo(t,e,n,i)}drawBorder(t){this.controlBorder.render(t)}getPreControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(a,R){for(let d=R;d>0;d--){const u=a[d];if(u.type===c.ElementType.TABLE){const g=u.trList||[];for(let L=g.length-1;L>=0;L--){const T=g[L],M=T.tdList;for(let P=M.length-1;P>=0;P--){const O=M[P],X=i(O.value,O.value.length-1);if(X)return{positionContext:{isTable:!0,index:d,trIndex:L,tdIndex:P,tdId:O.id,trId:T.id,tableId:u.id},nextIndex:X.nextIndex}}}}if(!u.controlId||u.controlId===n.controlId)continue;let h=d;for(;h>0;){const g=a[h];if(g.controlComponent===c.ControlComponent.VALUE||g.controlComponent===c.ControlComponent.PREFIX||g.controlComponent===c.ControlComponent.PRE_TEXT)break;h--}return{positionContext:{isTable:!1},nextIndex:h}}return null}const{startIndex:r}=this.range.getRange(),o=this.getElementList(),l=i(o,r);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:R,trIndex:d,tdIndex:u}=e,h=a[R].trList;for(let L=d;L>=0;L--){const T=h[L],M=T.tdList;for(let P=M.length-1;P>=0;P--){if(d===L&&P>=u)continue;const O=M[P],X=i(O.value,O.value.length-1);if(X)return{positionContext:{isTable:!0,index:e.index,trIndex:L,tdIndex:P,tdId:O.id,trId:T.id,tableId:n.tableId},nextIndex:X.nextIndex}}}const g=i(a,R-1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}getNextControlContext(){if(!this.activeControl)return null;const e=this.draw.getPosition().getPositionContext();if(!e)return null;const n=this.activeControl.getElement();function i(a,R){var d,u;for(let h=R;h<a.length;h++){const g=a[h];if(g.type===c.ElementType.TABLE){const L=g.trList||[];for(let T=0;T<L.length;T++){const M=L[T],P=M.tdList;for(let O=0;O<P.length;O++){const X=P[O],I=i(X.value,0);if(I)return{positionContext:{isTable:!0,index:h,trIndex:T,tdIndex:O,tdId:X.id,trId:M.id,tableId:g.id},nextIndex:I.nextIndex}}}}if(!(!g.controlId||g.controlId===n.controlId||((d=a[h+1])==null?void 0:d.controlComponent)===c.ControlComponent.PREFIX||((u=a[h+1])==null?void 0:u.controlComponent)===c.ControlComponent.PRE_TEXT))return{positionContext:{isTable:!1},nextIndex:h}}return null}const{endIndex:r}=this.range.getRange(),o=this.getElementList(),l=i(o,r);if(l)return{positionContext:e.isTable?e:l.positionContext,nextIndex:l.nextIndex};if(n.tableId){const a=this.draw.getOriginalElementList(),{index:R,trIndex:d,tdIndex:u}=e,h=a[R].trList;for(let L=d;L<h.length;L++){const T=h[L],M=T.tdList;for(let P=0;P<M.length;P++){if(d===L&&P<=u)continue;const O=M[P],X=i(O.value,0);if(X)return{positionContext:{isTable:!0,index:e.index,trIndex:L,tdIndex:P,tdId:O.id,trId:T.id,tableId:n.tableId},nextIndex:X.nextIndex}}}const g=i(a,R+1);if(g)return{positionContext:{isTable:!1},nextIndex:g.nextIndex}}return null}initNextControl(t={}){const{direction:e=dt.DOWN}=t;let n=null;if(e===dt.UP?n=this.getPreControlContext():n=this.getNextControlContext(),!n)return;const{nextIndex:i,positionContext:r}=n;this.draw.getPosition().setPositionContext(r),this.draw.getRange().replaceRange({startIndex:i,endIndex:i}),this.draw.render({curIndex:i,isCompute:!1,isSetCursor:!0,isSubmitHistory:!1})}setMinWidthControlInfo(t){var d,u,h,g,L;const{row:e,rowElement:n,controlRealWidth:i,availableWidth:r}=t;if(!((d=n.control)!=null&&d.minWidth))return;const{scale:o}=this.options,l=n.control.minWidth*o;let a=null;if(((u=n.control)==null?void 0:u.minWidth)&&(((h=n.control)==null?void 0:h.rowFlex)===c.RowFlex.CENTER||((g=n.control)==null?void 0:g.rowFlex)===c.RowFlex.RIGHT)){let T=n.metrics.width,M=e.elementList.length-1;for(;M>=0;){const P=e.elementList[M];if(T+=P.metrics.width,((L=e.elementList[M-1])==null?void 0:L.controlComponent)===c.ControlComponent.PREFIX){a=P;break}M--}a&&T<l&&(n.control.rowFlex===c.RowFlex.CENTER?a.left=(l-T)/2:n.control.rowFlex===c.RowFlex.RIGHT&&(a.left=l-T-n.metrics.width))}const R=l-i;if(R>0){const T=(a==null?void 0:a.left)||0,M=r-e.width-n.metrics.width,P=Math.min(M,R);n.left=P-T,e.width+=P-T}}}class $s{constructor(t){this.draw=t,this.options=t.getOptions()}setSelect(t){const{checkbox:e}=t;e?e.value=!e.value:t.checkbox={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:i,row:r}=t;let{y:o}=t;const{checkbox:{gap:l,lineWidth:a,fillStyle:R,strokeStyle:d,verticalAlign:u},scale:h}=this.options,{metrics:g,checkbox:L}=r.elementList[i];if(u===c.VerticalAlign.TOP||u===c.VerticalAlign.MIDDLE){let X=i+1,I=null;for(;X<r.elementList.length&&(I=r.elementList[X],!(I.value!==y&&I.value!==Ce));)X++;if(I){const{metrics:{boundingBoxAscent:f,boundingBoxDescent:S}}=I,N=f+S;N>g.height&&(u===c.VerticalAlign.TOP?o-=f-g.height:u===c.VerticalAlign.MIDDLE&&(o-=(N-g.height)/2))}}const T=Math.round(n+l*h),M=Math.round(o-g.height+a),P=g.width-l*2*h,O=g.height;e.save(),e.beginPath(),e.translate(.5,.5),L!=null&&L.value?(e.lineWidth=a,e.strokeStyle="red",e.rect(T,M,P,O),e.stroke(),e.beginPath(),e.fillStyle=R,e.fillRect(T,M,P,O),e.beginPath(),e.strokeStyle=d,e.lineWidth=a*2*h,e.moveTo(T+2*h,M+O/2),e.lineTo(T+P/2,M+O-3*h),e.lineTo(T+P-2*h,M+3*h),e.stroke()):(e.lineWidth=a,e.strokeStyle="red",e.rect(T,M,P,O),e.stroke());debugger;e.closePath(),e.restore()}}class js{constructor(t){this.draw=t,this.options=t.getOptions()}setSelect(t){const{radio:e}=t;e?e.value=!e.value:t.radio={value:!0},this.draw.render({isCompute:!1,isSetCursor:!1})}render(t){const{ctx:e,x:n,index:i,row:r}=t;let{y:o}=t;const{radio:{gap:l,lineWidth:a,fillStyle:R,strokeStyle:d,verticalAlign:u},scale:h}=this.options,{metrics:g,radio:L}=r.elementList[i];if(u===c.VerticalAlign.TOP||u===c.VerticalAlign.MIDDLE){let X=i+1,I=null;for(;X<r.elementList.length&&(I=r.elementList[X],!(I.value!==y&&I.value!==Ce));)X++;if(I){const{metrics:{boundingBoxAscent:f,boundingBoxDescent:S}}=I,N=f+S;N>g.height&&(u===c.VerticalAlign.TOP?o-=f-g.height:u===c.VerticalAlign.MIDDLE&&(o-=(N-g.height)/2))}}const T=Math.round(n+l*h),M=Math.round(o-g.height+a),P=g.width-l*2*h,O=g.height;e.save(),e.beginPath(),e.translate(.5,.5),e.strokeStyle=L!=null&&L.value?R:d,e.lineWidth=a,e.arc(T+P/2,M+O/2,P/2,0,Math.PI*2),e.stroke(),L!=null&&L.value&&(e.beginPath(),e.fillStyle=R,e.arc(T+P/2,M+O/2,P/3,0,Math.PI*2),e.fill()),e.closePath(),e.restore()}}const ei="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHA9Ilx1MjAwQiIsdT1gCmA7ZnVuY3Rpb24gYShpKXt2YXIgYyxmO2xldCBsPSIiLG49MDtmb3IoO248aS5sZW5ndGg7KXtjb25zdCB0PWlbbl07aWYodC50eXBlPT09InRhYmxlIil7aWYodC50ckxpc3QpZm9yKGxldCBzPTA7czx0LnRyTGlzdC5sZW5ndGg7cysrKXtjb25zdCBvPXQudHJMaXN0W3NdO2ZvcihsZXQgZT0wO2U8by50ZExpc3QubGVuZ3RoO2UrKyl7Y29uc3Qgcj1vLnRkTGlzdFtlXTtsKz1hKHIudmFsdWUpfX19ZWxzZSBpZih0LnR5cGU9PT0iaHlwZXJsaW5rIil7Y29uc3Qgcz10Lmh5cGVybGlua0lkLG89W107Zm9yKDtuPGkubGVuZ3RoOyl7Y29uc3QgZT1pW25dO2lmKHMhPT1lLmh5cGVybGlua0lkKXtuLS07YnJlYWt9ZGVsZXRlIGUudHlwZSxvLnB1c2goZSksbisrfWwrPWEobyl9ZWxzZSBpZih0LmNvbnRyb2xJZCl7aWYoISgoYz10LmNvbnRyb2wpIT1udWxsJiZjLmhpZGUpKXtjb25zdCBzPXQuY29udHJvbElkLG89W107Zm9yKDtuPGkubGVuZ3RoOyl7Y29uc3QgZT1pW25dO2lmKHMhPT1lLmNvbnRyb2xJZCl7bi0tO2JyZWFrfWUuY29udHJvbENvbXBvbmVudD09PSJ2YWx1ZSImJihkZWxldGUgZS5jb250cm9sSWQsby5wdXNoKGUpKSxuKyt9bCs9YShvKX19ZWxzZSghdC50eXBlfHx0LnR5cGU9PT0idGV4dCIpJiYhKChmPXQuYXJlYSkhPW51bGwmJmYuaGlkZSkmJihsKz10LnZhbHVlKTtuKyt9cmV0dXJuIGx9ZnVuY3Rpb24gaChpKXtjb25zdCBsPVtdLG49L1swLTldLyxjPS9bQS1aYS16XS8sZj0vXHMvO2xldCB0PSExLHM9ITEsbz0iIjtmdW5jdGlvbiBlKCl7byYmKGwucHVzaChvKSxvPSIiKX1mb3IoY29uc3QgciBvZiBpKWMudGVzdChyKT8odHx8ZSgpLG8rPXIsdD0hMCxzPSExKTpuLnRlc3Qocik/KHN8fGUoKSxvKz1yLHQ9ITEscz0hMCk6KGUoKSx0PSExLHM9ITEsZi50ZXN0KHIpfHxsLnB1c2gocikpO3JldHVybiBlKCksbH1vbm1lc3NhZ2U9aT0+e2NvbnN0IGw9aS5kYXRhLGM9YShsKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke3B9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChwLCJnIiksdSksZj1oKGMpO3Bvc3RNZXNzYWdlKGYubGVuZ3RoKX19KSgpOwo=",ni=typeof window!="undefined"&&window.Blob&&new Blob([atob(ei)],{type:"text/javascript;charset=utf-8"});function qs(){const s=ni&&(window.URL||window.webkitURL).createObjectURL(ni);try{return s?new Worker(s,{}):new Worker("data:application/javascript;base64,"+ei,{type:"module"})}finally{s&&(window.URL||window.webkitURL).revokeObjectURL(s)}}const ii="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IGg9e2ZpcnN0OjEsc2Vjb25kOjIsdGhpcmQ6Myxmb3VydGg6NCxmaWZ0aDo1LHNpeHRoOjZ9LGI9WyJ0ZXh0IiwiaHlwZXJsaW5rIiwic3Vic2NyaXB0Iiwic3VwZXJzY3JpcHQiLCJjb250cm9sIiwiZGF0ZSIsImxhYmVsIl0sbT0iXHUyMDBCIjtmdW5jdGlvbiBJKGMpe3JldHVybiFjLnR5cGV8fGIuaW5jbHVkZXMoYy50eXBlKX1mdW5jdGlvbiBOKGMpe3ZhciBFO2NvbnN0e2VsZW1lbnRMaXN0OmcscG9zaXRpb25MaXN0OmR9PWMscD1bXTtsZXQgcj0wO2Zvcig7cjxnLmxlbmd0aDspe2NvbnN0IHQ9Z1tyXSxsPShlLG4scyk9Pntjb25zdCB1PWUudGl0bGVJZCxMPWUubGV2ZWwsaT17dHlwZToidGl0bGUiLHZhbHVlOiIiLGxldmVsOkwsdGl0bGVJZDp1LHBhZ2VObzpkW3JdLnBhZ2VOb30sbz1bXTtmb3IoO3M8bi5sZW5ndGg7KXtjb25zdCBhPW5bc107aWYodSE9PWEudGl0bGVJZCl7cy0tO2JyZWFrfW8ucHVzaChhKSxzKyt9cmV0dXJuIGkudmFsdWU9by5maWx0ZXIoYT0+SShhKSkubWFwKGE9PmEudmFsdWUpLmpvaW4oIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChtLCJnIiksIiIpLHtwb3NpdGlvbjpzLHRpdGxlRWxlbWVudDppfX07aWYodC50aXRsZUlkKXtjb25zdHtwb3NpdGlvbjplLHRpdGxlRWxlbWVudDpufT1sKHQsZyxyKTtyPWUscC5wdXNoKG4pfWlmKHQudHlwZT09PSJ0YWJsZSIpe2NvbnN0IGU9dC50ckxpc3Q7Zm9yKGxldCBuPTA7bjxlLmxlbmd0aDtuKyspe2NvbnN0IHM9ZVtuXTtmb3IobGV0IHU9MDt1PHMudGRMaXN0Lmxlbmd0aDt1Kyspe2NvbnN0IGk9cy50ZExpc3RbdV0udmFsdWU7aWYoaS5sZW5ndGg+MSl7bGV0IG89MTtmb3IoO288aS5sZW5ndGg7KXtpZigoRT1pW29dKSE9bnVsbCYmRS50aXRsZUlkKXtjb25zdHt0aXRsZUVsZW1lbnQ6YSxwb3NpdGlvbjp5fT1sKGlbb10saSxvKTtwLnB1c2goYSksbz15fW8rK319fX19cisrfWlmKCFwLmxlbmd0aClyZXR1cm4gbnVsbDtjb25zdCBmPSh0LGwpPT57Y29uc3QgZT1sLnN1YkNhdGFsb2dbbC5zdWJDYXRhbG9nLmxlbmd0aC0xXSxuPWhbZT09bnVsbD92b2lkIDA6ZS5sZXZlbF0scz1oW3QubGV2ZWxdO2UmJnM+bj9mKHQsZSk6bC5zdWJDYXRhbG9nLnB1c2goe2lkOnQudGl0bGVJZCxuYW1lOnQudmFsdWUsbGV2ZWw6dC5sZXZlbCxwYWdlTm86dC5wYWdlTm8sc3ViQ2F0YWxvZzpbXX0pfSx2PVtdO2ZvcihsZXQgdD0wO3Q8cC5sZW5ndGg7dCsrKXtjb25zdCBsPXBbdF0sZT12W3YubGVuZ3RoLTFdLG49aFtlPT1udWxsP3ZvaWQgMDplLmxldmVsXSxzPWhbbC5sZXZlbF07ZSYmcz5uP2YobCxlKTp2LnB1c2goe2lkOmwudGl0bGVJZCxuYW1lOmwudmFsdWUsbGV2ZWw6bC5sZXZlbCxwYWdlTm86bC5wYWdlTm8sc3ViQ2F0YWxvZzpbXX0pfXJldHVybiB2fW9ubWVzc2FnZT1jPT57Y29uc3QgZz1jLmRhdGEsZD1OKGcpO3Bvc3RNZXNzYWdlKGQpfX0pKCk7Cg==",oi=typeof window!="undefined"&&window.Blob&&new Blob([atob(ii)],{type:"text/javascript;charset=utf-8"});function tr(){const s=oi&&(window.URL||window.webkitURL).createObjectURL(oi);try{return s?new Worker(s,{}):new Worker("data:application/javascript;base64,"+ii,{type:"module"})}finally{s&&(window.URL||window.webkitURL).revokeObjectURL(s)}}const si="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHUoZSl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBlKXtpZihzLnR5cGU9PT0idGFibGUiKXtjb25zdCBvPXMudHJMaXN0O2ZvcihsZXQgbj0wO248by5sZW5ndGg7bisrKXtjb25zdCBjPW9bbl07Zm9yKGxldCByPTA7cjxjLnRkTGlzdC5sZW5ndGg7cisrKXtjb25zdCBpPWMudGRMaXN0W3JdO3QucHVzaCguLi51KGkudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgbyBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMobyl8fHQucHVzaChvKX1yZXR1cm4gdH1vbm1lc3NhZ2U9ZT0+e2NvbnN0IHQ9ZS5kYXRhLHM9dSh0KTtwb3N0TWVzc2FnZShzKX19KSgpOwo=",ri=typeof window!="undefined"&&window.Blob&&new Blob([atob(si)],{type:"text/javascript;charset=utf-8"});function er(){const s=ri&&(window.URL||window.webkitURL).createObjectURL(ri);try{return s?new Worker(s,{}):new Worker("data:application/javascript;base64,"+si,{type:"module"})}finally{s&&(window.URL||window.webkitURL).revokeObjectURL(s)}}const li="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBSPShlPT4oZS5IQUxGPSJoYWxmIixlLk9ORV9USElSRD0ib25lLXRoaXJkIixlLlFVQVJURVI9InF1YXJ0ZXIiLGUpKShSfHx7fSksZz0oZT0+KGUuQVJBQklDPSJhcmFiaWMiLGUuQ0hJTkVTRT0iY2hpbmVzZSIsZSkpKGd8fHt9KTtjb25zdCB2PSJcdTIwMEIiO1IuSEFMRisiIiwxLzIsUi5PTkVfVEhJUkQrIiIsMS8zLFIuUVVBUlRFUisiIiwxLzQ7ZnVuY3Rpb24gUyhlKXtpZih0eXBlb2Ygc3RydWN0dXJlZENsb25lPT0iZnVuY3Rpb24iKXJldHVybiBzdHJ1Y3R1cmVkQ2xvbmUoZSk7aWYoIWV8fHR5cGVvZiBlIT0ib2JqZWN0IilyZXR1cm4gZTtsZXQgbj17fTtyZXR1cm4gQXJyYXkuaXNBcnJheShlKT9uPWUubWFwKHU9PlModSkpOk9iamVjdC5rZXlzKGUpLmZvckVhY2godT0+e25bdV09UyhlW3VdKX0pLG59ZnVuY3Rpb24geShlLG4pe2NvbnN0IHU9e307Zm9yKGNvbnN0IGYgaW4gZSluLmluY2x1ZGVzKGYpJiYodVtmXT1lW2ZdKTtyZXR1cm4gdX1mdW5jdGlvbiBYKGUsbil7cmV0dXJuIGUubGVuZ3RoIT09bi5sZW5ndGg/ITE6IWUuc29tZSh1PT4hbi5pbmNsdWRlcyh1KSl9dmFyIGE9KGU9PihlLlRFWFQ9InRleHQiLGUuSU1BR0U9ImltYWdlIixlLlRBQkxFPSJ0YWJsZSIsZS5IWVBFUkxJTks9Imh5cGVybGluayIsZS5TVVBFUlNDUklQVD0ic3VwZXJzY3JpcHQiLGUuU1VCU0NSSVBUPSJzdWJzY3JpcHQiLGUuU0VQQVJBVE9SPSJzZXBhcmF0b3IiLGUuUEFHRV9CUkVBSz0icGFnZUJyZWFrIixlLkNPTlRST0w9ImNvbnRyb2wiLGUuQVJFQT0iYXJlYSIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUuUkFESU89InJhZGlvIixlLkxBVEVYPSJsYXRleCIsZS5UQUI9InRhYiIsZS5EQVRFPSJkYXRlIixlLkJMT0NLPSJibG9jayIsZS5USVRMRT0idGl0bGUiLGUuTElTVD0ibGlzdCIsZS5MQUJFTD0ibGFiZWwiLGUpKShhfHx7fSk7Y29uc3QgXz1bInJvd0ZsZXgiLCJyb3dNYXJnaW4iXSxCPVsidHlwZSIsImZvbnQiLCJzaXplIiwiYm9sZCIsImNvbG9yIiwiaXRhbGljIiwiaGlnaGxpZ2h0IiwidW5kZXJsaW5lIiwic3RyaWtlb3V0Iiwicm93RmxleCIsInJvd01hcmdpbiIsImRhc2hBcnJheSIsInRyTGlzdCIsInRhYmxlVG9vbERpc2FibGVkIiwiYm9yZGVyVHlwZSIsImJvcmRlckNvbG9yIiwidHJhbnNsYXRlWCIsIndpZHRoIiwiaGVpZ2h0IiwidXJsIiwiY29sZ3JvdXAiLCJ2YWx1ZUxpc3QiLCJjb250cm9sIiwiY2hlY2tib3giLCJyYWRpbyIsImRhdGVGb3JtYXQiLCJibG9jayIsImxldmVsIiwidGl0bGUiLCJsaXN0VHlwZSIsImxpc3RTdHlsZSIsImxpc3RXcmFwIiwiZ3JvdXBJZHMiLCJjb25jZXB0SWQiLCJpbWdEaXNwbGF5IiwiaW1nRmxvYXRQb3NpdGlvbiIsImltZ1Rvb2xEaXNhYmxlZCIsImltZ1ByZXZpZXdEaXNhYmxlZCIsImltZ0Nyb3AiLCJpbWdDYXB0aW9uIiwidGV4dERlY29yYXRpb24iLCJleHRlbnNpb24iLCJleHRlcm5hbElkIiwiYXJlYUlkIiwiYXJlYSIsImhpZGUiLCJsYWJlbCIsImxhYmVsSWQiLCJsaW5lV2lkdGgiLCJmb3JtSW5wdXQiXSxVPVsiY29uY2VwdElkIiwiZXh0ZW5zaW9uIiwiZXh0ZXJuYWxJZCIsInZlcnRpY2FsQWxpZ24iLCJiYWNrZ3JvdW5kQ29sb3IiLCJib3JkZXJUeXBlcyIsInNsYXNoVHlwZXMiLCJkaXNhYmxlZCIsImRlbGV0YWJsZSJdLHc9WyJmb250Iiwic2l6ZSIsImJvbGQiLCJoaWdobGlnaHQiLCJpdGFsaWMiLCJzdHJpa2VvdXQiXTthLlRFWFQsYS5IWVBFUkxJTkssYS5TVUJTQ1JJUFQsYS5TVVBFUlNDUklQVCxhLkNPTlRST0wsYS5EQVRFLGEuSU1BR0UsYS5MQVRFWCxhLkJMT0NLLGEuUEFHRV9CUkVBSyxhLlNFUEFSQVRPUixhLlRBQkxFLGEuVElUTEUsYS5MSVNUO3ZhciBQPShlPT4oZS5VTD0idWwiLGUuT0w9Im9sIixlKSkoUHx8e30pLE89KGU9PihlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuQ0hFQ0tCT1g9ImNoZWNrYm94IixlKSkoT3x8e30pLHA9KGU9PihlLkRJU0M9ImRpc2MiLGUuQ0lSQ0xFPSJjaXJjbGUiLGUuU1FVQVJFPSJzcXVhcmUiLGUuREVDSU1BTD0iZGVjaW1hbCIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUpKShwfHx7fSk7Ty5ESVNDKyIiLE8uQ0lSQ0xFKyIiLE8uU1FVQVJFKyIiLE8uQ0hFQ0tCT1grIiIsUC5PTCsiIixQLlVMKyIiLHAuRElTQysiIixwLkNJUkNMRSsiIixwLlNRVUFSRSsiIixwLkRFQ0lNQUwrIiIscC5DSEVDS0JPWCsiIjt2YXIgRT0oZT0+KGUuRklSU1Q9ImZpcnN0IixlLlNFQ09ORD0ic2Vjb25kIixlLlRISVJEPSJ0aGlyZCIsZS5GT1VSVEg9ImZvdXJ0aCIsZS5GSUZUSD0iZmlmdGgiLGUuU0lYVEg9InNpeHRoIixlKSkoRXx8e30pO0UuRklSU1QrIiIsRS5TRUNPTkQrIiIsRS5USElSRCsiIixFLkZPVVJUSCsiIixFLkZJRlRIKyIiLEUuU0lYVEgrIiIsRS5GSVJTVCsiIixFLlNFQ09ORCsiIixFLlRISVJEKyIiLEUuRk9VUlRIKyIiLEUuRklGVEgrIiIsRS5TSVhUSCsiIixFLkZJUlNULEUuU0VDT05ELEUuVEhJUkQsRS5GT1VSVEgsRS5GSUZUSCxFLlNJWFRIO3ZhciBBPShlPT4oZS5QUkVGSVg9InByZWZpeCIsZS5QT1NURklYPSJwb3N0Zml4IixlLlBSRV9URVhUPSJwcmVUZXh0IixlLlBPU1RfVEVYVD0icG9zdFRleHQiLGUuUExBQ0VIT0xERVI9InBsYWNlaG9sZGVyIixlLlZBTFVFPSJ2YWx1ZSIsZS5DSEVDS0JPWD0iY2hlY2tib3giLGUuUkFESU89InJhZGlvIixlKSkoQXx8e30pLEQ9KGU9PihlLkxFRlQ9ImxlZnQiLGUuQ0VOVEVSPSJjZW50ZXIiLGUuUklHSFQ9InJpZ2h0IixlLkFMSUdOTUVOVD0iYWxpZ25tZW50IixlLkpVU1RJRlk9Imp1c3RpZnkiLGUpKShEfHx7fSksTj0oZT0+KGUuQ09OVEFJTj0iY29udGFpbiIsZS5DT1ZFUj0iY292ZXIiLGUpKShOfHx7fSksaz0oZT0+KGUuUkVQRUFUPSJyZXBlYXQiLGUuTk9fUkVQRUFUPSJuby1yZXBlYXQiLGUuUkVQRUFUX1g9InJlcGVhdC14IixlLlJFUEVBVF9ZPSJyZXBlYXQteSIsZSkpKGt8fHt9KTtOLkNPVkVSLGsuTk9fUkVQRUFUO3ZhciBiPShlPT4oZS5UT1A9InRvcCIsZS5NSURETEU9Im1pZGRsZSIsZS5CT1RUT009ImJvdHRvbSIsZSkpKGJ8fHt9KTtiLkJPVFRPTSxSLkhBTEYsUi5IQUxGO2NvbnN0IEs9e1BBR0VfTk86IntwYWdlTm99IixQQUdFX0NPVU5UOiJ7cGFnZUNvdW50fSJ9O0QuQ0VOVEVSLEsuUEFHRV9OTyxnLkFSQUJJQyxiLkJPVFRPTTt2YXIgbT0oZT0+KGUuVEVYVD0idGV4dCIsZS5JTUFHRT0iaW1hZ2UiLGUpKShtfHx7fSk7bS5URVhULGcuQVJBQklDO3ZhciB4PShlPT4oZS5QQUdFPSJwYWdlIixlLkNPTlRJTlVJVFk9ImNvbnRpbnVpdHkiLGUpKSh4fHx7fSk7eC5DT05USU5VSVRZO2Z1bmN0aW9uIE0oZSxuKXtjb25zdCB1PU9iamVjdC5rZXlzKGUpLGY9T2JqZWN0LmtleXMobik7aWYodS5sZW5ndGghPT1mLmxlbmd0aClyZXR1cm4hMTtmb3IobGV0IEk9MDtJPHUubGVuZ3RoO0krKyl7Y29uc3QgbD11W0ldO2lmKGwhPT0idmFsdWUiJiYhKGw9PT0iZ3JvdXBJZHMiJiZBcnJheS5pc0FycmF5KGVbbF0pJiZBcnJheS5pc0FycmF5KG5bbF0pJiZYKGVbbF0sbltsXSkpJiZlW2xdIT09bltsXSlyZXR1cm4hMX1yZXR1cm4hMH1mdW5jdGlvbiBIKGUsbj17fSl7Y29uc3R7ZXh0cmFQaWNrQXR0cnM6dX09bixmPVsuLi5CXTt1JiZmLnB1c2goLi4udSk7Y29uc3QgST17dmFsdWU6ZS52YWx1ZT09PXY/YApgOmUudmFsdWV9O3JldHVybiBmLmZvckVhY2gobD0+e2NvbnN0IEM9ZVtsXTtDIT09dm9pZCAwJiYoSVtsXT1DKX0pLEl9ZnVuY3Rpb24gVChlLG49e30pe2NvbnN0e2V4dHJhUGlja0F0dHJzOnUsaXNDbGFzc2lmeUFyZWE6Zj0hMSxpc0Nsb25lOkk9ITB9PW4sbD1JP1MoZSk6ZSxDPVtdO2xldCBpPTA7Zm9yKDtpPGwubGVuZ3RoOyl7bGV0IHQ9bFtpXTtpZihpPT09MCYmdC52YWx1ZT09PXYmJiF0Lmxpc3RJZCYmKCF0LnR5cGV8fHQudHlwZT09PWEuVEVYVCkpe2krKztjb250aW51ZX1pZih0LmFyZWFJZCl7Y29uc3Qgcj10LmFyZWFJZCxkPXQuYXJlYSxjPVtdO2Zvcig7aTxsLmxlbmd0aDspe2NvbnN0IG89bFtpXTtpZihyIT09by5hcmVhSWQpe2ktLTticmVha31kZWxldGUgby5hcmVhLGRlbGV0ZSBvLmFyZWFJZCxjLnB1c2gobyksaSsrfWNvbnN0IHM9VChjLG4pO2lmKGYpe2NvbnN0IG89e3R5cGU6YS5BUkVBLHZhbHVlOiIiLGFyZWFJZDpyLGFyZWE6ZH07by52YWx1ZUxpc3Q9cyx0PW99ZWxzZXtDLnNwbGljZShpLDAsLi4ucyk7Y29udGludWV9fWVsc2UgaWYodC50aXRsZUlkJiZ0LmxldmVsKXtjb25zdCByPXQudGl0bGVJZDtpZihyKXtjb25zdCBkPXQubGV2ZWwsYz17dHlwZTphLlRJVExFLHRpdGxlOnQudGl0bGUsdGl0bGVJZDpyLHZhbHVlOiIiLGxldmVsOmR9LHM9W107Zm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgbz1sW2ldO2lmKHIhPT1vLnRpdGxlSWQpe2ktLTticmVha31kZWxldGUgby5sZXZlbCxkZWxldGUgby50aXRsZSxzLnB1c2gobyksaSsrfWMudmFsdWVMaXN0PVQocyxuKSx0PWN9fWVsc2UgaWYodC5saXN0SWQmJnQubGlzdFR5cGUpe2NvbnN0IHI9dC5saXN0SWQ7aWYocil7Y29uc3QgZD10Lmxpc3RUeXBlLGM9dC5saXN0U3R5bGUscz17dHlwZTphLkxJU1QsdmFsdWU6IiIsbGlzdElkOnIsbGlzdFR5cGU6ZCxsaXN0U3R5bGU6Y30sbz1bXTtmb3IoO2k8bC5sZW5ndGg7KXtjb25zdCBoPWxbaV07aWYociE9PWgubGlzdElkKXtpLS07YnJlYWt9ZGVsZXRlIGgubGlzdFR5cGUsZGVsZXRlIGgubGlzdFN0eWxlLG8ucHVzaChoKSxpKyt9cy52YWx1ZUxpc3Q9VChvLG4pLHQ9c319ZWxzZSBpZih0LnR5cGU9PT1hLlRBQkxFKXtpZih0LnBhZ2luZ0lkKXtsZXQgcj1pKzEsZD0wO2Zvcig7cjxsLmxlbmd0aDspe2NvbnN0IGM9bFtyXTtpZihjLnBhZ2luZ0lkPT09dC5wYWdpbmdJZCl0LmhlaWdodCs9Yy5oZWlnaHQsdC50ckxpc3QucHVzaCguLi5jLnRyTGlzdCkscisrLGQrKztlbHNlIGJyZWFrfWkrPWR9aWYodC50ckxpc3QpZm9yKGxldCByPTA7cjx0LnRyTGlzdC5sZW5ndGg7cisrKXtjb25zdCBkPXQudHJMaXN0W3JdO2RlbGV0ZSBkLmlkO2ZvcihsZXQgYz0wO2M8ZC50ZExpc3QubGVuZ3RoO2MrKyl7Y29uc3Qgcz1kLnRkTGlzdFtjXSxvPXtjb2xzcGFuOnMuY29sc3Bhbixyb3dzcGFuOnMucm93c3Bhbix2YWx1ZTpUKHMudmFsdWUsey4uLm4saXNDbGFzc2lmeUFyZWE6ITF9KX07VS5mb3JFYWNoKGg9Pntjb25zdCBMPXNbaF07TCE9PXZvaWQgMCYmKG9baF09TCl9KSxkLnRkTGlzdFtjXT1vfX19ZWxzZSBpZih0LnR5cGU9PT1hLkhZUEVSTElOSyl7Y29uc3Qgcj10Lmh5cGVybGlua0lkO2lmKHIpe2NvbnN0IGQ9e3R5cGU6YS5IWVBFUkxJTkssdmFsdWU6IiIsdXJsOnQudXJsfSxjPVtdO2Zvcig7aTxsLmxlbmd0aDspe2NvbnN0IHM9bFtpXTtpZihyIT09cy5oeXBlcmxpbmtJZCl7aS0tO2JyZWFrfWRlbGV0ZSBzLnR5cGUsZGVsZXRlIHMudXJsLGMucHVzaChzKSxpKyt9ZC52YWx1ZUxpc3Q9VChjLG4pLHQ9ZH19ZWxzZSBpZih0LnR5cGU9PT1hLkRBVEUpe2NvbnN0IHI9dC5kYXRlSWQ7aWYocil7Y29uc3QgZD17dHlwZTphLkRBVEUsdmFsdWU6IiIsZGF0ZUZvcm1hdDp0LmRhdGVGb3JtYXR9LGM9W107Zm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgcz1sW2ldO2lmKHIhPT1zLmRhdGVJZCl7aS0tO2JyZWFrfWRlbGV0ZSBzLnR5cGUsZGVsZXRlIHMuZGF0ZUZvcm1hdCxjLnB1c2gocyksaSsrfWQudmFsdWVMaXN0PVQoYyxuKSx0PWR9fWVsc2UgaWYodC5jb250cm9sSWQpe2NvbnN0IHI9dC5jb250cm9sSWQ7aWYodC5jb250cm9sQ29tcG9uZW50PT09QS5QUkVGSVgpe2NvbnN0IGQ9W107bGV0IGM9ITEscz1pO2Zvcig7czxsLmxlbmd0aDspe2NvbnN0IG89bFtzXTtpZihyIT09by5jb250cm9sSWQpYnJlYWs7by5jb250cm9sQ29tcG9uZW50PT09QS5WQUxVRSYmKGRlbGV0ZSBvLmNvbnRyb2wsZGVsZXRlIG8uY29udHJvbElkLGQucHVzaChvKSksby5jb250cm9sQ29tcG9uZW50PT09QS5QT1NURklYJiYoYz0hMCkscysrfWlmKGMpe2NvbnN0IG89eSh0LHcpLGg9ey4uLnQuY29udHJvbCwuLi5vfSxMPXsuLi55KHQsXyksdHlwZTphLkNPTlRST0wsdmFsdWU6IiIsY29udHJvbDpoLGNvbnRyb2xJZDpyfTtMLmNvbnRyb2wudmFsdWU9VChkLG4pLHQ9SChMLHtleHRyYVBpY2tBdHRyczp1fSksaSs9cy1pLTF9fWlmKHQuY29udHJvbENvbXBvbmVudCYmKGRlbGV0ZSB0LmNvbnRyb2wsZGVsZXRlIHQuY29udHJvbElkLHQuY29udHJvbENvbXBvbmVudCE9PUEuVkFMVUUmJnQuY29udHJvbENvbXBvbmVudCE9PUEuUFJFX1RFWFQmJnQuY29udHJvbENvbXBvbmVudCE9PUEuUE9TVF9URVhUKSl7aSsrO2NvbnRpbnVlfX1jb25zdCBGPUgodCx7ZXh0cmFQaWNrQXR0cnM6dX0pO2lmKCF0LnR5cGV8fHQudHlwZT09PWEuVEVYVHx8dC50eXBlPT09YS5TVUJTQ1JJUFR8fHQudHlwZT09PWEuU1VQRVJTQ1JJUFQpZm9yKDtpPGwubGVuZ3RoOyl7Y29uc3Qgcj1sW2krMV07aWYoaSsrLHImJk0oRixIKHIse2V4dHJhUGlja0F0dHJzOnV9KSkpe2NvbnN0IGQ9ci52YWx1ZT09PXY/YApgOnIudmFsdWU7Ri52YWx1ZSs9ZH1lbHNlIGJyZWFrfWVsc2UgaSsrO0MucHVzaChGKX1yZXR1cm4gQ31vbm1lc3NhZ2U9ZT0+e2NvbnN0IG49ZS5kYXRhLHtvcHRpb25zOnUsZGF0YTpmfT1uLHtleHRyYVBpY2tBdHRyczpJPVtdfT11fHx7fSxsPXtoZWFkZXI6VChmLmhlYWRlcix7ZXh0cmFQaWNrQXR0cnM6SSxpc0Nsb25lOiExfSksbWFpbjpUKGYubWFpbix7ZXh0cmFQaWNrQXR0cnM6SSxpc0NsYXNzaWZ5QXJlYTohMCxpc0Nsb25lOiExfSksZm9vdGVyOlQoZi5mb290ZXIse2V4dHJhUGlja0F0dHJzOkksaXNDbG9uZTohMX0pfTtwb3N0TWVzc2FnZShsKX19KSgpOwo=",ai=typeof window!="undefined"&&window.Blob&&new Blob([atob(li)],{type:"text/javascript;charset=utf-8"});function nr(){const s=ai&&(window.URL||window.webkitURL).createObjectURL(ai);try{return s?new Worker(s,{}):new Worker("data:application/javascript;base64,"+li,{type:"module"})}finally{s&&(window.URL||window.webkitURL).revokeObjectURL(s)}}class ir{constructor(t){this.draw=t,this.wordCountWorker=new qs,this.catalogWorker=new tr,this.groupWorker=new er,this.valueWorker=new nr}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=i=>{t(i.data)},this.wordCountWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(n)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=r=>{t(r.data)},this.catalogWorker.onerror=r=>{e(r)};const n=this.draw.getOriginalMainElementList(),i=this.draw.getPosition().getOriginalMainPositionList();this.catalogWorker.postMessage({elementList:n,positionList:i})})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=i=>{t(i.data)},this.groupWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(n)})}getValue(t){return new Promise((e,n)=>{this.valueWorker.onmessage=i=>{e({version:Qe,data:i.data,options:_(this.draw.getOptions())})},this.valueWorker.onerror=i=>{n(i)},this.valueWorker.postMessage({data:this.draw.getOriginValue(t),options:t})})}}var bl="";class cn{constructor(t){this.options=t,this.mask=null,this.container=null,this.inputList=[],this._render()}_render(){var M;const{title:t,data:e,onClose:n,onCancel:i,onConfirm:r}=this.options,o=document.createElement("div");o.classList.add("dialog-mask"),o.setAttribute(Kt,c.EditorComponent.COMPONENT),document.body.append(o);const l=document.createElement("div");l.classList.add("dialog-container"),l.setAttribute(Kt,c.EditorComponent.COMPONENT);const a=document.createElement("div");a.classList.add("dialog"),l.append(a);const R=document.createElement("div");R.classList.add("dialog-title");const d=document.createElement("span");d.append(document.createTextNode(t));const u=document.createElement("i");u.onclick=()=>{n&&n(),this._dispose()},R.append(d),R.append(u),a.append(R);const h=document.createElement("div");h.classList.add("dialog-option");for(let P=0;P<e.length;P++){const O=e[P],X=document.createElement("div");if(X.classList.add("dialog-option__item"),O.label){const f=document.createElement("span");f.append(document.createTextNode(O.label)),X.append(f),O.required&&f.classList.add("dialog-option__item--require")}let I;if(O.type==="select")I=document.createElement("select"),(M=O.options)==null||M.forEach(f=>{const S=document.createElement("option");S.value=f.value,S.label=f.label,I.append(S)});else if(O.type==="textarea")I=document.createElement("textarea");else if(O.type==="color"){I=document.createElement("input"),I.type="text",I.onclick=function(){f.click()};const f=document.querySelector("#color");f.oninput=function(){I.value=f.value}}else I=document.createElement("input"),I.type=O.type;O.width&&(I.style.width=`${O.width}px`),O.height&&(I.style.height=`${O.height}px`),I.name=O.name,I.value=O.value||"",I instanceof HTMLSelectElement||(I.placeholder=O.placeholder||""),X.append(I),h.append(X),this.inputList.push(I)}a.append(h);const g=document.createElement("div");g.classList.add("dialog-menu");const L=document.createElement("button");L.classList.add("dialog-menu__cancel"),L.append(document.createTextNode("\u53D6\u6D88")),L.type="button",L.onclick=()=>{i&&i(),this._dispose()},g.append(L);const T=document.createElement("button");T.append(document.createTextNode("\u786E\u5B9A")),T.type="submit",T.onclick=()=>{if(r){const P=this.inputList.map(O=>({name:O.name,value:O.value}));r(P)}this._dispose()},g.append(T),a.append(g),document.body.append(l),this.container=l,this.mask=o}_dispose(){var t,e;(t=this.mask)==null||t.remove(),(e=this.container)==null||e.remove()}}function dn(s){const t={width:400,height:200,fontFamily:"Simsun",fontSize:20,color:"#ffffff",bold:!1,italic:!1,borderWidth:1,textBgColor:"#000000",borderColor:"#000000",text:"",...s};console.log("config",t);const e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height);let i="";t.bold&&(i+="bold "),t.italic&&(i+="italic ");let r=t.fontSize,o,l;do{const g=`${i}${r}px ${t.fontFamily}`;n.font=g;const L=n.measureText(t.text);if(o=L.width,l=L.actualBoundingBoxAscent+L.actualBoundingBoxDescent,(o>t.width||l>t.height)&&r>1)r--;else break}while(!0);const a=`${i}${r}px ${t.fontFamily}`;n.font=a;const R=n.measureText(t.text);o=R.width,l=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent;const d=(t.width-o)/2-4,u=(t.height-l)/2-4;n.fillStyle=t.textBgColor,n.fillRect(d,u,o+8,l+8),n.fillStyle=t.color,n.textAlign="center",n.textBaseline="middle",n.fillText(t.text,e.width/2,e.height/2);const h=t.borderWidth;return n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(h,h,t.width-h*2,t.height-h*2),e.toDataURL("image/png")}function hn(s){const t={checked:!1,width:100,height:40,label:"",fontSize:14,fontFamily:"SimSun",color:"#000000",borderColor:"#000000",checkColor:"#5175f4",boxSize:20,gap:8,borderWidth:1,...s},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=t.height/2,r=t.gap+t.borderWidth,o=i-t.boxSize/2;if(n.strokeStyle=t.borderColor,n.lineWidth=1.5,n.strokeRect(r,o,t.boxSize,t.boxSize),t.checked){n.fillStyle=t.checkColor,n.fillRect(r+2,o+2,t.boxSize-4,t.boxSize-4),n.beginPath(),n.strokeStyle="#ffffff",n.lineWidth=2,n.lineCap="round",n.lineJoin="round";const l=r+5,a=o+t.boxSize/2+2,R=r+t.boxSize/2-1,d=o+t.boxSize-6,u=r+t.boxSize-4,h=o+6;n.moveTo(l,a),n.lineTo(R,d),n.lineTo(u,h),n.stroke()}if(t.label){n.font=`${t.fontSize}px ${t.fontFamily}`,n.fillStyle=t.color,n.textAlign="left",n.textBaseline="middle";const l=r+t.boxSize+t.gap;n.fillText(t.label,l,i)}return e.toDataURL("image/png")}function un(s){const t={checked:!1,width:100,height:40,label:"",fontSize:14,fontFamily:"SimSun",color:"#000000",borderColor:"#000000",checkColor:"#5175f4",boxSize:20,gap:8,borderWidth:1,...s},e=document.createElement("canvas"),n=e.getContext("2d");e.width=t.width,e.height=t.height,n.clearRect(0,0,e.width,e.height),n.fillStyle="#ffffff",n.fillRect(0,0,e.width,e.height),n.strokeStyle=t.borderColor,n.lineWidth=t.borderWidth,n.strokeRect(t.borderWidth/2,t.borderWidth/2,t.width-t.borderWidth,t.height-t.borderWidth);const i=t.height/2,r=t.gap+t.borderWidth,o=i-t.boxSize/2,l=r+t.boxSize/2,a=o+t.boxSize/2;if(n.strokeStyle=t.borderColor,n.lineWidth=1.5,n.beginPath(),n.arc(l,a,t.boxSize/2,0,Math.PI*2),n.stroke(),t.checked&&(n.fillStyle=t.checkColor,n.beginPath(),n.arc(l,a,t.boxSize/4,0,Math.PI*2),n.fill()),t.label){n.font=`${t.fontSize}px ${t.fontFamily}`,n.fillStyle=t.color,n.textAlign="left",n.textBaseline="middle";const R=r+t.boxSize+t.gap;n.fillText(t.label,R,i)}return e.toDataURL("image/png")}function Ri(s,t){var e,n,i,r,o,l,a,R,d,u,h,g,L,T,M;console.log("el",s),new cn({title:"\u8868\u5355\u590D\u9009\u6846",data:[{type:"select",label:"\u8868\u5355 Key",name:"key",required:!0,value:(n=(e=s==null?void 0:s.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355 Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=s==null?void 0:s.formInput)==null?void 0:i.width)!=null?r:"120"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(o=s==null?void 0:s.formInput)==null?void 0:o.height)!=null?l:"40"},{type:"select",label:"\u9ED8\u8BA4\u9009\u4E2D",name:"checked",required:!0,value:(a=s==null?void 0:s.formInput)!=null&&a.checked?"true":"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"text",label:"\u6807\u7B7E\u6587\u5B57",name:"label",required:!0,value:(d=(R=s==null?void 0:s.formInput)==null?void 0:R.label)!=null?d:"",placeholder:"\u8BF7\u8F93\u5165\u6807\u7B7E\u6587\u5B57"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(h=(u=s==null?void 0:s.formInput)==null?void 0:u.fontSize)!=null?h:"14"},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(L=(g=s==null?void 0:s.formInput)==null?void 0:g.color)!=null?L:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(M=(T=s==null?void 0:s.formInput)==null?void 0:T.fontFamily)!=null?M:"SimSun",options:t.getExtensionParam("fontOptions")==null||t.getExtensionParam("fontOptions")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("formInputKeys")}],onConfirm:P=>{var E,V,Y,K,b,p,H,w;console.log("payload: ",P);const O=(E=P.find(D=>D.name==="key"))==null?void 0:E.value;if(!O)return;const X=(V=P.find(D=>D.name==="width"))==null?void 0:V.value;if(!X)return;const I=(Y=P.find(D=>D.name==="height"))==null?void 0:Y.value;if(!I)return;const f=((K=P.find(D=>D.name==="checked"))==null?void 0:K.value)==="true",S=((b=P.find(D=>D.name==="label"))==null?void 0:b.value)||"",N=(p=P.find(D=>D.name==="fontSize"))==null?void 0:p.value,m=(H=P.find(D=>D.name==="color"))==null?void 0:H.value,W=(w=P.find(D=>D.name==="fontFamily"))==null?void 0:w.value,U={key:O,width:X,height:I,checked:f,label:S,fontSize:N,fontFamily:W,color:m,type:"checkbox"},F={value:hn({checked:f,label:S,width:Number(X),height:Number(I),fontSize:Number(N),fontFamily:W,color:m}),type:c.ElementType.IMAGE,formInput:U,width:Number(X),height:Number(I)};if(s!=null&&s.id){const D={id:s.id,properties:F};console.log("deleteOpt12",D),t.command.executeUpdateElementById(D);return}t.command.executeInsertElementList([F])}})}function ci(s,t){var e,n,i,r,o,l,a,R,d,u,h,g,L,T,M;console.log("el",s),new cn({title:"\u8868\u5355\u5355\u9009\u6846",data:[{type:"text",label:"\u8868\u5355 Key",name:"key",required:!0,value:(n=(e=s==null?void 0:s.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355 Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6 (px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=s==null?void 0:s.formInput)==null?void 0:i.width)!=null?r:"120"},{type:"number",label:"\u9AD8\u5EA6 (px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(o=s==null?void 0:s.formInput)==null?void 0:o.height)!=null?l:"40"},{type:"select",label:"\u9ED8\u8BA4\u9009\u4E2D",name:"checked",required:!0,value:(a=s==null?void 0:s.formInput)!=null&&a.checked?"true":"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"text",label:"\u6807\u7B7E\u6587\u5B57",name:"label",required:!0,value:(d=(R=s==null?void 0:s.formInput)==null?void 0:R.label)!=null?d:"",placeholder:"\u8BF7\u8F93\u5165\u6807\u7B7E\u6587\u5B57"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(h=(u=s==null?void 0:s.formInput)==null?void 0:u.fontSize)!=null?h:"14"},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(L=(g=s==null?void 0:s.formInput)==null?void 0:g.color)!=null?L:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(M=(T=s==null?void 0:s.formInput)==null?void 0:T.fontFamily)!=null?M:"SimSun",options:t.getExtensionParam("fontOptions")==null||t.getExtensionParam("fontOptions")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("formInputKeys")}],onConfirm:P=>{var E,V,Y,K,b,p,H,w;console.log("payload: ",P);const O=(E=P.find(D=>D.name==="key"))==null?void 0:E.value;if(!O)return;const X=(V=P.find(D=>D.name==="width"))==null?void 0:V.value;if(!X)return;const I=(Y=P.find(D=>D.name==="height"))==null?void 0:Y.value;if(!I)return;const f=((K=P.find(D=>D.name==="checked"))==null?void 0:K.value)==="true",S=((b=P.find(D=>D.name==="label"))==null?void 0:b.value)||"",N=(p=P.find(D=>D.name==="fontSize"))==null?void 0:p.value,m=(H=P.find(D=>D.name==="color"))==null?void 0:H.value,W=(w=P.find(D=>D.name==="fontFamily"))==null?void 0:w.value,U={key:O,width:X,height:I,checked:f,label:S,fontSize:N,fontFamily:W,color:m,type:"radio"},F={value:un({checked:f,label:S,width:Number(X),height:Number(I),fontSize:Number(N),fontFamily:W,color:m}),type:c.ElementType.IMAGE,formInput:U,width:Number(X),height:Number(I)};if(s!=null&&s.id){const D={id:s.id,properties:F};console.log("deleteOpt12",D),t.command.executeUpdateElementById(D);return}t.command.executeInsertElementList([F])}})}function di(s,t){var e,n,i,r,o,l,a,R,d,u,h,g,L,T,M,P;console.log("el",s),new cn({title:"\u8868\u5355\u6587\u672C\u6846",data:[{type:"select",label:"\u8868\u5355Key",name:"key",required:!0,value:(n=(e=s==null?void 0:s.formInput)==null?void 0:e.key)!=null?n:"",placeholder:"\u8BF7\u8F93\u5165\u8868\u5355Key",options:t.getExtensionParam("formInputKeys")==null||t.getExtensionParam("formInputKeys")==null?[]:t.getExtensionParam("formInputKeys")},{type:"number",label:"\u5BBD\u5EA6(px)",name:"width",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5BBD\u5EA6",value:(r=(i=s==null?void 0:s.formInput)==null?void 0:i.width)!=null?r:"100"},{type:"number",label:"\u9AD8\u5EA6(px)",name:"height",required:!0,placeholder:"\u8BF7\u8F93\u5165\u9AD8\u5EA6",value:(l=(o=s==null?void 0:s.formInput)==null?void 0:o.height)!=null?l:"50"},{type:"number",label:"\u5B57\u53F7",name:"fontSize",required:!0,placeholder:"\u8BF7\u8F93\u5165\u5B57\u53F7",value:(R=(a=s==null?void 0:s.formInput)==null?void 0:a.fontSize)!=null?R:"10"},{type:"select",label:"\u662F\u5426\u52A0\u7C97",name:"bold",required:!0,value:(d=s==null?void 0:s.formInput)!=null&&d.bold?String((u=s==null?void 0:s.formInput)==null?void 0:u.bold):"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"select",label:"\u662F\u5426\u659C\u4F53",name:"italic",required:!0,value:(h=s==null?void 0:s.formInput)!=null&&h.italic?String((g=s==null?void 0:s.formInput)==null?void 0:g.italic):"false",options:[{label:"\u662F",value:"true"},{label:"\u5426",value:"false"}]},{type:"color",label:"\u5B57\u4F53\u989C\u8272",name:"color",required:!0,value:(T=(L=s==null?void 0:s.formInput)==null?void 0:L.color)!=null?T:"#000000"},{type:"select",label:"\u5B57\u4F53\u6837\u5F0F",name:"fontFamily",required:!0,value:(P=(M=s==null?void 0:s.formInput)==null?void 0:M.fontFamily)!=null?P:"SimSun",options:t.getExtensionParam("fontOptions")==null||t.getExtensionParam("fontOptions")==null?[{label:"SimSun",value:"SimSun"}]:t.getExtensionParam("formInputKeys")}],onConfirm:O=>{var V,Y,K,b,p,H,w,D;console.log("payload: ",O);const X=(V=O.find(J=>J.name==="key"))==null?void 0:V.value;if(!X)return;const I=(Y=O.find(J=>J.name==="width"))==null?void 0:Y.value;if(!I)return;const f=(K=O.find(J=>J.name==="height"))==null?void 0:K.value;if(!f)return;const S=(b=O.find(J=>J.name==="fontSize"))==null?void 0:b.value,N=((p=O.find(J=>J.name==="bold"))==null?void 0:p.value)==="true",m=((H=O.find(J=>J.name==="italic"))==null?void 0:H.value)==="true",W=(w=O.find(J=>J.name==="color"))==null?void 0:w.value,Z=(D=O.find(J=>J.name==="fontFamily"))==null?void 0:D.value,Q={key:X,width:I,height:f,fontSize:S,bold:N,italic:m,color:W,fontFamily:Z,type:"input"},E={value:dn({text:X,width:I,height:f}),type:c.ElementType.IMAGE,formInput:Q,width:Number(I),height:Number(f)};if(s!=null&&s.id){const J={id:s.id,properties:E};console.log("deleteOpt12",J),t.command.executeUpdateElementById(J);return}t.command.executeInsertElementList([E])}})}class or{constructor(t){this._keydown=()=>{this.resizerSelection.style.display==="block"&&(this.clearResizer(),document.removeEventListener("keydown",this._keydown))},this.container=t.getContainer(),this.canvas=t.getPage(),this.draw=t,this.options=t.getOptions(),this.curElement=null,this.curElementSrc="",this.previewerDrawOption={},this.curPosition=null,this.eventBus=t.getEventBus(),this.imageList=[],this.curShowElement=null,this.imageCount=null,this.imagePre=null,this.imageNext=null;const{resizerSelection:e,resizerHandleList:n,resizerImageContainer:i,resizerImage:r,resizerSize:o}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=n,this.resizerImageContainer=i,this.resizerImage=r,this.resizerSize=o,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.previewerContainer=null,this.previewerImage=null}_getElementPosition(t,e=null){var d;const{scale:n}=this.options;let i=0,r=0;const o=this.draw.getHeight(),l=this.draw.getPageGap(),R=((d=e==null?void 0:e.pageNo)!=null?d:this.draw.getPageNo())*(o+l);if(t.imgFloatPosition)i=t.imgFloatPosition.x*n,r=t.imgFloatPosition.y*n+R;else if(e){const{coordinate:{leftTop:[u,h]},ascent:g}=e;i=u,r=h+R+g}return{x:i,y:r}}_createResizerDom(){const{scale:t}=this.options,e=document.createElement("div");e.classList.add(`${x}-resizer-selection`),e.style.display="none",e.style.borderColor=this.options.resizerColor,e.style.borderWidth=`${t}px`;const n=[];for(let a=0;a<8;a++){const R=document.createElement("div");R.style.background=this.options.resizerColor,R.classList.add("resizer-handle"),R.classList.add(`handle-${a}`),R.setAttribute("data-index",String(a)),R.onmousedown=this._mousedown.bind(this),e.append(R),n.push(R)}this.container.append(e);const i=document.createElement("div");i.classList.add(`${x}-resizer-size-view`);const r=document.createElement("span");i.append(r),e.append(i);const o=document.createElement("div");o.classList.add(`${x}-resizer-image`),o.style.display="none";const l=document.createElement("img");return o.append(l),this.container.append(o),{resizerSelection:e,resizerHandleList:n,resizerImageContainer:o,resizerImage:l,resizerSize:r}}_mousedown(t){if(this.canvas=this.draw.getPage(),!this.curElement)return;const{scale:e}=this.options;this.mousedownX=t.x,this.mousedownY=t.y;const n=t.target;this.curHandleIndex=Number(n.dataset.index);const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,this.canvas.style.cursor=i,this.curElement.formInput&&(console.log("this.curElement.formInput",this.curElement.formInput),console.log("this.curElement.formInput.type",this.curElement.formInput.type),this.curElement.formInput.width=`${this.curElement.width*e}`,this.curElement.formInput.height=`${this.curElement.height*e}`,this.curElement.formInput.type=="checkbox"?this.curElementSrc=hn(this.curElement.formInput):this.curElement.formInput.type=="radio"?this.curElementSrc=un(this.curElement.formInput):this.curElementSrc=dn({text:this.curElement.formInput.key,width:this.curElement.formInput.width,height:this.curElement.formInput.height})),console.log(this.curElement),this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{x:r,y:o}=this._getElementPosition(this.curElement,this.curPosition);this.resizerImageContainer.style.left=`${r}px`,this.resizerImageContainer.style.top=`${o}px`,this.resizerImage.style.width=`${this.curElement.width*e}px`,this.resizerImage.style.height=`${this.curElement.height*e}px`;const l=this._mousemove.bind(this);document.addEventListener("mousemove",l),document.addEventListener("mouseup",()=>{var a;this.curElement&&!this.previewerDrawOption.dragDisable&&(this.curElement.width=this.width,this.curElement.height=this.height,this.curElement.formInput&&(this.curElement.formInput.width=`${this.width}`,this.curElement.formInput.height=`${this.height}`,this.curElement.formInput.type=="checkbox"?this.curElementSrc=hn(this.curElement.formInput):this.curElement.formInput.type=="radio"?this.curElementSrc=un(this.curElement.formInput):this.curElementSrc=dn({text:this.curElement.formInput.key,width:this.curElement.formInput.width,height:this.curElement.formInput.height}),this.curElement.value=this.curElementSrc),console.log("this.draw.render"),this.draw.render({isSetCursor:!0,curIndex:(a=this.curPosition)==null?void 0:a.index})),this.resizerImageContainer.style.display="none",document.removeEventListener("mousemove",l),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.curElement||this.previewerDrawOption.dragDisable)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const R=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 1:i=this.mousedownY-t.y;break;case 2:{const R=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 4:{const R=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const R=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.curElement.height*n/this.curElement.width}break;case 7:n=this.mousedownX-t.x;break}const r=this.curElement.width+n/e,o=this.curElement.height+i/e;if(r<=0||o<=0)return;this.width=r,this.height=o;const l=r*e,a=o*e;this.resizerImage.style.width=`${l}px`,this.resizerImage.style.height=`${a}px`,this._updateResizerRect(l,a),this._updateResizerSizeView(l,a),t.preventDefault(),this.eventBus.isSubscribe("imageSizeChange")&&this.eventBus.emit("imageSizeChange",{element:this.curElement})}_drawPreviewer(){const t=document.createElement("div");t.classList.add(`${x}-image-previewer`);const e=document.createElement("i");e.classList.add("image-close"),e.onclick=()=>{this._clearPreviewer()},t.append(e);const n=document.createElement("div");n.classList.add(`${x}-image-container`);const i=document.createElement("img");i.src=this.curElementSrc,i.draggable=!1,n.append(i),this.previewerImage=i,t.append(n);let r=0,o=0,l=1,a=0;const R=document.createElement("div");R.classList.add(`${x}-image-menu`);const d=document.createElement("div");d.classList.add("image-navigate");const u=document.createElement("i");u.classList.add("image-pre"),u.onclick=()=>{const S=this.imageList.findIndex(N=>{var m;return N.id===((m=this.curShowElement)==null?void 0:m.id)});S<=0||(this.curShowElement=this.imageList[S-1],i.src=this.curShowElement.value,this._updateImageNavigate())},d.append(u),this.imagePre=u;const h=document.createElement("span");h.classList.add("image-count"),this.imageCount=h,d.append(h);const g=document.createElement("i");g.classList.add("image-next"),g.onclick=()=>{const S=this.imageList.findIndex(N=>{var m;return N.id===((m=this.curShowElement)==null?void 0:m.id)});S>=this.imageList.length-1||(this.curShowElement=this.imageList[S+1],i.src=this.curShowElement.value,this._updateImageNavigate())},this.imageNext=g,d.append(g),R.append(d);const L=document.createElement("i");L.classList.add("zoom-in"),L.onclick=()=>{l+=.1,this._setPreviewerTransform(l,a,r,o)},R.append(L);const T=document.createElement("i");T.onclick=()=>{l-.1<=.1||(l-=.1,this._setPreviewerTransform(l,a,r,o))},T.classList.add("zoom-out"),R.append(T);const M=document.createElement("i");M.classList.add("rotate"),M.onclick=()=>{a+=1,this._setPreviewerTransform(l,a,r,o)},R.append(M);const P=document.createElement("i");P.classList.add("original-size"),P.onclick=()=>{r=0,o=0,l=1,a=0,this._setPreviewerTransform(l,a,r,o)},R.append(P);const O=document.createElement("i");O.classList.add("image-download"),O.onclick=()=>{var N;const{mime:S}=this.previewerDrawOption;In(i.src,`${(N=this.curElement)==null?void 0:N.id}.${S||"png"}`)},R.append(O),t.append(R),this.previewerContainer=t,document.body.append(t);let X=0,I=0,f=!1;i.onmousedown=S=>{f=!0,X=S.x,I=S.y,t.style.cursor="move"},t.onmousemove=S=>{!f||(r+=S.x-X,o+=S.y-I,X=S.x,I=S.y,this._setPreviewerTransform(l,a,r,o))},t.onmouseup=()=>{f=!1,t.style.cursor="auto"},t.onwheel=S=>{if(S.preventDefault(),S.stopPropagation(),S.deltaY<0)l+=.1;else{if(l-.1<=.1)return;l-=.1}this._setPreviewerTransform(l,a,r,o)},this._updateImageNavigate()}_updateImageNavigate(){const t=this.imageList.findIndex(e=>{var n;return e.id===((n=this.curShowElement)==null?void 0:n.id)});this.imageCount.innerText=`${t+1} / ${this.imageList.length}`,t<=0?this.imagePre.classList.add("disabled"):this.imagePre.classList.remove("disabled"),t>=this.imageList.length-1?this.imageNext.classList.add("disabled"):this.imageNext.classList.remove("disabled")}_setPreviewerTransform(t,e,n,i){!this.previewerImage||(this.previewerImage.style.left=`${n}px`,this.previewerImage.style.top=`${i}px`,this.previewerImage.style.transform=`scale(${t}) rotate(${e*90}deg)`)}_clearPreviewer(){var t;(t=this.previewerContainer)==null||t.remove(),this.previewerContainer=null,document.body.style.overflow="auto"}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options,r=this.draw.isReadonly();this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let o=0;o<8;o++){const l=o===0||o===6||o===7?-n:o===1||o===5?t/2:t-n,a=o===0||o===1||o===2?-n:o===3||o===7?e/2-n:e-n;this.resizerHandleList[o].style.transform=`scale(${i})`,this.resizerHandleList[o].style.left=`${l}px`,this.resizerHandleList[o].style.top=`${a}px`,this.resizerHandleList[o].style.display=r?"none":"block"}}_updateResizerSizeView(t,e){this.resizerSize.innerText=`${Math.round(t)} \xD7 ${Math.round(e)}`}render(){var e,n;const t=this.draw.getMode();!this.curElement||this.curElement.imgToolDisabled&&!this.draw.isDesignMode()||t===c.EditorMode.PRINT&&((e=this.options.modeRule[c.EditorMode.PRINT])==null?void 0:e.imagePreviewerDisabled)||t===c.EditorMode.READONLY&&((n=this.options.modeRule[c.EditorMode.READONLY])==null?void 0:n.imagePreviewerDisabled)||(this.imageList=this.draw.getImageParticle().getOriginalMainImageList(),this.curShowElement=this.curElement,this._drawPreviewer(),document.body.style.overflow="hidden")}drawResizer(t,e=null,n={}){var r,o;const i=this.draw.getMode();t.imgToolDisabled&&!this.draw.isDesignMode()||i===c.EditorMode.PRINT&&((r=this.options.modeRule[c.EditorMode.PRINT])==null?void 0:r.imagePreviewerDisabled)||i===c.EditorMode.READONLY&&((o=this.options.modeRule[c.EditorMode.READONLY])==null?void 0:o.imagePreviewerDisabled)||(this.previewerDrawOption=n,this.curElementSrc=t[n.srcKey||"value"]||"",this.updateResizer(t,e),document.addEventListener("keydown",this._keydown))}updateResizer(t,e=null){console.log(t);const{scale:n}=this.options,i=t.width*n,r=t.height*n;this._updateResizerSizeView(i,r);const{x:o,y:l}=this._getElementPosition(t,e);this.resizerSelection.style.left=`${o}px`,this.resizerSelection.style.top=`${l}px`,this.resizerSelection.style.borderWidth=`${n}px`,this._updateResizerRect(i,r),this.resizerSelection.style.display="block",this.curElement=t,this.curPosition=e,this.width=i,this.height=r}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}class sr{constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.datePicker=new ti(t,{onSubmit:this._setValue.bind(this)})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[n,i]=e,r=this.draw.getElementList(),o=r[n+1];this.draw.spliceElementList(r,n+1,i-n),this.range.setRange(n,n);const l={type:c.ElementType.DATE,value:"",dateFormat:o.dateFormat,valueList:[{value:t}]};Ot(r,[l],n,{editorOptions:this.options}),this.draw.insertElementList([l])}getDateElementRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const r=this.draw.getElementList(),o=r[n];if(o.type!==c.ElementType.DATE)return null;let l=n;for(;l>=0;){if(r[l].dateId!==o.dateId){t=l;break}l--}let a=n+1;for(;a<r.length;){if(r[a].dateId!==o.dateId){e=a-1;break}a++}return a===r.length&&(e=a-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const n=this.draw.getElementList(),i=this.getDateElementRange(),r=i?n.slice(i[0]+1,i[1]+1).map(o=>o.value).join(""):"";this.datePicker.render({value:r,position:e,dateFormat:t.dateFormat})}}class hi{constructor(t){this.element=t,this.videoCache=new Map}snapshot(t,e,n){return new Promise((i,r)=>{var l,a;const o=((a=(l=this.element.block)==null?void 0:l.videoBlock)==null?void 0:a.src)||"";if(this.videoCache.has(o)){const R=this.videoCache.get(o);t.drawImage(R,e,n,this.element.metrics.width,this.element.metrics.height),i(this.element)}else{const R=document.createElement("video");R.src=o,R.muted=!0,R.crossOrigin="anonymous",R.onloadeddata=()=>{t.drawImage(R,e,n,this.element.metrics.width,this.element.metrics.height),this.videoCache.set(o,R),i(this.element)},R.onerror=d=>{r(d)},R.play().then(()=>{R.pause()})}})}render(t){var i;const e=this.element.block,n=document.createElement("video");n.style.width="100%",n.style.height="100%",n.style.objectFit="contain",n.src=((i=e.videoBlock)==null?void 0:i.src)||"",n.controls=!0,t.append(n)}}class rr{constructor(t,e){this.draw=t.getDraw(),this.options=this.draw.getOptions(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null;const{blockItem:n,resizerMask:i,resizerSelection:r,resizerHandleList:o}=this._createBlockItem();this.blockItem=n,this.blockContainer.append(this.blockItem),this.blockCache=new Map,this.resizerMask=i,this.resizerSelection=r,this.resizerHandleList=o,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.isAllowResize=!1}getBlockElement(){return this.element}getBlockWidth(){return this.element.width||this.element.metrics.width}_createBlockItem(){const{scale:t,resizerColor:e}=this.options,n=document.createElement("div");n.classList.add(`${x}-block-item`);const i=document.createElement("div");i.style.display="none",i.classList.add(`${x}-resizer-selection`),i.style.borderColor=e,i.style.borderWidth=`${t}px`;const r=[];for(let l=0;l<8;l++){const a=document.createElement("div");a.style.background=e,a.classList.add("resizer-handle"),a.classList.add(`handle-${l}`),a.setAttribute("data-index",String(l)),a.onmousedown=this._mousedown.bind(this),i.append(a),r.push(a)}const o=document.createElement("div");return o.classList.add(`${x}-resizer-mask`),o.style.display="none",n.append(o),n.onmouseenter=()=>{if(this.draw.isReadonly())return;const{width:a,height:R}=this.element.metrics;this._updateResizerRect(a,R),i.style.display="block"},n.onmouseleave=()=>{this.isAllowResize||(i.style.display="none")},n.append(i),{blockItem:n,resizerMask:o,resizerSelection:i,resizerHandleList:r}}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options;this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let r=0;r<8;r++){const o=r===0||r===6||r===7?-n:r===1||r===5?t/2:t-n,l=r===0||r===1||r===2?-n:r===3||r===7?e/2-n:e-n;this.resizerHandleList[r].style.transform=`scale(${i})`,this.resizerHandleList[r].style.left=`${o}px`,this.resizerHandleList[r].style.top=`${l}px`}}_mousedown(t){const e=this.draw.getPage();this.mousedownX=t.x,this.mousedownY=t.y,this.isAllowResize=!0;const n=t.target;this.curHandleIndex=Number(n.dataset.index),this.resizerMask.style.display="block";const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,e.style.cursor=i;const r=this._mousemove.bind(this);document.addEventListener("mousemove",r),document.addEventListener("mouseup",()=>{this.element.width=Math.min(this.width,this.draw.getInnerWidth()),this.element.height=this.height,this.isAllowResize=!1,this.resizerSelection.style.display="none",this.resizerMask.style.display="none",document.removeEventListener("mousemove",r),document.body.style.cursor="",e.style.cursor="text",this.draw.render()},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.isAllowResize)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const R=this.mousedownX-t.x,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 1:i=this.mousedownY-t.y;break;case 2:{const R=t.x-this.mousedownX,d=this.mousedownY-t.y;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 4:{const R=t.x-this.mousedownX,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const R=this.mousedownX-t.x,d=t.y-this.mousedownY;n=Math.cbrt(R**3+d**3),i=this.element.height*n/this.getBlockWidth()}break;case 7:n=this.mousedownX-t.x;break}const r=this.getBlockWidth()+n/e,o=this.element.height+i/e;if(r<=0||o<=0)return;this.width=r,this.height=o;const l=r*e,a=o*e;this._updateResizerRect(l,a),this.blockItem.style.width=`${l}px`,this.blockItem.style.height=`${a}px`,t.preventDefault()}snapshot(t,e,n){if(this.element.block.type===c.BlockType.VIDEO)if(this.blockItem.style.display="none",this.blockCache.has(this.element.id))this.blockCache.get(this.element.id).snapshot(t,e,n);else{this.block=new hi(this.element);const r=this.block.snapshot(t,e,n);this.draw.getImageObserver().add(r),this.blockCache.set(this.element.id,this.block)}}render(){const t=this.element.block;t.type===c.BlockType.IFRAME?(this.block=new he(this.element),this.block.render(this.blockItem)):t.type===c.BlockType.VIDEO&&(this.block=new hi(this.element),this.block.render(this.blockItem))}setClientRects(t,e,n){const i=this.draw.getHeight(),r=this.draw.getPageGap(),o=t*(i+r),{metrics:l}=this.element;this.blockItem.style.display="block",this.blockItem.style.width=`${l.width}px`,this.blockItem.style.height=`${l.height}px`,this.blockItem.style.left=`${e}px`,this.blockItem.style.top=`${o+n}px`}remove(){this.blockItem.remove()}}class lr{constructor(t){this.draw=t,this.container=t.getContainer(),this.blockMap=new Map,this.blockContainer=this._createBlockContainer(),this.container.append(this.blockContainer)}_createBlockContainer(){const t=document.createElement("div");return t.classList.add(`${x}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,n,i,r){const o=n.id;let l=this.blockMap.get(o);l||(l=new rr(this,n),l.render(),this.blockMap.set(o,l)),this.draw.isPrintMode()?l.snapshot(t,i,r):l.setClientRects(e,i,r)}clear(){if(!this.blockMap.size)return;const t=this.draw.getOriginalMainElementList(),e=[];for(let n=0;n<t.length;n++){const i=t[n];i.type===c.ElementType.BLOCK&&e.push(i.id)}this.blockMap.forEach(n=>{const i=n.getBlockElement().id;e.includes(i)||(n.remove(),this.blockMap.delete(i))})}}var gn={contextmenu:{global:{cut:"\u526A\u5207",copy:"\u590D\u5236",paste:"\u7C98\u8D34",selectAll:"\u5168\u9009",print:"\u6253\u5370"},control:{delete:"\u5220\u9664\u63A7\u4EF6"},hyperlink:{delete:"\u5220\u9664\u94FE\u63A5",cancel:"\u53D6\u6D88\u94FE\u63A5",edit:"\u7F16\u8F91\u94FE\u63A5"},image:{change:"\u66F4\u6539\u56FE\u7247",saveAs:"\u53E6\u5B58\u4E3A\u56FE\u7247",textWrap:"\u6587\u5B57\u73AF\u7ED5",textWrapType:{embed:"\u5D4C\u5165\u578B",upDown:"\u4E0A\u4E0B\u578B\u73AF\u7ED5",surround:"\u56DB\u5468\u578B\u73AF\u7ED5",floatTop:"\u6D6E\u4E8E\u6587\u5B57\u4E0A\u65B9",floatBottom:"\u886C\u4E8E\u6587\u5B57\u4E0B\u65B9"}},table:{insertRowCol:"\u63D2\u5165\u884C\u5217",insertTopRow:"\u4E0A\u65B9\u63D2\u51651\u884C",insertBottomRow:"\u4E0B\u65B9\u63D2\u51651\u884C",insertLeftCol:"\u5DE6\u4FA7\u63D2\u51651\u5217",insertRightCol:"\u53F3\u4FA7\u63D2\u51651\u5217",deleteRowCol:"\u5220\u9664\u884C\u5217",deleteRow:"\u5220\u96641\u884C",deleteCol:"\u5220\u96641\u5217",deleteTable:"\u5220\u9664\u6574\u4E2A\u8868\u683C",mergeCell:"\u5408\u5E76\u5355\u5143\u683C",mergeCancelCell:"\u53D6\u6D88\u5408\u5E76",verticalAlign:"\u5782\u76F4\u5BF9\u9F50",verticalAlignTop:"\u9876\u7AEF\u5BF9\u9F50",verticalAlignMiddle:"\u5782\u76F4\u5C45\u4E2D",verticalAlignBottom:"\u5E95\u7AEF\u5BF9\u9F50",border:"\u8868\u683C\u8FB9\u6846",borderAll:"\u6240\u6709\u6846\u7EBF",borderEmpty:"\u65E0\u6846\u7EBF",borderDash:"\u865A\u6846\u7EBF",borderExternal:"\u5916\u4FA7\u6846\u7EBF",borderInternal:"\u5185\u4FA7\u6846\u7EBF",borderTd:"\u5355\u5143\u683C\u8FB9\u6846",borderTdTop:"\u4E0A\u8FB9\u6846",borderTdRight:"\u53F3\u8FB9\u6846",borderTdBottom:"\u4E0B\u8FB9\u6846",borderTdLeft:"\u5DE6\u8FB9\u6846",borderTdForward:"\u6B63\u659C\u7EBF",borderTdBack:"\u53CD\u659C\u7EBF"}},datePicker:{now:"\u6B64\u523B",confirm:"\u786E\u5B9A",return:"\u8FD4\u56DE\u65E5\u671F",timeSelect:"\u65F6\u95F4\u9009\u62E9",weeks:{sun:"\u65E5",mon:"\u4E00",tue:"\u4E8C",wed:"\u4E09",thu:"\u56DB",fri:"\u4E94",sat:"\u516D"},year:"\u5E74",month:"\u6708",hour:"\u65F6",minute:"\u5206",second:"\u79D2"},frame:{header:"\u9875\u7709",footer:"\u9875\u811A"},pageBreak:{displayName:"\u5206\u9875\u7B26"},zone:{headerTip:"\u53CC\u51FB\u7F16\u8F91\u9875\u7709",footerTip:"\u53CC\u51FB\u7F16\u8F91\u9875\u811A"}},ar={contextmenu:{global:{cut:"Cut",copy:"Copy",paste:"Paste",selectAll:"Select all",print:"Print"},control:{delete:"Delete control"},hyperlink:{delete:"Delete hyperlink",cancel:"Cancel hyperlink",edit:"Edit hyperlink"},image:{change:"Change image",saveAs:"Save as image",textWrap:"Text wrap",textWrapType:{embed:"Embed",upDown:"Up down",surround:"Surround",floatTop:"Float above text",floatBottom:"Float below text"}},table:{insertRowCol:"Insert row col",insertTopRow:"Insert top 1 row",insertBottomRow:"Insert bottom 1 row",insertLeftCol:"Insert left 1 col",insertRightCol:"Insert right 1 col",deleteRowCol:"Delete row col",deleteRow:"Delete 1 row",deleteCol:"Delete 1 col",deleteTable:"Delete table",mergeCell:"Merge cell",mergeCancelCell:"Cancel merge cell",verticalAlign:"Vertical align",verticalAlignTop:"Top",verticalAlignMiddle:"Middle",verticalAlignBottom:"Bottom",border:"Table border",borderAll:"All",borderEmpty:"Empty",borderDash:"Dash",borderExternal:"External",borderInternal:"Internal",borderTd:"Table cell border",borderTdTop:"Top",borderTdRight:"Right",borderTdBottom:"Bottom",borderTdLeft:"Left",borderTdForward:"Forward",borderTdBack:"Back"}},datePicker:{now:"Now",confirm:"Confirm",return:"Return",timeSelect:"Time select",weeks:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},year:" ",month:" ",hour:"Hour",minute:"Minute",second:"Second"},frame:{header:"Header",footer:"Footer"},pageBreak:{displayName:"Page Break"},zone:{headerTip:"Double click to edit header",footerTip:"Double click to edit footer"}};class Rr{constructor(t){this.langMap=new Map([["zhCN",gn],["en",ar]]),this.currentLocale=t}registerLangMap(t,e){const n=this.langMap.get(t);this.langMap.set(t,Nn(n||gn,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||gn}t(t){const e=t.split(".");let n="",i=this.getLang();for(let r=0;r<e.length;r++){const o=e[r],l=Reflect.get(i,o);if(l)n=i=l;else return""}return n}}class cr{constructor(){this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class dr{constructor(t,e){this.draw=t,this.zone=e,this.i18n=t.getI18n(),this.container=t.getContainer(),this.pageContainer=t.getPageContainer();const{tipContainer:n,tipContent:i}=this._drawZoneTip();this.tipContainer=n,this.tipContent=i,this.isDisableMouseMove=!0,this.currentMoveZone=c.EditorZone.MAIN;const r=[],{header:o,footer:l}=t.getOptions();o.disabled||r.push(c.EditorZone.HEADER),l.disabled||r.push(c.EditorZone.FOOTER),r.length&&this._watchMouseMoveZoneChange(r)}_watchMouseMoveZoneChange(t){this.pageContainer.addEventListener("mousemove",Ci(e=>{if(!(this.isDisableMouseMove||!this.draw.getIsPagingMode())&&!!e.offsetY)if(e.target instanceof HTMLCanvasElement){const n=this.zone.getZoneByY(e.offsetY);if(!t.includes(n)){this._updateZoneTip(!1);return}this.currentMoveZone=n,this._updateZoneTip(this.zone.getZone()===c.EditorZone.MAIN&&(n===c.EditorZone.HEADER||n===c.EditorZone.FOOTER),e.x,e.y)}else this._updateZoneTip(!1)},250)),this.pageContainer.addEventListener("mouseenter",()=>{this.isDisableMouseMove=!1}),this.pageContainer.addEventListener("mouseleave",()=>{this.isDisableMouseMove=!0,this._updateZoneTip(!1)})}_drawZoneTip(){const t=document.createElement("div");t.classList.add(`${x}-zone-tip`);const e=document.createElement("span");return t.append(e),this.container.append(t),{tipContainer:t,tipContent:e}}_updateZoneTip(t,e,n){t?(this.tipContainer.classList.add("show"),this.tipContainer.style.left=`${e}px`,this.tipContainer.style.top=`${n}px`,this.tipContent.innerText=this.i18n.t(`zone.${this.currentMoveZone===c.EditorZone.HEADER?"headerTip":"footerTip"}`)):this.tipContainer.classList.remove("show")}}class hr{constructor(t){this.INDICATOR_PADDING=2,this.INDICATOR_TITLE_TRANSLATE=[20,5],this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=c.EditorZone.MAIN,this.indicatorContainer=null,this.options.zone.tipDisabled||new dr(t,this)}isHeaderActive(){return this.getZone()===c.EditorZone.HEADER}isMainActive(){return this.getZone()===c.EditorZone.MAIN}isFooterActive(){return this.getZone()===c.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){const{header:e,footer:n}=this.options;!e.editable&&t===c.EditorZone.HEADER||!n.editable&&t===c.EditorZone.FOOTER||this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),Ge(()=>{const i=this.draw.getListener();i.zoneChange&&i.zoneChange(t);const r=this.draw.getEventBus();r.isSubscribe("zoneChange")&&r.emit("zoneChange",t)}))}getZoneByY(t){const e=this.draw.getHeader(),n=e.getHeaderTop()+e.getHeight(),i=this.draw.getFooter(),o=this.draw.getHeight()-(i.getFooterBottom()+i.getHeight());return t<n?c.EditorZone.HEADER:t>o?c.EditorZone.FOOTER:c.EditorZone.MAIN}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[n,i]=this.INDICATOR_TITLE_TRANSLATE,r=this.draw.getPageList(),o=this.draw.getMargins(),l=this.draw.getInnerWidth(),a=this.draw.getHeight(),R=this.draw.getPageGap(),d=a+R;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${x}-zone-indicator`);const u=this.draw.getHeader(),h=this.draw.getFooter(),g=e?u.getHeight():h.getHeight(),L=e?u.getHeaderTop():a-h.getFooterBottom()-g;for(let T=0;T<r.length;T++){const M=d*T+L,P=o[3]-this.INDICATOR_PADDING,O=o[3]+l+this.INDICATOR_PADDING,X=e?M-this.INDICATOR_PADDING:M+g+this.INDICATOR_PADDING,I=e?M+g+this.INDICATOR_PADDING:M-this.INDICATOR_PADDING,f=document.createElement("div");f.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),f.style.top=`${I}px`,f.style.transform=`translate(${n*t}px, ${i*t}px) scale(${t})`,this.indicatorContainer.append(f);const S=document.createElement("span");S.classList.add(`${x}-zone-indicator-border__top`),S.style.top=`${X}px`,S.style.width=`${l}px`,S.style.marginLeft=`${o[3]}px`,this.indicatorContainer.append(S);const N=document.createElement("span");N.classList.add(`${x}-zone-indicator-border__left`),N.style.top=`${M}px`,N.style.height=`${g}px`,N.style.left=`${P}px`,this.indicatorContainer.append(N);const m=document.createElement("span");m.classList.add(`${x}-zone-indicator-border__bottom`),m.style.top=`${I}px`,this.indicatorContainer.append(m);const W=document.createElement("span");W.classList.add(`${x}-zone-indicator-border__right`),W.style.top=`${M}px`,W.style.height=`${g}px`,W.style.left=`${O}px`,this.indicatorContainer.append(W)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){var t;(t=this.indicatorContainer)==null||t.remove(),this.indicatorContainer=null}}class ur{constructor(t,e){this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(){const t=this.getFooterBottom(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],r=this.draw.getHeight(),o=this.getHeight(),l=r-t-o;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:l,innerWidth:e,zone:c.EditorZone.FOOTER})}getFooterBottom(){const{footer:{bottom:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{footer:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Sn[t])}getHeight(){if(this.options.footer.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getFooterBottom()+e-t[2];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isFooterActive()?1:this.options.footer.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),r=[];let o=0;for(let l=0;l<this.rowList.length;l++){const a=this.rowList[l];if(o+a.height>i)break;r.push(a),o+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:r,pageNo:e,startIndex:0,innerWidth:n,zone:c.EditorZone.FOOTER}),t.restore()}}class gr{constructor(t){this.UN_COUNT_STYLE_WIDTH=20,this.MEASURE_BASE_TEXT="0",this.LIST_GAP=10,this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}setList(t,e){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:r}=this.range.getRange();if(!~i&&!~r)return;const o=this.range.getRangeParagraphElementList();if(!o||!o.length)return;if(o.find(u=>u.listType===t&&u.listStyle===e)||!t){this.unsetList();return}const a=k();o.forEach(u=>{u.listId=a,u.listType=t,u.listStyle=e});const R=i===r,d=R?r:i;this.draw.render({curIndex:d,isSetCursor:R})}unsetList(){var R;if(this.draw.isReadonly())return;const{startIndex:e,endIndex:n}=this.range.getRange();if(!~e&&!~n)return;const i=(R=this.range.getRangeParagraphElementList())==null?void 0:R.filter(d=>d.listId);if(!i||!i.length)return;const r=this.draw.getElementList(),o=r[n];if(o.listId){let d=n+1;for(;d<r.length;){const u=r[d];if(u.value===y&&!u.listWrap)break;if(u.listId!==o.listId){this.draw.spliceElementList(r,d,0,[{value:y}]);break}d++}}i.forEach(d=>{delete d.listId,delete d.listType,delete d.listStyle,delete d.listWrap});const l=e===n,a=l?n:e;this.draw.render({curIndex:a,isSetCursor:l})}computeListStyle(t,e){const n=new Map;let i=0,r=e[i].listId,o=[];const l=e.length;for(;i<l;){const a=e[i];if(r&&r===a.listId)o.push(a);else if(a.listId&&a.listId!==r){if(o.length){const R=this.getListStyleWidth(t,o);n.set(r,R)}r=a.listId,o=r?[a]:[]}i++}if(o.length){const a=this.getListStyleWidth(t,o);n.set(r,a)}return n}findStyledElement(t){let e=t[0];for(let n=1;n<t.length;n++){const i=t[n];if(i.font||i.size||i.bold||i.italic){e=i;break}}return e}getListFontStyle(t,e){if(this.options.list.inheritStyle){const n=this.findStyledElement(t);return this.draw.getElementFont(n,e)}else{const{defaultFont:n,defaultSize:i}=this.options;return`${i*e}px ${n}`}}getListStyleWidth(t,e){const{scale:n,checkbox:i}=this.options,r=e[0];if(r.listStyle&&r.listStyle!==c.ListStyle.DECIMAL)return r.listStyle===c.ListStyle.CHECKBOX?(i.width+this.LIST_GAP)*n:this.UN_COUNT_STYLE_WIDTH*n;const o=e.reduce((R,d)=>(d.value===y&&(R+=1),R),0);if(!o)return 0;t.save(),t.font=this.getListFontStyle(e,n);const l=`${this.MEASURE_BASE_TEXT.repeat(String(o).length)}${c.KeyMap.PERIOD}`,a=t.measureText(l);return t.restore(),Math.ceil((a.width+this.LIST_GAP)*n)}drawListStyle(t,e,n){var M;const{elementList:i,offsetX:r,listIndex:o,ascent:l}=e,a=i[0];if(a.value!==y||a.listWrap)return;let R=0;const{defaultTabWidth:d,scale:u}=this.options;for(let P=1;P<i.length;P++){const O=i[P];if((O==null?void 0:O.type)!==c.ElementType.TAB)break;R+=d*u}const{coordinate:{leftTop:[h,g]}}=n,L=h-r+R,T=g+l;if(a.listStyle===c.ListStyle.CHECKBOX){const{width:P,height:O,gap:X}=this.options.checkbox,I={...a,checkbox:{value:!!((M=a.checkbox)!=null&&M.value)},metrics:{...a.metrics,width:(P+X*2)*u,height:O*u}};this.draw.getCheckboxParticle().render({ctx:t,x:L-X*u,y:T,index:0,row:{...e,elementList:[I,...e.elementList]}})}else{let P="";if(a.listType===c.ListType.UL?P=_e[a.listStyle]||_e[_t.DISC]:P=`${o+1}${c.KeyMap.PERIOD}`,!P)return;t.save(),t.font=this.getListFontStyle(i,u),t.fillText(P,L,T),t.restore()}}}const ui=class{constructor(s){this.options=s.getOptions()}render(s,t,e,n){const{scale:i,lineBreak:{color:r,lineWidth:o}}=this.options;s.save(),s.beginPath();const l=n-ui.HEIGHT*i/2,a=e+t.metrics.width;s.translate(a,l),s.scale(i,i),s.strokeStyle=r,s.lineWidth=o,s.lineCap="round",s.lineJoin="round",s.beginPath(),s.moveTo(8,0),s.lineTo(12,0),s.lineTo(12,6),s.lineTo(3,6),s.moveTo(3,6),s.lineTo(6,3),s.moveTo(3,6),s.lineTo(6,9),s.stroke(),s.closePath(),s.restore()}};let le=ui;le.WIDTH=12,le.HEIGHT=9,le.GAP=3;class gi{constructor(t){this.draw=t,this.position=t.getPosition(),this.options=t.getOptions(),this.elementList=[],this.rowList=[],this.positionList=[]}_recovery(){this.elementList=[],this.rowList=[],this.positionList=[]}_compute(t){this._computeRowList(),this._computePositionList(t)}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(t){const{lineBreak:e,scale:n}=this.options,i=this.draw.getHeader().getExtraHeight(),r=this.draw.getInnerWidth(),o=this.draw.getMargins();let l=o[3];e.disabled||(l+=(le.WIDTH+le.GAP)*n);const a=(t==null?void 0:t.startY)||o[0]+i;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:l,startY:a,innerWidth:r})}render(t,e){const{placeholder:n=this.options.placeholder}=e||{},{data:i,font:r,size:o,color:l,opacity:a}=n;this._recovery(),this.elementList=[{value:i,font:r,size:o,color:l}],ut(this.elementList,{editorOptions:this.options,isForceCompensation:!0}),this._compute(e);const R=this.draw.getInnerWidth();t.save(),t.globalAlpha=a,this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:this.rowList,pageNo:0,startIndex:0,innerWidth:R,isDrawLineBreak:!1}),t.restore()}}class Lr{constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==c.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=k();return t.forEach(n=>{Array.isArray(n.groupIds)||(n.groupIds=[]),n.groupIds.push(e)}),this.draw.render({isSetCursor:!1,isCompute:!1}),e}getElementListByGroupId(t,e){var i,r;const n=[];for(let o=0;o<t.length;o++){const l=t[o];if(l.type===c.ElementType.TABLE){const a=l.trList;for(let R=0;R<a.length;R++){const d=a[R];for(let u=0;u<d.tdList.length;u++){const h=d.tdList[u],g=this.getElementListByGroupId(h.value,e);if(g.length)return n.push(...g),n}}}if((i=l==null?void 0:l.groupIds)!=null&&i.includes(e)){n.push(l);const a=t[o+1];if(!((r=a==null?void 0:a.groupIds)!=null&&r.includes(e)))break}}return n}deleteGroup(t){if(this.draw.isReadonly())return;const e=this.draw.getOriginalMainElementList(),n=this.getElementListByGroupId(e,t);if(!!n.length){for(let i=0;i<n.length;i++){const r=n[i],o=r.groupIds,l=o.findIndex(a=>a===t);o.splice(l,1),o.length||delete r.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){var n,i;for(let r=0;r<t.length;r++){const o=t[r];if(o.type===c.ElementType.TABLE){const a=o.trList;for(let R=0;R<a.length;R++){const d=a[R];for(let u=0;u<d.tdList.length;u++){const h=d.tdList[u],g=this.getContextByGroupId(h.value,e);if(g)return{...g,isTable:!0,index:r,trIndex:R,tdIndex:u,tdId:h.id,trId:d.id,tableId:o.tableId}}}}const l=t[r+1];if(((n=o.groupIds)==null?void 0:n.includes(e))&&!((i=l==null?void 0:l.groupIds)!=null&&i.includes(e)))return{isTable:!1,startIndex:r,endIndex:r}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,n,i,r){const o=t.groupIds;if(!!o)for(const l of o){const a=this.fillRectMap.get(l);a?a.width+=i:this.fillRectMap.set(l,{x:e,y:n,width:i,height:r})}}render(t){var R;if(!this.fillRectMap.size)return;const e=this.range.getRange(),i=(R=this.draw.getElementList()[e.endIndex])==null?void 0:R.groupIds,{group:{backgroundColor:r,opacity:o,activeOpacity:l,activeBackgroundColor:a}}=this.options;t.save(),this.fillRectMap.forEach((d,u)=>{const{x:h,y:g,width:L,height:T}=d;i!=null&&i.includes(u)?(t.globalAlpha=l,t.fillStyle=a):(t.globalAlpha=o,t.fillStyle=r),t.fillRect(h,g,L,T)}),t.restore(),this.clearFillInfo()}}class Tr{constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:r,whiteSpace:{color:o,radius:l}}=this.options,a=e.metrics;t.save(),t.fillStyle=o,t.beginPath(),t.arc(n+a.width/2,i,l*r,0,Math.PI*2),t.fill(),t.closePath(),t.restore()}}class Pr{constructor(t){this.draw=t,this.eventBus=this.draw.getEventBus(),this.pageContainer=this.draw.getPageContainer(),this.pageContainer.addEventListener("mousemove",this._mousemove.bind(this)),this.pageContainer.addEventListener("mouseenter",this._mouseenter.bind(this)),this.pageContainer.addEventListener("mouseleave",this._mouseleave.bind(this)),this.pageContainer.addEventListener("mousedown",this._mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this._mouseup.bind(this)),this.pageContainer.addEventListener("click",this._click.bind(this))}_mousemove(t){!this.eventBus.isSubscribe("mousemove")||this.eventBus.emit("mousemove",t)}_mouseenter(t){!this.eventBus.isSubscribe("mouseenter")||this.eventBus.emit("mouseenter",t)}_mouseleave(t){!this.eventBus.isSubscribe("mouseleave")||this.eventBus.emit("mouseleave",t)}_mousedown(t){!this.eventBus.isSubscribe("mousedown")||this.eventBus.emit("mousedown",t)}_mouseup(t){!this.eventBus.isSubscribe("mouseup")||this.eventBus.emit("mouseup",t)}_click(t){!this.eventBus.isSubscribe("click")||this.eventBus.emit("click",t)}}class Mr{constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:n,lineNumber:{color:i,size:r,font:o,right:l,type:a}}=this.options,R=this.draw.getTextParticle(),d=this.draw.getMargins(),u=this.draw.getPosition().getOriginalMainPositionList(),g=this.draw.getPageRowList()[e];t.save(),t.fillStyle=i,t.font=`${r*n}px ${o}`;for(let L=0;L<g.length;L++){const T=g[L],{coordinate:{leftBottom:M}}=u[T.startIndex],P=a===c.LineNumberType.PAGE?L+1:T.rowIndex+1,O=R.measureText(t,{value:`${P}`}),X=d[3]-(O.width+l)*n,I=M[1]-O.actualBoundingBoxAscent*n;t.fillText(`${P}`,X,I)}t.restore()}}class Or{constructor(t){this.draw=t,this.header=t.getHeader(),this.footer=t.getFooter(),this.options=t.getOptions()}render(t){const{scale:e,pageBorder:{color:n,lineWidth:i,padding:r}}=this.options;t.save(),t.translate(.5,.5),t.strokeStyle=n,t.lineWidth=i*e;const o=this.draw.getMargins(),l=o[3]-r[3]*e,a=o[0]+this.header.getExtraHeight()-r[0]*e,R=this.draw.getInnerWidth()+(r[1]+r[3])*e,d=this.draw.getHeight()-a-this.footer.getExtraHeight()-o[2]+r[2]*e;t.rect(l,a,R,d),t.stroke(),t.restore()}}function Sr(s,t){const{value:e,oldValue:n}=t;n.isTable&&!e.isTable&&s.getTableTool().dispose()}class Xr{constructor(t){this.draw=t,this.eventBus=t.getEventBus(),this.execute()}execute(){this.eventBus.on("positionContextChange",t=>{Sr(this.draw,t)})}}class Ir{constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.tableTool=t.getTableTool(),this.tableParticle=t.getTableParticle(),this.options=t.getOptions()}insertTable(t,e){var L;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{defaultTrMinHeight:r}=this.options.table,o=this.draw.getElementList();let l=0;if((L=o[n])!=null&&L.listId){const T=this.position.getPositionList(),{rowIndex:M}=T[n],O=this.draw.getRowList()[M];l=(O==null?void 0:O.offsetX)||0}const a=this.draw.getContextInnerWidth()-l,R=[],d=a/e;for(let T=0;T<e;T++)R.push({width:d});const u=[];for(let T=0;T<t;T++){const M=[],P={height:r,tdList:M};for(let O=0;O<e;O++)M.push({colspan:1,rowspan:1,value:[]});u.push(P)}const h={type:c.ElementType.TABLE,value:"",colgroup:R,trList:u};ut([h],{editorOptions:this.options}),Ot(o,[h],n,{editorOptions:this.options});const g=n+1;this.draw.spliceElementList(o,g,n===i?0:i-n,[h]),this.range.setRange(g,g),this.draw.render({curIndex:g,isSetCursor:!1})}insertTableTopRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=l[n];if(a.tdList.length<o.colgroup.length){const u=a.tdList[0].rowIndex;for(let h=0;h<n;h++){const g=l[h];for(let L=0;L<g.tdList.length;L++){const T=g.tdList[L];T.rowspan>1&&T.rowIndex+T.rowspan>=u+1&&(T.rowspan+=1)}}}const R=k(),d={height:a.height,id:R,tdList:[]};for(let u=0;u<a.tdList.length;u++){const h=a.tdList[u],g=k();d.tdList.push({id:g,rowspan:1,colspan:h.colspan,value:[{value:y,size:16,tableId:i,trId:R,tdId:g}]})}l.splice(n,0,d),this.position.setPositionContext({isTable:!0,index:e,trIndex:n,tdIndex:0,tdId:d.tdList[0].id,trId:d.id,tableId:i}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableBottomRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=l[n],R=l.length-1===n?a:l[n+1];if(R.tdList.length<o.colgroup.length){const h=R.tdList[0].rowIndex;for(let g=0;g<n+1;g++){const L=l[g];for(let T=0;T<L.tdList.length;T++){const M=L.tdList[T];M.rowspan>1&&M.rowIndex+M.rowspan>=h+1&&(M.rowspan+=1)}}}const d=k(),u={height:R.height,id:d,tdList:[]};for(let h=0;h<R.tdList.length;h++){const g=R.tdList[h],L=k();u.tdList.push({id:L,rowspan:1,colspan:g.colspan,value:[{value:y,size:16,tableId:i,trId:d,tdId:L}]})}l.splice(n+1,0,u),this.position.setPositionContext({isTable:!0,index:e,trIndex:n+1,tdIndex:0,tdId:u.tdList[0].id,trId:u.id,tableId:o.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}adjustColWidth(t){if(t.type!==c.ElementType.TABLE)return;const{defaultColMinWidth:e}=this.options.table,n=t.colgroup,i=n.reduce((o,l)=>o+l.width,0),r=this.draw.getOriginalInnerWidth();if(i>r){const o=n.filter(a=>a.width>e),l=(i-r)/o.length;for(let a=0;a<n.length;a++){const R=n[a];R.width-l>=e&&(R.width-=l)}}}insertTableLeftCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=n;for(let u=0;u<l.length;u++){const h=l[u],g=k();h.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:R}=this.options.table;o.colgroup.splice(a,0,{width:R}),this.adjustColWidth(o),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:i}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableRightCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=n+1;for(let u=0;u<l.length;u++){const h=l[u],g=k();h.tdList.splice(a,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:R}=this.options.table;o.colgroup.splice(a,0,{width:R}),this.adjustColWidth(o),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:a,tdId:l[0].tdList[a].id,trId:l[0].id,tableId:o.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}deleteTableRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tdIndex:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=l[n],R=a.tdList[i].rowIndex;if(l.length<=1&&o.pagingIndex===0){this.deleteTable();return}for(let d=0;d<R;d++){const h=l[d].tdList;for(let g=0;g<h.length;g++){const L=h[g];L.rowIndex+L.rowspan>R&&L.rowspan--}}for(let d=0;d<a.tdList.length;d++){const u=a.tdList[d];if(u.rowspan>1){const h=k(),g=l[n+1];g.tdList.splice(d,0,{id:h,rowspan:u.rowspan-1,colspan:u.colspan,value:[{value:y,size:16,tableId:o.id,trId:g.id,tdId:h}]})}}l.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.clearRange(),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTableCol(){var u;const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,R=l[i].tdList[n].colIndex;if(!l.find(h=>h.tdList.length>1)){this.deleteTable();return}for(let h=0;h<l.length;h++){const g=l[h];for(let L=0;L<g.tdList.length;L++){const T=g.tdList[L];T.colIndex<=R&&T.colIndex+T.colspan>R&&(T.colspan>1?T.colspan--:g.tdList.splice(L,1))}}(u=o.colgroup)==null||u.splice(R,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTable(){const t=this.position.getPositionContext();if(!t.isTable)return;const e=this.draw.getOriginalElementList(),n=e[t.index];let i=1,r=t.index;if(n.pagingId){r=t.index-n.pagingIndex;for(let l=r+1;l<e.length&&e[l].pagingId===n.pagingId;l++)i++}e.splice(r,i);const o=r-1;this.position.setPositionContext({isTable:!1,index:o}),this.range.setRange(o,o),this.draw.render({curIndex:o}),this.tableTool.dispose()}mergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{isCrossRowCol:e,startTdIndex:n,endTdIndex:i,startTrIndex:r,endTrIndex:o}=this.range.getRange();if(!e)return;const{index:l}=t,d=this.draw.getOriginalElementList()[l].trList;let u=d[r].tdList[n],h=d[o].tdList[i];(u.x>h.x||u.y>h.y)&&([u,h]=[h,u]);const g=u.colIndex,L=h.colIndex+(h.colspan-1),T=u.rowIndex,M=h.rowIndex+(h.rowspan-1),P=[];for(let F=0;F<d.length;F++){const E=d[F],V=[];for(let Y=0;Y<E.tdList.length;Y++){const K=E.tdList[Y],b=K.colIndex,p=K.rowIndex;b>=g&&b<=L&&p>=T&&p<=M&&V.push(K)}V.length&&P.push(V)}if(!P.length)return;const O=P[P.length-1],X=P[0][0],I=O[O.length-1],f=X.x,S=X.y,N=I.x+I.width,m=I.y+I.height;for(let F=0;F<P.length;F++){const E=P[F];for(let V=0;V<E.length;V++){const Y=E[V],K=Y.x,b=Y.y,p=K+Y.width,H=b+Y.height;if(f>K||S>b||N<p||m<H)return}}const W=[],Z=P[0][0],U=Z.value[0];for(let F=0;F<P.length;F++){const E=P[F];for(let V=0;V<E.length;V++){const Y=E[V];if(!(F===0&&V===0)){W.push(Y.id);const b=Y.value.length>1?0:1;for(let p=b;p<Y.value.length;p++){const H=Y.value[p];Bt(de,U,H),Z.value.push(H)}}F===0&&V!==0&&(Z.colspan+=Y.colspan),F!==0&&Z.colIndex===Y.colIndex&&(Z.rowspan+=Y.rowspan)}}for(let F=0;F<d.length;F++){const E=d[F];let V=0;for(;V<E.tdList.length;){const Y=E.tdList[V];W.includes(Y.id)&&(E.tdList.splice(V,1),V--),V++}}this.position.setPositionContext({...t,trIndex:Z.trIndex,tdIndex:Z.tdIndex});const Q=Z.value.length-1;this.range.setRange(Q,Q),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,o=this.draw.getOriginalElementList()[e],l=o.trList,a=l[i],R=a.tdList[n];if(R.rowspan===1&&R.colspan===1)return;const d=R.colspan;if(R.colspan>1){for(let h=1;h<R.colspan;h++){const g=k();a.tdList.splice(n+h,0,{id:g,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:o.id,trId:a.id,tdId:g}]})}R.colspan=1}if(R.rowspan>1){for(let h=1;h<R.rowspan;h++){const g=l[i+h];for(let L=0;L<d;L++){const T=k();g.tdList.splice(R.colIndex,0,{id:T,rowspan:1,colspan:1,value:[{value:y,size:16,tableId:o.id,trId:g.id,tdId:T}]})}}R.rowspan=1}const u=R.value.length-1;this.range.setRange(u,u),this.draw.render(),this.tableTool.render()}splitVerticalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:r}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,R=a[r],d=R.tdList[i];l.colgroup.splice(i+1,0,{width:this.options.table.defaultColMinWidth});for(let u=0;u<a.length;u++){const h=a[u];let g=0;for(;g<h.tdList.length;){const L=h.tdList[g];if(L.rowIndex!==d.rowIndex)L.colIndex<=d.colIndex&&L.colIndex+L.colspan>d.colIndex&&L.colspan++;else if(L.id===d.id){const T=k();R.tdList.splice(g+d.colspan,0,{id:T,rowspan:d.rowspan,colspan:1,value:[{value:y,size:16,tableId:l.id,trId:h.id,tdId:T}]}),g++}g++}}this.draw.render(),this.tableTool.render()}splitHorizontalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:r}=t,l=this.draw.getOriginalElementList()[n],a=l.trList,d=a[r].tdList[i];let u=-1,h=0;for(;h<a.length;){if(h===u){h++;continue}const g=a[h];let L=0;for(;L<g.tdList.length;){const T=g.tdList[L];if(T.id===d.id){const M=k(),P=k();a.splice(h+d.rowspan,0,{id:M,height:this.options.table.defaultTrMinHeight,tdList:[{id:P,rowspan:1,colspan:d.colspan,value:[{value:y,size:16,tableId:l.id,trId:M,tdId:P}]}]}),u=h+d.rowspan}else T.rowIndex>=d.rowIndex&&T.rowIndex<d.rowIndex+d.rowspan&&T.rowIndex+T.rowspan>=d.rowIndex+d.rowspan&&T.rowspan++;L++}h++}this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const r=e[i];for(let o=0;o<r.length;o++){const l=r[o];!l||l.verticalAlign===t||!l.verticalAlign&&t===c.VerticalAlign.TOP||(l.verticalAlign=t)}}const{endIndex:n}=this.range.getRange();this.draw.render({curIndex:n})}tableBorderType(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,r=this.draw.getOriginalElementList()[n];if(!r.borderType&&t===c.TableBorder.ALL||r.borderType===t)return;r.borderType=t;const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o})}tableBorderColor(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,r=this.draw.getOriginalElementList()[n];if(!r.borderColor&&t===this.options.table.defaultBorderColor||r.borderColor===t)return;r.borderColor=t;const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o,isCompute:!1})}tableTdBorderType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(o=>{var l;return!((l=o.borderTypes)!=null&&l.includes(t))});n.forEach(o=>{o.borderTypes||(o.borderTypes=[]);const l=o.borderTypes.findIndex(a=>a===t);i?~l||o.borderTypes.push(t):~l&&o.borderTypes.splice(l,1),o.borderTypes.length||delete o.borderTypes});const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdSlashType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(o=>{var l;return!((l=o.slashTypes)!=null&&l.includes(t))});n.forEach(o=>{o.slashTypes||(o.slashTypes=[]);const l=o.slashTypes.findIndex(a=>a===t);i?~l||o.slashTypes.push(t):~l&&o.slashTypes.splice(l,1),o.slashTypes.length||delete o.slashTypes});const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdBackgroundColor(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const r=e[i];for(let o=0;o<r.length;o++){const l=r[o];l.backgroundColor=t}}const{endIndex:n}=this.range.getRange();this.range.setRange(n,n),this.draw.render({isCompute:!1})}tableSelectAll(){const t=this.position.getPositionContext(),{index:e,tableId:n,isTable:i}=t;if(!i||!n)return;const{startIndex:r,endIndex:o}=this.range.getRange(),a=this.draw.getOriginalElementList()[e].trList,R=a.length-1,d=a[R].tdList.length-1;this.range.replaceRange({startIndex:r,endIndex:o,tableId:n,startTdIndex:0,endTdIndex:d,startTrIndex:0,endTrIndex:R}),this.draw.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1})}}c.AreaMode=void 0,function(s){s.EDIT="edit",s.READONLY="readonly",s.FORM="form"}(c.AreaMode||(c.AreaMode={}));class Nr{constructor(t){this.areaInfoMap=new Map,this.draw=t,this.options=t.getOptions(),this.zone=t.getZone(),this.range=t.getRange(),this.position=t.getPosition()}getAreaInfo(){return this.areaInfoMap}getActiveAreaId(){if(!this.areaInfoMap.size)return null;const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];return(n==null?void 0:n.areaId)||null}getActiveAreaInfo(){const t=this.getActiveAreaId();return t&&this.areaInfoMap.get(t)||null}isReadonly(){const t=this.getActiveAreaInfo();if(!(t!=null&&t.area))return!1;switch(t.area.mode){case c.AreaMode.EDIT:return!1;case c.AreaMode.READONLY:return!0;case c.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:r,range:o}=t;if(this.zone.getZone()!==c.EditorZone.MAIN&&this.zone.setZone(c.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),o&&!this.getActiveAreaId()){const{startIndex:a,endIndex:R}=o,d=this.draw.getOriginalMainElementList();if(!d[a]||!d[R])return null;this.range.setRange(o.startIndex,o.endIndex)}else if(r===c.LocationPosition.BEFORE)this.range.setRange(0,0);else{const R=this.draw.getOriginalMainElementList().length-1;this.range.setRange(R,R)}const l=e||k();return this.draw.insertElementList([{type:c.ElementType.AREA,value:"",areaId:l,valueList:n,area:_(i)}]),l}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const r of this.areaInfoMap){const{area:o,positionList:l}=r[1];if((o==null?void 0:o.hide)||!(o!=null&&o.backgroundColor)&&!(o!=null&&o.borderColor)&&!(o!=null&&o.placeholder))continue;const a=l.filter(L=>L.pageNo===e);if(!a.length)continue;t.translate(.5,.5);const R=a[0],d=a[a.length-1],u=n[3],h=Math.ceil(R.coordinate.leftTop[1]),g=Math.ceil(d.coordinate.rightBottom[1]-h);o.backgroundColor&&(t.fillStyle=o.backgroundColor,t.fillRect(u,h,i,g)),o.borderColor&&(t.strokeStyle=o.borderColor,t.strokeRect(u,h,i,g)),o.placeholder&&l.length<=1&&new gi(this.draw).render(t,{placeholder:{...Dn,...o.placeholder},startY:R.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],r=i.areaId;if(r){const o=this.areaInfoMap.get(r);o?(o.elementList.push(i),o.positionList.push(e[n])):this.areaInfoMap.set(r,{id:r,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:tt(n.elementList)}:null}getContextByAreaId(t,e){var i,r,o;const n=this.draw.getOriginalMainElementList();for(let l=0;l<n.length;l++){const a=n[l];if((e==null?void 0:e.position)===c.LocationPosition.OUTER_BEFORE){if(((i=n[l+1])==null?void 0:i.areaId)!==t)continue}else if((e==null?void 0:e.position)===c.LocationPosition.AFTER){if(!(a.areaId===t&&((r=n[l+1])==null?void 0:r.areaId)!==t))continue}else if((e==null?void 0:e.position)===c.LocationPosition.OUTER_AFTER){if(!(a.areaId!==t&&((o=n[l-1])==null?void 0:o.areaId)===t))continue}else if(a.areaId!==t)continue;const R=this.position.getOriginalMainPositionList();return{range:{startIndex:l,endIndex:l},elementPosition:R[l]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const r=["top","hide"];Object.entries(t.properties).forEach(([o,l])=>{if(Fn(l))return;const a=o;n.area[a]=l,r.includes(a)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,r=this.draw.getOriginalMainElementList(),o=t.value;ut([{type:c.ElementType.AREA,value:"",valueList:o,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(r,i[0].index,i.length,o,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class fr{constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,i,r,o){if(this.imageCache.has(o)){const l=this.imageCache.get(o);t.drawImage(l,e,n,i,r)}else{const l=new Image;l.setAttribute("crossOrigin","Anonymous"),l.src=o,l.onload=()=>{this.imageCache.set(o,l),t.drawImage(l,e,n,i,r)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:r,top:o,width:l,height:a,value:R}=this.mainBadge,d=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),u=(r||i.left)*n,h=(o||i.top)*n+d;this._drawImage(t,u,h,l*n,a*n,R)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:r}=this.options;for(const o of n){const{positionList:l}=o[1],a=l[0];if(a.pageNo!==e)continue;const R=this.areaBadgeMap.get(o[0]);if(!R)continue;const{left:d,top:u,width:h,height:g,value:L}=R,T=(d||r.left)*i,M=(u||r.top)*i+a.coordinate.leftTop[1];this._drawImage(t,T,M,h*i,g*i,L)}}}}}class mr{constructor(t,e){this.isDrawing=!1,this.startStroke=null,this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){var R;if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const r=this.draw.getPageNo();let o=this.data.find(d=>d.pageNo===r);if(this.startStroke&&(o||(o={pageNo:r,strokes:[]},this.data.push(o)),o.strokes.push(this.startStroke),this.startStroke=null),!((R=o==null?void 0:o.strokes)!=null&&R.length))return;const{scale:l}=this.options;o.strokes[o.strokes.length-1].points.push(e/l,n/l),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){var l;const n=(l=this.data.find(a=>a.pageNo===e))==null?void 0:l.strokes;if(!(n!=null&&n.length))return;const{graffiti:{defaultLineColor:i,defaultLineWidth:r},scale:o}=this.options;t.save();for(let a=0;a<n.length;a++){const R=n[a];t.beginPath(),t.strokeStyle=R.lineColor||i,t.lineWidth=(R.lineWidth||r)*o,t.moveTo(R.points[0]*o,R.points[1]*o);for(let d=2;d<R.points.length;d+=2)t.lineTo(R.points[d]*o,R.points[d+1]*o);t.stroke()}t.restore()}}class Fr{constructor(t,e,n,i,r,o){this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.renderCount=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=n.main,this.listener=i,this.eventBus=r,this.override=o,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new Rr(e.locale),this.historyManager=new ms(this),this.position=new Fs(this),this.zone=new hr(this),this.range=new Ws(this),this.margin=new Ys(this),this.background=new ps(this),this.badge=new fr(this),this.search=new Zs(this),this.group=new Lr(this),this.area=new Nr(this),this.underline=new Es(this),this.strikeout=new Us(this),this.highlight=new Vs(this),this.previewer=new or(this),this.imageParticle=new Yn(this),this.laTexParticle=new En(this),this.textParticle=new Qs(this),this.tableParticle=new bs(this),this.tableTool=new Ks(this),this.tableOperate=new Ir(this),this.pageNumber=new re(this),this.lineNumber=new Mr(this),this.waterMark=new Bs(this),this.placeholder=new gi(this),this.header=new Hs(this,n.header),this.footer=new ur(this,n.footer),this.hyperlinkParticle=new ys(this),this.labelParticle=new ws(this),this.dateParticle=new sr(this),this.separatorParticle=new Js(this),this.pageBreakParticle=new vs(this),this.superscriptParticle=new Gs,this.subscriptParticle=new xs,this.checkboxParticle=new $s(this),this.radioParticle=new js(this),this.blockParticle=new lr(this),this.listParticle=new gr(this),this.lineBreakParticle=new le(this),this.whiteSpaceParticle=new Tr(this),this.control=new zs(this),this.pageBorder=new Or(this),this.graffiti=new mr(this,n.graffiti),this.scrollObserver=new Cs(this),this.selectionObserver=new Ds(this),this.imageObserver=new cr,new Pr(this),this.canvasEvent=new Ns(this),this.cursor=new jo(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new fs(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new ir(this),new Xr(this);const{letterClass:l}=e;this.LETTER_REG=new RegExp(`[${l.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${l.map(a=>`[^${a}][${a}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.mode===c.EditorMode.PRINT&&this.setPrintData(),this.render({isInit:!0,isSetCursor:!1,isFirstRender:!0})}setPrintData(){this.printModeData={header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()};const t=_(this.printModeData);["header","main","footer"].forEach(n=>{t[n]=this.control.filterAssistElement(t[n])}),this.setEditorData(t)}clearPrintData(){this.printModeData&&(this.setEditorData(this.printModeData),this.printModeData=null)}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}setMode(t){this.mode!==t&&(t===c.EditorMode.PRINT&&this.setPrintData(),this.mode===c.EditorMode.PRINT&&this.clearPrintData(),this.clearSideEffect(),this.range.clearRange(),this.mode=t,this.options.mode=t,this.render({isSetCursor:!1,isSubmitHistory:!1}))}isReadonly(){var t,e;if((e=(t=this.area.getActiveAreaInfo())==null?void 0:t.area)!=null&&e.mode)return this.area.isReadonly();switch(this.mode){case c.EditorMode.DESIGN:return!1;case c.EditorMode.READONLY:case c.EditorMode.PRINT:case c.EditorMode.GRAFFITI:return!0;case c.EditorMode.FORM:return!this.control.getIsRangeWithinControl();default:return!1}}isDisabled(){var r,o,l,a,R;if(this.mode===c.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if((r=this.getTd())!=null&&r.disabled)return!0;if(t===e){const d=n[t],u=n[t+1];return!!(((o=d==null?void 0:d.title)==null?void 0:o.disabled)&&((l=u==null?void 0:u.title)==null?void 0:l.disabled)&&d.titleId===u.titleId||((a=d==null?void 0:d.control)==null?void 0:a.disabled)&&((R=u==null?void 0:u.control)==null?void 0:R.disabled)&&d.controlId===u.controlId)}return n.slice(t+1,e+1).some(d=>{var u,h;return((u=d.title)==null?void 0:u.disabled)||((h=d.control)==null?void 0:h.disabled)})}isDesignMode(){return this.mode===c.EditorMode.DESIGN}isPrintMode(){return this.mode===c.EditorMode.PRINT}isGraffitiMode(){return this.mode===c.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===c.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===c.PaperDirection.VERTICAL?n:e}getWidth(){return Math.floor(this.getOriginalWidth()*this.options.scale)}getHeight(){return Math.floor(this.getOriginalHeight()*this.options.scale)}getMainHeight(){return this.getHeight()-this.getMainOuterHeight()}getMainOuterHeight(){const t=this.getMargins(),e=this.header.getExtraHeight(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}getCanvasWidth(t=-1){return this.getPage(t).width}getCanvasHeight(t=-1){return this.getPage(t).height}getInnerWidth(){const t=this.getWidth(),e=this.getMargins();return t-e[1]-e[3]}getOriginalInnerWidth(){const t=this.getOriginalWidth(),e=this.getOriginalMargins();return t-e[1]-e[3]}getContextInnerWidth(){const t=this.position.getPositionContext();if(t.isTable){const{index:e,trIndex:n,tdIndex:i}=t,o=this.getOriginalElementList()[e].trList[n].tdList[i],l=this.getTdPadding();return o.width-l[1]-l[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===c.PaperDirection.VERTICAL?t:[t[1],t[2],t[3],t[0]]}getPageGap(){return this.options.pageGap*this.options.scale}getOriginalPageGap(){return this.options.pageGap}getPageNumberBottom(){const{pageNumber:{bottom:t},scale:e}=this.options;return t*e}getMarginIndicatorSize(){return this.options.marginIndicatorSize*this.options.scale}getDefaultBasicRowMarginHeight(){return this.options.defaultBasicRowMarginHeight*this.options.scale}getHighlightMarginHeight(){return this.options.highlightMarginHeight*this.options.scale}getTdPadding(){const{table:{tdPadding:t},scale:e}=this.options;return t.map(n=>n*e)}getContainer(){return this.container}getPageContainer(){return this.pageContainer}getVisiblePageNoList(){return this.visiblePageNoList}setVisiblePageNoList(t){this.visiblePageNoList=t,this.listener.visiblePageNoListChange&&this.listener.visiblePageNoListChange(this.visiblePageNoList),this.eventBus.isSubscribe("visiblePageNoListChange")&&this.eventBus.emit("visiblePageNoListChange",this.visiblePageNoList)}getIntersectionPageNo(){return this.intersectionPageNo}setIntersectionPageNo(t){this.intersectionPageNo=t,this.listener.intersectionPageNoChange&&this.listener.intersectionPageNoChange(this.intersectionPageNo),this.eventBus.isSubscribe("intersectionPageNoChange")&&this.eventBus.emit("intersectionPageNoChange",this.intersectionPageNo)}getPageNo(){return this.pageNo}setPageNo(t){this.pageNo=t}getRenderCount(){return this.renderCount}getPage(t=-1){return this.pageList[~t?t:this.pageNo]}getPageList(){return this.pageList}getPageCount(){return this.pageList.length}getTableRowList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return t[n].trList[i].tdList[r].rowList}getOriginalRowList(){const t=this.getZone();return t.isHeaderActive()?this.header.getRowList():t.isFooterActive()?this.footer.getRowList():this.rowList}getRowList(){return this.position.getPositionContext().isTable?this.getTableRowList(this.getOriginalElementList()):this.getOriginalRowList()}getPageRowList(){return this.pageRowList}getCtx(){return this.ctxList[this.pageNo]}getOptions(){return this.options}getSearch(){return this.search}getGroup(){return this.group}getArea(){return this.area}getBadge(){return this.badge}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getLineBreakParticle(){return this.lineBreakParticle}getTextParticle(){return this.textParticle}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){var o;const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:r}=e;return((o=t[n].trList)==null?void 0:o[i].tdList[r].value)||[]}getElementList(){const t=this.position.getPositionContext(),e=this.getOriginalElementList();return t.isTable?this.getTableElementList(e):e}getMainElementList(){return this.position.getPositionContext().isTable?this.getTableElementList(this.elementList):this.elementList}getOriginalElementList(){const t=this.getZone();return t.isHeaderActive()?this.getHeaderElementList():t.isFooterActive()?this.getFooterElementList():this.elementList}getOriginalMainElementList(){return this.elementList}getFooterElementList(){return this.footer.getElementList()}getTd(){const t=this.position.getPositionContext(),{index:e,trIndex:n,tdIndex:i,isTable:r}=t;return r?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:r=!0}=e;ut(t,{isHandleFirstElement:!1,editorOptions:this.options});let o=-1,l=this.control.getActiveControl();if(!l&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),l=this.control.getActiveControl()),l&&this.control.getIsRangeWithinControl())o=l.setValue(t,void 0,{isIgnoreDisabledRule:!0}),this.control.emitControlContentChange();else{const a=this.getElementList(),R=n===i,d=n+1;R||this.spliceElementList(a,d,i-n),this.spliceElementList(a,d,0,t),o=n+t.length;const u=a[d-1];t[0].listId&&u&&!u.listId&&(u==null?void 0:u.value)===y&&(!u.type||u.type===c.ElementType.TEXT)&&(a.splice(n,1),o-=1)}~o&&(this.range.setRange(o,o),this.render({curIndex:o,isSubmitHistory:r}))}appendElementList(t,e={}){if(!t.length)return;ut(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:r=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:r})}spliceElementList(t,e,n,i,r){var R,d,u,h,g,L,T,M;const{isIgnoreDeletedRule:o=!1}=r||{},{group:l,modeRule:a}=this.options;if(n>0){const P=e+n,O=t[P],X=O==null?void 0:O.listId;if(X&&((R=t[e-1])==null?void 0:R.listId)!==X){let I=P;for(;I<t.length;){const f=t[I];if(f.listId!==X||f.value===y)break;delete f.listId,delete f.listType,delete f.listStyle,I++}}if(!o&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const I=(d=this.getTd())==null?void 0:d.deletable;let f=P-1;for(;f>=e;){const S=t[f];((S==null?void 0:S.hide)||((u=S==null?void 0:S.control)==null?void 0:u.hide)||((h=S==null?void 0:S.area)==null?void 0:h.hide)||I!==!1&&((g=S==null?void 0:S.control)==null?void 0:g.deletable)!==!1&&(!S.controlId||this.mode!==c.EditorMode.FORM||!a[this.mode].controlDeletableDisabled)&&((L=S==null?void 0:S.title)==null?void 0:L.deletable)!==!1&&(l.deletable!==!1||!((T=S.groupIds)!=null&&T.length))&&(((M=S==null?void 0:S.area)==null?void 0:M.deletable)!==!1||(S==null?void 0:S.areaIndex)!==0))&&t.splice(f,1),f--}}else t.splice(e,n)}if(i!=null&&i.length)for(let P=0;P<i.length;P++)t.splice(e+P,0,i[P])}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}getTableTool(){return this.tableTool}getTableOperate(){return this.tableOperate}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,r=!!n&&i!==n;r&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const o=this.pageList.map(l=>l.toDataURL());return e&&this.setPagePixelRatio(null),r&&this.setMode(i),o}getPainterStyle(){return this.painterStyle&&Object.keys(this.painterStyle).length?this.painterStyle:null}getPainterOptions(){return this.painterOptions}setPainterStyle(t,e){this.painterStyle=t,this.painterOptions=e||null,this.getPainterStyle()&&this.pageList.forEach(n=>n.style.cursor="copy")}setDefaultRange(){!this.elementList.length||setTimeout(()=>{const t=this.elementList.length-1;this.range.setRange(t,t),this.range.setRangeStyle()})}getIsPagingMode(){return this.options.pageMode===c.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===c.PageMode.PAGING){const{height:i}=this.options,r=this.getPagePixelRatio(),o=this.pageList[0];o.style.height=`${i}px`,o.height=i*r,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(c.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((o,l)=>{o.width=n*e,o.height=i*e,o.style.width=`${n}px`,o.style.height=`${i}px`,o.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[l])});const r=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!r,curIndex:r==null?void 0:r.index}),this.listener.pageScaleChange&&this.listener.pageScaleChange(t),this.eventBus.isSubscribe("pageScaleChange")&&this.eventBus.emit("pageScaleChange",t)}getPagePixelRatio(){return this.pagePixelRatio||window.devicePixelRatio}setPagePixelRatio(t){!this.pagePixelRatio&&t===window.devicePixelRatio||t===this.pagePixelRatio||(this.pagePixelRatio=t,this.setPageDevicePixel())}setPageDevicePixel(){const t=this.getPagePixelRatio(),e=this.getWidth(),n=this.getHeight();this.pageList.forEach((i,r)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),r=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((o,l)=>{o.width=i*n,o.height=r*n,o.style.width=`${i}px`,o.style.height=`${r}px`,this._initPageContext(this.ctxList[l])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,o)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,this._initPageContext(this.ctxList[o])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getOriginValue(t={}){const{pageNo:e}=t;let n=this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(n=this.pageRowList[e].flatMap(r=>r.elementList)),{header:this.getHeaderElementList(),main:n,footer:this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t),{extraPickAttrs:n}=t,i={header:tt(e.header,{extraPickAttrs:n}),main:tt(e.main,{extraPickAttrs:n,isClassifyArea:!0}),footer:tt(e.footer,{extraPickAttrs:n}),graffiti:e.graffiti};return{version:Qe,data:i,options:_(this.options)}}setValue(t,e){const{header:n,main:i,footer:r}=_(t);if(!n&&!i&&!r)return;const{isSetCursor:o=!1}=e||{};[n,i,r].forEach(R=>{!R||ut(R,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:r}),this.historyManager.recovery();const a=o?i!=null&&i.length?i.length-1:0:void 0;a!==void 0&&this.range.setRange(a,a),this.render({curIndex:a,isSetCursor:o,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_wrapContainer(t){const e=document.createElement("div");return t.append(e),e}_formatContainer(){this.container.style.position="relative",this.container.style.width=`${this.getWidth()}px`,this.container.setAttribute(Kt,c.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${x}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const r=this.getPagePixelRatio();i.width=e*r,i.height=n*r,i.style.cursor="text";const o=i.getContext("2d");this._initPageContext(o),this.pageList.push(i),this.ctxList.push(o)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}getElementFont(t,e=1){const{defaultSize:n,defaultFont:i}=this.options,r=t.font||i,o=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${o*e}px ${r}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){var a;const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:r}=this.options,o=t.size||e;let l=1;return o<12?l=o/12:o>30&&(l=1+(o-30)/30),n*l*((a=t.rowMargin)!=null?a:i)*r}computeRowList(t){var Q,F,E,V,Y,K,b,p,H,w,D,J,v,St,ft,Xt,ct,nt,gt,j,$,Tt;const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:r=!1,startX:o=0,startY:l=0,pageHeight:a=0,mainOuterHeight:R=0,surroundElementList:d=[]}=t,{defaultSize:u,scale:h,imgCaption:g,table:{tdPadding:L,defaultTrMinHeight:T},defaultTabWidth:M}=this.options,P=this.getDefaultBasicRowMarginHeight(),X=document.createElement("canvas").getContext("2d"),I=this.listParticle.computeListStyle(X,n),f=[];n.length&&f.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:((Q=n==null?void 0:n[0])==null?void 0:Q.rowFlex)||((F=n==null?void 0:n[1])==null?void 0:F.rowFlex)});let S=o,N=l,m=0,W,Z=0,U=0;for(let it=0;it<n.length;it++){const et=f[f.length-1],C=n[it],Qt=this.getElementRowMargin(C),G={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},Me=et.offsetX||C.listId&&I.get(C.listId)||0,ht=e-Me,Oi=et.elementList.length===1;if(S+=Oi?Me:0,N+=Oi&&et.offsetY||0,(C.hide||((E=C.control)==null?void 0:E.hide)||((V=C.area)==null?void 0:V.hide))&&!this.isDesignMode()){const B=et.elementList[et.elementList.length-1];G.height=(B==null?void 0:B.metrics.height)||this.options.defaultSize*h,G.boundingBoxAscent=(B==null?void 0:B.metrics.boundingBoxAscent)||0,G.boundingBoxDescent=(B==null?void 0:B.metrics.boundingBoxDescent)||0}else if(C.type===c.ElementType.IMAGE||C.type===c.ElementType.LATEX)if(C.imgDisplay===c.ImageDisplay.SURROUND||C.imgDisplay===c.ImageDisplay.FLOAT_TOP||C.imgDisplay===c.ImageDisplay.FLOAT_BOTTOM)G.width=0,G.height=0,G.boundingBoxDescent=0;else{const B=C.width*h,st=C.height*h;if(B>ht){const z=st*ht/B;C.width=ht/h,C.height=z/h,G.width=ht,G.height=z,G.boundingBoxDescent=z}else G.width=B,G.height=st,G.boundingBoxDescent=st;if((Y=C.imgCaption)!=null&&Y.value){const z=C.imgCaption.size||g.size,Pt=(K=C.imgCaption.top)!=null?K:g.top,zt=(z+Pt)*h;G.boundingBoxAscent+=zt}}else if(C.type===c.ElementType.TABLE){const B=L[1]+L[3],st=L[0]+L[2];if(C.pagingId){let rt=it+1,Mt=0;for(;rt<n.length;){const lt=n[rt];if(lt.pagingId===C.pagingId){const at=lt.trList.filter(Vt=>!Vt.pagingRepeat);C.trList.push(...at),C.height+=lt.height,rt++,Mt++}else break}Mt&&n.splice(it+1,Mt)}C.pagingIndex=(b=C.pagingIndex)!=null?b:0;const z=C.trList;for(let rt=0;rt<z.length;rt++){const Mt=z[rt];Mt.height=Mt.minHeight||T,Mt.minHeight=Mt.height}this.tableParticle.computeRowColInfo(C);for(let rt=0;rt<z.length;rt++){const Mt=z[rt];for(let lt=0;lt<Mt.tdList.length;lt++){const at=Mt.tdList[lt],Vt=this.computeRowList({innerWidth:(at.width-B)*h,elementList:at.value,isFromTable:!0,isPagingMode:i}),Rt=Vt.reduce((Nt,Dt)=>Nt+Dt.height,0);at.rowList=Vt;const Lt=Rt/h+st;if(at.height<Lt){const Nt=Lt-at.height,Dt=z[rt+at.rowspan-1];Dt.height+=Nt,Dt.tdList.forEach(vt=>{vt.height+=Nt,vt.realHeight?vt.realHeight+=Nt:vt.realHeight=vt.height})}let It=0,Yt=0,Ft=0;for(;Ft<at.rowspan;){const Nt=z[Ft+rt]||z[rt];It+=Nt.minHeight,Yt+=Nt.height,Ft++}at.realMinHeight=It,at.realHeight=Yt,at.mainHeight=Lt}}const Pt=this.tableParticle.getTrListGroupByCol(z);for(let rt=0;rt<Pt.length;rt++){const Mt=Pt[rt];let lt=-1;for(let at=0;at<Mt.tdList.length;at++){const Vt=Mt.tdList[at],Rt=Vt.realHeight,Lt=Vt.mainHeight,It=Vt.realMinHeight,Yt=Lt<It?Rt-It:Rt-Lt;(!~lt||Yt<lt)&&(lt=Yt)}if(lt>0){const at=z[rt];at.height-=lt,at.tdList.forEach(Vt=>{Vt.height-=lt,Vt.realHeight-=lt})}}this.tableParticle.computeRowColInfo(C);const zt=this.tableParticle.getTableHeight(C),mi=this.tableParticle.getTableWidth(C);C.width=mi,C.height=zt;const Dl=mi*h,Tn=zt*h;if(G.width=Dl,G.height=Tn,G.boundingBoxDescent=Tn,G.boundingBoxAscent=-Qt,((p=n[it+1])==null?void 0:p.type)===c.ElementType.TABLE&&(G.boundingBoxAscent-=Qt),i){const rt=this.getHeight(),Mt=this.getMainOuterHeight();let lt=Mt;for(let Rt=0;Rt<f.length;Rt++){const Lt=f[Rt],It=Lt.offsetY||0;Lt.height+lt+It>rt||((H=f[Rt-1])==null?void 0:H.isPageBreak)?lt=Mt+Lt.height+It:lt+=Lt.height+It}const at=Qt*2*h,Vt=C.trList[0].height*h;if((lt+Vt+at>rt||C.pagingIndex!==0&&C.trList[0].pagingRepeat||((w=n[it-1])==null?void 0:w.type)===c.ElementType.PAGE_BREAK)&&(lt=Mt),lt+at+Tn>rt){const Rt=C.trList;let Lt=0,It=0,Yt=0;if(Rt.length>1)for(let Ft=0;Ft<Rt.length;Ft++){const Nt=Rt[Ft],Dt=Nt.height*h;if(lt+at+Yt+Dt>rt){const vt=Nt.tdList.reduce(($t,Ee)=>$t+Ee.colspan,0);((D=C.colgroup)==null?void 0:D.length)!==vt&&(It=0);break}else Lt=Ft+1,It=Rt.length-Lt,Yt+=Dt}if(It){const Ft=Rt.splice(Lt,It),Nt=Ft.reduce((ce,Pn)=>ce+Pn.height,0),Dt=Nt*h,vt=C.pagingId||k();C.pagingId=vt,C.height-=Nt,G.height-=Dt,G.boundingBoxDescent-=Dt;const $t=_(C);$t.pagingId=vt,$t.pagingIndex=C.pagingIndex+1;const Ee=Rt.filter(ce=>ce.pagingRepeat);if(Ee.length){const ce=_(Ee);ce.forEach(Pn=>Pn.id=k()),Ft.unshift(...ce)}$t.trList=Ft,$t.id=k(),this.spliceElementList(n,it+1,0,[$t])}}if(C.pagingId){const Rt=this.position.getPositionContext();if(Rt.isTable){let Lt=-1,It=-1,Yt=it;for(;Yt<n.length;){const Ft=n[Yt];if(Ft.pagingId!==C.pagingId)break;const Nt=Ft.trList.findIndex(Dt=>Dt.id===Rt.trId);if(~Nt){Lt=Yt,It=Nt;break}Yt++}~Lt&&(Rt.index=Lt,Rt.trIndex=It,this.position.setPositionContext(Rt))}}}}else if(C.type===c.ElementType.SEPARATOR){const{separator:{lineWidth:B}}=this.options,st=C.lineWidth||B;C.width=ht/h,G.width=ht,G.height=st*h,G.boundingBoxAscent=-Qt,G.boundingBoxDescent=-Qt+G.height}else if(C.type===c.ElementType.PAGE_BREAK)C.width=ht/h,G.width=ht,G.height=u;else if(C.type===c.ElementType.RADIO||C.controlComponent===c.ControlComponent.RADIO){const{width:B,height:st,gap:z}=this.options.radio,Pt=B+z*2;C.width=Pt,G.width=Pt*h,G.height=st*h}else if(C.type===c.ElementType.CHECKBOX||C.controlComponent===c.ControlComponent.CHECKBOX){const{width:B,height:st,gap:z}=this.options.checkbox,Pt=B+z*2;C.width=Pt,G.width=Pt*h,G.height=st*h}else if(C.type===c.ElementType.TAB)G.width=M*h,G.height=u*h,G.boundingBoxDescent=0,G.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(X,X.font);else if(C.type===c.ElementType.BLOCK){if(!C.width)G.width=ht;else{const B=C.width*h;G.width=Math.min(B,ht)}G.height=C.height*h,G.boundingBoxDescent=G.height,G.boundingBoxAscent=0}else if(C.type===c.ElementType.LABEL){const{defaultSize:B,label:{defaultPadding:st}}=this.options;X.font=this.getElementFont(C);const z=this.textParticle.measureText(X,C);G.width=(z.width+st[1]+st[3])*h,G.height=(C.size||B)*h,G.boundingBoxDescent=0,G.boundingBoxAscent=(st[0]+z.actualBoundingBoxAscent)*h}else{const B=C.size||u;(C.type===c.ElementType.SUPERSCRIPT||C.type===c.ElementType.SUBSCRIPT)&&(C.actualSize=Math.ceil(B*.6)),G.height=(C.actualSize||B)*h,X.font=this.getElementFont(C);const st=this.textParticle.measureText(X,C);G.width=st.width*h,C.letterSpacing&&(G.width+=C.letterSpacing*h);const z=this.textParticle.measureBasisWord(X,C.font);G.boundingBoxAscent=z.actualBoundingBoxAscent*h,G.boundingBoxDescent=z.actualBoundingBoxDescent*h,C.type===c.ElementType.SUPERSCRIPT?G.boundingBoxAscent+=G.height/2:C.type===c.ElementType.SUBSCRIPT&&(G.boundingBoxDescent+=G.height/2)}const Si=!C.hide&&(C.imgDisplay!==c.ImageDisplay.INLINE&&C.type===c.ElementType.IMAGE||C.type===c.ElementType.LATEX)?G.height+Qt:G.boundingBoxAscent+Qt,Re=Qt+G.boundingBoxAscent+G.boundingBoxDescent+Qt,Ct=Object.assign(C,{metrics:G,left:0,style:this.getElementFont(C,h)});(J=Ct.control)!=null&&J.minWidth&&(Ct.controlComponent&&(U+=G.width),Ct.controlComponent===c.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:et,rowElement:Ct,availableWidth:ht,controlRealWidth:U}),U=0));const q=n[it-1];let Xi=n[it+1],Ue=et.width+G.width;if(this.options.wordBreak===c.WordBreak.BREAK_WORD&&(!(q!=null&&q.type)||(q==null?void 0:q.type)===c.ElementType.TEXT)&&(!C.type||C.type===c.ElementType.TEXT)){const B=`${(q==null?void 0:q.value)||""}${C.value}`;if(this.WORD_LIKE_REG.test(B)){const{width:z,endElement:Pt}=this.textParticle.measureWord(X,n,it),zt=z*h;Pt&&zt<=ht&&(Ue+=zt,Xi=Pt)}Ue+=this.textParticle.measurePunctuationWidth(X,Xi)*h}C.listId&&(C.listId!==W?Z=0:C.value===y&&!C.listWrap&&Z++),W=C.listId;const Ii=this.position.setSurroundPosition({pageNo:m,rowElement:Ct,row:et,rowElementRect:{x:S,y:N,height:Re,width:G.width},availableWidth:ht,surroundElementList:d});S=Ii.x,Ue+=Ii.rowIncreaseWidth,S+=G.width;const Ni=C.type===c.ElementType.SEPARATOR||C.type===c.ElementType.TABLE||(q==null?void 0:q.type)===c.ElementType.TABLE||(q==null?void 0:q.type)===c.ElementType.BLOCK||C.type===c.ElementType.BLOCK||(q==null?void 0:q.imgDisplay)===c.ImageDisplay.INLINE||C.imgDisplay===c.ImageDisplay.INLINE||(q==null?void 0:q.listId)!==C.listId||(q==null?void 0:q.areaId)!==C.areaId&&!((v=C.area)!=null&&v.hide)||((St=C.control)==null?void 0:St.flexDirection)===c.FlexDirection.COLUMN&&(C.controlComponent===c.ControlComponent.CHECKBOX||C.controlComponent===c.ControlComponent.RADIO)&&(q==null?void 0:q.controlComponent)===c.ControlComponent.VALUE||it!==0&&C.value===y&&!((ft=C.area)!=null&&ft.hide),fi=Ue>ht,Ln=Ni||fi;if(Ln){const B={width:G.width,height:Re,startIndex:it,elementList:[Ct],ascent:Si,rowIndex:et.rowIndex+1,rowFlex:((Xt=n[it])==null?void 0:Xt.rowFlex)||((ct=n[it+1])==null?void 0:ct.rowFlex),isPageBreak:C.type===c.ElementType.PAGE_BREAK};if(Ct.controlComponent!==c.ControlComponent.PREFIX&&((nt=Ct.control)==null?void 0:nt.indentation)===c.ControlIndentation.VALUE_START){const st=et.elementList.findIndex(z=>z.controlId===Ct.controlId&&z.controlComponent!==c.ControlComponent.PREFIX);if(~st){const Pt=this.position.computeRowPosition({row:et,innerWidth:this.getInnerWidth()})[st];Pt&&(B.offsetX=Pt.coordinate.leftTop[0])}}C.listId&&(B.isList=!0,B.offsetX=I.get(C.listId),B.listIndex=Z),B.offsetY=!r&&((gt=C.area)==null?void 0:gt.top)&&C.areaId!==((j=n[it-1])==null?void 0:j.areaId)?C.area.top*h:0,f.push(B)}else et.width+=G.width,it===0&&(oe(n[1])||!!(($=n[1])!=null&&$.areaId))?(et.height=P,et.ascent=P):et.height<Re&&(et.height=Re,et.ascent=Si),et.elementList.push(Ct);if((Ln||it===n.length-1)&&(et.isWidthNotEnough=fi&&!Ni,!et.isSurround&&((q==null?void 0:q.rowFlex)===c.RowFlex.JUSTIFY||(q==null?void 0:q.rowFlex)===c.RowFlex.ALIGNMENT&&et.isWidthNotEnough))){const B=((Tt=et.elementList[0])==null?void 0:Tt.value)===y?et.elementList.slice(1):et.elementList,st=(ht-et.width)/(B.length-1);for(let z=0;z<B.length-1;z++){const Pt=B[z];Pt.metrics.width+=st}et.width=ht}if(Ln){S=o,N+=et.height,i&&!r&&a&&(N-l+R+Re>a||C.type===c.ElementType.PAGE_BREAK)&&(N=l,vo(d,m),m+=1),Ct.left=0;const B=f[f.length-1];S=this.position.setSurroundPosition({pageNo:m,rowElement:Ct,row:B,rowElementRect:{x:S,y:N,height:Re,width:G.width},availableWidth:ht,surroundElementList:d}).x,S+=G.width}}return f}_computePageList(){var a;const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),r=this.getMainOuterHeight();let o=r,l=0;if(e===c.PageMode.CONTINUITY){t[0]=this.rowList,o+=this.rowList.reduce((h,g)=>h+g.height+(g.offsetY||0),0);const R=this.getPagePixelRatio(),d=this.pageList[0],u=Number(d.style.height.replace("px",""));if(o>u)d.style.height=`${o}px`,d.height=o*R;else{const h=o<i?i:o;d.style.height=`${h}px`,d.height=h*R}this._initPageContext(this.ctxList[0])}else for(let R=0;R<this.rowList.length;R++){const d=this.rowList[R],u=d.offsetY||0;if(d.height+u+o>i||((a=this.rowList[R-1])==null?void 0:a.isPageBreak)){if(Number.isInteger(n)&&l>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}o=r+d.height+u,t.push([d]),l++}else o+=d.height+u,t[l].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:r}=e,o=this.getDefaultBasicRowMarginHeight(),l=this.getHighlightMarginHeight();for(let a=0;a<n.length;a++){const R=n[a];for(let d=0;d<R.elementList.length;d++){const u=R.elementList[d],h=R.elementList[d-1],g=u.highlight||this.control.getControlHighlight(r,R.startIndex+d);if(g){h&&h.highlight&&h.highlight!==u.highlight&&this.highlight.render(t);const{coordinate:{leftTop:[L,T]}}=i[R.startIndex+d],M=u.left||0;this.highlight.recordFillInfo(t,L-M,T+o-l,u.metrics.width+M,R.height-2*o+2*l,g)}else h!=null&&h.highlight&&this.highlight.render(t)}this.highlight.render(t)}}drawRow(t,e){var f,S,N,m,W,Z,U,Q,F;debugger;this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:r,lineBreak:o,whiteSpace:l}=this.options,{rowList:a,pageNo:R,elementList:d,positionList:u,startIndex:h,zone:g,isDrawLineBreak:L=!o.disabled,isDrawWhiteSpace:T=!l.disabled}=e,M=this.isPrintMode(),P=this.isGraffitiMode(),{isCrossRowCol:O,tableId:X}=this.range.getRange();let I=h;for(let E=0;E<a.length;E++){const V=a[E],Y={x:0,y:0,width:0,height:0};let K=null;for(let b=0;b<V.elementList.length;b++){const p=V.elementList[b],H=p.metrics,{ascent:w,coordinate:{leftTop:[D,J]}}=u[V.startIndex+b],v=V.elementList[b-1];if((p.hide||((f=p.control)==null?void 0:f.hide)||((S=p.area)==null?void 0:S.hide))&&!this.isDesignMode())this.textParticle.complete();else if(p.type===c.ElementType.IMAGE)this.textParticle.complete(),p.imgDisplay!==c.ImageDisplay.SURROUND&&p.imgDisplay!==c.ImageDisplay.FLOAT_TOP&&p.imgDisplay!==c.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,p,D,J+w);else if(p.type===c.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,p,D,J+w);else if(p.type===c.ElementType.TABLE)O&&(Y.x=D,Y.y=J,K=p),this.tableParticle.render(t,p,D,J);else if(p.type===c.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,p,D,J+w);else if(p.type===c.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,p,D,J+w);else if(p.type===c.ElementType.DATE){const ct=V.elementList[b+1];(!v||v.dateId!==p.dateId)&&this.textParticle.complete(),this.textParticle.record(t,p,D,J+w),(!ct||ct.dateId!==p.dateId)&&this.textParticle.complete()}else p.type===c.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,p,D,J+w)):p.type===c.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,p,D,J+w)):p.type===c.ElementType.SEPARATOR?this.separatorParticle.render(t,p,D,J):p.type===c.ElementType.PAGE_BREAK?this.mode!==c.EditorMode.CLEAN&&!M&&this.pageBreakParticle.render(t,p,D,J):p.type===c.ElementType.CHECKBOX||p.controlComponent===c.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:D,y:J+w,index:b,row:V})):p.type===c.ElementType.RADIO||p.controlComponent===c.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x:D,y:J+w,index:b,row:V})):p.type===c.ElementType.TAB?this.textParticle.complete():p.rowFlex===c.RowFlex.ALIGNMENT||p.rowFlex===c.RowFlex.JUSTIFY?(this.textParticle.record(t,p,D,J+w),this.textParticle.complete()):p.type===c.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,R,p,D,J+w)):(p.left&&this.textParticle.complete(),this.textParticle.record(t,p,D,J+w),(p.width||p.letterSpacing||Zi.test(p.value))&&this.textParticle.complete());if(L&&!M&&this.mode!==c.EditorMode.CLEAN&&!V.isWidthNotEnough&&b===V.elementList.length-1&&this.lineBreakParticle.render(t,p,D,J+V.height/2),T&&Ei.test(p.value)&&this.whiteSpaceParticle.render(t,p,D,J+V.height/2),(N=p.control)!=null&&N.border){((m=v==null?void 0:v.control)==null?void 0:m.border)&&v.controlId!==p.controlId&&this.control.drawBorder(t);const ct=this.getElementRowMargin(p);this.control.recordBorderInfo(D,J+ct,p.metrics.width,V.height-2*ct)}else(W=v==null?void 0:v.control)!=null&&W.border&&this.control.drawBorder(t);if(p.underline||((Z=p.control)==null?void 0:Z.underline)){(v==null?void 0:v.type)===c.ElementType.SUBSCRIPT&&p.type!==c.ElementType.SUBSCRIPT&&this.underline.render(t);const ct=this.getElementRowMargin(p),nt=p.left||0;let gt=0;p.type===c.ElementType.SUBSCRIPT&&(gt=this.subscriptParticle.getOffsetY(p));const j=(U=p.control)!=null&&U.underline?this.options.underlineColor:p.color;this.underline.recordFillInfo(t,D-nt,J+V.height-ct+gt,H.width+nt,0,j,(Q=p.textDecoration)==null?void 0:Q.style)}else((v==null?void 0:v.underline)||((F=v==null?void 0:v.control)==null?void 0:F.underline))&&this.underline.render(t);if(p.strikeout){if(!p.type||Ut.includes(p.type)){v&&(v.type===c.ElementType.SUBSCRIPT&&p.type!==c.ElementType.SUBSCRIPT||v.type===c.ElementType.SUPERSCRIPT&&p.type!==c.ElementType.SUPERSCRIPT||this.getElementSize(v)!==this.getElementSize(p))&&this.strikeout.render(t);const ct=this.textParticle.measureBasisWord(t,this.getElementFont(p));let nt=J+w+ct.actualBoundingBoxDescent*n-H.height/2;p.type===c.ElementType.SUBSCRIPT?nt+=this.subscriptParticle.getOffsetY(p):p.type===c.ElementType.SUPERSCRIPT&&(nt+=this.superscriptParticle.getOffsetY(p)),this.strikeout.recordFillInfo(t,D,nt,H.width)}}else v!=null&&v.strikeout&&this.strikeout.render(t);const{zone:St,startIndex:ft,endIndex:Xt}=this.range.getRange();if(St===g&&ft!==Xt&&ft<=I&&I<=Xt){const ct=this.position.getPositionContext();if(!ct.isTable&&!p.tdId||ct.tdId===p.tdId)if(ft===I){const nt=d[ft+1];nt&&nt.value===y&&(Y.x=D+H.width,Y.y=J,Y.height=V.height,Y.width+=this.options.rangeMinWidth)}else{let nt=H.width;nt===0&&V.elementList.length===1&&(nt=this.options.rangeMinWidth),Y.width||(Y.x=D,Y.y=J,Y.height=V.height),Y.width+=nt}}if(!r.disabled&&p.groupIds&&this.group.recordFillInfo(p,D,J,H.width,V.height),I++,p.type===c.ElementType.TABLE&&!p.hide){const ct=i[1]+i[3];for(let nt=0;nt<p.trList.length;nt++){const gt=p.trList[nt];for(let j=0;j<gt.tdList.length;j++){const $=gt.tdList[j];this.drawRow(t,{elementList:$.value,positionList:$.positionList,rowList:$.rowList,pageNo:R,startIndex:0,innerWidth:($.width-ct)*n,zone:g,isDrawLineBreak:L})}}}}if(V.isList&&this.listParticle.drawListStyle(t,V,u[V.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!M&&!P){if(Y.width&&Y.height){const{x:b,y:p,width:H,height:w}=Y;this.range.render(t,b,p,H,w)}if(O&&K&&K.id===X){const{coordinate:{leftTop:[b,p]}}=u[V.startIndex];this.tableParticle.drawRange(t,K,b,p)}}}}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:r,pageNo:o}=e;for(let l=0;l<i.length;l++){const a=i[l],R=a.element;if((o===a.pageNo||a.zone===c.EditorZone.HEADER||a.zone==c.EditorZone.FOOTER)&&R.imgDisplay&&r.includes(R.imgDisplay)&&R.type===c.ElementType.IMAGE){const d=R.imgFloatPosition;this.imageParticle.render(t,R,d.x*n,d.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){var P,O,X;const{elementList:e,positionList:n,rowList:i,pageNo:r}=t,{inactiveAlpha:o,pageMode:l,header:a,footer:R,pageNumber:d,lineNumber:u,pageBorder:h}=this.options,g=this.mode===c.EditorMode.PRINT,L=this.getInnerWidth(),T=this.ctxList[r];T.globalAlpha=this.zone.isMainActive()?1:o,this._clearPage(r),(!g||!((P=this.options.modeRule[c.EditorMode.PRINT])!=null&&P.backgroundDisabled))&&this.background.render(T,r),g||this.area.render(T,r),l!==c.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(T,r),g||this.margin.render(T,r),this._drawFloat(T,{pageNo:r,imgDisplays:[c.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(T,r);const M=(O=i[0])==null?void 0:O.startIndex;this.drawRow(T,{elementList:e,positionList:n,rowList:i,pageNo:r,startIndex:M,innerWidth:L,zone:c.EditorZone.MAIN}),this.getIsPagingMode()&&(a.disabled||this.header.render(T,r),d.disabled||this.pageNumber.render(T,r),R.disabled||this.footer.render(T,r)),this._drawFloat(T,{pageNo:r,imgDisplays:[c.ImageDisplay.FLOAT_TOP,c.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(T,r),this.elementList.length<=1&&!((X=this.elementList[0])!=null&&X.listId)&&this.placeholder.render(T),u.disabled||this.lineNumber.render(T,r),h.disabled||this.pageBorder.render(T),this.badge.render(T,r),this.isGraffitiMode()&&this.graffiti.render(T,r)}_disconnectLazyRender(){var t;(t=this.lazyRenderIntersectionObserver)==null||t.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const r=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[r],pageNo:r})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){this.renderCount++;const{header:e,footer:n}=this.options,{isSubmitHistory:i=!0,isSetCursor:r=!0,isCompute:o=!0,isLazy:l=!0,isInit:a=!1,isSourceHistory:R=!1,isFirstRender:d=!1}=t||{};let{curIndex:u}=t||{};const h=this.getInnerWidth(),g=this.getIsPagingMode(),L=this.pageRowList.length;if(o){this.position.setFloatPositionList([]),g&&(e.disabled||this.header.compute(),n.disabled||this.footer.compute());const P=this.getMargins(),O=this.getHeight(),X=this.header.getExtraHeight(),I=this.getMainOuterHeight(),f=P[3],S=P[0]+X,N=tn(this.elementList);if(this.rowList=this.computeRowList({startX:f,startY:S,pageHeight:O,mainOuterHeight:I,isPagingMode:g,innerWidth:h,surroundElementList:N,elementList:this.elementList}),this.pageRowList=this._computePageList(),this.position.computePositionList(),this.area.compute(),!this.isPrintMode()){const m=this.search.getSearchKeyword();m&&this.search.compute(m),this.control.computeHighlightList()}this.isGraffitiMode()&&this.graffiti.compute()}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let P=0;P<this.pageRowList.length;P++)this.pageList[P]||this._createPage(P);const T=this.pageRowList.length,M=this.pageList.length;if(M>T){const P=M-T;this.ctxList.splice(T,P),this.pageList.splice(T,P).forEach(O=>O.remove())}l&&g?this._lazyRender():this._immediateRender(),r?u=this.setCursor(u):this.range.getIsSelection()&&this.cursor.focus(),(i&&!d||u!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(u),Ge(()=>{this.range.setRangeStyle(),o&&this.control.getActiveControl()&&this.control.reAwakeControl(),o&&!this.isReadonly()&&this.position.getPositionContext().isTable&&this.tableTool.render(),o&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),L!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(i||R)&&!a&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"))})}setCursor(t){var r;const e=this.position.getPositionContext(),n=this.position.getPositionList();if(e.isTable){const{index:o,trIndex:l,tdIndex:a}=e,d=(r=this.getOriginalElementList()[o].trList)==null?void 0:r[l].tdList[a].positionList;t===void 0&&d&&(t=d.length-1);const u=d==null?void 0:d[t];this.position.setCursorPosition(u||null)}else this.position.setCursorPosition(t!==void 0?n[t]:null);let i=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const l=this.getElementList()[t];if(ji.includes(l.type)){i=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(l,a)}}return this.cursor.drawCursor({isShow:i}),t}submitHistory(t){const e=this.position.getPositionContext(),n=qe(this.elementList),i=qe(this.header.getElementList()),r=qe(this.footer.getElementList()),o=_(this.range.getRange()),l=this.pageNo,a=_(e),R=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(R),this.setPageNo(l),this.position.setPositionContext(_(a)),this.header.setElementList(_(i)),this.footer.setElementList(_(r)),this.elementList=_(n),this.range.replaceRange(_(o)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}}class Li{constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeSize=t.size.bind(t),this.executeSizeAdd=t.sizeAdd.bind(t),this.executeSizeMinus=t.sizeMinus.bind(t),this.executeBold=t.bold.bind(t),this.executeItalic=t.italic.bind(t),this.executeUnderline=t.underline.bind(t),this.executeStrikeout=t.strikeout.bind(t),this.executeSuperscript=t.superscript.bind(t),this.executeSubscript=t.subscript.bind(t),this.executeColor=t.color.bind(t),this.executeHighlight=t.highlight.bind(t),this.executeTitle=t.title.bind(t),this.executeList=t.list.bind(t),this.executeRowFlex=t.rowFlex.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeJumpControl=t.jumpControl.bind(t)}}function Ti(s,t){let e=0;for(let n=1;n<t;n++){const i=s[n],r=s[n-1];(i.value===y&&!i.listWrap&&!i.listId||i.listId!==(r==null?void 0:r.listId)&&r.value!==y||i.titleId!==(r==null?void 0:r.titleId)&&r.value!==y)&&e++}return e}function Wr(s,t){return s===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:s===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:s===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${s}px`,height:`${t}px`}}function pr(s,t){const{width:e,height:n,direction:i=c.PaperDirection.VERTICAL}=t,r=document.createElement("iframe");r.style.visibility="hidden",r.style.position="absolute",r.style.left="0",r.style.top="0",r.style.width="0",r.style.height="0",r.style.border="none",document.body.append(r);const o=r.contentWindow,l=o.document;l.open();const a=document.createElement("div"),R=Wr(e,n);s.forEach(h=>{const g=document.createElement("img");g.style.width=i===c.PaperDirection.HORIZONTAL?R.height:R.width,g.style.height=i===c.PaperDirection.HORIZONTAL?R.width:R.height,g.src=h,a.append(g)});const d=document.createElement("style"),u=`
89
89
  * {
90
90
  margin: 0;
91
91
  padding: 0;