@hufe921/canvas-editor 0.9.51 → 0.9.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/canvas-editor.es.js +14 -8
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +9 -9
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +1 -0
- package/dist/src/editor/interface/Control.d.ts +3 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
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-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:14.28571%;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:14.28571%;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;overflow:hidden;border-radius:8px;background-color:#fff;border:1px solid rgb(235 236 240)}.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}.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:last-child:after{display:none}.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}.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: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}.ce-resizer-selection>div{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}.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-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-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-external{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iIzNENDc1NyIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOSA1VjNIOHYyaDF6bTAgOXYtMkg4djJoMXpNNSA4SDN2MWgyVjh6bTkgMGgtMnYxaDJWOHpNOSA3djFoMXYxSDl2MUg4VjlIN1Y4aDFWN2gxeiIgZmlsbD0iI0FBQUNCMCIvPjwvc3ZnPg==)}.ce-contextmenu-border-td{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgZD0iTTguNSAyLjUgdjYgaC02Ii8+PC9zdmc+)}.ce-contextmenu-border-td-bottom{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIuNSAzYS41LjUgMCAwMS41LS41aDExYS41LjUgMCAwMS41LjV2MTFhLjUuNSAwIDAxLS41LjVIM2EuNS41IDAgMDEtLjUtLjVWM3oiIHN0cm9rZT0iI0FBQUNCMCIvPjxwYXRoIHN0cm9rZT0iIzNENDc1NyIgZD0iTTIuNSA4LjUgaDEyIi8+PC9zdmc+)}.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-inputarea{width:100px;height:30px;min-width:0;min-height:0;margin:0;padding:0;left:0;right: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}}')),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();})();
|
|
2
|
-
var MR=Object.defineProperty,dR=Object.defineProperties;var OR=Object.getOwnPropertyDescriptors;var xe=Object.getOwnPropertySymbols;var PR=Object.prototype.hasOwnProperty,XR=Object.prototype.propertyIsEnumerable;var ie=(M,_,it)=>_ in M?MR(M,_,{enumerable:!0,configurable:!0,writable:!0,value:it}):M[_]=it,
|
|
3
|
-
`,ve=" ",Re=" ",Be=["\xB7","\u3001",":","\uFF1A",",","\uFF0C",".","\u3002",";","\uFF1B","?","\uFF1F","!","\uFF01"],se={[M.MaxHeightRatio.HALF]:1/2,[M.MaxHeightRatio.ONE_THIRD]:1/3,[M.MaxHeightRatio.QUARTER]:1/4},oe={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"};M.RowFlex=void 0,function(R){R.LEFT="left",R.CENTER="center",R.RIGHT="right",R.ALIGNMENT="alignment"}(M.RowFlex||(M.RowFlex={}));const wt=/[0-9.]/,Ae=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,_e=/[#*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,ke=new RegExp(`${_e.source}|${Ae.source}`,"g");function re(R,t){let e;return function(...i){e&&window.clearTimeout(e),e=window.setTimeout(()=>{R.apply(this,i)},t)}}function $(R){if(!R||typeof R!="object")return R;let t={};return Array.isArray(R)?t=R.map(e=>$(e)):Object.keys(R).forEach(e=>t[e]=$(R[e])),t}function Jt(R){return R&&R.nodeType===1&&R.tagName.toLowerCase()==="body"}function ft(R,t,e){if(R&&!Jt(R))for(R=e?R:R.parentNode;R;){if(!t||t(R)||Jt(R))return t&&!t(R)&&Jt(R)?null:R;R=R.parentNode}return null}function x(){function R(){return((1+Math.random())*65536|0).toString(16).substring(1)}return R()+R()+"-"+R()+"-"+R()+"-"+R()+"-"+R()+R()+R()}function ht(R){const t=[],e=new Map;for(const n of R.matchAll(ke))e.set(n.index,n[0]);let i=0;for(;i<R.length;){const n=e.get(i);n?(t.push(n),i+=n.length):(t.push(R[i]),i++)}return t}function le(R,t){const e=document.createElement("a");e.href=R,e.download=t,e.click()}function ze(R,t){$e(3,R,t)}function $e(R,t,e){let i=0,n=0;const s=function(o){i=new Date().getTime()-n<300?i+1:0,n=new Date().getTime(),i>=R-1&&(e(o),i=0)};t.addEventListener("click",s)}function ae(R){return Object.prototype.toString.call(R)==="[object Object]"}function ce(R){return Array.isArray(R)}function ue(R,t){if(ae(R)&&ae(t)){const e=t;for(const[i,n]of Object.entries(R))e[i]?e[i]=ue(n,e[i]):e[i]=n}else ce(R)&&ce(t)&&t.push(...R);return t}function Dt(R){setTimeout(()=>{R()},0)}function he(R){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(!R||isNaN(R))return"\u96F6";const i=R.toString().split("");let n="";for(let s=0;s<i.length;s++){const o=i.length-1-s;n=`${e[s]}${n}`,n=`${t[Number(i[o])]}${n}`}return n=n.replace(/零(千|百|十)/g,"\u96F6").replace(/十零/g,"\u5341"),n=n.replace(/零+/g,"\u96F6"),n=n.replace(/零亿/g,"\u4EBF").replace(/零万/g,"\u4E07"),n=n.replace(/亿万/g,"\u4EBF"),n=n.replace(/零+$/,""),n=n.replace(/^一十/g,"\u5341"),n}function Me(R,t,e){for(let i=0;i<R.length;i++){const n=R[i],s=t[n];s!==void 0?e[n]=s:delete e[n]}}function de(R,t){const e={};for(const i in R)t.includes(i)||(e[i]=R[i]);return e}function je(R){const e=new TextEncoder().encode(R),i=Array.from(e,s=>String.fromCharCode(s));return window.btoa(i.join(""))}function qe(R){let t=R.parentElement;for(;t;){const i=window.getComputedStyle(t).getPropertyValue("overflow-y");if(t.scrollHeight>t.clientHeight&&(i==="auto"||i==="scroll"))return t;t=t.parentElement}return document.documentElement}function ti(R,t){return R.length!==t.length?!1:!R.some(e=>!t.includes(e))}const ei=12,ii={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF"},gt="editor-component",H="ce";var rt;(function(R){R.UP="top",R.DOWN="down",R.LEFT="left",R.RIGHT="right"})(rt||(rt={})),M.ElementType=void 0,function(R){R.TEXT="text",R.IMAGE="image",R.TABLE="table",R.HYPERLINK="hyperlink",R.SUPERSCRIPT="superscript",R.SUBSCRIPT="subscript",R.SEPARATOR="separator",R.PAGE_BREAK="pageBreak",R.CONTROL="control",R.CHECKBOX="checkbox",R.LATEX="latex",R.TAB="tab",R.DATE="date",R.BLOCK="block",R.TITLE="title",R.LIST="list"}(M.ElementType||(M.ElementType={}));const mt=["bold","color","highlight","font","size","italic","underline","strikeout"],ni=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","url","hyperlinkId","dateId","dateFormat","groupIds"],Ri=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","rowMargin","dashArray","trList","borderType","width","height","url","colgroup","valueList","control","checkbox","dateFormat","block","level","listType","listStyle","listWrap","groupIds"],si=["verticalAlign","backgroundColor","borderType"],Oe=["tdId","trId","tableId"],oi=["level","titleId"],ri=["listId","listType","listStyle"],li=[...Oe,...oi,...ri],Ft=[M.ElementType.TEXT,M.ElementType.HYPERLINK,M.ElementType.SUBSCRIPT,M.ElementType.SUPERSCRIPT,M.ElementType.CONTROL,M.ElementType.DATE],ai=[M.ElementType.BLOCK,M.ElementType.PAGE_BREAK,M.ElementType.SEPARATOR,M.ElementType.TABLE],ci=["HR","TABLE","UL","OL"],ui=[M.ElementType.TITLE,M.ElementType.LIST];class Pe{constructor(t){d(this,"draw");d(this,"options");d(this,"imageCache");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const i=8,n=(t-Math.ceil(t/i)*i)/2,s=(e-Math.ceil(e/i)*i)/2,o=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
|
|
2
|
+
var MR=Object.defineProperty,dR=Object.defineProperties;var OR=Object.getOwnPropertyDescriptors;var xe=Object.getOwnPropertySymbols;var PR=Object.prototype.hasOwnProperty,XR=Object.prototype.propertyIsEnumerable;var ie=(M,_,it)=>_ in M?MR(M,_,{enumerable:!0,configurable:!0,writable:!0,value:it}):M[_]=it,H=(M,_)=>{for(var it in _||(_={}))PR.call(_,it)&&ie(M,it,_[it]);if(xe)for(var it of xe(_))XR.call(_,it)&&ie(M,it,_[it]);return M},$=(M,_)=>dR(M,OR(_));var d=(M,_,it)=>(ie(M,typeof _!="symbol"?_+"":_,it),it);(function(M,_){typeof exports=="object"&&typeof module!="undefined"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(M=typeof globalThis!="undefined"?globalThis:M||self,_(M["canvas-editor"]={}))})(this,function(M){"use strict";var _="";const it="0.9.52";M.MaxHeightRatio=void 0,function(R){R.HALF="half",R.ONE_THIRD="one-third",R.QUARTER="quarter"}(M.MaxHeightRatio||(M.MaxHeightRatio={})),M.NumberType=void 0,function(R){R.ARABIC="arabic",R.CHINESE="chinese"}(M.NumberType||(M.NumberType={}));const C="\u200B",ne=`
|
|
3
|
+
`,ve=" ",Re=" ",Be=["\xB7","\u3001",":","\uFF1A",",","\uFF0C",".","\u3002",";","\uFF1B","?","\uFF1F","!","\uFF01"],se={[M.MaxHeightRatio.HALF]:1/2,[M.MaxHeightRatio.ONE_THIRD]:1/3,[M.MaxHeightRatio.QUARTER]:1/4},oe={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"};M.RowFlex=void 0,function(R){R.LEFT="left",R.CENTER="center",R.RIGHT="right",R.ALIGNMENT="alignment"}(M.RowFlex||(M.RowFlex={}));const wt=/[0-9.]/,Ae=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,_e=/[#*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,ke=new RegExp(`${_e.source}|${Ae.source}`,"g");function re(R,t){let e;return function(...i){e&&window.clearTimeout(e),e=window.setTimeout(()=>{R.apply(this,i)},t)}}function j(R){if(!R||typeof R!="object")return R;let t={};return Array.isArray(R)?t=R.map(e=>j(e)):Object.keys(R).forEach(e=>t[e]=j(R[e])),t}function Jt(R){return R&&R.nodeType===1&&R.tagName.toLowerCase()==="body"}function ft(R,t,e){if(R&&!Jt(R))for(R=e?R:R.parentNode;R;){if(!t||t(R)||Jt(R))return t&&!t(R)&&Jt(R)?null:R;R=R.parentNode}return null}function x(){function R(){return((1+Math.random())*65536|0).toString(16).substring(1)}return R()+R()+"-"+R()+"-"+R()+"-"+R()+"-"+R()+R()+R()}function ht(R){const t=[],e=new Map;for(const n of R.matchAll(ke))e.set(n.index,n[0]);let i=0;for(;i<R.length;){const n=e.get(i);n?(t.push(n),i+=n.length):(t.push(R[i]),i++)}return t}function le(R,t){const e=document.createElement("a");e.href=R,e.download=t,e.click()}function ze(R,t){$e(3,R,t)}function $e(R,t,e){let i=0,n=0;const s=function(o){i=new Date().getTime()-n<300?i+1:0,n=new Date().getTime(),i>=R-1&&(e(o),i=0)};t.addEventListener("click",s)}function ae(R){return Object.prototype.toString.call(R)==="[object Object]"}function ce(R){return Array.isArray(R)}function ue(R,t){if(ae(R)&&ae(t)){const e=t;for(const[i,n]of Object.entries(R))e[i]?e[i]=ue(n,e[i]):e[i]=n}else ce(R)&&ce(t)&&t.push(...R);return t}function Dt(R){setTimeout(()=>{R()},0)}function he(R){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(!R||isNaN(R))return"\u96F6";const i=R.toString().split("");let n="";for(let s=0;s<i.length;s++){const o=i.length-1-s;n=`${e[s]}${n}`,n=`${t[Number(i[o])]}${n}`}return n=n.replace(/零(千|百|十)/g,"\u96F6").replace(/十零/g,"\u5341"),n=n.replace(/零+/g,"\u96F6"),n=n.replace(/零亿/g,"\u4EBF").replace(/零万/g,"\u4E07"),n=n.replace(/亿万/g,"\u4EBF"),n=n.replace(/零+$/,""),n=n.replace(/^一十/g,"\u5341"),n}function Me(R,t,e){for(let i=0;i<R.length;i++){const n=R[i],s=t[n];s!==void 0?e[n]=s:delete e[n]}}function de(R,t){const e={};for(const i in R)t.includes(i)||(e[i]=R[i]);return e}function je(R){const e=new TextEncoder().encode(R),i=Array.from(e,s=>String.fromCharCode(s));return window.btoa(i.join(""))}function qe(R){let t=R.parentElement;for(;t;){const i=window.getComputedStyle(t).getPropertyValue("overflow-y");if(t.scrollHeight>t.clientHeight&&(i==="auto"||i==="scroll"))return t;t=t.parentElement}return document.documentElement}function ti(R,t){return R.length!==t.length?!1:!R.some(e=>!t.includes(e))}const ei=12,ii={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF"},gt="editor-component",E="ce";var rt;(function(R){R.UP="top",R.DOWN="down",R.LEFT="left",R.RIGHT="right"})(rt||(rt={})),M.ElementType=void 0,function(R){R.TEXT="text",R.IMAGE="image",R.TABLE="table",R.HYPERLINK="hyperlink",R.SUPERSCRIPT="superscript",R.SUBSCRIPT="subscript",R.SEPARATOR="separator",R.PAGE_BREAK="pageBreak",R.CONTROL="control",R.CHECKBOX="checkbox",R.LATEX="latex",R.TAB="tab",R.DATE="date",R.BLOCK="block",R.TITLE="title",R.LIST="list"}(M.ElementType||(M.ElementType={}));const mt=["bold","color","highlight","font","size","italic","underline","strikeout"],ni=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","url","hyperlinkId","dateId","dateFormat","groupIds"],Ri=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","rowMargin","dashArray","trList","borderType","width","height","url","colgroup","valueList","control","checkbox","dateFormat","block","level","listType","listStyle","listWrap","groupIds"],si=["verticalAlign","backgroundColor","borderType"],Oe=["tdId","trId","tableId"],oi=["level","titleId"],ri=["listId","listType","listStyle"],li=[...Oe,...oi,...ri],Ft=[M.ElementType.TEXT,M.ElementType.HYPERLINK,M.ElementType.SUBSCRIPT,M.ElementType.SUPERSCRIPT,M.ElementType.CONTROL,M.ElementType.DATE],ai=[M.ElementType.BLOCK,M.ElementType.PAGE_BREAK,M.ElementType.SEPARATOR,M.ElementType.TABLE],ci=["HR","TABLE","UL","OL"],ui=[M.ElementType.TITLE,M.ElementType.LIST];class Pe{constructor(t){d(this,"draw");d(this,"options");d(this,"imageCache");this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const i=8,n=(t-Math.ceil(t/i)*i)/2,s=(e-Math.ceil(e/i)*i)/2,o=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
|
|
4
4
|
<rect width="${t}" height="${e}" fill="url(#mosaic)" />
|
|
5
5
|
<defs>
|
|
6
6
|
<pattern id="mosaic" x="${n}" y="${s}" width="${i*2}" height="${i*2}" patternUnits="userSpaceOnUse">
|
|
@@ -56,13 +56,13 @@ trailer
|
|
|
56
56
|
>>startxref
|
|
57
57
|
|
|
58
58
|
%%EOF
|
|
59
|
-
`,a+l}boxes(t){t||(t={});const[e,i,n,s]=this.resolveScale(t),o=[];for(let r=0;r<this._tree.chld.length;r++){const{x:a,y:l,w:u,h:c}=this._tree.chld[r].bbox;o.push({x:e+a*n,y:i+l*s,w:u*n,h:c*s})}return o}box(t){t||(t={});const[e,i,n,s]=this.resolveScale(t);return{x:e+this._tree.bbox.x*n,y:i+this._tree.bbox.y*s,w:this._tree.bbox.w*n,h:this._tree.bbox.h*s}}}class Ne extends Pe{static convertLaTextToSVG(t){return new Ti(t).svg({SCALE_X:10,SCALE_Y:10,MARGIN_X:0,MARGIN_Y:0})}render(t,e,i,n){const{scale:s}=this.options,o=e.width*s,r=e.height*s;if(this.imageCache.has(e.value)){const a=this.imageCache.get(e.value);t.drawImage(a,i,n,o,r)}else{const a=new Promise((l,u)=>{const c=new Image;c.src=e.laTexSVG,c.onload=()=>{t.drawImage(c,i,n,o,r),this.imageCache.set(e.value,c),l(e)},c.onerror=h=>{u(h)}});this.addImageObserver(a)}}}M.ListType=void 0,function(R){R.UL="ul",R.OL="ol"}(M.ListType||(M.ListType={}));var Vt;(function(R){R.DISC="disc",R.CIRCLE="circle",R.SQUARE="square"})(Vt||(Vt={}));var Te;(function(R){R.DECIMAL="decimal"})(Te||(Te={})),M.ListStyle=void 0,function(R){R.DISC="disc",R.CIRCLE="circle",R.SQUARE="square",R.DECIMAL="decimal"}(M.ListStyle||(M.ListStyle={}));const Se={[Vt.DISC]:"\u2022",[Vt.CIRCLE]:"\u25E6",[Vt.SQUARE]:"\u25AB\uFE0E"},Si={[M.ListType.OL]:"ol",[M.ListType.UL]:"ul"},gi={[M.ListStyle.DISC]:"disc",[M.ListStyle.CIRCLE]:"circle",[M.ListStyle.SQUARE]:"square",[M.ListStyle.DECIMAL]:"decimal"};M.TitleLevel=void 0,function(R){R.FIRST="first",R.SECOND="second",R.THIRD="third",R.FOURTH="fourth",R.FIFTH="fifth",R.SIXTH="sixth"}(M.TitleLevel||(M.TitleLevel={}));const Fi={defaultFirstSize:26,defaultSecondSize:24,defaultThirdSize:22,defaultFourthSize:20,defaultFifthSize:18,defaultSixthSize:16},ge={[M.TitleLevel.FIRST]:"defaultFirstSize",[M.TitleLevel.SECOND]:"defaultSecondSize",[M.TitleLevel.THIRD]:"defaultThirdSize",[M.TitleLevel.FOURTH]:"defaultFourthSize",[M.TitleLevel.FIFTH]:"defaultFifthSize",[M.TitleLevel.SIXTH]:"defaultSixthSize"},Wi={[M.TitleLevel.FIRST]:1,[M.TitleLevel.SECOND]:2,[M.TitleLevel.THIRD]:3,[M.TitleLevel.FOURTH]:4,[M.TitleLevel.FIFTH]:5,[M.TitleLevel.SIXTH]:6},Vi={H1:M.TitleLevel.FIRST,H2:M.TitleLevel.SECOND,H3:M.TitleLevel.THIRD,H4:M.TitleLevel.FOURTH,H5:M.TitleLevel.FIFTH,H6:M.TitleLevel.SIXTH};M.ControlType=void 0,function(R){R.TEXT="text",R.SELECT="select",R.CHECKBOX="checkbox"}(M.ControlType||(M.ControlType={}));var f;(function(R){R.PREFIX="prefix",R.POSTFIX="postfix",R.PLACEHOLDER="placeholder",R.VALUE="value",R.CHECKBOX="checkbox"})(f||(f={})),M.ImageDisplay=void 0,function(R){R.INLINE="inline",R.BLOCK="block"}(M.ImageDisplay||(M.ImageDisplay={}));function Fe(R){const t=[];for(let e=0;e<R.length;e++){const i=R[e],n=ht(i.value);for(let s=0;s<n.length;s++)t.push(
|
|
60
|
-
`&&R.unshift({value:C});let s=0;for(;s<R.length;){let o=R[s];if(o.type===M.ElementType.TITLE){R.splice(s,1);const r=o.valueList||[];if(at(r
|
|
59
|
+
`,a+l}boxes(t){t||(t={});const[e,i,n,s]=this.resolveScale(t),o=[];for(let r=0;r<this._tree.chld.length;r++){const{x:a,y:l,w:u,h:c}=this._tree.chld[r].bbox;o.push({x:e+a*n,y:i+l*s,w:u*n,h:c*s})}return o}box(t){t||(t={});const[e,i,n,s]=this.resolveScale(t);return{x:e+this._tree.bbox.x*n,y:i+this._tree.bbox.y*s,w:this._tree.bbox.w*n,h:this._tree.bbox.h*s}}}class Ne extends Pe{static convertLaTextToSVG(t){return new Ti(t).svg({SCALE_X:10,SCALE_Y:10,MARGIN_X:0,MARGIN_Y:0})}render(t,e,i,n){const{scale:s}=this.options,o=e.width*s,r=e.height*s;if(this.imageCache.has(e.value)){const a=this.imageCache.get(e.value);t.drawImage(a,i,n,o,r)}else{const a=new Promise((l,u)=>{const c=new Image;c.src=e.laTexSVG,c.onload=()=>{t.drawImage(c,i,n,o,r),this.imageCache.set(e.value,c),l(e)},c.onerror=h=>{u(h)}});this.addImageObserver(a)}}}M.ListType=void 0,function(R){R.UL="ul",R.OL="ol"}(M.ListType||(M.ListType={}));var Vt;(function(R){R.DISC="disc",R.CIRCLE="circle",R.SQUARE="square"})(Vt||(Vt={}));var Te;(function(R){R.DECIMAL="decimal"})(Te||(Te={})),M.ListStyle=void 0,function(R){R.DISC="disc",R.CIRCLE="circle",R.SQUARE="square",R.DECIMAL="decimal"}(M.ListStyle||(M.ListStyle={}));const Se={[Vt.DISC]:"\u2022",[Vt.CIRCLE]:"\u25E6",[Vt.SQUARE]:"\u25AB\uFE0E"},Si={[M.ListType.OL]:"ol",[M.ListType.UL]:"ul"},gi={[M.ListStyle.DISC]:"disc",[M.ListStyle.CIRCLE]:"circle",[M.ListStyle.SQUARE]:"square",[M.ListStyle.DECIMAL]:"decimal"};M.TitleLevel=void 0,function(R){R.FIRST="first",R.SECOND="second",R.THIRD="third",R.FOURTH="fourth",R.FIFTH="fifth",R.SIXTH="sixth"}(M.TitleLevel||(M.TitleLevel={}));const Fi={defaultFirstSize:26,defaultSecondSize:24,defaultThirdSize:22,defaultFourthSize:20,defaultFifthSize:18,defaultSixthSize:16},ge={[M.TitleLevel.FIRST]:"defaultFirstSize",[M.TitleLevel.SECOND]:"defaultSecondSize",[M.TitleLevel.THIRD]:"defaultThirdSize",[M.TitleLevel.FOURTH]:"defaultFourthSize",[M.TitleLevel.FIFTH]:"defaultFifthSize",[M.TitleLevel.SIXTH]:"defaultSixthSize"},Wi={[M.TitleLevel.FIRST]:1,[M.TitleLevel.SECOND]:2,[M.TitleLevel.THIRD]:3,[M.TitleLevel.FOURTH]:4,[M.TitleLevel.FIFTH]:5,[M.TitleLevel.SIXTH]:6},Vi={H1:M.TitleLevel.FIRST,H2:M.TitleLevel.SECOND,H3:M.TitleLevel.THIRD,H4:M.TitleLevel.FOURTH,H5:M.TitleLevel.FIFTH,H6:M.TitleLevel.SIXTH};M.ControlType=void 0,function(R){R.TEXT="text",R.SELECT="select",R.CHECKBOX="checkbox"}(M.ControlType||(M.ControlType={}));var f;(function(R){R.PREFIX="prefix",R.POSTFIX="postfix",R.PLACEHOLDER="placeholder",R.VALUE="value",R.CHECKBOX="checkbox"})(f||(f={})),M.ImageDisplay=void 0,function(R){R.INLINE="inline",R.BLOCK="block"}(M.ImageDisplay||(M.ImageDisplay={}));function Fe(R){const t=[];for(let e=0;e<R.length;e++){const i=R[e],n=ht(i.value);for(let s=0;s<n.length;s++)t.push($(H({},i),{value:n[s]}))}return t}function at(R,t){const{isHandleFirstElement:e,editorOptions:i}=H({isHandleFirstElement:!0},t),n=R[0];e&&(n==null?void 0:n.value)!==C&&(n==null?void 0:n.value)!==`
|
|
60
|
+
`&&R.unshift({value:C});let s=0;for(;s<R.length;){let o=R[s];if(o.type===M.ElementType.TITLE){R.splice(s,1);const r=o.valueList||[];if(at(r,$(H({},t),{isHandleFirstElement:!1})),r.length){const a=x(),l=i.title;for(let u=0;u<r.length;u++){const c=r[u];o.level&&(c.titleId=a,c.level=o.level),We(c)&&(c.size||(c.size=l[ge[c.level]]),c.bold===void 0&&(c.bold=!0)),R.splice(s,0,c),s++}}s--}else if(o.type===M.ElementType.LIST){R.splice(s,1);const r=o.valueList||[];if(at(r,H({},t)),r.length){const a=x();for(let l=0;l<r.length;l++){const u=r[l];u.listId=a,u.listType=o.listType,u.listStyle=o.listStyle,R.splice(s,0,u),s++}}s--}else if(o.type===M.ElementType.TABLE){const r=x();if(o.id=r,o.trList)for(let a=0;a<o.trList.length;a++){const l=o.trList[a],u=x();l.id=u,(!l.minHeight||l.minHeight<i.defaultTrMinHeight)&&(l.minHeight=i.defaultTrMinHeight),l.height<l.minHeight&&(l.height=l.minHeight);for(let c=0;c<l.tdList.length;c++){const h=l.tdList[c],O=x();h.id=O,at(h.value,$(H({},t),{isHandleFirstElement:!0}));for(let P=0;P<h.value.length;P++){const N=h.value[P];N.tdId=O,N.trId=u,N.tableId=r}}}}else if(o.type===M.ElementType.HYPERLINK){R.splice(s,1);const r=Fe(o.valueList||[]);if(r.length){const a=x();for(let l=0;l<r.length;l++){const u=r[l];u.type=o.type,u.url=o.url,u.hyperlinkId=a,R.splice(s,0,u),s++}}s--}else if(o.type===M.ElementType.DATE){R.splice(s,1);const r=Fe(o.valueList||[]);if(r.length){const a=x();for(let l=0;l<r.length;l++){const u=r[l];u.type=o.type,u.dateFormat=o.dateFormat,u.dateId=a,R.splice(s,0,u),s++}}s--}else if(o.type===M.ElementType.CONTROL){const{prefix:r,postfix:a,value:l,placeholder:u,code:c,type:h,valueSets:O}=o.control,{editorOptions:{control:P,checkbox:N}}=t,X=x();R.splice(s,1);const L={};i&&i.control&&(L.color=i.control.bracketColor);const g=ht(r||P.prefix);for(let V=0;V<g.length;V++){const T=g[V];R.splice(s,0,H({controlId:X,value:T,type:o.type,control:o.control,controlComponent:f.PREFIX},L)),s++}if(l&&l.length||h===M.ControlType.CHECKBOX||h===M.ControlType.SELECT&&c&&(!l||!l.length)){let V=l||[];if(h===M.ControlType.CHECKBOX){const T=c?c.split(","):[];if(Array.isArray(O)&&O.length){const W=V.reduce((Z,S)=>Z.concat(S.value.split("").map(m=>$(H({},S),{value:m}))),[]);let F=0;for(let Z=0;Z<O.length;Z++){const S=O[Z];R.splice(s,0,{controlId:X,value:"",type:o.type,control:o.control,controlComponent:f.CHECKBOX,checkbox:{code:S.code,value:T.includes(S.code)}}),s++;const m=ht(S.value);for(let I=0;I<m.length;I++){const U=m[I],Q=I===m.length-1;R.splice(s,0,$(H({},W[F]),{controlId:X,value:U,type:o.type,letterSpacing:Q?N.gap:0,control:o.control,controlComponent:f.VALUE})),F++,s++}}}}else{if((!l||!l.length)&&Array.isArray(O)&&O.length){const T=O.find(W=>W.code===c);T&&(V=[{value:T.value}])}for(let T=0;T<V.length;T++){const W=V[T],F=ht(W.value);for(let Z=0;Z<F.length;Z++){const S=F[Z];R.splice(s,0,$(H({},W),{controlId:X,value:S,type:o.type,control:o.control,controlComponent:f.VALUE})),s++}}}}else if(u){const V={};i&&i.control&&(V.color=i.control.placeholderColor);const T=ht(u);for(let W=0;W<T.length;W++){const F=T[W];R.splice(s,0,H({controlId:X,value:F,type:o.type,control:o.control,controlComponent:f.PLACEHOLDER},V)),s++}}const Y=ht(a||P.postfix);for(let V=0;V<Y.length;V++){const T=Y[V];R.splice(s,0,H({controlId:X,value:T,type:o.type,control:o.control,controlComponent:f.POSTFIX},L)),s++}s--}else if((!o.type||o.type===M.ElementType.TEXT)&&o.value.length>1){R.splice(s,1);const r=ht(o.value);for(let a=0;a<r.length;a++)R.splice(s+a,0,$(H({},o),{value:r[a]}));o=R[s]}if(o.value===`
|
|
61
61
|
`&&(o.value=C),(o.type===M.ElementType.IMAGE||o.type===M.ElementType.BLOCK)&&(o.id=x()),o.type===M.ElementType.LATEX){const{svg:r,width:a,height:l}=Ne.convertLaTextToSVG(o.value);o.width=o.width||a,o.height=o.height||l,o.laTexSVG=r,o.id=x()}s++}}function Yi(R,t){const e=Object.keys(R),i=Object.keys(t);if(e.length!==i.length)return!1;for(let n=0;n<e.length;n++){const s=e[n];if(s!=="value"&&!(s==="groupIds"&&Array.isArray(R[s])&&Array.isArray(t[s])&&ti(R[s],t[s]))&&R[s]!==t[s])return!1}return!0}function Ut(R){const t={value:R.value===C?`
|
|
62
|
-
`:R.value};return Ri.forEach(e=>{const i=R[e];i!==void 0&&(t[e]=i)}),t}function k(R){const t
|
|
62
|
+
`:R.value};return Ri.forEach(e=>{const i=R[e];i!==void 0&&(t[e]=i)}),t}function k(R){const t=j(R),e=[];let i=0;for(;i<t.length;){let n=t[i];if(i===0&&n.value===C&&(!n.type||n.type===M.ElementType.TEXT)){i++;continue}if(n.titleId&&n.level){const o=n.titleId,r=n.level,a={type:M.ElementType.TITLE,value:"",level:r},l=[];for(;i<t.length;){const u=t[i];if(o!==u.titleId){i--;break}delete u.level,l.push(u),i++}a.valueList=k(l),n=a}else if(n.listId&&n.listType){const o=n.listId,r=n.listType,a=n.listStyle,l={type:M.ElementType.LIST,value:"",listId:o,listType:r,listStyle:a},u=[];for(;i<t.length;){const c=t[i];if(o!==c.listId){i--;break}delete c.listType,delete c.listStyle,u.push(c),i++}l.valueList=k(u),n=l}else if(n.type===M.ElementType.TABLE){if(n.trList)for(let o=0;o<n.trList.length;o++){const r=n.trList[o];delete r.id;for(let a=0;a<r.tdList.length;a++){const l=r.tdList[a],u={colspan:l.colspan,rowspan:l.rowspan,value:k(l.value)};si.forEach(c=>{const h=l[c];h!==void 0&&(u[c]=h)}),r.tdList[a]=u}}}else if(n.type===M.ElementType.HYPERLINK){const o=n.hyperlinkId,r={type:M.ElementType.HYPERLINK,value:"",url:n.url},a=[];for(;i<t.length;){const l=t[i];if(o!==l.hyperlinkId){i--;break}delete l.type,delete l.url,a.push(l),i++}r.valueList=k(a),n=r}else if(n.type===M.ElementType.DATE){const o=n.dateId,r={type:M.ElementType.DATE,value:"",dateFormat:n.dateFormat},a=[];for(;i<t.length;){const l=t[i];if(o!==l.dateId){i--;break}delete l.type,delete l.dateFormat,a.push(l),i++}r.valueList=k(a),n=r}else if(n.type===M.ElementType.CONTROL){const o=n.controlId,r=n.control,a={type:M.ElementType.CONTROL,value:"",control:r},l=[];for(;i<t.length;){const u=t[i];if(o!==u.controlId){i--;break}u.controlComponent===f.VALUE&&(delete u.type,delete u.control,l.push(u)),i++}a.control.value=k(l),n=a}const s=Ut(n);if(!n.type||n.type===M.ElementType.TEXT||n.type===M.ElementType.SUBSCRIPT||n.type===M.ElementType.SUPERSCRIPT)for(;i<t.length;){const o=t[i+1];if(i++,o&&Yi(s,Ut(o))){const r=o.value===C?`
|
|
63
63
|
`:o.value;s.value+=r}else break}else i++;e.push(s)}return e}function Zi(R){switch(window.getComputedStyle(R).textAlign){case"left":case"start":return M.RowFlex.LEFT;case"center":return M.RowFlex.CENTER;case"right":case"end":return M.RowFlex.RIGHT;case"justify":return M.RowFlex.ALIGNMENT;default:return M.RowFlex.LEFT}}function We(R){return!R.type||Ft.includes(R.type)}function Bt(R,t){const e=R[t];if(!e)return null;const i=R[t+1];return!e.listId&&e.value===C&&i&&i.value!==C?i:e}function tt(R,t,e,i){var o,r;const n=Bt(R,e);if(!n)return;const{isBreakWhenWrap:s=!1}=i||{};for(let a=0;a<t.length;a++){const l=t[a];if(s&&!n.listId&&/^\n/.test(l.value))break;if(!n.listId&&l.type===M.ElementType.LIST){(o=l.valueList)==null||o.forEach(u=>{Me(Oe,n,u)});continue}((r=l.valueList)==null?void 0:r.length)&&tt(R,l.valueList,e),Me(li,n,l)}}function Ui(R,t){let e="span";R.type===M.ElementType.SUPERSCRIPT?e="sup":R.type===M.ElementType.SUBSCRIPT?e="sub":(R.rowFlex===M.RowFlex.CENTER||R.rowFlex===M.RowFlex.RIGHT)&&(e="p");const i=document.createElement(e);if(i.style.fontFamily=R.font||t.defaultFont,R.rowFlex){const n=R.rowFlex===M.RowFlex.ALIGNMENT;i.style.textAlign=n?"justify":R.rowFlex}return R.color&&(i.style.color=R.color),R.bold&&(i.style.fontWeight="600"),R.italic&&(i.style.fontStyle="italic"),i.style.fontSize=`${R.size||t.defaultSize}px`,R.highlight&&(i.style.backgroundColor=R.highlight),R.underline&&(i.style.textDecoration="underline"),i.innerText=R.value.replace(new RegExp(`${C}`,"g"),`
|
|
64
64
|
`),i}function Ve(R){let t=0;const e=new Map;for(let i=0;i<R.length;i++){const n=R[i];if(n.listWrap){const s=e.get(t)||[];s.push(n),e.set(t,s)}else{const s=n.value.split(`
|
|
65
|
-
`);for(let o=0;o<s.length;o++){o>0&&(t+=1);const r=s[o],a=e.get(t)||[];a.push(
|
|
65
|
+
`);for(let o=0;o<s.length;o++){o>0&&(t+=1);const r=s[o],a=e.get(t)||[];a.push($(H({},n),{value:r})),e.set(t,a)}}}return e}function Et(R,t){function e(i){var s,o,r,a,l;const n=document.createElement("div");for(let u=0;u<i.length;u++){const c=i[u];if(c.type===M.ElementType.TABLE){const h=document.createElement("table"),O=c.trList;for(let P=0;P<O.length;P++){const N=document.createElement("tr"),X=O[P];for(let L=0;L<X.tdList.length;L++){const g=document.createElement("td");g.style.border="1px solid";const Y=X.tdList[L];g.colSpan=Y.colspan,g.rowSpan=Y.rowspan;const V=e(k(Y.value));g.innerHTML=V.innerHTML,Y.backgroundColor&&(g.style.backgroundColor=Y.backgroundColor),N.append(g)}h.append(N)}n.append(h)}else if(c.type===M.ElementType.HYPERLINK){const h=document.createElement("a");h.innerText=c.valueList.map(O=>O.value).join(""),c.url&&(h.href=c.url),n.append(h)}else if(c.type===M.ElementType.TITLE){const h=document.createElement(`h${Wi[c.level]}`),O=e(k(c.valueList));h.innerHTML=O.innerHTML,n.append(h)}else if(c.type===M.ElementType.LIST){const h=document.createElement(Si[c.listType]);c.listStyle&&(h.style.listStyleType=gi[c.listStyle]);const O=k(c.valueList);Ve(O).forEach(N=>{const X=document.createElement("li"),L=e(N);X.innerHTML=L.innerHTML,h.append(X)}),n.append(h)}else if(c.type===M.ElementType.IMAGE){const h=document.createElement("img");c.value&&(h.src=c.value,h.width=c.width,h.height=c.height),n.append(h)}else if(c.type===M.ElementType.SEPARATOR){const h=document.createElement("hr");n.append(h)}else if(c.type===M.ElementType.CHECKBOX){const h=document.createElement("input");h.type="checkbox",((s=c.checkbox)==null?void 0:s.value)&&h.setAttribute("checked","true"),n.append(h)}else if(c.type===M.ElementType.TAB){const h=document.createElement("span");h.innerHTML=`${Re}${Re}`,n.append(h)}else if(!c.type||c.type===M.ElementType.LATEX||Ft.includes(c.type)){let h="";if(c.type===M.ElementType.CONTROL?h=((r=(o=c.control.value)==null?void 0:o[0])==null?void 0:r.value)||"":c.type===M.ElementType.DATE?h=((a=c.valueList)==null?void 0:a.map(P=>P.value).join(""))||"":h=c.value,!h)continue;const O=Ui(c,t);((l=i[u-1])==null?void 0:l.type)===M.ElementType.TITLE&&(h=h.replace(/^\n/,"")),O.tagName==="P"&&(h=h.replace(/\n$/,"")),O.innerText=h.replace(new RegExp(`${C}`,"g"),`
|
|
66
66
|
`),n.append(O)}}return n}return e(k(R))}function Qi(R){if(!R||R.nodeType!==3)return null;const t=R.parentNode,e=t.nodeName==="FONT"?t.parentNode:t,i=Zi(e),n=R.textContent,s=window.getComputedStyle(e);if(!n||e.nodeName==="STYLE")return null;const o={value:n,color:s.color,bold:Number(s.fontWeight)>500,italic:s.fontStyle.includes("italic"),size:Math.floor(parseFloat(s.fontSize))};return e.nodeName==="SUB"||s.verticalAlign==="sub"?o.type=M.ElementType.SUBSCRIPT:(e.nodeName==="SUP"||s.verticalAlign==="super")&&(o.type=M.ElementType.SUPERSCRIPT),i!==M.RowFlex.LEFT&&(o.rowFlex=i),s.backgroundColor!=="rgba(0, 0, 0, 0)"&&(o.highlight=s.backgroundColor),s.textDecorationLine==="underline"&&(o.underline=!0),o}function Qt(R,t){const e=[];function i(o){if(o.nodeType===3){const r=Qi(o);r&&e.push(r)}else if(o.nodeType===1){const r=o.childNodes;for(let a=0;a<r.length;a++){const l=r[a];if(l.nodeName==="BR")e.push({value:`
|
|
67
67
|
`});else if(l.nodeName==="A"){const u=l,c=u.innerText;c&&e.push({type:M.ElementType.HYPERLINK,value:"",valueList:[{value:c}],url:u.href})}else if(/H[1-6]/.test(l.nodeName)){const c=Qt(l.innerHTML,t);e.push({value:"",type:M.ElementType.TITLE,level:Vi[l.nodeName],valueList:c}),l.nextSibling&&!ci.includes(l.nextSibling.nodeName)&&e.push({value:`
|
|
68
68
|
`})}else if(l.nodeName==="UL"||l.nodeName==="OL"){const u=l,c={value:"",type:M.ElementType.LIST,valueList:[]};l.nodeName==="OL"?c.listType=M.ListType.OL:(c.listType=M.ListType.UL,c.listStyle=u.style.listStyleType),u.querySelectorAll("li").forEach(h=>{const O=Qt(h.innerHTML,t);O.forEach(P=>{P.value===`
|
|
@@ -75,7 +75,7 @@ trailer
|
|
|
75
75
|
`:""}`}}}else if(l.type===M.ElementType.HYPERLINK)i+=l.valueList.map(u=>u.value).join("");else if(l.type===M.ElementType.TITLE)i+=`${t(k(l.valueList))}`;else if(l.type===M.ElementType.LIST){const u=k(l.valueList),c=Ve(u);c.forEach((h,O)=>{const P=c.size-1===O;i+=`
|
|
76
76
|
${O+1}.${t(h)}${P?`
|
|
77
77
|
`:""}`})}else if(l.type===M.ElementType.CHECKBOX)i+=((n=l.checkbox)==null?void 0:n.value)?"\u2611":"\u25A1";else if(!l.type||l.type===M.ElementType.LATEX||Ft.includes(l.type)){let u="";l.type===M.ElementType.CONTROL?u=((o=(s=l.control.value)==null?void 0:s[0])==null?void 0:o.value)||"":l.type===M.ElementType.DATE?u=((r=l.valueList)==null?void 0:r.map(c=>c.value).join(""))||"":u=l.value,i+=u.replace(new RegExp(`${C}`,"g"),`
|
|
78
|
-
`)}}return i}return t(k(R))}class Ii{constructor(t,e){d(this,"draw");d(this,"container");d(this,"agentCursorDom");d(this,"canvasEvent");this.draw=t,this.container=t.getContainer(),this.canvasEvent=e;const i=document.createElement("textarea");i.autocomplete="off",i.classList.add(`${
|
|
79
|
-
`||(h.splice(P,0,L),P++)}P--}P++}}tt(r,h,o,{isBreakWhenWrap:!0})}this.draw.insertElementList(h)});else if(u.kind==="file"&&u.type.includes("image")){const c=u.getAsFile();if(c){const h=new FileReader;h.readAsDataURL(c),h.onload=()=>{const O=new Image,P=h.result;O.src=P,O.onload=()=>{const N={value:P,type:M.ElementType.IMAGE,width:O.width,height:O.height};~o&&tt(r,[N],o),this.draw.insertElementList([N])}}}}}t.preventDefault()}_compositionstart(){this.canvasEvent.compositionstart()}_compositionend(t){this.canvasEvent.compositionend(t)}}class Ki{constructor(t,e){d(this,"ANIMATION_CLASS",`${H}-cursor--animation`);d(this,"draw");d(this,"container");d(this,"options");d(this,"position");d(this,"cursorDom");d(this,"cursorAgent");d(this,"blinkTimeout");this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${H}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new Ii(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=""}_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)}drawCursor(t){let e=this.position.getCursorPosition();if(!e)return;const{scale:i,cursor:n}=this.options,{color:s,width:o,isShow:r=!0,isBlink:a=!0,isFocus:l=!0,hitLineStartIndex:u}=b(b({},n),t),c=this.draw.getHeight(),h=this.draw.getPageGap();u&&(e=this.position.getPositionList()[u]);const{metrics:O,coordinate:{leftTop:P,rightTop:N},ascent:X,pageNo:L}=e,V=(this.draw.getZone().isMainActive()?L:this.draw.getPageNo())*(c+h),T=O.height/4,W=O.height+T*2,F=this.cursorAgent.getAgentCursorDom();l&&setTimeout(()=>{F.focus(),F.setSelectionRange(0,0)});const Z=O.boundingBoxDescent<0?0:O.boundingBoxDescent,S=P[1]+X+Z-(W-T)+V,m=u?P[0]:N[0];if(F.style.left=`${m}px`,F.style.top=`${S+W-ei*i}px`,!r)return;const I=this.draw.isReadonly();this.cursorDom.style.width=`${o}px`,this.cursorDom.style.backgroundColor=s,this.cursorDom.style.left=`${m}px`,this.cursorDom.style.top=`${S}px`,this.cursorDom.style.display=I?"none":"block",this.cursorDom.style.height=`${W}px`,a?this._setBlinkTimeout():this._clearBlinkTimeout()}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:i}=t;if(!e||!i)return;const{pageNo:n,coordinate:{leftTop:s,leftBottom:o}}=e,r=n*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,a=i===rt.UP,l=o[0],u=a?s[1]+r:o[1]+r,c=qe(this.container),h={left:0,right:0,top:0,bottom:0};if(c===document.documentElement)h.right=window.innerWidth,h.bottom=window.innerHeight;else{const{left:P,right:N,top:X,bottom:L}=c.getBoundingClientRect();h.left=P,h.right=N,h.top=X,h.bottom=L}const{maskMargin:O}=this.options;if(h.top+=O[0],h.bottom-=O[2],!(l>=h.left&&l<=h.right&&u>=h.top&&u<=h.bottom)){const{scrollLeft:P,scrollTop:N}=c;a?c.scroll(P,N-(h.top-u)):c.scroll(P,N+u-h.bottom)}}}var _t;(function(R){R[R.LEFT=0]="LEFT",R[R.CENTER=1]="CENTER",R[R.RIGHT=2]="RIGHT"})(_t||(_t={}));const Nt=typeof navigator!="undefined"&&/Mac OS X/.test(navigator.userAgent),fi=typeof navigator!="undefined"&&/iPad|iPhone/.test(navigator.userAgent);function Ot(R){return Nt?R.metaKey:R.ctrlKey}M.KeyMap=void 0,function(R){R.Delete="Delete",R.Backspace="Backspace",R.Enter="Enter",R.Left="ArrowLeft",R.Right="ArrowRight",R.Up="ArrowUp",R.Down="ArrowDown",R.ESC="Escape",R.TAB="Tab",R.META="Meta",R.LEFT_BRACKET="[",R.RIGHT_BRACKET="]",R.COMMA=",",R.PERIOD=".",R.LEFT_ANGLE_BRACKET="<",R.RIGHT_ANGLE_BRACKET=">",R.EQUAL="=",R.MINUS="-",R.PLUS="+",R.A="a",R.B="b",R.C="c",R.D="d",R.E="e",R.F="f",R.G="g",R.H="h",R.I="i",R.J="j",R.K="k",R.L="l",R.M="m",R.N="n",R.O="o",R.P="p",R.Q="q",R.R="r",R.S="s",R.T="t",R.U="u",R.V="v",R.W="w",R.X="x",R.Y="y",R.Z="z",R.A_UPPERCASE="A",R.B_UPPERCASE="B",R.C_UPPERCASE="C",R.D_UPPERCASE="D",R.E_UPPERCASE="E",R.F_UPPERCASE="F",R.G_UPPERCASE="G",R.H_UPPERCASE="H",R.I_UPPERCASE="I",R.J_UPPERCASE="J",R.K_UPPERCASE="K",R.L_UPPERCASE="L",R.M_UPPERCASE="M",R.N_UPPERCASE="N",R.O_UPPERCASE="O",R.P_UPPERCASE="P",R.Q_UPPERCASE="Q",R.R_UPPERCASE="R",R.S_UPPERCASE="S",R.T_UPPERCASE="T",R.U_UPPERCASE="U",R.V_UPPERCASE="V",R.W_UPPERCASE="W",R.X_UPPERCASE="X",R.Y_UPPERCASE="Y",R.Z_UPPERCASE="Z",R.ZERO="0",R.ONE="1",R.TWO="2",R.THREE="3",R.FOUR="4",R.FIVE="5",R.SIX="6",R.SEVEN="7",R.EIGHT="8",R.NINE="9"}(M.KeyMap||(M.KeyMap={}));class kt{constructor(t,e){d(this,"element");d(this,"control");this.element=t,this.control=e}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(),i=t[e],n=[];let s=e;for(;s>0;){const r=t[s];if(r.controlId!==i.controlId||r.controlComponent===f.PREFIX)break;r.controlComponent===f.VALUE&&n.unshift(r),s--}let o=e+1;for(;o<t.length;){const r=t[o];if(r.controlId!==i.controlId||r.controlComponent===f.POSTFIX)break;r.controlComponent===f.VALUE&&n.push(r),o++}return n}setValue(){return-1}setSelect(t={}){const{control:e}=this.element,i=t.elementList||this.control.getElementList(),{startIndex:n}=t.range||this.control.getRange(),s=i[n],o=[];let r=n;for(;r>0;){const l=i[r];if(l.controlId!==s.controlId||l.controlComponent===f.PREFIX)break;if(l.controlComponent===f.CHECKBOX){const u=l.checkbox;u&&u.value&&u.code&&o.unshift(u.code)}r--}let a=n+1;for(;a<i.length;){const l=i[a];if(l.controlId!==s.controlId||l.controlComponent===f.POSTFIX)break;if(l.controlComponent===f.CHECKBOX){const u=l.checkbox;u&&u.value&&u.code&&o.push(u.code)}a++}e.code=o.join(",")}keydown(t){const e=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:n}=e;return t.key===M.KeyMap.Backspace||t.key===M.KeyMap.Delete?this.control.removeControl(i):n}cut(){return-1}}function Di(R,t){if(R.button===_t.RIGHT)return;const e=t.getDraw(),i=e.isReadonly(),n=e.getRange(),s=e.getPosition();if(!t.isAllowDrag){const m=n.getRange();if(!i&&m.startIndex!==m.endIndex&&n.getIsPointInRange(R.offsetX,R.offsetY)){t.isAllowDrag=!0,t.cacheRange=$(m),t.cacheElementList=e.getElementList(),t.cachePositionList=s.getPositionList();return}}const r=R.target.dataset.index;r&&e.setPageNo(Number(r)),t.isAllowSelection=!0;const a=s.adjustPositionContext({x:R.offsetX,y:R.offsetY});if(!a)return;const{index:l,isDirectHit:u,isCheckbox:c,isImage:h,isTable:O,tdValueIndex:P,hitLineStartIndex:N}=a;t.mouseDownStartPosition=q(b({},a),{index:O?P:l});const X=e.getElementList(),L=s.getPositionList(),g=O?P:l,Y=X[g],V=!!(u&&h),T=!!(u&&c);if(~l){n.setRange(g,g),s.setCursorPosition(L[g]);const m=T&&!i;if(m){const{checkbox:I}=Y;I?I.value=!I.value:Y.checkbox={value:!0};const Q=e.getControl().getActiveControl();Q instanceof kt&&Q.setSelect()}e.render({curIndex:g,isSubmitHistory:m,isSetCursor:!V&&!T,isCompute:!1}),N&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:N})}const W=e.getPreviewer();W.clearResizer(),V&&!i&&(W.drawResizer(Y,L[g],Y.type===M.ElementType.LATEX?{mime:"svg",srcKey:"laTexSVG"}:{}),e.getCursor().drawCursor({isShow:!1}));const F=e.getTableTool();F.dispose(),O&&!i&&F.render();const Z=e.getHyperlinkParticle();Z.clearHyperlinkPopup(),Y.type===M.ElementType.HYPERLINK&&(Ot(R)?Z.openHyperlink(Y):Z.drawHyperlinkPopup(Y,L[g]));const S=e.getDateParticle();S.clearDatePicker(),Y.type===M.ElementType.DATE&&!i&&S.renderDatePicker(Y,L[g])}function Gt(R){const t=x();return Reflect.set(R,"dragId",t),t}function bt(R,t){return t.findIndex(e=>e.dragId===R)}function mi(R,t){var e,i,n;if(t.isAllowDrop){const s=t.getDraw();if(s.isReadonly())return;const o=s.getPosition(),r=o.getPositionList(),a=s.getRange(),l=t.cacheRange,u=t.cacheElementList,c=t.cachePositionList,h=a.getRange();if(h.startIndex>=l.startIndex&&h.endIndex<=l.endIndex){a.replaceRange(b({},l)),s.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1});return}const O=u.slice(l.startIndex+1,l.endIndex+1);if(O.find(v=>v.type===M.ElementType.CONTROL)){const v=u[l.startIndex+1],st=u[l.endIndex];if(!((v.type!==M.ElementType.CONTROL||v.controlComponent===f.PREFIX)&&(st.type!==M.ElementType.CONTROL||st.controlComponent===f.POSTFIX)||v.controlId===st.controlId&&v.controlComponent===f.PREFIX&&st.controlComponent===f.POSTFIX||((e=v.control)==null?void 0:e.type)===M.ControlType.TEXT&&v.controlComponent===f.VALUE&&((i=st.control)==null?void 0:i.type)===M.ControlType.TEXT&&st.controlComponent===f.VALUE)){s.render({curIndex:h.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const N=s.getOptions(),X=s.getElementList(),L=O.map(v=>{var st;if(!v.type||v.type===M.ElementType.TEXT||((st=v.control)==null?void 0:st.type)===M.ControlType.TEXT){const Lt={value:v.value};return mt.forEach(Yt=>{const Zt=v[Yt];Zt!==void 0&&(Lt[Yt]=Zt)}),Lt}else{const Lt=$(v);return at([Lt],{isHandleFirstElement:!1,editorOptions:N}),Lt}});tt(X,L,h.startIndex);const g=Gt(u[l.startIndex]),Y=Gt(u[l.endIndex]),V=L.length;let T=h.startIndex,W=T+V;const F=s.getControl(),Z=F.getActiveControl();if(Z&&u[T].controlComponent!==f.POSTFIX?(W=Z.setValue(L),T=W-V):s.spliceElementList(X,T+1,0,...L),!~W){s.render({isSetCursor:!1});return}const S=Gt(X[T]),m=Gt(X[W]),I=bt(g,u),U=bt(Y,u),Q=u[U];Q.type===M.ElementType.CONTROL&&Q.controlComponent!==f.POSTFIX?(a.replaceRange(q(b({},l),{startIndex:I,endIndex:U})),(n=F.getActiveControl())==null||n.cut()):s.spliceElementList(u,I+1,U-I);const D=X[h.startIndex],K=u[l.startIndex],E=r[h.startIndex],y=c[l.startIndex],p=o.getPositionContext();let G=p.index;G&&(D.tableId&&!K.tableId?y.index<G&&(G-=V):!D.tableId&&K.tableId&&E.index<G&&(G+=V),o.setPositionContext(q(b({},p),{index:G})));const w=bt(S,X),A=bt(m,X);a.setRange(w,A,h.tableId,h.startTdIndex,h.endTdIndex,h.startTrIndex,h.endTrIndex),s.render({isSetCursor:!1})}else t.isAllowDrag&&t.mousedown(R)}function pi(R,t){const i=t.getDraw().getPageContainer(),{x:n,y:s,width:o,height:r}=i.getBoundingClientRect();R.x>=n&&R.x<=n+o&&R.y>=s&&R.y<=s+r||t.setIsAllowSelection(!1)}function Hi(R,t){const e=t.getDraw();if(t.isAllowDrag){const V=R.offsetX,T=R.offsetY,{startIndex:W,endIndex:F}=t.cacheRange,Z=t.cachePositionList;for(let S=W+1;S<=F;S++){const{coordinate:{leftTop:m,rightBottom:I}}=Z[S];if(V>=m[0]&&V<=I[0]&&T>=m[1]&&T<=I[1])return}t.dragover(R),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const n=R.target.dataset.index;n&&e.setPageNo(Number(n));const o=e.getPosition().getPositionByXY({x:R.offsetX,y:R.offsetY});if(!~o.index)return;const{index:r,isTable:a,tdValueIndex:l,tdIndex:u,trIndex:c,tableId:h}=o,{index:O,isTable:P,tdIndex:N,trIndex:X,tableId:L}=t.mouseDownStartPosition,g=a?l:r,Y=e.getRange();if(a&&P&&(u!==N||c!==X))Y.setRange(g,g,h,N,u,X,c);else{let V=~g?g:0;if((P||a)&&L!==h)return;let T=O;if(T>V&&([T,V]=[V,T]),T===V)return;Y.setRange(T,V)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function Ei(R,t){var L,g,Y,V;if(t.isComposing)return;const e=t.getDraw(),i=e.getPosition(),n=i.getCursorPosition();if(!n)return;const s=e.isReadonly(),o=e.getHistoryManager(),r=e.getElementList(),a=i.getPositionList(),{index:l}=n,u=e.getRange(),{startIndex:c,endIndex:h}=u.getRange(),O=c===h,P=e.getControl(),N=P.isPartRangeInControlOutside(),X=P.getActiveControl();if(R.key===M.KeyMap.Backspace){if(s||N)return;let T;if(X)T=P.keydown(R);else{if(O&&r[l].value===C&&l===0){R.preventDefault();return}const W=r[c];if(O&&W.rowFlex&&W.value===C){const F=e.getRowList(),Z=a[c].rowNo;F[Z].elementList.forEach(m=>{delete m.rowFlex})}O?e.spliceElementList(r,l,1):e.spliceElementList(r,c+1,h-c),T=O?l-1:c}u.setRange(T,T),e.render({curIndex:T})}else if(R.key===M.KeyMap.Delete){if(s||N)return;let T;X?T=P.keydown(R):((L=r[h+1])==null?void 0:L.type)===M.ElementType.CONTROL?T=P.removeControl(h+1):(O?e.spliceElementList(r,l+1,1):e.spliceElementList(r,c+1,h-c),T=O?l:c),u.setRange(T,T),e.render({curIndex:T})}else if(R.key===M.KeyMap.Enter){if(s||N)return;const T={value:C},W=r[c],F=r[h];R.shiftKey&&W.listId&&(T.listWrap=!0),F.titleId&&F.titleId!==((g=r[h+1])==null?void 0:g.titleId)||tt(r,[T],c);let Z;X&&!P.isRangInPostfix()?Z=P.setValue([T]):(O?e.spliceElementList(r,l+1,0,T):e.spliceElementList(r,c+1,h-c,T),Z=l+1),~Z&&(u.setRange(Z,Z),e.render({curIndex:Z})),R.preventDefault()}else if(R.key===M.KeyMap.Left){if(s)return;if(l>0){const T=i.getCursorPosition();let W=1;if(Ot(R)){const I=e.getLetterReg(),U=R.shiftKey&&!O&&c===(T==null?void 0:T.index)?h:c;if(I.test((Y=r[U])==null?void 0:Y.value)){let Q=U-1;for(;Q>0;){const D=r[Q];if(!I.test(D.value))break;W++,Q--}}}const F=c-W;let Z=F,S=F;if(R.shiftKey&&T&&(c!==h?c===T.index?(Z=c,S=h-W):(Z=F,S=h):S=h),!~Z||!~S)return;u.setRange(Z,S);const m=Z===S;e.render({curIndex:m?Z:void 0,isSetCursor:m,isSubmitHistory:!1,isCompute:!1}),R.preventDefault()}}else if(R.key===M.KeyMap.Right){if(s)return;if(l<a.length){const T=i.getCursorPosition();let W=1;if(Ot(R)){const U=e.getLetterReg(),Q=R.shiftKey&&!O&&c===(T==null?void 0:T.index)?h:c;if(U.test((V=r[Q+1])==null?void 0:V.value)){let D=Q+2;for(;D<r.length;){const K=r[D];if(!U.test(K.value))break;W++,D++}}}const F=h+W;let Z=F,S=F;R.shiftKey&&T&&(c!==h?c===T.index?(Z=c,S=F):(Z=c+W,S=h):Z=c);const m=r.length-1;if(Z>m||S>m)return;u.setRange(Z,S);const I=Z===S;e.render({curIndex:I?Z:void 0,isSetCursor:I,isSubmitHistory:!1,isCompute:!1}),R.preventDefault()}}else if(R.key===M.KeyMap.Up||R.key===M.KeyMap.Down){if(s)return;let T=n;R.shiftKey&&(c===n.index?T=a[h]:T=a[c]);const{index:W,rowNo:F,rowIndex:Z,coordinate:{leftTop:[S],rightTop:[m]}}=T,I=R.key===M.KeyMap.Up;if(I&&Z===0||!I&&Z===e.getRowCount()-1)return;const U=[];if(I){let y=W-1;for(;y>0;){const p=a[y];if(y--,p.rowNo!==F){if(U[0]&&U[0].rowNo!==p.rowNo)break;U.unshift(p)}}}else{let y=W+1;for(;y<a.length;){const p=a[y];if(y++,p.rowNo!==F){if(U[0]&&U[0].rowNo!==p.rowNo)break;U.push(p)}}}let Q=0;for(let y=0;y<U.length;y++){const p=U[y],{coordinate:{leftTop:[G],rightTop:[w]}}=p;if(y===U.length-1&&(Q=p.index),!(m<=G||S>=w)){Q=p.index;break}}if(!Q)return;let D=Q,K=Q;R.shiftKey&&(c!==h?c===n.index?D=c:K=h:I?K=h:D=c),D>K&&([D,K]=[K,D]),u.setRange(D,K);const E=D===K;e.render({curIndex:E?D:void 0,isSetCursor:E,isSubmitHistory:!1,isCompute:!1}),e.getCursor().moveCursorToVisible({cursorPosition:a[I?D:K],direction:I?rt.UP:rt.DOWN})}else if(Ot(R)&&R.key===M.KeyMap.Z){if(s)return;o.undo(),R.preventDefault()}else if(Ot(R)&&R.key===M.KeyMap.Y){if(s)return;o.redo(),R.preventDefault()}else if(Ot(R)&&R.key===M.KeyMap.C)t.copy(),R.preventDefault();else if(Ot(R)&&R.key===M.KeyMap.X)t.cut(),R.preventDefault();else if(Ot(R)&&R.key===M.KeyMap.A)t.selectAll(),R.preventDefault();else if(Ot(R)&&R.key===M.KeyMap.S){if(s)return;const T=e.getListener();T.saved&&T.saved(e.getValue());const W=e.getEventBus();W.isSubscribe("saved")&&W.emit("saved",e.getValue()),R.preventDefault()}else if(R.key===M.KeyMap.ESC){t.clearPainterStyle();const T=e.getZone();T.isMainActive()||T.setZone(M.EditorZone.MAIN),R.preventDefault()}else if(R.key===M.KeyMap.TAB){const T={type:M.ElementType.TAB,value:""};tt(r,[T],c),e.insertElementList([T]),R.preventDefault()}}function Ye(R,t){var W;const e=t.getDraw();if(e.isReadonly())return;const s=e.getPosition().getCursorPosition();if(!R||!s)return;const o=t.isComposing;if(o&&((W=t.compositionInfo)==null?void 0:W.value)===R)return;const r=e.getControl();if(r.isPartRangeInControlOutside())return;Ze(t),o||e.getCursor().clearAgentDomValue();const a=r.getActiveControl(),{TEXT:l,HYPERLINK:u,SUBSCRIPT:c,SUPERSCRIPT:h,DATE:O}=M.ElementType,P=R.replaceAll(`
|
|
80
|
-
`,C),N=e.getRange(),{startIndex:X,endIndex:L}=N.getRange(),g=e.getElementList(),Y=Bt(g,L);if(!Y)return;const V=ht(P).map(F=>{const Z={value:F},S=g[L+1];return(Y.type===l||!Y.type&&Y.value!==C||Y.type===u&&(S==null?void 0:S.type)===u||Y.type===O&&(S==null?void 0:S.type)===O||Y.type===c&&(S==null?void 0:S.type)===c||Y.type===h&&(S==null?void 0:S.type)===h)&&ni.forEach(m=>{if(m==="groupIds"&&!(S==null?void 0:S.groupIds))return;const I=Y[m];I!==void 0&&(Z[m]=I)}),o&&(Z.underline=!0),Z});let T;if(a&&!r.isRangInPostfix())T=r.setValue(V);else{const F=X+1;X!==L&&e.spliceElementList(g,F,L-X),tt(g,V,X),e.spliceElementList(g,F,0,...V),T=X+V.length}~T&&(N.setRange(T,T),e.render({curIndex:T,isSubmitHistory:!o})),o&&(t.compositionInfo={elementList:g,value:P,startIndex:T-V.length,endIndex:T})}function Ze(R){if(!R.compositionInfo)return;const{elementList:t,startIndex:e,endIndex:i}=R.compositionInfo;t.splice(e+1,i-e),R.getDraw().getRange().setRange(e,e),R.compositionInfo=null}function Gi(R,t){if(!R||!t)return;const e=new Blob([R],{type:"text/plain"}),i=new Blob([t],{type:"text/html"});if(window.ClipboardItem){const n=new ClipboardItem({[e.type]:e,[i.type]:i});window.navigator.clipboard.write([n])}else{const n=document.createElement("div");n.setAttribute("contenteditable","true"),n.innerHTML=t,document.body.append(n);const s=window.getSelection(),o=document.createRange();o.selectNodeContents(n),s==null||s.removeAllRanges(),s==null||s.addRange(o),document.execCommand("copy"),n.remove()}}function Ue(R,t){const e=Et(R,t);document.body.append(e);const i=e.innerText;e.remove();const n=e.innerHTML;!i||!n||Gi(i,n)}function bi(R){const t=R.getDraw(),e=t.getRange(),{startIndex:i,endIndex:n}=e.getRange();if(!~i&&!~i||t.isReadonly())return;const o=t.getControl();if(o.isPartRangeInControlOutside())return;const a=o.getActiveControl(),l=t.getElementList();let u=i,c=n;if(i===n){const N=t.getPosition().getPositionList(),X=N[i],L=X.rowNo,g=X.pageNo,Y=[];for(let T=0;T<N.length;T++){const W=N[T];if(W.pageNo>g)break;W.pageNo===g&&W.rowNo===L&&Y.push(T)}const V=Y[0]-1;u=V<0?0:V,c=Y[Y.length-1]}const h=t.getOptions();Ue(l.slice(u+1,c+1),h);let O;a?O=o.cut():(t.spliceElementList(l,u+1,c-u),O=u),e.setRange(O,O),t.render({curIndex:O})}function yi(R){const t=R.getDraw(),e=t.getRange(),i=e.getIsCollapsed()?e.getRangeRowElementList():e.getSelectionElementList();!(i==null?void 0:i.length)||Ue(i,t.getOptions())}function Ci(R,t){var i;R.preventDefault();const e=(i=R.dataTransfer)==null?void 0:i.getData("text");e&&t.input(e)}function wi(R,t){const e=R.getDraw(),i=e.getLetterReg(),n=e.getPosition();if(e.getIsPagingMode()){const h=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(!~h.index&&h.zone){e.getZone().setZone(h.zone);return}}const s=n.getCursorPosition();if(!s)return;const{value:o,index:r}=s;let a=0,l=0;const u=wt.test(o);if(u||i.test(o)){const h=e.getElementList();let O=r-1;for(;O>0;){const N=h[O].value;if(u&&wt.test(N)||!u&&i.test(N))a++,O--;else break}let P=r+1;for(;P<h.length;){const N=h[P].value;if(u&&wt.test(N)||!u&&i.test(N))l++,P++;else break}}e.getRange().setRange(r-a-1,r+l),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function Ji(R){const t=R.getDraw(),i=t.getPosition().getCursorPosition();if(!i)return;const{index:n}=i,s=t.getElementList();let o=0,r=0,a=n-1;for(;a>0&&s[a].value!==C;)o++,a--;let l=n+1;for(;l<s.length&&s[l].value!==C;)r++,l++;t.getRange().setRange(n-o-1,n+r),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}var Qe={dblclick:wi,threeClick:Ji};function xi(R){R.isComposing=!0}function vi(R,t){R.isComposing=!1;const e=R.getDraw();if(t.data)setTimeout(()=>{R.compositionInfo&&Ye(t.data,R)});else{Ze(R);const n=e.getRange(),{endIndex:s}=n.getRange();e.render({curIndex:s,isSubmitHistory:!1})}e.getCursor().clearAgentDomValue()}var Ie={compositionstart:xi,compositionend:vi};function Bi(R,t){const e=t.getDraw();if(e.isReadonly())return;R.preventDefault();const n=e.getPageContainer();if(!ft(R.target,g=>g===n,!0))return;const r=R.target.dataset.index;r&&e.setPageNo(Number(r));const a=e.getPosition(),l=a.adjustPositionContext({x:R.offsetX,y:R.offsetY});if(!l)return;const{isTable:u,tdValueIndex:c,index:h}=l,O=a.getPositionList(),P=u?c:h;~h&&(e.getRange().setRange(P,P),a.setCursorPosition(O[P]));const N=e.getCursor(),{cursor:{dragColor:X,dragWidth:L}}=e.getOptions();N.drawCursor({width:L,color:X,isBlink:!1})}var Ai={dragover:Bi};class _i{constructor(t){d(this,"isAllowSelection");d(this,"isComposing");d(this,"compositionInfo");d(this,"isAllowDrag");d(this,"isAllowDrop");d(this,"cacheRange");d(this,"cacheElementList");d(this,"cachePositionList");d(this,"mouseDownStartPosition");d(this,"draw");d(this,"pageContainer");d(this,"pageList");d(this,"range");d(this,"position");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.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)),ze(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)return;const e=this.range.getSelection();if(!e)return;const i=Object.keys(t);e.forEach(s=>{i.forEach(o=>{const r=o;s[r]=t[r]})}),this.draw.render({isSetCursor:!1});const n=this.draw.getPainterOptions();(!n||!n.isDblclick)&&this.clearPainterStyle()}selectAll(){const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}mousemove(t){Hi(t,this)}mousedown(t){Di(t,this)}click(){fi&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){mi(t,this)}mouseleave(t){pi(t,this)}keydown(t){Ei(t,this)}dblclick(t){Qe.dblclick(this,t)}threeClick(){Qe.threeClick(this)}input(t){Ye(t,this)}cut(){bi(this)}copy(){yi(this)}compositionstart(){Ie.compositionstart(this)}compositionend(t){Ie.compositionend(this,t)}drop(t){Ci(t,this)}dragover(t){Ai.dragover(t,this)}}class ki{constructor(t,e){d(this,"draw");d(this,"options");d(this,"cursor");d(this,"canvasEvent");d(this,"range");d(this,"previewer");d(this,"tableTool");d(this,"hyperlinkParticle");d(this,"control");d(this,"dateParticle");d(this,"dprMediaQueryList");d(this,"clearSideEffect",t=>{if(!this.cursor)return;const e=(t==null?void 0:t.composedPath()[0])||t.target,i=this.draw.getPageList();if(ft(e,o=>i.includes(o),!0)){this.setRangeStyle();return}if(ft(e,o=>!!o&&o.nodeType===1&&!!o.getAttribute(gt),!0)){this.setRangeStyle(),this.watchCursorActive();return}this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker()});d(this,"setCanvasEventAbility",()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)});d(this,"setRangeStyle",()=>{this.range.setRangeStyle()});d(this,"setPageScale",t=>{if(!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const i=e*10+1;i<=30&&this.draw.setPageScale(i/10)}else{const i=e*10-1;i>=5&&this.draw.setPageScale(i/10)}});d(this,"_handleVisibilityChange",()=>{var t;if(document.visibilityState){const e=this.range.getIsCollapsed();(t=this.cursor)==null||t.drawCursor({isShow:e})}});d(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.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("keyup",this.setRangeStyle),document.addEventListener("click",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("keyup",this.setRangeStyle),document.removeEventListener("click",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?void 0:t.getAgentIsActive())||(e=this.cursor)==null||e.drawCursor({isFocus:!1,isBlink:!1})})}}class zi{constructor(t){d(this,"undoStack",[]);d(this,"redoStack",[]);d(this,"maxRecordCount");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}recovery(){this.undoStack=[],this.redoStack=[]}}M.EditorComponent=void 0,function(R){R.COMPONENT="component",R.MENU="menu",R.MAIN="main",R.FOOTER="footer",R.CONTEXTMENU="contextmenu",R.POPUP="popup",R.CATALOG="catalog",R.COMMENT="comment"}(M.EditorComponent||(M.EditorComponent={}));var Xt;(function(R){R.PAGE="page",R.TABLE="table"})(Xt||(Xt={})),M.EditorMode=void 0,function(R){R.EDIT="edit",R.CLEAN="clean",R.READONLY="readonly",R.FORM="form",R.PRINT="print"}(M.EditorMode||(M.EditorMode={})),M.EditorZone=void 0,function(R){R.HEADER="header",R.MAIN="main",R.FOOTER="footer"}(M.EditorZone||(M.EditorZone={})),M.PageMode=void 0,function(R){R.PAGING="paging",R.CONTINUITY="continuity"}(M.PageMode||(M.PageMode={})),M.PaperDirection=void 0,function(R){R.VERTICAL="vertical",R.HORIZONTAL="horizontal"}(M.PaperDirection||(M.PaperDirection={})),M.WordBreak=void 0,function(R){R.BREAK_ALL="break-all",R.BREAK_WORD="break-word"}(M.WordBreak||(M.WordBreak={}));class $i{constructor(t){d(this,"cursorPosition");d(this,"positionContext");d(this,"positionList");d(this,"draw");d(this,"options");this.positionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.options=t.getOptions()}getTablePositionList(t){const{index:e,trIndex:i,tdIndex:n}=this.positionContext;return t[e].trList[i].tdList[n].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}computePageRowPosition(t){const{positionList:e,rowList:i,pageNo:n,startX:s,startY:o,startRowIndex:r,startIndex:a,innerWidth:l}=t,{scale:u,tdPadding:c}=this.options;let h=s,O=o,P=a;for(let N=0;N<i.length;N++){const X=i[N];X.rowFlex===M.RowFlex.CENTER?h+=(l-X.width)/2:X.rowFlex===M.RowFlex.RIGHT&&(h+=l-X.width),X.isList&&(h+=X.offsetX||0);const L=h,g=O;for(let Y=0;Y<X.elementList.length;Y++){const V=X.elementList[Y],T=V.metrics,W=V.imgDisplay!==M.ImageDisplay.INLINE&&V.type===M.ElementType.IMAGE||V.type===M.ElementType.LATEX?X.ascent-T.height:X.ascent;V.left&&(h+=V.left);const F={pageNo:n,index:P,value:V.value,rowIndex:r+N,rowNo:N,metrics:T,left:V.left||0,ascent:W,lineHeight:X.height,isFirstLetter:Y===0,isLastLetter:Y===X.elementList.length-1,coordinate:{leftTop:[h,O],leftBottom:[h,O+X.height],rightTop:[h+T.width,O],rightBottom:[h+T.width,O+X.height]}};if(e.push(F),P++,h+=T.width,V.type===M.ElementType.TABLE){const Z=c[1]+c[3],S=c[0]+c[2];for(let m=0;m<V.trList.length;m++){const I=V.trList[m];for(let U=0;U<I.tdList.length;U++){const Q=I.tdList[U];Q.positionList=[];const D=Q.rowList,K=this.computePageRowPosition({positionList:Q.positionList,rowList:D,pageNo:n,startRowIndex:0,startIndex:0,startX:(Q.x+c[3])*u+L,startY:(Q.y+c[0])*u+g,innerWidth:(Q.width-Z)*u});if(Q.verticalAlign===M.VerticalAlign.MIDDLE||Q.verticalAlign===M.VerticalAlign.BOTTOM){const E=D.reduce((G,w)=>G+w.height,0),y=(Q.height-S)*u-E,p=Q.verticalAlign===M.VerticalAlign.MIDDLE?y/2:y;Math.floor(p)>0&&Q.positionList.forEach(G=>{const{coordinate:{leftTop:w,leftBottom:A,rightBottom:v,rightTop:st}}=G;w[1]+=p,A[1]+=p,v[1]+=p,st[1]+=p})}h=K.x,O=K.y}}h=L,O=g}}h=s,O+=X.height}return{x:h,y:O,index:P}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),i=this.draw.getMargins(),n=i[3],o=this.draw.getHeader().getExtraHeight(),r=i[0]+o;let a=0;for(let l=0;l<e.length;l++){const u=e[l],c=u[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:u,pageNo:l,startRowIndex:a,startIndex:c,startX:n,startY:r,innerWidth:t}),a+=u.length}}setCursorPosition(t){this.cursorPosition=t}getCursorPosition(){return this.cursorPosition}getPositionContext(){return this.positionContext}setPositionContext(t){this.positionContext=t}getPositionByXY(t){var N,X;const{x:e,y:i,isTable:n}=t;let{elementList:s,positionList:o}=t;s||(s=this.draw.getOriginalElementList()),o||(o=this.getOriginalPositionList());const r=this.draw.getZone(),a=this.draw.getPageNo(),l=r.isMainActive(),u=l?a:0;for(let L=0;L<o.length;L++){const{index:g,pageNo:Y,left:V,isFirstLetter:T,coordinate:{leftTop:W,rightTop:F,leftBottom:Z}}=o[L];if(u===Y&&W[0]-V<=e&&F[0]>=e&&W[1]<=i&&Z[1]>=i){let S=L;const m=s[L];if(m.type===M.ElementType.TABLE)for(let U=0;U<m.trList.length;U++){const Q=m.trList[U];for(let D=0;D<Q.tdList.length;D++){const K=Q.tdList[D],E=this.getPositionByXY({x:e,y:i,td:K,tablePosition:o[L],isTable:!0,elementList:K.value,positionList:K.positionList});if(~E.index){const{index:y,hitLineStartIndex:p}=E,G=K.value[y];return{index:g,isCheckbox:G.type===M.ElementType.CHECKBOX||G.controlComponent===f.CHECKBOX,isControl:G.type===M.ElementType.CONTROL,isImage:E.isImage,isDirectHit:E.isDirectHit,isTable:!0,tdIndex:D,trIndex:U,tdValueIndex:y,tdId:K.id,trId:Q.id,tableId:m.id,hitLineStartIndex:p}}}}if(m.type===M.ElementType.IMAGE||m.type===M.ElementType.LATEX)return{index:S,isDirectHit:!0,isImage:!0};if(m.type===M.ElementType.CHECKBOX||m.controlComponent===f.CHECKBOX)return{index:S,isDirectHit:!0,isCheckbox:!0};let I;if(s[g].value!==C){const U=F[0]-W[0];e<W[0]+U/2&&(S=L-1,T&&(I=L))}return{hitLineStartIndex:I,index:S,isControl:m.type===M.ElementType.CONTROL}}}let c=!1,h=-1,O;if(n){const{scale:L}=this.options,{td:g,tablePosition:Y}=t;if(g&&Y){const{leftTop:V}=Y.coordinate,T=g.x*L+V[0],W=g.y*L+V[1],F=g.width*L,Z=g.height*L;if(!(T<e&&e<T+F&&W<i&&i<W+Z))return{index:h}}}const P=o.filter(L=>L.isLastLetter&&L.pageNo===u);for(let L=0;L<P.length;L++){const{index:g,pageNo:Y,coordinate:{leftTop:V,leftBottom:T}}=P[L];if(u===Y&&i>V[1]&&i<=T[1]){if(e<this.options.margins[3]){const F=o.findIndex(Z=>Z.pageNo===u&&Z.rowNo===P[L].rowNo);~F?o[F].value===C?h=F:(h=F-1,O=F):h=g}else h=g;c=!0;break}}if(!c){const L=this.draw.getHeader(),g=L.getHeaderTop()+L.getHeight(),Y=this.draw.getFooter(),T=this.draw.getHeight()-(Y.getFooterBottom()+Y.getHeight());if(l){if(i<g)return{index:-1,zone:M.EditorZone.HEADER};if(i>T)return{index:-1,zone:M.EditorZone.FOOTER}}else if(i<=T&&i>=g)return{index:-1,zone:M.EditorZone.MAIN};return{index:((N=P[P.length-1])==null?void 0:N.index)||o.length-1}}return{hitLineStartIndex:O,index:h,isControl:((X=s[h])==null?void 0:X.type)===M.ElementType.CONTROL}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==M.EditorMode.READONLY){const{index:h,isTable:O,trIndex:P,tdIndex:N,tdValueIndex:X}=e,L=this.draw.getControl(),{newIndex:g}=L.moveCursor({index:h,isTable:O,trIndex:P,tdIndex:N,tdValueIndex:X});O?e.tdValueIndex=g:e.index=g}const{index:i,isCheckbox:n,isControl:s,isTable:o,trIndex:r,tdIndex:a,tdId:l,trId:u,tableId:c}=e;return this.setPositionContext({isTable:o||!1,isCheckbox:n||!1,isControl:s||!1,index:i,trIndex:r,tdIndex:a,tdId:l,trId:u,tableId:c}),e}}class ji{constructor(t){d(this,"draw");d(this,"options");d(this,"range");d(this,"listener");d(this,"eventBus");d(this,"position");d(this,"historyManager");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}}getRange(){return this.range}clearRange(){this.setRange(-1,-1)}getIsCollapsed(){const{startIndex:t,endIndex:e}=this.range;return t===e}getSelection(){const{startIndex:t,endIndex:e}=this.range;return t===e?null:this.draw.getElementList().slice(t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let i=0;i<t.length;i++){const n=t[i];for(let s=0;s<n.length;s++){const o=n[s];e.push(...o.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||Ft.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Ft.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const i=this.position.getPositionList(),n=new Map;for(let s=t;s<e+1;s++){const{pageNo:o,rowNo:r}=i[s],a=n.get(o);a?a.has(r)||a.add(r):n.set(o,new Set([r]))}return n}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:i}=this.range;if(!~t&&!~e)return null;if(i)return this.getSelectionElementList();const n=this.getRangeRow();if(!n)return null;const s=this.position.getPositionList(),o=this.draw.getElementList(),r=[];for(let a=0;a<s.length;a++){const l=s[a],u=n.get(l.pageNo);!u||u.has(l.rowNo)&&r.push(o[a])}return r}getRangeParagraph(){var a,l,u;const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const i=this.position.getPositionList(),n=this.draw.getElementList(),s=new Map;let o=t;for(;o>=0;){const{pageNo:c,rowNo:h}=i[o];let O=s.get(c);if(O||(O=[],s.set(c,O)),O.includes(h)||O.unshift(h),((a=i[o])==null?void 0:a.value)===C||n[o].titleId!==((l=n[o-1])==null?void 0:l.titleId))break;o--}if(t!==e){let c=t+1;for(;c<e;){const{pageNo:h,rowNo:O}=i[c];let P=s.get(h);P||(P=[],s.set(h,P)),P.includes(O)||P.push(O),c++}}let r=e;for(;r<i.length&&!(i[r].value===C||n[r].titleId!==((u=n[r+1])==null?void 0:u.titleId));){const{pageNo:c,rowNo:h}=i[r];let O=s.get(c);O||(O=[],s.set(c,O)),O.includes(h)||O.push(h),r++}return s}getRangeParagraphElementList(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const i=[],n=this.getRangeParagraph();if(!n)return null;const s=this.draw.getElementList(),o=this.position.getPositionList();for(let r=0;r<o.length;r++){const a=o[r],l=n.get(a.pageNo);!l||l.includes(a.rowNo)&&i.push(s[r])}return i}getIsSelectAll(){const t=this.draw.getElementList(),{startIndex:e,endIndex:i}=this.range;return e===0&&t.length-1===i}getIsPointInRange(t,e){const{startIndex:i,endIndex:n}=this.range,s=this.position.getPositionList();for(let o=i+1;o<=n;o++){const{coordinate:{leftTop:r,rightBottom:a}}=s[o];if(t>=r[0]&&t<=a[0]&&e>=r[1]&&e<=a[1])return!0}return!1}setRange(t,e,i,n,s,o,r){this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=i,this.range.startTdIndex=n,this.range.endTdIndex=s,this.range.startTrIndex=o,this.range.endTrIndex=r,this.range.isCrossRowCol=!!(n||s||o||r),this.range.zone=this.draw.getZone().getZone();const a=this.draw.getControl();if(~t&&~e){const u=this.draw.getElementList()[t];if((u==null?void 0:u.type)===M.ElementType.CONTROL){a.initControl();return}}a.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}setRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:i,endIndex:n,isCrossRowCol:s}=this.range;if(!~i&&!~n)return;let o;if(s){const U=this.draw.getOriginalElementList(),Q=this.position.getPositionContext();o=U[Q.index]}else{const U=~n?n:0,Q=this.draw.getElementList();o=Bt(Q,U)}if(!o)return;const r=this.getSelection()||[o],a=o.type||M.ElementType.TEXT,l=o.font||this.options.defaultFont,u=o.size||this.options.defaultSize,c=!~r.findIndex(U=>!U.bold),h=!~r.findIndex(U=>!U.italic),O=!~r.findIndex(U=>{var Q;return!U.underline&&!((Q=U.control)==null?void 0:Q.underline)}),P=!~r.findIndex(U=>!U.strikeout),N=o.color||null,X=o.highlight||null,L=o.rowFlex||null,g=o.rowMargin||this.options.defaultRowMargin,Y=o.dashArray||[],V=o.level||null,T=o.listType||null,W=o.listStyle||null,F=!!this.draw.getPainterStyle(),Z=this.historyManager.isCanUndo(),S=this.historyManager.isCanRedo(),m=o.groupIds||null,I={type:a,undo:Z,redo:S,painter:F,font:l,size:u,bold:c,italic:h,underline:O,strikeout:P,color:N,highlight:X,rowFlex:L,rowMargin:g,dashArray:Y,level:V,listType:T,listStyle:W,groupIds:m};t&&t(I),e&&this.eventBus.emit("rangeStyleChange",I)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const i=this.options.defaultFont,n=this.options.defaultSize,s=this.options.defaultRowMargin,o=!!this.draw.getPainterStyle(),r=this.historyManager.isCanUndo(),a=this.historyManager.isCanRedo(),l={type:null,undo:r,redo:a,painter:o,font:i,size:n,bold:!1,italic:!1,underline:!1,strikeout:!1,color:null,highlight:null,rowFlex:null,rowMargin:s,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null};t&&t(l),e&&this.eventBus.emit("rangeStyleChange",l)}shrinkBoundary(){const t=this.draw.getElementList(),e=this.getRange(),{startIndex:i,endIndex:n}=e,s=t[i],o=t[n];if(i===n){if(s.controlComponent===f.PLACEHOLDER){let r=i-1;for(;r>0;){const a=t[r];if(a.controlId!==s.controlId||a.controlComponent===f.PREFIX){e.startIndex=r,e.endIndex=r;break}r--}}}else{if(s.controlComponent===f.PLACEHOLDER||o.controlComponent===f.PLACEHOLDER){let r=n-1;for(;r>0;){const a=t[r];if(a.controlId!==o.controlId||a.controlComponent===f.PREFIX){e.startIndex=r,e.endIndex=r;return}r--}}if(s.controlComponent===f.PREFIX){let r=i+1;for(;r<t.length;){const a=t[r];if(a.controlId!==s.controlId||a.controlComponent===f.VALUE){e.startIndex=r-1;break}else if(a.controlComponent===f.PLACEHOLDER){e.startIndex=r-1,e.endIndex=r-1;return}r++}}if(o.controlComponent!==f.VALUE){let r=i-1;for(;r>0;){const a=t[r];if(a.controlId!==s.controlId||a.controlComponent===f.VALUE){e.startIndex=r;break}else if(a.controlComponent===f.PLACEHOLDER){e.startIndex=r,e.endIndex=r;return}r--}}}}render(t,e,i,n,s){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,i,n,s),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(C,"g"),""):""}}class qi{constructor(t){d(this,"draw");d(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{backgroundColor:i}=this.options,n=this.draw.getCanvasWidth(e),s=this.draw.getCanvasHeight(e);t.save(),t.fillStyle=i,t.fillRect(0,0,n,s),t.restore()}}class zt{constructor(){d(this,"fillRect");d(this,"fillColor");this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,i,n,s,o){const r=!this.fillRect.width;if(!r&&this.fillColor&&this.fillColor!==o){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,i,n,s,o);return}r&&(this.fillRect.x=e,this.fillRect.y=i),s&&this.fillRect.height<s&&(this.fillRect.height=s),this.fillRect.width+=n,this.fillColor=o}}class tn extends zt{constructor(t){super();d(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:i,y:n,width:s,height:o}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(i,n,s,o),t.restore(),this.clearFillInfo()}}class en{constructor(t){d(this,"draw");d(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:i,pageMode:n}=this.options,s=this.draw.getWidth(),o=n===M.PageMode.CONTINUITY?this.draw.getCanvasHeight(e):this.draw.getHeight(),r=this.draw.getMargins(),a=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=i,t.beginPath();const l=[r[3],r[0]],u=[s-r[1],r[0]],c=[r[3],o-r[2]],h=[s-r[1],o-r[2]];t.moveTo(l[0]-a,l[1]),t.lineTo(...l),t.lineTo(l[0],l[1]-a),t.moveTo(u[0]+a,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]-a),t.moveTo(c[0]-a,c[1]),t.lineTo(...c),t.lineTo(c[0],c[1]+a),t.moveTo(h[0]+a,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+a),t.stroke(),t.restore()}}class nn{constructor(t){d(this,"draw");d(this,"options");d(this,"position");d(this,"searchKeyword");d(this,"searchNavigateIndex");d(this,"searchMatchList");this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.searchNavigateIndex=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t){this.searchKeyword=t,this.searchNavigateIndex=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 i=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const n=this.searchMatchList[t];if(i!==n.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===i)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 i=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const n=this.searchMatchList[t];if(i!==n.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===i)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:i,rightTop:n},pageNo:s}=t,o=this.draw.getHeight(),r=this.draw.getPageGap(),a=s*(o+r),l=document.createElement("div");l.style.position="absolute";const u=50;l.style.width=`${n[0]-e[0]+u}px`,l.style.height=`${i[1]-e[1]+u}px`,l.style.left=`${e[0]}px`,l.style.top=`${e[1]+a}px`,this.draw.getContainer().append(l),l.scrollIntoView(!1),l.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,i=null;for(let n=0;n<this.searchMatchList.length;n++){const s=this.searchMatchList[n];i!==s.groupId&&(i=s.groupId,e+=1)}return{index:t,count:e}}compute(t){const e=t.toLocaleLowerCase(),i=[],n=[],s=this.draw.getOriginalElementList(),o=s.length,r=[];for(let c=0;c<o;c++)s[c].type===M.ElementType.TABLE&&r.push(c);let a=0,l=0;for(;l<o-1;){const c=r.length?r[a]:o,h=s.slice(l,c);h.length&&n.push({index:l,type:Xt.PAGE,elementList:h});const O=s[c];O&&n.push({index:c,type:Xt.TABLE,elementList:[O]}),l=c+1,a++}function u(c,h,O,P){if(!c)return;const N=O.map(g=>!g.type||Ft.includes(g.type)&&g.controlComponent!==f.CHECKBOX?g.value:C).filter(Boolean).join("").toLocaleLowerCase(),X=[];let L=N.indexOf(c);for(;L!==-1;)X.push(L),L=N.indexOf(c,L+1);for(let g=0;g<X.length;g++){const Y=X[g],V=x();for(let T=0;T<c.length;T++){const W=Y+T+((P==null?void 0:P.startIndex)||0);i.push(b({type:h,index:W,groupId:V},P))}}}for(let c=0;c<n.length;c++){const h=n[c];if(h.type===Xt.TABLE){const O=h.elementList[0];for(let P=0;P<O.trList.length;P++){const N=O.trList[P];for(let X=0;X<N.tdList.length;X++){const L=N.tdList[X],g={tableIndex:h.index,trIndex:P,tdIndex:X,tdId:L.id};u(e,h.type,L.value,g)}}}else u(e,h.type,h.elementList,{startIndex:h.index})}this.searchMatchList=i}render(t,e){var a,l;if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:i,searchMatchColor:n,searchNavigateMatchColor:s}=this.options,o=this.position.getOriginalPositionList(),r=this.draw.getOriginalElementList();t.save(),t.globalAlpha=i;for(let u=0;u<this.searchMatchList.length;u++){const c=this.searchMatchList[u];let h=null;if(c.type===Xt.TABLE){const{tableIndex:W,trIndex:F,tdIndex:Z,index:S}=c;h=(l=(a=r[W])==null?void 0:a.trList[F].tdList[Z])==null?void 0:l.positionList[S]}else h=o[c.index];if(!h)continue;const{coordinate:{leftTop:O,leftBottom:P,rightTop:N},pageNo:X}=h;if(X!==e)continue;if(this.getSearchNavigateIndexList().includes(u)){t.fillStyle=s;const W=this.searchMatchList[u-1];(!W||W.groupId!==c.groupId)&&this.searchNavigateScrollIntoView(h)}else t.fillStyle=n;const g=O[0],Y=O[1],V=N[0]-O[0],T=P[1]-O[1];t.fillRect(g,Y,V,T)}t.restore()}}class Rn extends zt{constructor(t){super();d(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{strikeoutColor:e}=this.options,{x:i,y:n,width:s}=this.fillRect;t.save(),t.strokeStyle=e;const o=n+.5;t.beginPath(),t.moveTo(i,o),t.lineTo(i+s,o),t.stroke(),t.restore(),this.clearFillInfo()}}class sn extends zt{constructor(t){super();d(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{underlineColor:e}=this.options,{x:i,y:n,width:s}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e;const o=Math.floor(n+2*t.lineWidth)+.5;t.beginPath(),t.moveTo(i,o),t.lineTo(i+s,o),t.stroke(),t.restore(),this.clearFillInfo()}}class on{constructor(t){d(this,"draw");d(this,"ctx");d(this,"curX");d(this,"curY");d(this,"text");d(this,"curStyle");d(this,"curColor");d(this,"cacheMeasureText");this.draw=t,this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.cacheMeasureText=new Map}measureWord(t,e,i){const n=this.draw.getLetterReg();let s=0,o=e[i],r=i;for(;r<e.length;){const a=e[r];if(a.type&&a.type!==M.ElementType.TEXT||!n.test(a.value)){o=a;break}s+=this.measureText(t,a).width,r++}return{width:s,endElement:o}}measurePunctuationWidth(t,e){return!e||!Be.includes(e.value)?0: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 i=`${e.value}${t.font}`,n=this.cacheMeasureText.get(i);if(n)return n;const s=t.measureText(e.value);return this.cacheMeasureText.set(i,s),s}complete(){this._render(),this.text=""}record(t,e,i,n){this.ctx=t,this.text||this._setCurXY(i,n),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(i,n)),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.curColor&&(this.ctx.fillStyle=this.curColor),this.ctx.fillText(this.text,this.curX,this.curY),this.ctx.restore())}}const $t={PAGE_NO:"{pageNo}",PAGE_COUNT:"{pageCount}"},rn={bottom:60,size:12,font:"Yahei",color:"#000000",rowFlex:M.RowFlex.CENTER,format:$t.PAGE_NO,numberType:M.NumberType.ARABIC,disabled:!1,startPageNo:1,fromPageNo:0};class ln{constructor(t){d(this,"draw");d(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:i,pageMode:n,pageNumber:{size:s,font:o,color:r,rowFlex:a,numberType:l,format:u,startPageNo:c,fromPageNo:h}}=this.options;if(e<h)return;let O=u;const P=new RegExp($t.PAGE_NO);if(P.test(O)){const F=e+c-h,Z=l===M.NumberType.CHINESE?he(F):`${F}`;O=O.replace(P,Z)}const N=new RegExp($t.PAGE_COUNT);if(N.test(O)){const F=this.draw.getPageCount()-h,Z=l===M.NumberType.CHINESE?he(F):`${F}`;O=O.replace(N,Z)}const X=this.draw.getWidth(),L=n===M.PageMode.CONTINUITY?this.draw.getCanvasHeight(e):this.draw.getHeight(),g=this.draw.getPageNumberBottom(),Y=L-g;t.save(),t.fillStyle=r,t.font=`${s*i}px ${o}`;let V=0;const T=this.draw.getMargins(),{width:W}=t.measureText(O);a===M.RowFlex.CENTER?V=(X-W)/2:a===M.RowFlex.RIGHT?V=X-W-T[1]:V=T[3],t.fillText(O,V,Y),t.restore()}}class an{constructor(t){d(this,"draw");d(this,"_observer",re(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150));this.draw=t,setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}_addEvent(){document.addEventListener("scroll",this._observer)}removeEvent(){document.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),i=Math.max(document.documentElement.clientHeight,window.innerHeight),n=Math.min(e.bottom,i)-Math.max(e.top,0);return{intersectionHeight:n>0?n:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let i=0,n=0;for(let s=0;s<t.length;s++){const o=t[s],{intersectionHeight:r}=this.getElementVisibleInfo(o);if(n&&!r)break;r&&e.push(s),r>n&&(n=r,i=s)}return{intersectionPageNo:i,visiblePageNoList:e}}}class cn{constructor(t){d(this,"step",5);d(this,"thresholdPoints",[70,40,10,20]);d(this,"rangeManager");d(this,"requestAnimationFrameId");d(this,"isMousedown");d(this,"isMoving");d(this,"_mousedown",()=>{this.isMousedown=!0});d(this,"_mouseup",()=>{this.isMousedown=!1,this._stopMove()});d(this,"_mousemove",t=>{if(!this.isMousedown||this.rangeManager.getIsCollapsed())return;const{x:e,y:i}=t,n=document.documentElement.clientWidth,s=document.documentElement.clientHeight;i<this.thresholdPoints[0]?this._startMove(rt.UP):s-i<=this.thresholdPoints[1]?this._startMove(rt.DOWN):e<this.thresholdPoints[2]?this._startMove(rt.LEFT):n-e<this.thresholdPoints[3]?this._startMove(rt.RIGHT):this._stopMove()});this.requestAnimationFrameId=null,this.isMousedown=!1,this.isMoving=!1,this.rangeManager=t.getRange(),this._addEvent()}_addEvent(){document.addEventListener("mousedown",this._mousedown),document.addEventListener("mousemove",this._mousemove),document.addEventListener("mouseup",this._mouseup)}removeEvent(){document.removeEventListener("mousedown",this._mousedown),document.removeEventListener("mousemove",this._mousemove),document.removeEventListener("mouseup",this._mouseup)}_move(t){const e=window.scrollX,i=window.scrollY;t===rt.DOWN?window.scrollTo(e,i+this.step):t===rt.UP?window.scrollTo(e,i-this.step):t===rt.LEFT?window.scrollTo(e-this.step,i):window.scrollTo(e+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)}}M.TableBorder=void 0,function(R){R.ALL="all",R.EMPTY="empty",R.EXTERNAL="external"}(M.TableBorder||(M.TableBorder={})),M.TdBorder=void 0,function(R){R.BOTTOM="bottom"}(M.TdBorder||(M.TdBorder={})),M.TdSlash=void 0,function(R){R.FORWARD="forward",R.BACK="back"}(M.TdSlash||(M.TdSlash={}));class un{constructor(t){d(this,"draw");d(this,"range");d(this,"options");this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=$(t);for(let i=0;i<t.length;i++){const n=e[i];for(let s=n.tdList.length-1;s>=0;s--){const o=n.tdList[s],{rowspan:r,rowIndex:a,colIndex:l}=o,u=a+r-1;if(u!==s){const c=n.tdList.splice(s,1)[0];e[u].tdList.splice(l,0,c)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:i,tdIndex:n}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:s,startTdIndex:o,endTdIndex:r,startTrIndex:a,endTrIndex:l}=this.range.getRange(),h=this.draw.getOriginalElementList()[e].trList;if(!s)return[[h[i].tdList[n]]];let O=h[a].tdList[o],P=h[l].tdList[r];(O.x>P.x||O.y>P.y)&&([O,P]=[P,O]);const N=O.colIndex,X=P.colIndex+(P.colspan-1),L=O.rowIndex,g=P.rowIndex+(P.rowspan-1),Y=[];for(let V=0;V<h.length;V++){const T=h[V],W=[];for(let F=0;F<T.tdList.length;F++){const Z=T.tdList[F],S=Z.colIndex,m=Z.rowIndex;S>=N&&S<=X&&m>=L&&m<=g&&W.push(Z)}W.length&&Y.push(W)}return Y.length?Y:null}_drawOuterBorder(t){const{ctx:e,startX:i,startY:n,width:s,height:o,isDrawFullBorder:r}=t;e.beginPath();const a=Math.round(i),l=Math.round(n);e.translate(.5,.5),r?e.rect(a,l,s,o):(e.moveTo(a,l+o),e.lineTo(a,l),e.lineTo(a+s,l)),e.stroke(),e.translate(-.5,-.5)}_drawSlash(t,e,i,n){const{scale:s}=this.options;t.save();const o=e.width*s,r=e.height*s,a=Math.round(e.x*s+i),l=Math.round(e.y*s+n);e.slashType===M.TdSlash.FORWARD?(t.moveTo(a+o,l),t.lineTo(a,l+r)):(t.moveTo(a,l),t.lineTo(a+o,l+r)),t.stroke(),t.restore()}_drawBorder(t,e,i,n){const{colgroup:s,trList:o,borderType:r}=e;if(!s||!o)return;const{scale:a}=this.options,l=e.width*a,u=e.height*a,c=r===M.TableBorder.EMPTY,h=r===M.TableBorder.EXTERNAL;t.save(),c||this._drawOuterBorder({ctx:t,startX:i,startY:n,width:l,height:u,isDrawFullBorder:h});for(let O=0;O<o.length;O++){const P=o[O];for(let N=0;N<P.tdList.length;N++){const X=P.tdList[N];if(X.slashType&&this._drawSlash(t,X,i,n),!X.borderType&&(c||h))continue;const L=X.width*a,g=X.height*a,Y=Math.round(X.x*a+i+L),V=Math.round(X.y*a+n);t.translate(.5,.5),t.beginPath(),X.borderType===M.TdBorder.BOTTOM&&(t.moveTo(Y,V+g),t.lineTo(Y-L,V+g),t.stroke()),!c&&!h&&(t.moveTo(Y,V+g),t.moveTo(Y,V),t.lineTo(Y,V+g),t.lineTo(Y-L,V+g),t.stroke()),t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,i,n){const{trList:s}=e;if(!s)return;const{scale:o}=this.options;for(let r=0;r<s.length;r++){const a=s[r];for(let l=0;l<a.tdList.length;l++){const u=a.tdList[l];if(!u.backgroundColor)continue;t.save();const c=u.width*o,h=u.height*o,O=Math.round(u.x*o+i),P=Math.round(u.y*o+n);t.fillStyle=u.backgroundColor,t.fillRect(O,P,c,h),t.restore()}}}computeRowColInfo(t){const{colgroup:e,trList:i}=t;if(!e||!i)return;let n=0,s=0;for(let o=0;o<i.length;o++){const r=i[o],a=i.length-1===o;let l=0;for(let u=0;u<r.tdList.length;u++){const c=r.tdList[u];let h=0;if(i.length>1&&o!==0)for(let V=0;V<o;V++){const T=i[V];for(let W=0;W<T.tdList.length;W++){const F=T.tdList[W],Z=F.x,S=F.y,m=F.width,I=F.height;if(!(Z<n)){if(Z>n)break;if(Z===n&&S+I>s){const U=T.tdList[W+1];U&&F.colIndex+F.colspan!==U.colIndex?(n=U.x,h=U.colIndex):(n+=m,h+=F.colspan)}}}}let O=0;const P=r.tdList[u-1];P?(O=P.colIndex+h+1,P.colspan>1&&(O+=P.colspan-1)):O+=h;let N=0;for(let V=0;V<c.colspan;V++)N+=e[V+O].width;let X=0;for(let V=0;V<c.rowspan;V++)X+=i[V+o].height;(l===0||l>X)&&(l=X);const L=r.tdList.length-1===u;let g=a;if(!g&&c.rowspan>1){const V=i.length-1-o;g=c.rowspan-1===V}const Y=a&&L;c.isLastRowTd=L,c.isLastColTd=g,c.isLastTd=Y,c.x=n,c.y=s,c.width=N,c.height=X,c.rowIndex=o,c.colIndex=O,n+=N,L&&!Y&&(n=0,s+=l)}}}drawRange(t,e,i,n){const{scale:s,rangeAlpha:o,rangeColor:r}=this.options,{type:a,trList:l}=e;if(!l||a!==M.ElementType.TABLE)return;const{isCrossRowCol:u,startTdIndex:c,endTdIndex:h,startTrIndex:O,endTrIndex:P}=this.range.getRange();if(!u)return;let N=l[O].tdList[c],X=l[P].tdList[h];(N.x>X.x||N.y>X.y)&&([N,X]=[X,N]);const L=N.colIndex,g=X.colIndex+(X.colspan-1),Y=N.rowIndex,V=X.rowIndex+(X.rowspan-1);t.save();for(let T=0;T<l.length;T++){const W=l[T];for(let F=0;F<W.tdList.length;F++){const Z=W.tdList[F],S=Z.colIndex,m=Z.rowIndex;if(S>=L&&S<=g&&m>=Y&&m<=V){const I=Z.x*s,U=Z.y*s,Q=Z.width*s,D=Z.height*s;t.globalAlpha=o,t.fillStyle=r,t.fillRect(I+i,U+n,Q,D)}}}t.restore()}render(t,e,i,n){this._drawBackgroundColor(t,e,i,n),this._drawBorder(t,e,i,n)}}var Pt;(function(R){R.ROW="row",R.COL="col"})(Pt||(Pt={}));class hn{constructor(t){d(this,"MIN_TD_WIDTH",20);d(this,"ROW_COL_OFFSET",18);d(this,"BORDER_VALUE",4);d(this,"draw");d(this,"canvas");d(this,"options");d(this,"position");d(this,"container");d(this,"toolRowContainer");d(this,"toolColContainer");d(this,"toolBorderContainer");d(this,"anchorLine");d(this,"mousedownX");d(this,"mousedownY");this.draw=t,this.canvas=t.getPage(),this.options=t.getOptions(),this.position=t.getPosition(),this.container=t.getContainer(),this.toolRowContainer=null,this.toolColContainer=null,this.toolBorderContainer=null,this.anchorLine=null,this.mousedownX=0,this.mousedownY=0}dispose(){var t,e,i;(t=this.toolRowContainer)==null||t.remove(),(e=this.toolColContainer)==null||e.remove(),(i=this.toolBorderContainer)==null||i.remove(),this.toolRowContainer=null,this.toolColContainer=null,this.toolBorderContainer=null}render(){const{isTable:t,index:e,trIndex:i,tdIndex:n}=this.position.getPositionContext();if(!t)return;this.dispose();const{scale:s}=this.options,o=this.draw.getOriginalElementList(),r=this.position.getOriginalPositionList(),a=o[e],l=r[e],{colgroup:u,trList:c}=a,{coordinate:{leftTop:h}}=l,O=this.draw.getHeight(),P=this.draw.getPageGap(),N=this.draw.getPageNo()*(O+P),X=h[0],L=h[1]+N,g=a.trList[i].tdList[n],Y=g.rowIndex,V=g.colIndex,T=c.map(U=>U.height),W=document.createElement("div");W.classList.add(`${H}-table-tool__row`),W.style.transform=`translateX(-${this.ROW_COL_OFFSET*s}px)`;for(let U=0;U<T.length;U++){const Q=T[U]*s,D=document.createElement("div");D.classList.add(`${H}-table-tool__row__item`),U===Y&&D.classList.add("active");const K=document.createElement("div");K.classList.add(`${H}-table-tool__anchor`),K.onmousedown=E=>{this._mousedown({evt:E,element:a,index:U,order:Pt.ROW})},D.append(K),D.style.height=`${Q}px`,W.append(D)}W.style.left=`${X}px`,W.style.top=`${L}px`,this.container.append(W),this.toolRowContainer=W;const F=u.map(U=>U.width),Z=document.createElement("div");Z.classList.add(`${H}-table-tool__col`),Z.style.transform=`translateY(-${this.ROW_COL_OFFSET*s}px)`;for(let U=0;U<F.length;U++){const Q=F[U]*s,D=document.createElement("div");D.classList.add(`${H}-table-tool__col__item`),U===V&&D.classList.add("active");const K=document.createElement("div");K.classList.add(`${H}-table-tool__anchor`),K.onmousedown=E=>{this._mousedown({evt:E,element:a,index:U,order:Pt.COL})},D.append(K),D.style.width=`${Q}px`,Z.append(D)}Z.style.left=`${X}px`,Z.style.top=`${L}px`,this.container.append(Z),this.toolColContainer=Z;const S=a.height*s,m=a.width*s,I=document.createElement("div");I.classList.add(`${H}-table-tool__border`),I.style.height=`${S}px`,I.style.width=`${m}px`,I.style.left=`${X}px`,I.style.top=`${L}px`;for(let U=0;U<c.length;U++){const Q=c[U];for(let D=0;D<Q.tdList.length;D++){const K=Q.tdList[D],E=document.createElement("div");E.classList.add(`${H}-table-tool__border__row`),E.style.width=`${K.width*s}px`,E.style.height=`${this.BORDER_VALUE}px`,E.style.top=`${(K.y+K.height)*s-this.BORDER_VALUE/2}px`,E.style.left=`${K.x*s}px`,E.onmousedown=p=>{this._mousedown({evt:p,element:a,index:K.rowIndex+K.rowspan-1,order:Pt.ROW})},I.appendChild(E);const y=document.createElement("div");y.classList.add(`${H}-table-tool__border__col`),y.style.width=`${this.BORDER_VALUE}px`,y.style.height=`${K.height*s}px`,y.style.top=`${K.y*s}px`,y.style.left=`${(K.x+K.width)*s-this.BORDER_VALUE/2}px`,y.onmousedown=p=>{this._mousedown({evt:p,element:a,index:K.colIndex+K.colspan-1,order:Pt.COL})},I.appendChild(y)}}this.container.append(I),this.toolBorderContainer=I}_mousedown(t){const{evt:e,index:i,order:n,element:s}=t;this.canvas=this.draw.getPage();const{scale:o}=this.options,r=this.draw.getWidth(),a=this.draw.getHeight(),l=this.draw.getPageGap(),u=this.draw.getPageNo()*(a+l);this.mousedownX=e.x,this.mousedownY=e.y;const c=e.target,h=this.canvas.getBoundingClientRect(),O=window.getComputedStyle(c).cursor;document.body.style.cursor=O,this.canvas.style.cursor=O;let P=0,N=0;const X=document.createElement("div");X.classList.add(`${H}-table-anchor__line`),n===Pt.ROW?(X.classList.add(`${H}-table-anchor__line__row`),X.style.width=`${r}px`,P=0,N=u+this.mousedownY-h.top):(X.classList.add(`${H}-table-anchor__line__col`),X.style.height=`${a}px`,P=this.mousedownX-h.left,N=u),X.style.left=`${P}px`,X.style.top=`${N}px`,this.container.append(X),this.anchorLine=X;let L=0,g=0;const Y=V=>{const T=this._mousemove(V,n,P,N);T&&(L=T.dx,g=T.dy)};document.addEventListener("mousemove",Y),document.addEventListener("mouseup",()=>{var T;let V=!1;if(n===Pt.ROW){const W=s.trList[i],{defaultTrMinHeight:F}=this.options;g<0&&W.height+g<F&&(g=F-W.height),g&&(W.height+=g,W.minHeight=W.height,V=!0)}else{const{colgroup:W}=s;if(W&&L){const F=this.draw.getInnerWidth(),Z=W[i].width;L<0&&Z+L<this.MIN_TD_WIDTH&&(L=this.MIN_TD_WIDTH-Z);const S=(T=W[i+1])==null?void 0:T.width;L>0&&S&&S-L<this.MIN_TD_WIDTH&&(L=S-this.MIN_TD_WIDTH);const m=Z+L;let I=0;for(let U=0;U<W.length;U++){const Q=W[U];U===i+1&&(I-=L),U===i&&(I+=m),U!==i&&(I+=Q.width)}if(I>F){const U=s.width;L=F-U}L&&(W.length-1!==i&&(W[i+1].width-=L/o),W[i].width+=L/o,V=!0)}}V&&this.draw.render({isSetCursor:!1}),X.remove(),document.removeEventListener("mousemove",Y),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,i,n){if(!this.anchorLine)return null;const s=t.x-this.mousedownX,o=t.y-this.mousedownY;return e===Pt.ROW?this.anchorLine.style.top=`${n+o}px`:this.anchorLine.style.left=`${i+s}px`,t.preventDefault(),{dx:s,dy:o}}}class Mn{constructor(t){d(this,"draw");d(this,"options");d(this,"container");d(this,"hyperlinkPopupContainer");d(this,"hyperlinkDom");this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:i}=this._createHyperlinkPopupDom();this.hyperlinkDom=i,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${H}-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:[i,n]},lineHeight:s}=e,o=this.draw.getHeight(),r=this.draw.getPageGap(),a=this.draw.getPageNo()*(o+r);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${i}px`,this.hyperlinkPopupContainer.style.top=`${n+a+s}px`;const l=t.url||"#";this.hyperlinkDom.href=l,this.hyperlinkDom.title=l,this.hyperlinkDom.innerText=l}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,i,n){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,i,n),t.restore()}}class dn{constructor(t,e){d(this,"draw");d(this,"position");d(this,"options");d(this,"elementList");d(this,"rowList");d(this,"positionList");this.draw=t,this.position=t.getPosition(),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(t,this.elementList)}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),n=this.draw.getMargins()[3],s=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:n,startY:s,innerWidth:e})}getHeaderTop(){const{header:{top:t,disabled:e},scale:i}=this.options;return e?0:Math.floor(t*i)}getMaxHeight(){const{header:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*se[t])}getHeight(){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(),n=this.getHeaderTop()+e-t[0];return n<=0?0:n}render(t,e){t.globalAlpha=1;const i=this.draw.getInnerWidth(),n=this.getMaxHeight(),s=[];let o=0;for(let r=0;r<this.rowList.length;r++){const a=this.rowList[r];if(o+a.height>n)break;s.push(a),o+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:s,pageNo:e,startIndex:0,innerWidth:i,zone:M.EditorZone.HEADER})}}class On{render(t,e,i,n){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,i,n-e.metrics.height/2),t.restore()}}class Pn{render(t,e,i,n){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,i,n+e.metrics.height/2),t.restore()}}class Xn{render(t,e,i,n){t.save(),e.color&&(t.strokeStyle=e.color),e.dashArray&&e.dashArray.length&&t.setLineDash(e.dashArray),t.translate(0,.5),t.beginPath(),t.moveTo(i,n),t.lineTo(i+e.width,n),t.stroke(),t.restore()}}class Ln{constructor(t){d(this,"draw");d(this,"options");d(this,"i18n");this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,i,n){const{pageBreak:{font:s,fontSize:o,lineDash:r}}=this.options,a=this.i18n.t("pageBreak.displayName"),{scale:l,defaultRowMargin:u}=this.options,c=o*l,h=e.width,O=this.draw.getDefaultBasicRowMarginHeight()*u;t.save(),t.font=`${c}px ${s}`;const P=t.measureText(a),N=(h-P.width)/2;t.setLineDash(r),t.translate(0,.5+O),t.beginPath(),t.moveTo(i,n),t.lineTo(i+N,n),t.moveTo(i+N+P.width,n),t.lineTo(i+h,n),t.stroke(),t.fillText(a,i+N,n+P.actualBoundingBoxAscent-c/2),t.restore()}}class Nn{constructor(t){d(this,"draw");d(this,"options");this.draw=t,this.options=t.getOptions()}render(t){const{watermark:{data:e,opacity:i,font:n,size:s,color:o},scale:r}=this.options,a=this.draw.getWidth(),l=this.draw.getHeight(),u=a/2,c=l/2;t.save(),t.globalAlpha=i,t.font=`${s*r}px ${n}`,t.fillStyle=o;const h=t.measureText(e);t.translate(u,c),t.rotate(-45*Math.PI/180),t.fillText(e,-h.width/2,h.actualBoundingBoxAscent-s/2),t.restore()}}class yt{constructor(t,e){d(this,"element");d(this,"control");d(this,"isPopup");d(this,"selectDom");this.element=t,this.control=e,this.isPopup=!1,this.selectDom=null}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(),i=t[e],n=[];let s=e;for(;s>0;){const r=t[s];if(r.controlId!==i.controlId||r.controlComponent===f.PREFIX)break;r.controlComponent===f.VALUE&&n.unshift(r),s--}let o=e+1;for(;o<t.length;){const r=t[o];if(r.controlId!==i.controlId||r.controlComponent===f.POSTFIX)break;r.controlComponent===f.VALUE&&n.push(r),o++}return n}setValue(){return-1}keydown(t){const e=this.control.getElementList(),i=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:s}=i,o=e[n],r=e[s];if(t.key===M.KeyMap.Backspace)return n!==s?this.clearSelect():o.controlComponent===f.PREFIX||r.controlComponent===f.POSTFIX||o.controlComponent===f.PLACEHOLDER?this.control.removeControl(n):this.clearSelect();if(t.key===M.KeyMap.Delete){if(n!==s)return this.clearSelect();{const a=e[s+1];return o.controlComponent===f.PREFIX&&a.controlComponent===f.PLACEHOLDER||a.controlComponent===f.POSTFIX||o.controlComponent===f.PLACEHOLDER?this.control.removeControl(n):this.clearSelect()}}return s}cut(){this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();return t===e?t:this.clearSelect()}clearSelect(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:i}=t.range||this.control.getRange(),n=e[i];let s=-1,o=-1,r=i;for(;r>0;){const u=e[r];if(u.controlId!==n.controlId||u.controlComponent===f.PREFIX){s=r;break}r--}let a=i+1;for(;a<e.length;){const u=e[a];if(u.controlId!==n.controlId||u.controlComponent===f.POSTFIX){o=a-1;break}a++}return!~s||!~o?-1:(this.control.getDraw().spliceElementList(e,s+1,o-s),this.control.addPlaceholder(r),this.element.control.code=null,r)}setSelect(t,e={}){const n=this.element.control.valueSets;if(!Array.isArray(n)||!n.length)return;const s=n.find(O=>O.code===t);if(!s)return;const o=this.clearSelect(e);this.control.removePlaceholder(o);const r=e.elementList||this.control.getElementList(),a=r[o],l=a.controlComponent===f.PREFIX?de(a,mt):a,u=o+1,c=ht(s.value),h=this.control.getDraw();for(let O=0;O<c.length;O++){const P=q(b({},l),{value:c[O],controlComponent:f.VALUE});tt(r,[P],o),h.spliceElementList(r,u+O,0,P)}if(this.element.control.code=t,!e.range){const O=u+c.length-1;this.control.repaintControl(O),this.destroy()}}_createSelectPopupDom(){const e=this.element.control.valueSets;if(!Array.isArray(e)||!e.length)return;const i=this.control.getPosition();if(!i)return;const n=document.createElement("div");n.classList.add(`${H}-select-control-popup`),n.setAttribute(gt,M.EditorComponent.POPUP);const s=document.createElement("ul");for(let c=0;c<e.length;c++){const h=e[c],O=document.createElement("li");this.getCode()===h.code&&O.classList.add("active"),O.onclick=()=>{this.setSelect(h.code)},O.append(document.createTextNode(h.value)),s.append(O)}n.append(s);const{coordinate:{leftTop:[o,r]},lineHeight:a}=i,l=this.control.getPreY();n.style.left=`${o}px`,n.style.top=`${r+l+a}px`,this.control.getContainer().append(n),this.selectDom=n}awake(){var i;if(this.isPopup)return;const{startIndex:t}=this.control.getRange();((i=this.control.getElementList()[t+1])==null?void 0:i.controlId)===this.element.controlId&&(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){var t;!this.isPopup||((t=this.selectDom)==null||t.remove(),this.isPopup=!1)}}class Ke{constructor(t,e){d(this,"element");d(this,"control");this.element=t,this.control=e}getElement(){return this.element}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),i=t[e],n=[];let s=e;for(;s>0;){const r=t[s];if(r.controlId!==i.controlId||r.controlComponent===f.PREFIX)break;r.controlComponent===f.VALUE&&n.unshift(r),s--}let o=e+1;for(;o<t.length;){const r=t[o];if(r.controlId!==i.controlId||r.controlComponent===f.POSTFIX)break;r.controlComponent===f.VALUE&&n.push(r),o++}return n}setValue(t,e={}){const i=e.elementList||this.control.getElementList(),n=e.range||this.control.getRange();this.control.shrinkBoundary();const{startIndex:s,endIndex:o}=n,r=this.control.getDraw();s!==o?r.spliceElementList(i,s+1,o-s):this.control.removePlaceholder(s);const a=i[s],l=a.controlComponent===f.PREFIX?de(a,mt):a,u=n.startIndex+1;for(let c=0;c<t.length;c++){const h=q(b(b({},l),t[c]),{controlComponent:f.VALUE});tt(i,[h],s),r.spliceElementList(i,u+c,0,h)}return u+t.length-1}clearValue(t={}){const e=t.elementList||this.control.getElementList(),i=t.range||this.control.getRange(),{startIndex:n,endIndex:s}=i;return this.control.getDraw().spliceElementList(e,n+1,s-n),this.getValue().length||this.control.addPlaceholder(n),n}keydown(t){const e=this.control.getElementList(),i=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:s}=i,o=e[n],r=e[s],a=this.control.getDraw();if(t.key===M.KeyMap.Backspace)return n!==s?(a.spliceElementList(e,n+1,s-n),this.getValue().length||this.control.addPlaceholder(n),n):o.controlComponent===f.PREFIX||r.controlComponent===f.POSTFIX||o.controlComponent===f.PLACEHOLDER?this.control.removeControl(n):(a.spliceElementList(e,n,1),this.getValue().length||this.control.addPlaceholder(n-1),n-1);if(t.key===M.KeyMap.Delete){if(n!==s)return a.spliceElementList(e,n+1,s-n),this.getValue().length||this.control.addPlaceholder(n),n;{const l=e[s+1];return o.controlComponent===f.PREFIX&&l.controlComponent===f.PLACEHOLDER||l.controlComponent===f.POSTFIX||o.controlComponent===f.PLACEHOLDER?this.control.removeControl(n):(a.spliceElementList(e,n+1,1),this.getValue().length||this.control.addPlaceholder(n),n)}}return s}cut(){this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const i=this.control.getDraw(),n=this.control.getElementList();return i.spliceElementList(n,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}}class Tn{constructor(t){d(this,"draw");d(this,"range");d(this,"listener");d(this,"eventBus");d(this,"options");d(this,"activeControl");this.draw=t,this.range=t.getRange(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.options=t.getOptions().control,this.activeControl=null}getDraw(){return this.draw}filterAssistElement(t){return["header","main","footer"].forEach(i=>{t[i]=t[i].filter(n=>{var s;return n.type!==M.ElementType.CONTROL||((s=n.control)==null?void 0:s.minWidth)?!0:n.controlComponent!==f.PREFIX&&n.controlComponent!==f.POSTFIX&&n.controlComponent!==f.PLACEHOLDER})}),t}isPartRangeInControlOutside(){const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const i=this.getElementList(),n=i[t],s=i[e];return(n.type===M.ElementType.CONTROL||s.type===M.ElementType.CONTROL)&&n.controlId!==s.controlId}isRangInPostfix(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();return t!==e?!1:this.getElementList()[t].controlComponent===f.POSTFIX}isRangeWithinControl(){const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const i=this.getElementList(),n=i[t],s=i[e];return(n.type===M.ElementType.CONTROL||s.type===M.ElementType.CONTROL)&&s.controlComponent!==f.POSTFIX&&n.controlId===s.controlId}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(){const t=this.draw.getHeight(),e=this.draw.getPageGap();return this.draw.getPageNo()*(t+e)}getRange(){return this.range.getRange()}shrinkBoundary(){this.range.shrinkBoundary()}getActiveControl(){return this.activeControl}initControl(){if(this.draw.isReadonly())return;const e=this.getElementList(),i=this.getRange(),n=e[i.startIndex];if(this.activeControl){this.activeControl instanceof yt&&this.activeControl.awake();const o=this.activeControl.getElement();if(n.controlId===o.controlId)return}this.destroyControl();const s=n.control;if(s.type===M.ControlType.TEXT)this.activeControl=new Ke(n,this);else if(s.type===M.ControlType.SELECT){const o=new yt(n,this);this.activeControl=o,o.awake()}else s.type===M.ControlType.CHECKBOX&&(this.activeControl=new kt(n,this));Dt(()=>{var u;const o=this.listener.controlChange,r=this.eventBus.isSubscribe("controlChange");if(!o&&!r)return;let a;const l=(u=this.activeControl)==null?void 0:u.getValue();l&&l.length?a=k(l)[0].control:a=Ut($(n)).control,o&&o(a),r&&this.eventBus.emit("controlChange",a)})}destroyControl(){this.activeControl&&(this.activeControl instanceof yt&&this.activeControl.destroy(),this.activeControl=null,Dt(()=>{const t=this.listener.controlChange,e=this.eventBus.isSubscribe("controlChange");!t&&!e||(t&&t(null),e&&this.eventBus.emit("controlChange",null))}))}repaintControl(t){this.range.setRange(t,t),this.draw.render({curIndex:t})}moveCursor(t){const{index:e,trIndex:i,tdIndex:n,tdValueIndex:s}=t;let o=this.draw.getOriginalElementList(),r;const a=t.isTable?s:e;if(t.isTable?(o=o[e].trList[i].tdList[n].value,r=o[s]):r=o[e],r.controlComponent===f.VALUE)return{newIndex:a,newElement:r};if(r.controlComponent===f.POSTFIX){let l=a+1;for(;l<o.length;){if(o[l].controlId!==r.controlId)return{newIndex:l-1,newElement:o[l-1]};l++}}else if(r.controlComponent===f.PREFIX){let l=a+1;for(;l<o.length;){const u=o[l];if(u.controlId!==r.controlId||u.controlComponent!==f.PREFIX)return{newIndex:l-1,newElement:o[l-1]};l++}}else if(r.controlComponent===f.PLACEHOLDER){let l=a-1;for(;l>0;){const u=o[l];if(u.controlId!==r.controlId||u.controlComponent===f.PREFIX)return{newIndex:l,newElement:o[l]};l--}}return{newIndex:a,newElement:r}}removeControl(t){const e=this.getElementList(),i=e[t];let n=-1,s=-1,o=t;for(;o>0;){if(e[o].controlId!==i.controlId){n=o;break}o--}let r=t+1;for(;r<e.length;){if(e[r].controlId!==i.controlId){s=r-1;break}r++}return r===e.length&&(s=r-1),!~n&&!~s?t:(n=~n?n:0,this.draw.spliceElementList(e,n+1,s-n),n)}removePlaceholder(t){const e=this.getElementList(),i=e[t],n=e[t+1];if(i.controlComponent===f.PLACEHOLDER||n.controlComponent===f.PLACEHOLDER){let s=t;for(;s<e.length;){const o=e[s];if(o.controlId!==i.controlId)break;o.controlComponent===f.PLACEHOLDER?this.draw.spliceElementList(e,s,1):s++}}}addPlaceholder(t){const e=this.getElementList(),i=e[t],n=i.control;if(!n.placeholder)return;const s=ht(n.placeholder);for(let o=0;o<s.length;o++){const a={value:s[o],controlId:i.controlId,type:M.ElementType.CONTROL,control:i.control,controlComponent:f.PLACEHOLDER,color:this.options.placeholderColor};tt(e,[a],t),this.draw.spliceElementList(e,t+o+1,0,a)}}setValue(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.setValue(t)}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()}getValueByConceptId(t){var o;const{conceptId:e}=t,i=[...this.draw.getHeaderElementList(),...this.draw.getOriginalMainElementList(),...this.draw.getFooterElementList()],n=[];let s=0;for(;s<i.length;){const r=i[s];if(s++,((o=r==null?void 0:r.control)==null?void 0:o.conceptId)!==e)continue;const{type:a,code:l,valueSets:u}=r.control;let c=s,h="";for(;c<i.length;){const O=i[c];if(O.controlId!==r.controlId)break;a===M.ControlType.TEXT&&O.controlComponent===f.VALUE&&(h+=O.value),c++}if(a===M.ControlType.TEXT)n.push({value:h||null,innerText:h||null});else if(a===M.ControlType.SELECT||a===M.ControlType.CHECKBOX){const O=l==null?void 0:l.split(",").map(P=>{var N;return(N=u==null?void 0:u.find(X=>X.code===P))==null?void 0:N.value}).filter(Boolean).join("");n.push({value:l||null,innerText:O||null})}s=c}return n}setValueByConceptId(t){var r;if(this.draw.isReadonly())return;let i=!1;const{conceptId:n,value:s}=t,o=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of o){let l=0;for(;l<a.length;){const u=a[l];if(l++,((r=u==null?void 0:u.control)==null?void 0:r.conceptId)!==n)continue;i=!0;const{type:c}=u.control;let h=l;for(;h<a.length&&a[h].controlId===u.controlId;)h++;const O={startIndex:l-1,endIndex:h-2},P={range:O,elementList:a};if(c===M.ControlType.TEXT){const X=[{value:s}];at(X,{isHandleFirstElement:!1,editorOptions:this.draw.getOptions()});const L=new Ke(u,this);s?L.setValue(X,P):L.clearValue(P)}else if(c===M.ControlType.SELECT){const X=new yt(u,this);s?X.setSelect(s,P):X.clearSelect(P)}else if(c===M.ControlType.CHECKBOX){const X=new kt(u,this),L=a.slice(O.startIndex+1,O.endIndex+1),g=(s==null?void 0:s.split(","))||[];for(const Y of L)if(Y.controlComponent===f.CHECKBOX){const V=Y.checkbox;V.value=g.includes(V.code)}X.setSelect(P)}let N=l;for(;N<a.length&&a[N].controlId===u.controlId;)N++;l=N}}i&&this.draw.render({isSetCursor:!1})}}class Sn{constructor(t){d(this,"options");this.options=t.getOptions()}render(t,e,i,n){const{checkbox:{gap:s,lineWidth:o,fillStyle:r,fontStyle:a},scale:l}=this.options,{metrics:u,checkbox:c}=e,h=Math.round(i+s),O=Math.round(n-u.height+o),P=u.width-s*2*l,N=u.height;t.save(),t.beginPath(),t.translate(.5,.5),(c==null?void 0:c.value)?(t.lineWidth=o,t.strokeStyle=r,t.rect(h,O,P,N),t.stroke(),t.beginPath(),t.fillStyle=r,t.fillRect(h,O,P,N),t.beginPath(),t.strokeStyle=a,t.lineWidth=o*2,t.moveTo(h+2*l,O+7*l),t.lineTo(h+7*l,O+11*l),t.moveTo(h+6.5*l,O+11*l),t.lineTo(h+12*l,O+3*l),t.stroke()):(t.lineWidth=o,t.rect(h,O,P,N),t.stroke()),t.closePath(),t.restore()}}const fe="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBjOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuVEFCTEU9InRhYmxlIix0LkhZUEVSTElOSz0iaHlwZXJsaW5rIix0LkNPTlRST0w9ImNvbnRyb2wifSkoY3x8KGM9e30pKTt2YXIgdTsoZnVuY3Rpb24odCl7dC5WQUxVRT0idmFsdWUifSkodXx8KHU9e30pKTtjb25zdCBoPSJcdTIwMEIiLGc9YApgO2Z1bmN0aW9uIHAodCl7bGV0IGw9IiIsbz0wO2Zvcig7bzx0Lmxlbmd0aDspe2NvbnN0IG49dFtvXTtpZihuLnR5cGU9PT1jLlRBQkxFKXtpZihuLnRyTGlzdClmb3IobGV0IGk9MDtpPG4udHJMaXN0Lmxlbmd0aDtpKyspe2NvbnN0IHM9bi50ckxpc3RbaV07Zm9yKGxldCBlPTA7ZTxzLnRkTGlzdC5sZW5ndGg7ZSsrKXtjb25zdCByPXMudGRMaXN0W2VdO2wrPXAoci52YWx1ZSl9fX1lbHNlIGlmKG4udHlwZT09PWMuSFlQRVJMSU5LKXtjb25zdCBpPW4uaHlwZXJsaW5rSWQscz1bXTtmb3IoO288dC5sZW5ndGg7KXtjb25zdCBlPXRbb107aWYoaSE9PWUuaHlwZXJsaW5rSWQpe28tLTticmVha31kZWxldGUgZS50eXBlLHMucHVzaChlKSxvKyt9bCs9cChzKX1lbHNlIGlmKG4udHlwZT09PWMuQ09OVFJPTCl7Y29uc3QgaT1uLmNvbnRyb2xJZCxzPVtdO2Zvcig7bzx0Lmxlbmd0aDspe2NvbnN0IGU9dFtvXTtpZihpIT09ZS5jb250cm9sSWQpe28tLTticmVha31lLmNvbnRyb2xDb21wb25lbnQ9PT11LlZBTFVFJiYoZGVsZXRlIGUudHlwZSxzLnB1c2goZSkpLG8rK31sKz1wKHMpfSghbi50eXBlfHxuLnR5cGU9PT1jLlRFWFQpJiYobCs9bi52YWx1ZSksbysrfXJldHVybiBsfWZ1bmN0aW9uIGQodCl7Y29uc3QgbD1bXSxvPS9bMC05XS8sbj0vW0EtWmEtel0vLGk9L1xzLztsZXQgcz0hMSxlPSExLHI9IiI7ZnVuY3Rpb24gYSgpe3ImJihsLnB1c2gocikscj0iIil9Zm9yKGNvbnN0IGYgb2YgdCluLnRlc3QoZik/KHN8fGEoKSxyKz1mLHM9ITAsZT0hMSk6by50ZXN0KGYpPyhlfHxhKCkscis9ZixzPSExLGU9ITApOihhKCkscz0hMSxlPSExLGkudGVzdChmKXx8bC5wdXNoKGYpKTtyZXR1cm4gYSgpLGx9b25tZXNzYWdlPXQ9Pntjb25zdCBsPXQuZGF0YSxuPXAobCkucmVwbGFjZShuZXcgUmVnRXhwKGBeJHtofWApLCIiKS5yZXBsYWNlKG5ldyBSZWdFeHAoaCwiZyIpLGcpLGk9ZChuKTtwb3N0TWVzc2FnZShpLmxlbmd0aCl9fSkoKTt9KSgpOwo=",De=typeof window!="undefined"&&window.Blob&&new Blob([atob(fe)],{type:"text/javascript;charset=utf-8"});function gn(){const R=De&&(window.URL||window.webkitURL).createObjectURL(De);try{return R?new Worker(R):new Worker("data:application/javascript;base64,"+fe,{type:"module"})}finally{R&&(window.URL||window.webkitURL).revokeObjectURL(R)}}const me="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBnOyhmdW5jdGlvbihlKXtlLlRJVExFPSJ0aXRsZSJ9KShnfHwoZz17fSkpO3ZhciBvOyhmdW5jdGlvbihlKXtlLkZJUlNUPSJmaXJzdCIsZS5TRUNPTkQ9InNlY29uZCIsZS5USElSRD0idGhpcmQiLGUuRk9VUlRIPSJmb3VydGgiLGUuRklGVEg9ImZpZnRoIixlLlNJWFRIPSJzaXh0aCJ9KShvfHwobz17fSkpO2NvbnN0IHU9e1tvLkZJUlNUXToxLFtvLlNFQ09ORF06Mixbby5USElSRF06Myxbby5GT1VSVEhdOjQsW28uRklGVEhdOjUsW28uU0lYVEhdOjZ9LEk9Ilx1MjAwQiI7ZnVuY3Rpb24gZihlKXtjb25zdCBhPVtdO2xldCBzPTA7Zm9yKDtzPGUubGVuZ3RoOyl7Y29uc3QgdD1lW3NdO2lmKHQudGl0bGVJZCl7Y29uc3Qgbj10LnRpdGxlSWQsbD10LmxldmVsLGM9e3R5cGU6Zy5USVRMRSx2YWx1ZToiIixsZXZlbDpsLHRpdGxlSWQ6bn0saT1bXTtmb3IoO3M8ZS5sZW5ndGg7KXtjb25zdCB2PWVbc107aWYobiE9PXYudGl0bGVJZCl7cy0tO2JyZWFrfWkucHVzaCh2KSxzKyt9Yy52YWx1ZT1pLm1hcCh2PT52LnZhbHVlKS5qb2luKCIiKS5yZXBsYWNlKG5ldyBSZWdFeHAoSSwiZyIpLCIiKSxhLnB1c2goYyl9cysrfWlmKCFhLmxlbmd0aClyZXR1cm4gbnVsbDtjb25zdCBoPSh0LG4pPT57Y29uc3QgbD1uLnN1YkNhdGFsb2dbbi5zdWJDYXRhbG9nLmxlbmd0aC0xXSxjPXVbbD09bnVsbD92b2lkIDA6bC5sZXZlbF0saT11W3QubGV2ZWxdO2wmJmk+Yz9oKHQsbCk6bi5zdWJDYXRhbG9nLnB1c2goe2lkOnQudGl0bGVJZCxuYW1lOnQudmFsdWUsbGV2ZWw6dC5sZXZlbCxzdWJDYXRhbG9nOltdfSl9LHI9W107Zm9yKGxldCB0PTA7dDxhLmxlbmd0aDt0Kyspe2NvbnN0IG49YVt0XSxsPXJbci5sZW5ndGgtMV0sYz11W2w9PW51bGw/dm9pZCAwOmwubGV2ZWxdLGk9dVtuLmxldmVsXTtsJiZpPmM/aChuLGwpOnIucHVzaCh7aWQ6bi50aXRsZUlkLG5hbWU6bi52YWx1ZSxsZXZlbDpuLmxldmVsLHN1YkNhdGFsb2c6W119KX1yZXR1cm4gcn1vbm1lc3NhZ2U9ZT0+e2NvbnN0IGE9ZS5kYXRhLHM9ZihhKTtwb3N0TWVzc2FnZShzKX19KSgpO30pKCk7Cg==",pe=typeof window!="undefined"&&window.Blob&&new Blob([atob(me)],{type:"text/javascript;charset=utf-8"});function Fn(){const R=pe&&(window.URL||window.webkitURL).createObjectURL(pe);try{return R?new Worker(R):new Worker("data:application/javascript;base64,"+me,{type:"module"})}finally{R&&(window.URL||window.webkitURL).revokeObjectURL(R)}}const He="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBuOyhmdW5jdGlvbihvKXtvLlRBQkxFPSJ0YWJsZSJ9KShufHwobj17fSkpO2Z1bmN0aW9uIGMobyl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBvKXtpZihzLnR5cGU9PT1uLlRBQkxFKXtjb25zdCBlPXMudHJMaXN0O2ZvcihsZXQgcj0wO3I8ZS5sZW5ndGg7cisrKXtjb25zdCBpPWVbcl07Zm9yKGxldCB1PTA7dTxpLnRkTGlzdC5sZW5ndGg7dSsrKXtjb25zdCBkPWkudGRMaXN0W3VdO3QucHVzaCguLi5jKGQudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgZSBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMoZSl8fHQucHVzaChlKX1yZXR1cm4gdH1vbm1lc3NhZ2U9bz0+e2NvbnN0IHQ9by5kYXRhLHM9Yyh0KTtwb3N0TWVzc2FnZShzKX19KSgpO30pKCk7Cg==",Ee=typeof window!="undefined"&&window.Blob&&new Blob([atob(He)],{type:"text/javascript;charset=utf-8"});function Wn(){const R=Ee&&(window.URL||window.webkitURL).createObjectURL(Ee);try{return R?new Worker(R):new Worker("data:application/javascript;base64,"+He,{type:"module"})}finally{R&&(window.URL||window.webkitURL).revokeObjectURL(R)}}class Vn{constructor(t){d(this,"draw");d(this,"wordCountWorker");d(this,"catalogWorker");d(this,"groupWorker");this.draw=t,this.wordCountWorker=new gn,this.catalogWorker=new Fn,this.groupWorker=new Wn}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=n=>{t(n.data)},this.wordCountWorker.onerror=n=>{e(n)};const i=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(i)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=n=>{t(n.data)},this.catalogWorker.onerror=n=>{e(n)};const i=this.draw.getOriginalMainElementList();this.catalogWorker.postMessage(i)})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=n=>{t(n.data)},this.groupWorker.onerror=n=>{e(n)};const i=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(i)})}}class Yn{constructor(t){d(this,"container");d(this,"canvas");d(this,"draw");d(this,"options");d(this,"curElement");d(this,"curElementSrc");d(this,"previewerDrawOption");d(this,"curPosition");d(this,"resizerSelection");d(this,"resizerHandleList");d(this,"resizerImageContainer");d(this,"resizerImage");d(this,"width");d(this,"height");d(this,"mousedownX");d(this,"mousedownY");d(this,"curHandleIndex");d(this,"previewerContainer");d(this,"previewerImage");d(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;const{resizerSelection:e,resizerHandleList:i,resizerImageContainer:n,resizerImage:s}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=i,this.resizerImageContainer=n,this.resizerImage=s,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,e.ondblclick=this._dblclick.bind(this),this.previewerContainer=null,this.previewerImage=null}_createResizerDom(){const t=document.createElement("div");t.classList.add(`${H}-resizer-selection`),t.style.display="none",t.style.borderColor=this.options.resizerColor;const e=[];for(let s=0;s<8;s++){const o=document.createElement("div");o.style.background=this.options.resizerColor,o.classList.add(`handle-${s}`),o.setAttribute("data-index",String(s)),o.onmousedown=this._mousedown.bind(this),t.append(o),e.push(o)}this.container.append(t);const i=document.createElement("div");i.classList.add(`${H}-resizer-image`),i.style.display="none";const n=document.createElement("img");return i.append(n),this.container.append(i),{resizerSelection:t,resizerHandleList:e,resizerImageContainer:i,resizerImage:n}}_mousedown(t){if(this.canvas=this.draw.getPage(),!this.curPosition||!this.curElement)return;const{scale:e}=this.options,i=this.draw.getHeight(),n=this.draw.getPageGap();this.mousedownX=t.x,this.mousedownY=t.y;const s=t.target;this.curHandleIndex=Number(s.dataset.index);const o=window.getComputedStyle(s).cursor;document.body.style.cursor=o,this.canvas.style.cursor=o,this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{coordinate:{leftTop:[r,a]}}=this.curPosition,l=this.draw.getPageNo()*(i+n);this.resizerImageContainer.style.left=`${r}px`,this.resizerImageContainer.style.top=`${a+l}px`,this.resizerImage.style.width=`${this.curElement.width*e}px`,this.resizerImage.style.height=`${this.curElement.height*e}px`;const u=this._mousemove.bind(this);document.addEventListener("mousemove",u),document.addEventListener("mouseup",()=>{this.curElement&&this.curPosition&&(this.curElement.width=this.width,this.curElement.height=this.height,this.draw.render({isSetCursor:!1}),this.drawResizer(this.curElement,this.curPosition,this.previewerDrawOption)),this.resizerImageContainer.style.display="none",document.removeEventListener("mousemove",u),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.curElement)return;const{scale:e}=this.options;let i=0,n=0;switch(this.curHandleIndex){case 0:i=this.mousedownX-t.x,n=this.mousedownY-t.y;break;case 1:n=this.mousedownY-t.y;break;case 2:i=t.x-this.mousedownX,n=this.mousedownY-t.y;break;case 3:i=t.x-this.mousedownX;break;case 5:n=t.y-this.mousedownY;break;case 6:i=this.mousedownX-t.x,n=t.y-this.mousedownY;break;case 7:i=this.mousedownX-t.x;break;default:i=t.x-this.mousedownX,n=t.y-this.mousedownY;break}this.width=this.curElement.width+i,this.height=this.curElement.height+n,this.resizerImage.style.width=`${this.width*e}px`,this.resizerImage.style.height=`${this.height*e}px`,t.preventDefault()}_dblclick(){this._drawPreviewer(),document.body.style.overflow="hidden"}_drawPreviewer(){const t=document.createElement("div");t.classList.add(`${H}-image-previewer`);const e=document.createElement("i");e.classList.add("image-close"),e.onclick=()=>{this._clearPreviewer()},t.append(e);const i=document.createElement("div");i.classList.add(`${H}-image-container`);const n=document.createElement("img");n.src=this.curElementSrc,n.draggable=!1,i.append(n),this.previewerImage=n,t.append(i);let s=0,o=0,r=1,a=0;const l=document.createElement("div");l.classList.add(`${H}-image-menu`);const u=document.createElement("i");u.classList.add("zoom-in"),u.onclick=()=>{r+=.1,this._setPreviewerTransform(r,a,s,o)},l.append(u);const c=document.createElement("i");c.onclick=()=>{r-.1<=.1||(r-=.1,this._setPreviewerTransform(r,a,s,o))},c.classList.add("zoom-out"),l.append(c);const h=document.createElement("i");h.classList.add("rotate"),h.onclick=()=>{a+=1,this._setPreviewerTransform(r,a,s,o)},l.append(h);const O=document.createElement("i");O.classList.add("original-size"),O.onclick=()=>{s=0,o=0,r=1,a=0,this._setPreviewerTransform(r,a,s,o)},l.append(O);const P=document.createElement("i");P.classList.add("image-download"),P.onclick=()=>{var Y;const{mime:g}=this.previewerDrawOption;le(n.src,`${(Y=this.curElement)==null?void 0:Y.id}.${g||"png"}`)},l.append(P),t.append(l),this.previewerContainer=t,document.body.append(t);let N=0,X=0,L=!1;n.onmousedown=g=>{L=!0,N=g.x,X=g.y,t.style.cursor="move"},t.onmousemove=g=>{!L||(s+=g.x-N,o+=g.y-X,N=g.x,X=g.y,this._setPreviewerTransform(r,a,s,o))},t.onmouseup=()=>{L=!1,t.style.cursor="auto"},t.onwheel=g=>{if(g.preventDefault(),g.deltaY<0)r+=.1;else{if(r-.1<=.1)return;r-=.1}this._setPreviewerTransform(r,a,s,o)}}_setPreviewerTransform(t,e,i,n){!this.previewerImage||(this.previewerImage.style.left=`${i}px`,this.previewerImage.style.top=`${n}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"}drawResizer(t,e,i={}){this.previewerDrawOption=i;const{scale:n}=this.options,{coordinate:{leftTop:[s,o]},ascent:r}=e,a=t.width*n,l=t.height*n,u=this.draw.getHeight(),c=this.draw.getPageGap(),h=this.options.resizerSize,O=this.draw.getPageNo()*(u+c);this.resizerSelection.style.left=`${s}px`,this.resizerSelection.style.top=`${o+O+r}px`,this.resizerSelection.style.width=`${a}px`,this.resizerSelection.style.height=`${l}px`;for(let P=0;P<8;P++){const N=P===0||P===6||P===7?-h:P===1||P===5?a/2:a-h,X=P===0||P===1||P===2?-h:P===3||P===7?l/2-h:l-h;this.resizerHandleList[P].style.left=`${N}px`,this.resizerHandleList[P].style.top=`${X}px`}this.resizerSelection.style.display="block",this.curElement=t,this.curElementSrc=t[i.srcKey||"value"]||"",this.curPosition=e,this.width=this.curElement.width*n,this.height=this.curElement.height*n,document.addEventListener("keydown",this._keydown)}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}const Zn={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"}},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",borderExternal:"\u5916\u4FA7\u6846\u7EBF",borderTd:"\u5355\u5143\u683C\u8FB9\u6846",borderTdBottom:"\u4E0B\u8FB9\u6846",borderTdForward:"\u6B63\u659C\u7EBF",borderTdBack:"\u53CD\u659C\u7EBF"}},Ge={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"};var jt={contextmenu:Zn,datePicker:Ge,frame:{header:"\u9875\u7709",footer:"\u9875\u811A"},pageBreak:{displayName:"\u5206\u9875\u7B26"}};class Un{constructor(t={}){d(this,"options");d(this,"now");d(this,"dom");d(this,"renderOptions");d(this,"isDatePicker");d(this,"pickDate");d(this,"lang");this.options=b({mountDom:document.body},t),this.lang=Ge,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(`${H}-date-container`);const e=document.createElement("div");e.classList.add(`${H}-date-wrap`);const i=document.createElement("div");i.classList.add(`${H}-date-title`);const n=document.createElement("span");n.classList.add(`${H}-date-title__pre-year`),n.innerText="<<";const s=document.createElement("span");s.classList.add(`${H}-date-title__pre-month`),s.innerText="<";const o=document.createElement("span");o.classList.add(`${H}-date-title__now`);const r=document.createElement("span");r.classList.add(`${H}-date-title__next-month`),r.innerText=">";const a=document.createElement("span");a.classList.add(`${H}-date-title__next-year`),a.innerText=">>",i.append(n),i.append(s),i.append(o),i.append(r),i.append(a);const l=document.createElement("div");l.classList.add(`${H}-date-week`);const{weeks:{sun:u,mon:c,tue:h,wed:O,thu:P,fri:N,sat:X}}=this.lang;[u,c,h,O,P,N,X].forEach(U=>{const Q=document.createElement("span");Q.innerText=`${U}`,l.append(Q)});const g=document.createElement("div");g.classList.add(`${H}-date-day`),e.append(i),e.append(l),e.append(g);const Y=document.createElement("ul");Y.classList.add(`${H}-time-wrap`);let V,T,W;[this.lang.hour,this.lang.minute,this.lang.second].forEach((U,Q)=>{const D=document.createElement("li"),K=document.createElement("span");K.innerText=U,D.append(K);const E=document.createElement("ol"),y=Q===0,p=Q===1,G=y?24:60;for(let w=0;w<G;w++){const A=document.createElement("li");A.innerText=`${String(w).padStart(2,"0")}`,A.setAttribute("data-id",`${w}`),E.append(A)}y?V=E:p?T=E:W=E,D.append(E),Y.append(D)});const Z=document.createElement("div");Z.classList.add(`${H}-date-menu`);const S=document.createElement("button");S.classList.add(`${H}-date-menu__time`),S.innerText=this.lang.timeSelect;const m=document.createElement("button");m.classList.add(`${H}-date-menu__now`),m.innerText=this.lang.now;const I=document.createElement("button");return I.classList.add(`${H}-date-menu__submit`),I.innerText=this.lang.confirm,Z.append(S),Z.append(m),Z.append(I),t.append(e),t.append(Y),t.append(Z),this.options.mountDom.append(t),{container:t,dateWrap:e,datePickerWeek:l,timeWrap:Y,title:{preYear:n,preMonth:s,now:o,nextMonth:r,nextYear:a},day:g,time:{hour:V,minute:T,second:W},menu:{time:S,now:m,submit:I}}}_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 i=t.target.dataset.id;!i||(this.pickDate.setHours(Number(i)),this._setTimePick(!1))},this.dom.time.minute.onclick=t=>{if(!this.pickDate)return;const i=t.target.dataset.id;!i||(this.pickDate.setMinutes(Number(i)),this._setTimePick(!1))},this.dom.time.second.onclick=t=>{if(!this.pickDate)return;const i=t.target.dataset.id;!i||(this.pickDate.setSeconds(Number(i)),this._setTimePick(!1))}}_setPosition(){if(!this.renderOptions)return;const{position:{coordinate:{leftTop:[t,e]},lineHeight:i},startTop:n}=this.renderOptions;this.dom.container.style.left=`${t}px`,this.dom.container.style.top=`${e+(n||0)+i}px`}isInvalidDate(t){return t.toDateString()==="Invalid Date"}_setValue(){var e;const t=(e=this.renderOptions)==null?void 0:e.value;if(t){const i=new Date(t);this.now=this.isInvalidDate(i)?new Date:i}else this.now=new Date;this.pickDate=new Date(this.now)}_setLang(){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:i,wed:n,thu:s,fri:o,sat:r}}=this.lang,a=[t,e,i,n,s,o,r];this.dom.datePickerWeek.childNodes.forEach((h,O)=>{const P=h;P.innerText=a[O]});const l=this.dom.time.hour.previousElementSibling;l.innerText=this.lang.hour;const u=this.dom.time.minute.previousElementSibling;u.innerText=this.lang.minute;const c=this.dom.time.second.previousElementSibling;c.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),i=t.getMonth()+1,n=t.getDate();let s=null,o=null,r=null;this.pickDate&&(s=this.pickDate.getFullYear(),o=this.pickDate.getMonth()+1,r=this.pickDate.getDate());const a=this.now.getFullYear(),l=this.now.getMonth()+1;this.dom.title.now.innerText=`${a}${this.lang.year} ${String(l).padStart(2,"0")}${this.lang.month}`;const c=new Date(a,l,0).getDate();let h=new Date(a,l-1,1).getDay();h===0&&(h=7);const O=new Date(a,l-1,0).getDate();this.dom.day.innerHTML="";const P=O-h+1;for(let X=P;X<=O;X++){const L=document.createElement("div");L.classList.add("disable"),L.innerText=`${X}`,L.onclick=()=>{const g=l-2;this.now=new Date(a,g,X),this._setDatePick(a,g,X)},this.dom.day.append(L)}for(let X=1;X<=c;X++){const L=document.createElement("div");e===a&&i===l&&n===X&&L.classList.add("active"),this.pickDate&&s===a&&o===l&&r===X&&L.classList.add("select"),L.innerText=`${X}`,L.onclick=g=>{const Y=l-1;this.now=new Date(a,Y,X),this._setDatePick(a,Y,X),g.stopPropagation()},this.dom.day.append(L)}const N=6*7-h-c;for(let X=1;X<=N;X++){const L=document.createElement("div");L.classList.add("disable"),L.innerText=`${X}`,L.onclick=()=>{this.now=new Date(a,l,X),this._setDatePick(a,l,X)},this.dom.day.append(L)}}_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,i){var n,s,o;this.now=new Date(t,e,i),(n=this.pickDate)==null||n.setFullYear(t),(s=this.pickDate)==null||s.setMonth(e),(o=this.pickDate)==null||o.setDate(i),this._update()}_setTimePick(t=!0){var u,c,h;const e=((u=this.pickDate)==null?void 0:u.getHours())||0,i=((c=this.pickDate)==null?void 0:c.getMinutes())||0,n=((h=this.pickDate)==null?void 0:h.getSeconds())||0,{hour:s,minute:o,second:r}=this.dom.time;[s,o,r].forEach(O=>{O.querySelectorAll("li").forEach(P=>P.classList.remove("active"))}),[[s,e],[o,i],[r,n]].forEach(([O,P])=>{const N=O.querySelector(`[data-id='${P}']`);N.classList.add("active"),t&&this._scrollIntoView(O,N)})}_scrollIntoView(t,e){if(!e){t.scrollTop=0;return}const i=[];let n=e.offsetParent;for(;n&&t!==n&&t.contains(n);)i.push(n),n=n.offsetParent;const s=e.offsetTop+i.reduce((l,u)=>l+u.offsetTop,0),o=s+e.offsetHeight,r=t.scrollTop,a=r+t.clientHeight;s<r?t.scrollTop=s:o>a&&(t.scrollTop=o-t.clientHeight)}_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.element.dateFormat,i=this.formatDate(this.pickDate,e);this.options.onSubmit(i)}}formatDate(t,e="yyyy-MM-dd hh:mm:ss"){let i=e;const n={"y+":t.getFullYear().toString(),"M+":(t.getMonth()+1).toString(),"d+":t.getDate().toString(),"h+":t.getHours().toString(),"m+":t.getMinutes().toString(),"s+":t.getSeconds().toString()};for(const s in n){const o=new RegExp("("+s+")").exec(e),r=s;o&&(i=i.replace(o[1],o[1].length===1?n[r]:n[r].padStart(o[1].length,"0")))}return i}render(t){this.renderOptions=t,this.options.getLang&&(this.lang=this.options.getLang(),this._setLang()),this._setValue(),this._update(),this._setPosition(),this.isDatePicker=!0,this._toggleDateTimePicker(),this._toggleVisible(!0)}dispose(){this._toggleVisible(!1)}}class Qn{constructor(t){d(this,"draw");d(this,"range");d(this,"datePicker");this.draw=t,this.range=t.getRange();const e=t.getI18n(),i=e.t.bind(e);this.datePicker=new Un({mountDom:t.getContainer(),onSubmit:this._setValue.bind(this),getLang:()=>({now:i("datePicker.now"),confirm:i("datePicker.confirm"),return:i("datePicker.return"),timeSelect:i("datePicker.timeSelect"),weeks:{sun:i("datePicker.weeks.sun"),mon:i("datePicker.weeks.mon"),tue:i("datePicker.weeks.tue"),wed:i("datePicker.weeks.wed"),thu:i("datePicker.weeks.thu"),fri:i("datePicker.weeks.fri"),sat:i("datePicker.weeks.sat")},year:i("datePicker.year"),month:i("datePicker.month"),hour:i("datePicker.hour"),minute:i("datePicker.minute"),second:i("datePicker.second")})})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[i,n]=e,s=this.draw.getElementList(),o=s[i+1];this.draw.spliceElementList(s,i+1,n-i),this.range.setRange(i,i);const r={type:M.ElementType.DATE,value:"",dateFormat:o.dateFormat,valueList:[{value:t}]};tt(s,[r],i),this.draw.insertElementList([r])}getDateElementRange(){let t=-1,e=-1;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return null;const s=this.draw.getElementList(),o=s[i];if(o.type!==M.ElementType.DATE)return null;let r=i;for(;r>0;){if(s[r].dateId!==o.dateId){t=r;break}r--}let a=i+1;for(;a<s.length;){if(s[a].dateId!==o.dateId){e=a-1;break}a++}return a===s.length&&(e=a-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const i=this.draw.getHeight(),n=this.draw.getPageGap(),s=this.draw.getPageNo()*(i+n),o=this.draw.getElementList(),r=this.getDateElementRange(),a=r?o.slice(r[0]+1,r[1]+1).map(l=>l.value).join(""):"";this.datePicker.render({value:a,element:t,position:e,startTop:s})}render(t,e,i,n){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,i,n),t.restore()}}M.BlockType=void 0,function(R){R.IFRAME="iframe",R.VIDEO="video"}(M.BlockType||(M.BlockType={}));const ee=class{constructor(t){d(this,"element");this.element=t}render(t){var n;const e=this.element.block,i=document.createElement("iframe");i.sandbox.add(...ee.sandbox),i.style.border="none",i.style.width="100%",i.style.height="100%",i.src=((n=e.iframeBlock)==null?void 0:n.src)||"",t.append(i)}};let qt=ee;d(qt,"sandbox",["allow-forms","allow-scripts","allow-same-origin","allow-popups"]);class In{constructor(t){d(this,"element");this.element=t}render(t){var n;const e=this.element.block,i=document.createElement("video");i.style.width="100%",i.style.height="100%",i.style.objectFit="contain",i.src=((n=e.videoBlock)==null?void 0:n.src)||"",i.controls=!0,i.crossOrigin="anonymous",t.append(i)}}class Kn{constructor(t,e){d(this,"draw");d(this,"element");d(this,"block");d(this,"blockContainer");d(this,"blockItem");this.draw=t.getDraw(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null,this.blockItem=this._createBlockItem(),this.blockContainer.append(this.blockItem)}getBlockElement(){return this.element}_createBlockItem(){const t=document.createElement("div");return t.classList.add(`${H}-block-item`),t}render(){const t=this.element.block;t.type===M.BlockType.IFRAME?(this.block=new qt(this.element),this.block.render(this.blockItem)):t.type===M.BlockType.VIDEO&&(this.block=new In(this.element),this.block.render(this.blockItem))}setClientRects(t,e,i){const n=this.draw.getHeight(),s=this.draw.getPageGap(),o=t*(n+s),{metrics:r}=this.element;this.blockItem.style.width=`${r.width}px`,this.blockItem.style.height=`${r.height}px`,this.blockItem.style.left=`${e}px`,this.blockItem.style.top=`${o+i}px`}remove(){this.blockItem.remove()}}class fn{constructor(t){d(this,"draw");d(this,"container");d(this,"blockContainer");d(this,"blockMap");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(`${H}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,i,n){const s=e.id,o=this.blockMap.get(s);if(o)o.setClientRects(t,i,n);else{const r=new Kn(this,e);r.render(),r.setClientRects(t,i,n),this.blockMap.set(s,r)}}clear(){if(!this.blockMap.size)return;const t=this.draw.getElementList(),e=[];for(let i=0;i<t.length;i++){const n=t[i];n.type===M.ElementType.BLOCK&&e.push(n.id)}this.blockMap.forEach(i=>{const n=i.getBlockElement().id;e.includes(n)||(i.remove(),this.blockMap.delete(n))})}}var Dn={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"}},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",borderExternal:"External",borderTd:"Table cell border",borderTdBottom:"Bottom",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"}};class mn{constructor(){d(this,"langMap",new Map([["zhCN",jt],["en",Dn]]));d(this,"currentLocale","zhCN")}registerLangMap(t,e){const i=this.langMap.get(t);this.langMap.set(t,ue(i||jt,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||jt}t(t){const e=t.split(".");let i="",n=this.getLang();for(let s=0;s<e.length;s++){const o=e[s],r=Reflect.get(n,o);if(r)i=n=r;else return""}return i}}class pn{constructor(){d(this,"promiseList");this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class Hn{constructor(t){d(this,"INDICATOR_PADDING",2);d(this,"INDICATOR_TITLE_TRANSLATE",[20,5]);d(this,"draw");d(this,"options");d(this,"i18n");d(this,"container");d(this,"currentZone");d(this,"indicatorContainer");this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=M.EditorZone.MAIN,this.indicatorContainer=null}isHeaderActive(){return this.getZone()===M.EditorZone.HEADER}isMainActive(){return this.getZone()===M.EditorZone.MAIN}isFooterActive(){return this.getZone()===M.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),Dt(()=>{const e=this.draw.getListener();e.zoneChange&&e.zoneChange(t);const i=this.draw.getEventBus();i.isSubscribe("zoneChange")&&i.emit("zoneChange",t)}))}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[i,n]=this.INDICATOR_TITLE_TRANSLATE,s=this.draw.getPageList(),o=this.draw.getMargins(),r=this.draw.getInnerWidth(),a=this.draw.getHeight(),l=this.draw.getPageGap(),u=a+l;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${H}-zone-indicator`);const c=this.draw.getHeader(),h=this.draw.getFooter(),O=e?c.getHeight():h.getHeight(),P=e?c.getHeaderTop():a-h.getFooterBottom()-O;for(let N=0;N<s.length;N++){const X=u*N+P,L=o[3]-this.INDICATOR_PADDING,g=o[3]+r+this.INDICATOR_PADDING,Y=e?X-this.INDICATOR_PADDING:X+O+this.INDICATOR_PADDING,V=e?X+O+this.INDICATOR_PADDING:X-this.INDICATOR_PADDING,T=document.createElement("div");T.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),T.style.top=`${V}px`,T.style.transform=`translate(${i*t}px, ${n*t}px) scale(${t})`,this.indicatorContainer.append(T);const W=document.createElement("span");W.classList.add(`${H}-zone-indicator-border__top`),W.style.top=`${Y}px`,W.style.width=`${r}px`,W.style.marginLeft=`${o[3]}px`,this.indicatorContainer.append(W);const F=document.createElement("span");F.classList.add(`${H}-zone-indicator-border__left`),F.style.top=`${X}px`,F.style.height=`${O}px`,F.style.left=`${L}px`,this.indicatorContainer.append(F);const Z=document.createElement("span");Z.classList.add(`${H}-zone-indicator-border__bottom`),Z.style.top=`${V}px`,this.indicatorContainer.append(Z);const S=document.createElement("span");S.classList.add(`${H}-zone-indicator-border__right`),S.style.top=`${X}px`,S.style.height=`${O}px`,S.style.left=`${g}px`,this.indicatorContainer.append(S)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){var t;(t=this.indicatorContainer)==null||t.remove(),this.indicatorContainer=null}}class En{constructor(t,e){d(this,"draw");d(this,"position");d(this,"options");d(this,"elementList");d(this,"rowList");d(this,"positionList");this.draw=t,this.position=t.getPosition(),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(t,this.elementList)}_computePositionList(){const t=this.getFooterBottom(),e=this.draw.getInnerWidth(),n=this.draw.getMargins()[3],s=this.draw.getHeight(),o=this.getHeight(),r=s-t-o;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:n,startY:r,innerWidth:e})}getFooterBottom(){const{footer:{bottom:t,disabled:e},scale:i}=this.options;return e?0:Math.floor(t*i)}getMaxHeight(){const{footer:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*se[t])}getHeight(){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(),n=this.getFooterBottom()+e-t[2];return n<=0?0:n}render(t,e){t.globalAlpha=1;const i=this.draw.getInnerWidth(),n=this.getMaxHeight(),s=[];let o=0;for(let r=0;r<this.rowList.length;r++){const a=this.rowList[r];if(o+a.height>n)break;s.push(a),o+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:s,pageNo:e,startIndex:0,innerWidth:i,zone:M.EditorZone.FOOTER})}}class Gn{constructor(t){d(this,"options");d(this,"UN_COUNT_STYLE_WIDTH",20);d(this,"MEASURE_BASE_TEXT","0");d(this,"LIST_GAP",10);this.options=t.getOptions()}computeListStyle(t,e){const i=new Map;let n=0,s=e[n].listId,o=[];const r=e.length;for(;n<r;){const a=e[n];if(s&&s===a.listId)o.push(a);else if(a.listId&&a.listId!==s){if(o.length){const l=this.getListStyleWidth(t,o);i.set(s,l)}s=a.listId,o=s?[a]:[]}n++}if(o.length){const a=this.getListStyleWidth(t,o);i.set(s,a)}return i}getListStyleWidth(t,e){const{scale:i}=this.options,n=e[0];if(n.listStyle&&n.listStyle!==M.ListStyle.DECIMAL)return this.UN_COUNT_STYLE_WIDTH*i;const s=e.reduce((a,l)=>(l.value===C&&(a+=1),a),0);if(!s)return 0;const o=`${this.MEASURE_BASE_TEXT.repeat(String(s).length)}${M.KeyMap.PERIOD}`,r=t.measureText(o);return Math.ceil((r.width+this.LIST_GAP)*i)}drawListStyle(t,e,i){const{elementList:n,offsetX:s,listIndex:o,ascent:r}=e,a=n[0];if(a.value!==C||a.listWrap)return;let l=0;const{defaultTabWidth:u,scale:c,defaultFont:h,defaultSize:O}=this.options;for(let Y=1;Y<n.length;Y++){const V=n[Y];if((V==null?void 0:V.type)!==M.ElementType.TAB)break;l+=u*c}let P="";if(a.listType===M.ListType.UL?P=Se[a.listStyle]||Se[Vt.DISC]:P=`${o+1}${M.KeyMap.PERIOD}`,!P)return;const{coordinate:{leftTop:[N,X]}}=i,L=N-s+l,g=X+r;t.save(),t.font=`${O*c}px ${h}`,t.fillText(P,L,g),t.restore()}}class bn{constructor(t){d(this,"draw");d(this,"position");d(this,"options");d(this,"elementList");d(this,"rowList");d(this,"positionList");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(){this._computeRowList(),this._computePositionList()}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList(t,this.elementList)}_computePositionList(){const t=this.draw.getHeader().getExtraHeight(),e=this.draw.getInnerWidth(),i=this.draw.getMargins(),n=i[3],s=i[0]+t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:n,startY:s,innerWidth:e})}render(t){const{placeholder:{data:e,font:i,size:n,color:s,opacity:o}}=this.options;if(!e)return;this._recovery(),this.elementList=[{value:e,font:i,size:n,color:s}],at(this.elementList,{editorOptions:this.options}),this._compute();const r=this.draw.getInnerWidth();t.save(),t.globalAlpha=o,this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:this.rowList,pageNo:0,startIndex:0,innerWidth:r}),t.restore()}}class yn{constructor(t){d(this,"draw");d(this,"options");d(this,"range");d(this,"fillRectMap");this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==M.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=x();return t.forEach(i=>{Array.isArray(i.groupIds)||(i.groupIds=[]),i.groupIds.push(e)}),this.draw.render({isSetCursor:!1,isCompute:!1}),e}getElementListByGroupId(t,e){var n,s;const i=[];for(let o=0;o<t.length;o++){const r=t[o];if(r.type===M.ElementType.TABLE){const a=r.trList;for(let l=0;l<a.length;l++){const u=a[l];for(let c=0;c<u.tdList.length;c++){const h=u.tdList[c],O=this.getElementListByGroupId(h.value,e);if(O.length)return i.push(...O),i}}}if((n=r==null?void 0:r.groupIds)==null?void 0:n.includes(e)){i.push(r);const a=t[o+1];if(!((s=a==null?void 0:a.groupIds)==null?void 0:s.includes(e)))break}}return i}deleteGroup(t){if(this.draw.isReadonly())return;const e=this.draw.getOriginalMainElementList(),i=this.getElementListByGroupId(e,t);if(!!i.length){for(let n=0;n<i.length;n++){const s=i[n],o=s.groupIds,r=o.findIndex(a=>a===t);o.splice(r,1),o.length||delete s.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){var i,n;for(let s=0;s<t.length;s++){const o=t[s];if(o.type===M.ElementType.TABLE){const a=o.trList;for(let l=0;l<a.length;l++){const u=a[l];for(let c=0;c<u.tdList.length;c++){const h=u.tdList[c],O=this.getContextByGroupId(h.value,e);if(O)return q(b({},O),{isTable:!0,index:s,trIndex:l,tdIndex:c,tdId:h.id,trId:u.id,tableId:o.tableId})}}}const r=t[s+1];if(((i=o.groupIds)==null?void 0:i.includes(e))&&!((n=r==null?void 0:r.groupIds)==null?void 0:n.includes(e)))return{isTable:!1,startIndex:s,endIndex:s}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,i,n,s){const o=t.groupIds;if(!!o)for(const r of o){const a=this.fillRectMap.get(r);a?a.width+=n:this.fillRectMap.set(r,{x:e,y:i,width:n,height:s})}}render(t){var l;if(!this.fillRectMap.size)return;const e=this.range.getRange(),n=(l=this.draw.getElementList()[e.endIndex])==null?void 0:l.groupIds,{group:{backgroundColor:s,opacity:o,activeOpacity:r,activeBackgroundColor:a}}=this.options;t.save(),this.fillRectMap.forEach((u,c)=>{const{x:h,y:O,width:P,height:N}=u;(n==null?void 0:n.includes(c))?(t.globalAlpha=r,t.fillStyle=a):(t.globalAlpha=o,t.fillStyle=s),t.fillRect(h,O,P,N)}),t.restore(),this.clearFillInfo()}}class Cn{constructor(t,e,i,n,s,o){d(this,"container");d(this,"pageContainer");d(this,"pageList");d(this,"ctxList");d(this,"pageNo");d(this,"pagePixelRatio");d(this,"mode");d(this,"options");d(this,"position");d(this,"zone");d(this,"elementList");d(this,"listener");d(this,"eventBus");d(this,"override");d(this,"i18n");d(this,"canvasEvent");d(this,"globalEvent");d(this,"cursor");d(this,"range");d(this,"margin");d(this,"background");d(this,"search");d(this,"group");d(this,"underline");d(this,"strikeout");d(this,"highlight");d(this,"historyManager");d(this,"previewer");d(this,"imageParticle");d(this,"laTexParticle");d(this,"textParticle");d(this,"tableParticle");d(this,"tableTool");d(this,"pageNumber");d(this,"waterMark");d(this,"placeholder");d(this,"header");d(this,"footer");d(this,"hyperlinkParticle");d(this,"dateParticle");d(this,"separatorParticle");d(this,"pageBreakParticle");d(this,"superscriptParticle");d(this,"subscriptParticle");d(this,"checkboxParticle");d(this,"blockParticle");d(this,"listParticle");d(this,"control");d(this,"workerManager");d(this,"scrollObserver");d(this,"selectionObserver");d(this,"imageObserver");d(this,"LETTER_REG");d(this,"WORD_LIKE_REG");d(this,"rowList");d(this,"pageRowList");d(this,"painterStyle");d(this,"painterOptions");d(this,"visiblePageNoList");d(this,"intersectionPageNo");d(this,"lazyRenderIntersectionObserver");d(this,"printModeData");this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=i.main,this.listener=n,this.eventBus=s,this.override=o,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new mn,this.historyManager=new zi(this),this.position=new $i(this),this.zone=new Hn(this),this.range=new ji(this),this.margin=new en(this),this.background=new qi(this),this.search=new nn(this),this.group=new yn(this),this.underline=new sn(this),this.strikeout=new Rn(this),this.highlight=new tn(this),this.previewer=new Yn(this),this.imageParticle=new Pe(this),this.laTexParticle=new Ne(this),this.textParticle=new on(this),this.tableParticle=new un(this),this.tableTool=new hn(this),this.pageNumber=new ln(this),this.waterMark=new Nn(this),this.placeholder=new bn(this),this.header=new dn(this,i.header),this.footer=new En(this,i.footer),this.hyperlinkParticle=new Mn(this),this.dateParticle=new Qn(this),this.separatorParticle=new Xn,this.pageBreakParticle=new Ln(this),this.superscriptParticle=new On,this.subscriptParticle=new Pn,this.checkboxParticle=new Sn(this),this.blockParticle=new fn(this),this.listParticle=new Gn(this),this.control=new Tn(this),this.scrollObserver=new an(this),this.selectionObserver=new cn(this),this.imageObserver=new pn,this.canvasEvent=new _i(this),this.cursor=new Ki(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new ki(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new Vn(this);const{letterClass:r}=e;this.LETTER_REG=new RegExp(`[${r.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${r.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.render({isInit:!0,isSetCursor:!1})}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}setMode(t){this.mode!==t&&(t===M.EditorMode.PRINT&&(this.printModeData={header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()},this.setEditorData(this.control.filterAssistElement($(this.printModeData)))),this.mode===M.EditorMode.PRINT&&this.printModeData&&(this.setEditorData(this.printModeData),this.printModeData=null),this.mode=t,this.render({isSetCursor:!1,isSubmitHistory:!1}))}isReadonly(){switch(this.mode){case M.EditorMode.READONLY:case M.EditorMode.PRINT:return!0;case M.EditorMode.FORM:return!this.control.isRangeWithinControl();default:return!1}}getOriginalWidth(){const{paperDirection:t,width:e,height:i}=this.options;return t===M.PaperDirection.VERTICAL?e:i}getOriginalHeight(){const{paperDirection:t,width:e,height:i}=this.options;return t===M.PaperDirection.VERTICAL?i: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(),i=this.footer.getExtraHeight();return t[0]+t[2]+e+i}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]}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===M.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}getTdPadding(){const{tdPadding:t,scale:e}=this.options;return t.map(i=>i*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}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:i,trIndex:n,tdIndex:s}=e;return t[i].trList[n].tdList[s].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}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){const e=this.position.getPositionContext(),{index:i,trIndex:n,tdIndex:s}=e;return t[i].trList[n].tdList[s].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()}insertElementList(t){if(!t.length||this.control.isPartRangeInControlOutside())return;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;at(t,{isHandleFirstElement:!1,editorOptions:this.options});let s=-1;const o=this.control.getActiveControl();if(o&&!this.control.isRangInPostfix())s=o.setValue(t);else{const r=this.getElementList(),a=i===n,l=i+1;a||this.spliceElementList(r,l,n-i),this.spliceElementList(r,l,0,...t),s=i+t.length}~s&&(this.range.setRange(s,s),this.render({curIndex:s}))}appendElementList(t,e={}){if(!t.length)return;at(t,{isHandleFirstElement:!1,editorOptions:this.options});let i;const{isPrepend:n}=e;n?(this.elementList.splice(1,0,...t),i=t.length):(this.elementList.push(...t),i=this.elementList.length-1),this.range.setRange(i,i),this.render({curIndex:i})}spliceElementList(t,e,i,...n){var s;if(i>0){const o=e+i,r=t[o],a=r==null?void 0:r.listId;if(a&&((s=t[e-1])==null?void 0:s.listId)!==a){let l=o;for(;l<t.length;){const u=t[l];if(u.listId!==a||u.value===C)break;delete u.listId,delete u.listType,delete u.listStyle,l++}}}t.splice(e,i,...n)}getCanvasEvent(){return this.canvasEvent}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}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getRowCount(){return this.rowList.length}async getDataURL(t={}){const{pixelRatio:e,mode:i}=t;e&&this.setPagePixelRatio(e);const n=this.mode,s=!!i&&n!==i;s&&this.setMode(i),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const o=this.pageList.map(r=>r.toDataURL());return e&&this.setPagePixelRatio(null),s&&this.setMode(n),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(i=>i.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===M.PageMode.PAGING}setPageMode(t){if(!(!t||this.options.pageMode===t)){if(this.options.pageMode=t,t===M.PageMode.PAGING){const{height:e}=this.options,i=this.getPagePixelRatio(),n=this.pageList[0];n.style.height=`${e}px`,n.height=e*i,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(M.EditorZone.MAIN);this.render({isSubmitHistory:!1,isSetCursor:!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 i=this.getWidth(),n=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((s,o)=>{s.width=i*e,s.height=n*e,s.style.width=`${i}px`,s.style.height=`${n}px`,s.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[o])}),this.render({isSubmitHistory:!1,isSetCursor:!1}),this.listener.pageScaleChange&&this.listener.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(),i=this.getHeight();this.pageList.forEach((n,s)=>{n.width=e*t,n.height=i*t,this._initPageContext(this.ctxList[s])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const i=this.getPagePixelRatio(),n=this.getWidth(),s=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((o,r)=>{o.width=n*i,o.height=s*i,o.style.width=`${n}px`,o.style.height=`${s}px`,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const i=this.getWidth(),n=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((s,o)=>{s.width=i*e,s.height=n*e,s.style.width=`${i}px`,s.style.height=`${n}px`,this._initPageContext(this.ctxList[o])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getValue(t={}){const{width:e,height:i,margins:n,watermark:s}=this.options,{pageNo:o}=t;let r=this.elementList;Number.isInteger(o)&&o>=0&&o<this.pageRowList.length&&(r=this.pageRowList[o].flatMap(l=>l.elementList));const a={header:k(this.getHeaderElementList()),main:k(r),footer:k(this.getFooterElementList())};return{version:it,width:e,height:i,margins:n,watermark:s.data?s:void 0,data:a}}setValue(t){const{header:e,main:i,footer:n}=t;if(!e&&!i&&!n)return;[e,i,n].forEach(o=>{!o||at(o,{editorOptions:this.options})}),this.setEditorData({header:e,main:i,footer:n}),this.historyManager.recovery(),this.render({isSetCursor:!1})}setEditorData(t){const{header:e,main:i,footer:n}=t;e&&this.header.setElementList(e),i&&(this.elementList=i),n&&this.footer.setElementList(n)}_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(gt,M.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${H}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),i=this.getHeight(),n=document.createElement("canvas");n.style.width=`${e}px`,n.style.height=`${i}px`,n.style.display="block",n.style.backgroundColor="#ffffff",n.style.marginBottom=`${this.getPageGap()}px`,n.setAttribute("data-index",String(t)),this.pageContainer.append(n);const s=this.getPagePixelRatio();n.width=e*s,n.height=i*s,n.style.cursor="text";const o=n.getContext("2d");this._initPageContext(o),this.pageList.push(n),this.ctxList.push(o)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}_getFont(t,e=1){const{defaultSize:i,defaultFont:n}=this.options,s=t.font||n,o=t.actualSize||t.size||i;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${o*e}px ${s}`}computeRowList(t,e){var X,L,g,Y,V;const{defaultSize:i,defaultRowMargin:n,scale:s,tdPadding:o,defaultTabWidth:r}=this.options,a=this.getDefaultBasicRowMarginHeight(),u=document.createElement("canvas").getContext("2d"),c=this.listParticle.computeListStyle(u,e),h=[];e.length&&h.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowFlex:(X=e==null?void 0:e[1])==null?void 0:X.rowFlex});let O,P=0,N=0;for(let T=0;T<e.length;T++){const W=h[h.length-1],F=e[T],Z=a*(F.rowMargin||n),S={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},m=F.listId&&c.get(F.listId)||0,I=t-m;if(F.type===M.ElementType.IMAGE||F.type===M.ElementType.LATEX){const p=F.width*s,G=F.height*s,w=F.imgDisplay===M.ImageDisplay.INLINE?0:W.width;if(w+p>I){const A=I-w,v=A>0?A:Math.min(p,I);F.width=v,F.height=G*v/p,S.width=F.width,S.height=F.height,S.boundingBoxDescent=F.height}else S.width=p,S.height=G,S.boundingBoxDescent=G;S.boundingBoxAscent=0}else if(F.type===M.ElementType.TABLE){const p=o[1]+o[3],G=o[0]+o[2];this.tableParticle.computeRowColInfo(F);const w=F.trList;for(let B=0;B<w.length;B++){const j=w[B];for(let nt=0;nt<j.tdList.length;nt++){const z=j.tdList[nt],et=this.computeRowList((z.width-p)*s,z.value),ct=et.reduce((St,Ct)=>St+Ct.height,0);z.rowList=et;const ot=(ct+G)/s;if(z.height<ot){const St=ot-z.height,Ct=w[B+z.rowspan-1];Ct.height+=St,Ct.tdList.forEach(hR=>{hR.height+=St})}let ut=0,Tt=0,Kt=0;for(;Kt<z.rowspan;){const St=w[Kt+B];ut+=St.minHeight,Tt+=St.height,Kt++}z.realMinHeight=ut,z.realHeight=Tt,z.mainHeight=ot}}const A=this.tableParticle.getTrListGroupByCol(w);for(let B=0;B<A.length;B++){const j=A[B];let nt=-1;for(let z=0;z<j.tdList.length;z++){const et=j.tdList[z],ct=et.realHeight,ot=et.mainHeight,ut=et.realMinHeight,Tt=ot<ut?ct-ut:ct-ot;(!~nt||Tt<nt)&&(nt=Tt)}if(nt>0){const z=w[B];z.height-=nt,z.tdList.forEach(et=>{et.height-=nt})}}this.tableParticle.computeRowColInfo(F);const v=w.reduce((B,j)=>B+j.height,0),st=F.colgroup.reduce((B,j)=>B+j.width,0);F.width=st,F.height=v;const Lt=st*s,Yt=v*s;S.width=Lt,S.height=Yt,S.boundingBoxDescent=Yt,S.boundingBoxAscent=0;const Zt=this.getHeight(),we=this.getMainOuterHeight();let It=we;for(let B=0;B<h.length;B++){const j=h[B];j.height+It>Zt||((L=h[B-1])==null?void 0:L.isPageBreak)?It=we+j.height:It+=j.height}const Je=Z*2*s;if(It+Je+Yt>Zt){const B=F.trList;let j=0,nt=0,z=0;if(B.length>1)for(let et=0;et<B.length;et++){const ct=B[et],ot=ct.height*s;if(It+Je+z+ot>Zt){((g=F.colgroup)==null?void 0:g.length)!==ct.tdList.length&&(nt=0);break}else j=et+1,nt=B.length-j,z+=ot}if(nt){const et=B.splice(j,nt),ct=et.reduce((Tt,Kt)=>Tt+Kt.height,0);F.height-=ct,S.height-=ct,S.boundingBoxDescent-=ct;const ot=$(F);ot.trList=et,ot.id=x(),this.spliceElementList(e,T+1,0,ot);const ut=this.position.getPositionContext();ut.isTable&&ut.trIndex===j&&(ut.index+=1,ut.trIndex=0,this.position.setPositionContext(ut))}}}else if(F.type===M.ElementType.SEPARATOR)F.width=I,S.width=I,S.height=i,S.boundingBoxAscent=-Z,S.boundingBoxDescent=-Z;else if(F.type===M.ElementType.PAGE_BREAK)F.width=I,S.width=I,S.height=i;else if(F.type===M.ElementType.CHECKBOX||F.controlComponent===f.CHECKBOX){const{width:p,height:G,gap:w}=this.options.checkbox,A=(p+w*2)*s;F.width=A,S.width=A,S.height=G*s}else if(F.type===M.ElementType.TAB)S.width=r*s,S.height=i*s,S.boundingBoxDescent=0,S.boundingBoxAscent=S.height;else if(F.type===M.ElementType.BLOCK){if(!F.width)S.width=I;else{const p=F.width*s;S.width=Math.min(p,I)}S.height=F.height*s,S.boundingBoxDescent=S.height,S.boundingBoxAscent=0}else{const p=F.size||i;(F.type===M.ElementType.SUPERSCRIPT||F.type===M.ElementType.SUBSCRIPT)&&(F.actualSize=Math.ceil(p*.6)),S.height=(F.actualSize||p)*s,u.font=this._getFont(F);const G=this.textParticle.measureText(u,F);S.width=G.width*s,F.letterSpacing&&(S.width+=F.letterSpacing*s),S.boundingBoxAscent=(F.value===C?i:G.actualBoundingBoxAscent)*s,S.boundingBoxDescent=G.actualBoundingBoxDescent*s,F.type===M.ElementType.SUPERSCRIPT?S.boundingBoxAscent+=S.height/2:F.type===M.ElementType.SUBSCRIPT&&(S.boundingBoxDescent+=S.height/2)}const U=F.imgDisplay!==M.ImageDisplay.INLINE&&F.type===M.ElementType.IMAGE||F.type===M.ElementType.LATEX?S.height+Z:S.boundingBoxAscent+Z,Q=Z+S.boundingBoxAscent+S.boundingBoxDescent+Z,D=Object.assign(F,{metrics:S,style:this._getFont(F,s)});if(((Y=D.control)==null?void 0:Y.minWidth)&&(D.controlComponent&&(N+=S.width),D.controlComponent===f.POSTFIX)){const p=D.control.minWidth-N;if(p>0){const G=I-W.width-S.width,w=Math.min(G,p)*s;D.left=w,W.width+=w}else D.left=0;N=0}const K=e[T-1];let E=e[T+1],y=W.width+S.width;if(this.options.wordBreak===M.WordBreak.BREAK_WORD&&(!(K==null?void 0:K.type)||(K==null?void 0:K.type)===M.ElementType.TEXT)&&(!F.type||F.type===M.ElementType.TEXT)){const p=`${(K==null?void 0:K.value)||""}${F.value}`;if(this.WORD_LIKE_REG.test(p)){const{width:G,endElement:w}=this.textParticle.measureWord(u,e,T);y+=G,E=w}y+=this.textParticle.measurePunctuationWidth(u,E)}if(F.listId&&(F.listId!==O?P=0:F.value===C&&!F.listWrap&&P++),O=F.listId,F.type===M.ElementType.TABLE||(K==null?void 0:K.type)===M.ElementType.TABLE||(K==null?void 0:K.type)===M.ElementType.BLOCK||F.type===M.ElementType.BLOCK||(K==null?void 0:K.imgDisplay)===M.ImageDisplay.INLINE||F.imgDisplay===M.ImageDisplay.INLINE||y>I||T!==0&&F.value===C||(K==null?void 0:K.listId)!==F.listId){if(W.startIndex===0&&W.elementList.length===1&&(ai.includes(F.type)||F.listId)&&(W.height=a),(K==null?void 0:K.rowFlex)===M.RowFlex.ALIGNMENT&&y>I){const G=(I-W.width)/W.elementList.length;for(let w=0;w<W.elementList.length;w++){const A=W.elementList[w];A.metrics.width+=G}W.width=I}const p={width:S.width,height:Q,startIndex:T,elementList:[D],ascent:U,rowFlex:(V=e[T+1])==null?void 0:V.rowFlex,isPageBreak:F.type===M.ElementType.PAGE_BREAK};F.listId&&(p.isList=!0,p.offsetX=c.get(F.listId),p.listIndex=P),h.push(p)}else W.width+=S.width,W.height<Q&&(W.height=Q,W.ascent=U),W.elementList.push(D)}return h}_computePageList(){var r;const t=[[]],{pageMode:e}=this.options,i=this.getHeight(),n=this.getMainOuterHeight();let s=n,o=0;if(e===M.PageMode.CONTINUITY){t[0]=this.rowList,s+=this.rowList.reduce((c,h)=>c+h.height,0);const a=this.getPagePixelRatio(),l=this.pageList[0],u=Number(l.style.height.replace("px",""));if(s>u)l.style.height=`${s}px`,l.height=s*a;else{const c=s<i?i:s;l.style.height=`${c}px`,l.height=c*a}this._initPageContext(this.ctxList[0])}else for(let a=0;a<this.rowList.length;a++){const l=this.rowList[a];l.height+s>i||((r=this.rowList[a-1])==null?void 0:r.isPageBreak)?(s=n+l.height,t.push([l]),o++):(s+=l.height,t[o].push(l))}return t}_drawRichText(t){this.underline.render(t),this.strikeout.render(t),this.highlight.render(t),this.textParticle.complete()}drawRow(t,e){var g,Y;const{rowList:i,pageNo:n,elementList:s,positionList:o,startIndex:r,zone:a}=e,l=this.mode===M.EditorMode.PRINT,{scale:u,tdPadding:c,defaultBasicRowMarginHeight:h,defaultRowMargin:O,group:P}=this.options,{isCrossRowCol:N,tableId:X}=this.range.getRange();let L=r;for(let V=0;V<i.length;V++){const T=i[V],W={x:0,y:0,width:0,height:0};let F=null;for(let Z=0;Z<T.elementList.length;Z++){const S=T.elementList[Z],m=S.metrics,{ascent:I,coordinate:{leftTop:[U,Q]}}=o[T.startIndex+Z],D=T.elementList[Z-1];if(S.highlight?(D&&D.highlight&&D.highlight!==S.highlight&&this.highlight.render(t),this.highlight.recordFillInfo(t,U,Q,m.width,T.height,S.highlight)):(D==null?void 0:D.highlight)&&this.highlight.render(t),S.type===M.ElementType.IMAGE?(this._drawRichText(t),this.imageParticle.render(t,S,U,Q+I)):S.type===M.ElementType.LATEX?(this._drawRichText(t),this.laTexParticle.render(t,S,U,Q+I)):S.type===M.ElementType.TABLE?(N&&(W.x=U,W.y=Q,F=S),this.tableParticle.render(t,S,U,Q)):S.type===M.ElementType.HYPERLINK?(this._drawRichText(t),this.hyperlinkParticle.render(t,S,U,Q+I)):S.type===M.ElementType.DATE?(this._drawRichText(t),this.dateParticle.render(t,S,U,Q+I)):S.type===M.ElementType.SUPERSCRIPT?(this._drawRichText(t),this.superscriptParticle.render(t,S,U,Q+I)):S.type===M.ElementType.SUBSCRIPT?(this._drawRichText(t),this.subscriptParticle.render(t,S,U,Q+I)):S.type===M.ElementType.SEPARATOR?this.separatorParticle.render(t,S,U,Q):S.type===M.ElementType.PAGE_BREAK?this.mode!==M.EditorMode.CLEAN&&!l&&this.pageBreakParticle.render(t,S,U,Q):S.type===M.ElementType.CHECKBOX||S.controlComponent===f.CHECKBOX?(this._drawRichText(t),this.checkboxParticle.render(t,S,U,Q+I)):S.type===M.ElementType.TAB?this._drawRichText(t):S.rowFlex===M.RowFlex.ALIGNMENT?(this.textParticle.record(t,S,U,Q+I),this._drawRichText(t)):S.type===M.ElementType.BLOCK?(this._drawRichText(t),this.blockParticle.render(n,S,U,Q)):(this.textParticle.record(t,S,U,Q+I),(S.width||S.letterSpacing)&&this.textParticle.complete()),S.underline||((g=S.control)==null?void 0:g.underline)){const p=h*(S.rowMargin||O)*u,G=S.left||0,w=S.controlComponent===f.PLACEHOLDER?void 0:S.color;this.underline.recordFillInfo(t,U-G,Q+T.height-p,m.width+G,0,w)}else((D==null?void 0:D.underline)||((Y=D==null?void 0:D.control)==null?void 0:Y.underline))&&this.underline.render(t);S.strikeout?this.strikeout.recordFillInfo(t,U,Q+T.height/2,m.width):(D==null?void 0:D.strikeout)&&this.strikeout.render(t);const{zone:K,startIndex:E,endIndex:y}=this.range.getRange();if(K===a&&E!==y&&E<=L&&L<=y)if(E===L){const p=s[E+1];p&&p.value===C&&(W.x=U+m.width,W.y=Q,W.height=T.height,W.width+=this.options.rangeMinWidth)}else{const p=this.position.getPositionContext();if(!p.isTable&&!S.tdId||p.tdId===S.tdId){let G=m.width;G===0&&T.elementList.length===1&&(G=this.options.rangeMinWidth),W.width||(W.x=U,W.y=Q,W.height=T.height),W.width+=G}}if(!P.disabled&&S.groupIds&&this.group.recordFillInfo(S,U,Q,m.width,T.height),L++,S.type===M.ElementType.TABLE){const p=c[1]+c[3];for(let G=0;G<S.trList.length;G++){const w=S.trList[G];for(let A=0;A<w.tdList.length;A++){const v=w.tdList[A];this.drawRow(t,{elementList:v.value,positionList:v.positionList,rowList:v.rowList,pageNo:n,startIndex:0,innerWidth:(v.width-p)*u,zone:a})}}}}if(T.isList&&this.listParticle.drawListStyle(t,T,o[T.startIndex]),this._drawRichText(t),this.group.render(t),!l){if(W.width&&W.height){const{x:Z,y:S,width:m,height:I}=W;this.range.render(t,Z,S,m,I)}if(N&&F&&F.id===X){const{coordinate:{leftTop:[Z,S]}}=o[T.startIndex];this.tableParticle.drawRange(t,F,Z,S)}}}}_clearPage(t){const e=this.ctxList[t],i=this.pageList[t];e.clearRect(0,0,i.width,i.height),this.blockParticle.clear()}_drawPage(t){const{elementList:e,positionList:i,rowList:n,pageNo:s}=t,{inactiveAlpha:o,pageMode:r,header:a,footer:l,pageNumber:u}=this.options,c=this.getInnerWidth(),h=this.ctxList[s];h.globalAlpha=this.zone.isMainActive()?1:o,this._clearPage(s),this.background.render(h,s),this.margin.render(h,s);const O=n[0].startIndex;this.drawRow(h,{elementList:e,positionList:i,rowList:n,pageNo:s,startIndex:O,innerWidth:c,zone:M.EditorZone.MAIN}),this.getIsPagingMode()&&(a.disabled||this.header.render(h,s),u.disabled||this.pageNumber.render(h,s),l.disabled||this.footer.render(h,s)),this.search.getSearchKeyword()&&this.search.render(h,s),r!==M.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(h),this.elementList.length<=1&&this.placeholder.render(h)}_disconnectLazyRender(){var t;(t=this.lazyRenderIntersectionObserver)==null||t.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(i=>{i.forEach(n=>{if(n.isIntersecting){const s=Number(n.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[s],pageNo:s})}})}),this.pageList.forEach(i=>{this.lazyRenderIntersectionObserver.observe(i)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let i=0;i<this.pageRowList.length;i++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[i],pageNo:i})}render(t){var X;const{header:e,footer:i}=this.options,{isSubmitHistory:n=!0,isSetCursor:s=!0,isCompute:o=!0,isLazy:r=!0,isInit:a=!1,isSourceHistory:l=!1}=t||{};let{curIndex:u}=t||{};const c=this.getInnerWidth(),h=this.getIsPagingMode();if(o){h&&(e.disabled||this.header.compute(),i.disabled||this.footer.compute()),this.rowList=this.computeRowList(c,this.elementList),this.pageRowList=this._computePageList(),this.position.computePositionList();const L=this.search.getSearchKeyword();L&&this.search.compute(L)}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let L=0;L<this.pageRowList.length;L++)this.pageList[L]||this._createPage(L);const O=this.pageRowList.length,P=this.pageList.length;if(P>O){const L=P-O;this.ctxList.splice(O,L),this.pageList.splice(O,L).forEach(g=>g.remove())}r&&h?this._lazyRender():this._immediateRender();const N=this.position.getPositionContext();if(s){const L=this.position.getPositionList();if(N.isTable){const{index:g,trIndex:Y,tdIndex:V}=N,W=(X=this.getOriginalElementList()[g].trList)==null?void 0:X[Y].tdList[V].positionList;u===void 0&&W&&(u=W.length-1);const F=W==null?void 0:W[u];this.position.setCursorPosition(F||null)}else this.position.setCursorPosition(u!==void 0?L[u]:null);this.cursor.drawCursor()}if(n){const L=this,g=$(this.elementList),Y=$(this.header.getElementList()),V=$(this.footer.getElementList()),{startIndex:T,endIndex:W}=this.range.getRange(),F=this.pageNo,Z=$(N),S=this.zone.getZone();this.historyManager.execute(function(){L.zone.setZone(S),L.setPageNo(F),L.position.setPositionContext($(Z)),L.header.setElementList($(Y)),L.footer.setElementList($(V)),L.elementList=$(g),L.range.setRange(T,W),L.render({curIndex:u,isSubmitHistory:!1,isSourceHistory:!0})})}Dt(()=>{o&&!this.isReadonly()&&N.isTable&&this.tableTool.render(),o&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length),(n||l)&&!a&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"))})}destroy(){this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}}class be{constructor(t){d(this,"executeMode");d(this,"executeCut");d(this,"executeCopy");d(this,"executePaste");d(this,"executeSelectAll");d(this,"executeBackspace");d(this,"executeSetRange");d(this,"executeForceUpdate");d(this,"executeUndo");d(this,"executeRedo");d(this,"executePainter");d(this,"executeApplyPainterStyle");d(this,"executeFormat");d(this,"executeFont");d(this,"executeSize");d(this,"executeSizeAdd");d(this,"executeSizeMinus");d(this,"executeBold");d(this,"executeItalic");d(this,"executeUnderline");d(this,"executeStrikeout");d(this,"executeSuperscript");d(this,"executeSubscript");d(this,"executeColor");d(this,"executeHighlight");d(this,"executeTitle");d(this,"executeList");d(this,"executeRowFlex");d(this,"executeRowMargin");d(this,"executeInsertTable");d(this,"executeInsertTableTopRow");d(this,"executeInsertTableBottomRow");d(this,"executeInsertTableLeftCol");d(this,"executeInsertTableRightCol");d(this,"executeDeleteTableRow");d(this,"executeDeleteTableCol");d(this,"executeDeleteTable");d(this,"executeMergeTableCell");d(this,"executeCancelMergeTableCell");d(this,"executeTableTdVerticalAlign");d(this,"executeTableBorderType");d(this,"executeTableTdBorderType");d(this,"executeTableTdSlashType");d(this,"executeTableTdBackgroundColor");d(this,"executeTableSelectAll");d(this,"executeImage");d(this,"executeHyperlink");d(this,"executeDeleteHyperlink");d(this,"executeCancelHyperlink");d(this,"executeEditHyperlink");d(this,"executeSeparator");d(this,"executePageBreak");d(this,"executeAddWatermark");d(this,"executeDeleteWatermark");d(this,"executeSearch");d(this,"executeSearchNavigatePre");d(this,"executeSearchNavigateNext");d(this,"executeReplace");d(this,"executePrint");d(this,"executeReplaceImageElement");d(this,"executeSaveAsImageElement");d(this,"executeChangeImageDisplay");d(this,"executePageMode");d(this,"executePageScaleRecovery");d(this,"executePageScaleMinus");d(this,"executePageScaleAdd");d(this,"executePaperSize");d(this,"executePaperDirection");d(this,"executeSetPaperMargin");d(this,"executeInsertElementList");d(this,"executeAppendElementList");d(this,"executeSetValue");d(this,"executeRemoveControl");d(this,"executeSetLocale");d(this,"executeLocationCatalog");d(this,"executeWordTool");d(this,"executeSetHTML");d(this,"executeSetGroup");d(this,"executeDeleteGroup");d(this,"executeLocationGroup");d(this,"executeSetControlValue");d(this,"getCatalog");d(this,"getImage");d(this,"getOptions");d(this,"getValue");d(this,"getHTML");d(this,"getText");d(this,"getWordCount");d(this,"getRangeText");d(this,"getRangeContext");d(this,"getRangeRow");d(this,"getRangeParagraph");d(this,"getPaperMargin");d(this,"getSearchNavigateInfo");d(this,"getLocale");d(this,"getGroupIds");d(this,"getControlValue");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.executeForceUpdate=t.forceUpdate.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.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.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.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.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.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.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.getImage=t.getImage.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.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.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.executeSetControlValue=t.setControlValue.bind(t),this.getControlValue=t.getControlValue.bind(t)}}const te={data:"",color:"#AEB5C0",opacity:.3,size:200,font:"Yahei"};M.VerticalAlign=void 0,function(R){R.TOP="top",R.MIDDLE="middle",R.BOTTOM="bottom"}(M.VerticalAlign||(M.VerticalAlign={}));function wn(R,t,e){const i=document.createElement("iframe");i.style.visibility="hidden",i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.width="0",i.style.height="0",i.style.border="none",document.body.append(i);const n=i.contentWindow,s=n.document;s.open();const o=document.createElement("div");R.forEach(l=>{const u=document.createElement("img");u.style.width=`${t}px`,u.style.height=`${e}px`,u.src=l,o.append(u)});const r=document.createElement("style"),a="*{margin:0;padding:0;}";r.append(document.createTextNode(a)),setTimeout(()=>{s.write(`${r.outerHTML}${o.innerHTML}`),n.print(),s.close(),window.addEventListener("mouseover",()=>{i==null||i.remove()},{once:!0})})}class Jn{constructor(t){d(this,"draw");d(this,"range");d(this,"position");d(this,"historyManager");d(this,"canvasEvent");d(this,"tableTool");d(this,"options");d(this,"control");d(this,"workerManager");d(this,"searchManager");d(this,"i18n");this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.canvasEvent=t.getCanvasEvent(),this.tableTool=t.getTableTool(),this.options=t.getOptions(),this.control=t.getControl(),this.workerManager=t.getWorkerManager(),this.searchManager=t.getSearch(),this.i18n=t.getI18n()}mode(t){this.draw.setMode(t)}cut(){this.draw.isReadonly()||this.canvasEvent.cut()}copy(){this.canvasEvent.copy()}async paste(){if(this.draw.isReadonly())return;const e=await navigator.clipboard.readText();e&&this.canvasEvent.input(e)}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly())return;const e=this.draw.getElementList(),{startIndex:i,endIndex:n}=this.range.getRange(),s=i===n;if(s&&e[i].value===C&&i===0)return;s?this.draw.spliceElementList(e,i,1):this.draw.spliceElementList(e,i+1,n-i);const o=s?i-1:i;this.range.setRange(o,o),this.draw.render({curIndex:o})}setRange(t,e){if(t<0||e<0||e<t)return;this.range.setRange(t,e);const i=t===e;this.draw.render({curIndex:i?t:void 0,isCompute:!1,isSubmitHistory:!1,isSetCursor:i})}forceUpdate(t){const{isSubmitHistory:e=!1}=t||{};this.range.clearRange(),this.draw.render({isSubmitHistory:e,isSetCursor:!1})}undo(){this.draw.isReadonly()||this.historyManager.undo()}redo(){this.draw.isReadonly()||this.historyManager.redo()}painter(t){if(this.draw.isReadonly())return;const i=this.range.getSelection();if(!i)return;const n={};i.forEach(s=>{mt.forEach(r=>{const a=r;n[a]===void 0&&(n[a]=s[a])})}),this.draw.setPainterStyle(n,t)}applyPainterStyle(){this.canvasEvent.applyPainterStyle()}format(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();!e||(e.forEach(i=>{i.font="",i.color="",i.bold=!1,i.italic=!1,i.underline=!1,i.strikeout=!1}),this.draw.render({isSetCursor:!1}))}font(t){if(this.draw.isReadonly())return;const i=this.range.getSelectionElementList();!i||(i.forEach(n=>{n.font=t}),this.draw.render({isSetCursor:!1}))}size(t){const{minSize:e,maxSize:i,defaultSize:n}=this.options;if(t<e||t>i||this.draw.isReadonly())return;const o=this.range.getTextLikeSelectionElementList();if(!o||!o.length)return;let r=!1;o.forEach(a=>{!a.size&&t===n||a.size&&a.size===t||(a.size=t,r=!0)}),r&&this.draw.render({isSetCursor:!1})}sizeAdd(){if(this.draw.isReadonly())return;const e=this.range.getTextLikeSelectionElementList();if(!e||!e.length)return;const{defaultSize:i,maxSize:n}=this.options;let s=!1;e.forEach(o=>{o.size||(o.size=i),!(o.size>=n)&&(o.size+2>n?o.size=n:o.size+=2,s=!0)}),s&&this.draw.render({isSetCursor:!1})}sizeMinus(){if(this.draw.isReadonly())return;const e=this.range.getTextLikeSelectionElementList();if(!e||!e.length)return;const{defaultSize:i,minSize:n}=this.options;let s=!1;e.forEach(o=>{o.size||(o.size=i),!(o.size<=n)&&(o.size-2<n?o.size=n:o.size-=2,s=!0)}),s&&this.draw.render({isSetCursor:!1})}bold(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();if(!e)return;const i=e.findIndex(n=>!n.bold);e.forEach(n=>{n.bold=!!~i}),this.draw.render({isSetCursor:!1})}italic(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();if(!e)return;const i=e.findIndex(n=>!n.italic);e.forEach(n=>{n.italic=!!~i}),this.draw.render({isSetCursor:!1})}underline(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();if(!e)return;const i=e.findIndex(n=>!n.underline);e.forEach(n=>{n.underline=!!~i}),this.draw.render({isSetCursor:!1,isCompute:!1})}strikeout(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();if(!e)return;const i=e.findIndex(n=>!n.strikeout);e.forEach(n=>{n.strikeout=!!~i}),this.draw.render({isSetCursor:!1,isCompute:!1})}superscript(){if(this.draw.isReadonly()||this.control.getActiveControl())return;const i=this.range.getSelectionElementList();if(!i)return;const n=i.findIndex(s=>s.type===M.ElementType.SUPERSCRIPT);i.forEach(s=>{~n?s.type===M.ElementType.SUPERSCRIPT&&(s.type=M.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===M.ElementType.TEXT||s.type===M.ElementType.SUBSCRIPT)&&(s.type=M.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(){if(this.draw.isReadonly()||this.control.getActiveControl())return;const i=this.range.getSelectionElementList();if(!i)return;const n=i.findIndex(s=>s.type===M.ElementType.SUBSCRIPT);i.forEach(s=>{~n?s.type===M.ElementType.SUBSCRIPT&&(s.type=M.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===M.ElementType.TEXT||s.type===M.ElementType.SUPERSCRIPT)&&(s.type=M.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t){if(this.draw.isReadonly())return;const i=this.range.getSelectionElementList();!i||(i.forEach(n=>{n.color=t}),this.draw.render({isSetCursor:!1,isCompute:!1}))}highlight(t){if(this.draw.isReadonly())return;const i=this.range.getSelectionElementList();!i||(i.forEach(n=>{n.highlight=t}),this.draw.render({isSetCursor:!1,isCompute:!1}))}title(t){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;const s=this.draw.getElementList(),o=i===n?this.range.getRangeParagraphElementList():s.slice(i+1,n+1);if(!o||!o.length)return;const r=x(),a=this.draw.getOptions().title;o.forEach(c=>{!c.type&&c.value===C||(t?(c.level=t,c.titleId=r,We(c)&&(c.size=a[ge[t]],c.bold=!0)):c.titleId&&(delete c.titleId,delete c.level,delete c.size,delete c.bold))});const l=i===n,u=l?n:i;this.draw.render({curIndex:u,isSetCursor:l})}list(t,e){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:s}=this.range.getRange();if(!~n&&!~s)return;const o=this.range.getRangeParagraphElementList();if(!o||!o.length)return;const r=o.find(c=>c.listType===t&&c.listStyle===e),a=x();o.forEach(c=>{!r&&t?(c.listId=a,c.listType=t,c.listStyle=e):c.listId&&(delete c.listId,delete c.listType,delete c.listStyle)});const l=n===s,u=l?s:n;this.draw.render({curIndex:u,isSetCursor:l})}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;const s=this.range.getRangeRowElementList();if(!s)return;s.forEach(a=>{a.rowFlex=t});const o=i===n,r=o?n:i;this.draw.render({curIndex:r,isSetCursor:o})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;const s=this.range.getRangeRowElementList();if(!s)return;s.forEach(a=>{a.rowMargin=t});const o=i===n,r=o?n:i;this.draw.render({curIndex:r,isSetCursor:o})}insertTable(t,e){var N;if(this.draw.isReadonly()||this.control.getActiveControl())return;const{startIndex:s,endIndex:o}=this.range.getRange();if(!~s&&!~o)return;const r=this.draw.getElementList();let a=0;if((N=r[s])==null?void 0:N.listId){const X=this.position.getPositionList(),{rowIndex:L}=X[s],Y=this.draw.getRowList()[L];a=(Y==null?void 0:Y.offsetX)||0}const l=this.draw.getOriginalInnerWidth()-a,u=[],c=l/e;for(let X=0;X<e;X++)u.push({width:c});const h=[];for(let X=0;X<t;X++){const L=[],g={height:this.options.defaultTrMinHeight,tdList:L};for(let Y=0;Y<e;Y++)L.push({colspan:1,rowspan:1,value:[{value:C,size:16}]});h.push(g)}const O={type:M.ElementType.TABLE,value:"",colgroup:u,trList:h};at([O],{editorOptions:this.options}),tt(r,[O],s);const P=s+1;this.draw.spliceElementList(r,P,s===o?0:o-s,O),this.range.setRange(P,P),this.draw.render({curIndex:P,isSetCursor:!1})}insertTableTopRow(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,trIndex:n,tableId:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=a[n];if(l.tdList.length<r.colgroup.length){const h=l.tdList[0].rowIndex;for(let O=0;O<n;O++){const P=a[O];for(let N=0;N<P.tdList.length;N++){const X=P.tdList[N];X.rowspan>1&&X.rowIndex+X.rowspan>=h+1&&(X.rowspan+=1)}}}const u=x(),c={height:l.height,id:u,tdList:[]};for(let h=0;h<l.tdList.length;h++){const O=l.tdList[h],P=x();c.tdList.push({id:P,rowspan:1,colspan:O.colspan,value:[{value:C,size:16,tableId:s,trId:u,tdId:P}]})}a.splice(n,0,c),this.position.setPositionContext({isTable:!0,index:i,trIndex:n,tdIndex:0,tdId:c.tdList[0].id,trId:c.id,tableId:s}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableBottomRow(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,trIndex:n,tableId:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=a[n],u=a.length-1===n?l:a[n+1];if(u.tdList.length<r.colgroup.length){const O=u.tdList[0].rowIndex;for(let P=0;P<n+1;P++){const N=a[P];for(let X=0;X<N.tdList.length;X++){const L=N.tdList[X];L.rowspan>1&&L.rowIndex+L.rowspan>=O+1&&(L.rowspan+=1)}}}const c=x(),h={height:u.height,id:c,tdList:[]};for(let O=0;O<u.tdList.length;O++){const P=u.tdList[O],N=x();h.tdList.push({id:N,rowspan:1,colspan:P.colspan,value:[{value:C,size:16,tableId:s,trId:c,tdId:N}]})}a.splice(n+1,0,h),this.position.setPositionContext({isTable:!0,index:i,trIndex:n+1,tdIndex:0,tdId:h.tdList[0].id,trId:h.id,tableId:s}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableLeftCol(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,tdIndex:n,tableId:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=n;for(let O=0;O<a.length;O++){const P=a[O],N=x();P.tdList.splice(l,0,{id:N,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:s,trId:P.id,tdId:N}]})}const u=r.colgroup;u.splice(l,0,{width:this.options.defaultColMinWidth});const c=u.reduce((O,P)=>O+P.width,0),h=this.draw.getOriginalInnerWidth();if(c>h){const O=(c-h)/u.length;for(let P=0;P<u.length;P++){const N=u[P];N.width-=O}}this.position.setPositionContext({isTable:!0,index:i,trIndex:0,tdIndex:l,tdId:a[0].tdList[l].id,trId:a[0].id,tableId:s}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableRightCol(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,tdIndex:n,tableId:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=n+1;for(let O=0;O<a.length;O++){const P=a[O],N=x();P.tdList.splice(l,0,{id:N,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:s,trId:P.id,tdId:N}]})}const u=r.colgroup;u.splice(l,0,{width:this.options.defaultColMinWidth});const c=u.reduce((O,P)=>O+P.width,0),h=this.draw.getOriginalInnerWidth();if(c>h){const O=(c-h)/u.length;for(let P=0;P<u.length;P++){const N=u[P];N.width-=O}}this.position.setPositionContext({isTable:!0,index:i,trIndex:0,tdIndex:l,tdId:a[0].tdList[l].id,trId:a[0].id,tableId:s}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}deleteTableRow(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,trIndex:n}=e,o=this.draw.getOriginalElementList()[i],r=o.trList,a=r[n];if(r.length<=1){this.deleteTable();return}for(let l=0;l<a.tdList.length;l++){const u=a.tdList[l];if(u.rowspan>1){let c=n+1;for(;c<n+u.rowspan;){const h=x(),O=r[c];O.tdList.splice(l,0,{id:h,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:o.id,trId:O.id,tdId:h}]}),c+=1}}}r.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:e.index}),this.tableTool.dispose()}deleteTableCol(){var h;if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,tdIndex:n,trIndex:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,u=a[s].tdList[n].colIndex;if(!a.find(O=>O.tdList.length>1)){this.deleteTable();return}for(let O=0;O<a.length;O++){const P=a[O];for(let N=0;N<P.tdList.length;N++){const X=P.tdList[N];if(X.colspan>1){const L=X.colIndex;L<=u&&L+X.colspan-1>=u&&(X.colspan-=1)}}}for(let O=0;O<a.length;O++){const P=a[O];let N=-1;for(let X=0;X<P.tdList.length;X++)P.tdList[X].colIndex===u&&(N=X);~N&&P.tdList.splice(N,1)}(h=r.colgroup)==null||h.splice(u,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:e.index}),this.tableTool.dispose()}deleteTable(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;this.draw.getOriginalElementList().splice(e.index,1);const n=e.index-1;this.position.setPositionContext({isTable:!1,index:n}),this.range.setRange(n,n),this.draw.render({curIndex:n}),this.tableTool.dispose()}mergeTableCell(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{isCrossRowCol:i,startTdIndex:n,endTdIndex:s,startTrIndex:o,endTrIndex:r}=this.range.getRange();if(!i)return;const{index:a}=e,c=this.draw.getOriginalElementList()[a].trList;let h=c[o].tdList[n],O=c[r].tdList[s];(h.x>O.x||h.y>O.y)&&([h,O]=[O,h]);const P=h.colIndex,N=O.colIndex+(O.colspan-1),X=h.rowIndex,L=O.rowIndex+(O.rowspan-1),g=[];for(let Q=0;Q<c.length;Q++){const D=c[Q],K=[];for(let E=0;E<D.tdList.length;E++){const y=D.tdList[E],p=y.colIndex,G=y.rowIndex;p>=P&&p<=N&&G>=X&&G<=L&&K.push(y)}K.length&&g.push(K)}if(!g.length)return;const Y=g[g.length-1],V=g[0][0],T=Y[Y.length-1],W=V.x,F=V.y,Z=T.x+T.width,S=T.y+T.height;for(let Q=0;Q<g.length;Q++){const D=g[Q];for(let K=0;K<D.length;K++){const E=D[K],y=E.x,p=E.y,G=y+E.width,w=p+E.height;if(W>y||F>p||Z<G||S<w)return}}const m=[],I=g[0][0];for(let Q=0;Q<g.length;Q++){const D=g[Q];for(let K=0;K<D.length;K++){const E=D[K];Q===0&&K===0||m.push(E.id),Q===0&&K!==0&&(I.colspan+=E.colspan),Q!==0&&I.colIndex===E.colIndex&&(I.rowspan+=E.rowspan)}}for(let Q=0;Q<c.length;Q++){const D=c[Q];let K=0;for(;K<D.tdList.length;){const E=D.tdList[K];m.includes(E.id)&&(D.tdList.splice(K,1),K--),K++}}const U=h.value.length-1;this.range.setRange(U,U),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,tdIndex:n,trIndex:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=a[s],u=l.tdList[n];if(u.rowspan===1&&u.colspan===1)return;const c=u.colspan;if(u.colspan>1){for(let O=1;O<u.colspan;O++){const P=x();l.tdList.splice(n+O,0,{id:P,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:r.id,trId:l.id,tdId:P}]})}u.colspan=1}if(u.rowspan>1){for(let O=1;O<u.rowspan;O++){const P=a[s+O];for(let N=0;N<c;N++){const X=x();P.tdList.splice(u.colIndex,0,{id:X,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:r.id,trId:P.id,tdId:X}]})}}u.rowspan=1}const h=u.value.length-1;this.range.setRange(h,h),this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){if(this.draw.isReadonly())return;const i=this.draw.getTableParticle().getRangeRowCol();if(!i)return;for(let s=0;s<i.length;s++){const o=i[s];for(let r=0;r<o.length;r++){const a=o[r];!a||a.verticalAlign===t||!a.verticalAlign&&t===M.VerticalAlign.TOP||(a.verticalAlign=t)}}const{endIndex:n}=this.range.getRange();this.draw.render({curIndex:n})}tableBorderType(t){if(this.draw.isReadonly())return;const i=this.position.getPositionContext();if(!i.isTable)return;const{index:n}=i,o=this.draw.getOriginalElementList()[n];if(!o.borderType&&t===M.TableBorder.ALL||o.borderType===t)return;o.borderType=t;const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdBorderType(t){if(this.draw.isReadonly())return;const i=this.draw.getTableParticle().getRangeRowCol();if(!i)return;const n=i.flat(),s=n.some(r=>r.borderType!==t);n.forEach(r=>{s?r.borderType=t:delete r.borderType});const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o})}tableTdSlashType(t){if(this.draw.isReadonly())return;const i=this.draw.getTableParticle().getRangeRowCol();if(!i)return;const n=i.flat(),s=n.some(r=>r.slashType!==t);n.forEach(r=>{s?r.slashType=t:delete r.slashType});const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o})}tableTdBackgroundColor(t){if(this.draw.isReadonly())return;const i=this.draw.getTableParticle().getRangeRowCol();if(!i)return;for(let s=0;s<i.length;s++){const o=i[s];for(let r=0;r<o.length;r++){const a=o[r];a.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:i,isTable:n}=t;if(!n||!i)return;const{startIndex:s,endIndex:o}=this.range.getRange(),a=this.draw.getOriginalElementList()[e].trList,l=a.length-1,u=a[l].tdList.length-1;this.range.replaceRange({startIndex:s,endIndex:o,tableId:i,startTdIndex:0,endTdIndex:u,startTrIndex:0,endTrIndex:l}),this.draw.render({isCompute:!1,isSubmitHistory:!1})}hyperlink(t){if(this.draw.isReadonly()||this.control.getActiveControl())return;const{startIndex:n,endIndex:s}=this.range.getRange();if(!~n&&!~s)return;const o=this.draw.getElementList(),{valueList:r,url:a}=t,l=x(),u=r==null?void 0:r.map(O=>({url:a,hyperlinkId:l,value:O.value,type:M.ElementType.HYPERLINK}));if(!u)return;const c=n+1;tt(o,u,n),this.draw.spliceElementList(o,c,n===s?0:s-n,...u);const h=c+u.length-1;this.range.setRange(h,h),this.draw.render({curIndex:h})}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return null;const s=this.draw.getElementList(),o=s[i];if(o.type!==M.ElementType.HYPERLINK)return null;let r=i;for(;r>0;){if(s[r].hyperlinkId!==o.hyperlinkId){t=r+1;break}r--}let a=i+1;for(;a<s.length;){if(s[a].hyperlinkId!==o.hyperlinkId){e=a-1;break}a++}return a===s.length&&(e=a-1),!~t||!~e?null:[t,e]}deleteHyperlink(){const t=this.getHyperlinkRange();if(!t)return;const e=this.draw.getElementList(),[i,n]=t;this.draw.spliceElementList(e,i,n-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const s=i-1;this.range.setRange(s,s),this.draw.render({curIndex:s})}cancelHyperlink(){const t=this.getHyperlinkRange();if(!t)return;const e=this.draw.getElementList(),[i,n]=t;for(let o=i;o<=n;o++){const r=e[o];delete r.type,delete r.url,delete r.hyperlinkId,delete r.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s,isCompute:!1})}editHyperlink(t){const e=this.getHyperlinkRange();if(!e)return;const i=this.draw.getElementList(),[n,s]=e;for(let r=n;r<=s;r++){const a=i[r];a.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o,isCompute:!1})}separator(t){if(this.draw.isReadonly()||this.control.getActiveControl())return;const{startIndex:n,endIndex:s}=this.range.getRange();if(!~n&&!~s)return;const o=this.draw.getElementList();let r=-1;const a=o[s+1];if(a&&a.type===M.ElementType.SEPARATOR){if(a.dashArray&&a.dashArray.join()===t.join())return;r=s,a.dashArray=t}else{const l={value:ne,type:M.ElementType.SEPARATOR,dashArray:t};tt(o,[l],n),n!==0&&o[n].value===C?(this.draw.spliceElementList(o,n,1,l),r=n-1):(this.draw.spliceElementList(o,n+1,0,l),r=n)}this.range.setRange(r,r),this.draw.render({curIndex:r})}pageBreak(){this.draw.isReadonly()||this.control.getActiveControl()||this.insertElementList([{type:M.ElementType.PAGE_BREAK,value:ne}])}addWatermark(t){if(this.draw.isReadonly())return;const i=this.draw.getOptions(),{color:n,size:s,opacity:o,font:r}=te;i.watermark.data=t.data,i.watermark.color=t.color||n,i.watermark.size=t.size||s,i.watermark.opacity=t.opacity||o,i.watermark.font=t.font||r,this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1})}deleteWatermark(){if(this.draw.isReadonly())return;const e=this.draw.getOptions();e.watermark&&e.watermark.data&&(e.watermark=b({},te),this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.control.getActiveControl())return;const{startIndex:n,endIndex:s}=this.range.getRange();if(!~n&&!~s)return;const o=this.draw.getElementList(),{value:r,width:a,height:l}=t,u={value:r,width:a,height:l,id:x(),type:M.ElementType.IMAGE},c=n+1;tt(o,[u],n),this.draw.spliceElementList(o,c,n===s?0:s-n,u),this.range.setRange(c,c),this.draw.render({curIndex:c})}search(t){this.searchManager.setSearchKeyword(t),this.draw.render({isSetCursor:!1,isSubmitHistory:!1})}searchNavigatePre(){this.searchManager.searchNavigatePre()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}searchNavigateNext(){this.searchManager.searchNavigateNext()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}getSearchNavigateInfo(){return this.searchManager.getSearchNavigateInfo()}replace(t){if(this.draw.isReadonly()||!t||new RegExp(`${C}`,"g").test(t))return;const i=this.draw.getSearch().getSearchMatchList();if(!i.length)return;let n=0,s=0,o="",r="",a=-1;const l=this.draw.getOriginalElementList();for(let h=0;h<i.length;h++){const O=i[h];if(O.type===Xt.TABLE){const{tableIndex:P,trIndex:N,tdIndex:X,index:L,tdId:g}=O;r&&g!==r&&(s=0),r=g;const Y=P+n,V=l[Y].trList[N].tdList[X].value,T=L+s,W=V[T];if(o===O.groupId){this.draw.spliceElementList(V,T,1),s--;continue}for(let F=0;F<t.length;F++){const Z=t[F];F===0?W.value=Z:(this.draw.spliceElementList(V,T+F,0,q(b({},W),{value:Z})),s++)}}else{const P=O.index+n,N=l[P];if(N.type===M.ElementType.CONTROL&&N.controlComponent!==f.VALUE)continue;if(~a||(a=h),o===O.groupId){this.draw.spliceElementList(l,P,1),n--;continue}for(let X=0;X<t.length;X++){const L=t[X];X===0?N.value=L:(this.draw.spliceElementList(l,P+X,0,q(b({},N),{value:L})),n++)}}o=O.groupId}if(!~a)return;const u=i[a],c=u.index+(t.length-1);if(u.type===Xt.TABLE){const{tableIndex:h,trIndex:O,tdIndex:P,index:N}=u,X=l[h].trList[O].tdList[P].value[N];this.position.setPositionContext({isTable:!0,index:h,trIndex:O,tdIndex:P,tdId:X.tdId,trId:X.trId,tableId:X.tableId})}else this.position.setPositionContext({isTable:!1});this.range.setRange(c,c),this.draw.render({curIndex:c})}async print(){const{scale:t,printPixelRatio:e}=this.options;t!==1&&this.draw.setPageScale(1);const i=this.draw.getOriginalWidth(),n=this.draw.getOriginalHeight(),s=await this.draw.getDataURL({pixelRatio:e,mode:M.EditorMode.PRINT});wn(s,i,n),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),n=this.draw.getElementList()[e];!n||n.type!==M.ElementType.IMAGE||(n.id=x(),n.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),i=this.draw.getElementList()[t];!i||i.type!==M.ElementType.IMAGE||le(i.value,`${i.id}.png`)}changeImageDisplay(t,e){t.imgDisplay!==e&&(t.imgDisplay=e,this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!1}))}getImage(t){return this.draw.getDataURL(t)}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),i=this.draw.getOriginalMainElementList(),n=this.draw.getFooterElementList();return{header:Et(e,t).innerHTML,main:Et(i,t).innerHTML,footer:Et(n,t).innerHTML}}getText(){const t=this.draw.getHeaderElementList(),e=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:At(t),main:At(e),footer:At(i)}}getWordCount(){return this.workerManager.getWordCount()}getRangeText(){return this.range.toString()}getRangeContext(){const t=this.range.getRange(),{startIndex:e,endIndex:i}=t;if(!~e&&!~i)return null;const n=e===i,s=this.draw.getElementList(),o=Ut(s[n?e:e+1]),r=Ut(s[i]),a=this.position.getPositionList(),l=a[e].pageNo,u=a[i].pageNo,c=[],h=this.position.getSelectionPositionList();if(h){const O=this.draw.getOriginalHeight(),P=this.draw.getOriginalPageGap();let N=null,X=0,L=null;for(let g=0;g<h.length;g++){const{rowNo:Y,pageNo:V,coordinate:{leftTop:T,rightTop:W},lineHeight:F}=h[g];N===null||N!==Y?(L&&c.push(L),L={x:T[0],y:T[1]+V*(O+P),width:W[0]-T[0],height:F},N=Y,X=T[0]):(L.width=W[0]-X,g===h.length-1&&L&&c.push(L))}}return $({isCollapsed:n,startElement:o,endElement:r,startPageNo:l,endPageNo:u,rangeRects:c})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?k(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?k(t):null}pageMode(t){this.draw.setPageMode(t)}pageScaleRecovery(){const{scale:t}=this.options;t!==1&&this.draw.setPageScale(1)}pageScaleMinus(){const{scale:t}=this.options,e=t*10-1;e>=5&&this.draw.setPageScale(e/10)}pageScaleAdd(){const{scale:t}=this.options,e=t*10+1;e<=30&&this.draw.setPageScale(e/10)}paperSize(t,e){this.draw.setPaperSize(t,e)}paperDirection(t){this.draw.setPaperDirection(t)}getPaperMargin(){return this.options.margins}setPaperMargin(t){return this.draw.setPaperMargin(t)}insertElementList(t){if(!t.length||this.draw.isReadonly())return;const{startIndex:i}=this.range.getRange(),n=this.draw.getElementList();tt(n,t,i),this.draw.insertElementList(t)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(t,e)}setValue(t){this.draw.setValue(t)}removeControl(){const{startIndex:t,endIndex:e}=this.range.getRange();if(t!==e||this.draw.getElementList()[t].type!==M.ElementType.CONTROL)return;const o=this.draw.getControl().removeControl(t);this.range.setRange(o,o),this.draw.render({curIndex:o})}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){var n;const e=this.draw.getMainElementList();let i=-1;for(let s=0;s<e.length;s++)if(e[s].titleId===t&&((n=e[s+1])==null?void 0:n.titleId)!==t){i=s;break}!~i||(this.range.setRange(i,i),this.draw.render({curIndex:i,isCompute:!1,isSubmitHistory:!1}))}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let i=0;i<t.length;i++)if(t[i].value===C)for(;i+1<t.length;){const s=t[i+1];if(s.value!==C&&s.value!==ve)break;t.splice(i+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const i=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:i})}}setHTML(t){const{header:e,main:i,footer:n}=t,s=this.draw.getOriginalInnerWidth(),o=r=>r!==void 0?Qt(r,{innerWidth:s}):void 0;this.setValue({header:o(e),main:o(i),footer:o(n)})}setGroup(){return this.draw.isReadonly()?null:this.draw.getGroup().setGroup()}deleteGroup(t){this.draw.isReadonly()||this.draw.getGroup().deleteGroup(t)}getGroupIds(){return this.draw.getWorkerManager().getGroupIds()}locationGroup(t){const e=this.draw.getOriginalMainElementList(),i=this.draw.getGroup().getContextByGroupId(e,t);if(!i)return;const{isTable:n,index:s,trIndex:o,tdIndex:r,tdId:a,trId:l,tableId:u,endIndex:c}=i;this.position.setPositionContext({isTable:n,index:s,trIndex:o,tdIndex:r,tdId:a,trId:l,tableId:u}),this.range.setRange(c,c),this.draw.render({curIndex:c,isCompute:!1,isSubmitHistory:!1})}getControlValue(t){return this.draw.getControl().getValueByConceptId(t)}setControlValue(t){this.draw.isReadonly()||this.draw.getControl().setValueByConceptId(t)}}class xn{constructor(){d(this,"rangeStyleChange");d(this,"visiblePageNoListChange");d(this,"intersectionPageNoChange");d(this,"pageSizeChange");d(this,"pageScaleChange");d(this,"saved");d(this,"contentChange");d(this,"controlChange");d(this,"pageModeChange");d(this,"zoneChange");this.rangeStyleChange=null,this.visiblePageNoListChange=null,this.intersectionPageNoChange=null,this.pageSizeChange=null,this.pageScaleChange=null,this.saved=null,this.contentChange=null,this.controlChange=null,this.pageModeChange=null,this.zoneChange=null}}class vn{constructor(t){d(this,"contextMenuList");d(this,"shortcutList");d(this,"langMap");const{contextMenu:e,shortcut:i,i18n:n}=t;this.contextMenuList=e.registerContextMenuList.bind(e),this.shortcutList=i.registerShortcutList.bind(i),this.langMap=n.registerLangMap.bind(n)}}const ye={SELECTED_TEXT:"%s"},Bn=[{i18nPath:"contextmenu.control.delete",when:R=>{var t;return!R.isReadonly&&!R.editorHasSelection&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.CONTROL},callback:R=>{R.executeRemoveControl()}}],An=[{i18nPath:"contextmenu.global.cut",shortCut:`${Nt?"\u2318":"Ctrl"} + X`,when:R=>!R.isReadonly,callback:R=>{R.executeCut()}},{i18nPath:"contextmenu.global.copy",shortCut:`${Nt?"\u2318":"Ctrl"} + C`,when:R=>R.editorHasSelection,callback:R=>{R.executeCopy()}},{i18nPath:"contextmenu.global.paste",shortCut:`${Nt?"\u2318":"Ctrl"} + V`,when:R=>!R.isReadonly&&R.editorTextFocus,callback:R=>{R.executePaste()}},{i18nPath:"contextmenu.global.selectAll",shortCut:`${Nt?"\u2318":"Ctrl"} + A`,when:R=>R.editorTextFocus,callback:R=>{R.executeSelectAll()}},{isDivider:!0},{i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:R=>{R.executePrint()}}],_n=[{i18nPath:"contextmenu.hyperlink.delete",when:R=>{var t;return!R.isReadonly&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.HYPERLINK},callback:R=>{R.executeDeleteHyperlink()}},{i18nPath:"contextmenu.hyperlink.cancel",when:R=>{var t;return!R.isReadonly&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.HYPERLINK},callback:R=>{R.executeCancelHyperlink()}},{i18nPath:"contextmenu.hyperlink.edit",when:R=>{var t;return!R.isReadonly&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.HYPERLINK},callback:(R,t)=>{var i;const e=window.prompt("\u7F16\u8F91\u94FE\u63A5",(i=t.startElement)==null?void 0:i.url);e&&R.executeEditHyperlink(e)}}],kn=[{i18nPath:"contextmenu.image.change",icon:"image-change",when:R=>{var t;return!R.isReadonly&&!R.editorHasSelection&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.IMAGE},callback:R=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],i=new FileReader;i.readAsDataURL(e),i.onload=()=>{const n=i.result;R.executeReplaceImageElement(n)}},t.click()}},{i18nPath:"contextmenu.image.saveAs",icon:"image",when:R=>{var t;return!R.editorHasSelection&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.IMAGE},callback:R=>{R.executeSaveAsImageElement()}},{i18nPath:"contextmenu.image.textWrap",when:R=>{var t;return!R.isReadonly&&!R.editorHasSelection&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.IMAGE},childMenus:[{i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(R,t)=>{R.executeChangeImageDisplay(t.startElement,M.ImageDisplay.BLOCK)}},{i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(R,t)=>{R.executeChangeImageDisplay(t.startElement,M.ImageDisplay.INLINE)}}]}],zn=[{isDivider:!0},{i18nPath:"contextmenu.table.border",icon:"border-all",when:R=>!R.isReadonly&&R.isInTable,childMenus:[{i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:R=>{R.executeTableBorderType(M.TableBorder.ALL)}},{i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:R=>{R.executeTableBorderType(M.TableBorder.EMPTY)}},{i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:R=>{R.executeTableBorderType(M.TableBorder.EXTERNAL)}},{i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:R=>{R.executeTableTdBorderType(M.TdBorder.BOTTOM)}},{i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:R=>{R.executeTableTdSlashType(M.TdSlash.FORWARD)}},{i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:R=>{R.executeTableTdSlashType(M.TdSlash.BACK)}}]}]},{i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:R=>!R.isReadonly&&R.isInTable,childMenus:[{i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:R=>{R.executeTableTdVerticalAlign(M.VerticalAlign.TOP)}},{i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:R=>{R.executeTableTdVerticalAlign(M.VerticalAlign.MIDDLE)}},{i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:R=>{R.executeTableTdVerticalAlign(M.VerticalAlign.BOTTOM)}}]},{i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:R=>!R.isReadonly&&R.isInTable,childMenus:[{i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:R=>{R.executeInsertTableTopRow()}},{i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:R=>{R.executeInsertTableBottomRow()}},{i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:R=>{R.executeInsertTableLeftCol()}},{i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:R=>{R.executeInsertTableRightCol()}}]},{i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:R=>!R.isReadonly&&R.isInTable,childMenus:[{i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:R=>{R.executeDeleteTableRow()}},{i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:R=>{R.executeDeleteTableCol()}},{i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:R=>{R.executeDeleteTable()}}]},{i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:R=>!R.isReadonly&&R.isCrossRowCol,callback:R=>{R.executeMergeTableCell()}},{i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:R=>!R.isReadonly&&R.isInTable,callback:R=>{R.executeCancelMergeTableCell()}}];class $n{constructor(t,e){d(this,"draw");d(this,"command");d(this,"range");d(this,"position");d(this,"i18n");d(this,"container");d(this,"contextMenuList");d(this,"contextMenuContainerList");d(this,"contextMenuRelationShip");d(this,"context");d(this,"_proxyContextMenuEvent",t=>{var n;this.context=this._getContext();const e=[];let i=!1;for(let s=0;s<this.contextMenuList.length;s++){const o=this.contextMenuList[s];o.isDivider?e.push(o):((n=o.when)==null?void 0:n.call(o,this.context))&&(e.push(o),i=!0)}i&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()});d(this,"_handleSideEffect",t=>{if(this.contextMenuContainerList.length){const e=(t==null?void 0:t.composedPath()[0])||t.target;ft(e,n=>!!n&&n.nodeType===1&&n.getAttribute(gt)===M.EditorComponent.CONTEXTMENU,!0)||this.dispose()}});this.draw=t,this.command=e,this.range=t.getRange(),this.position=t.getPosition(),this.i18n=t.getI18n(),this.container=t.getContainer(),this.context=null,this.contextMenuList=[...An,...zn,...kn,...Bn,..._n],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_getContext(){const t=this.draw.isReadonly(),{isCrossRowCol:e,startIndex:i,endIndex:n}=this.range.getRange(),s=!!(~i||~n),o=s&&i!==n,a=this.position.getPositionContext().isTable,l=a&&!!e,u=this.draw.getElementList(),c=u[i]||null,h=u[n]||null,O=this.draw.getZone().getZone();return{startElement:c,endElement:h,isReadonly:t,editorHasSelection:o,editorTextFocus:s,isInTable:a,isCrossRowCol:l,zone:O}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${H}-contextmenu-container`),t.setAttribute(gt,M.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){const{contextMenuList:e,left:i,top:n,parentMenuContainer:s}=t,o=this._createContextMenuContainer(),r=document.createElement("div");r.classList.add(`${H}-contextmenu-content`);let a=null;s&&this.contextMenuRelationShip.set(s,o);for(let X=0;X<e.length;X++){const L=e[X];if(L.isDivider){if(X!==0&&X!==e.length-1){const g=document.createElement("div");g.classList.add(`${H}-contextmenu-divider`),r.append(g)}}else{const g=document.createElement("div");g.classList.add(`${H}-contextmenu-item`),L.childMenus?(g.classList.add(`${H}-contextmenu-sub-item`),g.onmouseenter=()=>{this._setHoverStatus(g,!0),this._removeSubMenu(o);const W=g.getBoundingClientRect(),F=W.left+W.width,Z=W.top;a=this._render({contextMenuList:L.childMenus,left:F,top:Z,parentMenuContainer:o})},g.onmouseleave=W=>{(!a||!a.contains(W.relatedTarget))&&this._setHoverStatus(g,!1)}):(g.onmouseenter=()=>{this._setHoverStatus(g,!0),this._removeSubMenu(o)},g.onmouseleave=()=>{this._setHoverStatus(g,!1)},g.onclick=()=>{L.callback&&this.context&&L.callback(this.command,this.context),this.dispose()});const Y=document.createElement("i");g.append(Y),L.icon&&Y.classList.add(`${H}-contextmenu-${L.icon}`);const V=document.createElement("span"),T=L.i18nPath?this._formatName(this.i18n.t(L.i18nPath)):this._formatName(L.name||"");if(V.append(document.createTextNode(T)),g.append(V),L.shortCut){const W=document.createElement("span");W.classList.add(`${H}-shortcut`),W.append(document.createTextNode(L.shortCut)),g.append(W)}r.append(g)}}o.append(r),o.style.display="block";const l=window.innerWidth,u=o.getBoundingClientRect(),c=u.width,h=i+c>l?i-c:i;o.style.left=`${h}px`;const O=window.innerHeight,P=u.height,N=n+P>O?n-P:n;return o.style.top=`${N}px`,this.contextMenuContainerList.push(o),o}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){var i;e?((i=t.parentNode)==null||i.querySelectorAll(`${H}-contextmenu-item`).forEach(n=>n.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(ye),i=new RegExp(`${e.join("|")}`);let n=t;if(i.test(n)){const s=new RegExp(ye.SELECTED_TEXT,"g");if(s.test(n)){const o=this.range.toString();n=n.replace(s,o)}}return n}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const jn={top:30,maxHeightRadio:M.MaxHeightRatio.HALF,disabled:!1},qn={placeholderColor:"#9c9b9b",bracketColor:"#000000",prefix:"{",postfix:"}"},tR={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",fontStyle:"#ffffff"},eR=[{key:M.KeyMap.X_UPPERCASE,ctrl:!0,shift:!0,callback:R=>{R.executeStrikeout()}},{key:M.KeyMap.LEFT_BRACKET,mod:!0,callback:R=>{R.executeSizeAdd()}},{key:M.KeyMap.RIGHT_BRACKET,mod:!0,callback:R=>{R.executeSizeMinus()}},{key:M.KeyMap.B,mod:!0,callback:R=>{R.executeBold()}},{key:M.KeyMap.I,mod:!0,callback:R=>{R.executeItalic()}},{key:M.KeyMap.U,mod:!0,callback:R=>{R.executeUnderline()}},{key:Nt?M.KeyMap.COMMA:M.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:R=>{R.executeSuperscript()}},{key:Nt?M.KeyMap.PERIOD:M.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:R=>{R.executeSubscript()}},{key:M.KeyMap.L,mod:!0,callback:R=>{R.executeRowFlex(M.RowFlex.LEFT)}},{key:M.KeyMap.E,mod:!0,callback:R=>{R.executeRowFlex(M.RowFlex.CENTER)}},{key:M.KeyMap.R,mod:!0,callback:R=>{R.executeRowFlex(M.RowFlex.RIGHT)}},{key:M.KeyMap.J,mod:!0,callback:R=>{R.executeRowFlex(M.RowFlex.ALIGNMENT)}}],iR=[{key:M.KeyMap.ZERO,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(null)}},{key:M.KeyMap.ONE,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.FIRST)}},{key:M.KeyMap.TWO,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.SECOND)}},{key:M.KeyMap.THREE,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.THIRD)}},{key:M.KeyMap.FOUR,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.FOURTH)}},{key:M.KeyMap.FIVE,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.FIFTH)}},{key:M.KeyMap.SIX,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.SIXTH)}}],nR=[{key:M.KeyMap.I,shift:!0,mod:!0,callback:R=>{R.executeList(M.ListType.UL,M.ListStyle.DISC)}},{key:M.KeyMap.U,shift:!0,mod:!0,callback:R=>{R.executeList(M.ListType.OL)}}];class RR{constructor(t,e){d(this,"command");d(this,"globalShortcutList");d(this,"agentShortcutList");d(this,"_globalKeydown",t=>{!this.globalShortcutList.length||this._execute(t,this.globalShortcutList)});this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...eR,...iR,...nR]),this._addEvent(),t.getCursor().getAgentDom().addEventListener("keydown",this._agentKeydown.bind(this))}_addEvent(){document.addEventListener("keydown",this._globalKeydown)}removeEvent(){document.removeEventListener("keydown",this._globalKeydown)}_addShortcutList(t){for(let e=t.length-1;e>=0;e--){const i=t[e];i.isGlobal?this.globalShortcutList.unshift(i):this.agentShortcutList.unshift(i)}}registerShortcutList(t){this._addShortcutList(t)}_agentKeydown(t){!this.agentShortcutList.length||this._execute(t,this.agentShortcutList)}_execute(t,e){var i;for(let n=0;n<e.length;n++){const s=e[n];if((s.mod?Ot(t)===!!s.mod:t.ctrlKey===!!s.ctrl&&t.metaKey===!!s.meta)&&t.shiftKey===!!s.shift&&t.altKey===!!s.alt&&t.key===s.key){s.disable||((i=s==null?void 0:s.callback)==null||i.call(s,this.command),t.preventDefault());break}}}}const sR={bottom:30,maxHeightRadio:M.MaxHeightRatio.HALF,disabled:!1},oR={data:"",color:"#DCDFE6",opacity:1,size:16,font:"Yahei"};class rR{constructor(t){d(this,"editor");this.editor=t}use(t,e){t(this.editor,e)}}class lR{constructor(){d(this,"eventHub");this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const i=this.eventHub.get(t)||new Set;i.add(e),this.eventHub.set(t,i)}emit(t,e){if(!t)return;const i=this.eventHub.get(t);if(!!i){if(i.size===1)return[...i][0](e);i.forEach(n=>n(e))}}off(t,e){if(!t||typeof e!="function")return;const i=this.eventHub.get(t);!i||i.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}}const aR={opacity:.1,backgroundColor:"#E99D00",activeOpacity:.5,activeBackgroundColor:"#E99D00",disabled:!1};class cR{constructor(){d(this,"paste")}}const uR={font:"Yahei",fontSize:12,lineDash:[3,1]};class Ce{constructor(t,e,i={}){d(this,"command");d(this,"listener");d(this,"eventBus");d(this,"override");d(this,"register");d(this,"destroy");d(this,"use");const n=b(b({},jn),i.header),s=b(b({},sR),i.footer),o=b(b({},rn),i.pageNumber),r=b(b({},te),i.watermark),a=b(b({},qn),i.control),l=b(b({},tR),i.checkbox),u=b(b({},ii),i.cursor),c=b(b({},Fi),i.title),h=b(b({},oR),i.placeholder),O=b(b({},aR),i.group),P=b(b({},uR),i.pageBreak),N=q(b({mode:M.EditorMode.EDIT,defaultType:"TEXT",defaultFont:"Yahei",defaultSize:16,minSize:5,maxSize:72,defaultRowMargin:1,defaultBasicRowMarginHeight:8,defaultTabWidth:32,width:794,height:1123,scale:1,pageGap:20,backgroundColor:"#FFFFFF",underlineColor:"#000000",strikeoutColor:"#FF0000",rangeAlpha:.6,rangeColor:"#AECBFA",rangeMinWidth:5,searchMatchAlpha:.6,searchMatchColor:"#FFFF00",searchNavigateMatchColor:"#AAD280",highlightAlpha:.6,resizerColor:"#4182D9",resizerSize:5,marginIndicatorSize:35,marginIndicatorColor:"#BABABA",margins:[100,120,100,120],pageMode:M.PageMode.PAGING,tdPadding:[0,5,5,5],defaultTrMinHeight:42,defaultColMinWidth:40,defaultHyperlinkColor:"#0000FF",paperDirection:M.PaperDirection.VERTICAL,inactiveAlpha:.6,historyMaxRecordCount:100,wordBreak:M.WordBreak.BREAK_WORD,printPixelRatio:3,maskMargin:[0,0,0,0],letterClass:[oe.ENGLISH]},i),{header:n,footer:s,pageNumber:o,watermark:r,control:a,checkbox:l,cursor:u,title:c,placeholder:h,group:O,pageBreak:P});let X=[],L=[],g=[];Array.isArray(e)?L=e:(X=e.header||[],L=e.main,g=e.footer||[]),[X,L,g].forEach(Z=>{at(Z,{editorOptions:N})}),this.listener=new xn,this.eventBus=new lR,this.override=new cR;const V=new Cn(t,N,{header:X,main:L,footer:g},this.listener,this.eventBus,this.override);this.command=new be(new Jn(V));const T=new $n(V,this.command),W=new RR(V,this.command);this.register=new vn({contextMenu:T,shortcut:W,i18n:V.getI18n()}),this.destroy=()=>{V.destroy(),W.removeEvent(),T.removeEvent()};const F=new rR(this);this.use=F.use.bind(F)}}M.Command=be,M.EDITOR_COMPONENT=gt,M.Editor=Ce,M.LETTER_CLASS=oe,M.default=Ce,Object.defineProperty(M,"__esModule",{value:!0}),M[Symbol.toStringTag]="Module"});
|
|
78
|
+
`)}}return i}return t(k(R))}class Ii{constructor(t,e){d(this,"draw");d(this,"container");d(this,"agentCursorDom");d(this,"canvasEvent");this.draw=t,this.container=t.getContainer(),this.canvasEvent=e;const i=document.createElement("textarea");i.autocomplete="off",i.classList.add(`${E}-inputarea`),i.innerText="",this.container.append(i),this.agentCursorDom=i,i.onkeydown=n=>this._keyDown(n),i.oninput=re(this._input.bind(this),0),i.onpaste=n=>this._paste(n),i.addEventListener("compositionstart",this._compositionstart.bind(this)),i.addEventListener("compositionend",this._compositionend.bind(this))}getAgentCursorDom(){return this.agentCursorDom}_keyDown(t){this.canvasEvent.keydown(t)}_input(t){!t.data||this.canvasEvent.input(t.data)}_paste(t){if(this.draw.isReadonly())return;const i=t.clipboardData;if(!i)return;const{paste:n}=this.draw.getOverride();if(n){n(t);return}const s=this.draw.getRange(),{startIndex:o}=s.getRange(),r=this.draw.getElementList();let a=!1;for(let l=0;l<i.items.length;l++)if(i.items[l].type==="text/html"){a=!0;break}for(let l=0;l<i.items.length;l++){const u=i.items[l];if(u.kind==="string")u.type==="text/plain"&&!a&&u.getAsString(c=>{this.canvasEvent.input(c)}),u.type==="text/html"&&a&&u.getAsString(c=>{const h=Qt(c,{innerWidth:this.draw.getOriginalInnerWidth()});if(~o&&!s.getIsSelectAll()){const O=r[o];if((O==null?void 0:O.titleId)||(O==null?void 0:O.listId)){let P=0;for(;P<h.length;){const N=h[P];if(O.titleId&&/^\n/.test(N.value))break;if(ui.includes(N.type)){if(h.splice(P,1),N.valueList)for(let X=0;X<N.valueList.length;X++){const L=N.valueList[X];L.value===C||L.value===`
|
|
79
|
+
`||(h.splice(P,0,L),P++)}P--}P++}}tt(r,h,o,{isBreakWhenWrap:!0})}this.draw.insertElementList(h)});else if(u.kind==="file"&&u.type.includes("image")){const c=u.getAsFile();if(c){const h=new FileReader;h.readAsDataURL(c),h.onload=()=>{const O=new Image,P=h.result;O.src=P,O.onload=()=>{const N={value:P,type:M.ElementType.IMAGE,width:O.width,height:O.height};~o&&tt(r,[N],o),this.draw.insertElementList([N])}}}}}t.preventDefault()}_compositionstart(){this.canvasEvent.compositionstart()}_compositionend(t){this.canvasEvent.compositionend(t)}}class Ki{constructor(t,e){d(this,"ANIMATION_CLASS",`${E}-cursor--animation`);d(this,"draw");d(this,"container");d(this,"options");d(this,"position");d(this,"cursorDom");d(this,"cursorAgent");d(this,"blinkTimeout");this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${E}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new Ii(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=""}_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)}drawCursor(t){let e=this.position.getCursorPosition();if(!e)return;const{scale:i,cursor:n}=this.options,{color:s,width:o,isShow:r=!0,isBlink:a=!0,isFocus:l=!0,hitLineStartIndex:u}=H(H({},n),t),c=this.draw.getHeight(),h=this.draw.getPageGap();u&&(e=this.position.getPositionList()[u]);const{metrics:O,coordinate:{leftTop:P,rightTop:N},ascent:X,pageNo:L}=e,V=(this.draw.getZone().isMainActive()?L:this.draw.getPageNo())*(c+h),T=O.height/4,W=O.height+T*2,F=this.cursorAgent.getAgentCursorDom();l&&setTimeout(()=>{F.focus(),F.setSelectionRange(0,0)});const Z=O.boundingBoxDescent<0?0:O.boundingBoxDescent,S=P[1]+X+Z-(W-T)+V,m=u?P[0]:N[0];if(F.style.left=`${m}px`,F.style.top=`${S+W-ei*i}px`,!r)return;const I=this.draw.isReadonly();this.cursorDom.style.width=`${o}px`,this.cursorDom.style.backgroundColor=s,this.cursorDom.style.left=`${m}px`,this.cursorDom.style.top=`${S}px`,this.cursorDom.style.display=I?"none":"block",this.cursorDom.style.height=`${W}px`,a?this._setBlinkTimeout():this._clearBlinkTimeout()}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:i}=t;if(!e||!i)return;const{pageNo:n,coordinate:{leftTop:s,leftBottom:o}}=e,r=n*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,a=i===rt.UP,l=o[0],u=a?s[1]+r:o[1]+r,c=qe(this.container),h={left:0,right:0,top:0,bottom:0};if(c===document.documentElement)h.right=window.innerWidth,h.bottom=window.innerHeight;else{const{left:P,right:N,top:X,bottom:L}=c.getBoundingClientRect();h.left=P,h.right=N,h.top=X,h.bottom=L}const{maskMargin:O}=this.options;if(h.top+=O[0],h.bottom-=O[2],!(l>=h.left&&l<=h.right&&u>=h.top&&u<=h.bottom)){const{scrollLeft:P,scrollTop:N}=c;a?c.scroll(P,N-(h.top-u)):c.scroll(P,N+u-h.bottom)}}}var _t;(function(R){R[R.LEFT=0]="LEFT",R[R.CENTER=1]="CENTER",R[R.RIGHT=2]="RIGHT"})(_t||(_t={}));const Nt=typeof navigator!="undefined"&&/Mac OS X/.test(navigator.userAgent),fi=typeof navigator!="undefined"&&/iPad|iPhone/.test(navigator.userAgent);function Ot(R){return Nt?R.metaKey:R.ctrlKey}M.KeyMap=void 0,function(R){R.Delete="Delete",R.Backspace="Backspace",R.Enter="Enter",R.Left="ArrowLeft",R.Right="ArrowRight",R.Up="ArrowUp",R.Down="ArrowDown",R.ESC="Escape",R.TAB="Tab",R.META="Meta",R.LEFT_BRACKET="[",R.RIGHT_BRACKET="]",R.COMMA=",",R.PERIOD=".",R.LEFT_ANGLE_BRACKET="<",R.RIGHT_ANGLE_BRACKET=">",R.EQUAL="=",R.MINUS="-",R.PLUS="+",R.A="a",R.B="b",R.C="c",R.D="d",R.E="e",R.F="f",R.G="g",R.H="h",R.I="i",R.J="j",R.K="k",R.L="l",R.M="m",R.N="n",R.O="o",R.P="p",R.Q="q",R.R="r",R.S="s",R.T="t",R.U="u",R.V="v",R.W="w",R.X="x",R.Y="y",R.Z="z",R.A_UPPERCASE="A",R.B_UPPERCASE="B",R.C_UPPERCASE="C",R.D_UPPERCASE="D",R.E_UPPERCASE="E",R.F_UPPERCASE="F",R.G_UPPERCASE="G",R.H_UPPERCASE="H",R.I_UPPERCASE="I",R.J_UPPERCASE="J",R.K_UPPERCASE="K",R.L_UPPERCASE="L",R.M_UPPERCASE="M",R.N_UPPERCASE="N",R.O_UPPERCASE="O",R.P_UPPERCASE="P",R.Q_UPPERCASE="Q",R.R_UPPERCASE="R",R.S_UPPERCASE="S",R.T_UPPERCASE="T",R.U_UPPERCASE="U",R.V_UPPERCASE="V",R.W_UPPERCASE="W",R.X_UPPERCASE="X",R.Y_UPPERCASE="Y",R.Z_UPPERCASE="Z",R.ZERO="0",R.ONE="1",R.TWO="2",R.THREE="3",R.FOUR="4",R.FIVE="5",R.SIX="6",R.SEVEN="7",R.EIGHT="8",R.NINE="9"}(M.KeyMap||(M.KeyMap={}));class kt{constructor(t,e){d(this,"element");d(this,"control");this.element=t,this.control=e}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(),i=t[e],n=[];let s=e;for(;s>0;){const r=t[s];if(r.controlId!==i.controlId||r.controlComponent===f.PREFIX)break;r.controlComponent===f.VALUE&&n.unshift(r),s--}let o=e+1;for(;o<t.length;){const r=t[o];if(r.controlId!==i.controlId||r.controlComponent===f.POSTFIX)break;r.controlComponent===f.VALUE&&n.push(r),o++}return n}setValue(){return-1}setSelect(t={}){const{control:e}=this.element,i=t.elementList||this.control.getElementList(),{startIndex:n}=t.range||this.control.getRange(),s=i[n],o=[];let r=n;for(;r>0;){const l=i[r];if(l.controlId!==s.controlId||l.controlComponent===f.PREFIX)break;if(l.controlComponent===f.CHECKBOX){const u=l.checkbox;u&&u.value&&u.code&&o.unshift(u.code)}r--}let a=n+1;for(;a<i.length;){const l=i[a];if(l.controlId!==s.controlId||l.controlComponent===f.POSTFIX)break;if(l.controlComponent===f.CHECKBOX){const u=l.checkbox;u&&u.value&&u.code&&o.push(u.code)}a++}e.code=o.join(",")}keydown(t){const e=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:n}=e;return t.key===M.KeyMap.Backspace||t.key===M.KeyMap.Delete?this.control.removeControl(i):n}cut(){return-1}}function Di(R,t){if(R.button===_t.RIGHT)return;const e=t.getDraw(),i=e.isReadonly(),n=e.getRange(),s=e.getPosition();if(!t.isAllowDrag){const m=n.getRange();if(!i&&m.startIndex!==m.endIndex&&n.getIsPointInRange(R.offsetX,R.offsetY)){t.isAllowDrag=!0,t.cacheRange=j(m),t.cacheElementList=e.getElementList(),t.cachePositionList=s.getPositionList();return}}const r=R.target.dataset.index;r&&e.setPageNo(Number(r)),t.isAllowSelection=!0;const a=s.adjustPositionContext({x:R.offsetX,y:R.offsetY});if(!a)return;const{index:l,isDirectHit:u,isCheckbox:c,isImage:h,isTable:O,tdValueIndex:P,hitLineStartIndex:N}=a;t.mouseDownStartPosition=$(H({},a),{index:O?P:l});const X=e.getElementList(),L=s.getPositionList(),g=O?P:l,Y=X[g],V=!!(u&&h),T=!!(u&&c);if(~l){n.setRange(g,g),s.setCursorPosition(L[g]);const m=T&&!i;if(m){const{checkbox:I}=Y;I?I.value=!I.value:Y.checkbox={value:!0};const Q=e.getControl().getActiveControl();Q instanceof kt&&Q.setSelect()}e.render({curIndex:g,isSubmitHistory:m,isSetCursor:!V&&!T,isCompute:!1}),N&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:N})}const W=e.getPreviewer();W.clearResizer(),V&&!i&&(W.drawResizer(Y,L[g],Y.type===M.ElementType.LATEX?{mime:"svg",srcKey:"laTexSVG"}:{}),e.getCursor().drawCursor({isShow:!1}));const F=e.getTableTool();F.dispose(),O&&!i&&F.render();const Z=e.getHyperlinkParticle();Z.clearHyperlinkPopup(),Y.type===M.ElementType.HYPERLINK&&(Ot(R)?Z.openHyperlink(Y):Z.drawHyperlinkPopup(Y,L[g]));const S=e.getDateParticle();S.clearDatePicker(),Y.type===M.ElementType.DATE&&!i&&S.renderDatePicker(Y,L[g])}function Gt(R){const t=x();return Reflect.set(R,"dragId",t),t}function bt(R,t){return t.findIndex(e=>e.dragId===R)}function mi(R,t){var e,i,n;if(t.isAllowDrop){const s=t.getDraw();if(s.isReadonly())return;const o=s.getPosition(),r=o.getPositionList(),a=s.getRange(),l=t.cacheRange,u=t.cacheElementList,c=t.cachePositionList,h=a.getRange();if(h.startIndex>=l.startIndex&&h.endIndex<=l.endIndex){a.replaceRange(H({},l)),s.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1});return}const O=u.slice(l.startIndex+1,l.endIndex+1);if(O.find(v=>v.type===M.ElementType.CONTROL)){const v=u[l.startIndex+1],st=u[l.endIndex];if(!((v.type!==M.ElementType.CONTROL||v.controlComponent===f.PREFIX)&&(st.type!==M.ElementType.CONTROL||st.controlComponent===f.POSTFIX)||v.controlId===st.controlId&&v.controlComponent===f.PREFIX&&st.controlComponent===f.POSTFIX||((e=v.control)==null?void 0:e.type)===M.ControlType.TEXT&&v.controlComponent===f.VALUE&&((i=st.control)==null?void 0:i.type)===M.ControlType.TEXT&&st.controlComponent===f.VALUE)){s.render({curIndex:h.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const N=s.getOptions(),X=s.getElementList(),L=O.map(v=>{var st;if(!v.type||v.type===M.ElementType.TEXT||((st=v.control)==null?void 0:st.type)===M.ControlType.TEXT){const Lt={value:v.value};return mt.forEach(Yt=>{const Zt=v[Yt];Zt!==void 0&&(Lt[Yt]=Zt)}),Lt}else{const Lt=j(v);return at([Lt],{isHandleFirstElement:!1,editorOptions:N}),Lt}});tt(X,L,h.startIndex);const g=Gt(u[l.startIndex]),Y=Gt(u[l.endIndex]),V=L.length;let T=h.startIndex,W=T+V;const F=s.getControl(),Z=F.getActiveControl();if(Z&&u[T].controlComponent!==f.POSTFIX?(W=Z.setValue(L),T=W-V):s.spliceElementList(X,T+1,0,...L),!~W){s.render({isSetCursor:!1});return}const S=Gt(X[T]),m=Gt(X[W]),I=bt(g,u),U=bt(Y,u),Q=u[U];Q.type===M.ElementType.CONTROL&&Q.controlComponent!==f.POSTFIX?(a.replaceRange($(H({},l),{startIndex:I,endIndex:U})),(n=F.getActiveControl())==null||n.cut()):s.spliceElementList(u,I+1,U-I);const D=X[h.startIndex],K=u[l.startIndex],G=r[h.startIndex],y=c[l.startIndex],p=o.getPositionContext();let b=p.index;b&&(D.tableId&&!K.tableId?y.index<b&&(b-=V):!D.tableId&&K.tableId&&G.index<b&&(b+=V),o.setPositionContext($(H({},p),{index:b})));const w=bt(S,X),A=bt(m,X);a.setRange(w,A,h.tableId,h.startTdIndex,h.endTdIndex,h.startTrIndex,h.endTrIndex),s.render({isSetCursor:!1})}else t.isAllowDrag&&t.mousedown(R)}function pi(R,t){const i=t.getDraw().getPageContainer(),{x:n,y:s,width:o,height:r}=i.getBoundingClientRect();R.x>=n&&R.x<=n+o&&R.y>=s&&R.y<=s+r||t.setIsAllowSelection(!1)}function Hi(R,t){const e=t.getDraw();if(t.isAllowDrag){const V=R.offsetX,T=R.offsetY,{startIndex:W,endIndex:F}=t.cacheRange,Z=t.cachePositionList;for(let S=W+1;S<=F;S++){const{coordinate:{leftTop:m,rightBottom:I}}=Z[S];if(V>=m[0]&&V<=I[0]&&T>=m[1]&&T<=I[1])return}t.dragover(R),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const n=R.target.dataset.index;n&&e.setPageNo(Number(n));const o=e.getPosition().getPositionByXY({x:R.offsetX,y:R.offsetY});if(!~o.index)return;const{index:r,isTable:a,tdValueIndex:l,tdIndex:u,trIndex:c,tableId:h}=o,{index:O,isTable:P,tdIndex:N,trIndex:X,tableId:L}=t.mouseDownStartPosition,g=a?l:r,Y=e.getRange();if(a&&P&&(u!==N||c!==X))Y.setRange(g,g,h,N,u,X,c);else{let V=~g?g:0;if((P||a)&&L!==h)return;let T=O;if(T>V&&([T,V]=[V,T]),T===V)return;Y.setRange(T,V)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function Ei(R,t){var L,g,Y,V;if(t.isComposing)return;const e=t.getDraw(),i=e.getPosition(),n=i.getCursorPosition();if(!n)return;const s=e.isReadonly(),o=e.getHistoryManager(),r=e.getElementList(),a=i.getPositionList(),{index:l}=n,u=e.getRange(),{startIndex:c,endIndex:h}=u.getRange(),O=c===h,P=e.getControl(),N=P.isPartRangeInControlOutside(),X=P.getActiveControl();if(R.key===M.KeyMap.Backspace){if(s||N)return;let T;if(X)T=P.keydown(R);else{if(O&&r[l].value===C&&l===0){R.preventDefault();return}const W=r[c];if(O&&W.rowFlex&&W.value===C){const F=e.getRowList(),Z=a[c].rowNo;F[Z].elementList.forEach(m=>{delete m.rowFlex})}O?e.spliceElementList(r,l,1):e.spliceElementList(r,c+1,h-c),T=O?l-1:c}u.setRange(T,T),e.render({curIndex:T})}else if(R.key===M.KeyMap.Delete){if(s||N)return;let T;X?T=P.keydown(R):((L=r[h+1])==null?void 0:L.type)===M.ElementType.CONTROL?T=P.removeControl(h+1):(O?e.spliceElementList(r,l+1,1):e.spliceElementList(r,c+1,h-c),T=O?l:c),u.setRange(T,T),e.render({curIndex:T})}else if(R.key===M.KeyMap.Enter){if(s||N)return;const T={value:C},W=r[c],F=r[h];R.shiftKey&&W.listId&&(T.listWrap=!0),F.titleId&&F.titleId!==((g=r[h+1])==null?void 0:g.titleId)||tt(r,[T],c);let Z;X&&!P.isRangInPostfix()?Z=P.setValue([T]):(O?e.spliceElementList(r,l+1,0,T):e.spliceElementList(r,c+1,h-c,T),Z=l+1),~Z&&(u.setRange(Z,Z),e.render({curIndex:Z})),R.preventDefault()}else if(R.key===M.KeyMap.Left){if(s)return;if(l>0){const T=i.getCursorPosition();let W=1;if(Ot(R)){const I=e.getLetterReg(),U=R.shiftKey&&!O&&c===(T==null?void 0:T.index)?h:c;if(I.test((Y=r[U])==null?void 0:Y.value)){let Q=U-1;for(;Q>0;){const D=r[Q];if(!I.test(D.value))break;W++,Q--}}}const F=c-W;let Z=F,S=F;if(R.shiftKey&&T&&(c!==h?c===T.index?(Z=c,S=h-W):(Z=F,S=h):S=h),!~Z||!~S)return;u.setRange(Z,S);const m=Z===S;e.render({curIndex:m?Z:void 0,isSetCursor:m,isSubmitHistory:!1,isCompute:!1}),R.preventDefault()}}else if(R.key===M.KeyMap.Right){if(s)return;if(l<a.length){const T=i.getCursorPosition();let W=1;if(Ot(R)){const U=e.getLetterReg(),Q=R.shiftKey&&!O&&c===(T==null?void 0:T.index)?h:c;if(U.test((V=r[Q+1])==null?void 0:V.value)){let D=Q+2;for(;D<r.length;){const K=r[D];if(!U.test(K.value))break;W++,D++}}}const F=h+W;let Z=F,S=F;R.shiftKey&&T&&(c!==h?c===T.index?(Z=c,S=F):(Z=c+W,S=h):Z=c);const m=r.length-1;if(Z>m||S>m)return;u.setRange(Z,S);const I=Z===S;e.render({curIndex:I?Z:void 0,isSetCursor:I,isSubmitHistory:!1,isCompute:!1}),R.preventDefault()}}else if(R.key===M.KeyMap.Up||R.key===M.KeyMap.Down){if(s)return;let T=n;R.shiftKey&&(c===n.index?T=a[h]:T=a[c]);const{index:W,rowNo:F,rowIndex:Z,coordinate:{leftTop:[S],rightTop:[m]}}=T,I=R.key===M.KeyMap.Up;if(I&&Z===0||!I&&Z===e.getRowCount()-1)return;const U=[];if(I){let y=W-1;for(;y>0;){const p=a[y];if(y--,p.rowNo!==F){if(U[0]&&U[0].rowNo!==p.rowNo)break;U.unshift(p)}}}else{let y=W+1;for(;y<a.length;){const p=a[y];if(y++,p.rowNo!==F){if(U[0]&&U[0].rowNo!==p.rowNo)break;U.push(p)}}}let Q=0;for(let y=0;y<U.length;y++){const p=U[y],{coordinate:{leftTop:[b],rightTop:[w]}}=p;if(y===U.length-1&&(Q=p.index),!(m<=b||S>=w)){Q=p.index;break}}if(!Q)return;let D=Q,K=Q;R.shiftKey&&(c!==h?c===n.index?D=c:K=h:I?K=h:D=c),D>K&&([D,K]=[K,D]),u.setRange(D,K);const G=D===K;e.render({curIndex:G?D:void 0,isSetCursor:G,isSubmitHistory:!1,isCompute:!1}),e.getCursor().moveCursorToVisible({cursorPosition:a[I?D:K],direction:I?rt.UP:rt.DOWN})}else if(Ot(R)&&R.key===M.KeyMap.Z){if(s)return;o.undo(),R.preventDefault()}else if(Ot(R)&&R.key===M.KeyMap.Y){if(s)return;o.redo(),R.preventDefault()}else if(Ot(R)&&R.key===M.KeyMap.C)t.copy(),R.preventDefault();else if(Ot(R)&&R.key===M.KeyMap.X)t.cut(),R.preventDefault();else if(Ot(R)&&R.key===M.KeyMap.A)t.selectAll(),R.preventDefault();else if(Ot(R)&&R.key===M.KeyMap.S){if(s)return;const T=e.getListener();T.saved&&T.saved(e.getValue());const W=e.getEventBus();W.isSubscribe("saved")&&W.emit("saved",e.getValue()),R.preventDefault()}else if(R.key===M.KeyMap.ESC){t.clearPainterStyle();const T=e.getZone();T.isMainActive()||T.setZone(M.EditorZone.MAIN),R.preventDefault()}else if(R.key===M.KeyMap.TAB){const T={type:M.ElementType.TAB,value:""};tt(r,[T],c),e.insertElementList([T]),R.preventDefault()}}function Ye(R,t){var W;const e=t.getDraw();if(e.isReadonly())return;const s=e.getPosition().getCursorPosition();if(!R||!s)return;const o=t.isComposing;if(o&&((W=t.compositionInfo)==null?void 0:W.value)===R)return;const r=e.getControl();if(r.isPartRangeInControlOutside())return;Ze(t),o||e.getCursor().clearAgentDomValue();const a=r.getActiveControl(),{TEXT:l,HYPERLINK:u,SUBSCRIPT:c,SUPERSCRIPT:h,DATE:O}=M.ElementType,P=R.replaceAll(`
|
|
80
|
+
`,C),N=e.getRange(),{startIndex:X,endIndex:L}=N.getRange(),g=e.getElementList(),Y=Bt(g,L);if(!Y)return;const V=ht(P).map(F=>{const Z={value:F},S=g[L+1];return(Y.type===l||!Y.type&&Y.value!==C||Y.type===u&&(S==null?void 0:S.type)===u||Y.type===O&&(S==null?void 0:S.type)===O||Y.type===c&&(S==null?void 0:S.type)===c||Y.type===h&&(S==null?void 0:S.type)===h)&&ni.forEach(m=>{if(m==="groupIds"&&!(S==null?void 0:S.groupIds))return;const I=Y[m];I!==void 0&&(Z[m]=I)}),o&&(Z.underline=!0),Z});let T;if(a&&!r.isRangInPostfix())T=r.setValue(V);else{const F=X+1;X!==L&&e.spliceElementList(g,F,L-X),tt(g,V,X),e.spliceElementList(g,F,0,...V),T=X+V.length}~T&&(N.setRange(T,T),e.render({curIndex:T,isSubmitHistory:!o})),o&&(t.compositionInfo={elementList:g,value:P,startIndex:T-V.length,endIndex:T})}function Ze(R){if(!R.compositionInfo)return;const{elementList:t,startIndex:e,endIndex:i}=R.compositionInfo;t.splice(e+1,i-e),R.getDraw().getRange().setRange(e,e),R.compositionInfo=null}function Gi(R,t){if(!R||!t)return;const e=new Blob([R],{type:"text/plain"}),i=new Blob([t],{type:"text/html"});if(window.ClipboardItem){const n=new ClipboardItem({[e.type]:e,[i.type]:i});window.navigator.clipboard.write([n])}else{const n=document.createElement("div");n.setAttribute("contenteditable","true"),n.innerHTML=t,document.body.append(n);const s=window.getSelection(),o=document.createRange();o.selectNodeContents(n),s==null||s.removeAllRanges(),s==null||s.addRange(o),document.execCommand("copy"),n.remove()}}function Ue(R,t){const e=Et(R,t);document.body.append(e);const i=e.innerText;e.remove();const n=e.innerHTML;!i||!n||Gi(i,n)}function bi(R){const t=R.getDraw(),e=t.getRange(),{startIndex:i,endIndex:n}=e.getRange();if(!~i&&!~i||t.isReadonly())return;const o=t.getControl();if(o.isPartRangeInControlOutside())return;const a=o.getActiveControl(),l=t.getElementList();let u=i,c=n;if(i===n){const N=t.getPosition().getPositionList(),X=N[i],L=X.rowNo,g=X.pageNo,Y=[];for(let T=0;T<N.length;T++){const W=N[T];if(W.pageNo>g)break;W.pageNo===g&&W.rowNo===L&&Y.push(T)}const V=Y[0]-1;u=V<0?0:V,c=Y[Y.length-1]}const h=t.getOptions();Ue(l.slice(u+1,c+1),h);let O;a?O=o.cut():(t.spliceElementList(l,u+1,c-u),O=u),e.setRange(O,O),t.render({curIndex:O})}function yi(R){const t=R.getDraw(),e=t.getRange(),i=e.getIsCollapsed()?e.getRangeRowElementList():e.getSelectionElementList();!(i==null?void 0:i.length)||Ue(i,t.getOptions())}function Ci(R,t){var i;R.preventDefault();const e=(i=R.dataTransfer)==null?void 0:i.getData("text");e&&t.input(e)}function wi(R,t){const e=R.getDraw(),i=e.getLetterReg(),n=e.getPosition();if(e.getIsPagingMode()){const h=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(!~h.index&&h.zone){e.getZone().setZone(h.zone);return}}const s=n.getCursorPosition();if(!s)return;const{value:o,index:r}=s;let a=0,l=0;const u=wt.test(o);if(u||i.test(o)){const h=e.getElementList();let O=r-1;for(;O>0;){const N=h[O].value;if(u&&wt.test(N)||!u&&i.test(N))a++,O--;else break}let P=r+1;for(;P<h.length;){const N=h[P].value;if(u&&wt.test(N)||!u&&i.test(N))l++,P++;else break}}const c=e.getRange();c.setRange(r-a-1,r+l),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),c.setRangeStyle()}function Ji(R){const t=R.getDraw(),i=t.getPosition().getCursorPosition();if(!i)return;const{index:n}=i,s=t.getElementList();let o=0,r=0,a=n-1;for(;a>0&&s[a].value!==C;)o++,a--;let l=n+1;for(;l<s.length&&s[l].value!==C;)r++,l++;t.getRange().setRange(n-o-1,n+r),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}var Qe={dblclick:wi,threeClick:Ji};function xi(R){R.isComposing=!0}function vi(R,t){R.isComposing=!1;const e=R.getDraw();if(t.data)setTimeout(()=>{R.compositionInfo&&Ye(t.data,R)});else{Ze(R);const n=e.getRange(),{endIndex:s}=n.getRange();e.render({curIndex:s,isSubmitHistory:!1})}e.getCursor().clearAgentDomValue()}var Ie={compositionstart:xi,compositionend:vi};function Bi(R,t){const e=t.getDraw();if(e.isReadonly())return;R.preventDefault();const n=e.getPageContainer();if(!ft(R.target,g=>g===n,!0))return;const r=R.target.dataset.index;r&&e.setPageNo(Number(r));const a=e.getPosition(),l=a.adjustPositionContext({x:R.offsetX,y:R.offsetY});if(!l)return;const{isTable:u,tdValueIndex:c,index:h}=l,O=a.getPositionList(),P=u?c:h;~h&&(e.getRange().setRange(P,P),a.setCursorPosition(O[P]));const N=e.getCursor(),{cursor:{dragColor:X,dragWidth:L}}=e.getOptions();N.drawCursor({width:L,color:X,isBlink:!1})}var Ai={dragover:Bi};class _i{constructor(t){d(this,"isAllowSelection");d(this,"isComposing");d(this,"compositionInfo");d(this,"isAllowDrag");d(this,"isAllowDrop");d(this,"cacheRange");d(this,"cacheElementList");d(this,"cachePositionList");d(this,"mouseDownStartPosition");d(this,"draw");d(this,"pageContainer");d(this,"pageList");d(this,"range");d(this,"position");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.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)),ze(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)return;const e=this.range.getSelection();if(!e)return;const i=Object.keys(t);e.forEach(s=>{i.forEach(o=>{const r=o;s[r]=t[r]})}),this.draw.render({isSetCursor:!1});const n=this.draw.getPainterOptions();(!n||!n.isDblclick)&&this.clearPainterStyle()}selectAll(){const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}mousemove(t){Hi(t,this)}mousedown(t){Di(t,this)}click(){fi&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){mi(t,this)}mouseleave(t){pi(t,this)}keydown(t){Ei(t,this)}dblclick(t){Qe.dblclick(this,t)}threeClick(){Qe.threeClick(this)}input(t){Ye(t,this)}cut(){bi(this)}copy(){yi(this)}compositionstart(){Ie.compositionstart(this)}compositionend(t){Ie.compositionend(this,t)}drop(t){Ci(t,this)}dragover(t){Ai.dragover(t,this)}}class ki{constructor(t,e){d(this,"draw");d(this,"options");d(this,"cursor");d(this,"canvasEvent");d(this,"range");d(this,"previewer");d(this,"tableTool");d(this,"hyperlinkParticle");d(this,"control");d(this,"dateParticle");d(this,"dprMediaQueryList");d(this,"clearSideEffect",t=>{if(!this.cursor)return;const e=(t==null?void 0:t.composedPath()[0])||t.target,i=this.draw.getPageList();if(ft(e,o=>i.includes(o),!0)){this.setRangeStyle();return}if(ft(e,o=>!!o&&o.nodeType===1&&!!o.getAttribute(gt),!0)){this.setRangeStyle(),this.watchCursorActive();return}this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker()});d(this,"setCanvasEventAbility",()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)});d(this,"setRangeStyle",()=>{this.range.setRangeStyle()});d(this,"setPageScale",t=>{if(!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const i=e*10+1;i<=30&&this.draw.setPageScale(i/10)}else{const i=e*10-1;i>=5&&this.draw.setPageScale(i/10)}});d(this,"_handleVisibilityChange",()=>{var t;if(document.visibilityState){const e=this.range.getIsCollapsed();(t=this.cursor)==null||t.drawCursor({isShow:e})}});d(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.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("keyup",this.setRangeStyle),document.addEventListener("click",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("keyup",this.setRangeStyle),document.removeEventListener("click",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?void 0:t.getAgentIsActive())||(e=this.cursor)==null||e.drawCursor({isFocus:!1,isBlink:!1})})}}class zi{constructor(t){d(this,"undoStack",[]);d(this,"redoStack",[]);d(this,"maxRecordCount");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}recovery(){this.undoStack=[],this.redoStack=[]}}M.EditorComponent=void 0,function(R){R.COMPONENT="component",R.MENU="menu",R.MAIN="main",R.FOOTER="footer",R.CONTEXTMENU="contextmenu",R.POPUP="popup",R.CATALOG="catalog",R.COMMENT="comment"}(M.EditorComponent||(M.EditorComponent={}));var Xt;(function(R){R.PAGE="page",R.TABLE="table"})(Xt||(Xt={})),M.EditorMode=void 0,function(R){R.EDIT="edit",R.CLEAN="clean",R.READONLY="readonly",R.FORM="form",R.PRINT="print"}(M.EditorMode||(M.EditorMode={})),M.EditorZone=void 0,function(R){R.HEADER="header",R.MAIN="main",R.FOOTER="footer"}(M.EditorZone||(M.EditorZone={})),M.PageMode=void 0,function(R){R.PAGING="paging",R.CONTINUITY="continuity"}(M.PageMode||(M.PageMode={})),M.PaperDirection=void 0,function(R){R.VERTICAL="vertical",R.HORIZONTAL="horizontal"}(M.PaperDirection||(M.PaperDirection={})),M.WordBreak=void 0,function(R){R.BREAK_ALL="break-all",R.BREAK_WORD="break-word"}(M.WordBreak||(M.WordBreak={}));class $i{constructor(t){d(this,"cursorPosition");d(this,"positionContext");d(this,"positionList");d(this,"draw");d(this,"options");this.positionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.options=t.getOptions()}getTablePositionList(t){const{index:e,trIndex:i,tdIndex:n}=this.positionContext;return t[e].trList[i].tdList[n].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}computePageRowPosition(t){const{positionList:e,rowList:i,pageNo:n,startX:s,startY:o,startRowIndex:r,startIndex:a,innerWidth:l}=t,{scale:u,tdPadding:c}=this.options;let h=s,O=o,P=a;for(let N=0;N<i.length;N++){const X=i[N];X.rowFlex===M.RowFlex.CENTER?h+=(l-X.width)/2:X.rowFlex===M.RowFlex.RIGHT&&(h+=l-X.width),X.isList&&(h+=X.offsetX||0);const L=h,g=O;for(let Y=0;Y<X.elementList.length;Y++){const V=X.elementList[Y],T=V.metrics,W=V.imgDisplay!==M.ImageDisplay.INLINE&&V.type===M.ElementType.IMAGE||V.type===M.ElementType.LATEX?X.ascent-T.height:X.ascent;V.left&&(h+=V.left);const F={pageNo:n,index:P,value:V.value,rowIndex:r+N,rowNo:N,metrics:T,left:V.left||0,ascent:W,lineHeight:X.height,isFirstLetter:Y===0,isLastLetter:Y===X.elementList.length-1,coordinate:{leftTop:[h,O],leftBottom:[h,O+X.height],rightTop:[h+T.width,O],rightBottom:[h+T.width,O+X.height]}};if(e.push(F),P++,h+=T.width,V.type===M.ElementType.TABLE){const Z=c[1]+c[3],S=c[0]+c[2];for(let m=0;m<V.trList.length;m++){const I=V.trList[m];for(let U=0;U<I.tdList.length;U++){const Q=I.tdList[U];Q.positionList=[];const D=Q.rowList,K=this.computePageRowPosition({positionList:Q.positionList,rowList:D,pageNo:n,startRowIndex:0,startIndex:0,startX:(Q.x+c[3])*u+L,startY:(Q.y+c[0])*u+g,innerWidth:(Q.width-Z)*u});if(Q.verticalAlign===M.VerticalAlign.MIDDLE||Q.verticalAlign===M.VerticalAlign.BOTTOM){const G=D.reduce((b,w)=>b+w.height,0),y=(Q.height-S)*u-G,p=Q.verticalAlign===M.VerticalAlign.MIDDLE?y/2:y;Math.floor(p)>0&&Q.positionList.forEach(b=>{const{coordinate:{leftTop:w,leftBottom:A,rightBottom:v,rightTop:st}}=b;w[1]+=p,A[1]+=p,v[1]+=p,st[1]+=p})}h=K.x,O=K.y}}h=L,O=g}}h=s,O+=X.height}return{x:h,y:O,index:P}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),i=this.draw.getMargins(),n=i[3],o=this.draw.getHeader().getExtraHeight(),r=i[0]+o;let a=0;for(let l=0;l<e.length;l++){const u=e[l],c=u[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:u,pageNo:l,startRowIndex:a,startIndex:c,startX:n,startY:r,innerWidth:t}),a+=u.length}}setCursorPosition(t){this.cursorPosition=t}getCursorPosition(){return this.cursorPosition}getPositionContext(){return this.positionContext}setPositionContext(t){this.positionContext=t}getPositionByXY(t){var N,X;const{x:e,y:i,isTable:n}=t;let{elementList:s,positionList:o}=t;s||(s=this.draw.getOriginalElementList()),o||(o=this.getOriginalPositionList());const r=this.draw.getZone(),a=this.draw.getPageNo(),l=r.isMainActive(),u=l?a:0;for(let L=0;L<o.length;L++){const{index:g,pageNo:Y,left:V,isFirstLetter:T,coordinate:{leftTop:W,rightTop:F,leftBottom:Z}}=o[L];if(u===Y&&W[0]-V<=e&&F[0]>=e&&W[1]<=i&&Z[1]>=i){let S=L;const m=s[L];if(m.type===M.ElementType.TABLE)for(let U=0;U<m.trList.length;U++){const Q=m.trList[U];for(let D=0;D<Q.tdList.length;D++){const K=Q.tdList[D],G=this.getPositionByXY({x:e,y:i,td:K,tablePosition:o[L],isTable:!0,elementList:K.value,positionList:K.positionList});if(~G.index){const{index:y,hitLineStartIndex:p}=G,b=K.value[y];return{index:g,isCheckbox:b.type===M.ElementType.CHECKBOX||b.controlComponent===f.CHECKBOX,isControl:b.type===M.ElementType.CONTROL,isImage:G.isImage,isDirectHit:G.isDirectHit,isTable:!0,tdIndex:D,trIndex:U,tdValueIndex:y,tdId:K.id,trId:Q.id,tableId:m.id,hitLineStartIndex:p}}}}if(m.type===M.ElementType.IMAGE||m.type===M.ElementType.LATEX)return{index:S,isDirectHit:!0,isImage:!0};if(m.type===M.ElementType.CHECKBOX||m.controlComponent===f.CHECKBOX)return{index:S,isDirectHit:!0,isCheckbox:!0};let I;if(s[g].value!==C){const U=F[0]-W[0];e<W[0]+U/2&&(S=L-1,T&&(I=L))}return{hitLineStartIndex:I,index:S,isControl:m.type===M.ElementType.CONTROL}}}let c=!1,h=-1,O;if(n){const{scale:L}=this.options,{td:g,tablePosition:Y}=t;if(g&&Y){const{leftTop:V}=Y.coordinate,T=g.x*L+V[0],W=g.y*L+V[1],F=g.width*L,Z=g.height*L;if(!(T<e&&e<T+F&&W<i&&i<W+Z))return{index:h}}}const P=o.filter(L=>L.isLastLetter&&L.pageNo===u);for(let L=0;L<P.length;L++){const{index:g,pageNo:Y,coordinate:{leftTop:V,leftBottom:T}}=P[L];if(u===Y&&i>V[1]&&i<=T[1]){if(e<this.options.margins[3]){const F=o.findIndex(Z=>Z.pageNo===u&&Z.rowNo===P[L].rowNo);~F?o[F].value===C?h=F:(h=F-1,O=F):h=g}else h=g;c=!0;break}}if(!c){const L=this.draw.getHeader(),g=L.getHeaderTop()+L.getHeight(),Y=this.draw.getFooter(),T=this.draw.getHeight()-(Y.getFooterBottom()+Y.getHeight());if(l){if(i<g)return{index:-1,zone:M.EditorZone.HEADER};if(i>T)return{index:-1,zone:M.EditorZone.FOOTER}}else if(i<=T&&i>=g)return{index:-1,zone:M.EditorZone.MAIN};return{index:((N=P[P.length-1])==null?void 0:N.index)||o.length-1}}return{hitLineStartIndex:O,index:h,isControl:((X=s[h])==null?void 0:X.type)===M.ElementType.CONTROL}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==M.EditorMode.READONLY){const{index:h,isTable:O,trIndex:P,tdIndex:N,tdValueIndex:X}=e,L=this.draw.getControl(),{newIndex:g}=L.moveCursor({index:h,isTable:O,trIndex:P,tdIndex:N,tdValueIndex:X});O?e.tdValueIndex=g:e.index=g}const{index:i,isCheckbox:n,isControl:s,isTable:o,trIndex:r,tdIndex:a,tdId:l,trId:u,tableId:c}=e;return this.setPositionContext({isTable:o||!1,isCheckbox:n||!1,isControl:s||!1,index:i,trIndex:r,tdIndex:a,tdId:l,trId:u,tableId:c}),e}}class ji{constructor(t){d(this,"draw");d(this,"options");d(this,"range");d(this,"listener");d(this,"eventBus");d(this,"position");d(this,"historyManager");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}}getRange(){return this.range}clearRange(){this.setRange(-1,-1)}getIsCollapsed(){const{startIndex:t,endIndex:e}=this.range;return t===e}getSelection(){const{startIndex:t,endIndex:e}=this.range;return t===e?null:this.draw.getElementList().slice(t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let i=0;i<t.length;i++){const n=t[i];for(let s=0;s<n.length;s++){const o=n[s];e.push(...o.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||Ft.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Ft.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const i=this.position.getPositionList(),n=new Map;for(let s=t;s<e+1;s++){const{pageNo:o,rowNo:r}=i[s],a=n.get(o);a?a.has(r)||a.add(r):n.set(o,new Set([r]))}return n}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:i}=this.range;if(!~t&&!~e)return null;if(i)return this.getSelectionElementList();const n=this.getRangeRow();if(!n)return null;const s=this.position.getPositionList(),o=this.draw.getElementList(),r=[];for(let a=0;a<s.length;a++){const l=s[a],u=n.get(l.pageNo);!u||u.has(l.rowNo)&&r.push(o[a])}return r}getRangeParagraph(){var a,l,u;const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const i=this.position.getPositionList(),n=this.draw.getElementList(),s=new Map;let o=t;for(;o>=0;){const{pageNo:c,rowNo:h}=i[o];let O=s.get(c);if(O||(O=[],s.set(c,O)),O.includes(h)||O.unshift(h),((a=i[o])==null?void 0:a.value)===C||n[o].titleId!==((l=n[o-1])==null?void 0:l.titleId))break;o--}if(t!==e){let c=t+1;for(;c<e;){const{pageNo:h,rowNo:O}=i[c];let P=s.get(h);P||(P=[],s.set(h,P)),P.includes(O)||P.push(O),c++}}let r=e;for(;r<i.length&&!(i[r].value===C||n[r].titleId!==((u=n[r+1])==null?void 0:u.titleId));){const{pageNo:c,rowNo:h}=i[r];let O=s.get(c);O||(O=[],s.set(c,O)),O.includes(h)||O.push(h),r++}return s}getRangeParagraphElementList(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const i=[],n=this.getRangeParagraph();if(!n)return null;const s=this.draw.getElementList(),o=this.position.getPositionList();for(let r=0;r<o.length;r++){const a=o[r],l=n.get(a.pageNo);!l||l.includes(a.rowNo)&&i.push(s[r])}return i}getIsSelectAll(){const t=this.draw.getElementList(),{startIndex:e,endIndex:i}=this.range;return e===0&&t.length-1===i}getIsPointInRange(t,e){const{startIndex:i,endIndex:n}=this.range,s=this.position.getPositionList();for(let o=i+1;o<=n;o++){const{coordinate:{leftTop:r,rightBottom:a}}=s[o];if(t>=r[0]&&t<=a[0]&&e>=r[1]&&e<=a[1])return!0}return!1}setRange(t,e,i,n,s,o,r){this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=i,this.range.startTdIndex=n,this.range.endTdIndex=s,this.range.startTrIndex=o,this.range.endTrIndex=r,this.range.isCrossRowCol=!!(n||s||o||r),this.range.zone=this.draw.getZone().getZone();const a=this.draw.getControl();if(~t&&~e){const u=this.draw.getElementList()[t];if((u==null?void 0:u.type)===M.ElementType.CONTROL){a.initControl();return}}a.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}setRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:i,endIndex:n,isCrossRowCol:s}=this.range;if(!~i&&!~n)return;let o;if(s){const U=this.draw.getOriginalElementList(),Q=this.position.getPositionContext();o=U[Q.index]}else{const U=~n?n:0,Q=this.draw.getElementList();o=Bt(Q,U)}if(!o)return;const r=this.getSelection()||[o],a=o.type||M.ElementType.TEXT,l=o.font||this.options.defaultFont,u=o.size||this.options.defaultSize,c=!~r.findIndex(U=>!U.bold),h=!~r.findIndex(U=>!U.italic),O=!~r.findIndex(U=>{var Q;return!U.underline&&!((Q=U.control)==null?void 0:Q.underline)}),P=!~r.findIndex(U=>!U.strikeout),N=o.color||null,X=o.highlight||null,L=o.rowFlex||null,g=o.rowMargin||this.options.defaultRowMargin,Y=o.dashArray||[],V=o.level||null,T=o.listType||null,W=o.listStyle||null,F=!!this.draw.getPainterStyle(),Z=this.historyManager.isCanUndo(),S=this.historyManager.isCanRedo(),m=o.groupIds||null,I={type:a,undo:Z,redo:S,painter:F,font:l,size:u,bold:c,italic:h,underline:O,strikeout:P,color:N,highlight:X,rowFlex:L,rowMargin:g,dashArray:Y,level:V,listType:T,listStyle:W,groupIds:m};t&&t(I),e&&this.eventBus.emit("rangeStyleChange",I)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const i=this.options.defaultFont,n=this.options.defaultSize,s=this.options.defaultRowMargin,o=!!this.draw.getPainterStyle(),r=this.historyManager.isCanUndo(),a=this.historyManager.isCanRedo(),l={type:null,undo:r,redo:a,painter:o,font:i,size:n,bold:!1,italic:!1,underline:!1,strikeout:!1,color:null,highlight:null,rowFlex:null,rowMargin:s,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null};t&&t(l),e&&this.eventBus.emit("rangeStyleChange",l)}shrinkBoundary(){const t=this.draw.getElementList(),e=this.getRange(),{startIndex:i,endIndex:n}=e,s=t[i],o=t[n];if(i===n){if(s.controlComponent===f.PLACEHOLDER){let r=i-1;for(;r>0;){const a=t[r];if(a.controlId!==s.controlId||a.controlComponent===f.PREFIX){e.startIndex=r,e.endIndex=r;break}r--}}}else{if(s.controlComponent===f.PLACEHOLDER||o.controlComponent===f.PLACEHOLDER){let r=n-1;for(;r>0;){const a=t[r];if(a.controlId!==o.controlId||a.controlComponent===f.PREFIX){e.startIndex=r,e.endIndex=r;return}r--}}if(s.controlComponent===f.PREFIX){let r=i+1;for(;r<t.length;){const a=t[r];if(a.controlId!==s.controlId||a.controlComponent===f.VALUE){e.startIndex=r-1;break}else if(a.controlComponent===f.PLACEHOLDER){e.startIndex=r-1,e.endIndex=r-1;return}r++}}if(o.controlComponent!==f.VALUE){let r=i-1;for(;r>0;){const a=t[r];if(a.controlId!==s.controlId||a.controlComponent===f.VALUE){e.startIndex=r;break}else if(a.controlComponent===f.PLACEHOLDER){e.startIndex=r,e.endIndex=r;return}r--}}}}render(t,e,i,n,s){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,i,n,s),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(C,"g"),""):""}}class qi{constructor(t){d(this,"draw");d(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{backgroundColor:i}=this.options,n=this.draw.getCanvasWidth(e),s=this.draw.getCanvasHeight(e);t.save(),t.fillStyle=i,t.fillRect(0,0,n,s),t.restore()}}class zt{constructor(){d(this,"fillRect");d(this,"fillColor");this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,i,n,s,o){const r=!this.fillRect.width;if(!r&&this.fillColor&&this.fillColor!==o){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,i,n,s,o);return}r&&(this.fillRect.x=e,this.fillRect.y=i),s&&this.fillRect.height<s&&(this.fillRect.height=s),this.fillRect.width+=n,this.fillColor=o}}class tn extends zt{constructor(t){super();d(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:i,y:n,width:s,height:o}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(i,n,s,o),t.restore(),this.clearFillInfo()}}class en{constructor(t){d(this,"draw");d(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:i,pageMode:n}=this.options,s=this.draw.getWidth(),o=n===M.PageMode.CONTINUITY?this.draw.getCanvasHeight(e):this.draw.getHeight(),r=this.draw.getMargins(),a=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=i,t.beginPath();const l=[r[3],r[0]],u=[s-r[1],r[0]],c=[r[3],o-r[2]],h=[s-r[1],o-r[2]];t.moveTo(l[0]-a,l[1]),t.lineTo(...l),t.lineTo(l[0],l[1]-a),t.moveTo(u[0]+a,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]-a),t.moveTo(c[0]-a,c[1]),t.lineTo(...c),t.lineTo(c[0],c[1]+a),t.moveTo(h[0]+a,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+a),t.stroke(),t.restore()}}class nn{constructor(t){d(this,"draw");d(this,"options");d(this,"position");d(this,"searchKeyword");d(this,"searchNavigateIndex");d(this,"searchMatchList");this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.searchNavigateIndex=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t){this.searchKeyword=t,this.searchNavigateIndex=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 i=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const n=this.searchMatchList[t];if(i!==n.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===i)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 i=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const n=this.searchMatchList[t];if(i!==n.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===i)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:i,rightTop:n},pageNo:s}=t,o=this.draw.getHeight(),r=this.draw.getPageGap(),a=s*(o+r),l=document.createElement("div");l.style.position="absolute";const u=50;l.style.width=`${n[0]-e[0]+u}px`,l.style.height=`${i[1]-e[1]+u}px`,l.style.left=`${e[0]}px`,l.style.top=`${e[1]+a}px`,this.draw.getContainer().append(l),l.scrollIntoView(!1),l.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,i=null;for(let n=0;n<this.searchMatchList.length;n++){const s=this.searchMatchList[n];i!==s.groupId&&(i=s.groupId,e+=1)}return{index:t,count:e}}compute(t){const e=t.toLocaleLowerCase(),i=[],n=[],s=this.draw.getOriginalElementList(),o=s.length,r=[];for(let c=0;c<o;c++)s[c].type===M.ElementType.TABLE&&r.push(c);let a=0,l=0;for(;l<o-1;){const c=r.length?r[a]:o,h=s.slice(l,c);h.length&&n.push({index:l,type:Xt.PAGE,elementList:h});const O=s[c];O&&n.push({index:c,type:Xt.TABLE,elementList:[O]}),l=c+1,a++}function u(c,h,O,P){if(!c)return;const N=O.map(g=>!g.type||Ft.includes(g.type)&&g.controlComponent!==f.CHECKBOX?g.value:C).filter(Boolean).join("").toLocaleLowerCase(),X=[];let L=N.indexOf(c);for(;L!==-1;)X.push(L),L=N.indexOf(c,L+1);for(let g=0;g<X.length;g++){const Y=X[g],V=x();for(let T=0;T<c.length;T++){const W=Y+T+((P==null?void 0:P.startIndex)||0);i.push(H({type:h,index:W,groupId:V},P))}}}for(let c=0;c<n.length;c++){const h=n[c];if(h.type===Xt.TABLE){const O=h.elementList[0];for(let P=0;P<O.trList.length;P++){const N=O.trList[P];for(let X=0;X<N.tdList.length;X++){const L=N.tdList[X],g={tableIndex:h.index,trIndex:P,tdIndex:X,tdId:L.id};u(e,h.type,L.value,g)}}}else u(e,h.type,h.elementList,{startIndex:h.index})}this.searchMatchList=i}render(t,e){var a,l;if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:i,searchMatchColor:n,searchNavigateMatchColor:s}=this.options,o=this.position.getOriginalPositionList(),r=this.draw.getOriginalElementList();t.save(),t.globalAlpha=i;for(let u=0;u<this.searchMatchList.length;u++){const c=this.searchMatchList[u];let h=null;if(c.type===Xt.TABLE){const{tableIndex:W,trIndex:F,tdIndex:Z,index:S}=c;h=(l=(a=r[W])==null?void 0:a.trList[F].tdList[Z])==null?void 0:l.positionList[S]}else h=o[c.index];if(!h)continue;const{coordinate:{leftTop:O,leftBottom:P,rightTop:N},pageNo:X}=h;if(X!==e)continue;if(this.getSearchNavigateIndexList().includes(u)){t.fillStyle=s;const W=this.searchMatchList[u-1];(!W||W.groupId!==c.groupId)&&this.searchNavigateScrollIntoView(h)}else t.fillStyle=n;const g=O[0],Y=O[1],V=N[0]-O[0],T=P[1]-O[1];t.fillRect(g,Y,V,T)}t.restore()}}class Rn extends zt{constructor(t){super();d(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{strikeoutColor:e}=this.options,{x:i,y:n,width:s}=this.fillRect;t.save(),t.strokeStyle=e;const o=n+.5;t.beginPath(),t.moveTo(i,o),t.lineTo(i+s,o),t.stroke(),t.restore(),this.clearFillInfo()}}class sn extends zt{constructor(t){super();d(this,"options");this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{underlineColor:e}=this.options,{x:i,y:n,width:s}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e;const o=Math.floor(n+2*t.lineWidth)+.5;t.beginPath(),t.moveTo(i,o),t.lineTo(i+s,o),t.stroke(),t.restore(),this.clearFillInfo()}}class on{constructor(t){d(this,"draw");d(this,"ctx");d(this,"curX");d(this,"curY");d(this,"text");d(this,"curStyle");d(this,"curColor");d(this,"cacheMeasureText");this.draw=t,this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.cacheMeasureText=new Map}measureWord(t,e,i){const n=this.draw.getLetterReg();let s=0,o=e[i],r=i;for(;r<e.length;){const a=e[r];if(a.type&&a.type!==M.ElementType.TEXT||!n.test(a.value)){o=a;break}s+=this.measureText(t,a).width,r++}return{width:s,endElement:o}}measurePunctuationWidth(t,e){return!e||!Be.includes(e.value)?0: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 i=`${e.value}${t.font}`,n=this.cacheMeasureText.get(i);if(n)return n;const s=t.measureText(e.value);return this.cacheMeasureText.set(i,s),s}complete(){this._render(),this.text=""}record(t,e,i,n){this.ctx=t,this.text||this._setCurXY(i,n),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(i,n)),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.curColor&&(this.ctx.fillStyle=this.curColor),this.ctx.fillText(this.text,this.curX,this.curY),this.ctx.restore())}}const $t={PAGE_NO:"{pageNo}",PAGE_COUNT:"{pageCount}"},rn={bottom:60,size:12,font:"Yahei",color:"#000000",rowFlex:M.RowFlex.CENTER,format:$t.PAGE_NO,numberType:M.NumberType.ARABIC,disabled:!1,startPageNo:1,fromPageNo:0};class ln{constructor(t){d(this,"draw");d(this,"options");this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:i,pageMode:n,pageNumber:{size:s,font:o,color:r,rowFlex:a,numberType:l,format:u,startPageNo:c,fromPageNo:h}}=this.options;if(e<h)return;let O=u;const P=new RegExp($t.PAGE_NO);if(P.test(O)){const F=e+c-h,Z=l===M.NumberType.CHINESE?he(F):`${F}`;O=O.replace(P,Z)}const N=new RegExp($t.PAGE_COUNT);if(N.test(O)){const F=this.draw.getPageCount()-h,Z=l===M.NumberType.CHINESE?he(F):`${F}`;O=O.replace(N,Z)}const X=this.draw.getWidth(),L=n===M.PageMode.CONTINUITY?this.draw.getCanvasHeight(e):this.draw.getHeight(),g=this.draw.getPageNumberBottom(),Y=L-g;t.save(),t.fillStyle=r,t.font=`${s*i}px ${o}`;let V=0;const T=this.draw.getMargins(),{width:W}=t.measureText(O);a===M.RowFlex.CENTER?V=(X-W)/2:a===M.RowFlex.RIGHT?V=X-W-T[1]:V=T[3],t.fillText(O,V,Y),t.restore()}}class an{constructor(t){d(this,"draw");d(this,"_observer",re(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150));this.draw=t,setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}_addEvent(){document.addEventListener("scroll",this._observer)}removeEvent(){document.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),i=Math.max(document.documentElement.clientHeight,window.innerHeight),n=Math.min(e.bottom,i)-Math.max(e.top,0);return{intersectionHeight:n>0?n:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let i=0,n=0;for(let s=0;s<t.length;s++){const o=t[s],{intersectionHeight:r}=this.getElementVisibleInfo(o);if(n&&!r)break;r&&e.push(s),r>n&&(n=r,i=s)}return{intersectionPageNo:i,visiblePageNoList:e}}}class cn{constructor(t){d(this,"step",5);d(this,"thresholdPoints",[70,40,10,20]);d(this,"rangeManager");d(this,"requestAnimationFrameId");d(this,"isMousedown");d(this,"isMoving");d(this,"_mousedown",()=>{this.isMousedown=!0});d(this,"_mouseup",()=>{this.isMousedown=!1,this._stopMove()});d(this,"_mousemove",t=>{if(!this.isMousedown||this.rangeManager.getIsCollapsed())return;const{x:e,y:i}=t,n=document.documentElement.clientWidth,s=document.documentElement.clientHeight;i<this.thresholdPoints[0]?this._startMove(rt.UP):s-i<=this.thresholdPoints[1]?this._startMove(rt.DOWN):e<this.thresholdPoints[2]?this._startMove(rt.LEFT):n-e<this.thresholdPoints[3]?this._startMove(rt.RIGHT):this._stopMove()});this.requestAnimationFrameId=null,this.isMousedown=!1,this.isMoving=!1,this.rangeManager=t.getRange(),this._addEvent()}_addEvent(){document.addEventListener("mousedown",this._mousedown),document.addEventListener("mousemove",this._mousemove),document.addEventListener("mouseup",this._mouseup)}removeEvent(){document.removeEventListener("mousedown",this._mousedown),document.removeEventListener("mousemove",this._mousemove),document.removeEventListener("mouseup",this._mouseup)}_move(t){const e=window.scrollX,i=window.scrollY;t===rt.DOWN?window.scrollTo(e,i+this.step):t===rt.UP?window.scrollTo(e,i-this.step):t===rt.LEFT?window.scrollTo(e-this.step,i):window.scrollTo(e+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)}}M.TableBorder=void 0,function(R){R.ALL="all",R.EMPTY="empty",R.EXTERNAL="external"}(M.TableBorder||(M.TableBorder={})),M.TdBorder=void 0,function(R){R.BOTTOM="bottom"}(M.TdBorder||(M.TdBorder={})),M.TdSlash=void 0,function(R){R.FORWARD="forward",R.BACK="back"}(M.TdSlash||(M.TdSlash={}));class un{constructor(t){d(this,"draw");d(this,"range");d(this,"options");this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=j(t);for(let i=0;i<t.length;i++){const n=e[i];for(let s=n.tdList.length-1;s>=0;s--){const o=n.tdList[s],{rowspan:r,rowIndex:a,colIndex:l}=o,u=a+r-1;if(u!==s){const c=n.tdList.splice(s,1)[0];e[u].tdList.splice(l,0,c)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:i,tdIndex:n}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:s,startTdIndex:o,endTdIndex:r,startTrIndex:a,endTrIndex:l}=this.range.getRange(),h=this.draw.getOriginalElementList()[e].trList;if(!s)return[[h[i].tdList[n]]];let O=h[a].tdList[o],P=h[l].tdList[r];(O.x>P.x||O.y>P.y)&&([O,P]=[P,O]);const N=O.colIndex,X=P.colIndex+(P.colspan-1),L=O.rowIndex,g=P.rowIndex+(P.rowspan-1),Y=[];for(let V=0;V<h.length;V++){const T=h[V],W=[];for(let F=0;F<T.tdList.length;F++){const Z=T.tdList[F],S=Z.colIndex,m=Z.rowIndex;S>=N&&S<=X&&m>=L&&m<=g&&W.push(Z)}W.length&&Y.push(W)}return Y.length?Y:null}_drawOuterBorder(t){const{ctx:e,startX:i,startY:n,width:s,height:o,isDrawFullBorder:r}=t;e.beginPath();const a=Math.round(i),l=Math.round(n);e.translate(.5,.5),r?e.rect(a,l,s,o):(e.moveTo(a,l+o),e.lineTo(a,l),e.lineTo(a+s,l)),e.stroke(),e.translate(-.5,-.5)}_drawSlash(t,e,i,n){const{scale:s}=this.options;t.save();const o=e.width*s,r=e.height*s,a=Math.round(e.x*s+i),l=Math.round(e.y*s+n);e.slashType===M.TdSlash.FORWARD?(t.moveTo(a+o,l),t.lineTo(a,l+r)):(t.moveTo(a,l),t.lineTo(a+o,l+r)),t.stroke(),t.restore()}_drawBorder(t,e,i,n){const{colgroup:s,trList:o,borderType:r}=e;if(!s||!o)return;const{scale:a}=this.options,l=e.width*a,u=e.height*a,c=r===M.TableBorder.EMPTY,h=r===M.TableBorder.EXTERNAL;t.save(),c||this._drawOuterBorder({ctx:t,startX:i,startY:n,width:l,height:u,isDrawFullBorder:h});for(let O=0;O<o.length;O++){const P=o[O];for(let N=0;N<P.tdList.length;N++){const X=P.tdList[N];if(X.slashType&&this._drawSlash(t,X,i,n),!X.borderType&&(c||h))continue;const L=X.width*a,g=X.height*a,Y=Math.round(X.x*a+i+L),V=Math.round(X.y*a+n);t.translate(.5,.5),t.beginPath(),X.borderType===M.TdBorder.BOTTOM&&(t.moveTo(Y,V+g),t.lineTo(Y-L,V+g),t.stroke()),!c&&!h&&(t.moveTo(Y,V+g),t.moveTo(Y,V),t.lineTo(Y,V+g),t.lineTo(Y-L,V+g),t.stroke()),t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,i,n){const{trList:s}=e;if(!s)return;const{scale:o}=this.options;for(let r=0;r<s.length;r++){const a=s[r];for(let l=0;l<a.tdList.length;l++){const u=a.tdList[l];if(!u.backgroundColor)continue;t.save();const c=u.width*o,h=u.height*o,O=Math.round(u.x*o+i),P=Math.round(u.y*o+n);t.fillStyle=u.backgroundColor,t.fillRect(O,P,c,h),t.restore()}}}computeRowColInfo(t){const{colgroup:e,trList:i}=t;if(!e||!i)return;let n=0,s=0;for(let o=0;o<i.length;o++){const r=i[o],a=i.length-1===o;let l=0;for(let u=0;u<r.tdList.length;u++){const c=r.tdList[u];let h=0;if(i.length>1&&o!==0)for(let V=0;V<o;V++){const T=i[V];for(let W=0;W<T.tdList.length;W++){const F=T.tdList[W],Z=F.x,S=F.y,m=F.width,I=F.height;if(!(Z<n)){if(Z>n)break;if(Z===n&&S+I>s){const U=T.tdList[W+1];U&&F.colIndex+F.colspan!==U.colIndex?(n=U.x,h=U.colIndex):(n+=m,h+=F.colspan)}}}}let O=0;const P=r.tdList[u-1];P?(O=P.colIndex+h+1,P.colspan>1&&(O+=P.colspan-1)):O+=h;let N=0;for(let V=0;V<c.colspan;V++)N+=e[V+O].width;let X=0;for(let V=0;V<c.rowspan;V++)X+=i[V+o].height;(l===0||l>X)&&(l=X);const L=r.tdList.length-1===u;let g=a;if(!g&&c.rowspan>1){const V=i.length-1-o;g=c.rowspan-1===V}const Y=a&&L;c.isLastRowTd=L,c.isLastColTd=g,c.isLastTd=Y,c.x=n,c.y=s,c.width=N,c.height=X,c.rowIndex=o,c.colIndex=O,n+=N,L&&!Y&&(n=0,s+=l)}}}drawRange(t,e,i,n){const{scale:s,rangeAlpha:o,rangeColor:r}=this.options,{type:a,trList:l}=e;if(!l||a!==M.ElementType.TABLE)return;const{isCrossRowCol:u,startTdIndex:c,endTdIndex:h,startTrIndex:O,endTrIndex:P}=this.range.getRange();if(!u)return;let N=l[O].tdList[c],X=l[P].tdList[h];(N.x>X.x||N.y>X.y)&&([N,X]=[X,N]);const L=N.colIndex,g=X.colIndex+(X.colspan-1),Y=N.rowIndex,V=X.rowIndex+(X.rowspan-1);t.save();for(let T=0;T<l.length;T++){const W=l[T];for(let F=0;F<W.tdList.length;F++){const Z=W.tdList[F],S=Z.colIndex,m=Z.rowIndex;if(S>=L&&S<=g&&m>=Y&&m<=V){const I=Z.x*s,U=Z.y*s,Q=Z.width*s,D=Z.height*s;t.globalAlpha=o,t.fillStyle=r,t.fillRect(I+i,U+n,Q,D)}}}t.restore()}render(t,e,i,n){this._drawBackgroundColor(t,e,i,n),this._drawBorder(t,e,i,n)}}var Pt;(function(R){R.ROW="row",R.COL="col"})(Pt||(Pt={}));class hn{constructor(t){d(this,"MIN_TD_WIDTH",20);d(this,"ROW_COL_OFFSET",18);d(this,"BORDER_VALUE",4);d(this,"draw");d(this,"canvas");d(this,"options");d(this,"position");d(this,"container");d(this,"toolRowContainer");d(this,"toolColContainer");d(this,"toolBorderContainer");d(this,"anchorLine");d(this,"mousedownX");d(this,"mousedownY");this.draw=t,this.canvas=t.getPage(),this.options=t.getOptions(),this.position=t.getPosition(),this.container=t.getContainer(),this.toolRowContainer=null,this.toolColContainer=null,this.toolBorderContainer=null,this.anchorLine=null,this.mousedownX=0,this.mousedownY=0}dispose(){var t,e,i;(t=this.toolRowContainer)==null||t.remove(),(e=this.toolColContainer)==null||e.remove(),(i=this.toolBorderContainer)==null||i.remove(),this.toolRowContainer=null,this.toolColContainer=null,this.toolBorderContainer=null}render(){const{isTable:t,index:e,trIndex:i,tdIndex:n}=this.position.getPositionContext();if(!t)return;this.dispose();const{scale:s}=this.options,o=this.draw.getOriginalElementList(),r=this.position.getOriginalPositionList(),a=o[e],l=r[e],{colgroup:u,trList:c}=a,{coordinate:{leftTop:h}}=l,O=this.draw.getHeight(),P=this.draw.getPageGap(),N=this.draw.getPageNo()*(O+P),X=h[0],L=h[1]+N,g=a.trList[i].tdList[n],Y=g.rowIndex,V=g.colIndex,T=c.map(U=>U.height),W=document.createElement("div");W.classList.add(`${E}-table-tool__row`),W.style.transform=`translateX(-${this.ROW_COL_OFFSET*s}px)`;for(let U=0;U<T.length;U++){const Q=T[U]*s,D=document.createElement("div");D.classList.add(`${E}-table-tool__row__item`),U===Y&&D.classList.add("active");const K=document.createElement("div");K.classList.add(`${E}-table-tool__anchor`),K.onmousedown=G=>{this._mousedown({evt:G,element:a,index:U,order:Pt.ROW})},D.append(K),D.style.height=`${Q}px`,W.append(D)}W.style.left=`${X}px`,W.style.top=`${L}px`,this.container.append(W),this.toolRowContainer=W;const F=u.map(U=>U.width),Z=document.createElement("div");Z.classList.add(`${E}-table-tool__col`),Z.style.transform=`translateY(-${this.ROW_COL_OFFSET*s}px)`;for(let U=0;U<F.length;U++){const Q=F[U]*s,D=document.createElement("div");D.classList.add(`${E}-table-tool__col__item`),U===V&&D.classList.add("active");const K=document.createElement("div");K.classList.add(`${E}-table-tool__anchor`),K.onmousedown=G=>{this._mousedown({evt:G,element:a,index:U,order:Pt.COL})},D.append(K),D.style.width=`${Q}px`,Z.append(D)}Z.style.left=`${X}px`,Z.style.top=`${L}px`,this.container.append(Z),this.toolColContainer=Z;const S=a.height*s,m=a.width*s,I=document.createElement("div");I.classList.add(`${E}-table-tool__border`),I.style.height=`${S}px`,I.style.width=`${m}px`,I.style.left=`${X}px`,I.style.top=`${L}px`;for(let U=0;U<c.length;U++){const Q=c[U];for(let D=0;D<Q.tdList.length;D++){const K=Q.tdList[D],G=document.createElement("div");G.classList.add(`${E}-table-tool__border__row`),G.style.width=`${K.width*s}px`,G.style.height=`${this.BORDER_VALUE}px`,G.style.top=`${(K.y+K.height)*s-this.BORDER_VALUE/2}px`,G.style.left=`${K.x*s}px`,G.onmousedown=p=>{this._mousedown({evt:p,element:a,index:K.rowIndex+K.rowspan-1,order:Pt.ROW})},I.appendChild(G);const y=document.createElement("div");y.classList.add(`${E}-table-tool__border__col`),y.style.width=`${this.BORDER_VALUE}px`,y.style.height=`${K.height*s}px`,y.style.top=`${K.y*s}px`,y.style.left=`${(K.x+K.width)*s-this.BORDER_VALUE/2}px`,y.onmousedown=p=>{this._mousedown({evt:p,element:a,index:K.colIndex+K.colspan-1,order:Pt.COL})},I.appendChild(y)}}this.container.append(I),this.toolBorderContainer=I}_mousedown(t){const{evt:e,index:i,order:n,element:s}=t;this.canvas=this.draw.getPage();const{scale:o}=this.options,r=this.draw.getWidth(),a=this.draw.getHeight(),l=this.draw.getPageGap(),u=this.draw.getPageNo()*(a+l);this.mousedownX=e.x,this.mousedownY=e.y;const c=e.target,h=this.canvas.getBoundingClientRect(),O=window.getComputedStyle(c).cursor;document.body.style.cursor=O,this.canvas.style.cursor=O;let P=0,N=0;const X=document.createElement("div");X.classList.add(`${E}-table-anchor__line`),n===Pt.ROW?(X.classList.add(`${E}-table-anchor__line__row`),X.style.width=`${r}px`,P=0,N=u+this.mousedownY-h.top):(X.classList.add(`${E}-table-anchor__line__col`),X.style.height=`${a}px`,P=this.mousedownX-h.left,N=u),X.style.left=`${P}px`,X.style.top=`${N}px`,this.container.append(X),this.anchorLine=X;let L=0,g=0;const Y=V=>{const T=this._mousemove(V,n,P,N);T&&(L=T.dx,g=T.dy)};document.addEventListener("mousemove",Y),document.addEventListener("mouseup",()=>{var T;let V=!1;if(n===Pt.ROW){const W=s.trList[i],{defaultTrMinHeight:F}=this.options;g<0&&W.height+g<F&&(g=F-W.height),g&&(W.height+=g,W.minHeight=W.height,V=!0)}else{const{colgroup:W}=s;if(W&&L){const F=this.draw.getInnerWidth(),Z=W[i].width;L<0&&Z+L<this.MIN_TD_WIDTH&&(L=this.MIN_TD_WIDTH-Z);const S=(T=W[i+1])==null?void 0:T.width;L>0&&S&&S-L<this.MIN_TD_WIDTH&&(L=S-this.MIN_TD_WIDTH);const m=Z+L;let I=0;for(let U=0;U<W.length;U++){const Q=W[U];U===i+1&&(I-=L),U===i&&(I+=m),U!==i&&(I+=Q.width)}if(I>F){const U=s.width;L=F-U}L&&(W.length-1!==i&&(W[i+1].width-=L/o),W[i].width+=L/o,V=!0)}}V&&this.draw.render({isSetCursor:!1}),X.remove(),document.removeEventListener("mousemove",Y),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,i,n){if(!this.anchorLine)return null;const s=t.x-this.mousedownX,o=t.y-this.mousedownY;return e===Pt.ROW?this.anchorLine.style.top=`${n+o}px`:this.anchorLine.style.left=`${i+s}px`,t.preventDefault(),{dx:s,dy:o}}}class Mn{constructor(t){d(this,"draw");d(this,"options");d(this,"container");d(this,"hyperlinkPopupContainer");d(this,"hyperlinkDom");this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:i}=this._createHyperlinkPopupDom();this.hyperlinkDom=i,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${E}-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:[i,n]},lineHeight:s}=e,o=this.draw.getHeight(),r=this.draw.getPageGap(),a=this.draw.getPageNo()*(o+r);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${i}px`,this.hyperlinkPopupContainer.style.top=`${n+a+s}px`;const l=t.url||"#";this.hyperlinkDom.href=l,this.hyperlinkDom.title=l,this.hyperlinkDom.innerText=l}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,i,n){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,i,n),t.restore()}}class dn{constructor(t,e){d(this,"draw");d(this,"position");d(this,"options");d(this,"elementList");d(this,"rowList");d(this,"positionList");this.draw=t,this.position=t.getPosition(),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(t,this.elementList)}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),n=this.draw.getMargins()[3],s=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:n,startY:s,innerWidth:e})}getHeaderTop(){const{header:{top:t,disabled:e},scale:i}=this.options;return e?0:Math.floor(t*i)}getMaxHeight(){const{header:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*se[t])}getHeight(){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(),n=this.getHeaderTop()+e-t[0];return n<=0?0:n}render(t,e){t.globalAlpha=1;const i=this.draw.getInnerWidth(),n=this.getMaxHeight(),s=[];let o=0;for(let r=0;r<this.rowList.length;r++){const a=this.rowList[r];if(o+a.height>n)break;s.push(a),o+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:s,pageNo:e,startIndex:0,innerWidth:i,zone:M.EditorZone.HEADER})}}class On{render(t,e,i,n){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,i,n-e.metrics.height/2),t.restore()}}class Pn{render(t,e,i,n){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,i,n+e.metrics.height/2),t.restore()}}class Xn{render(t,e,i,n){t.save(),e.color&&(t.strokeStyle=e.color),e.dashArray&&e.dashArray.length&&t.setLineDash(e.dashArray),t.translate(0,.5),t.beginPath(),t.moveTo(i,n),t.lineTo(i+e.width,n),t.stroke(),t.restore()}}class Ln{constructor(t){d(this,"draw");d(this,"options");d(this,"i18n");this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,i,n){const{pageBreak:{font:s,fontSize:o,lineDash:r}}=this.options,a=this.i18n.t("pageBreak.displayName"),{scale:l,defaultRowMargin:u}=this.options,c=o*l,h=e.width,O=this.draw.getDefaultBasicRowMarginHeight()*u;t.save(),t.font=`${c}px ${s}`;const P=t.measureText(a),N=(h-P.width)/2;t.setLineDash(r),t.translate(0,.5+O),t.beginPath(),t.moveTo(i,n),t.lineTo(i+N,n),t.moveTo(i+N+P.width,n),t.lineTo(i+h,n),t.stroke(),t.fillText(a,i+N,n+P.actualBoundingBoxAscent-c/2),t.restore()}}class Nn{constructor(t){d(this,"draw");d(this,"options");this.draw=t,this.options=t.getOptions()}render(t){const{watermark:{data:e,opacity:i,font:n,size:s,color:o},scale:r}=this.options,a=this.draw.getWidth(),l=this.draw.getHeight(),u=a/2,c=l/2;t.save(),t.globalAlpha=i,t.font=`${s*r}px ${n}`,t.fillStyle=o;const h=t.measureText(e);t.translate(u,c),t.rotate(-45*Math.PI/180),t.fillText(e,-h.width/2,h.actualBoundingBoxAscent-s/2),t.restore()}}class yt{constructor(t,e){d(this,"element");d(this,"control");d(this,"isPopup");d(this,"selectDom");this.element=t,this.control=e,this.isPopup=!1,this.selectDom=null}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(),i=t[e],n=[];let s=e;for(;s>0;){const r=t[s];if(r.controlId!==i.controlId||r.controlComponent===f.PREFIX)break;r.controlComponent===f.VALUE&&n.unshift(r),s--}let o=e+1;for(;o<t.length;){const r=t[o];if(r.controlId!==i.controlId||r.controlComponent===f.POSTFIX)break;r.controlComponent===f.VALUE&&n.push(r),o++}return n}setValue(){return-1}keydown(t){const e=this.control.getElementList(),i=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:s}=i,o=e[n],r=e[s];if(t.key===M.KeyMap.Backspace)return n!==s?this.clearSelect():o.controlComponent===f.PREFIX||r.controlComponent===f.POSTFIX||o.controlComponent===f.PLACEHOLDER?this.control.removeControl(n):this.clearSelect();if(t.key===M.KeyMap.Delete){if(n!==s)return this.clearSelect();{const a=e[s+1];return o.controlComponent===f.PREFIX&&a.controlComponent===f.PLACEHOLDER||a.controlComponent===f.POSTFIX||o.controlComponent===f.PLACEHOLDER?this.control.removeControl(n):this.clearSelect()}}return s}cut(){this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();return t===e?t:this.clearSelect()}clearSelect(t={}){const e=t.elementList||this.control.getElementList(),{startIndex:i}=t.range||this.control.getRange(),n=e[i];let s=-1,o=-1,r=i;for(;r>0;){const u=e[r];if(u.controlId!==n.controlId||u.controlComponent===f.PREFIX){s=r;break}r--}let a=i+1;for(;a<e.length;){const u=e[a];if(u.controlId!==n.controlId||u.controlComponent===f.POSTFIX){o=a-1;break}a++}return!~s||!~o?-1:(this.control.getDraw().spliceElementList(e,s+1,o-s),this.control.addPlaceholder(r),this.element.control.code=null,r)}setSelect(t,e={}){const n=this.element.control.valueSets;if(!Array.isArray(n)||!n.length)return;const s=n.find(O=>O.code===t);if(!s)return;const o=this.clearSelect(e);this.control.removePlaceholder(o);const r=e.elementList||this.control.getElementList(),a=r[o],l=a.controlComponent===f.PREFIX?de(a,mt):a,u=o+1,c=ht(s.value),h=this.control.getDraw();for(let O=0;O<c.length;O++){const P=$(H({},l),{value:c[O],controlComponent:f.VALUE});tt(r,[P],o),h.spliceElementList(r,u+O,0,P)}if(this.element.control.code=t,!e.range){const O=u+c.length-1;this.control.repaintControl(O),this.destroy()}}_createSelectPopupDom(){const e=this.element.control.valueSets;if(!Array.isArray(e)||!e.length)return;const i=this.control.getPosition();if(!i)return;const n=document.createElement("div");n.classList.add(`${E}-select-control-popup`),n.setAttribute(gt,M.EditorComponent.POPUP);const s=document.createElement("ul");for(let c=0;c<e.length;c++){const h=e[c],O=document.createElement("li");this.getCode()===h.code&&O.classList.add("active"),O.onclick=()=>{this.setSelect(h.code)},O.append(document.createTextNode(h.value)),s.append(O)}n.append(s);const{coordinate:{leftTop:[o,r]},lineHeight:a}=i,l=this.control.getPreY();n.style.left=`${o}px`,n.style.top=`${r+l+a}px`,this.control.getContainer().append(n),this.selectDom=n}awake(){var i;if(this.isPopup)return;const{startIndex:t}=this.control.getRange();((i=this.control.getElementList()[t+1])==null?void 0:i.controlId)===this.element.controlId&&(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){var t;!this.isPopup||((t=this.selectDom)==null||t.remove(),this.isPopup=!1)}}class Ke{constructor(t,e){d(this,"element");d(this,"control");this.element=t,this.control=e}getElement(){return this.element}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),i=t[e],n=[];let s=e;for(;s>0;){const r=t[s];if(r.controlId!==i.controlId||r.controlComponent===f.PREFIX)break;r.controlComponent===f.VALUE&&n.unshift(r),s--}let o=e+1;for(;o<t.length;){const r=t[o];if(r.controlId!==i.controlId||r.controlComponent===f.POSTFIX)break;r.controlComponent===f.VALUE&&n.push(r),o++}return n}setValue(t,e={}){const i=e.elementList||this.control.getElementList(),n=e.range||this.control.getRange();this.control.shrinkBoundary();const{startIndex:s,endIndex:o}=n,r=this.control.getDraw();s!==o?r.spliceElementList(i,s+1,o-s):this.control.removePlaceholder(s);const a=i[s],l=a.controlComponent===f.PREFIX?de(a,mt):a,u=n.startIndex+1;for(let c=0;c<t.length;c++){const h=$(H(H({},l),t[c]),{controlComponent:f.VALUE});tt(i,[h],s),r.spliceElementList(i,u+c,0,h)}return u+t.length-1}clearValue(t={}){const e=t.elementList||this.control.getElementList(),i=t.range||this.control.getRange(),{startIndex:n,endIndex:s}=i;return this.control.getDraw().spliceElementList(e,n+1,s-n),this.getValue().length||this.control.addPlaceholder(n),n}keydown(t){const e=this.control.getElementList(),i=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:s}=i,o=e[n],r=e[s],a=this.control.getDraw();if(t.key===M.KeyMap.Backspace)return n!==s?(a.spliceElementList(e,n+1,s-n),this.getValue().length||this.control.addPlaceholder(n),n):o.controlComponent===f.PREFIX||r.controlComponent===f.POSTFIX||o.controlComponent===f.PLACEHOLDER?this.control.removeControl(n):(a.spliceElementList(e,n,1),this.getValue().length||this.control.addPlaceholder(n-1),n-1);if(t.key===M.KeyMap.Delete){if(n!==s)return a.spliceElementList(e,n+1,s-n),this.getValue().length||this.control.addPlaceholder(n),n;{const l=e[s+1];return o.controlComponent===f.PREFIX&&l.controlComponent===f.PLACEHOLDER||l.controlComponent===f.POSTFIX||o.controlComponent===f.PLACEHOLDER?this.control.removeControl(n):(a.spliceElementList(e,n+1,1),this.getValue().length||this.control.addPlaceholder(n),n)}}return s}cut(){this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const i=this.control.getDraw(),n=this.control.getElementList();return i.spliceElementList(n,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}}class Tn{constructor(t){d(this,"draw");d(this,"range");d(this,"listener");d(this,"eventBus");d(this,"options");d(this,"activeControl");this.draw=t,this.range=t.getRange(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.options=t.getOptions().control,this.activeControl=null}getDraw(){return this.draw}filterAssistElement(t){return["header","main","footer"].forEach(i=>{t[i]=t[i].filter(n=>{var s;return n.type!==M.ElementType.CONTROL||((s=n.control)==null?void 0:s.minWidth)?!0:n.controlComponent!==f.PREFIX&&n.controlComponent!==f.POSTFIX&&n.controlComponent!==f.PLACEHOLDER})}),t}isPartRangeInControlOutside(){const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const i=this.getElementList(),n=i[t],s=i[e];return(n.type===M.ElementType.CONTROL||s.type===M.ElementType.CONTROL)&&n.controlId!==s.controlId}isRangInPostfix(){if(!this.activeControl)return!1;const{startIndex:t,endIndex:e}=this.getRange();return t!==e?!1:this.getElementList()[t].controlComponent===f.POSTFIX}isRangeWithinControl(){const{startIndex:t,endIndex:e}=this.getRange();if(!~t&&!~e)return!1;const i=this.getElementList(),n=i[t],s=i[e];return(n.type===M.ElementType.CONTROL||s.type===M.ElementType.CONTROL)&&s.controlComponent!==f.POSTFIX&&n.controlId===s.controlId}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(){const t=this.draw.getHeight(),e=this.draw.getPageGap();return this.draw.getPageNo()*(t+e)}getRange(){return this.range.getRange()}shrinkBoundary(){this.range.shrinkBoundary()}getActiveControl(){return this.activeControl}initControl(){if(this.draw.isReadonly())return;const e=this.getElementList(),i=this.getRange(),n=e[i.startIndex];if(this.activeControl){this.activeControl instanceof yt&&this.activeControl.awake();const o=this.activeControl.getElement();if(n.controlId===o.controlId)return}this.destroyControl();const s=n.control;if(s.type===M.ControlType.TEXT)this.activeControl=new Ke(n,this);else if(s.type===M.ControlType.SELECT){const o=new yt(n,this);this.activeControl=o,o.awake()}else s.type===M.ControlType.CHECKBOX&&(this.activeControl=new kt(n,this));Dt(()=>{var u;const o=this.listener.controlChange,r=this.eventBus.isSubscribe("controlChange");if(!o&&!r)return;let a;const l=(u=this.activeControl)==null?void 0:u.getValue();l&&l.length?a=k(l)[0].control:a=Ut(j(n)).control,o&&o(a),r&&this.eventBus.emit("controlChange",a)})}destroyControl(){this.activeControl&&(this.activeControl instanceof yt&&this.activeControl.destroy(),this.activeControl=null,Dt(()=>{const t=this.listener.controlChange,e=this.eventBus.isSubscribe("controlChange");!t&&!e||(t&&t(null),e&&this.eventBus.emit("controlChange",null))}))}repaintControl(t){this.range.setRange(t,t),this.draw.render({curIndex:t})}moveCursor(t){const{index:e,trIndex:i,tdIndex:n,tdValueIndex:s}=t;let o=this.draw.getOriginalElementList(),r;const a=t.isTable?s:e;if(t.isTable?(o=o[e].trList[i].tdList[n].value,r=o[s]):r=o[e],r.controlComponent===f.VALUE)return{newIndex:a,newElement:r};if(r.controlComponent===f.POSTFIX){let l=a+1;for(;l<o.length;){if(o[l].controlId!==r.controlId)return{newIndex:l-1,newElement:o[l-1]};l++}}else if(r.controlComponent===f.PREFIX){let l=a+1;for(;l<o.length;){const u=o[l];if(u.controlId!==r.controlId||u.controlComponent!==f.PREFIX)return{newIndex:l-1,newElement:o[l-1]};l++}}else if(r.controlComponent===f.PLACEHOLDER){let l=a-1;for(;l>0;){const u=o[l];if(u.controlId!==r.controlId||u.controlComponent===f.PREFIX)return{newIndex:l,newElement:o[l]};l--}}return{newIndex:a,newElement:r}}removeControl(t){const e=this.getElementList(),i=e[t];let n=-1,s=-1,o=t;for(;o>0;){if(e[o].controlId!==i.controlId){n=o;break}o--}let r=t+1;for(;r<e.length;){if(e[r].controlId!==i.controlId){s=r-1;break}r++}return r===e.length&&(s=r-1),!~n&&!~s?t:(n=~n?n:0,this.draw.spliceElementList(e,n+1,s-n),n)}removePlaceholder(t){const e=this.getElementList(),i=e[t],n=e[t+1];if(i.controlComponent===f.PLACEHOLDER||n.controlComponent===f.PLACEHOLDER){let s=t;for(;s<e.length;){const o=e[s];if(o.controlId!==i.controlId)break;o.controlComponent===f.PLACEHOLDER?this.draw.spliceElementList(e,s,1):s++}}}addPlaceholder(t){const e=this.getElementList(),i=e[t],n=i.control;if(!n.placeholder)return;const s=ht(n.placeholder);for(let o=0;o<s.length;o++){const a={value:s[o],controlId:i.controlId,type:M.ElementType.CONTROL,control:i.control,controlComponent:f.PLACEHOLDER,color:this.options.placeholderColor};tt(e,[a],t),this.draw.spliceElementList(e,t+o+1,0,a)}}setValue(t){if(!this.activeControl)throw new Error("active control is null");return this.activeControl.setValue(t)}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()}getValueByConceptId(t){var o;const{conceptId:e}=t,i=[...this.draw.getHeaderElementList(),...this.draw.getOriginalMainElementList(),...this.draw.getFooterElementList()],n=[];let s=0;for(;s<i.length;){const r=i[s];if(s++,((o=r==null?void 0:r.control)==null?void 0:o.conceptId)!==e)continue;const{type:a,code:l,valueSets:u}=r.control;let c=s,h="";for(;c<i.length;){const O=i[c];if(O.controlId!==r.controlId)break;a===M.ControlType.TEXT&&O.controlComponent===f.VALUE&&(h+=O.value),c++}if(a===M.ControlType.TEXT)n.push($(H({},r.control),{value:h||null,innerText:h||null}));else if(a===M.ControlType.SELECT||a===M.ControlType.CHECKBOX){const O=l==null?void 0:l.split(",").map(P=>{var N;return(N=u==null?void 0:u.find(X=>X.code===P))==null?void 0:N.value}).filter(Boolean).join("");n.push($(H({},r.control),{value:l||null,innerText:O||null}))}s=c}return n}setValueByConceptId(t){var r;if(this.draw.isReadonly())return;let i=!1;const{conceptId:n,value:s}=t,o=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of o){let l=0;for(;l<a.length;){const u=a[l];if(l++,((r=u==null?void 0:u.control)==null?void 0:r.conceptId)!==n)continue;i=!0;const{type:c}=u.control;let h=l;for(;h<a.length&&a[h].controlId===u.controlId;)h++;const O={startIndex:l-1,endIndex:h-2},P={range:O,elementList:a};if(c===M.ControlType.TEXT){const X=[{value:s}];at(X,{isHandleFirstElement:!1,editorOptions:this.draw.getOptions()});const L=new Ke(u,this);s?L.setValue(X,P):L.clearValue(P)}else if(c===M.ControlType.SELECT){const X=new yt(u,this);s?X.setSelect(s,P):X.clearSelect(P)}else if(c===M.ControlType.CHECKBOX){const X=new kt(u,this),L=a.slice(O.startIndex+1,O.endIndex+1),g=(s==null?void 0:s.split(","))||[];for(const Y of L)if(Y.controlComponent===f.CHECKBOX){const V=Y.checkbox;V.value=g.includes(V.code)}X.setSelect(P)}let N=l;for(;N<a.length&&a[N].controlId===u.controlId;)N++;l=N}}i&&this.draw.render({isSetCursor:!1})}}class Sn{constructor(t){d(this,"options");this.options=t.getOptions()}render(t,e,i,n){const{checkbox:{gap:s,lineWidth:o,fillStyle:r,fontStyle:a},scale:l}=this.options,{metrics:u,checkbox:c}=e,h=Math.round(i+s),O=Math.round(n-u.height+o),P=u.width-s*2*l,N=u.height;t.save(),t.beginPath(),t.translate(.5,.5),(c==null?void 0:c.value)?(t.lineWidth=o,t.strokeStyle=r,t.rect(h,O,P,N),t.stroke(),t.beginPath(),t.fillStyle=r,t.fillRect(h,O,P,N),t.beginPath(),t.strokeStyle=a,t.lineWidth=o*2,t.moveTo(h+2*l,O+7*l),t.lineTo(h+7*l,O+11*l),t.moveTo(h+6.5*l,O+11*l),t.lineTo(h+12*l,O+3*l),t.stroke()):(t.lineWidth=o,t.rect(h,O,P,N),t.stroke()),t.closePath(),t.restore()}}const fe="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBjOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuVEFCTEU9InRhYmxlIix0LkhZUEVSTElOSz0iaHlwZXJsaW5rIix0LkNPTlRST0w9ImNvbnRyb2wifSkoY3x8KGM9e30pKTt2YXIgdTsoZnVuY3Rpb24odCl7dC5WQUxVRT0idmFsdWUifSkodXx8KHU9e30pKTtjb25zdCBoPSJcdTIwMEIiLGc9YApgO2Z1bmN0aW9uIHAodCl7bGV0IGw9IiIsbz0wO2Zvcig7bzx0Lmxlbmd0aDspe2NvbnN0IG49dFtvXTtpZihuLnR5cGU9PT1jLlRBQkxFKXtpZihuLnRyTGlzdClmb3IobGV0IGk9MDtpPG4udHJMaXN0Lmxlbmd0aDtpKyspe2NvbnN0IHM9bi50ckxpc3RbaV07Zm9yKGxldCBlPTA7ZTxzLnRkTGlzdC5sZW5ndGg7ZSsrKXtjb25zdCByPXMudGRMaXN0W2VdO2wrPXAoci52YWx1ZSl9fX1lbHNlIGlmKG4udHlwZT09PWMuSFlQRVJMSU5LKXtjb25zdCBpPW4uaHlwZXJsaW5rSWQscz1bXTtmb3IoO288dC5sZW5ndGg7KXtjb25zdCBlPXRbb107aWYoaSE9PWUuaHlwZXJsaW5rSWQpe28tLTticmVha31kZWxldGUgZS50eXBlLHMucHVzaChlKSxvKyt9bCs9cChzKX1lbHNlIGlmKG4udHlwZT09PWMuQ09OVFJPTCl7Y29uc3QgaT1uLmNvbnRyb2xJZCxzPVtdO2Zvcig7bzx0Lmxlbmd0aDspe2NvbnN0IGU9dFtvXTtpZihpIT09ZS5jb250cm9sSWQpe28tLTticmVha31lLmNvbnRyb2xDb21wb25lbnQ9PT11LlZBTFVFJiYoZGVsZXRlIGUudHlwZSxzLnB1c2goZSkpLG8rK31sKz1wKHMpfSghbi50eXBlfHxuLnR5cGU9PT1jLlRFWFQpJiYobCs9bi52YWx1ZSksbysrfXJldHVybiBsfWZ1bmN0aW9uIGQodCl7Y29uc3QgbD1bXSxvPS9bMC05XS8sbj0vW0EtWmEtel0vLGk9L1xzLztsZXQgcz0hMSxlPSExLHI9IiI7ZnVuY3Rpb24gYSgpe3ImJihsLnB1c2gocikscj0iIil9Zm9yKGNvbnN0IGYgb2YgdCluLnRlc3QoZik/KHN8fGEoKSxyKz1mLHM9ITAsZT0hMSk6by50ZXN0KGYpPyhlfHxhKCkscis9ZixzPSExLGU9ITApOihhKCkscz0hMSxlPSExLGkudGVzdChmKXx8bC5wdXNoKGYpKTtyZXR1cm4gYSgpLGx9b25tZXNzYWdlPXQ9Pntjb25zdCBsPXQuZGF0YSxuPXAobCkucmVwbGFjZShuZXcgUmVnRXhwKGBeJHtofWApLCIiKS5yZXBsYWNlKG5ldyBSZWdFeHAoaCwiZyIpLGcpLGk9ZChuKTtwb3N0TWVzc2FnZShpLmxlbmd0aCl9fSkoKTt9KSgpOwo=",De=typeof window!="undefined"&&window.Blob&&new Blob([atob(fe)],{type:"text/javascript;charset=utf-8"});function gn(){const R=De&&(window.URL||window.webkitURL).createObjectURL(De);try{return R?new Worker(R):new Worker("data:application/javascript;base64,"+fe,{type:"module"})}finally{R&&(window.URL||window.webkitURL).revokeObjectURL(R)}}const me="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBnOyhmdW5jdGlvbihlKXtlLlRJVExFPSJ0aXRsZSJ9KShnfHwoZz17fSkpO3ZhciBvOyhmdW5jdGlvbihlKXtlLkZJUlNUPSJmaXJzdCIsZS5TRUNPTkQ9InNlY29uZCIsZS5USElSRD0idGhpcmQiLGUuRk9VUlRIPSJmb3VydGgiLGUuRklGVEg9ImZpZnRoIixlLlNJWFRIPSJzaXh0aCJ9KShvfHwobz17fSkpO2NvbnN0IHU9e1tvLkZJUlNUXToxLFtvLlNFQ09ORF06Mixbby5USElSRF06Myxbby5GT1VSVEhdOjQsW28uRklGVEhdOjUsW28uU0lYVEhdOjZ9LEk9Ilx1MjAwQiI7ZnVuY3Rpb24gZihlKXtjb25zdCBhPVtdO2xldCBzPTA7Zm9yKDtzPGUubGVuZ3RoOyl7Y29uc3QgdD1lW3NdO2lmKHQudGl0bGVJZCl7Y29uc3Qgbj10LnRpdGxlSWQsbD10LmxldmVsLGM9e3R5cGU6Zy5USVRMRSx2YWx1ZToiIixsZXZlbDpsLHRpdGxlSWQ6bn0saT1bXTtmb3IoO3M8ZS5sZW5ndGg7KXtjb25zdCB2PWVbc107aWYobiE9PXYudGl0bGVJZCl7cy0tO2JyZWFrfWkucHVzaCh2KSxzKyt9Yy52YWx1ZT1pLm1hcCh2PT52LnZhbHVlKS5qb2luKCIiKS5yZXBsYWNlKG5ldyBSZWdFeHAoSSwiZyIpLCIiKSxhLnB1c2goYyl9cysrfWlmKCFhLmxlbmd0aClyZXR1cm4gbnVsbDtjb25zdCBoPSh0LG4pPT57Y29uc3QgbD1uLnN1YkNhdGFsb2dbbi5zdWJDYXRhbG9nLmxlbmd0aC0xXSxjPXVbbD09bnVsbD92b2lkIDA6bC5sZXZlbF0saT11W3QubGV2ZWxdO2wmJmk+Yz9oKHQsbCk6bi5zdWJDYXRhbG9nLnB1c2goe2lkOnQudGl0bGVJZCxuYW1lOnQudmFsdWUsbGV2ZWw6dC5sZXZlbCxzdWJDYXRhbG9nOltdfSl9LHI9W107Zm9yKGxldCB0PTA7dDxhLmxlbmd0aDt0Kyspe2NvbnN0IG49YVt0XSxsPXJbci5sZW5ndGgtMV0sYz11W2w9PW51bGw/dm9pZCAwOmwubGV2ZWxdLGk9dVtuLmxldmVsXTtsJiZpPmM/aChuLGwpOnIucHVzaCh7aWQ6bi50aXRsZUlkLG5hbWU6bi52YWx1ZSxsZXZlbDpuLmxldmVsLHN1YkNhdGFsb2c6W119KX1yZXR1cm4gcn1vbm1lc3NhZ2U9ZT0+e2NvbnN0IGE9ZS5kYXRhLHM9ZihhKTtwb3N0TWVzc2FnZShzKX19KSgpO30pKCk7Cg==",pe=typeof window!="undefined"&&window.Blob&&new Blob([atob(me)],{type:"text/javascript;charset=utf-8"});function Fn(){const R=pe&&(window.URL||window.webkitURL).createObjectURL(pe);try{return R?new Worker(R):new Worker("data:application/javascript;base64,"+me,{type:"module"})}finally{R&&(window.URL||window.webkitURL).revokeObjectURL(R)}}const He="KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBuOyhmdW5jdGlvbihvKXtvLlRBQkxFPSJ0YWJsZSJ9KShufHwobj17fSkpO2Z1bmN0aW9uIGMobyl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBvKXtpZihzLnR5cGU9PT1uLlRBQkxFKXtjb25zdCBlPXMudHJMaXN0O2ZvcihsZXQgcj0wO3I8ZS5sZW5ndGg7cisrKXtjb25zdCBpPWVbcl07Zm9yKGxldCB1PTA7dTxpLnRkTGlzdC5sZW5ndGg7dSsrKXtjb25zdCBkPWkudGRMaXN0W3VdO3QucHVzaCguLi5jKGQudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgZSBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMoZSl8fHQucHVzaChlKX1yZXR1cm4gdH1vbm1lc3NhZ2U9bz0+e2NvbnN0IHQ9by5kYXRhLHM9Yyh0KTtwb3N0TWVzc2FnZShzKX19KSgpO30pKCk7Cg==",Ee=typeof window!="undefined"&&window.Blob&&new Blob([atob(He)],{type:"text/javascript;charset=utf-8"});function Wn(){const R=Ee&&(window.URL||window.webkitURL).createObjectURL(Ee);try{return R?new Worker(R):new Worker("data:application/javascript;base64,"+He,{type:"module"})}finally{R&&(window.URL||window.webkitURL).revokeObjectURL(R)}}class Vn{constructor(t){d(this,"draw");d(this,"wordCountWorker");d(this,"catalogWorker");d(this,"groupWorker");this.draw=t,this.wordCountWorker=new gn,this.catalogWorker=new Fn,this.groupWorker=new Wn}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=n=>{t(n.data)},this.wordCountWorker.onerror=n=>{e(n)};const i=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(i)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=n=>{t(n.data)},this.catalogWorker.onerror=n=>{e(n)};const i=this.draw.getOriginalMainElementList();this.catalogWorker.postMessage(i)})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=n=>{t(n.data)},this.groupWorker.onerror=n=>{e(n)};const i=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(i)})}}class Yn{constructor(t){d(this,"container");d(this,"canvas");d(this,"draw");d(this,"options");d(this,"curElement");d(this,"curElementSrc");d(this,"previewerDrawOption");d(this,"curPosition");d(this,"resizerSelection");d(this,"resizerHandleList");d(this,"resizerImageContainer");d(this,"resizerImage");d(this,"width");d(this,"height");d(this,"mousedownX");d(this,"mousedownY");d(this,"curHandleIndex");d(this,"previewerContainer");d(this,"previewerImage");d(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;const{resizerSelection:e,resizerHandleList:i,resizerImageContainer:n,resizerImage:s}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=i,this.resizerImageContainer=n,this.resizerImage=s,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,e.ondblclick=this._dblclick.bind(this),this.previewerContainer=null,this.previewerImage=null}_createResizerDom(){const t=document.createElement("div");t.classList.add(`${E}-resizer-selection`),t.style.display="none",t.style.borderColor=this.options.resizerColor;const e=[];for(let s=0;s<8;s++){const o=document.createElement("div");o.style.background=this.options.resizerColor,o.classList.add(`handle-${s}`),o.setAttribute("data-index",String(s)),o.onmousedown=this._mousedown.bind(this),t.append(o),e.push(o)}this.container.append(t);const i=document.createElement("div");i.classList.add(`${E}-resizer-image`),i.style.display="none";const n=document.createElement("img");return i.append(n),this.container.append(i),{resizerSelection:t,resizerHandleList:e,resizerImageContainer:i,resizerImage:n}}_mousedown(t){if(this.canvas=this.draw.getPage(),!this.curPosition||!this.curElement)return;const{scale:e}=this.options,i=this.draw.getHeight(),n=this.draw.getPageGap();this.mousedownX=t.x,this.mousedownY=t.y;const s=t.target;this.curHandleIndex=Number(s.dataset.index);const o=window.getComputedStyle(s).cursor;document.body.style.cursor=o,this.canvas.style.cursor=o,this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{coordinate:{leftTop:[r,a]}}=this.curPosition,l=this.draw.getPageNo()*(i+n);this.resizerImageContainer.style.left=`${r}px`,this.resizerImageContainer.style.top=`${a+l}px`,this.resizerImage.style.width=`${this.curElement.width*e}px`,this.resizerImage.style.height=`${this.curElement.height*e}px`;const u=this._mousemove.bind(this);document.addEventListener("mousemove",u),document.addEventListener("mouseup",()=>{this.curElement&&this.curPosition&&(this.curElement.width=this.width,this.curElement.height=this.height,this.draw.render({isSetCursor:!1}),this.drawResizer(this.curElement,this.curPosition,this.previewerDrawOption)),this.resizerImageContainer.style.display="none",document.removeEventListener("mousemove",u),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.curElement)return;const{scale:e}=this.options;let i=0,n=0;switch(this.curHandleIndex){case 0:i=this.mousedownX-t.x,n=this.mousedownY-t.y;break;case 1:n=this.mousedownY-t.y;break;case 2:i=t.x-this.mousedownX,n=this.mousedownY-t.y;break;case 3:i=t.x-this.mousedownX;break;case 5:n=t.y-this.mousedownY;break;case 6:i=this.mousedownX-t.x,n=t.y-this.mousedownY;break;case 7:i=this.mousedownX-t.x;break;default:i=t.x-this.mousedownX,n=t.y-this.mousedownY;break}this.width=this.curElement.width+i,this.height=this.curElement.height+n,this.resizerImage.style.width=`${this.width*e}px`,this.resizerImage.style.height=`${this.height*e}px`,t.preventDefault()}_dblclick(){this._drawPreviewer(),document.body.style.overflow="hidden"}_drawPreviewer(){const t=document.createElement("div");t.classList.add(`${E}-image-previewer`);const e=document.createElement("i");e.classList.add("image-close"),e.onclick=()=>{this._clearPreviewer()},t.append(e);const i=document.createElement("div");i.classList.add(`${E}-image-container`);const n=document.createElement("img");n.src=this.curElementSrc,n.draggable=!1,i.append(n),this.previewerImage=n,t.append(i);let s=0,o=0,r=1,a=0;const l=document.createElement("div");l.classList.add(`${E}-image-menu`);const u=document.createElement("i");u.classList.add("zoom-in"),u.onclick=()=>{r+=.1,this._setPreviewerTransform(r,a,s,o)},l.append(u);const c=document.createElement("i");c.onclick=()=>{r-.1<=.1||(r-=.1,this._setPreviewerTransform(r,a,s,o))},c.classList.add("zoom-out"),l.append(c);const h=document.createElement("i");h.classList.add("rotate"),h.onclick=()=>{a+=1,this._setPreviewerTransform(r,a,s,o)},l.append(h);const O=document.createElement("i");O.classList.add("original-size"),O.onclick=()=>{s=0,o=0,r=1,a=0,this._setPreviewerTransform(r,a,s,o)},l.append(O);const P=document.createElement("i");P.classList.add("image-download"),P.onclick=()=>{var Y;const{mime:g}=this.previewerDrawOption;le(n.src,`${(Y=this.curElement)==null?void 0:Y.id}.${g||"png"}`)},l.append(P),t.append(l),this.previewerContainer=t,document.body.append(t);let N=0,X=0,L=!1;n.onmousedown=g=>{L=!0,N=g.x,X=g.y,t.style.cursor="move"},t.onmousemove=g=>{!L||(s+=g.x-N,o+=g.y-X,N=g.x,X=g.y,this._setPreviewerTransform(r,a,s,o))},t.onmouseup=()=>{L=!1,t.style.cursor="auto"},t.onwheel=g=>{if(g.preventDefault(),g.deltaY<0)r+=.1;else{if(r-.1<=.1)return;r-=.1}this._setPreviewerTransform(r,a,s,o)}}_setPreviewerTransform(t,e,i,n){!this.previewerImage||(this.previewerImage.style.left=`${i}px`,this.previewerImage.style.top=`${n}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"}drawResizer(t,e,i={}){this.previewerDrawOption=i;const{scale:n}=this.options,{coordinate:{leftTop:[s,o]},ascent:r}=e,a=t.width*n,l=t.height*n,u=this.draw.getHeight(),c=this.draw.getPageGap(),h=this.options.resizerSize,O=this.draw.getPageNo()*(u+c);this.resizerSelection.style.left=`${s}px`,this.resizerSelection.style.top=`${o+O+r}px`,this.resizerSelection.style.width=`${a}px`,this.resizerSelection.style.height=`${l}px`;for(let P=0;P<8;P++){const N=P===0||P===6||P===7?-h:P===1||P===5?a/2:a-h,X=P===0||P===1||P===2?-h:P===3||P===7?l/2-h:l-h;this.resizerHandleList[P].style.left=`${N}px`,this.resizerHandleList[P].style.top=`${X}px`}this.resizerSelection.style.display="block",this.curElement=t,this.curElementSrc=t[i.srcKey||"value"]||"",this.curPosition=e,this.width=this.curElement.width*n,this.height=this.curElement.height*n,document.addEventListener("keydown",this._keydown)}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}const Zn={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"}},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",borderExternal:"\u5916\u4FA7\u6846\u7EBF",borderTd:"\u5355\u5143\u683C\u8FB9\u6846",borderTdBottom:"\u4E0B\u8FB9\u6846",borderTdForward:"\u6B63\u659C\u7EBF",borderTdBack:"\u53CD\u659C\u7EBF"}},Ge={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"};var jt={contextmenu:Zn,datePicker:Ge,frame:{header:"\u9875\u7709",footer:"\u9875\u811A"},pageBreak:{displayName:"\u5206\u9875\u7B26"}};class Un{constructor(t={}){d(this,"options");d(this,"now");d(this,"dom");d(this,"renderOptions");d(this,"isDatePicker");d(this,"pickDate");d(this,"lang");this.options=H({mountDom:document.body},t),this.lang=Ge,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(`${E}-date-container`);const e=document.createElement("div");e.classList.add(`${E}-date-wrap`);const i=document.createElement("div");i.classList.add(`${E}-date-title`);const n=document.createElement("span");n.classList.add(`${E}-date-title__pre-year`),n.innerText="<<";const s=document.createElement("span");s.classList.add(`${E}-date-title__pre-month`),s.innerText="<";const o=document.createElement("span");o.classList.add(`${E}-date-title__now`);const r=document.createElement("span");r.classList.add(`${E}-date-title__next-month`),r.innerText=">";const a=document.createElement("span");a.classList.add(`${E}-date-title__next-year`),a.innerText=">>",i.append(n),i.append(s),i.append(o),i.append(r),i.append(a);const l=document.createElement("div");l.classList.add(`${E}-date-week`);const{weeks:{sun:u,mon:c,tue:h,wed:O,thu:P,fri:N,sat:X}}=this.lang;[u,c,h,O,P,N,X].forEach(U=>{const Q=document.createElement("span");Q.innerText=`${U}`,l.append(Q)});const g=document.createElement("div");g.classList.add(`${E}-date-day`),e.append(i),e.append(l),e.append(g);const Y=document.createElement("ul");Y.classList.add(`${E}-time-wrap`);let V,T,W;[this.lang.hour,this.lang.minute,this.lang.second].forEach((U,Q)=>{const D=document.createElement("li"),K=document.createElement("span");K.innerText=U,D.append(K);const G=document.createElement("ol"),y=Q===0,p=Q===1,b=y?24:60;for(let w=0;w<b;w++){const A=document.createElement("li");A.innerText=`${String(w).padStart(2,"0")}`,A.setAttribute("data-id",`${w}`),G.append(A)}y?V=G:p?T=G:W=G,D.append(G),Y.append(D)});const Z=document.createElement("div");Z.classList.add(`${E}-date-menu`);const S=document.createElement("button");S.classList.add(`${E}-date-menu__time`),S.innerText=this.lang.timeSelect;const m=document.createElement("button");m.classList.add(`${E}-date-menu__now`),m.innerText=this.lang.now;const I=document.createElement("button");return I.classList.add(`${E}-date-menu__submit`),I.innerText=this.lang.confirm,Z.append(S),Z.append(m),Z.append(I),t.append(e),t.append(Y),t.append(Z),this.options.mountDom.append(t),{container:t,dateWrap:e,datePickerWeek:l,timeWrap:Y,title:{preYear:n,preMonth:s,now:o,nextMonth:r,nextYear:a},day:g,time:{hour:V,minute:T,second:W},menu:{time:S,now:m,submit:I}}}_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 i=t.target.dataset.id;!i||(this.pickDate.setHours(Number(i)),this._setTimePick(!1))},this.dom.time.minute.onclick=t=>{if(!this.pickDate)return;const i=t.target.dataset.id;!i||(this.pickDate.setMinutes(Number(i)),this._setTimePick(!1))},this.dom.time.second.onclick=t=>{if(!this.pickDate)return;const i=t.target.dataset.id;!i||(this.pickDate.setSeconds(Number(i)),this._setTimePick(!1))}}_setPosition(){if(!this.renderOptions)return;const{position:{coordinate:{leftTop:[t,e]},lineHeight:i},startTop:n}=this.renderOptions;this.dom.container.style.left=`${t}px`,this.dom.container.style.top=`${e+(n||0)+i}px`}isInvalidDate(t){return t.toDateString()==="Invalid Date"}_setValue(){var e;const t=(e=this.renderOptions)==null?void 0:e.value;if(t){const i=new Date(t);this.now=this.isInvalidDate(i)?new Date:i}else this.now=new Date;this.pickDate=new Date(this.now)}_setLang(){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:i,wed:n,thu:s,fri:o,sat:r}}=this.lang,a=[t,e,i,n,s,o,r];this.dom.datePickerWeek.childNodes.forEach((h,O)=>{const P=h;P.innerText=a[O]});const l=this.dom.time.hour.previousElementSibling;l.innerText=this.lang.hour;const u=this.dom.time.minute.previousElementSibling;u.innerText=this.lang.minute;const c=this.dom.time.second.previousElementSibling;c.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),i=t.getMonth()+1,n=t.getDate();let s=null,o=null,r=null;this.pickDate&&(s=this.pickDate.getFullYear(),o=this.pickDate.getMonth()+1,r=this.pickDate.getDate());const a=this.now.getFullYear(),l=this.now.getMonth()+1;this.dom.title.now.innerText=`${a}${this.lang.year} ${String(l).padStart(2,"0")}${this.lang.month}`;const c=new Date(a,l,0).getDate();let h=new Date(a,l-1,1).getDay();h===0&&(h=7);const O=new Date(a,l-1,0).getDate();this.dom.day.innerHTML="";const P=O-h+1;for(let X=P;X<=O;X++){const L=document.createElement("div");L.classList.add("disable"),L.innerText=`${X}`,L.onclick=()=>{const g=l-2;this.now=new Date(a,g,X),this._setDatePick(a,g,X)},this.dom.day.append(L)}for(let X=1;X<=c;X++){const L=document.createElement("div");e===a&&i===l&&n===X&&L.classList.add("active"),this.pickDate&&s===a&&o===l&&r===X&&L.classList.add("select"),L.innerText=`${X}`,L.onclick=g=>{const Y=l-1;this.now=new Date(a,Y,X),this._setDatePick(a,Y,X),g.stopPropagation()},this.dom.day.append(L)}const N=6*7-h-c;for(let X=1;X<=N;X++){const L=document.createElement("div");L.classList.add("disable"),L.innerText=`${X}`,L.onclick=()=>{this.now=new Date(a,l,X),this._setDatePick(a,l,X)},this.dom.day.append(L)}}_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,i){var n,s,o;this.now=new Date(t,e,i),(n=this.pickDate)==null||n.setFullYear(t),(s=this.pickDate)==null||s.setMonth(e),(o=this.pickDate)==null||o.setDate(i),this._update()}_setTimePick(t=!0){var u,c,h;const e=((u=this.pickDate)==null?void 0:u.getHours())||0,i=((c=this.pickDate)==null?void 0:c.getMinutes())||0,n=((h=this.pickDate)==null?void 0:h.getSeconds())||0,{hour:s,minute:o,second:r}=this.dom.time;[s,o,r].forEach(O=>{O.querySelectorAll("li").forEach(P=>P.classList.remove("active"))}),[[s,e],[o,i],[r,n]].forEach(([O,P])=>{const N=O.querySelector(`[data-id='${P}']`);N.classList.add("active"),t&&this._scrollIntoView(O,N)})}_scrollIntoView(t,e){if(!e){t.scrollTop=0;return}const i=[];let n=e.offsetParent;for(;n&&t!==n&&t.contains(n);)i.push(n),n=n.offsetParent;const s=e.offsetTop+i.reduce((l,u)=>l+u.offsetTop,0),o=s+e.offsetHeight,r=t.scrollTop,a=r+t.clientHeight;s<r?t.scrollTop=s:o>a&&(t.scrollTop=o-t.clientHeight)}_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.element.dateFormat,i=this.formatDate(this.pickDate,e);this.options.onSubmit(i)}}formatDate(t,e="yyyy-MM-dd hh:mm:ss"){let i=e;const n={"y+":t.getFullYear().toString(),"M+":(t.getMonth()+1).toString(),"d+":t.getDate().toString(),"h+":t.getHours().toString(),"m+":t.getMinutes().toString(),"s+":t.getSeconds().toString()};for(const s in n){const o=new RegExp("("+s+")").exec(e),r=s;o&&(i=i.replace(o[1],o[1].length===1?n[r]:n[r].padStart(o[1].length,"0")))}return i}render(t){this.renderOptions=t,this.options.getLang&&(this.lang=this.options.getLang(),this._setLang()),this._setValue(),this._update(),this._setPosition(),this.isDatePicker=!0,this._toggleDateTimePicker(),this._toggleVisible(!0)}dispose(){this._toggleVisible(!1)}}class Qn{constructor(t){d(this,"draw");d(this,"range");d(this,"datePicker");this.draw=t,this.range=t.getRange();const e=t.getI18n(),i=e.t.bind(e);this.datePicker=new Un({mountDom:t.getContainer(),onSubmit:this._setValue.bind(this),getLang:()=>({now:i("datePicker.now"),confirm:i("datePicker.confirm"),return:i("datePicker.return"),timeSelect:i("datePicker.timeSelect"),weeks:{sun:i("datePicker.weeks.sun"),mon:i("datePicker.weeks.mon"),tue:i("datePicker.weeks.tue"),wed:i("datePicker.weeks.wed"),thu:i("datePicker.weeks.thu"),fri:i("datePicker.weeks.fri"),sat:i("datePicker.weeks.sat")},year:i("datePicker.year"),month:i("datePicker.month"),hour:i("datePicker.hour"),minute:i("datePicker.minute"),second:i("datePicker.second")})})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[i,n]=e,s=this.draw.getElementList(),o=s[i+1];this.draw.spliceElementList(s,i+1,n-i),this.range.setRange(i,i);const r={type:M.ElementType.DATE,value:"",dateFormat:o.dateFormat,valueList:[{value:t}]};tt(s,[r],i),this.draw.insertElementList([r])}getDateElementRange(){let t=-1,e=-1;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return null;const s=this.draw.getElementList(),o=s[i];if(o.type!==M.ElementType.DATE)return null;let r=i;for(;r>0;){if(s[r].dateId!==o.dateId){t=r;break}r--}let a=i+1;for(;a<s.length;){if(s[a].dateId!==o.dateId){e=a-1;break}a++}return a===s.length&&(e=a-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const i=this.draw.getHeight(),n=this.draw.getPageGap(),s=this.draw.getPageNo()*(i+n),o=this.draw.getElementList(),r=this.getDateElementRange(),a=r?o.slice(r[0]+1,r[1]+1).map(l=>l.value).join(""):"";this.datePicker.render({value:a,element:t,position:e,startTop:s})}render(t,e,i,n){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,i,n),t.restore()}}M.BlockType=void 0,function(R){R.IFRAME="iframe",R.VIDEO="video"}(M.BlockType||(M.BlockType={}));const ee=class{constructor(t){d(this,"element");this.element=t}render(t){var n;const e=this.element.block,i=document.createElement("iframe");i.sandbox.add(...ee.sandbox),i.style.border="none",i.style.width="100%",i.style.height="100%",i.src=((n=e.iframeBlock)==null?void 0:n.src)||"",t.append(i)}};let qt=ee;d(qt,"sandbox",["allow-forms","allow-scripts","allow-same-origin","allow-popups"]);class In{constructor(t){d(this,"element");this.element=t}render(t){var n;const e=this.element.block,i=document.createElement("video");i.style.width="100%",i.style.height="100%",i.style.objectFit="contain",i.src=((n=e.videoBlock)==null?void 0:n.src)||"",i.controls=!0,i.crossOrigin="anonymous",t.append(i)}}class Kn{constructor(t,e){d(this,"draw");d(this,"element");d(this,"block");d(this,"blockContainer");d(this,"blockItem");this.draw=t.getDraw(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null,this.blockItem=this._createBlockItem(),this.blockContainer.append(this.blockItem)}getBlockElement(){return this.element}_createBlockItem(){const t=document.createElement("div");return t.classList.add(`${E}-block-item`),t}render(){const t=this.element.block;t.type===M.BlockType.IFRAME?(this.block=new qt(this.element),this.block.render(this.blockItem)):t.type===M.BlockType.VIDEO&&(this.block=new In(this.element),this.block.render(this.blockItem))}setClientRects(t,e,i){const n=this.draw.getHeight(),s=this.draw.getPageGap(),o=t*(n+s),{metrics:r}=this.element;this.blockItem.style.width=`${r.width}px`,this.blockItem.style.height=`${r.height}px`,this.blockItem.style.left=`${e}px`,this.blockItem.style.top=`${o+i}px`}remove(){this.blockItem.remove()}}class fn{constructor(t){d(this,"draw");d(this,"container");d(this,"blockContainer");d(this,"blockMap");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(`${E}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,i,n){const s=e.id,o=this.blockMap.get(s);if(o)o.setClientRects(t,i,n);else{const r=new Kn(this,e);r.render(),r.setClientRects(t,i,n),this.blockMap.set(s,r)}}clear(){if(!this.blockMap.size)return;const t=this.draw.getElementList(),e=[];for(let i=0;i<t.length;i++){const n=t[i];n.type===M.ElementType.BLOCK&&e.push(n.id)}this.blockMap.forEach(i=>{const n=i.getBlockElement().id;e.includes(n)||(i.remove(),this.blockMap.delete(n))})}}var Dn={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"}},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",borderExternal:"External",borderTd:"Table cell border",borderTdBottom:"Bottom",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"}};class mn{constructor(){d(this,"langMap",new Map([["zhCN",jt],["en",Dn]]));d(this,"currentLocale","zhCN")}registerLangMap(t,e){const i=this.langMap.get(t);this.langMap.set(t,ue(i||jt,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||jt}t(t){const e=t.split(".");let i="",n=this.getLang();for(let s=0;s<e.length;s++){const o=e[s],r=Reflect.get(n,o);if(r)i=n=r;else return""}return i}}class pn{constructor(){d(this,"promiseList");this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class Hn{constructor(t){d(this,"INDICATOR_PADDING",2);d(this,"INDICATOR_TITLE_TRANSLATE",[20,5]);d(this,"draw");d(this,"options");d(this,"i18n");d(this,"container");d(this,"currentZone");d(this,"indicatorContainer");this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=M.EditorZone.MAIN,this.indicatorContainer=null}isHeaderActive(){return this.getZone()===M.EditorZone.HEADER}isMainActive(){return this.getZone()===M.EditorZone.MAIN}isFooterActive(){return this.getZone()===M.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),Dt(()=>{const e=this.draw.getListener();e.zoneChange&&e.zoneChange(t);const i=this.draw.getEventBus();i.isSubscribe("zoneChange")&&i.emit("zoneChange",t)}))}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[i,n]=this.INDICATOR_TITLE_TRANSLATE,s=this.draw.getPageList(),o=this.draw.getMargins(),r=this.draw.getInnerWidth(),a=this.draw.getHeight(),l=this.draw.getPageGap(),u=a+l;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${E}-zone-indicator`);const c=this.draw.getHeader(),h=this.draw.getFooter(),O=e?c.getHeight():h.getHeight(),P=e?c.getHeaderTop():a-h.getFooterBottom()-O;for(let N=0;N<s.length;N++){const X=u*N+P,L=o[3]-this.INDICATOR_PADDING,g=o[3]+r+this.INDICATOR_PADDING,Y=e?X-this.INDICATOR_PADDING:X+O+this.INDICATOR_PADDING,V=e?X+O+this.INDICATOR_PADDING:X-this.INDICATOR_PADDING,T=document.createElement("div");T.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),T.style.top=`${V}px`,T.style.transform=`translate(${i*t}px, ${n*t}px) scale(${t})`,this.indicatorContainer.append(T);const W=document.createElement("span");W.classList.add(`${E}-zone-indicator-border__top`),W.style.top=`${Y}px`,W.style.width=`${r}px`,W.style.marginLeft=`${o[3]}px`,this.indicatorContainer.append(W);const F=document.createElement("span");F.classList.add(`${E}-zone-indicator-border__left`),F.style.top=`${X}px`,F.style.height=`${O}px`,F.style.left=`${L}px`,this.indicatorContainer.append(F);const Z=document.createElement("span");Z.classList.add(`${E}-zone-indicator-border__bottom`),Z.style.top=`${V}px`,this.indicatorContainer.append(Z);const S=document.createElement("span");S.classList.add(`${E}-zone-indicator-border__right`),S.style.top=`${X}px`,S.style.height=`${O}px`,S.style.left=`${g}px`,this.indicatorContainer.append(S)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){var t;(t=this.indicatorContainer)==null||t.remove(),this.indicatorContainer=null}}class En{constructor(t,e){d(this,"draw");d(this,"position");d(this,"options");d(this,"elementList");d(this,"rowList");d(this,"positionList");this.draw=t,this.position=t.getPosition(),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(t,this.elementList)}_computePositionList(){const t=this.getFooterBottom(),e=this.draw.getInnerWidth(),n=this.draw.getMargins()[3],s=this.draw.getHeight(),o=this.getHeight(),r=s-t-o;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:n,startY:r,innerWidth:e})}getFooterBottom(){const{footer:{bottom:t,disabled:e},scale:i}=this.options;return e?0:Math.floor(t*i)}getMaxHeight(){const{footer:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*se[t])}getHeight(){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(),n=this.getFooterBottom()+e-t[2];return n<=0?0:n}render(t,e){t.globalAlpha=1;const i=this.draw.getInnerWidth(),n=this.getMaxHeight(),s=[];let o=0;for(let r=0;r<this.rowList.length;r++){const a=this.rowList[r];if(o+a.height>n)break;s.push(a),o+=a.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:s,pageNo:e,startIndex:0,innerWidth:i,zone:M.EditorZone.FOOTER})}}class Gn{constructor(t){d(this,"options");d(this,"UN_COUNT_STYLE_WIDTH",20);d(this,"MEASURE_BASE_TEXT","0");d(this,"LIST_GAP",10);this.options=t.getOptions()}computeListStyle(t,e){const i=new Map;let n=0,s=e[n].listId,o=[];const r=e.length;for(;n<r;){const a=e[n];if(s&&s===a.listId)o.push(a);else if(a.listId&&a.listId!==s){if(o.length){const l=this.getListStyleWidth(t,o);i.set(s,l)}s=a.listId,o=s?[a]:[]}n++}if(o.length){const a=this.getListStyleWidth(t,o);i.set(s,a)}return i}getListStyleWidth(t,e){const{scale:i}=this.options,n=e[0];if(n.listStyle&&n.listStyle!==M.ListStyle.DECIMAL)return this.UN_COUNT_STYLE_WIDTH*i;const s=e.reduce((a,l)=>(l.value===C&&(a+=1),a),0);if(!s)return 0;const o=`${this.MEASURE_BASE_TEXT.repeat(String(s).length)}${M.KeyMap.PERIOD}`,r=t.measureText(o);return Math.ceil((r.width+this.LIST_GAP)*i)}drawListStyle(t,e,i){const{elementList:n,offsetX:s,listIndex:o,ascent:r}=e,a=n[0];if(a.value!==C||a.listWrap)return;let l=0;const{defaultTabWidth:u,scale:c,defaultFont:h,defaultSize:O}=this.options;for(let Y=1;Y<n.length;Y++){const V=n[Y];if((V==null?void 0:V.type)!==M.ElementType.TAB)break;l+=u*c}let P="";if(a.listType===M.ListType.UL?P=Se[a.listStyle]||Se[Vt.DISC]:P=`${o+1}${M.KeyMap.PERIOD}`,!P)return;const{coordinate:{leftTop:[N,X]}}=i,L=N-s+l,g=X+r;t.save(),t.font=`${O*c}px ${h}`,t.fillText(P,L,g),t.restore()}}class bn{constructor(t){d(this,"draw");d(this,"position");d(this,"options");d(this,"elementList");d(this,"rowList");d(this,"positionList");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(){this._computeRowList(),this._computePositionList()}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList(t,this.elementList)}_computePositionList(){const t=this.draw.getHeader().getExtraHeight(),e=this.draw.getInnerWidth(),i=this.draw.getMargins(),n=i[3],s=i[0]+t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:n,startY:s,innerWidth:e})}render(t){const{placeholder:{data:e,font:i,size:n,color:s,opacity:o}}=this.options;if(!e)return;this._recovery(),this.elementList=[{value:e,font:i,size:n,color:s}],at(this.elementList,{editorOptions:this.options}),this._compute();const r=this.draw.getInnerWidth();t.save(),t.globalAlpha=o,this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:this.rowList,pageNo:0,startIndex:0,innerWidth:r}),t.restore()}}class yn{constructor(t){d(this,"draw");d(this,"options");d(this,"range");d(this,"fillRectMap");this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==M.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=x();return t.forEach(i=>{Array.isArray(i.groupIds)||(i.groupIds=[]),i.groupIds.push(e)}),this.draw.render({isSetCursor:!1,isCompute:!1}),e}getElementListByGroupId(t,e){var n,s;const i=[];for(let o=0;o<t.length;o++){const r=t[o];if(r.type===M.ElementType.TABLE){const a=r.trList;for(let l=0;l<a.length;l++){const u=a[l];for(let c=0;c<u.tdList.length;c++){const h=u.tdList[c],O=this.getElementListByGroupId(h.value,e);if(O.length)return i.push(...O),i}}}if((n=r==null?void 0:r.groupIds)==null?void 0:n.includes(e)){i.push(r);const a=t[o+1];if(!((s=a==null?void 0:a.groupIds)==null?void 0:s.includes(e)))break}}return i}deleteGroup(t){if(this.draw.isReadonly())return;const e=this.draw.getOriginalMainElementList(),i=this.getElementListByGroupId(e,t);if(!!i.length){for(let n=0;n<i.length;n++){const s=i[n],o=s.groupIds,r=o.findIndex(a=>a===t);o.splice(r,1),o.length||delete s.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){var i,n;for(let s=0;s<t.length;s++){const o=t[s];if(o.type===M.ElementType.TABLE){const a=o.trList;for(let l=0;l<a.length;l++){const u=a[l];for(let c=0;c<u.tdList.length;c++){const h=u.tdList[c],O=this.getContextByGroupId(h.value,e);if(O)return $(H({},O),{isTable:!0,index:s,trIndex:l,tdIndex:c,tdId:h.id,trId:u.id,tableId:o.tableId})}}}const r=t[s+1];if(((i=o.groupIds)==null?void 0:i.includes(e))&&!((n=r==null?void 0:r.groupIds)==null?void 0:n.includes(e)))return{isTable:!1,startIndex:s,endIndex:s}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,i,n,s){const o=t.groupIds;if(!!o)for(const r of o){const a=this.fillRectMap.get(r);a?a.width+=n:this.fillRectMap.set(r,{x:e,y:i,width:n,height:s})}}render(t){var l;if(!this.fillRectMap.size)return;const e=this.range.getRange(),n=(l=this.draw.getElementList()[e.endIndex])==null?void 0:l.groupIds,{group:{backgroundColor:s,opacity:o,activeOpacity:r,activeBackgroundColor:a}}=this.options;t.save(),this.fillRectMap.forEach((u,c)=>{const{x:h,y:O,width:P,height:N}=u;(n==null?void 0:n.includes(c))?(t.globalAlpha=r,t.fillStyle=a):(t.globalAlpha=o,t.fillStyle=s),t.fillRect(h,O,P,N)}),t.restore(),this.clearFillInfo()}}class Cn{constructor(t,e,i,n,s,o){d(this,"container");d(this,"pageContainer");d(this,"pageList");d(this,"ctxList");d(this,"pageNo");d(this,"pagePixelRatio");d(this,"mode");d(this,"options");d(this,"position");d(this,"zone");d(this,"elementList");d(this,"listener");d(this,"eventBus");d(this,"override");d(this,"i18n");d(this,"canvasEvent");d(this,"globalEvent");d(this,"cursor");d(this,"range");d(this,"margin");d(this,"background");d(this,"search");d(this,"group");d(this,"underline");d(this,"strikeout");d(this,"highlight");d(this,"historyManager");d(this,"previewer");d(this,"imageParticle");d(this,"laTexParticle");d(this,"textParticle");d(this,"tableParticle");d(this,"tableTool");d(this,"pageNumber");d(this,"waterMark");d(this,"placeholder");d(this,"header");d(this,"footer");d(this,"hyperlinkParticle");d(this,"dateParticle");d(this,"separatorParticle");d(this,"pageBreakParticle");d(this,"superscriptParticle");d(this,"subscriptParticle");d(this,"checkboxParticle");d(this,"blockParticle");d(this,"listParticle");d(this,"control");d(this,"workerManager");d(this,"scrollObserver");d(this,"selectionObserver");d(this,"imageObserver");d(this,"LETTER_REG");d(this,"WORD_LIKE_REG");d(this,"rowList");d(this,"pageRowList");d(this,"painterStyle");d(this,"painterOptions");d(this,"visiblePageNoList");d(this,"intersectionPageNo");d(this,"lazyRenderIntersectionObserver");d(this,"printModeData");this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=i.main,this.listener=n,this.eventBus=s,this.override=o,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new mn,this.historyManager=new zi(this),this.position=new $i(this),this.zone=new Hn(this),this.range=new ji(this),this.margin=new en(this),this.background=new qi(this),this.search=new nn(this),this.group=new yn(this),this.underline=new sn(this),this.strikeout=new Rn(this),this.highlight=new tn(this),this.previewer=new Yn(this),this.imageParticle=new Pe(this),this.laTexParticle=new Ne(this),this.textParticle=new on(this),this.tableParticle=new un(this),this.tableTool=new hn(this),this.pageNumber=new ln(this),this.waterMark=new Nn(this),this.placeholder=new bn(this),this.header=new dn(this,i.header),this.footer=new En(this,i.footer),this.hyperlinkParticle=new Mn(this),this.dateParticle=new Qn(this),this.separatorParticle=new Xn,this.pageBreakParticle=new Ln(this),this.superscriptParticle=new On,this.subscriptParticle=new Pn,this.checkboxParticle=new Sn(this),this.blockParticle=new fn(this),this.listParticle=new Gn(this),this.control=new Tn(this),this.scrollObserver=new an(this),this.selectionObserver=new cn(this),this.imageObserver=new pn,this.canvasEvent=new _i(this),this.cursor=new Ki(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new ki(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new Vn(this);const{letterClass:r}=e;this.LETTER_REG=new RegExp(`[${r.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${r.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.render({isInit:!0,isSetCursor:!1})}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}setMode(t){this.mode!==t&&(t===M.EditorMode.PRINT&&(this.printModeData={header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()},this.setEditorData(this.control.filterAssistElement(j(this.printModeData)))),this.mode===M.EditorMode.PRINT&&this.printModeData&&(this.setEditorData(this.printModeData),this.printModeData=null),this.mode=t,this.render({isSetCursor:!1,isSubmitHistory:!1}))}isReadonly(){switch(this.mode){case M.EditorMode.READONLY:case M.EditorMode.PRINT:return!0;case M.EditorMode.FORM:return!this.control.isRangeWithinControl();default:return!1}}getOriginalWidth(){const{paperDirection:t,width:e,height:i}=this.options;return t===M.PaperDirection.VERTICAL?e:i}getOriginalHeight(){const{paperDirection:t,width:e,height:i}=this.options;return t===M.PaperDirection.VERTICAL?i: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(),i=this.footer.getExtraHeight();return t[0]+t[2]+e+i}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]}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===M.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}getTdPadding(){const{tdPadding:t,scale:e}=this.options;return t.map(i=>i*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}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:i,trIndex:n,tdIndex:s}=e;return t[i].trList[n].tdList[s].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}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){const e=this.position.getPositionContext(),{index:i,trIndex:n,tdIndex:s}=e;return t[i].trList[n].tdList[s].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()}insertElementList(t){if(!t.length||this.control.isPartRangeInControlOutside())return;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;at(t,{isHandleFirstElement:!1,editorOptions:this.options});let s=-1;const o=this.control.getActiveControl();if(o&&!this.control.isRangInPostfix())s=o.setValue(t);else{const r=this.getElementList(),a=i===n,l=i+1;a||this.spliceElementList(r,l,n-i),this.spliceElementList(r,l,0,...t),s=i+t.length}~s&&(this.range.setRange(s,s),this.render({curIndex:s}))}appendElementList(t,e={}){if(!t.length)return;at(t,{isHandleFirstElement:!1,editorOptions:this.options});let i;const{isPrepend:n}=e;n?(this.elementList.splice(1,0,...t),i=t.length):(this.elementList.push(...t),i=this.elementList.length-1),this.range.setRange(i,i),this.render({curIndex:i})}spliceElementList(t,e,i,...n){var s;if(i>0){const o=e+i,r=t[o],a=r==null?void 0:r.listId;if(a&&((s=t[e-1])==null?void 0:s.listId)!==a){let l=o;for(;l<t.length;){const u=t[l];if(u.listId!==a||u.value===C)break;delete u.listId,delete u.listType,delete u.listStyle,l++}}}t.splice(e,i,...n)}getCanvasEvent(){return this.canvasEvent}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}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getRowCount(){return this.rowList.length}async getDataURL(t={}){const{pixelRatio:e,mode:i}=t;e&&this.setPagePixelRatio(e);const n=this.mode,s=!!i&&n!==i;s&&this.setMode(i),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const o=this.pageList.map(r=>r.toDataURL());return e&&this.setPagePixelRatio(null),s&&this.setMode(n),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(i=>i.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===M.PageMode.PAGING}setPageMode(t){if(!(!t||this.options.pageMode===t)){if(this.options.pageMode=t,t===M.PageMode.PAGING){const{height:e}=this.options,i=this.getPagePixelRatio(),n=this.pageList[0];n.style.height=`${e}px`,n.height=e*i,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(M.EditorZone.MAIN);this.render({isSubmitHistory:!1,isSetCursor:!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 i=this.getWidth(),n=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((s,o)=>{s.width=i*e,s.height=n*e,s.style.width=`${i}px`,s.style.height=`${n}px`,s.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[o])}),this.render({isSubmitHistory:!1,isSetCursor:!1}),this.listener.pageScaleChange&&this.listener.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(),i=this.getHeight();this.pageList.forEach((n,s)=>{n.width=e*t,n.height=i*t,this._initPageContext(this.ctxList[s])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const i=this.getPagePixelRatio(),n=this.getWidth(),s=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((o,r)=>{o.width=n*i,o.height=s*i,o.style.width=`${n}px`,o.style.height=`${s}px`,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const i=this.getWidth(),n=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((s,o)=>{s.width=i*e,s.height=n*e,s.style.width=`${i}px`,s.style.height=`${n}px`,this._initPageContext(this.ctxList[o])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getValue(t={}){const{width:e,height:i,margins:n,watermark:s}=this.options,{pageNo:o}=t;let r=this.elementList;Number.isInteger(o)&&o>=0&&o<this.pageRowList.length&&(r=this.pageRowList[o].flatMap(l=>l.elementList));const a={header:k(this.getHeaderElementList()),main:k(r),footer:k(this.getFooterElementList())};return{version:it,width:e,height:i,margins:n,watermark:s.data?s:void 0,data:a}}setValue(t){const{header:e,main:i,footer:n}=t;if(!e&&!i&&!n)return;[e,i,n].forEach(o=>{!o||at(o,{editorOptions:this.options})}),this.setEditorData({header:e,main:i,footer:n}),this.historyManager.recovery(),this.render({isSetCursor:!1})}setEditorData(t){const{header:e,main:i,footer:n}=t;e&&this.header.setElementList(e),i&&(this.elementList=i),n&&this.footer.setElementList(n)}_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(gt,M.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${E}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),i=this.getHeight(),n=document.createElement("canvas");n.style.width=`${e}px`,n.style.height=`${i}px`,n.style.display="block",n.style.backgroundColor="#ffffff",n.style.marginBottom=`${this.getPageGap()}px`,n.setAttribute("data-index",String(t)),this.pageContainer.append(n);const s=this.getPagePixelRatio();n.width=e*s,n.height=i*s,n.style.cursor="text";const o=n.getContext("2d");this._initPageContext(o),this.pageList.push(n),this.ctxList.push(o)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}_getFont(t,e=1){const{defaultSize:i,defaultFont:n}=this.options,s=t.font||n,o=t.actualSize||t.size||i;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${o*e}px ${s}`}computeRowList(t,e){var X,L,g,Y,V;const{defaultSize:i,defaultRowMargin:n,scale:s,tdPadding:o,defaultTabWidth:r}=this.options,a=this.getDefaultBasicRowMarginHeight(),u=document.createElement("canvas").getContext("2d"),c=this.listParticle.computeListStyle(u,e),h=[];e.length&&h.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowFlex:(X=e==null?void 0:e[1])==null?void 0:X.rowFlex});let O,P=0,N=0;for(let T=0;T<e.length;T++){const W=h[h.length-1],F=e[T],Z=a*(F.rowMargin||n),S={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},m=F.listId&&c.get(F.listId)||0,I=t-m;if(F.type===M.ElementType.IMAGE||F.type===M.ElementType.LATEX){const p=F.width*s,b=F.height*s,w=F.imgDisplay===M.ImageDisplay.INLINE?0:W.width;if(w+p>I){const A=I-w,v=A>0?A:Math.min(p,I);F.width=v,F.height=b*v/p,S.width=F.width,S.height=F.height,S.boundingBoxDescent=F.height}else S.width=p,S.height=b,S.boundingBoxDescent=b;S.boundingBoxAscent=0}else if(F.type===M.ElementType.TABLE){const p=o[1]+o[3],b=o[0]+o[2];this.tableParticle.computeRowColInfo(F);const w=F.trList;for(let B=0;B<w.length;B++){const q=w[B];for(let nt=0;nt<q.tdList.length;nt++){const z=q.tdList[nt],et=this.computeRowList((z.width-p)*s,z.value),ct=et.reduce((St,Ct)=>St+Ct.height,0);z.rowList=et;const ot=(ct+b)/s;if(z.height<ot){const St=ot-z.height,Ct=w[B+z.rowspan-1];Ct.height+=St,Ct.tdList.forEach(hR=>{hR.height+=St})}let ut=0,Tt=0,Kt=0;for(;Kt<z.rowspan;){const St=w[Kt+B];ut+=St.minHeight,Tt+=St.height,Kt++}z.realMinHeight=ut,z.realHeight=Tt,z.mainHeight=ot}}const A=this.tableParticle.getTrListGroupByCol(w);for(let B=0;B<A.length;B++){const q=A[B];let nt=-1;for(let z=0;z<q.tdList.length;z++){const et=q.tdList[z],ct=et.realHeight,ot=et.mainHeight,ut=et.realMinHeight,Tt=ot<ut?ct-ut:ct-ot;(!~nt||Tt<nt)&&(nt=Tt)}if(nt>0){const z=w[B];z.height-=nt,z.tdList.forEach(et=>{et.height-=nt})}}this.tableParticle.computeRowColInfo(F);const v=w.reduce((B,q)=>B+q.height,0),st=F.colgroup.reduce((B,q)=>B+q.width,0);F.width=st,F.height=v;const Lt=st*s,Yt=v*s;S.width=Lt,S.height=Yt,S.boundingBoxDescent=Yt,S.boundingBoxAscent=0;const Zt=this.getHeight(),we=this.getMainOuterHeight();let It=we;for(let B=0;B<h.length;B++){const q=h[B];q.height+It>Zt||((L=h[B-1])==null?void 0:L.isPageBreak)?It=we+q.height:It+=q.height}const Je=Z*2*s;if(It+Je+Yt>Zt){const B=F.trList;let q=0,nt=0,z=0;if(B.length>1)for(let et=0;et<B.length;et++){const ct=B[et],ot=ct.height*s;if(It+Je+z+ot>Zt){((g=F.colgroup)==null?void 0:g.length)!==ct.tdList.length&&(nt=0);break}else q=et+1,nt=B.length-q,z+=ot}if(nt){const et=B.splice(q,nt),ct=et.reduce((Tt,Kt)=>Tt+Kt.height,0);F.height-=ct,S.height-=ct,S.boundingBoxDescent-=ct;const ot=j(F);ot.trList=et,ot.id=x(),this.spliceElementList(e,T+1,0,ot);const ut=this.position.getPositionContext();ut.isTable&&ut.trIndex===q&&(ut.index+=1,ut.trIndex=0,this.position.setPositionContext(ut))}}}else if(F.type===M.ElementType.SEPARATOR)F.width=I,S.width=I,S.height=i,S.boundingBoxAscent=-Z,S.boundingBoxDescent=-Z;else if(F.type===M.ElementType.PAGE_BREAK)F.width=I,S.width=I,S.height=i;else if(F.type===M.ElementType.CHECKBOX||F.controlComponent===f.CHECKBOX){const{width:p,height:b,gap:w}=this.options.checkbox,A=(p+w*2)*s;F.width=A,S.width=A,S.height=b*s}else if(F.type===M.ElementType.TAB)S.width=r*s,S.height=i*s,S.boundingBoxDescent=0,S.boundingBoxAscent=S.height;else if(F.type===M.ElementType.BLOCK){if(!F.width)S.width=I;else{const p=F.width*s;S.width=Math.min(p,I)}S.height=F.height*s,S.boundingBoxDescent=S.height,S.boundingBoxAscent=0}else{const p=F.size||i;(F.type===M.ElementType.SUPERSCRIPT||F.type===M.ElementType.SUBSCRIPT)&&(F.actualSize=Math.ceil(p*.6)),S.height=(F.actualSize||p)*s,u.font=this._getFont(F);const b=this.textParticle.measureText(u,F);S.width=b.width*s,F.letterSpacing&&(S.width+=F.letterSpacing*s),S.boundingBoxAscent=(F.value===C?i:b.actualBoundingBoxAscent)*s,S.boundingBoxDescent=b.actualBoundingBoxDescent*s,F.type===M.ElementType.SUPERSCRIPT?S.boundingBoxAscent+=S.height/2:F.type===M.ElementType.SUBSCRIPT&&(S.boundingBoxDescent+=S.height/2)}const U=F.imgDisplay!==M.ImageDisplay.INLINE&&F.type===M.ElementType.IMAGE||F.type===M.ElementType.LATEX?S.height+Z:S.boundingBoxAscent+Z,Q=Z+S.boundingBoxAscent+S.boundingBoxDescent+Z,D=Object.assign(F,{metrics:S,style:this._getFont(F,s)});if(((Y=D.control)==null?void 0:Y.minWidth)&&(D.controlComponent&&(N+=S.width),D.controlComponent===f.POSTFIX)){const p=D.control.minWidth-N;if(p>0){const b=I-W.width-S.width,w=Math.min(b,p)*s;D.left=w,W.width+=w}else D.left=0;N=0}const K=e[T-1];let G=e[T+1],y=W.width+S.width;if(this.options.wordBreak===M.WordBreak.BREAK_WORD&&(!(K==null?void 0:K.type)||(K==null?void 0:K.type)===M.ElementType.TEXT)&&(!F.type||F.type===M.ElementType.TEXT)){const p=`${(K==null?void 0:K.value)||""}${F.value}`;if(this.WORD_LIKE_REG.test(p)){const{width:b,endElement:w}=this.textParticle.measureWord(u,e,T);y+=b,G=w}y+=this.textParticle.measurePunctuationWidth(u,G)}if(F.listId&&(F.listId!==O?P=0:F.value===C&&!F.listWrap&&P++),O=F.listId,F.type===M.ElementType.TABLE||(K==null?void 0:K.type)===M.ElementType.TABLE||(K==null?void 0:K.type)===M.ElementType.BLOCK||F.type===M.ElementType.BLOCK||(K==null?void 0:K.imgDisplay)===M.ImageDisplay.INLINE||F.imgDisplay===M.ImageDisplay.INLINE||y>I||T!==0&&F.value===C||(K==null?void 0:K.listId)!==F.listId){if(W.startIndex===0&&W.elementList.length===1&&(ai.includes(F.type)||F.listId)&&(W.height=a),(K==null?void 0:K.rowFlex)===M.RowFlex.ALIGNMENT&&y>I){const b=(I-W.width)/W.elementList.length;for(let w=0;w<W.elementList.length;w++){const A=W.elementList[w];A.metrics.width+=b}W.width=I}const p={width:S.width,height:Q,startIndex:T,elementList:[D],ascent:U,rowFlex:(V=e[T+1])==null?void 0:V.rowFlex,isPageBreak:F.type===M.ElementType.PAGE_BREAK};F.listId&&(p.isList=!0,p.offsetX=c.get(F.listId),p.listIndex=P),h.push(p)}else W.width+=S.width,W.height<Q&&(W.height=Q,W.ascent=U),W.elementList.push(D)}return h}_computePageList(){var r;const t=[[]],{pageMode:e}=this.options,i=this.getHeight(),n=this.getMainOuterHeight();let s=n,o=0;if(e===M.PageMode.CONTINUITY){t[0]=this.rowList,s+=this.rowList.reduce((c,h)=>c+h.height,0);const a=this.getPagePixelRatio(),l=this.pageList[0],u=Number(l.style.height.replace("px",""));if(s>u)l.style.height=`${s}px`,l.height=s*a;else{const c=s<i?i:s;l.style.height=`${c}px`,l.height=c*a}this._initPageContext(this.ctxList[0])}else for(let a=0;a<this.rowList.length;a++){const l=this.rowList[a];l.height+s>i||((r=this.rowList[a-1])==null?void 0:r.isPageBreak)?(s=n+l.height,t.push([l]),o++):(s+=l.height,t[o].push(l))}return t}_drawRichText(t){this.underline.render(t),this.strikeout.render(t),this.highlight.render(t),this.textParticle.complete()}drawRow(t,e){var g,Y;const{rowList:i,pageNo:n,elementList:s,positionList:o,startIndex:r,zone:a}=e,l=this.mode===M.EditorMode.PRINT,{scale:u,tdPadding:c,defaultBasicRowMarginHeight:h,defaultRowMargin:O,group:P}=this.options,{isCrossRowCol:N,tableId:X}=this.range.getRange();let L=r;for(let V=0;V<i.length;V++){const T=i[V],W={x:0,y:0,width:0,height:0};let F=null;for(let Z=0;Z<T.elementList.length;Z++){const S=T.elementList[Z],m=S.metrics,{ascent:I,coordinate:{leftTop:[U,Q]}}=o[T.startIndex+Z],D=T.elementList[Z-1];if(S.highlight?(D&&D.highlight&&D.highlight!==S.highlight&&this.highlight.render(t),this.highlight.recordFillInfo(t,U,Q,m.width,T.height,S.highlight)):(D==null?void 0:D.highlight)&&this.highlight.render(t),S.type===M.ElementType.IMAGE?(this._drawRichText(t),this.imageParticle.render(t,S,U,Q+I)):S.type===M.ElementType.LATEX?(this._drawRichText(t),this.laTexParticle.render(t,S,U,Q+I)):S.type===M.ElementType.TABLE?(N&&(W.x=U,W.y=Q,F=S),this.tableParticle.render(t,S,U,Q)):S.type===M.ElementType.HYPERLINK?(this._drawRichText(t),this.hyperlinkParticle.render(t,S,U,Q+I)):S.type===M.ElementType.DATE?(this._drawRichText(t),this.dateParticle.render(t,S,U,Q+I)):S.type===M.ElementType.SUPERSCRIPT?(this._drawRichText(t),this.superscriptParticle.render(t,S,U,Q+I)):S.type===M.ElementType.SUBSCRIPT?(this._drawRichText(t),this.subscriptParticle.render(t,S,U,Q+I)):S.type===M.ElementType.SEPARATOR?this.separatorParticle.render(t,S,U,Q):S.type===M.ElementType.PAGE_BREAK?this.mode!==M.EditorMode.CLEAN&&!l&&this.pageBreakParticle.render(t,S,U,Q):S.type===M.ElementType.CHECKBOX||S.controlComponent===f.CHECKBOX?(this._drawRichText(t),this.checkboxParticle.render(t,S,U,Q+I)):S.type===M.ElementType.TAB?this._drawRichText(t):S.rowFlex===M.RowFlex.ALIGNMENT?(this.textParticle.record(t,S,U,Q+I),this._drawRichText(t)):S.type===M.ElementType.BLOCK?(this._drawRichText(t),this.blockParticle.render(n,S,U,Q)):(this.textParticle.record(t,S,U,Q+I),(S.width||S.letterSpacing)&&this.textParticle.complete()),S.underline||((g=S.control)==null?void 0:g.underline)){const p=h*(S.rowMargin||O)*u,b=S.left||0,w=S.controlComponent===f.PLACEHOLDER?void 0:S.color;this.underline.recordFillInfo(t,U-b,Q+T.height-p,m.width+b,0,w)}else((D==null?void 0:D.underline)||((Y=D==null?void 0:D.control)==null?void 0:Y.underline))&&this.underline.render(t);S.strikeout?this.strikeout.recordFillInfo(t,U,Q+T.height/2,m.width):(D==null?void 0:D.strikeout)&&this.strikeout.render(t);const{zone:K,startIndex:G,endIndex:y}=this.range.getRange();if(K===a&&G!==y&&G<=L&&L<=y)if(G===L){const p=s[G+1];p&&p.value===C&&(W.x=U+m.width,W.y=Q,W.height=T.height,W.width+=this.options.rangeMinWidth)}else{const p=this.position.getPositionContext();if(!p.isTable&&!S.tdId||p.tdId===S.tdId){let b=m.width;b===0&&T.elementList.length===1&&(b=this.options.rangeMinWidth),W.width||(W.x=U,W.y=Q,W.height=T.height),W.width+=b}}if(!P.disabled&&S.groupIds&&this.group.recordFillInfo(S,U,Q,m.width,T.height),L++,S.type===M.ElementType.TABLE){const p=c[1]+c[3];for(let b=0;b<S.trList.length;b++){const w=S.trList[b];for(let A=0;A<w.tdList.length;A++){const v=w.tdList[A];this.drawRow(t,{elementList:v.value,positionList:v.positionList,rowList:v.rowList,pageNo:n,startIndex:0,innerWidth:(v.width-p)*u,zone:a})}}}}if(T.isList&&this.listParticle.drawListStyle(t,T,o[T.startIndex]),this._drawRichText(t),this.group.render(t),!l){if(W.width&&W.height){const{x:Z,y:S,width:m,height:I}=W;this.range.render(t,Z,S,m,I)}if(N&&F&&F.id===X){const{coordinate:{leftTop:[Z,S]}}=o[T.startIndex];this.tableParticle.drawRange(t,F,Z,S)}}}}_clearPage(t){const e=this.ctxList[t],i=this.pageList[t];e.clearRect(0,0,i.width,i.height),this.blockParticle.clear()}_drawPage(t){const{elementList:e,positionList:i,rowList:n,pageNo:s}=t,{inactiveAlpha:o,pageMode:r,header:a,footer:l,pageNumber:u}=this.options,c=this.getInnerWidth(),h=this.ctxList[s];h.globalAlpha=this.zone.isMainActive()?1:o,this._clearPage(s),this.background.render(h,s),this.margin.render(h,s);const O=n[0].startIndex;this.drawRow(h,{elementList:e,positionList:i,rowList:n,pageNo:s,startIndex:O,innerWidth:c,zone:M.EditorZone.MAIN}),this.getIsPagingMode()&&(a.disabled||this.header.render(h,s),u.disabled||this.pageNumber.render(h,s),l.disabled||this.footer.render(h,s)),this.search.getSearchKeyword()&&this.search.render(h,s),r!==M.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(h),this.elementList.length<=1&&this.placeholder.render(h)}_disconnectLazyRender(){var t;(t=this.lazyRenderIntersectionObserver)==null||t.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(i=>{i.forEach(n=>{if(n.isIntersecting){const s=Number(n.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[s],pageNo:s})}})}),this.pageList.forEach(i=>{this.lazyRenderIntersectionObserver.observe(i)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let i=0;i<this.pageRowList.length;i++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[i],pageNo:i})}render(t){var X;const{header:e,footer:i}=this.options,{isSubmitHistory:n=!0,isSetCursor:s=!0,isCompute:o=!0,isLazy:r=!0,isInit:a=!1,isSourceHistory:l=!1}=t||{};let{curIndex:u}=t||{};const c=this.getInnerWidth(),h=this.getIsPagingMode();if(o){h&&(e.disabled||this.header.compute(),i.disabled||this.footer.compute()),this.rowList=this.computeRowList(c,this.elementList),this.pageRowList=this._computePageList(),this.position.computePositionList();const L=this.search.getSearchKeyword();L&&this.search.compute(L)}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let L=0;L<this.pageRowList.length;L++)this.pageList[L]||this._createPage(L);const O=this.pageRowList.length,P=this.pageList.length;if(P>O){const L=P-O;this.ctxList.splice(O,L),this.pageList.splice(O,L).forEach(g=>g.remove())}r&&h?this._lazyRender():this._immediateRender();const N=this.position.getPositionContext();if(s){const L=this.position.getPositionList();if(N.isTable){const{index:g,trIndex:Y,tdIndex:V}=N,W=(X=this.getOriginalElementList()[g].trList)==null?void 0:X[Y].tdList[V].positionList;u===void 0&&W&&(u=W.length-1);const F=W==null?void 0:W[u];this.position.setCursorPosition(F||null)}else this.position.setCursorPosition(u!==void 0?L[u]:null);this.cursor.drawCursor()}if(n){const L=this,g=j(this.elementList),Y=j(this.header.getElementList()),V=j(this.footer.getElementList()),{startIndex:T,endIndex:W}=this.range.getRange(),F=this.pageNo,Z=j(N),S=this.zone.getZone();this.historyManager.execute(function(){L.zone.setZone(S),L.setPageNo(F),L.position.setPositionContext(j(Z)),L.header.setElementList(j(Y)),L.footer.setElementList(j(V)),L.elementList=j(g),L.range.setRange(T,W),L.render({curIndex:u,isSubmitHistory:!1,isSourceHistory:!0})})}Dt(()=>{o&&!this.isReadonly()&&N.isTable&&this.tableTool.render(),o&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length),(n||l)&&!a&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"))})}destroy(){this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}}class be{constructor(t){d(this,"executeMode");d(this,"executeCut");d(this,"executeCopy");d(this,"executePaste");d(this,"executeSelectAll");d(this,"executeBackspace");d(this,"executeSetRange");d(this,"executeForceUpdate");d(this,"executeUndo");d(this,"executeRedo");d(this,"executePainter");d(this,"executeApplyPainterStyle");d(this,"executeFormat");d(this,"executeFont");d(this,"executeSize");d(this,"executeSizeAdd");d(this,"executeSizeMinus");d(this,"executeBold");d(this,"executeItalic");d(this,"executeUnderline");d(this,"executeStrikeout");d(this,"executeSuperscript");d(this,"executeSubscript");d(this,"executeColor");d(this,"executeHighlight");d(this,"executeTitle");d(this,"executeList");d(this,"executeRowFlex");d(this,"executeRowMargin");d(this,"executeInsertTable");d(this,"executeInsertTableTopRow");d(this,"executeInsertTableBottomRow");d(this,"executeInsertTableLeftCol");d(this,"executeInsertTableRightCol");d(this,"executeDeleteTableRow");d(this,"executeDeleteTableCol");d(this,"executeDeleteTable");d(this,"executeMergeTableCell");d(this,"executeCancelMergeTableCell");d(this,"executeTableTdVerticalAlign");d(this,"executeTableBorderType");d(this,"executeTableTdBorderType");d(this,"executeTableTdSlashType");d(this,"executeTableTdBackgroundColor");d(this,"executeTableSelectAll");d(this,"executeImage");d(this,"executeHyperlink");d(this,"executeDeleteHyperlink");d(this,"executeCancelHyperlink");d(this,"executeEditHyperlink");d(this,"executeSeparator");d(this,"executePageBreak");d(this,"executeAddWatermark");d(this,"executeDeleteWatermark");d(this,"executeSearch");d(this,"executeSearchNavigatePre");d(this,"executeSearchNavigateNext");d(this,"executeReplace");d(this,"executePrint");d(this,"executeReplaceImageElement");d(this,"executeSaveAsImageElement");d(this,"executeChangeImageDisplay");d(this,"executePageMode");d(this,"executePageScaleRecovery");d(this,"executePageScaleMinus");d(this,"executePageScaleAdd");d(this,"executePaperSize");d(this,"executePaperDirection");d(this,"executeSetPaperMargin");d(this,"executeInsertElementList");d(this,"executeAppendElementList");d(this,"executeSetValue");d(this,"executeRemoveControl");d(this,"executeSetLocale");d(this,"executeLocationCatalog");d(this,"executeWordTool");d(this,"executeSetHTML");d(this,"executeSetGroup");d(this,"executeDeleteGroup");d(this,"executeLocationGroup");d(this,"executeSetControlValue");d(this,"getCatalog");d(this,"getImage");d(this,"getOptions");d(this,"getValue");d(this,"getHTML");d(this,"getText");d(this,"getWordCount");d(this,"getRangeText");d(this,"getRangeContext");d(this,"getRangeRow");d(this,"getRangeParagraph");d(this,"getPaperMargin");d(this,"getSearchNavigateInfo");d(this,"getLocale");d(this,"getGroupIds");d(this,"getControlValue");d(this,"getContainer");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.executeForceUpdate=t.forceUpdate.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.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.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.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.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.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.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.getImage=t.getImage.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.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.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.executeSetControlValue=t.setControlValue.bind(t),this.getControlValue=t.getControlValue.bind(t)}}const te={data:"",color:"#AEB5C0",opacity:.3,size:200,font:"Yahei"};M.VerticalAlign=void 0,function(R){R.TOP="top",R.MIDDLE="middle",R.BOTTOM="bottom"}(M.VerticalAlign||(M.VerticalAlign={}));function wn(R,t,e){const i=document.createElement("iframe");i.style.visibility="hidden",i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.width="0",i.style.height="0",i.style.border="none",document.body.append(i);const n=i.contentWindow,s=n.document;s.open();const o=document.createElement("div");R.forEach(l=>{const u=document.createElement("img");u.style.width=`${t}px`,u.style.height=`${e}px`,u.src=l,o.append(u)});const r=document.createElement("style"),a="*{margin:0;padding:0;}";r.append(document.createTextNode(a)),setTimeout(()=>{s.write(`${r.outerHTML}${o.innerHTML}`),n.print(),s.close(),window.addEventListener("mouseover",()=>{i==null||i.remove()},{once:!0})})}class Jn{constructor(t){d(this,"draw");d(this,"range");d(this,"position");d(this,"historyManager");d(this,"canvasEvent");d(this,"tableTool");d(this,"options");d(this,"control");d(this,"workerManager");d(this,"searchManager");d(this,"i18n");this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.canvasEvent=t.getCanvasEvent(),this.tableTool=t.getTableTool(),this.options=t.getOptions(),this.control=t.getControl(),this.workerManager=t.getWorkerManager(),this.searchManager=t.getSearch(),this.i18n=t.getI18n()}mode(t){this.draw.setMode(t)}cut(){this.draw.isReadonly()||this.canvasEvent.cut()}copy(){this.canvasEvent.copy()}async paste(){if(this.draw.isReadonly())return;const e=await navigator.clipboard.readText();e&&this.canvasEvent.input(e)}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly())return;const e=this.draw.getElementList(),{startIndex:i,endIndex:n}=this.range.getRange(),s=i===n;if(s&&e[i].value===C&&i===0)return;s?this.draw.spliceElementList(e,i,1):this.draw.spliceElementList(e,i+1,n-i);const o=s?i-1:i;this.range.setRange(o,o),this.draw.render({curIndex:o})}setRange(t,e){if(t<0||e<0||e<t)return;this.range.setRange(t,e);const i=t===e;this.draw.render({curIndex:i?t:void 0,isCompute:!1,isSubmitHistory:!1,isSetCursor:i})}forceUpdate(t){const{isSubmitHistory:e=!1}=t||{};this.range.clearRange(),this.draw.render({isSubmitHistory:e,isSetCursor:!1})}undo(){this.draw.isReadonly()||this.historyManager.undo()}redo(){this.draw.isReadonly()||this.historyManager.redo()}painter(t){if(this.draw.isReadonly())return;const i=this.range.getSelection();if(!i)return;const n={};i.forEach(s=>{mt.forEach(r=>{const a=r;n[a]===void 0&&(n[a]=s[a])})}),this.draw.setPainterStyle(n,t)}applyPainterStyle(){this.canvasEvent.applyPainterStyle()}format(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();!e||(e.forEach(i=>{i.font="",i.color="",i.bold=!1,i.italic=!1,i.underline=!1,i.strikeout=!1}),this.draw.render({isSetCursor:!1}))}font(t){if(this.draw.isReadonly())return;const i=this.range.getSelectionElementList();!i||(i.forEach(n=>{n.font=t}),this.draw.render({isSetCursor:!1}))}size(t){const{minSize:e,maxSize:i,defaultSize:n}=this.options;if(t<e||t>i||this.draw.isReadonly())return;const o=this.range.getTextLikeSelectionElementList();if(!o||!o.length)return;let r=!1;o.forEach(a=>{!a.size&&t===n||a.size&&a.size===t||(a.size=t,r=!0)}),r&&this.draw.render({isSetCursor:!1})}sizeAdd(){if(this.draw.isReadonly())return;const e=this.range.getTextLikeSelectionElementList();if(!e||!e.length)return;const{defaultSize:i,maxSize:n}=this.options;let s=!1;e.forEach(o=>{o.size||(o.size=i),!(o.size>=n)&&(o.size+2>n?o.size=n:o.size+=2,s=!0)}),s&&this.draw.render({isSetCursor:!1})}sizeMinus(){if(this.draw.isReadonly())return;const e=this.range.getTextLikeSelectionElementList();if(!e||!e.length)return;const{defaultSize:i,minSize:n}=this.options;let s=!1;e.forEach(o=>{o.size||(o.size=i),!(o.size<=n)&&(o.size-2<n?o.size=n:o.size-=2,s=!0)}),s&&this.draw.render({isSetCursor:!1})}bold(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();if(!e)return;const i=e.findIndex(n=>!n.bold);e.forEach(n=>{n.bold=!!~i}),this.draw.render({isSetCursor:!1})}italic(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();if(!e)return;const i=e.findIndex(n=>!n.italic);e.forEach(n=>{n.italic=!!~i}),this.draw.render({isSetCursor:!1})}underline(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();if(!e)return;const i=e.findIndex(n=>!n.underline);e.forEach(n=>{n.underline=!!~i}),this.draw.render({isSetCursor:!1,isCompute:!1})}strikeout(){if(this.draw.isReadonly())return;const e=this.range.getSelectionElementList();if(!e)return;const i=e.findIndex(n=>!n.strikeout);e.forEach(n=>{n.strikeout=!!~i}),this.draw.render({isSetCursor:!1,isCompute:!1})}superscript(){if(this.draw.isReadonly()||this.control.getActiveControl())return;const i=this.range.getSelectionElementList();if(!i)return;const n=i.findIndex(s=>s.type===M.ElementType.SUPERSCRIPT);i.forEach(s=>{~n?s.type===M.ElementType.SUPERSCRIPT&&(s.type=M.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===M.ElementType.TEXT||s.type===M.ElementType.SUBSCRIPT)&&(s.type=M.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(){if(this.draw.isReadonly()||this.control.getActiveControl())return;const i=this.range.getSelectionElementList();if(!i)return;const n=i.findIndex(s=>s.type===M.ElementType.SUBSCRIPT);i.forEach(s=>{~n?s.type===M.ElementType.SUBSCRIPT&&(s.type=M.ElementType.TEXT,delete s.actualSize):(!s.type||s.type===M.ElementType.TEXT||s.type===M.ElementType.SUPERSCRIPT)&&(s.type=M.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t){if(this.draw.isReadonly())return;const i=this.range.getSelectionElementList();!i||(i.forEach(n=>{n.color=t}),this.draw.render({isSetCursor:!1,isCompute:!1}))}highlight(t){if(this.draw.isReadonly())return;const i=this.range.getSelectionElementList();!i||(i.forEach(n=>{n.highlight=t}),this.draw.render({isSetCursor:!1,isCompute:!1}))}title(t){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;const s=this.draw.getElementList(),o=i===n?this.range.getRangeParagraphElementList():s.slice(i+1,n+1);if(!o||!o.length)return;const r=x(),a=this.draw.getOptions().title;o.forEach(c=>{!c.type&&c.value===C||(t?(c.level=t,c.titleId=r,We(c)&&(c.size=a[ge[t]],c.bold=!0)):c.titleId&&(delete c.titleId,delete c.level,delete c.size,delete c.bold))});const l=i===n,u=l?n:i;this.draw.render({curIndex:u,isSetCursor:l})}list(t,e){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:s}=this.range.getRange();if(!~n&&!~s)return;const o=this.range.getRangeParagraphElementList();if(!o||!o.length)return;const r=o.find(c=>c.listType===t&&c.listStyle===e),a=x();o.forEach(c=>{!r&&t?(c.listId=a,c.listType=t,c.listStyle=e):c.listId&&(delete c.listId,delete c.listType,delete c.listStyle)});const l=n===s,u=l?s:n;this.draw.render({curIndex:u,isSetCursor:l})}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;const s=this.range.getRangeRowElementList();if(!s)return;s.forEach(a=>{a.rowFlex=t});const o=i===n,r=o?n:i;this.draw.render({curIndex:r,isSetCursor:o})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return;const s=this.range.getRangeRowElementList();if(!s)return;s.forEach(a=>{a.rowMargin=t});const o=i===n,r=o?n:i;this.draw.render({curIndex:r,isSetCursor:o})}insertTable(t,e){var N;if(this.draw.isReadonly()||this.control.getActiveControl())return;const{startIndex:s,endIndex:o}=this.range.getRange();if(!~s&&!~o)return;const r=this.draw.getElementList();let a=0;if((N=r[s])==null?void 0:N.listId){const X=this.position.getPositionList(),{rowIndex:L}=X[s],Y=this.draw.getRowList()[L];a=(Y==null?void 0:Y.offsetX)||0}const l=this.draw.getOriginalInnerWidth()-a,u=[],c=l/e;for(let X=0;X<e;X++)u.push({width:c});const h=[];for(let X=0;X<t;X++){const L=[],g={height:this.options.defaultTrMinHeight,tdList:L};for(let Y=0;Y<e;Y++)L.push({colspan:1,rowspan:1,value:[{value:C,size:16}]});h.push(g)}const O={type:M.ElementType.TABLE,value:"",colgroup:u,trList:h};at([O],{editorOptions:this.options}),tt(r,[O],s);const P=s+1;this.draw.spliceElementList(r,P,s===o?0:o-s,O),this.range.setRange(P,P),this.draw.render({curIndex:P,isSetCursor:!1})}insertTableTopRow(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,trIndex:n,tableId:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=a[n];if(l.tdList.length<r.colgroup.length){const h=l.tdList[0].rowIndex;for(let O=0;O<n;O++){const P=a[O];for(let N=0;N<P.tdList.length;N++){const X=P.tdList[N];X.rowspan>1&&X.rowIndex+X.rowspan>=h+1&&(X.rowspan+=1)}}}const u=x(),c={height:l.height,id:u,tdList:[]};for(let h=0;h<l.tdList.length;h++){const O=l.tdList[h],P=x();c.tdList.push({id:P,rowspan:1,colspan:O.colspan,value:[{value:C,size:16,tableId:s,trId:u,tdId:P}]})}a.splice(n,0,c),this.position.setPositionContext({isTable:!0,index:i,trIndex:n,tdIndex:0,tdId:c.tdList[0].id,trId:c.id,tableId:s}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableBottomRow(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,trIndex:n,tableId:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=a[n],u=a.length-1===n?l:a[n+1];if(u.tdList.length<r.colgroup.length){const O=u.tdList[0].rowIndex;for(let P=0;P<n+1;P++){const N=a[P];for(let X=0;X<N.tdList.length;X++){const L=N.tdList[X];L.rowspan>1&&L.rowIndex+L.rowspan>=O+1&&(L.rowspan+=1)}}}const c=x(),h={height:u.height,id:c,tdList:[]};for(let O=0;O<u.tdList.length;O++){const P=u.tdList[O],N=x();h.tdList.push({id:N,rowspan:1,colspan:P.colspan,value:[{value:C,size:16,tableId:s,trId:c,tdId:N}]})}a.splice(n+1,0,h),this.position.setPositionContext({isTable:!0,index:i,trIndex:n+1,tdIndex:0,tdId:h.tdList[0].id,trId:h.id,tableId:s}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableLeftCol(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,tdIndex:n,tableId:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=n;for(let O=0;O<a.length;O++){const P=a[O],N=x();P.tdList.splice(l,0,{id:N,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:s,trId:P.id,tdId:N}]})}const u=r.colgroup;u.splice(l,0,{width:this.options.defaultColMinWidth});const c=u.reduce((O,P)=>O+P.width,0),h=this.draw.getOriginalInnerWidth();if(c>h){const O=(c-h)/u.length;for(let P=0;P<u.length;P++){const N=u[P];N.width-=O}}this.position.setPositionContext({isTable:!0,index:i,trIndex:0,tdIndex:l,tdId:a[0].tdList[l].id,trId:a[0].id,tableId:s}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableRightCol(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,tdIndex:n,tableId:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=n+1;for(let O=0;O<a.length;O++){const P=a[O],N=x();P.tdList.splice(l,0,{id:N,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:s,trId:P.id,tdId:N}]})}const u=r.colgroup;u.splice(l,0,{width:this.options.defaultColMinWidth});const c=u.reduce((O,P)=>O+P.width,0),h=this.draw.getOriginalInnerWidth();if(c>h){const O=(c-h)/u.length;for(let P=0;P<u.length;P++){const N=u[P];N.width-=O}}this.position.setPositionContext({isTable:!0,index:i,trIndex:0,tdIndex:l,tdId:a[0].tdList[l].id,trId:a[0].id,tableId:s}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}deleteTableRow(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,trIndex:n}=e,o=this.draw.getOriginalElementList()[i],r=o.trList,a=r[n];if(r.length<=1){this.deleteTable();return}for(let l=0;l<a.tdList.length;l++){const u=a.tdList[l];if(u.rowspan>1){let c=n+1;for(;c<n+u.rowspan;){const h=x(),O=r[c];O.tdList.splice(l,0,{id:h,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:o.id,trId:O.id,tdId:h}]}),c+=1}}}r.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:e.index}),this.tableTool.dispose()}deleteTableCol(){var h;if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,tdIndex:n,trIndex:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,u=a[s].tdList[n].colIndex;if(!a.find(O=>O.tdList.length>1)){this.deleteTable();return}for(let O=0;O<a.length;O++){const P=a[O];for(let N=0;N<P.tdList.length;N++){const X=P.tdList[N];if(X.colspan>1){const L=X.colIndex;L<=u&&L+X.colspan-1>=u&&(X.colspan-=1)}}}for(let O=0;O<a.length;O++){const P=a[O];let N=-1;for(let X=0;X<P.tdList.length;X++)P.tdList[X].colIndex===u&&(N=X);~N&&P.tdList.splice(N,1)}(h=r.colgroup)==null||h.splice(u,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:e.index}),this.tableTool.dispose()}deleteTable(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;this.draw.getOriginalElementList().splice(e.index,1);const n=e.index-1;this.position.setPositionContext({isTable:!1,index:n}),this.range.setRange(n,n),this.draw.render({curIndex:n}),this.tableTool.dispose()}mergeTableCell(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{isCrossRowCol:i,startTdIndex:n,endTdIndex:s,startTrIndex:o,endTrIndex:r}=this.range.getRange();if(!i)return;const{index:a}=e,c=this.draw.getOriginalElementList()[a].trList;let h=c[o].tdList[n],O=c[r].tdList[s];(h.x>O.x||h.y>O.y)&&([h,O]=[O,h]);const P=h.colIndex,N=O.colIndex+(O.colspan-1),X=h.rowIndex,L=O.rowIndex+(O.rowspan-1),g=[];for(let Q=0;Q<c.length;Q++){const D=c[Q],K=[];for(let G=0;G<D.tdList.length;G++){const y=D.tdList[G],p=y.colIndex,b=y.rowIndex;p>=P&&p<=N&&b>=X&&b<=L&&K.push(y)}K.length&&g.push(K)}if(!g.length)return;const Y=g[g.length-1],V=g[0][0],T=Y[Y.length-1],W=V.x,F=V.y,Z=T.x+T.width,S=T.y+T.height;for(let Q=0;Q<g.length;Q++){const D=g[Q];for(let K=0;K<D.length;K++){const G=D[K],y=G.x,p=G.y,b=y+G.width,w=p+G.height;if(W>y||F>p||Z<b||S<w)return}}const m=[],I=g[0][0];for(let Q=0;Q<g.length;Q++){const D=g[Q];for(let K=0;K<D.length;K++){const G=D[K];Q===0&&K===0||m.push(G.id),Q===0&&K!==0&&(I.colspan+=G.colspan),Q!==0&&I.colIndex===G.colIndex&&(I.rowspan+=G.rowspan)}}for(let Q=0;Q<c.length;Q++){const D=c[Q];let K=0;for(;K<D.tdList.length;){const G=D.tdList[K];m.includes(G.id)&&(D.tdList.splice(K,1),K--),K++}}const U=h.value.length-1;this.range.setRange(U,U),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){if(this.draw.isReadonly())return;const e=this.position.getPositionContext();if(!e.isTable)return;const{index:i,tdIndex:n,trIndex:s}=e,r=this.draw.getOriginalElementList()[i],a=r.trList,l=a[s],u=l.tdList[n];if(u.rowspan===1&&u.colspan===1)return;const c=u.colspan;if(u.colspan>1){for(let O=1;O<u.colspan;O++){const P=x();l.tdList.splice(n+O,0,{id:P,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:r.id,trId:l.id,tdId:P}]})}u.colspan=1}if(u.rowspan>1){for(let O=1;O<u.rowspan;O++){const P=a[s+O];for(let N=0;N<c;N++){const X=x();P.tdList.splice(u.colIndex,0,{id:X,rowspan:1,colspan:1,value:[{value:C,size:16,tableId:r.id,trId:P.id,tdId:X}]})}}u.rowspan=1}const h=u.value.length-1;this.range.setRange(h,h),this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){if(this.draw.isReadonly())return;const i=this.draw.getTableParticle().getRangeRowCol();if(!i)return;for(let s=0;s<i.length;s++){const o=i[s];for(let r=0;r<o.length;r++){const a=o[r];!a||a.verticalAlign===t||!a.verticalAlign&&t===M.VerticalAlign.TOP||(a.verticalAlign=t)}}const{endIndex:n}=this.range.getRange();this.draw.render({curIndex:n})}tableBorderType(t){if(this.draw.isReadonly())return;const i=this.position.getPositionContext();if(!i.isTable)return;const{index:n}=i,o=this.draw.getOriginalElementList()[n];if(!o.borderType&&t===M.TableBorder.ALL||o.borderType===t)return;o.borderType=t;const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableTdBorderType(t){if(this.draw.isReadonly())return;const i=this.draw.getTableParticle().getRangeRowCol();if(!i)return;const n=i.flat(),s=n.some(r=>r.borderType!==t);n.forEach(r=>{s?r.borderType=t:delete r.borderType});const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o})}tableTdSlashType(t){if(this.draw.isReadonly())return;const i=this.draw.getTableParticle().getRangeRowCol();if(!i)return;const n=i.flat(),s=n.some(r=>r.slashType!==t);n.forEach(r=>{s?r.slashType=t:delete r.slashType});const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o})}tableTdBackgroundColor(t){if(this.draw.isReadonly())return;const i=this.draw.getTableParticle().getRangeRowCol();if(!i)return;for(let s=0;s<i.length;s++){const o=i[s];for(let r=0;r<o.length;r++){const a=o[r];a.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:i,isTable:n}=t;if(!n||!i)return;const{startIndex:s,endIndex:o}=this.range.getRange(),a=this.draw.getOriginalElementList()[e].trList,l=a.length-1,u=a[l].tdList.length-1;this.range.replaceRange({startIndex:s,endIndex:o,tableId:i,startTdIndex:0,endTdIndex:u,startTrIndex:0,endTrIndex:l}),this.draw.render({isCompute:!1,isSubmitHistory:!1})}hyperlink(t){if(this.draw.isReadonly()||this.control.getActiveControl())return;const{startIndex:n,endIndex:s}=this.range.getRange();if(!~n&&!~s)return;const o=this.draw.getElementList(),{valueList:r,url:a}=t,l=x(),u=r==null?void 0:r.map(O=>({url:a,hyperlinkId:l,value:O.value,type:M.ElementType.HYPERLINK}));if(!u)return;const c=n+1;tt(o,u,n),this.draw.spliceElementList(o,c,n===s?0:s-n,...u);const h=c+u.length-1;this.range.setRange(h,h),this.draw.render({curIndex:h})}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:i,endIndex:n}=this.range.getRange();if(!~i&&!~n)return null;const s=this.draw.getElementList(),o=s[i];if(o.type!==M.ElementType.HYPERLINK)return null;let r=i;for(;r>0;){if(s[r].hyperlinkId!==o.hyperlinkId){t=r+1;break}r--}let a=i+1;for(;a<s.length;){if(s[a].hyperlinkId!==o.hyperlinkId){e=a-1;break}a++}return a===s.length&&(e=a-1),!~t||!~e?null:[t,e]}deleteHyperlink(){const t=this.getHyperlinkRange();if(!t)return;const e=this.draw.getElementList(),[i,n]=t;this.draw.spliceElementList(e,i,n-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const s=i-1;this.range.setRange(s,s),this.draw.render({curIndex:s})}cancelHyperlink(){const t=this.getHyperlinkRange();if(!t)return;const e=this.draw.getElementList(),[i,n]=t;for(let o=i;o<=n;o++){const r=e[o];delete r.type,delete r.url,delete r.hyperlinkId,delete r.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:s}=this.range.getRange();this.draw.render({curIndex:s,isCompute:!1})}editHyperlink(t){const e=this.getHyperlinkRange();if(!e)return;const i=this.draw.getElementList(),[n,s]=e;for(let r=n;r<=s;r++){const a=i[r];a.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:o}=this.range.getRange();this.draw.render({curIndex:o,isCompute:!1})}separator(t){if(this.draw.isReadonly()||this.control.getActiveControl())return;const{startIndex:n,endIndex:s}=this.range.getRange();if(!~n&&!~s)return;const o=this.draw.getElementList();let r=-1;const a=o[s+1];if(a&&a.type===M.ElementType.SEPARATOR){if(a.dashArray&&a.dashArray.join()===t.join())return;r=s,a.dashArray=t}else{const l={value:ne,type:M.ElementType.SEPARATOR,dashArray:t};tt(o,[l],n),n!==0&&o[n].value===C?(this.draw.spliceElementList(o,n,1,l),r=n-1):(this.draw.spliceElementList(o,n+1,0,l),r=n)}this.range.setRange(r,r),this.draw.render({curIndex:r})}pageBreak(){this.draw.isReadonly()||this.control.getActiveControl()||this.insertElementList([{type:M.ElementType.PAGE_BREAK,value:ne}])}addWatermark(t){if(this.draw.isReadonly())return;const i=this.draw.getOptions(),{color:n,size:s,opacity:o,font:r}=te;i.watermark.data=t.data,i.watermark.color=t.color||n,i.watermark.size=t.size||s,i.watermark.opacity=t.opacity||o,i.watermark.font=t.font||r,this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1})}deleteWatermark(){if(this.draw.isReadonly())return;const e=this.draw.getOptions();e.watermark&&e.watermark.data&&(e.watermark=H({},te),this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.control.getActiveControl())return;const{startIndex:n,endIndex:s}=this.range.getRange();if(!~n&&!~s)return;const o=this.draw.getElementList(),{value:r,width:a,height:l}=t,u={value:r,width:a,height:l,id:x(),type:M.ElementType.IMAGE},c=n+1;tt(o,[u],n),this.draw.spliceElementList(o,c,n===s?0:s-n,u),this.range.setRange(c,c),this.draw.render({curIndex:c})}search(t){this.searchManager.setSearchKeyword(t),this.draw.render({isSetCursor:!1,isSubmitHistory:!1})}searchNavigatePre(){this.searchManager.searchNavigatePre()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}searchNavigateNext(){this.searchManager.searchNavigateNext()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}getSearchNavigateInfo(){return this.searchManager.getSearchNavigateInfo()}replace(t){if(this.draw.isReadonly()||!t||new RegExp(`${C}`,"g").test(t))return;const i=this.draw.getSearch().getSearchMatchList();if(!i.length)return;let n=0,s=0,o="",r="",a=-1;const l=this.draw.getOriginalElementList();for(let h=0;h<i.length;h++){const O=i[h];if(O.type===Xt.TABLE){const{tableIndex:P,trIndex:N,tdIndex:X,index:L,tdId:g}=O;r&&g!==r&&(s=0),r=g;const Y=P+n,V=l[Y].trList[N].tdList[X].value,T=L+s,W=V[T];if(o===O.groupId){this.draw.spliceElementList(V,T,1),s--;continue}for(let F=0;F<t.length;F++){const Z=t[F];F===0?W.value=Z:(this.draw.spliceElementList(V,T+F,0,$(H({},W),{value:Z})),s++)}}else{const P=O.index+n,N=l[P];if(N.type===M.ElementType.CONTROL&&N.controlComponent!==f.VALUE)continue;if(~a||(a=h),o===O.groupId){this.draw.spliceElementList(l,P,1),n--;continue}for(let X=0;X<t.length;X++){const L=t[X];X===0?N.value=L:(this.draw.spliceElementList(l,P+X,0,$(H({},N),{value:L})),n++)}}o=O.groupId}if(!~a)return;const u=i[a],c=u.index+(t.length-1);if(u.type===Xt.TABLE){const{tableIndex:h,trIndex:O,tdIndex:P,index:N}=u,X=l[h].trList[O].tdList[P].value[N];this.position.setPositionContext({isTable:!0,index:h,trIndex:O,tdIndex:P,tdId:X.tdId,trId:X.trId,tableId:X.tableId})}else this.position.setPositionContext({isTable:!1});this.range.setRange(c,c),this.draw.render({curIndex:c})}async print(){const{scale:t,printPixelRatio:e}=this.options;t!==1&&this.draw.setPageScale(1);const i=this.draw.getOriginalWidth(),n=this.draw.getOriginalHeight(),s=await this.draw.getDataURL({pixelRatio:e,mode:M.EditorMode.PRINT});wn(s,i,n),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),n=this.draw.getElementList()[e];!n||n.type!==M.ElementType.IMAGE||(n.id=x(),n.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),i=this.draw.getElementList()[t];!i||i.type!==M.ElementType.IMAGE||le(i.value,`${i.id}.png`)}changeImageDisplay(t,e){t.imgDisplay!==e&&(t.imgDisplay=e,this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!1}))}getImage(t){return this.draw.getDataURL(t)}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),i=this.draw.getOriginalMainElementList(),n=this.draw.getFooterElementList();return{header:Et(e,t).innerHTML,main:Et(i,t).innerHTML,footer:Et(n,t).innerHTML}}getText(){const t=this.draw.getHeaderElementList(),e=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:At(t),main:At(e),footer:At(i)}}getWordCount(){return this.workerManager.getWordCount()}getRangeText(){return this.range.toString()}getRangeContext(){const t=this.range.getRange(),{startIndex:e,endIndex:i}=t;if(!~e&&!~i)return null;const n=e===i,s=this.draw.getElementList(),o=Ut(s[n?e:e+1]),r=Ut(s[i]),a=this.position.getPositionList(),l=a[e].pageNo,u=a[i].pageNo,c=[],h=this.position.getSelectionPositionList();if(h){const O=this.draw.getOriginalHeight(),P=this.draw.getOriginalPageGap();let N=null,X=0,L=null;for(let g=0;g<h.length;g++){const{rowNo:Y,pageNo:V,coordinate:{leftTop:T,rightTop:W},lineHeight:F}=h[g];N===null||N!==Y?(L&&c.push(L),L={x:T[0],y:T[1]+V*(O+P),width:W[0]-T[0],height:F},N=Y,X=T[0]):L.width=W[0]-X,g===h.length-1&&L&&c.push(L)}}return j({isCollapsed:n,startElement:o,endElement:r,startPageNo:l,endPageNo:u,rangeRects:c})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?k(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?k(t):null}pageMode(t){this.draw.setPageMode(t)}pageScaleRecovery(){const{scale:t}=this.options;t!==1&&this.draw.setPageScale(1)}pageScaleMinus(){const{scale:t}=this.options,e=t*10-1;e>=5&&this.draw.setPageScale(e/10)}pageScaleAdd(){const{scale:t}=this.options,e=t*10+1;e<=30&&this.draw.setPageScale(e/10)}paperSize(t,e){this.draw.setPaperSize(t,e)}paperDirection(t){this.draw.setPaperDirection(t)}getPaperMargin(){return this.options.margins}setPaperMargin(t){return this.draw.setPaperMargin(t)}insertElementList(t){if(!t.length||this.draw.isReadonly())return;const{startIndex:i}=this.range.getRange(),n=this.draw.getElementList();tt(n,t,i),this.draw.insertElementList(t)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(t,e)}setValue(t){this.draw.setValue(t)}removeControl(){const{startIndex:t,endIndex:e}=this.range.getRange();if(t!==e||this.draw.getElementList()[t].type!==M.ElementType.CONTROL)return;const o=this.draw.getControl().removeControl(t);this.range.setRange(o,o),this.draw.render({curIndex:o})}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){var n;const e=this.draw.getMainElementList();let i=-1;for(let s=0;s<e.length;s++)if(e[s].titleId===t&&((n=e[s+1])==null?void 0:n.titleId)!==t){i=s;break}!~i||(this.range.setRange(i,i),this.draw.render({curIndex:i,isCompute:!1,isSubmitHistory:!1}))}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let i=0;i<t.length;i++)if(t[i].value===C)for(;i+1<t.length;){const s=t[i+1];if(s.value!==C&&s.value!==ve)break;t.splice(i+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const i=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:i})}}setHTML(t){const{header:e,main:i,footer:n}=t,s=this.draw.getOriginalInnerWidth(),o=r=>r!==void 0?Qt(r,{innerWidth:s}):void 0;this.setValue({header:o(e),main:o(i),footer:o(n)})}setGroup(){return this.draw.isReadonly()?null:this.draw.getGroup().setGroup()}deleteGroup(t){this.draw.isReadonly()||this.draw.getGroup().deleteGroup(t)}getGroupIds(){return this.draw.getWorkerManager().getGroupIds()}locationGroup(t){const e=this.draw.getOriginalMainElementList(),i=this.draw.getGroup().getContextByGroupId(e,t);if(!i)return;const{isTable:n,index:s,trIndex:o,tdIndex:r,tdId:a,trId:l,tableId:u,endIndex:c}=i;this.position.setPositionContext({isTable:n,index:s,trIndex:o,tdIndex:r,tdId:a,trId:l,tableId:u}),this.range.setRange(c,c),this.draw.render({curIndex:c,isCompute:!1,isSubmitHistory:!1})}getControlValue(t){return this.draw.getControl().getValueByConceptId(t)}setControlValue(t){this.draw.isReadonly()||this.draw.getControl().setValueByConceptId(t)}getContainer(){return this.draw.getContainer()}}class xn{constructor(){d(this,"rangeStyleChange");d(this,"visiblePageNoListChange");d(this,"intersectionPageNoChange");d(this,"pageSizeChange");d(this,"pageScaleChange");d(this,"saved");d(this,"contentChange");d(this,"controlChange");d(this,"pageModeChange");d(this,"zoneChange");this.rangeStyleChange=null,this.visiblePageNoListChange=null,this.intersectionPageNoChange=null,this.pageSizeChange=null,this.pageScaleChange=null,this.saved=null,this.contentChange=null,this.controlChange=null,this.pageModeChange=null,this.zoneChange=null}}class vn{constructor(t){d(this,"contextMenuList");d(this,"shortcutList");d(this,"langMap");const{contextMenu:e,shortcut:i,i18n:n}=t;this.contextMenuList=e.registerContextMenuList.bind(e),this.shortcutList=i.registerShortcutList.bind(i),this.langMap=n.registerLangMap.bind(n)}}const ye={SELECTED_TEXT:"%s"},Bn=[{i18nPath:"contextmenu.control.delete",when:R=>{var t;return!R.isReadonly&&!R.editorHasSelection&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.CONTROL},callback:R=>{R.executeRemoveControl()}}],An=[{i18nPath:"contextmenu.global.cut",shortCut:`${Nt?"\u2318":"Ctrl"} + X`,when:R=>!R.isReadonly,callback:R=>{R.executeCut()}},{i18nPath:"contextmenu.global.copy",shortCut:`${Nt?"\u2318":"Ctrl"} + C`,when:R=>R.editorHasSelection,callback:R=>{R.executeCopy()}},{i18nPath:"contextmenu.global.paste",shortCut:`${Nt?"\u2318":"Ctrl"} + V`,when:R=>!R.isReadonly&&R.editorTextFocus,callback:R=>{R.executePaste()}},{i18nPath:"contextmenu.global.selectAll",shortCut:`${Nt?"\u2318":"Ctrl"} + A`,when:R=>R.editorTextFocus,callback:R=>{R.executeSelectAll()}},{isDivider:!0},{i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:R=>{R.executePrint()}}],_n=[{i18nPath:"contextmenu.hyperlink.delete",when:R=>{var t;return!R.isReadonly&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.HYPERLINK},callback:R=>{R.executeDeleteHyperlink()}},{i18nPath:"contextmenu.hyperlink.cancel",when:R=>{var t;return!R.isReadonly&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.HYPERLINK},callback:R=>{R.executeCancelHyperlink()}},{i18nPath:"contextmenu.hyperlink.edit",when:R=>{var t;return!R.isReadonly&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.HYPERLINK},callback:(R,t)=>{var i;const e=window.prompt("\u7F16\u8F91\u94FE\u63A5",(i=t.startElement)==null?void 0:i.url);e&&R.executeEditHyperlink(e)}}],kn=[{i18nPath:"contextmenu.image.change",icon:"image-change",when:R=>{var t;return!R.isReadonly&&!R.editorHasSelection&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.IMAGE},callback:R=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],i=new FileReader;i.readAsDataURL(e),i.onload=()=>{const n=i.result;R.executeReplaceImageElement(n)}},t.click()}},{i18nPath:"contextmenu.image.saveAs",icon:"image",when:R=>{var t;return!R.editorHasSelection&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.IMAGE},callback:R=>{R.executeSaveAsImageElement()}},{i18nPath:"contextmenu.image.textWrap",when:R=>{var t;return!R.isReadonly&&!R.editorHasSelection&&((t=R.startElement)==null?void 0:t.type)===M.ElementType.IMAGE},childMenus:[{i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(R,t)=>{R.executeChangeImageDisplay(t.startElement,M.ImageDisplay.BLOCK)}},{i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(R,t)=>{R.executeChangeImageDisplay(t.startElement,M.ImageDisplay.INLINE)}}]}],zn=[{isDivider:!0},{i18nPath:"contextmenu.table.border",icon:"border-all",when:R=>!R.isReadonly&&R.isInTable,childMenus:[{i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:R=>{R.executeTableBorderType(M.TableBorder.ALL)}},{i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:R=>{R.executeTableBorderType(M.TableBorder.EMPTY)}},{i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:R=>{R.executeTableBorderType(M.TableBorder.EXTERNAL)}},{i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:R=>{R.executeTableTdBorderType(M.TdBorder.BOTTOM)}},{i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:R=>{R.executeTableTdSlashType(M.TdSlash.FORWARD)}},{i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:R=>{R.executeTableTdSlashType(M.TdSlash.BACK)}}]}]},{i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:R=>!R.isReadonly&&R.isInTable,childMenus:[{i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:R=>{R.executeTableTdVerticalAlign(M.VerticalAlign.TOP)}},{i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:R=>{R.executeTableTdVerticalAlign(M.VerticalAlign.MIDDLE)}},{i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:R=>{R.executeTableTdVerticalAlign(M.VerticalAlign.BOTTOM)}}]},{i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:R=>!R.isReadonly&&R.isInTable,childMenus:[{i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:R=>{R.executeInsertTableTopRow()}},{i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:R=>{R.executeInsertTableBottomRow()}},{i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:R=>{R.executeInsertTableLeftCol()}},{i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:R=>{R.executeInsertTableRightCol()}}]},{i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:R=>!R.isReadonly&&R.isInTable,childMenus:[{i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:R=>{R.executeDeleteTableRow()}},{i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:R=>{R.executeDeleteTableCol()}},{i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:R=>{R.executeDeleteTable()}}]},{i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:R=>!R.isReadonly&&R.isCrossRowCol,callback:R=>{R.executeMergeTableCell()}},{i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:R=>!R.isReadonly&&R.isInTable,callback:R=>{R.executeCancelMergeTableCell()}}];class $n{constructor(t,e){d(this,"draw");d(this,"command");d(this,"range");d(this,"position");d(this,"i18n");d(this,"container");d(this,"contextMenuList");d(this,"contextMenuContainerList");d(this,"contextMenuRelationShip");d(this,"context");d(this,"_proxyContextMenuEvent",t=>{var n;this.context=this._getContext();const e=[];let i=!1;for(let s=0;s<this.contextMenuList.length;s++){const o=this.contextMenuList[s];o.isDivider?e.push(o):((n=o.when)==null?void 0:n.call(o,this.context))&&(e.push(o),i=!0)}i&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()});d(this,"_handleSideEffect",t=>{if(this.contextMenuContainerList.length){const e=(t==null?void 0:t.composedPath()[0])||t.target;ft(e,n=>!!n&&n.nodeType===1&&n.getAttribute(gt)===M.EditorComponent.CONTEXTMENU,!0)||this.dispose()}});this.draw=t,this.command=e,this.range=t.getRange(),this.position=t.getPosition(),this.i18n=t.getI18n(),this.container=t.getContainer(),this.context=null,this.contextMenuList=[...An,...zn,...kn,...Bn,..._n],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_getContext(){const t=this.draw.isReadonly(),{isCrossRowCol:e,startIndex:i,endIndex:n}=this.range.getRange(),s=!!(~i||~n),o=s&&i!==n,a=this.position.getPositionContext().isTable,l=a&&!!e,u=this.draw.getElementList(),c=u[i]||null,h=u[n]||null,O=this.draw.getZone().getZone();return{startElement:c,endElement:h,isReadonly:t,editorHasSelection:o,editorTextFocus:s,isInTable:a,isCrossRowCol:l,zone:O}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${E}-contextmenu-container`),t.setAttribute(gt,M.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){const{contextMenuList:e,left:i,top:n,parentMenuContainer:s}=t,o=this._createContextMenuContainer(),r=document.createElement("div");r.classList.add(`${E}-contextmenu-content`);let a=null;s&&this.contextMenuRelationShip.set(s,o);for(let X=0;X<e.length;X++){const L=e[X];if(L.isDivider){if(X!==0&&X!==e.length-1){const g=document.createElement("div");g.classList.add(`${E}-contextmenu-divider`),r.append(g)}}else{const g=document.createElement("div");g.classList.add(`${E}-contextmenu-item`),L.childMenus?(g.classList.add(`${E}-contextmenu-sub-item`),g.onmouseenter=()=>{this._setHoverStatus(g,!0),this._removeSubMenu(o);const W=g.getBoundingClientRect(),F=W.left+W.width,Z=W.top;a=this._render({contextMenuList:L.childMenus,left:F,top:Z,parentMenuContainer:o})},g.onmouseleave=W=>{(!a||!a.contains(W.relatedTarget))&&this._setHoverStatus(g,!1)}):(g.onmouseenter=()=>{this._setHoverStatus(g,!0),this._removeSubMenu(o)},g.onmouseleave=()=>{this._setHoverStatus(g,!1)},g.onclick=()=>{L.callback&&this.context&&L.callback(this.command,this.context),this.dispose()});const Y=document.createElement("i");g.append(Y),L.icon&&Y.classList.add(`${E}-contextmenu-${L.icon}`);const V=document.createElement("span"),T=L.i18nPath?this._formatName(this.i18n.t(L.i18nPath)):this._formatName(L.name||"");if(V.append(document.createTextNode(T)),g.append(V),L.shortCut){const W=document.createElement("span");W.classList.add(`${E}-shortcut`),W.append(document.createTextNode(L.shortCut)),g.append(W)}r.append(g)}}o.append(r),o.style.display="block";const l=window.innerWidth,u=o.getBoundingClientRect(),c=u.width,h=i+c>l?i-c:i;o.style.left=`${h}px`;const O=window.innerHeight,P=u.height,N=n+P>O?n-P:n;return o.style.top=`${N}px`,this.contextMenuContainerList.push(o),o}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){var i;e?((i=t.parentNode)==null||i.querySelectorAll(`${E}-contextmenu-item`).forEach(n=>n.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(ye),i=new RegExp(`${e.join("|")}`);let n=t;if(i.test(n)){const s=new RegExp(ye.SELECTED_TEXT,"g");if(s.test(n)){const o=this.range.toString();n=n.replace(s,o)}}return n}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const jn={top:30,maxHeightRadio:M.MaxHeightRatio.HALF,disabled:!1},qn={placeholderColor:"#9c9b9b",bracketColor:"#000000",prefix:"{",postfix:"}"},tR={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",fontStyle:"#ffffff"},eR=[{key:M.KeyMap.X_UPPERCASE,ctrl:!0,shift:!0,callback:R=>{R.executeStrikeout()}},{key:M.KeyMap.LEFT_BRACKET,mod:!0,callback:R=>{R.executeSizeAdd()}},{key:M.KeyMap.RIGHT_BRACKET,mod:!0,callback:R=>{R.executeSizeMinus()}},{key:M.KeyMap.B,mod:!0,callback:R=>{R.executeBold()}},{key:M.KeyMap.I,mod:!0,callback:R=>{R.executeItalic()}},{key:M.KeyMap.U,mod:!0,callback:R=>{R.executeUnderline()}},{key:Nt?M.KeyMap.COMMA:M.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:R=>{R.executeSuperscript()}},{key:Nt?M.KeyMap.PERIOD:M.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:R=>{R.executeSubscript()}},{key:M.KeyMap.L,mod:!0,callback:R=>{R.executeRowFlex(M.RowFlex.LEFT)}},{key:M.KeyMap.E,mod:!0,callback:R=>{R.executeRowFlex(M.RowFlex.CENTER)}},{key:M.KeyMap.R,mod:!0,callback:R=>{R.executeRowFlex(M.RowFlex.RIGHT)}},{key:M.KeyMap.J,mod:!0,callback:R=>{R.executeRowFlex(M.RowFlex.ALIGNMENT)}}],iR=[{key:M.KeyMap.ZERO,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(null)}},{key:M.KeyMap.ONE,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.FIRST)}},{key:M.KeyMap.TWO,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.SECOND)}},{key:M.KeyMap.THREE,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.THIRD)}},{key:M.KeyMap.FOUR,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.FOURTH)}},{key:M.KeyMap.FIVE,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.FIFTH)}},{key:M.KeyMap.SIX,alt:!0,ctrl:!0,callback:R=>{R.executeTitle(M.TitleLevel.SIXTH)}}],nR=[{key:M.KeyMap.I,shift:!0,mod:!0,callback:R=>{R.executeList(M.ListType.UL,M.ListStyle.DISC)}},{key:M.KeyMap.U,shift:!0,mod:!0,callback:R=>{R.executeList(M.ListType.OL)}}];class RR{constructor(t,e){d(this,"command");d(this,"globalShortcutList");d(this,"agentShortcutList");d(this,"_globalKeydown",t=>{!this.globalShortcutList.length||this._execute(t,this.globalShortcutList)});this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...eR,...iR,...nR]),this._addEvent(),t.getCursor().getAgentDom().addEventListener("keydown",this._agentKeydown.bind(this))}_addEvent(){document.addEventListener("keydown",this._globalKeydown)}removeEvent(){document.removeEventListener("keydown",this._globalKeydown)}_addShortcutList(t){for(let e=t.length-1;e>=0;e--){const i=t[e];i.isGlobal?this.globalShortcutList.unshift(i):this.agentShortcutList.unshift(i)}}registerShortcutList(t){this._addShortcutList(t)}_agentKeydown(t){!this.agentShortcutList.length||this._execute(t,this.agentShortcutList)}_execute(t,e){var i;for(let n=0;n<e.length;n++){const s=e[n];if((s.mod?Ot(t)===!!s.mod:t.ctrlKey===!!s.ctrl&&t.metaKey===!!s.meta)&&t.shiftKey===!!s.shift&&t.altKey===!!s.alt&&t.key===s.key){s.disable||((i=s==null?void 0:s.callback)==null||i.call(s,this.command),t.preventDefault());break}}}}const sR={bottom:30,maxHeightRadio:M.MaxHeightRatio.HALF,disabled:!1},oR={data:"",color:"#DCDFE6",opacity:1,size:16,font:"Yahei"};class rR{constructor(t){d(this,"editor");this.editor=t}use(t,e){t(this.editor,e)}}class lR{constructor(){d(this,"eventHub");this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const i=this.eventHub.get(t)||new Set;i.add(e),this.eventHub.set(t,i)}emit(t,e){if(!t)return;const i=this.eventHub.get(t);if(!!i){if(i.size===1)return[...i][0](e);i.forEach(n=>n(e))}}off(t,e){if(!t||typeof e!="function")return;const i=this.eventHub.get(t);!i||i.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}}const aR={opacity:.1,backgroundColor:"#E99D00",activeOpacity:.5,activeBackgroundColor:"#E99D00",disabled:!1};class cR{constructor(){d(this,"paste")}}const uR={font:"Yahei",fontSize:12,lineDash:[3,1]};class Ce{constructor(t,e,i={}){d(this,"command");d(this,"listener");d(this,"eventBus");d(this,"override");d(this,"register");d(this,"destroy");d(this,"use");const n=H(H({},jn),i.header),s=H(H({},sR),i.footer),o=H(H({},rn),i.pageNumber),r=H(H({},te),i.watermark),a=H(H({},qn),i.control),l=H(H({},tR),i.checkbox),u=H(H({},ii),i.cursor),c=H(H({},Fi),i.title),h=H(H({},oR),i.placeholder),O=H(H({},aR),i.group),P=H(H({},uR),i.pageBreak),N=$(H({mode:M.EditorMode.EDIT,defaultType:"TEXT",defaultFont:"Yahei",defaultSize:16,minSize:5,maxSize:72,defaultRowMargin:1,defaultBasicRowMarginHeight:8,defaultTabWidth:32,width:794,height:1123,scale:1,pageGap:20,backgroundColor:"#FFFFFF",underlineColor:"#000000",strikeoutColor:"#FF0000",rangeAlpha:.6,rangeColor:"#AECBFA",rangeMinWidth:5,searchMatchAlpha:.6,searchMatchColor:"#FFFF00",searchNavigateMatchColor:"#AAD280",highlightAlpha:.6,resizerColor:"#4182D9",resizerSize:5,marginIndicatorSize:35,marginIndicatorColor:"#BABABA",margins:[100,120,100,120],pageMode:M.PageMode.PAGING,tdPadding:[0,5,5,5],defaultTrMinHeight:42,defaultColMinWidth:40,defaultHyperlinkColor:"#0000FF",paperDirection:M.PaperDirection.VERTICAL,inactiveAlpha:.6,historyMaxRecordCount:100,wordBreak:M.WordBreak.BREAK_WORD,printPixelRatio:3,maskMargin:[0,0,0,0],letterClass:[oe.ENGLISH]},i),{header:n,footer:s,pageNumber:o,watermark:r,control:a,checkbox:l,cursor:u,title:c,placeholder:h,group:O,pageBreak:P});let X=[],L=[],g=[];Array.isArray(e)?L=e:(X=e.header||[],L=e.main,g=e.footer||[]),[X,L,g].forEach(Z=>{at(Z,{editorOptions:N})}),this.listener=new xn,this.eventBus=new lR,this.override=new cR;const V=new Cn(t,N,{header:X,main:L,footer:g},this.listener,this.eventBus,this.override);this.command=new be(new Jn(V));const T=new $n(V,this.command),W=new RR(V,this.command);this.register=new vn({contextMenu:T,shortcut:W,i18n:V.getI18n()}),this.destroy=()=>{V.destroy(),W.removeEvent(),T.removeEvent()};const F=new rR(this);this.use=F.use.bind(F)}}M.Command=be,M.EDITOR_COMPONENT=gt,M.Editor=Ce,M.LETTER_CLASS=oe,M.default=Ce,Object.defineProperty(M,"__esModule",{value:!0}),M[Symbol.toStringTag]="Module"});
|
|
81
81
|
//# sourceMappingURL=canvas-editor.umd.js.map
|