ht-emr 0.7.37 → 0.7.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="canvas-editor-style",e.appendChild(document.createTextNode(`.ce-select-control-popup{max-width:160px;min-width:69px;max-height:225px;position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;overflow-y:auto}.ce-select-control-popup ul{list-style:none;padding:3px 0;margin:0;box-sizing:border-box}.ce-select-control-popup ul li{font-size:13px;padding:0 20px;position:relative;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#666;height:36px;line-height:36px;box-sizing:border-box;cursor:pointer}.ce-select-control-popup ul li:hover{background-color:#eef2fd}.ce-select-control-popup ul li.active{color:var(--COLOR-HOVER, #5175f4);font-weight:700}.ce-calculator{position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;padding:8px;width:200px}.ce-calculator-display{width:100%;height:40px;line-height:40px;text-align:right;padding:0 10px;margin-bottom:8px;border:1px solid #e4e7ed;border-radius:4px;background-color:#f5f7fa;font-size:16px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis}.ce-calculator-buttons{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ce-calculator-button{width:100%;height:36px;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;font-size:14px;cursor:pointer;transition:all .2s;box-sizing:border-box}.ce-calculator-button:hover{background-color:#eef2fd;border-color:#c6d1ff}.ce-calculator-button:active{background-color:#e1e8ff}.ce-calculator-button.operator{background-color:#f5f7fa}.ce-calculator-button.operator:hover{background-color:#eef2fd}.ce-calculator-button.equal{background-color:var(--COLOR-HOVER, #5175f4);color:#fff;border-color:var(--COLOR-HOVER, #5175f4)}.ce-calculator-button.equal:hover{background-color:var(--COLOR-HOVER, #6a84ff);border-color:var(--COLOR-HOVER, #6a84ff)}.ce-calculator-button.utility{background-color:#f0f2f5}.ce-calculator-button.utility:hover{background-color:#e6e8eb}.ce-date-container{display:none;width:300px;overflow:hidden;left:0;right:0;position:absolute;z-index:1;color:#606266;background:#fff;border-radius:4px;padding:10px;-webkit-user-select:none;user-select:none;border:1px solid #e4e7ed;box-shadow:0 2px 12px #0000001a}.ce-date-container.active{display:block}.ce-date-wrap{display:none}.ce-date-wrap.active{display:block}.ce-date-title{display:flex;justify-content:center;align-items:center;text-align:center;color:#606266;font-size:16px}.ce-date-title>span{display:inline-block}.ce-date-title>span:not(.ce-date-title__now){font-family:cursive;cursor:pointer}.ce-date-title>span:not(.ce-date-title__now):hover{color:#5175f4}.ce-date-title .ce-date-title__pre-year,.ce-date-title .ce-date-title__pre-month{width:15%}.ce-date-title .ce-date-title__now{width:40%}.ce-date-title .ce-date-title__next-year,.ce-date-title .ce-date-title__next-month{width:15%}.ce-date-week{width:100%;display:flex;justify-content:center;margin-top:15px;padding-bottom:5px;border-bottom:1px solid #e4e7ed}.ce-date-week>span{list-style:none;width:calc(100%/7);text-align:center;color:#606266;font-size:14px}.ce-date-day{width:100%;display:flex;flex-wrap:wrap;align-items:center;margin-top:5px}.ce-date-day>div{width:calc(100%/7);height:40px;text-align:center;color:#606266;font-size:14px;cursor:pointer;line-height:40px;border-radius:4px}.ce-date-day>div:hover{color:#5175f4;opacity:.8}.ce-date-day>div.active{color:#5175f4;font-weight:700}.ce-date-day>div.disable{color:#c0c4cc}.ce-date-day>div.select{color:#fff;background-color:#5175f4}.ce-time-wrap{display:none;padding:10px;height:286px}.ce-time-wrap ::-webkit-scrollbar{width:0}.ce-time-wrap.active{display:flex}.ce-time-wrap li{list-style:none}.ce-time-wrap>li{width:33.3%;height:100%;text-align:center}.ce-time-wrap>li>span{transform:translateY(-5px);display:inline-block}.ce-time-wrap>li>ol{height:calc(100% - 20px);overflow-y:auto;border:1px solid #e2e2e2;position:relative}.ce-time-wrap>li:first-child>ol{border-right:0}.ce-time-wrap>li:last-child>ol{border-left:0}.ce-time-wrap>li>ol>li{line-height:30px;cursor:pointer;transition:all .3s}.ce-time-wrap>li>ol>li:hover{background-color:#eaeaea}.ce-time-wrap>li>ol>li.active{color:#fff;background:#5175f4}.ce-date-menu{width:100%;height:28px;display:flex;justify-content:flex-end;align-items:center;padding-top:10px;position:relative;border-top:1px solid #e4e7ed}.ce-date-menu button{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#fff;border:1px solid #dcdfe6;color:#606266;appearance:none;text-align:center;box-sizing:border-box;outline:none;transition:.1s;font-weight:500;-webkit-user-select:none;user-select:none;padding:7px 15px;font-size:12px;border-radius:3px;margin:0 0 0 10px}.ce-date-menu button:hover{color:#5175f4;border-color:#5175f4}.ce-date-menu button.ce-date-menu__time{border:1px solid transparent;position:absolute;left:0;margin-left:0}.ce-date-menu button.ce-date-menu__time:hover{color:#5175f4}.ce-block-item{position:absolute;z-index:0;background-color:#fff;border:1px solid rgb(235 236 240)}.ce-block-item .ce-resizer-selection{width:100%;height:100%}.ce-block-item .ce-resizer-mask{position:absolute;inset:0;z-index:1;background-color:transparent}.ce-table-tool__row{position:absolute;width:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed}.ce-table-tool__row .ce-table-tool__row__item{width:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__row .ce-table-tool__row__item:after{content:"";position:absolute;bottom:0;left:2px;width:8px;height:1px;background-color:#c0c6cf}.ce-table-tool__row .ce-table-tool__row__item:hover{background-color:#dadce0}.ce-table-tool__row .ce-table-tool__row__item:last-child:after{display:none}.ce-table-tool__quick__add{width:16px;height:16px;position:absolute;border-radius:50%;background-color:#e2e6ed;cursor:pointer}.ce-table-tool__quick__add:after{content:"+";color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%,-55%)}.ce-table-tool__select{width:16px;height:18px;position:absolute;border-radius:3px;cursor:pointer}.ce-table-tool__select:hover{background-color:#e2e6ed}.ce-table-tool__select:after{content:":::";color:#aaaaab;position:absolute;top:50%;left:50%;transform:translate(-75%,-50%) rotate(-90deg)}.ce-table-tool__col{position:absolute;height:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed;display:flex}.ce-table-tool__col .ce-table-tool__col__item{height:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__col .ce-table-tool__col__item:after{content:"";position:absolute;top:2px;left:-1px;width:1px;height:8px;z-index:1;background-color:#c0c6cf}.ce-table-tool__col .ce-table-tool__col__item:hover{background-color:#dadce0}.ce-table-tool__col .ce-table-tool__col__item:first-child:after{display:none}.ce-table-tool__row .ce-table-tool__row__item.active,.ce-table-tool__col .ce-table-tool__col__item.active{background-color:#c4d7fa}.ce-table-tool__col .ce-table-tool__anchor{right:-5px;width:10px;height:12px;z-index:9;position:absolute;cursor:col-resize}.ce-table-tool__row .ce-table-tool__anchor{bottom:-5px;left:0;width:12px;height:10px;z-index:9;position:absolute;cursor:row-resize}.ce-table-anchor__line{z-index:9;position:absolute;border:1px dotted #000000}.ce-table-tool__border{position:absolute;z-index:1;background:transparent;pointer-events:none}.ce-table-tool__border__row{position:absolute;cursor:row-resize;pointer-events:auto}.ce-table-tool__border__col{position:absolute;cursor:col-resize;pointer-events:auto}.ce-resizer-selection{position:absolute;border:1px solid;pointer-events:none}.ce-resizer-selection .resizer-handle{position:absolute;z-index:9;width:10px;height:10px;box-shadow:0 1px 4px #0000004d;border-radius:5px;border:2px solid #ffffff;box-sizing:border-box;pointer-events:initial}.ce-resizer-selection .handle-0{cursor:nw-resize}.ce-resizer-selection .handle-1{cursor:n-resize}.ce-resizer-selection .handle-2{cursor:ne-resize}.ce-resizer-selection .handle-3{cursor:e-resize}.ce-resizer-selection .handle-4{cursor:se-resize}.ce-resizer-selection .handle-5{cursor:s-resize}.ce-resizer-selection .handle-6{cursor:sw-resize}.ce-resizer-selection .handle-7{cursor:w-resize}.ce-resizer-size-view{display:flex;align-items:center;height:20px;white-space:nowrap;position:absolute;z-index:9;top:-30px;left:0;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px}.ce-resizer-size-view span{color:#fff;font-size:12px}.ce-resizer-image{position:absolute;opacity:.5}.ce-image-previewer{position:fixed;left:0;top:0;z-index:1000;width:100%;height:100%;overflow:hidden;background:#f2f4f7;display:flex;align-items:center;justify-content:center;animation:previewerAnimation .3s}@keyframes previewerAnimation{0%{opacity:.1}to{opacity:1}}.ce-image-previewer .image-close{width:24px;height:24px;display:inline-block;position:absolute;right:50px;top:30px;z-index:99;cursor:pointer;background:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M23.97%207l1.415%201.414-7.779%207.778%207.779%207.779-1.414%201.414-7.779-7.779-7.778%207.779L7%2023.97l7.778-7.779L7%208.414%208.414%207l7.778%207.778L23.971%207z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e") 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,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%2014v-4h2v4h4v2h-4v4h-2v-4h-4v-2h4zm8.749%2010.163A11.952%2011.952%200%200115%2027C8.373%2027%203%2021.627%203%2015S8.373%203%2015%203s12%205.373%2012%2012c0%202.954-1.067%205.658-2.837%207.749l4.908%204.908-1.414%201.414-4.908-4.908zM15%2025c5.523%200%2010-4.477%2010-10S20.523%205%2015%205%205%209.477%205%2015s4.477%2010%2010%2010z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.zoom-out{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M22.749%2024.163A11.952%2011.952%200%200115%2027C8.373%2027%203%2021.627%203%2015S8.373%203%2015%203s12%205.373%2012%2012c0%202.954-1.067%205.658-2.837%207.749l4.908%204.908-1.414%201.414-4.908-4.908zM15%2025c5.523%200%2010-4.477%2010-10S20.523%205%2015%205%205%209.477%205%2015s4.477%2010%2010%2010zm-5-11h10v2H10v-2z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.rotate{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M16%204c6.627%200%2012%205.373%2012%2012a11.97%2011.97%200%2001-4%208.944V23h-.86A9.968%209.968%200%200026%2016c0-5.523-4.477-10-10-10S6%2010.477%206%2016c0%205.185%203.947%209.449%209%209.95v2.009C8.84%2027.451%204%2022.291%204%2016%204%209.373%209.373%204%2016%204z'%20fill-rule='nonzero'/%3e%3cpath%20d='M19.879%2027.328l1.767-6.717%204.95%204.95z'/%3e%3c/g%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.original-size{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%204h24v24H4V4zm2%202v20h20V6H6zm4%205h2v10h-2V11zm5%202h2v2h-2v-2zm0%204h2v2h-2v-2zm5-6h2v10h-2V11z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.image-download{background-image:url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4.5%2015v3.5h15V15H21v5H3v-5h1.5zm8.232-11.226v9.196l4.05-4.05%201.06%201.06-5.834%205.834-5.833-5.833%201.06-1.06%203.998%203.996V3.774h1.5z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu .image-navigate{display:flex;align-items:center;justify-content:center}.ce-image-previewer .ce-image-menu i.image-pre{background-image:url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.5%204.063L6.875%2010l5.625%205.938'%20stroke='%233D4757'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.image-next{background-image:url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.5%204.063L13.125%2010%207.5%2015.938'%20stroke='%233D4757'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu .image-count{color:#000;font-size:20px}.ce-image-previewer .ce-image-menu i.disabled{cursor:not-allowed;opacity:.5}.ce-contextmenu-container{z-index:9;position:fixed;display:none;padding:4px;overflow-x:hidden;overflow-y:auto;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px}.ce-contextmenu-content{display:flex;flex-direction:column}.ce-contextmenu-content .ce-contextmenu-sub-item:after{position:absolute;content:"";width:16px;height:16px;right:12px;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M0%200h16v16H0z'/%3e%3cg%20fill='%23767C85'%3e%3cpath%20d='M7%2012.243l-.707-.707%204.243-4.243.707.707z'/%3e%3cpath%20d='M6.293%204.464L7%203.757%2011.243%208l-.707.707z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e")}.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:#1937580a}.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,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M12%204h-1V2H5v2H4V2a1%201%200%20011-1h6a1%201%200%20011%201v2zm0%205v4a1%201%200%2001-1%201H5a1%201%200%2001-1-1V9h1v4h6V9h1z'/%3e%3cpath%20d='M12%2012v-1h2V5H2v6h2v1H2a1%201%200%2001-1-1V5a1%201%200%20011-1h12a1%201%200%20011%201v6a1%201%200%2001-1%201h-2z'/%3e%3cpath%20d='M3%208h10v1H3zm8-2h2v1h-2z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-image{background-image:url("data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_0-公共_x2F_02工具栏_x2F_插入图片-16px-'%3e%3cg%20id='Group-19'%20transform='translate(1%201)'%3e%3cpath%20id='Combined-Shape'%20class='st0'%20d='M1%200h12c.6%200%201%20.4%201%201v11c0%20.6-.4%201-1%201H1c-.6%200-1-.4-1-1V1c0-.6.4-1%201-1zm0%201v11h12V1H1z'/%3e%3ccircle%20id='椭圆形'%20class='st0'%20cx='10'%20cy='4'%20r='1'/%3e%3cpath%20id='Path'%20class='st0'%20d='M8.5%2011.2l-4-4.1L1%2010.7V9.2c1.7-1.6%202.7-2.5%203-2.8.4-.5.7-.4%201%200L8.5%2010%2011%207.3c.4-.5.6-.5%201-.1l2%202.8v1.5l-2.5-3.4-3%203.1z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-image-change{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cg%20transform='translate(2%204)'%20fill='%233D4757'%3e%3ccircle%20fill-rule='nonzero'%20cx='3'%20cy='1'%20r='1'/%3e%3cpath%20d='M7.473%208.223L3.47%204.107%200%207.667v-1.5C1.715%204.6%202.707%203.664%202.975%203.358c.402-.457.651-.39%201.042%200L7.473%207%209.96%204.349c.414-.462.62-.462%201.011-.071L13%207.06v1.5l-2.51-3.41-3.017%203.072z'/%3e%3c/g%3e%3cpath%20d='M6%201.5H1.5v12h13v-4V13a.5.5%200%2001-.5.5H2a.5.5%200%2001-.5-.5V2a.5.5%200%2001.5-.5h4zm8.5%208V6l-.5.5h1l-.5-.5v3.5zM6%201.5h4L9.5%201v1l.5-.5H6z'%20stroke='%233D4757'/%3e%3cpath%20d='M13.085%201.316l-3.814%204a1%201%200%20001.458%201.368l3.815-4a1%201%200%2010-1.459-1.368z'%20fill='%233D4757'%20fill-rule='nonzero'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-row-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%233D4757'%20d='M8.5%205.5h6v4h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M4%207v1h2V7zm-3%20.5L4%205v5zM1%201h12v1H1zm0%2012h12v1H1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-top-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M8%205H7v3h1zm-.5-3L10%205H5z'/%3e%3crect%20stroke='%233D4757'%20x='1.5'%20y='10.5'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-bottom-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M7%2011h1V8H7zm.5%203L5%2011h5z'/%3e%3crect%20stroke='%233D4757'%20x='1.5'%20y='2.5'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-left-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M11%207v1h3V7zm-3%20.5L11%205v5z'/%3e%3crect%20stroke='%233D4757'%20transform='rotate(90%204%207.5)'%20x='-2'%20y='6'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-right-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M5%208V7H2v1zm3-.5L5%2010V5z'/%3e%3crect%20stroke='%233D4757'%20transform='rotate(90%2012%207.5)'%20x='6'%20y='6'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-row-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M8.5%206.5h6v2h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M2%2012h11v1H2zM2%202h11v1H2zm.63%203L7%209.35l-.635.65L2%205.63z'/%3e%3cpath%20fill='%233D4757'%20d='M2%209.363L6.355%205%207%205.707%202.695%2010z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M8.5%205.5h6v4h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M1%2013h12v1H1zM1%201h12v1H1zm0%204h1v1H1zm1%201h1v1H2zm1%201h1v1H3zm1-1h1v1H4zm1-1h1v1H5zM4%208h1v1H4zM2%208h1v1H2zm3%201h1v1H5zM1%209h1v1H1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M5.5%207.5v-6h4v6z'/%3e%3cpath%20fill='%233D4757'%20d='M13%2015V3h1v12zM1%2015V3h1v12zm4%200v-1h1v1zm1-1v-1h1v1zm1-1v-1h1v1zm-1-1v-1h1v1zm-1-1v-1h1v1zm3%201v-1h1v1zm0%202v-1h1v1zm1-3v-1h1v1zm0%204v-1h1v1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-table{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M14%2013h-1v-3H2v3H1v-3a1%201%200%20011-1h11a1%201%200%20011%201v3z'%20fill-rule='nonzero'/%3e%3cpath%20d='M5.625%202L10%206.375%209.375%207%205%202.625z'/%3e%3cpath%20d='M5%206.375L9.375%202l.625.625L5.625%207z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-merge-cell{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M6%201v1H2v11h4v1H2a1%201%200%2001-1-1V2a1%201%200%20011-1h4zm3%200h4a1%201%200%20011%201v11a1%201%200%2001-1%201H9v-1h4V2H9V1z'/%3e%3cpath%20fill-rule='nonzero'%20d='M6%201h1v4H6zm2%200h1v4H8z'/%3e%3cpath%20d='M8%207.5L10%206v3zm-1%200L5%206v3z'/%3e%3cpath%20d='M9%207h3v1H9zM3%207h3v1H3z'/%3e%3cpath%20fill-rule='nonzero'%20d='M8%2010h1v4H8zm-2%200h1v4H6z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-merge-cancel-cell{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M6%201v1H2v11h4v1H2a1%201%200%2001-1-1V2a1%201%200%20011-1h4zm3%200h4a1%201%200%20011%201v11a1%201%200%2001-1%201H9v-1h4V2H9V1z'/%3e%3cpath%20fill-rule='nonzero'%20d='M6%201h1v4H6zm2%200h1v4H8z'/%3e%3cpath%20d='M3%207.5L5%206v3zm9%200L10%206v3z'/%3e%3cpath%20d='M4%207h3v1H4zm4%200h3v1H8z'/%3e%3cpath%20fill-rule='nonzero'%20d='M8%2010h1v4H8zm-2%200h1v4H6z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-vertical-align{background-image:url("data:image/svg+xml,%3csvg%20height='16'%20viewBox='0%200%2016%2016'%20width='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%2013h12v1H2zm0-3h8v1H2zm0-3h12v1H2zm0-6h12v1H2zm0%203h8v1H2z'%20fill='%233d4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-top{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8%208H7v6h1zm-.5-3L10%208H5zM2%203h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-middle{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8%2012H7v3h1zm-.5-3l2.5%203H5zM7%203h1V0H7zm.5%203L5%203h5zM2%207h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-bottom{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%209h1V3H7zm.5%203L5%209h5zM2%2013h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-border-all{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%233D4757'/%3e%3cpath%20fill='%233D4757'%20d='M3%208h11v1H3z'/%3e%3cpath%20fill='%233D4757'%20d='M9%203v11H8V3z'/%3e%3c/svg%3e")}.ce-contextmenu-border-empty{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13%203h-1V2h1a1%201%200%20011%201v1h-1V3zm-3-1v1H8.5v2h-1V3H6V2h4zM4%202v1H3v1H2V3a1%201%200%20011-1h1zM2%206h1v1.5h2v1H3V10H2V6zm0%206h1v1h1v1H3a1%201%200%2001-1-1v-1zm4%202v-1h1.5v-2h1v2H10v1H6zm6%200v-1h1v-1h1v1a1%201%200%2001-1%201h-1zm2-4h-1V8.5h-2v-1h2V6h1v4zM8.5%207.5v-1h-1v1h-1v1h1v1h1v-1h1v-1h-1z'%20fill='%23AAACB0'/%3e%3c/svg%3e")}.ce-contextmenu-border-dash{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13%203h-1V2h1a1%201%200%20011%201v1h-1V3zm-3-1v1H8.5v2h-1V3H6V2h4zM4%202v1H3v1H2V3a1%201%200%20011-1h1zM2%206h1v1.5h2v1H3V10H2V6zm0%206h1v1h1v1H3a1%201%200%2001-1-1v-1zm4%202v-1h1.5v-2h1v2H10v1H6zm6%200v-1h1v-1h1v1a1%201%200%2001-1%201h-1zm2-4h-1V8.5h-2v-1h2V6h1v4zM8.5%207.5v-1h-1v1h-1v1h1v1h1v-1h1v-1h-1z'%20fill='%23000000'/%3e%3c/svg%3e")}.ce-contextmenu-border-external{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%233D4757'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9%205V3H8v2h1zm0%209v-2H8v2h1zM5%208H3v1h2V8zm9%200h-2v1h2V8zM9%207v1h1v1H9v1H8V9H7V8h1V7h1z'%20fill='%23AAACB0'/%3e%3c/svg%3e")}.ce-contextmenu-border-internal{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9%205V3H8v2h1zm0%209v-2H8v2h1zM5%208H3v1h2V8zm9%200h-2v1h2V8zM9%207v1h1v1H9v1H8V9H7V8h1V7h1z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-contextmenu-border-td{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20d='M8.5%202.5%20v6%20h-6'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-top{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M2.5%203%20h12'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-left{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M3%203%20v11'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-bottom{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M2.5%2014%20h12'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-right{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M14%203%20v11'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-forward{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'%20/%3e%3cpath%20stroke='%233D4757'%20d='M14%203%20l-11%2011'%20/%3e%3c/svg%3e")}.ce-contextmenu-border-td-back{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'%20/%3e%3cpath%20stroke='%233D4757'%20d='M3%203%20l11%2011'%20/%3e%3c/svg%3e")}.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:#dae7fc;position:absolute;transform-origin:0 0}.ce-zone-indicator-border__top,.ce-zone-indicator-border__bottom,.ce-zone-indicator-border__left,.ce-zone-indicator-border__right{display:block;position:absolute;z-index:0}.ce-zone-indicator-border__top{border-top:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__bottom{border-top:2px dashed rgb(238,238,238);width:100%}.ce-zone-indicator-border__left{border-left:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__right{border-right:2px dashed rgb(238,238,238)}.ce-zone-tip{display:none;align-items:center;height:30px;white-space:nowrap;position:fixed;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px;z-index:9;transition:all .3s;outline:none;-webkit-user-select:none;user-select:none;pointer-events:none;transform:translate(10px,10px)}.ce-zone-tip.show{display:flex}.ce-zone-tip span{color:#fff;font-size:12px}.ce-inputarea{min-width:60px!important;min-height:0;margin:0;padding:0;left:0;top:0;letter-spacing:0;font-size:12px;position:absolute;z-index:-1;outline:none;resize:none;border:none;overflow:hidden;color:transparent;-webkit-user-select:none;user-select:none;caret-color:transparent;background-color:transparent;white-space:pre}.ce-cursor{width:1px;height:20px;left:0;right:0;position:absolute;outline:none;background-color:#000;pointer-events:none}.ce-cursor.ce-cursor--animation{animation-duration:1s;animation-iteration-count:infinite;animation-name:cursorAnimation}@keyframes cursorAnimation{0%{opacity:1}13%{opacity:0}50%{opacity:0}63%{opacity:1}to{opacity:1}}.ce-float-image{position:absolute;opacity:.5;pointer-events:none}.ce-button-input-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;justify-content:center;align-items:center;z-index:2000}.ce-button-input-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:320px;max-width:480px;box-shadow:0 4px 20px #00000026}.ce-button-input-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.ce-button-input-modal__textarea{width:100%;min-height:100px;padding:10px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;line-height:1.5;resize:vertical;outline:none;box-sizing:border-box;font-family:inherit}.ce-button-input-modal__textarea:focus{border-color:#5175f4}.ce-button-input-modal__textarea::placeholder{color:#c0c4cc}.ce-button-input-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-button-input-modal__cancel,.ce-button-input-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-button-input-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-button-input-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-button-input-modal__confirm:hover{background:#409eff;border-color:#409eff}.ce-button-edit-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;justify-content:center;align-items:center;z-index:1000}.ce-button-edit-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:320px;max-width:480px;box-shadow:0 4px 20px #00000026}.ce-button-edit-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:16px}.ce-button-edit-modal__form{display:flex;flex-direction:column;gap:12px}.ce-button-edit-modal__field{display:flex;align-items:center;gap:8px}.ce-button-edit-modal__field label{min-width:80px;font-size:13px;color:#606266}.ce-button-edit-modal__field input{flex:1;padding:8px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;outline:none;box-sizing:border-box}.ce-button-edit-modal__field input:focus{border-color:#5175f4}.ce-button-edit-modal__field input::placeholder{color:#c0c4cc}.ce-button-edit-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-button-edit-modal__cancel,.ce-button-edit-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-button-edit-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-button-edit-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-button-edit-modal__confirm:hover{background:#409eff;border-color:#409eff}.ce-number-input-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;justify-content:center;align-items:center;z-index:2000}.ce-number-input-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:300px;max-width:400px;box-shadow:0 4px 20px #00000026}.ce-number-input-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.ce-number-input-modal__hint{font-size:12px;color:#909399;margin-bottom:12px}.ce-number-input-modal__input{width:100%;padding:10px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;outline:none;box-sizing:border-box}.ce-number-input-modal__input:focus{border-color:#5175f4}.ce-number-input-modal__input::placeholder{color:#c0c4cc}.ce-number-input-modal__error{font-size:12px;color:#f56c6c;margin-top:8px}.ce-number-input-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-number-input-modal__cancel,.ce-number-input-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-number-input-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-number-input-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-number-input-modal__confirm:hover{background:#409eff;border-color:#409eff}.tooth-position-edit-modal,.tooth-position-create-modal{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1000}.tooth-position-modal__container{position:relative;top:auto;left:auto;transform:none;background:#fff;border-radius:8px;box-shadow:0 4px 12px #00000026;min-width:400px;max-width:90vw;max-height:calc(100vh - 48px);display:flex;flex-direction:column;pointer-events:auto}.tooth-position-modal__header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #e8e8e8}.tooth-position-modal__header span{font-size:16px;font-weight:500;color:#333}.tooth-position-modal__close{font-size:20px;cursor:pointer;color:#999;line-height:1}.tooth-position-modal__close:hover{color:#333}.tooth-position-modal__content{padding:20px;max-height:60vh;overflow-y:auto}.tooth-section{margin-bottom:20px}.tooth-section:last-child{margin-bottom:0}.tooth-section-title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px;padding-left:8px;border-left:3px solid #1890ff}.tooth-row{display:flex;align-items:center;margin-bottom:8px}.tooth-row:last-child{margin-bottom:0}.tooth-row-label{width:30px;font-size:13px;color:#666}.tooth-buttons{display:flex;gap:8px;flex-wrap:wrap}.letter-buttons{margin-left:30px}.tooth-checkbox{display:flex;align-items:center;cursor:pointer}.tooth-checkbox input{display:none}.tooth-checkbox span{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid #d9d9d9;border-radius:4px;background:#f5f5f5;font-size:14px;color:#333;transition:all .2s}.tooth-checkbox input:checked+span{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-checkbox:hover span{border-color:#1890ff}.tooth-position-modal__footer{display:flex;justify-content:flex-end;gap:10px;padding:16px 20px;border-top:1px solid #e8e8e8}.tooth-position-modal__footer .btn-cancel,.tooth-position-modal__footer .btn-confirm{padding:8px 20px;font-size:14px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.tooth-position-modal__footer .btn-cancel:hover{color:#1890ff;border-color:#1890ff}.tooth-position-modal__footer .btn-confirm{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-position-modal__footer .btn-confirm:hover{background:#40a9ff;border-color:#40a9ff}.tooth-grid-container{display:flex;flex-direction:column;align-items:center;padding:15px 20px;background:#fafafa;border-radius:8px;margin-bottom:15px;position:relative}.tooth-quick-buttons{display:flex;gap:6px;margin-bottom:16px}.tooth-quick-buttons-left{display:flex;flex-direction:column;gap:6px;flex:1}.tooth-quick-buttons-row{display:flex;gap:6px}.tooth-quick-btn{padding:6px 12px;font-size:12px;border:1px solid #d9d9d9;border-radius:4px;cursor:pointer;background:#fff;color:#333;transition:all .2s;white-space:nowrap}.tooth-quick-btn:hover{border-color:#1890ff;color:#1890ff}.tooth-quick-btn.selected{background:#0ff;border-color:#0ff;color:#fff}.tooth-quick-btn--clear{background:#ff6b6b;border-color:#ff6b6b;color:#fff}.tooth-quick-btn--clear:hover{background:#ff5252;border-color:#ff5252;color:#fff}.tooth-grid-container:before{content:"";position:absolute;left:50%;top:20px;bottom:20px;width:2px;background:#000;transform:translate(-50%);z-index:1}.tooth-grid-container:after{content:"";position:absolute;left:20px;right:20px;top:50%;height:2px;background:#000;transform:translateY(-50%);z-index:1}.tooth-grid-letter-row,.tooth-grid-number-row{display:flex;align-items:center;justify-content:center;position:relative;z-index:2}.tooth-grid-half{display:flex;align-items:center;justify-content:center;gap:4px}.tooth-grid-half.left{justify-content:flex-end;padding-right:15px}.tooth-grid-half.right{justify-content:flex-start;padding-left:15px}.tooth-grid-divider-v,.tooth-grid-divider-h{display:none}.tooth-grid-number-item{width:34px;height:32px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:500;color:#333;cursor:pointer;background:#fff;transition:all .2s;box-sizing:border-box;border:1px solid #d9d9d9;border-radius:12px}.upper-number-row .tooth-grid-number-item{border-top:none;border-radius:0 0 12px 12px}.lower-number-row .tooth-grid-number-item{border-bottom:none;border-radius:12px 12px 0 0}.tooth-grid-number-item[data-value="1"],.tooth-grid-number-item[data-value="2"],.tooth-grid-number-item[data-value="3"]{border-radius:50px}.upper-number-row .tooth-grid-number-item[data-value="1"],.upper-number-row .tooth-grid-number-item[data-value="2"],.upper-number-row .tooth-grid-number-item[data-value="3"]{border-top:none!important;border-radius:0 0 50px 50px!important}.lower-number-row .tooth-grid-number-item[data-value="1"],.lower-number-row .tooth-grid-number-item[data-value="2"],.lower-number-row .tooth-grid-number-item[data-value="3"]{border-bottom:none!important;border-radius:50px 50px 0 0!important}.tooth-grid-number-item:hover{border-color:#1890ff;color:#1890ff}.tooth-grid-number-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-grid-letter-item{width:34px;height:32px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px solid #d9d9d9;transition:all .2s;box-sizing:border-box;border-radius:12px}.upper-letter-row .tooth-grid-letter-item{border-top:none;border-radius:0 0 12px 12px}.lower-letter-row .tooth-grid-letter-item{border-bottom:none;border-radius:12px 12px 0 0}.tooth-grid-letter-item[data-value=A],.tooth-grid-letter-item[data-value=B],.tooth-grid-letter-item[data-value=C]{border-radius:50px}.upper-letter-row .tooth-grid-letter-item[data-value=A],.upper-letter-row .tooth-grid-letter-item[data-value=B],.upper-letter-row .tooth-grid-letter-item[data-value=C]{border-top:none!important;border-radius:0 0 50px 50px!important}.lower-letter-row .tooth-grid-letter-item[data-value=A],.lower-letter-row .tooth-grid-letter-item[data-value=B],.lower-letter-row .tooth-grid-letter-item[data-value=C]{border-bottom:none!important;border-radius:50px 50px 0 0!important}.tooth-grid-letter-item:hover{border-color:#1890ff;color:#1890ff}.tooth-grid-letter-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-grid-letter-row.hidden,.tooth-grid-number-row.hidden{display:none}.tooth-grid-letter-row{margin-bottom:8px}.tooth-grid-number-row.upper-number-row{margin-bottom:15px}.tooth-grid-number-row.lower-number-row{margin-top:15px}.tooth-grid-letter-row.lower-letter-row{margin-top:8px}.tooth-preview-section{padding-top:10px;border-top:1px solid #e8e8e8}.tooth-preview-title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.tooth-preview-wrapper{display:flex;gap:15px}.tooth-preview-container{display:flex;justify-content:center;align-items:center;padding:10px;background:#fafafa;border-radius:8px;flex:1;min-height:60px}.tooth-preview-grid{display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;gap:0;width:100%;min-height:70px;position:relative}.tooth-preview-grid:before{content:"";position:absolute;left:50%;top:0;bottom:0;width:1px;background:#000;transform:translate(-50%)}.tooth-preview-grid:after{content:"";position:absolute;top:50%;left:0;right:0;height:1px;background:#000;transform:translateY(-50%)}.tooth-preview-quadrant{display:flex;align-items:center;padding:5px 10px;font-size:12px;flex-wrap:wrap;gap:4px;justify-content:center}.tooth-preview-upper-left{justify-content:flex-end}.tooth-preview-upper-right{justify-content:flex-start}.tooth-preview-lower-left{justify-content:flex-end}.tooth-preview-lower-right{justify-content:flex-start}.tooth-preview-tooth{position:relative;display:inline;margin:0 4px}.tooth-preview-tooth-value{font-size:12px}.tooth-preview-tooth-value--deciduous{font-size:10px}.tooth-preview-tooth-bracket{font-size:12px}.tooth-preview-supernumerary{font-size:9px;vertical-align:super;margin:0 1px}.tooth-preview-surface{font-size:9px;vertical-align:super;margin-left:1px}.tooth-extra-panel{width:100px;display:flex;flex-direction:column;gap:10px}.tooth-surface-panel{background:#fafafa;border-radius:8px;padding:10px 20px}.tooth-surface-title{font-size:12px;font-weight:500;color:#333;margin-bottom:8px;text-align:center}.tooth-surface-grid{display:flex;flex-direction:column;gap:4px;align-items:center}.tooth-surface-row{display:flex;gap:4px;justify-content:center}.tooth-surface-item{width:30px;height:30px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px dashed #d9d9d9;border-radius:5px;transition:all .2s;box-sizing:border-box}.tooth-surface-item--indent{margin-left:17px}.tooth-surface-item:hover{border-color:#1890ff;color:#1890ff}.tooth-surface-item.selected{background:#1890ff;border-color:#1890ff;border-style:solid;color:#fff}.tooth-supernumerary-panel{background:#fafafa;border-radius:8px;padding:10px 20px}.tooth-supernumerary-title{font-size:12px;font-weight:500;color:#333;margin-bottom:4px;text-align:center}.tooth-supernumerary-hint{font-size:10px;color:#999;font-weight:400}.tooth-supernumerary-grid{display:flex;gap:8px;justify-content:center;margin-top:8px}.tooth-supernumerary-item{width:30px;height:35px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px solid #d9d9d9;border-bottom:none;border-radius:50px;transition:all .2s;box-sizing:border-box}.tooth-supernumerary-item:hover{border-color:#1890ff;color:#1890ff}.tooth-supernumerary-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.ce-button-input-modal,.ce-button-edit-modal,.ce-number-input-modal,.tooth-position-edit-modal,.tooth-position-create-modal{inset:0;display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box;overflow:auto;background:transparent;pointer-events:none}.ce-button-input-modal__content,.ce-button-edit-modal__content,.ce-number-input-modal__content,.tooth-position-modal__container{pointer-events:auto}.ce-button-input-modal__content,.ce-button-edit-modal__content,.ce-number-input-modal__content{max-height:calc(100vh - 48px);overflow:auto}.tooth-position-modal__mask{display:none}.tooth-position-modal__container{position:relative;top:auto;left:auto;transform:none;display:flex;flex-direction:column;max-height:calc(100vh - 48px)}.ant-modal-mask{display:none!important}.ant-modal-wrap{position:fixed!important;inset:0!important;display:flex!important;align-items:center!important;justify-content:center!important;padding:24px!important;box-sizing:border-box!important;overflow:auto!important;pointer-events:none!important}.ant-modal{top:auto!important;margin:0!important;padding-bottom:0!important;max-width:calc(100vw - 48px)!important;max-height:calc(100vh - 48px)!important;pointer-events:auto!important}.ant-modal-content{max-height:calc(100vh - 48px)!important;overflow:auto!important}.dialog-mask{display:none}.dialog-container{position:fixed;inset:0;overflow:auto;z-index:999;margin:0;padding:24px;box-sizing:border-box;display:flex;justify-content:center;align-items:center;pointer-events:none}.dialog{position:relative;padding:0 30px 30px;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px;max-height:calc(100vh - 48px);overflow:auto;pointer-events:auto}.dialog-title{position:relative;border-bottom:1px solid #e2e6ed;margin-bottom:30px;height:60px;display:flex;align-items:center;justify-content:space-between}.dialog-title i{width:16px;height:16px;cursor:pointer;display:inline-block;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.9%208.192l4.242%204.243-.707.707L8.192%208.9%203.95%2013.142l-.707-.707%204.242-4.243L3.243%203.95l.707-.707%204.242%204.242%204.243-4.242.707.707L8.9%208.192z'%20fill='%236A6A6A'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.dialog-option__item{margin-bottom:18px;display:flex;align-items:center;justify-content:space-between}.dialog-option__item span{margin-right:12px;font-size:14px;color:#3d4757;position:relative}.dialog-option__item input,.dialog-option__item textarea,.dialog-option__item select{width:276px;height:30px;border-radius:2px;border:1px solid #d3d3d3;min-height:30px;padding:5px;box-sizing:border-box;outline:none;appearance:none;-webkit-user-select:none;user-select:none;font-family:inherit}.dialog-option__item input:focus,.dialog-option__item textarea:focus{border-color:#4991f2}.dialog-option__item--require:before{content:"*";color:#f56c6c;margin-right:4px;position:absolute;left:-8px}.dialog-menu{display:flex;align-items:center;justify-content:flex-end}.dialog-menu button{position:relative;display:inline-block;border:1px solid #e2e6ed;border-radius:2px;background:#fff;line-height:22px;padding:0 16px;white-space:nowrap;cursor:pointer}.dialog-menu button:hover{background:#1937580a}.dialog-menu__cancel{margin-right:16px}.dialog-menu button[type=submit]{color:#fff;background:#4991f2;border-color:#4991f2}.dialog-menu button[type=submit]:hover{background:#5b9cf3;border-color:#5b9cf3}.dialog-radio-group{display:flex;flex-direction:column;gap:8px}.dialog-radio-group--horizontal{flex-direction:row;gap:16px}.dialog-radio-item{display:flex;align-items:center;cursor:pointer;font-size:14px;color:#3d4757}.dialog-radio-item input[type=radio]{width:16px;height:16px;margin:0 6px 0 0;cursor:pointer;appearance:auto}.dialog-radio-item span{margin:0}`)),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- (function(s,pn){typeof exports=="object"&&typeof module<"u"?pn(exports):typeof define=="function"&&define.amd?define(["exports"],pn):(s=typeof globalThis<"u"?globalThis:s||self,pn(s["canvas-editor"]={}))})(this,(function(s){"use strict";const pn="0.7.37";s.MaxHeightRatio=void 0,(function(o){o.HALF="half",o.ONE_THIRD="one-third",o.QUARTER="quarter"})(s.MaxHeightRatio||(s.MaxHeightRatio={})),s.NumberType=void 0,(function(o){o.ARABIC="arabic",o.CHINESE="chinese"})(s.NumberType||(s.NumberType={})),s.ImageDisplay=void 0,(function(o){o.INLINE="inline",o.BLOCK="block",o.SURROUND="surround",o.FLOAT_TOP="float-top",o.FLOAT_BOTTOM="float-bottom"})(s.ImageDisplay||(s.ImageDisplay={})),s.LocationPosition=void 0,(function(o){o.BEFORE="before",o.AFTER="after",o.OUTER_BEFORE="outer-before",o.OUTER_AFTER="outer-after"})(s.LocationPosition||(s.LocationPosition={})),s.FlexDirection=void 0,(function(o){o.ROW="row",o.COLUMN="column"})(s.FlexDirection||(s.FlexDirection={}));const K="​",Xs=`
2
+ (function(s,pn){typeof exports=="object"&&typeof module<"u"?pn(exports):typeof define=="function"&&define.amd?define(["exports"],pn):(s=typeof globalThis<"u"?globalThis:s||self,pn(s["canvas-editor"]={}))})(this,(function(s){"use strict";const pn="0.7.38";s.MaxHeightRatio=void 0,(function(o){o.HALF="half",o.ONE_THIRD="one-third",o.QUARTER="quarter"})(s.MaxHeightRatio||(s.MaxHeightRatio={})),s.NumberType=void 0,(function(o){o.ARABIC="arabic",o.CHINESE="chinese"})(s.NumberType||(s.NumberType={})),s.ImageDisplay=void 0,(function(o){o.INLINE="inline",o.BLOCK="block",o.SURROUND="surround",o.FLOAT_TOP="float-top",o.FLOAT_BOTTOM="float-bottom"})(s.ImageDisplay||(s.ImageDisplay={})),s.LocationPosition=void 0,(function(o){o.BEFORE="before",o.AFTER="after",o.OUTER_BEFORE="outer-before",o.OUTER_AFTER="outer-after"})(s.LocationPosition||(s.LocationPosition={})),s.FlexDirection=void 0,(function(o){o.ROW="row",o.COLUMN="column"})(s.FlexDirection||(s.FlexDirection={}));const K="​",Xs=`
3
3
  `,ai=" ",Ns="&nbsp;",ia=["·","、",":",":",",",",",".","。",";",";","?","?","!","!"],ys={[s.MaxHeightRatio.HALF]:1/2,[s.MaxHeightRatio.ONE_THIRD]:1/3,[s.MaxHeightRatio.QUARTER]:1/4},ci={ENGLISH:"A-Za-z",NUMBER:"0-9.$¥",SPANISH:"A-Za-zÁÉÍÓÚáéíóúÑñÜü",FRENCH:"A-Za-zÀÂÇàâçÉéÈèÊêËëÎîÏïÔôÙùÛûŸÿ",GERMAN:"A-Za-zÄäÖöÜüß",RUSSIAN:"А-Яа-яЁё",PORTUGUESE:"A-Za-zÁÉÍÓÚáéíóúÃÕãõÇç",ITALIAN:"A-Za-zÀàÈèÉéÌìÍíÎîÓóÒòÙù",DUTCH:"A-Za-zÀàÁáÂâÄäÈèÉéÊêËëÌìÍíÎîÏïÓóÒòÔôÖöÙùÛûÜü",SWEDISH:"A-Za-zÅåÄäÖö",GREEK:"ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΛλΜμΝνΞξΟοΠπΡρΣσςΤτΥυΦφΧχΨψΩω"},sa="中";s.RowFlex=void 0,(function(o){o.LEFT="left",o.CENTER="center",o.RIGHT="right",o.ALIGNMENT="alignment",o.JUSTIFY="justify"})(s.RowFlex||(s.RowFlex={}));const di=/[0-9.]/,ra=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,la=/[#*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,aa=new RegExp(`${la.source}|${ra.source}`,"g"),ca=/[、,。?!;:……「」“”‘’*()【】〔〕〖〗〘〙〚〛《》———﹝﹞–—\\/·.,!?;:`~<>()[\]{}'"|]/,ui=new RegExp(`^[${K}
4
4
  ]`),da=/\s/;function ua(o,t){let e;return function(...n){e&&window.clearTimeout(e),e=window.setTimeout(()=>{o.apply(this,n)},t)}}function Ra(o,t){let e=0,n;return function(...i){const l=Date.now();l-e>=t?(window.clearTimeout(n),o.apply(this,i),e=l):(window.clearTimeout(n),n=window.setTimeout(()=>{o.apply(this,i),e=l},t))}}function Ri(o,t){if(!o||typeof o!="object")return o;let e={};return Array.isArray(o)?e=o.map(n=>Ri(n,t)):Object.keys(o).forEach(n=>{t.includes(n)||(e[n]=Ri(o[n],t))}),e}function at(o){if(typeof structuredClone=="function")return structuredClone(o);if(!o||typeof o!="object")return o;let t={};return Array.isArray(o)?t=o.map(e=>at(e)):Object.keys(o).forEach(e=>{t[e]=at(o[e])}),t}function hi(o){return o&&o.nodeType===1&&o.tagName.toLowerCase()==="body"}function bs(o,t,e){if(o&&!hi(o))for(o=o;o;){if(!t||t(o)||hi(o))return t&&!t(o)&&hi(o)?null:o;o=o.parentNode}return null}function mt(){function o(){return((1+Math.random())*65536|0).toString(16).substring(1)}return o()+o()+"-"+o()+"-"+o()+"-"+o()+"-"+o()+o()+o()}function Dt(o){const t=[];if(Intl.Segmenter){const n=new Intl.Segmenter().segment(o);for(const{segment:i}of n)t.push(i)}else{const e=new Map;for(const i of o.matchAll(aa))e.set(i.index,i[0]);let n=0;for(;n<o.length;){const i=e.get(n);i?(t.push(i),n+=i.length):(t.push(o[n]),n++)}}return t}function Vs(o,t){const e=document.createElement("a");e.href=o,e.download=t,e.click()}function ha(o,t){ga(3,o,t)}function ga(o,t,e){let n=0,i=0,l=null,r=null;const a=function(c){const d=new Date().getTime(),u=l!==null&&r!==null&&Math.abs(c.clientX-l)<=5&&Math.abs(c.clientY-r)<=5;n=d-i<300&&u?n+1:0,i=d,l=c.clientX,r=c.clientY,n>=o-1&&(e(c),n=0)};t.addEventListener("click",a)}function Io(o){return Object.prototype.toString.call(o)==="[object Object]"}function gi(o){return Array.isArray(o)}function fi(o){return Object.prototype.toString.call(o)==="[object Number]"}function fa(o){return Object.prototype.toString.call(o)==="[object String]"}function Ws(o,t){if(Io(o)&&Io(t)){const e=t;for(const[n,i]of Object.entries(o))e[n]?e[n]=Ws(i,e[n]):e[n]=i}else gi(o)&&gi(t)&&t.push(...o);return t}function Ti(o){if(typeof queueMicrotask=="function"){queueMicrotask(()=>{o()});return}if(typeof Promise<"u"){Promise.resolve().then(()=>{o()});return}setTimeout(()=>{o()},0)}function Ta(o){const t=["零","一","二","三","四","五","六","七","八","九"],e=["","十","百","千","万","十","百","千","亿","十","百","千","万","十","百","千","亿"];if(!o||isNaN(o))return"零";const n=o.toString().split("");let i="";for(let l=0;l<n.length;l++){const r=n.length-1-l;i=`${e[l]}${i}`,i=`${t[Number(n[r])]}${i}`}return i=i.replace(/零(千|百|十)/g,"零").replace(/十零/g,"十"),i=i.replace(/零+/g,"零"),i=i.replace(/零亿/g,"亿").replace(/零万/g,"万"),i=i.replace(/亿万/g,"亿"),i=i.replace(/零+$/,""),i=i.replace(/^一十/g,"十"),i}function un(o,t,e){for(let n=0;n<o.length;n++){const i=o[n],l=t[i];l!==void 0?e[i]=l:delete e[i]}}function Ys(o,t){if(!(!t.length||!o.length))for(let e=o.length-1;e>=0;e--)t.includes(o[e])&&o.splice(e,1)}function xt(o,t){const e={};for(const n in o)t.includes(n)&&(e[n]=o[n]);return e}function Ee(o,t){const e={};for(const n in o)t.includes(n)||(e[n]=o[n]);return e}function ma(o){const e=new TextEncoder().encode(o),n=Array.from(e,l=>String.fromCharCode(l));return window.btoa(n.join(""))}function Ca(o){let t=o.parentElement;for(;t;){const n=window.getComputedStyle(t).getPropertyValue("overflow-y");if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"))return t;t=t.parentElement}return document.documentElement}function Us(o,t){return o.length!==t.length?!1:!o.some(e=>!t.includes(e))}function pa(o,t){if(!Io(o)||!Io(t))return!1;const e=Object.keys(o),n=Object.keys(t);return e.length!==n.length?!1:!e.some(i=>t[i]!==o[i])}function Ia(o,t){const e=o.x,n=o.x+o.width,i=o.y,l=o.y+o.height,r=t.x,a=t.x+t.width,c=t.y,d=t.y+t.height;return!(e>a||n<r||i>d||l<c)}function ws(o){return o==null}function Eo(o){return o.replace(/\r\n|\r/g,`
5
5
  `)}function Zs(o,t,e=0){const n=Math.max(0,Math.floor(e));if(n>=o.length)return typeof t=="string"&&t===""?{index:o.length,length:0}:{index:-1,length:0};if(typeof t=="string"){if(t==="")return{index:n,length:0};const c=o.indexOf(t,n);return c===-1?{index:-1,length:0}:{index:c,length:t.length}}const i=t.flags,l=i.includes("g")?i:i+"g",r=new RegExp(t.source,l);r.lastIndex=n;const a=r.exec(o);return a?{index:a.index,length:a[0].length}:{index:-1,length:0}}function vs(o,t){if(!t){o.scrollTop=0;return}const e=[];let n=t.offsetParent;for(;n&&o!==n&&o.contains(n);)e.push(n),n=n.offsetParent;const i=t.offsetTop+e.reduce((c,d)=>c+d.offsetTop,0),l=i+t.offsetHeight,r=o.scrollTop,a=r+o.clientHeight;i<r?o.scrollTop=i:l>a&&(o.scrollTop=l-o.clientHeight)}function ie(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function Ea(o,t){return o.performance.enabled&&t>=o.performance.threshold}function mi(o,t,e,n=[],i){if(!Ea(o,e))return;const l={duration:Number(e.toFixed(2)),breakdown:n.map(r=>({label:r.label,duration:Number(r.duration.toFixed(2))})),...i};console.log(`[canvas-editor perf] ${t}`,l)}const Qs=12,La={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},Ze="editor-component",rt="ce",no=`${rt}-clipboard`,Lo={print:{imagePreviewerDisabled:!1,backgroundDisabled:!1},compare:{imagePreviewerDisabled:!1,backgroundDisabled:!1},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1,inputTraceEnabled:!0,deleteTraceEnabled:!0}};var Jt;(function(o){o.UP="top",o.DOWN="down",o.LEFT="left",o.RIGHT="right"})(Jt||(Jt={}));const In=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),Pa=typeof navigator<"u"&&/iPad|iPhone/.test(navigator.userAgent),Ma=/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),Oa=typeof navigator<"u"&&/Firefox/.test(navigator.userAgent);s.ElementType=void 0,(function(o){o.TEXT="text",o.TEXTFIELD="TextField",o.BUTTON="button",o.IMAGE="image",o.TABLE="table",o.HYPERLINK="hyperlink",o.SUPERSCRIPT="superscript",o.SUBSCRIPT="subscript",o.SEPARATOR="separator",o.PAGE_BREAK="pageBreak",o.CONTROL="control",o.AREA="area",o.CHECKBOX="checkbox",o.RADIO="radio",o.LATEX="latex",o.TAB="tab",o.DATE="date",o.BLOCK="block",o.TITLE="title",o.LIST="list",o.SPLIT_TAG="splitTag",o.LABEL="label",o.MENSTRUAL_HISTORY="menstrualHistory",o.FETAL_HEART_POSITION="fetalHeartPosition",o.TOOTH_POSITION="toothPosition",o.SPECIAL_SYMBOLS="specialSymbols",o.MACRO="macro",o.CUSTOM_MACRO="customMacro",o.REUSABLE_ITEM="reusableItem",o.SUB_TEMPLATE="subTemplate"})(s.ElementType||(s.ElementType={}));const Ne=["bold","color","highlight","font","size","italic","underline","strikeout","textDecoration","deletePerson","newElEditPerson","deleteTime","newElEditTime"],le=["rowFlex","rowMargin"],Sa=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","url","areaId","hyperlinkId","dateId","dateFormat","groupIds","templateId","subTemplateContent","subTemplateRelation","subTemplateConditions","rowMargin","textDecoration","deletePerson","newElEditPerson","deleteTime","newElEditTime"],Da=["type","font","size","bold","color","italic","highlight","underline","strikeout","rowFlex","rowMargin","dashArray","trList","tdPadding","tableToolDisabled","borderType","borderColor","borderWidth","borderExternalWidth","translateX","width","height","url","colgroup","valueList","control","checkbox","radio","dateFormat","block","level","title","listType","listStyle","listWrap","groupIds","conceptId","imgDisplay","imgFloatPosition","imgToolDisabled","imgPreviewDisabled","imgCrop","imgCaption","textDecoration","extension","externalId","areaId","area","hide","label","labelId","lineWidth","deletePerson","newElEditPerson","deleteTime","newElEditTime","dictCode","macroConfig","menstrualData","menstrualHistoryId","fetalHeartData","fetalHeartPositionId","toothPositionData","toothPositionId","reusableItemConfig","templateId","subTemplateContent","subTemplateRelation","subTemplateConditions","subTemplateExpanded"],Fa=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],En=["tdId","trId","tableId"],Ci=["level","titleId","title"],bn=["listId","listType","listStyle"],pi=["control","controlId","controlComponent"],Re=["font","size","bold","highlight","italic","strikeout","deletePerson","newElEditPerson","deleteTime","color","newElEditTime"],Rn=["areaId","area"],Ii=[...En,...Ci,...bn,...Rn],Le=[s.ElementType.TEXT,s.ElementType.HYPERLINK,s.ElementType.SUBSCRIPT,s.ElementType.SUPERSCRIPT,s.ElementType.CONTROL,s.ElementType.DATE],Xa=[s.ElementType.IMAGE,s.ElementType.LATEX],Na=[s.ElementType.BLOCK,s.ElementType.PAGE_BREAK,s.ElementType.SEPARATOR,s.ElementType.TABLE],ya=["HR","TABLE","UL","OL"],ba=[s.ElementType.TITLE,s.ElementType.LIST];class Vn{static sandbox=["allow-scripts","allow-same-origin"];static allow=["fullscreen"];element;constructor(t){this.element=t}_defineIframeProperties(t){Object.defineProperties(t,{parent:{get:()=>null},__POWERED_BY_CANVAS_EDITOR__:{get:()=>!0}})}render(t){const{iframeBlock:e}=this.element.block||{},n=document.createElement("iframe");n.setAttribute("data-id",this.element.id),n.sandbox.add(...e?.sandbox||Vn.sandbox),n.setAttribute("allow",[e?.allow||Vn.allow].join(" ")),n.style.border="none",n.style.width="100%",n.style.height="100%",e?.src?n.src=e.src:e?.srcdoc&&(n.srcdoc=e.srcdoc),t.append(n),this._defineIframeProperties(n.contentWindow)}}class Ks{draw;options;imageCache;container;floatImageContainer;floatImage;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer(),this.imageCache=new Map,this.floatImageContainer=null,this.floatImage=null}getOriginalMainImageList(){const t=[],e=n=>{for(const i of n)if(i.type===s.ElementType.TABLE){const l=i.trList;for(let r=0;r<l.length;r++){const a=l[r];for(let c=0;c<a.tdList.length;c++){const d=a.tdList[c];e(d.value)}}}else i.type===s.ElementType.IMAGE&&t.push(i)};return e(this.draw.getOriginalMainElementList()),t}_countImagesBeforeTarget(t,e){let n=0;for(const i of t){if(i===e)break;if(i.type===s.ElementType.TABLE){const l=i.trList;for(const r of l)for(const a of r.tdList)n+=this._countImagesBeforeTarget(a.value,e)}else i.type===s.ElementType.IMAGE&&n++}return n}createFloatImage(t){const{scale:e}=this.options;let n=this.floatImageContainer,i=this.floatImage;n||(n=document.createElement("div"),n.classList.add(`${rt}-float-image`),this.container.append(n),this.floatImageContainer=n),i||(i=document.createElement("img"),n.append(i),this.floatImage=i),n.style.display="none",i.style.width=`${t.width*e}px`,i.style.height=`${t.height*e}px`;const l=this.draw.getHeight(),r=this.draw.getPageGap(),a=this.draw.getPageNo()*(l+r),c=t.imgFloatPosition;n.style.left=`${c.x*e}px`,n.style.top=`${a+c.y*e}px`,i.src=t.value}dragFloatImage(t,e){if(!this.floatImageContainer)return;this.floatImageContainer.style.display="block";const n=parseFloat(this.floatImageContainer.style.left)+t,i=parseFloat(this.floatImageContainer.style.top)+e;this.floatImageContainer.style.left=`${n}px`,this.floatImageContainer.style.top=`${i}px`}destroyFloatImage(){this.floatImageContainer&&(this.floatImageContainer.style.display="none")}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const i=(t-Math.ceil(t/8)*8)/2,l=(e-Math.ceil(e/8)*8)/2,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
@@ -119,7 +119,7 @@ ${h||`${f+1}.`}${i(R)}${g?`
119
119
  `,K),{startIndex:Z,endIndex:Q}=g.getRange(),v=g.getRangeAnchorStyle(y,Z);if(!v)return;const st=Z>0?y[Z-1]:null,B=!!(v.controlId||v.control),k={...!B&&st?st:v,...b},q=i.isDesignMode(),x=y[Q+1],Xt=gn(y,v.originControlId,i.getMode()),wt=gn(y,x?.originControlId,i.getMode()),Ie=!v.originControlId&&!x?.originControlId&&be(v)&&Uo(x)&&!!v.controlId&&!!x.controlId&&v.controlId!==x.controlId,ne=io(v)&&Zi(x)&&!Xt&&!wt,ue=i.getMode()===s.EditorMode.EDIT?Er(y,v,x):void 0,tt=!!v.originControlId&&be(v)&&x?.controlId===v.originControlId&&!x.originControlId&&x.control?.type===s.ControlType.TEXTFIELD&&be(x),J=!!v.originControlId&&be(v)&&x?.controlId===v.originControlId&&!x.originControlId&&x.control?.type===s.ControlType.TEXTFIELD&&x.controlComponent===s.ControlComponent.VALUE,G=!!Xt&&Xt===wt&&!!v.controlId&&!!x?.controlId&&v.controlId!==x.controlId&&(io(v)||Zi(x))?Xt:null;if(Y&&(Ie||ne))return;const it=Uo(x)&&!x?.originControlId,z=be(v)&&!v.originControlId||v.type===s.ElementType.CONTROL&&v.controlComponent===s.ControlComponent.VALUE&&x?.type!==s.ElementType.CONTROL&&!v.originControlId,ut=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.BUTTON],Rt=(Ct,ot)=>!!(Ct?.controlId&&Ct.controlId===ot?.controlId&&(Ct.originControlId||null)===(ot.originControlId||null)),St=(Ct,ot)=>{if(Ct?.control?.type)return Ct.control.type;if(Ct?.controlId){for(let Zt=ot;Zt>=0;Zt--){const yt=y[Zt];if(!Rt(Ct,yt))break;if(yt.control?.type)return yt.control.type}for(let Zt=ot+1;Zt<y.length;Zt++){const yt=y[Zt];if(!Rt(Ct,yt))break;if(yt.control?.type)return yt.control.type}}},Nt=(Ct,ot)=>{const Zt=St(Ct,ot);return!!(Zt&&ut.includes(Zt))},At=Ct=>{const ot=y[Ct];let Zt=Ct;for(let yt=Ct+1;yt<y.length&&Rt(ot,y[yt]);yt++)Zt=yt;return Zt},Ft=!!(Nt(v,Z)&&v.controlComponent===s.ControlComponent.VALUE&&!v.originControlId&&Rt(v,x)&&be(x)&&!x?.value),_t=!!((Nt(v,Z)||St(v,Z)===s.ControlType.NUMBER)&&v.controlComponent===s.ControlComponent.VALUE&&v.originControlId&&Rt(v,x)&&be(x))?gn(y,v.originControlId,i.getMode()):null,re=Ir(y,_t),ft=it||z||Ft,Lt=ft?{...v,type:void 0,control:void 0,controlId:void 0,controlComponent:void 0,originControlId:void 0,color:r.defaultColor,highlight:void 0}:v,Vt=ft||B?Lt:k,Pt=Dt(U).map(Ct=>{const ot={value:Ct};if(q||!Vt.title?.disabled&&!Vt.control?.disabled){const Zt=y[Q+1];(!Vt.type||Vt.type===V||Vt.type===X&&Zt?.type===X||Vt.type===W&&Zt?.type===W||Vt.type===O&&Zt?.type===O||Vt.type===E&&Zt?.type===E)&&Sa.forEach(yt=>{if(yt==="groupIds"&&!Zt?.groupIds)return;const Tt=Vt[yt];Tt!==void 0&&(ot[yt]=Tt)}),(b||Vt.type===D)&&Ne.forEach(yt=>{const Tt=b?.[yt]||Vt[yt];Tt!==void 0&&(ot[yt]=Tt)}),f&&(ot.underline=!0)}if(!ft){const Zt=v.originControlId&&(v.controlComponent===s.ControlComponent.POSTFIX||v.controlComponent===s.ControlComponent.POSTTEXTFIX||v.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||v.controlComponent===s.ControlComponent.POST_TEXT);if(tt||J||ue){const It=ue||x;ot.controlId=It.controlId,ot.control=It.control,ot.controlComponent=s.ControlComponent.VALUE,delete ot.originControlId,vi(ot,It.control,r.defaultColor)}const yt=!v.originControlId&&v.controlId&&(v.controlComponent===s.ControlComponent.POSTFIX||v.controlComponent===s.ControlComponent.POSTTEXTFIX||v.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||v.controlComponent===s.ControlComponent.POST_TEXT)&&x?.controlId&&x.controlId!==v.controlId&&rd(v,x),Tt=v.controlId&&v.originControlId&&(v.controlComponent===s.ControlComponent.VALUE||v.controlComponent===s.ControlComponent.PLACEHOLDER);if(!tt&&!J&&!ue&&Zt&&!ot.controlId){const It=gn(y,v.originControlId,i.getMode());if(!It)return ot;let gt=null;for(let et=Z;et>=0;et--){const j=y[et];if(je(j,It)&&j.control){gt=j.control;break}}ot.controlId=It,ot.controlComponent=s.ControlComponent.VALUE,gt&&(ot.control=gt),vi(ot,gt,r.defaultColor)}else if(yt&&!ot.controlId){if(x?.controlId&&x.controlId!==v.controlId)if(x.controlComponent===s.ControlComponent.PREFIX||x.controlComponent===s.ControlComponent.PRETEXTFIX)for(let It=Z;It>=0;It--){const gt=y[It];if(gt.controlId===v.controlId&&(gt.controlComponent===s.ControlComponent.PREFIX||gt.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let et=It-1;et>=0;et--){const j=y[et];if(j.controlId&&j.controlId!==v.controlId&&(j.controlComponent===s.ControlComponent.PRETEXTFIX||j.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||j.controlComponent===s.ControlComponent.PREFIX||j.controlComponent===s.ControlComponent.PRE_TEXT)){ot.controlId=j.controlId,ot.controlComponent=s.ControlComponent.VALUE,j.control&&(ot.control=j.control);break}if(j.controlId&&j.controlId!==v.controlId&&(j.controlComponent===s.ControlComponent.POSTFIX||j.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}else(x.controlComponent===s.ControlComponent.POSTFIX||x.controlComponent===s.ControlComponent.POSTTEXTFIX)&&(ot.controlId=x.controlId,ot.controlComponent=s.ControlComponent.VALUE,x.control&&(ot.control=x.control));if(!ot.controlId)for(let It=Z;It>=0;It--){const gt=y[It];if(gt.controlId===v.controlId&&(gt.controlComponent===s.ControlComponent.PREFIX||gt.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let et=It-1;et>=0;et--){const j=y[et];if(j.controlId&&j.controlId!==v.controlId&&(j.controlComponent===s.ControlComponent.PRETEXTFIX||j.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||j.controlComponent===s.ControlComponent.PREFIX||j.controlComponent===s.ControlComponent.PRE_TEXT)){ot.controlId=j.controlId,ot.controlComponent=s.ControlComponent.VALUE,j.control&&(ot.control=j.control);break}if(j.controlId&&j.controlId!==v.controlId&&(j.controlComponent===s.ControlComponent.POSTFIX||j.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}}else if(Tt&&!ot.controlId){const It=v.controlId;let gt=v.control;if(!gt)for(let et=Z;et>=0;et--){const j=y[et];if(j.controlId===It&&j.control&&(gt=j.control,j.controlComponent===s.ControlComponent.PREFIX||j.controlComponent===s.ControlComponent.PRETEXTFIX))break}ot.controlId=It,ot.originControlId=v.originControlId,ot.controlComponent=s.ControlComponent.VALUE,gt&&(ot.control=gt)}else if(v.controlId){let It=v.control;if(!It)for(let gt=Z;gt>=0;gt--){const et=y[gt];if(je(et,v.controlId)&&et.control){It=et.control;break}}ot.controlId||(ot.controlId=v.controlId),It&&!ot.control&&(ot.control=It),ot.controlComponent||(ot.controlComponent=s.ControlComponent.VALUE)}else if(!ot.controlId&&!ot.control&&x?.originControlId&&(x.controlComponent===s.ControlComponent.PREFIX||x.controlComponent===s.ControlComponent.PRETEXTFIX)){const It=gn(y,x.originControlId,i.getMode());if(!It)return ot;let gt=null;for(let et=Q;et>=0;et--){const j=y[et];if(je(j,It)&&j.control){gt=j.control;break}}ot.controlId=It,ot.controlComponent=s.ControlComponent.VALUE,gt&&(ot.control=gt)}}if(Ct&&Ct!==K){const Zt=sd(Ct,r.defaultFont);ot.font=Zt}return ot});let Et;const Mt=a[u],Qt=a[u+1],ce=a[u-1];if(f)Et=Z;else{const Ct=et=>{if(Pt?.length)for(let j=0;j<Pt.length;j++)y.splice(et+j,0,Pt[j]);return et+Pt.length-1},ot=Z+1,Zt=Ft?At(Z)+1:ot,yt=()=>{let et=null,j,$t=null;const fe=i.getMode()===s.EditorMode.EDIT?Er(a,Mt,Qt):void 0;if(fe?.controlId?(et=fe.controlId,j=fe.control?.type):i.getMode()===s.EditorMode.EDIT&&io(Mt)&&Qt?.controlId===Mt.originControlId&&!Qt.originControlId&&Qt.control?.type===s.ControlType.TEXTFIELD&&(Qt.controlComponent===s.ControlComponent.VALUE||be(Qt))?(et=Mt.originControlId,j=s.ControlType.TEXTFIELD):io(Mt)?et=gn(a,Mt.originControlId,i.getMode()):Zi(Qt)?et=gn(a,Qt.originControlId,i.getMode()):G?et=G:Mt?.control?.type===s.ControlType.TEXT&&Mt.controlId&&!Mt.originControlId&&be(Mt)&&ce?.originControlId===Mt.controlId&&(et=Mt.controlId,$t={startIndex:u-1,endIndex:u-1}),!et)return null;if(!j)for(let zt=u;zt>=0;zt--){const jt=a[zt];if(je(jt,et)&&jt.control?.type){j=jt.control.type;break}if(jt.controlId&&jt.controlId!==et&&jt.originControlId!==et)break}return j!==s.ControlType.TEXT&&!(i.getMode()===s.EditorMode.EDIT&&j===s.ControlType.TEXTFIELD)?null:{parentControlId:et,activationIndex:(()=>{for(let zt=u+1;zt<a.length;zt++){const jt=a[zt];if(je(jt,et))return zt;if(jt.controlId&&jt.controlId!==et&&jt.originControlId!==et)break}for(let zt=u;zt>=0;zt--){const jt=a[zt];if(je(jt,et))return zt;if(jt.controlId&&jt.controlId!==et&&jt.originControlId!==et)break}return u})(),boundaryRange:$t}},Tt=I?.getElement(),It=!!(Tt?.control?.type===s.ControlType.BUTTON&&!Tt.control?.buttonText&&Tt.control?.editable!==!1&&l.getIsRangeWithinControl());Z!==Q&&!It&&(i.removeSplitTdOtherRangeElements(),i.spliceElementList(y,ot,Q-Z));const gt=yt();if(_t&&re?.control){const et=At(Z);Pt.forEach(j=>{Qi(j,_t,re.control,r.defaultColor)}),se(y,Pt,et,{editorOptions:r}),i.spliceElementList(y,et+1,0,Pt),Et=et+Pt.length}else if(gt){const{parentControlId:et,activationIndex:j,boundaryRange:$t}=gt;p(j,j),C();const fe=l.getActiveControl(),me=Qt?.controlId===et&&!Qt?.originControlId&&Qt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,zt=!!(Mt?.originControlId&&io(Mt)&&me!==-1),jt=$t||(zt?{startIndex:u,endIndex:u}:me!==-1?{startIndex:u,endIndex:me}:{startIndex:Z,endIndex:Q});p(jt.startIndex,jt.endIndex),fe&&fe.getElement()?.controlId===et&&(fe.getElement()?.control?.type===s.ControlType.TEXT||fe.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Pt.forEach(eo=>{Qi(eo,et,fe.getElement().control,r.defaultColor)}),Et=fe.setValue(Pt,{range:jt,elementList:y}),l.emitControlContentChange(),p(Et,Et),C()):ft?Et=Ct(Zt):(Et=l.setValue(Pt),l.emitControlContentChange())}else if(ft)Et=Ct(Zt);else if(Mt?.originControlId&&(Mt.controlComponent===s.ControlComponent.POSTFIX||Mt.controlComponent===s.ControlComponent.POST_TEXT||Mt.controlComponent===s.ControlComponent.POSTTEXTFIX||Mt.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))if(I?.getElement()?.control?.type===s.ControlType.TEXT&&I.getElement()?.controlId===Mt.controlId&&(I.getElement()?.originControlId||null)===(Mt.originControlId||null))Et=l.setValue(Pt),l.emitControlContentChange();else{const j=gn(a,Mt.originControlId,i.getMode());if(!j){Et=Ct(ot);return}let $t;for(let me=u;me>=0;me--){const zt=a[me];if(je(zt,j)&&zt.control?.type){$t=zt.control.type;break}if(zt.controlId&&zt.controlId!==j&&zt.originControlId!==j)break}if($t===s.ControlType.TEXT||i.getMode()===s.EditorMode.EDIT&&$t===s.ControlType.TEXTFIELD){const me=()=>{for(let Me=u+1;Me<a.length;Me++){const we=a[Me];if(je(we,j))return Me;if(we.controlId&&we.controlId!==j&&we.originControlId!==j)break}for(let Me=u;Me>=0;Me--){const we=a[Me];if(je(we,j))return Me;if(we.controlId&&we.controlId!==j&&we.originControlId!==j)break}return u},zt=Qt?.controlId===j&&Qt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,jt=zt!==-1?{startIndex:u,endIndex:zt}:{startIndex:u,endIndex:u},eo=me();p(eo,eo),C();const Cn=l.getActiveControl();p(jt.startIndex,jt.endIndex),Cn&&Cn.getElement()?.controlId===j&&(Cn.getElement()?.control?.type===s.ControlType.TEXT||Cn.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Pt.forEach(Me=>{Qi(Me,j,Cn.getElement().control,r.defaultColor)}),Et=Cn.setValue(Pt,{range:jt,elementList:y}),l.emitControlContentChange(),p(Et,Et),C()):Et=Ct(ot)}else Et=Ct(ot)}else if((Mt?.control?.type===s.ControlType.SELECT||Qt?.control?.type===s.ControlType.SELECT)&&I?.getElement()?.control?.type===s.ControlType.SELECT&&l.getIsRangeWithinControl()){const et=l.getActiveControl();et&&typeof et.awake=="function"&&et.awake(),Et=Z}else if(I?.getElement()?.control?.type===s.ControlType.DATE&&l.getIsRangeWithinControl()){const et=l.getActiveControl();et&&typeof et.awake=="function"&&et.awake(),Et=Z}else!ft&&(Mt?.control?.type===s.ControlType.BUTTON||Qt?.control?.type===s.ControlType.BUTTON)?I?.getElement()?.control?.type===s.ControlType.BUTTON&&I.getElement()?.control?.editable!==!1&&l.getIsRangeWithinControl()?(Et=l.setValue(Pt),l.emitControlContentChange()):Et=Z:I&&l.getIsRangeWithinControl()?(Et=l.setValue(Pt),l.emitControlContentChange()):(Mt?.type==="control"||Qt?.type==="control")&&!ft?Et=Ct(ot):(se(y,Pt,Z,{editorOptions:r}),i.spliceElementList(y,ot,0,Pt),Et=Z+Pt.length)}if(~Et&&!f){const Ct=ie()-n,ot=ie();T(()=>{g.setRange(Et,Et),i.render({curIndex:Et,isSubmitHistory:!f,traceLabel:`input:${e}`})}),mi(r,`input:${e}`,ie()-n,[{label:"mutate",duration:Ct},{label:"renderCall",duration:ie()-ot}],{isComposing:f,textLength:Pt.length,compositionChainDuration:e==="compositionend"&&S!==void 0?Number((ie()-S).toFixed(2)):void 0})}f&&(t.compositionInfo={value:U,startIndex:Et,endIndex:Q,defaultStyle:b,perfStartTime:n})}function ld(o){o.compositionInfo&&(o.compositionInfo=null)}function ad(o,t){if(!o.compositionInfo||o.isComposing)return t;const{startIndex:e,endIndex:n}=o.compositionInfo;return e!==n&&(o.getDraw().removeSplitTdOtherRangeElements(),o.getDraw().spliceElementList(t,e+1,n-e),o.getDraw().getRange().setRange(e,e)),o.compositionInfo=null,t}async function cd(o){const t=o.getDraw(),e=t.getRange(),{startIndex:n,endIndex:i}=e.getRange();if(!~n&&!~n||t.isReadonly()||!e.getIsCanInput())return;const l=t.getElementList();let r=n,a=i;if(n===i){const R=t.getPosition().getPositionList(),f=R[n],g=f.rowNo,T=f.pageNo,C=[];for(let I=0;I<R.length;I++){const m=R[I];if(m.pageNo>T)break;m.pageNo===T&&m.rowNo===g&&C.push(I)}const p=C[0]-1;r=p<0?0:p,a=C[C.length-1]}const c=t.getOptions();await dr(l.slice(r+1,a+1),c);const d=t.getControl();let u;d.getActiveControl()&&d.getIsRangeWithinControl()?(u=d.cut(),d.emitControlContentChange()):(t.spliceElementList(l,r+1,a-r),u=r),e.setRange(u,u),t.render({curIndex:u})}function dd(o){return o.replace(/^(?:\r\n|\r|\n)+|(?:\r\n|\r|\n)+$/g,"")}async function ud(o,t){const e=o.getDraw(),n=e.getMode()===s.EditorMode.COMPARE,i=n||t?.isPlainText,{copy:l}=e.getOverride();if(l&&l()?.preventDefault!==!1)return;const r=e.getRange();let a=null;if(r.getRange().isCrossRowCol){const d=r.getRangeTableElement();if(!d)return;const u=e.getTableParticle().getRangeRowCol();if(!u)return;const h={type:s.ElementType.TABLE,value:"",colgroup:[],trList:[]},R=u[0],f=R[0].colIndex,g=R[R.length-1],T=g.colIndex+g.colspan-1;for(let C=f;C<=T;C++)h.colgroup.push(d.colgroup[C]);for(let C=0;C<u.length;C++){const p=u[C],I=d.trList[p[0].rowIndex],m={tdList:[],height:I.height,minHeight:I.minHeight};for(let L=0;L<p.length;L++)m.tdList.push(p[L]);h.trList.push(m)}a=n?[h]:Yt([h])}else a=r.getIsCollapsed()?r.getRangeRowElementList():r.getSelectionElementList();if(i&&a?.length){const d=Mn(a,e.getOptions());await bc(n?dd(d):d);return}a?.length&&await dr(a,e.getOptions())}function Rd(o,t){const e=t.getDraw(),{drop:n}=e.getOverride();if(n&&n(o)?.preventDefault!==!1)return;o.preventDefault();const i=o.dataTransfer?.getData("text");if(i)t.input(i);else{const l=o.dataTransfer?.files;if(!l)return;for(let r=0;r<l.length;r++){const a=l[r];a.type.startsWith("image")&&Wi(t,a)}}}function Lr(o){if(!Intl.Segmenter)return null;const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const i=t.getRange().getRangeParagraphInfo();if(!i)return null;const l=i?.elementList?.map(R=>!R.type||R.type!==s.ElementType.CONTROL&&Le.includes(R.type)?R.value:K).join("")||"";if(!l)return null;const r=e.isFirstLetter||t.getCursor().getHitLineStartIndex()?e.index+1:e.index,a=i.startIndex,d=new Intl.Segmenter(void 0,{granularity:"word"}).segment(l);let u=-1,h=-1;for(const{segment:R,index:f,isWordLike:g}of d){const T=f+a;if(g&&r>=T&&r<T+R.length){u=T-1,h=u+R.length;break}}return~u&&~h?{startIndex:u,endIndex:h}:null}function hd(o){const t=o.getDraw(),e=t.getPosition().getCursorPosition();if(!e)return null;const{value:n,index:i}=e,l=t.getLetterReg();let r=0,a=0;const c=di.test(n);if(c||l.test(n)){const u=t.getElementList();let h=i-1;for(;h>0;){const f=u[h].value;if(c&&di.test(f)||!c&&l.test(f))r++,h--;else break}let R=i+1;for(;R<u.length;){const f=u[R].value;if(c&&di.test(f)||!c&&l.test(f))a++,R++;else break}}const d=i-r-1;return d<0?null:{startIndex:d,endIndex:i+a}}function gd(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(e.getMode()===s.EditorMode.FORM){const a=i.isTable&&e.getTd()?.value||e.getElementList(),c=i.isTable?i.tdValueIndex:i.index,d=a[c],u=fd(a,d),h=e.getEventBus();if(i.isDirectHit&&u?.controlId&&u.control?.type===s.ControlType.BUTTON&&!u.control.buttonText&&h.isSubscribe("buttonChange")){const R=a.filter(f=>f.controlId===u.controlId&&(f.originControlId||null)===(u.originControlId||null));h.emit("buttonChange",{evt:t,element:at(u),elementList:at(R),controlId:u.controlId,control:at(u.control)});return}}if(i.isImage&&i.isDirectHit){const a=e.getElementList(),c=e.getEventBus(),d=a[i.index];if(c.isSubscribe("imageDblclick")&&c.emit("imageDblclick",{evt:t,element:d}),d.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&e.getMode()===s.EditorMode.EDIT&&!~i.index&&i.zone){e.getZone().setZone(i.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((i.isCheckbox||i.isRadio)&&i.isDirectHit)return;const l=e.getRange(),r=Lr(o)||hd(o);r&&(l.setRange(r.startIndex,r.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),l.setRangeStyle())}function fd(o,t){if(!t?.controlId)return null;const e=t.originControlId||null,n=l=>!!(l&&l.controlId===t.controlId&&(l.originControlId||null)===e);if(t.control?.type===s.ControlType.BUTTON)return t;const i=o.indexOf(t);for(let l=i;l>=0;l--){const r=o[l];if(!n(r))break;if(r.control?.type===s.ControlType.BUTTON)return r}for(let l=i+1;l<o.length;l++){const r=o[l];if(!n(r))break;if(r.control?.type===s.ControlType.BUTTON)return r}return null}function Td(o){const t=o.getDraw(),e=t.getControl();if(e.getActiveControl()&&e.selectValue())return;const i=t.getPosition().getCursorPosition();if(!i)return;const{index:l}=i,r=t.getElementList();let a=0,c=0,d=l-1;for(;d>0;){const g=r[d],T=r[d-1];if(g.value===K&&!g.listWrap||g.listId!==T?.listId||g.titleId!==T?.titleId)break;a++,d--}let u=l+1;for(;u<r.length;){const g=r[u],T=r[u+1];if(g.value===K&&!g.listWrap||g.listId!==T?.listId||g.titleId!==T?.titleId)break;c++,u++}const h=t.getRange();let R=l-a-1;if(r[R]?.value!==K&&(R-=1),R<0)return;let f=l+c+1;(r[f]?.value===K||f>r.length-1)&&(f-=1),h.setRange(R,f),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}const Pr={dblclick:gd,threeClick:Td};function md(o){o.isComposing=!0,o.getDraw().getMacroParticle().compositionStart()}function Cd(o,t){const e=ie();o.isComposing=!1;const n=o.getDraw(),i=n.getOptions();if(n.getMacroParticle().compositionEnd(t.data)){n.getCursor().clearAgentDomValue();return}if(t.data)o.compositionInfo&&(o.compositionInfo.perfStartTime=e),Oa?setTimeout(()=>{o.compositionInfo&&Ki(t.data,o,"compositionend")},1):o.compositionInfo&&Ki(t.data,o,"compositionend");else{const a=o.compositionInfo?.cancel;if(ld(o),!a){const c=n.getRange(),{endIndex:d}=c.getRange();n.render({curIndex:d,isSubmitHistory:!1,traceLabel:"compositionend:empty"})}}n.getCursor().clearAgentDomValue(),mi(i,"compositionend",ie()-e,[],{hasData:!!t.data,dataLength:t.data?.length||0})}function pd(o){o.compositionInfo&&(o.compositionInfo.cancel=!0)}const Hi={compositionstart:md,compositionend:Cd,compositionCancel:pd};function Id(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!bs(o.target,m=>m===i))return;const a=o.target.dataset.index;a&&e.setPageNo(Number(a));const c=e.getPosition(),d=c.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!d)return;const{isTable:u,tdValueIndex:h,index:R}=d,f=c.getPositionList(),g=u?h:R;~R&&(e.getRange().setRange(g,g),c.setCursorPosition(f[g]));const T=e.getCursor(),{cursor:{dragColor:C,dragWidth:p,dragFloatImageDisabled:I}}=e.getOptions();if(I){const m=t.cacheElementList?.[t.cacheRange.startIndex];if(m?.type===s.ElementType.IMAGE&&(m.imgDisplay===s.ImageDisplay.FLOAT_TOP||m.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM||m.imgDisplay===s.ImageDisplay.SURROUND))return}T.drawCursor({width:p,color:C,isBlink:!1,isFocus:!1})}const Ed={dragover:Id};class Ld{isAllowSelection;isComposing;compositionInfo;isAllowDrag;isAllowDrop;cacheRange;cacheElementList;cachePositionList;cachePositionContext;mouseDownStartPosition;draw;pageContainer;pageList;range;position;constructor(t){this.draw=t,this.pageContainer=t.getPageContainer(),this.pageList=t.getPageList(),this.range=this.draw.getRange(),this.position=this.draw.getPosition(),this.isAllowSelection=!1,this.isComposing=!1,this.compositionInfo=null,this.isAllowDrag=!1,this.isAllowDrop=!1,this.cacheRange=null,this.cacheElementList=null,this.cachePositionList=null,this.cachePositionContext=null,this.mouseDownStartPosition=null}getDraw(){return this.draw}register(){this.pageContainer.addEventListener("click",this.click.bind(this)),this.pageContainer.addEventListener("mousedown",this.mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this.mouseup.bind(this)),this.pageContainer.addEventListener("mouseleave",this.mouseleave.bind(this)),this.pageContainer.addEventListener("mousemove",this.mousemove.bind(this)),this.pageContainer.addEventListener("dblclick",this.dblclick.bind(this)),this.pageContainer.addEventListener("dragover",this.dragover.bind(this)),this.pageContainer.addEventListener("drop",this.drop.bind(this)),ha(this.pageContainer,this.threeClick.bind(this))}setIsAllowSelection(t){this.isAllowSelection=t,t||this.applyPainterStyle()}setIsAllowDrag(t){this.isAllowDrag=t,this.isAllowDrop=t}clearPainterStyle(){this.pageList.forEach(t=>{t.style.cursor="text"}),this.draw.setPainterStyle(null)}applyPainterStyle(){const t=this.draw.getPainterStyle();if(!t||this.draw.isReadonly()||this.draw.isDisabled())return;let n=this.range.getSelection();if(!n){const r=Lr(this);r&&(n=this.draw.getElementList().slice(r.startIndex+1,r.endIndex+1))}if(!n)return;const i=Object.keys(t);n.forEach(r=>{i.forEach(a=>{const c=a;Reflect.set(r,c,t[c])})}),this.draw.render({isSetCursor:!1});const l=this.draw.getPainterOptions();(!l||!l.isDblclick)&&this.clearPainterStyle()}selectAll(){if(!this.draw.isSelectionDisabled())if(this.position.getPositionContext().isTable)this.draw.getTableOperate().tableSelectAll();else{const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}}mousemove(t){this.draw.isInteractionSuspended()||Kc(t,this)}mousedown(t){this.draw.isInteractionSuspended()||Zc(t,this)}click(){this.draw.isInteractionSuspended()||Pa&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){this.draw.isInteractionSuspended()||vc(t,this)}mouseleave(t){this.draw.isInteractionSuspended()||Qc(t,this)}keydown(t){this.draw.isInteractionSuspended()||nd(t,this)}dblclick(t){this.draw.isInteractionSuspended()||Pr.dblclick(this,t)}threeClick(){this.draw.isInteractionSuspended()||Pr.threeClick(this)}input(t,e="input"){this.draw.isInteractionSuspended()||Ki(t,this,e)}async cut(){this.draw.isInteractionSuspended()||await cd(this)}async copy(t){this.draw.isInteractionSuspended()||await ud(this,t)}compositionstart(){this.draw.isInteractionSuspended()||Hi.compositionstart(this)}compositionend(t){this.draw.isInteractionSuspended()||Hi.compositionend(this,t)}compositionCancel(){this.draw.isInteractionSuspended()||Hi.compositionCancel(this)}drop(t){this.draw.isInteractionSuspended()||Rd(t,this)}dragover(t){this.draw.isInteractionSuspended()||Ed.dragover(t,this)}}const Mr={PAGE_SCALE:"pageScale"};class Pd{draw;options;cursor;canvasEvent;range;previewer;tableTool;hyperlinkParticle;control;dateParticle;imageParticle;dprMediaQueryList;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.canvasEvent=e,this.cursor=null,this.range=t.getRange(),this.previewer=t.getPreviewer(),this.tableTool=t.getTableTool(),this.hyperlinkParticle=t.getHyperlinkParticle(),this.dateParticle=t.getDateParticle(),this.imageParticle=t.getImageParticle(),this.control=t.getControl(),this.dprMediaQueryList=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)}register(){this.cursor=this.draw.getCursor(),this.addEvent()}addEvent(){window.addEventListener("blur",this.clearSideEffect),document.addEventListener("mousedown",this.clearSideEffect),document.addEventListener("mouseup",this.setCanvasEventAbility),document.addEventListener("wheel",this.setPageScale,{passive:!1}),document.addEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.addEventListener("change",this._handleDprChange)}removeEvent(){window.removeEventListener("blur",this.clearSideEffect),document.removeEventListener("mousedown",this.clearSideEffect),document.removeEventListener("mouseup",this.setCanvasEventAbility),document.removeEventListener("wheel",this.setPageScale),document.removeEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.removeEventListener("change",this._handleDprChange)}clearSideEffect=t=>{if(!this.cursor)return;if(this.draw.isInteractionSuspended()){this.resetSideEffect();return}const e=t?.composedPath?.()[0]||t.target;if(this.draw.isTargetInsideEditor(e)){this.watchCursorActive();return}this.resetSideEffect()};resetSideEffect=()=>{this.cursor&&(this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker(),this.imageParticle.destroyFloatImage())};setCanvasEventAbility=()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)};watchCursorActive(){this.range.getIsCollapsed()&&setTimeout(()=>{this.cursor?.getAgentIsActive()||this.cursor?.drawCursor({isFocus:!1,isBlink:!1})})}setPageScale=t=>{if(this.draw.isInteractionSuspended()||!this.draw.isTargetInsideEditor(t.target)||this.options.shortcutDisableKeys.includes(Mr.PAGE_SCALE)||!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const n=e*10+1;n<=30&&this.draw.setPageScale(n/10)}else{const n=e*10-1;n>=5&&this.draw.setPageScale(n/10)}};_handleVisibilityChange=()=>{if(document.visibilityState==="visible"){const t=this.range.getRange(),e=!!~t.startIndex&&!!~t.endIndex&&t.startIndex===t.endIndex;this.range.replaceRange(t),this.draw.render({isSetCursor:e,isCompute:!1,isSubmitHistory:!1,curIndex:t.startIndex})}};_handleDprChange=()=>{this.draw.setPageDevicePixel()}}class Md{undoStack=[];redoStack=[];maxRecordCount;constructor(t){this.maxRecordCount=t.getOptions().historyMaxRecordCount+1}undo(){if(this.undoStack.length>1){const t=this.undoStack.pop();this.redoStack.push(t),this.undoStack.length&&this.undoStack[this.undoStack.length-1]()}}redo(){if(this.redoStack.length){const t=this.redoStack.pop();this.undoStack.push(t),t()}}execute(t){for(this.undoStack.push(t),this.redoStack.length&&(this.redoStack=[]);this.undoStack.length>this.maxRecordCount;)this.undoStack.shift()}isCanUndo(){return this.undoStack.length>1}isCanRedo(){return!!this.redoStack.length}isStackEmpty(){return!this.undoStack.length&&!this.redoStack.length}recovery(){this.undoStack=[],this.redoStack=[]}popUndo(){return this.undoStack.pop()}}class Od{cursorPosition;positionContext;positionList;floatPositionList;draw;eventBus;options;constructor(t){this.positionList=[],this.floatPositionList=[],this.cursorPosition=null,this.positionContext={isTable:!1,isControl:!1},this.draw=t,this.eventBus=t.getEventBus(),this.options=t.getOptions()}getFloatPositionList(){return this.floatPositionList}getTablePositionList(t){const{index:e,trIndex:n,tdIndex:i}=this.positionContext;return t[e].trList[n].tdList[i].positionList||[]}getPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalElementList()):this.getOriginalPositionList()}getMainPositionList(){return this.positionContext.isTable?this.getTablePositionList(this.draw.getOriginalMainElementList()):this.positionList}getOriginalPositionList(){const t=this.draw.getZone();return t.isHeaderActive()?this.draw.getHeader().getPositionList():t.isFooterActive()?this.draw.getFooter().getPositionList():this.positionList}getOriginalMainPositionList(){return this.positionList}getSelectionPositionList(){const{startIndex:t,endIndex:e}=this.draw.getRange().getRange();return t===e?null:this.getPositionList().slice(t+1,e+1)}setPositionList(t){this.positionList=t}setFloatPositionList(t){this.floatPositionList=t}computePageRowPosition(t){const{positionList:e,rowList:n,pageNo:i,startX:l,startY:r,startRowIndex:a,startIndex:c,innerWidth:d,zone:u}=t,{scale:h,table:{tdPadding:R}}=this.options;let f=l,g=r,T=c;for(let C=0;C<n.length;C++){const p=n[C];if(!p.isSurround){const L=p.width+(p.offsetX||0);p.rowFlex===s.RowFlex.CENTER?f+=(d-L)/2:p.rowFlex===s.RowFlex.RIGHT&&(f+=d-L)}f+=p.offsetX||0,g+=p.offsetY||0;const I=f,m=g;for(let L=0;L<p.elementList.length;L++){const P=p.elementList[L],M=P.metrics,F=!de(P)&&(P.imgDisplay!==s.ImageDisplay.INLINE&&P.type===s.ElementType.IMAGE||P.type===s.ElementType.LATEX)?p.ascent-M.height:p.ascent;P.left&&(f+=P.left),P.translateX&&(f+=P.translateX*h);const N={pageNo:i,index:T,value:P.value,rowIndex:a+C,rowNo:C,metrics:M,left:P.left||0,ascent:F,lineHeight:p.height,isFirstLetter:L===0,isLastLetter:L===p.elementList.length-1,coordinate:{leftTop:[f,g],leftBottom:[f,g+p.height],rightTop:[f+M.width,g],rightBottom:[f+M.width,g+p.height]}};if(P.imgDisplay===s.ImageDisplay.SURROUND||P.imgDisplay===s.ImageDisplay.FLOAT_TOP||P.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM){const Y=e[e.length-1];Y&&(N.metrics=Y.metrics,N.coordinate=Y.coordinate),P.imgFloatPosition||(P.imgFloatPosition={x:f,y:g,pageNo:i}),this.floatPositionList.push({pageNo:i,element:P,position:N,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:T,zone:u})}if(e.push(N),T++,f+=M.width,P.type===s.ElementType.TABLE&&!de(P)){const Y=P.tdPadding||R,b=Y[1]+Y[3],S=Y[0]+Y[2];for(let y=0;y<P.trList.length;y++){const V=P.trList[y];for(let X=0;X<V.tdList.length;X++){const O=V.tdList[X];O.positionList=[];const E=O.rowList,W=this.computePageRowPosition({positionList:O.positionList,rowList:E,pageNo:i,startRowIndex:0,startIndex:0,startX:(O.x+Y[3])*h+I+(P.translateX||0)*h,startY:(O.y+Y[0])*h+m,innerWidth:(O.width-b)*h,isTable:!0,index:T-1,tdIndex:X,trIndex:y,zone:u});if(O.verticalAlign===s.VerticalAlign.MIDDLE||O.verticalAlign===s.VerticalAlign.BOTTOM){const D=E.reduce((Q,v)=>Q+v.height,0),U=(O.height-S)*h-D,Z=O.verticalAlign===s.VerticalAlign.MIDDLE?U/2:U;Math.floor(Z)>0&&O.positionList.forEach(Q=>{const{coordinate:{leftTop:v,leftBottom:st,rightBottom:B,rightTop:H}}=Q;v[1]+=Z,st[1]+=Z,B[1]+=Z,H[1]+=Z})}f=W.x,g=W.y}}f=I,g=m}}f=l,g+=p.height}return{x:f,y:g,index:T}}computePositionList(){this.positionList=[];const t=this.draw.getInnerWidth(),e=this.draw.getPageRowList(),n=this.draw.getMargins(),i=n[3],r=this.draw.getHeader().getExtraHeight(),a=n[0]+r;let c=0;for(let d=0;d<e.length;d++){const u=e[d];if(!u?.length)continue;const h=u[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:u,pageNo:d,startRowIndex:c,startIndex:h,startX:i,startY:a,innerWidth:t}),c+=u.length}}computeRowPosition(t){const{row:e,innerWidth:n}=t,i=[];return this.computePageRowPosition({positionList:i,innerWidth:n,rowList:[at(e)],pageNo:0,startX:0,startY:0,startIndex:0,startRowIndex:0}),i}setCursorPosition(t){this.cursorPosition=t}getCursorPosition(){return this.cursorPosition}getPositionContext(){return this.positionContext}setPositionContext(t){this.eventBus.emit("positionContextChange",{value:t,oldValue:this.positionContext}),this.positionContext=t}getPositionByXY(t){const{x:e,y:n,isTable:i}=t;let{elementList:l,positionList:r}=t;l||(l=this.draw.getOriginalElementList()),r||(r=this.getOriginalPositionList());const a=this.draw.getZone(),c=t.pageNo??this.draw.getPageNo(),d=a.isMainActive(),u=d?c:0;if(!i){const T=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_TOP,s.ImageDisplay.SURROUND]});if(T)return T}for(let T=0;T<r.length;T++){const{index:C,pageNo:p,left:I,isFirstLetter:m,coordinate:{leftTop:L,rightTop:P,leftBottom:M}}=r[T];if(u===p){if(p>u)break;if(L[0]-I<=e&&P[0]>=e&&L[1]<=n&&M[1]>=n){let F=T;const N=l[T];if(N.type===s.ElementType.TABLE)for(let b=0;b<N.trList.length;b++){const S=N.trList[b];for(let y=0;y<S.tdList.length;y++){const V=S.tdList[y],X=this.getPositionByXY({x:e,y:n,td:V,pageNo:c,tablePosition:r[T],isTable:!0,elementList:V.value,positionList:V.positionList});if(~X.index){const{index:O,hitLineStartIndex:E}=X,W=V.value[O];return{index:C,isCheckbox:X.isCheckbox||W.type===s.ElementType.CHECKBOX||W.controlComponent===s.ControlComponent.CHECKBOX,isRadio:W.type===s.ElementType.RADIO||W.controlComponent===s.ControlComponent.RADIO,isControl:!!W.controlId,isImage:X.isImage,isLabel:X.isLabel,isMacro:X.isMacro,isDirectHit:X.isDirectHit,isTable:!0,tdIndex:y,trIndex:b,tdValueIndex:O,tdId:V.id,trId:S.id,tableId:N.id,hitLineStartIndex:E}}}}if(N.type===s.ElementType.IMAGE||N.type===s.ElementType.LATEX)return{index:F,isDirectHit:!0,isImage:!0};if(N.type===s.ElementType.MENSTRUAL_HISTORY)return{index:F,isDirectHit:!0};if(N.type===s.ElementType.FETAL_HEART_POSITION)return{index:F,isDirectHit:!0};if(N.type===s.ElementType.TOOTH_POSITION){const{scale:b}=this.options,S=N.width*b;return e>=L[0]&&e<=L[0]+S?{index:F,isDirectHit:!0}:{index:F}}if(N.type===s.ElementType.CHECKBOX||N.controlComponent===s.ControlComponent.CHECKBOX)return{index:F,isDirectHit:!0,isCheckbox:!0};if(N.type===s.ElementType.LABEL)return{index:F,isDirectHit:!0,isLabel:!0};if(N.type===s.ElementType.MACRO||N.type===s.ElementType.CUSTOM_MACRO||N.type===s.ElementType.REUSABLE_ITEM||N.type===s.ElementType.SUB_TEMPLATE)return{index:F,isDirectHit:!0,isMacro:!0};if(N.type===s.ElementType.TAB&&N.listStyle===s.ListStyle.CHECKBOX){let b=F-1;for(;b>0;){const S=l[b];if(S.value===K&&S.listStyle===s.ListStyle.CHECKBOX)break;b--}return{index:b,isDirectHit:!0,isCheckbox:!0}}if(N.type===s.ElementType.RADIO||N.controlComponent===s.ControlComponent.RADIO)return{index:F,isDirectHit:!0,isRadio:!0};let Y;if(l[C].value!==K){const b=P[0]-L[0];e<L[0]+b/2&&(F=T-1,m&&(Y=T))}return{isDirectHit:!0,hitLineStartIndex:Y,index:F,isControl:!!N.controlId}}}}if(!i){const T=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_BOTTOM]});if(T)return T}let h=!1,R=-1,f;if(i){const{scale:T}=this.options,{td:C,tablePosition:p}=t;if(C&&p){const{leftTop:I}=p.coordinate,m=C.x*T+I[0],L=C.y*T+I[1],P=C.width*T,M=C.height*T;if(!(m<e&&e<m+P&&L<n&&n<L+M))return{index:R}}}const g=r.filter(T=>T.isLastLetter&&T.pageNo===u);for(let T=0;T<g.length;T++){const{index:C,rowNo:p,coordinate:{leftTop:I,leftBottom:m}}=g[T];if(n>I[1]&&n<=m[1]){const L=r.findIndex(N=>N.pageNo===u&&N.rowNo===p),P=l[L],M=r[L],F=P.listStyle===s.ListStyle.CHECKBOX?this.draw.getMargins()[3]:M.coordinate.leftTop[0];if(e<F)~L?M.value===K?R=L:(R=L-1,f=L):R=C;else{if(P.listStyle===s.ListStyle.CHECKBOX&&e<I[0])return{index:L,isDirectHit:!0,isCheckbox:!0};R=C}h=!0;break}}if(!h){if(this.draw.getIsPagingMode()){const C=this.draw.getHeader(),p=C.getHeight(),I=C.getHeaderTop()+p,m=this.draw.getFooter(),P=this.draw.getHeight()-(m.getFooterBottom()+m.getHeight());if(d){if(n<I)return{index:-1,zone:s.EditorZone.HEADER};if(n>P)return{index:-1,zone:s.EditorZone.FOOTER}}else if(n<=P&&n>=I)return{index:-1,zone:s.EditorZone.MAIN}}const T=this.draw.getMargins();if(n<=T[0])for(let C=0;C<r.length;C++){const p=r[C];if(p.pageNo!==u||p.rowNo!==0)continue;const{leftTop:I,rightTop:m}=p.coordinate;if(e<=T[3]||e>=I[0]&&e<=m[0]||r[C+1]?.rowNo!==0)return{index:p.index}}else{const C=g[g.length-1];if(C){const p=C.rowNo;for(let I=0;I<r.length;I++){const m=r[I];if(m.pageNo!==u||m.rowNo!==p)continue;const{leftTop:L,rightTop:P}=m.coordinate;if(e<=T[3]||e>=L[0]&&e<=P[0]||r[I+1]?.rowNo!==p)return{index:m.index}}}}return{index:g[g.length-1]?.index||r.length-1}}return{hitLineStartIndex:f,index:R,isControl:!!l[R]?.controlId}}getFloatPositionByXY(t){const{x:e,y:n}=t,i=t.pageNo??this.draw.getPageNo(),l=this.draw.getZone().getZone(),{scale:r}=this.options;for(let a=0;a<this.floatPositionList.length;a++){const{position:c,element:d,isTable:u,index:h,trIndex:R,tdIndex:f,tdValueIndex:g,zone:T,pageNo:C}=this.floatPositionList[a];if(i===C&&d.type===s.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!T||T===l)){const p=d.imgFloatPosition,I=p.x*r,m=p.y*r,L=d.width*r,P=d.height*r;if(e>=I&&e<=I+L&&n>=m&&n<=m+P)return u?{index:h,isDirectHit:!0,isImage:!0,isTable:u,trIndex:R,tdIndex:f,tdValueIndex:g,tdId:d.tdId,trId:d.trId,tableId:d.tableId}:{index:c.index,isDirectHit:!0,isImage:!0}}}}adjustPositionContext(t){const e=this.getPositionByXY(t);if(!~e.index)return null;if(e.isControl&&this.draw.getMode()!==s.EditorMode.READONLY){const{index:C,isTable:p,trIndex:I,tdIndex:m,tdValueIndex:L}=e,P=this.draw.getControl(),{newIndex:M}=P.moveCursor({index:C,isTable:p,trIndex:I,tdIndex:m,tdValueIndex:L});p?e.tdValueIndex=M:e.index=M}const{index:n,isCheckbox:i,isRadio:l,isControl:r,isImage:a,isLabel:c,isDirectHit:d,isTable:u,trIndex:h,tdIndex:R,tdId:f,trId:g,tableId:T}=e;return this.setPositionContext({isTable:u||!1,isCheckbox:i||!1,isRadio:l||!1,isControl:r||!1,isImage:a||!1,isLabel:c||!1,isDirectHit:d||!1,index:n,trIndex:h,tdIndex:R,tdId:f,trId:g,tableId:T}),e}setSurroundPosition(t){const{scale:e}=this.options,{pageNo:n,row:i,rowElement:l,rowElementRect:r,surroundElementList:a,availableWidth:c}=t;let d=r.x,u=0;if(a.length&&!Kn(l)&&!l.control?.minWidth)for(let h=0;h<a.length;h++){const R=a[h],f=R.imgFloatPosition;if(f.pageNo!==n)continue;const g={...f,x:f.x*e,y:f.y*e,width:R.width*e,height:R.height*e};if(Ia(r,g)){i.isSurround=!0;const T=g.width+g.x-r.x;if(l.left=T,i.width+=T,u+=T,d=g.x+g.width,i.width+l.metrics.width>c){l.left=0,i.width-=u;break}}}return{x:d,rowIncreaseWidth:u}}}class Sd{draw;options;range;listener;eventBus;position;historyManager;defaultStyle;lastRangeStyle;constructor(t){this.draw=t,this.options=t.getOptions(),this.listener=t.getListener(),this.eventBus=t.getEventBus(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.range={startIndex:-1,endIndex:-1},this.defaultStyle=null,this.lastRangeStyle=null}_isSameRangeStyle(t,e){if(!t||!["type","undo","redo","painter","font","size","bold","italic","underline","strikeout","deletePerson","color","highlight","rowFlex","vertical","rowMargin","level","listType","listStyle","textDecoration","extension"].every(c=>t[c]===e[c])||!(t.dashArray.length===e.dashArray.length&&t.dashArray.every((c,d)=>c===e.dashArray[d])))return!1;const r=t.groupIds||[],a=e.groupIds||[];return r.length===a.length&&r.every((c,d)=>c===a[d])}_emitRangeStyle(t){this._isSameRangeStyle(this.lastRangeStyle,t)||(this.lastRangeStyle={...t,dashArray:[...t.dashArray],groupIds:t.groupIds?[...t.groupIds]:null},this.listener.rangeStyleChange?.(t),this.eventBus.isSubscribe("rangeStyleChange")&&this.eventBus.emit("rangeStyleChange",t))}getRange(){return this.range}clearRange(){this.setRange(-1,-1)}setDefaultStyle(t){t?this.defaultStyle={...this.defaultStyle,...t}:this.defaultStyle=null}getDefaultStyle(){return this.defaultStyle}getRangeAnchorStyle(t,e){const n=Zn(t,e);return n?{...n,...this.defaultStyle}:null}getIsRangeChange(t,e,n,i,l,r,a){return this.range.startIndex!==t||this.range.endIndex!==e||this.range.tableId!==n||this.range.startTdIndex!==i||this.range.endTdIndex!==l||this.range.startTrIndex!==r||this.range.endTrIndex!==a}getIsCollapsed(){const{startIndex:t,endIndex:e}=this.range;return t===e}getIsSelection(){const{startIndex:t,endIndex:e}=this.range;return!~t&&!~e?!1:t!==e}getSelection(){const{startIndex:t,endIndex:e,splitTdRange:n}=this.range;if(t===e)return null;if(n)return this.draw.getSplitTdValues(n.originalId).slice(n.startIndex+1,n.endIndex+1);const i=this.draw.getElementList();return i.slice(i[t]?.value===K?t:t+1,e+1)}getSelectionElementList(){if(this.range.isCrossRowCol){const t=this.draw.getTableParticle().getRangeRowCol();if(!t)return null;const e=[];for(let n=0;n<t.length;n++){const i=t[n];for(let l=0;l<i.length;l++){const r=i[l];e.push(...r.value)}}return e}return this.getSelection()}getTextLikeSelection(){const t=this.getSelection();return t?t.filter(e=>!e.type||Le.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Le.includes(e.type)):null}getRangeRow(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=new Map;for(let l=t;l<e+1;l++){const{pageNo:r,rowNo:a}=n[l],c=i.get(r);c?c.has(a)||c.add(a):i.set(r,new Set([a]))}return i}getRangeRowElementList(){const{startIndex:t,endIndex:e,isCrossRowCol:n}=this.range;if(!~t&&!~e)return null;if(n)return this.getSelectionElementList();const i=this.getRangeRow();if(!i)return null;const l=this.position.getPositionList(),r=this.draw.getElementList(),a=[];for(let c=0;c<l.length;c++){const d=l[c],u=i.get(d.pageNo);u&&u.has(d.rowNo)&&a.push(r[c])}return a}getRangeParagraph(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;const n=this.position.getPositionList(),i=this.draw.getElementList(),l=new Map;let r=t;for(;r>=0;){const{pageNo:d,rowNo:u}=n[r];let h=l.get(d);h||(h=[],l.set(d,h)),h.includes(u)||h.unshift(u);const R=i[r],f=i[r-1];if(R.value===K&&!R.listWrap||R.listId!==f?.listId||R.titleId!==f?.titleId)break;r--}const a=t===e;if(!a){let d=t+1;for(;d<e;){const{pageNo:u,rowNo:h}=n[d];let R=l.get(u);R||(R=[],l.set(u,R)),R.includes(h)||R.push(h),d++}}let c=e;for(a&&i[t].value===K&&(c+=1);c<n.length;){const d=i[c],u=i[c+1];if(d.value===K&&!d.listWrap||d.listId!==u?.listId||d.titleId!==u?.titleId)break;const{pageNo:h,rowNo:R}=n[c];let f=l.get(h);f||(f=[],l.set(h,f)),f.includes(R)||f.push(R),c++}return l}getRangeParagraphInfo(){const{startIndex:t,endIndex:e}=this.range;if(!~t&&!~e)return null;let n=-1;const i=[],l=this.getRangeParagraph();if(!l)return null;const r=this.draw.getElementList(),a=this.position.getPositionList();for(let c=0;c<a.length;c++){const d=a[c],u=l.get(d.pageNo);u&&u.includes(d.rowNo)&&(~n||(n=d.index),i.push(r[c]))}return i.length?{elementList:i,startIndex:n}:null}getRangeParagraphElementList(){return this.getRangeParagraphInfo()?.elementList||null}getRangeTableElement(){const t=this.position.getPositionContext();return t.isTable?this.draw.getOriginalElementList()[t.index]:null}getIsSelectAll(){const t=this.draw.getElementList(),{startIndex:e,endIndex:n}=this.range;return e===0&&t.length-1===n&&!this.position.getPositionContext().isTable}getIsPointInRange(t,e,n){const{startIndex:i,endIndex:l}=this.range,r=this.position.getPositionList();for(let a=i+1;a<=l&&r[a];a++){const{coordinate:{leftTop:d,rightBottom:u},pageNo:h}=r[a];if(n===h&&t>=d[0]&&t<=u[0]&&e>=d[1]&&e<=u[1])return!0}return!1}getKeywordRangeList(t){const e=this.draw.getSearch().getMatchList(t,this.draw.getOriginalElementList()),n=new Map;for(const l of e){const r=n.get(l.groupId);if(r)r.endIndex+=1;else{const{type:a,groupId:c,tableId:d,index:u,tdIndex:h,trIndex:R}=l,f={startIndex:u,endIndex:u};a===Ke.TABLE&&(f.tableId=d,f.startTdIndex=h,f.endTdIndex=h,f.startTrIndex=R,f.endTrIndex=R),n.set(c,f)}}const i=[];return n.forEach(l=>{i.push(l)}),i}getIsCanInput(){const{range:{startIndex:t,endIndex:e},elementList:n}=this.getRangeElement(),i=n[t];if(!i)return!1;if(t===e)return(i.controlComponent!==s.ControlComponent.PRE_TEXT||n[t+1]?.controlComponent!==s.ControlComponent.PRE_TEXT)&&i.controlComponent!==s.ControlComponent.POST_TEXT;const l=n[e];return l?!i.controlId&&!l.controlId||(!i.controlId||i.controlComponent===s.ControlComponent.POSTFIX)&&(!l.controlId||l.controlComponent===s.ControlComponent.POSTFIX)||!!i.controlId&&l.controlId===i.controlId&&l.controlComponent!==s.ControlComponent.PRE_TEXT&&l.controlComponent!==s.ControlComponent.POST_TEXT&&l.controlComponent!==s.ControlComponent.POSTFIX:!1}setRange(t,e,n,i,l,r,a,c){this.getIsRangeChange(t,e,n,i,l,r,a)&&(this.range.startIndex=t,this.range.endIndex=e,this.range.tableId=n,this.range.startTdIndex=i,this.range.endTdIndex=l,this.range.startTrIndex=r,this.range.endTrIndex=a,this.range.isCrossRowCol=!!(i||l||r||a),this.range.splitTdRange=c,this.setDefaultStyle(null)),this.range.zone=this.draw.getZone().getZone();const u=this.draw.getControl();if(~t&&~e&&!!this.draw.getElementList()[t]?.controlId&&!this.draw.isContentReadonly()){u.initControl();return}u.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}shrinkRange(){const{startIndex:t,endIndex:e}=this.range;t===e||!~t&&!~e||this.replaceRange({...this.range,startIndex:e})}setRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:i,isCrossRowCol:l}=this.range;if(!~n&&!~i)return;let r;if(l){const E=this.draw.getOriginalElementList(),W=this.position.getPositionContext();r=E[W.index]}else{const E=~i?i:0,W=this.draw.getElementList();r=this.getRangeAnchorStyle(W,E)}if(!r)return;const a=this.getSelection()||[r],c=r.type||s.ElementType.TEXT,d=r.font||this.options.defaultFont,u=r.size||this.options.defaultSize,h=!~a.findIndex(E=>!E.bold),R=!~a.findIndex(E=>!E.italic),f=!~a.findIndex(E=>!E.underline&&!E.control?.underline),g=!~a.findIndex(E=>!E.strikeout),T=r.color||null,C=r.highlight||null,p=r.rowFlex||null,I=r.vertical||null,m=r.rowMargin??this.options.defaultRowMargin,L=r.dashArray||[],P=r.level||null,M=r.listType||null,F=r.listStyle||null,N=f&&r.textDecoration||null,Y=!!this.draw.getPainterStyle(),b=this.historyManager.isCanUndo(),S=this.historyManager.isCanRedo(),y=r.groupIds||null,V=r.extension??null,X=r.deletePerson??"",O={type:c,undo:b,redo:S,painter:Y,font:d,size:u,bold:h,italic:R,underline:f,strikeout:g,deletePerson:X,color:T,highlight:C,rowFlex:p,vertical:I,rowMargin:m,dashArray:L,level:P,listType:M,listStyle:F,groupIds:y,textDecoration:N,extension:V};this._emitRangeStyle(O)}recoveryRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const n=this.options.defaultFont,i=this.options.defaultSize,l=this.options.defaultRowMargin,r=!!this.draw.getPainterStyle(),a=this.historyManager.isCanUndo(),c=this.historyManager.isCanRedo(),u={type:null,undo:a,redo:c,painter:r,font:n,size:i,bold:!1,italic:!1,underline:!1,strikeout:!1,deletePerson:"123",color:null,highlight:null,rowFlex:null,rowMargin:l,dashArray:[],level:null,listType:null,listStyle:null,groupIds:null,textDecoration:null,extension:null,vertical:null};this._emitRangeStyle(u)}shrinkBoundary(t={}){const{elementList:e,range:n}=this.getRangeElement(t),{startIndex:i,endIndex:l}=n;if(!~i&&!~l)return;const r=e[i],a=e[l];if(i===l){if(r.controlComponent===s.ControlComponent.PLACEHOLDER&&r.originControlId&&r.control?.type==="text")return;if(r.controlComponent===s.ControlComponent.PLACEHOLDER){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId===r.controlId&&(d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){n.startIndex=c,n.endIndex=c;break}if(d.controlId!==r.controlId&&!d.originControlId)break;c--}}if(r.controlComponent===s.ControlComponent.TEXTFIXLABEL){let c=i-1;for(;c>0;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===s.ControlComponent.VALUE||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;break}c--}}}else{if(r.controlComponent===s.ControlComponent.PLACEHOLDER||a.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.TEXTFIXLABEL||a.controlComponent===s.ControlComponent.TEXTFIXLABEL){let c=l-1;for(;c>0;){const d=e[c];if(d.controlId!==a.controlId||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){n.startIndex=c,n.endIndex=c;return}c--}}if(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PRETEXTFIX||r.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===s.ControlComponent.VALUE){n.startIndex=c-1;break}else if(d.controlComponent===s.ControlComponent.PLACEHOLDER){n.startIndex=c-1,n.endIndex=c-1;return}c++}}if(a.controlComponent!==s.ControlComponent.VALUE){let c=l-1;for(;c>0;){const d=e[c];if(d.controlId!==r.controlId||d.controlComponent===s.ControlComponent.VALUE){n.endIndex=c;break}else if(d.controlComponent===s.ControlComponent.PLACEHOLDER){n.startIndex=c,n.endIndex=c;return}c--}}}}render(t,e,n,i,l){t.save(),t.globalAlpha=this.options.rangeAlpha,t.fillStyle=this.options.rangeColor,t.fillRect(e,n,i,l),t.restore()}toString(){const t=this.getTextLikeSelection();return t?t.map(e=>e.value).join("").replace(new RegExp(K,"g"),""):""}getRangeElement(t={}){const e=t.elementList||this.draw.getElementList(),n=t.range||this.getRange(),{splitTdRange:i}=n,l={elementList:e,range:n};return i&&(l.range=i,l.elementList=this.draw.getSplitTdValues(i.originalId)??[]),l}}class Dd{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}_renderBackgroundColor(t,e,n,i){t.save(),t.fillStyle=e,t.fillRect(0,0,n,i),t.restore()}_drawImage(t,e,n,i){const{background:l,scale:r}=this.options;if(l.size===s.BackgroundSize.CONTAIN){const a=e.width*r,c=e.height*r;if(!l.repeat||l.repeat===s.BackgroundRepeat.NO_REPEAT)t.drawImage(e,0,0,a,c);else{let d=0,u=0;const h=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_X?Math.ceil(n*r/a):1,R=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_Y?Math.ceil(i*r/c):1;for(let f=0;f<h;f++){for(let g=0;g<R;g++)t.drawImage(e,d,u,a,c),u+=c;u=0,d+=a}}}else t.drawImage(e,0,0,n*r,i*r)}_renderBackgroundImage(t,e,n){const{background:i}=this.options,l=this.imageCache.get(i.image);if(l)this._drawImage(t,l,e,n);else{const r=new Image;r.setAttribute("crossOrigin","Anonymous"),r.src=i.image,r.onload=()=>{this.imageCache.set(i.image,r),this._drawImage(t,r,e,n),this.draw.render({isCompute:!1,isSubmitHistory:!1})}}}render(t,e){const{background:{image:n,color:i,applyPageNumbers:l}}=this.options;if(n&&(!l?.length||l.includes(e))){const{width:r,height:a}=this.options;this._renderBackgroundImage(t,r,a)}else{const r=this.draw.getCanvasWidth(e),a=this.draw.getCanvasHeight(e);this._renderBackgroundColor(t,i,r,a)}}}class Ai{fillRect;fillColor;fillDecorationStyle;constructor(){this.fillRect=this.clearFillInfo()}clearFillInfo(){return this.fillColor=void 0,this.fillDecorationStyle=void 0,this.fillRect={x:0,y:0,width:0,height:0},this.fillRect}recordFillInfo(t,e,n,i,l,r,a){const c=!this.fillRect.width;if(!c&&(this.fillColor!==r||this.fillDecorationStyle!==a)){this.render(t),this.clearFillInfo(),this.recordFillInfo(t,e,n,i,l,r,a);return}c&&(this.fillRect.x=e,this.fillRect.y=n),l&&this.fillRect.height<l&&(this.fillRect.height=l),this.fillRect.width+=i,this.fillColor=r,this.fillDecorationStyle=a}}class Fd extends Ai{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{highlightAlpha:e}=this.options,{x:n,y:i,width:l,height:r}=this.fillRect;t.save(),t.globalAlpha=e,t.fillStyle=this.fillColor,t.fillRect(n,i,l,r),t.restore(),this.clearFillInfo()}}class Xd{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{marginIndicatorColor:n,pageMode:i}=this.options,l=this.draw.getWidth(),r=i===s.PageMode.CONTINUITY?this.draw.getCanvasHeight(e)/this.draw.getPagePixelRatio():this.draw.getHeight(),a=this.draw.getMargins(),c=this.draw.getMarginIndicatorSize();t.save(),t.translate(.5,.5),t.strokeStyle=n,t.beginPath();const d=[a[3],a[0]],u=[l-a[1],a[0]],h=[a[3],r-a[2]],R=[l-a[1],r-a[2]];t.moveTo(d[0]-c,d[1]),t.lineTo(...d),t.lineTo(d[0],d[1]-c),t.moveTo(u[0]+c,u[1]),t.lineTo(...u),t.lineTo(u[0],u[1]-c),t.moveTo(h[0]-c,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+c),t.moveTo(R[0]+c,R[1]),t.lineTo(...R),t.lineTo(R[0],R[1]+c),t.stroke(),t.restore()}}class Nd{draw;options;position;range;searchKeyword;searchNavigateIndex;searchOptions;searchMatchList;constructor(t){this.draw=t,this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.searchNavigateIndex=null,this.searchOptions=null,this.searchKeyword=null,this.searchMatchList=[]}getSearchKeyword(){return this.searchKeyword}setSearchKeyword(t,e){this.searchKeyword=t,this.searchNavigateIndex=null,this.searchOptions=e||null}searchNavigatePre(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex-1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t>=0;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t-(this.searchKeyword.length-1);break}t--}if(!e){if(this.searchMatchList[this.searchMatchList.length-1].groupId===n)return null;this.searchNavigateIndex=this.searchMatchList.length-1-(this.searchKeyword.length-1)}}return this.searchNavigateIndex}searchNavigateNext(){if(!this.searchMatchList.length||!this.searchKeyword)return null;if(this.searchNavigateIndex===null)this.searchNavigateIndex=0;else{let t=this.searchNavigateIndex+1,e=!1;const n=this.searchMatchList[this.searchNavigateIndex].groupId;for(;t<this.searchMatchList.length;){const i=this.searchMatchList[t];if(n!==i.groupId){e=!0,this.searchNavigateIndex=t;break}t++}if(!e){if(this.searchMatchList[0].groupId===n)return null;this.searchNavigateIndex=0}}return this.searchNavigateIndex}searchNavigateScrollIntoView(t){const{coordinate:{leftTop:e,leftBottom:n,rightTop:i},pageNo:l}=t,r=this.draw.getHeight(),a=this.draw.getPageGap(),c=l*(r+a),d=document.createElement("div");d.style.position="absolute";const u=50;d.style.width=`${i[0]-e[0]+u}px`,d.style.height=`${n[1]-e[1]+u}px`,d.style.left=`${e[0]}px`,d.style.top=`${e[1]+c}px`,this.draw.getContainer().append(d),d.scrollIntoView(!1),d.remove()}getSearchNavigateIndexList(){return this.searchNavigateIndex===null||!this.searchKeyword?[]:new Array(this.searchKeyword.length).fill(this.searchNavigateIndex).map((t,e)=>t+e)}getSearchMatchList(){return this.searchMatchList}getSearchNavigateInfo(){if(!this.searchKeyword||!this.searchMatchList.length)return null;const t=this.searchNavigateIndex!==null?this.searchNavigateIndex/this.searchKeyword.length+1:0;let e=0,n=null;for(let i=0;i<this.searchMatchList.length;i++){const l=this.searchMatchList[i];n!==l.groupId&&(n=l.groupId,e+=1)}return{index:t,count:e}}getMatchList(t,e){const{isRegEnable:n=!1,isIgnoreCase:i=!0}=this.searchOptions||{},l=i?t.toLocaleLowerCase():t,r=[],a=[],c=e.length,d=[];for(let f=0;f<c;f++)e[f].type===s.ElementType.TABLE&&d.push(f);let u=0,h=0;for(;h<c-1;){const f=d.length?d[u]:c,g=e.slice(h,f);g.length&&a.push({index:h,type:Ke.PAGE,elementList:g});const T=e[f];T&&a.push({index:f,type:Ke.TABLE,elementList:[T]}),h=f+1,u++}function R(f,g,T,C){if(!f)return;let p=T.map(M=>!M.type||Le.includes(M.type)&&M.controlComponent!==s.ControlComponent.CHECKBOX&&M.controlComponent!==s.ControlComponent.RADIO&&!M.hide&&!M.control?.hide&&!M.area?.hide?M.value:K).filter(Boolean).join("");i&&(p=p.toLocaleLowerCase());const I=[],m=n?new RegExp(f):f;let{index:L,length:P}=Zs(p,m);for(;L!==-1&&P!==0;){I.push({index:L,length:P});const M=Zs(p,m,L+P);L=M.index,P=M.length}for(let M=0;M<I.length;M++){const{index:F,length:N}=I[M],Y=mt();for(let b=0;b<N;b++){const S=F+b+(C?.startIndex||0);r.push({type:g,index:S,groupId:Y,...C})}}}for(let f=0;f<a.length;f++){const g=a[f];if(g.type===Ke.TABLE){const T=g.elementList[0];for(let C=0;C<T.trList.length;C++){const p=T.trList[C];for(let I=0;I<p.tdList.length;I++){const m=p.tdList[I],L={tableId:T.id,tableIndex:g.index,trIndex:C,tdIndex:I,tdId:m.id};R(l,g.type,m.value,L)}}}else R(l,g.type,g.elementList,{startIndex:g.index})}return r}compute(t){const e=this.searchOptions?.isLimitSelection&&!this.range.getIsCollapsed(),n=e?this.range.getSelectionElementList():this.draw.getOriginalElementList();if(!n?.length||(this.searchMatchList=this.getMatchList(t,n),!e||!this.searchMatchList.length))return;const{startIndex:i}=this.range.getRange(),l=i+1;for(const r of this.searchMatchList)r.type===Ke.TABLE?r.tableIndex+=l:r.index+=l}render(t,e){if(!this.searchMatchList||!this.searchMatchList.length||!this.searchKeyword)return;const{searchMatchAlpha:n,searchMatchColor:i,searchNavigateMatchColor:l}=this.options,r=this.position.getOriginalPositionList(),a=this.draw.getOriginalElementList();t.save(),t.globalAlpha=n;for(let c=0;c<this.searchMatchList.length;c++){const d=this.searchMatchList[c];let u=null;if(d.type===Ke.TABLE){const{tableIndex:L,trIndex:P,tdIndex:M,index:F}=d;u=a[L]?.trList[P].tdList[M]?.positionList[F]}else u=r[d.index];if(!u)continue;const{coordinate:{leftTop:h,leftBottom:R,rightTop:f},pageNo:g}=u;if(g!==e)continue;if(this.getSearchNavigateIndexList().includes(c)){t.fillStyle=l;const L=this.searchMatchList[c-1];(!L||L.groupId!==d.groupId)&&this.searchNavigateScrollIntoView(u)}else t.fillStyle=i;const C=h[0],p=h[1],I=f[0]-h[0],m=R[1]-h[1];t.fillRect(C,p,I,m)}t.restore()}replace(t,e){if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const l=e?.index;if(fi(l)){const T=[];i.forEach(C=>{const p=T[T.length-1];!p||p[0].groupId!==C.groupId?T.push([C]):p.push(C)}),i=T[l]}if(!i?.length)return;const r=this.draw.isDesignMode();let a=0,c=0,d="",u="",h=-1;const R=this.draw.getOriginalElementList();for(let T=0;T<i.length;T++){const C=i[T];if(C.type===Ke.TABLE){const{tableIndex:p,trIndex:I,tdIndex:m,index:L,tdId:P}=C;u&&P!==u&&(c=0),u=P;const M=p+a,F=R[M].trList[I].tdList[m].value,N=L+c,Y=F[N];if(!r&&(Y?.control?.deletable===!1||Y?.title?.deletable===!1))continue;if(t===""){this.draw.spliceElementList(F,N,1),c--,~h||(h=T);continue}if(d===C.groupId){this.draw.spliceElementList(F,N,1),c--;continue}~h||(h=T);for(let b=0;b<t.length;b++){const S=t[b];b===0?Y.value=S:(this.draw.spliceElementList(F,N+b,0,[{...Y,value:S}]),c++)}}else{const p=C.index+a,I=R[p];if(!r&&(I?.control?.deletable===!1||I?.title?.deletable===!1)||I.type===s.ElementType.CONTROL&&I.controlComponent!==s.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(R,p,1),a--,~h||(h=T);continue}if(~h||(h=T),d===C.groupId){this.draw.spliceElementList(R,p,1),a--;continue}for(let m=0;m<t.length;m++){const L=t[m];m===0?I.value=L:(this.draw.spliceElementList(R,p+m,0,[{...I,value:L}]),a++)}}d=C.groupId}if(!~h)return;const f=i[h],g=f.index+(t.length-1);if(f.type===Ke.TABLE){const{tableIndex:T,trIndex:C,tdIndex:p,index:I}=f,m=R[T].trList[C].tdList[p].value[I];this.position.setPositionContext({isTable:!0,index:T,trIndex:C,tdIndex:p,tdId:m.tdId,trId:m.trId,tableId:m.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(g,g),this.draw.render({curIndex:g})}}class yd extends Ai{options;constructor(t){super(),this.options=t.getOptions()}render(t){if(!this.fillRect.width)return;const{scale:e,strikeoutColor:n}=this.options,{x:i,y:l,width:r}=this.fillRect;t.save(),t.lineWidth=e,t.strokeStyle=n;const a=l-3;t.beginPath(),t.moveTo(i,a),t.lineTo(i+r,a),t.stroke(),t.beginPath(),t.moveTo(i,l+3.5),t.lineTo(i+r,l+3.5),t.stroke(),t.restore(),this.clearFillInfo()}}s.TextDecorationStyle=void 0,(function(o){o.SOLID="solid",o.DOUBLE="double",o.DASHED="dashed",o.DOTTED="dotted",o.WAVY="wavy"})(s.TextDecorationStyle||(s.TextDecorationStyle={}));var An;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(An||(An={}));class bd extends Ai{options;constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,l){const r=e+i;switch(t.beginPath(),l){case An.DASHED:t.setLineDash([3,1]);break;case An.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(r,n),t.stroke()}_drawDouble(t,e,n,i){const r=e+i,a=n+3*this.options.scale;this.options.mode===s.EditorMode.PRINT||this.options.mode===s.EditorMode.COMPARE?t.strokeStyle="transparent":t.strokeStyle="red",t.beginPath(),t.moveTo(e,n),t.lineTo(r,n),t.stroke(),t.beginPath(),t.moveTo(e,a),t.lineTo(r,a),t.stroke()}_drawWave(t,e,n,i){const{scale:l}=this.options,r=1.2*l,a=1/l,c=n+2*r;t.beginPath();for(let d=0;d<i;d++){const u=r*Math.sin(a*d);t.lineTo(e+d,c+u)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:i,y:l,width:r}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const a=Math.floor(l+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case s.TextDecorationStyle.WAVY:this._drawWave(t,i,a,r);break;case s.TextDecorationStyle.DOUBLE:this._drawDouble(t,i,a,r);break;case s.TextDecorationStyle.DASHED:this._drawLine(t,i,a,r,An.DASHED);break;case s.TextDecorationStyle.DOTTED:this._drawLine(t,i,a,r,An.DOTTED);break;default:this._drawLine(t,i,a,r);break}t.restore(),this.clearFillInfo()}}class Vd{draw;options;ctx;curX;curY;text;curStyle;curColor;cacheMeasureText;constructor(t){this.draw=t,this.options=t.getOptions(),this.ctx=t.getCtx(),this.curX=-1,this.curY=-1,this.text="",this.curStyle="",this.cacheMeasureText=new Map}measureBasisWord(t,e){t.save(),t.font=e;const n=this.measureText(t,{value:sa});return t.restore(),n}measureWord(t,e,n){const i=this.draw.getLetterReg();let l=0,r=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==s.ElementType.TEXT||!i.test(c.value)){r=c;break}l+=this.measureText(t,c).width,a++}return{width:l,endElement:r}}buttonMeasureWord(t,e,n){const i=this.draw.getLetterReg();let l=0,r=null,a=n;for(;a<e.length;){const c=e[a];if(c.type&&c.type!==s.ElementType.TEXT||!i.test(c.value)){r=c;break}l+=this.measureText(t,c).width,a++}return{width:l,endElement:r}}measurePunctuationWidth(t,e){return!e||!ia.includes(e.value)?0:(t.font=this.draw.getElementFont(e),this.measureText(t,e).width)}measureText(t,e){if(e.width){const r=t.measureText(e.value);return{width:e.width,actualBoundingBoxAscent:r.actualBoundingBoxAscent,actualBoundingBoxDescent:r.actualBoundingBoxDescent,actualBoundingBoxLeft:r.actualBoundingBoxLeft,actualBoundingBoxRight:r.actualBoundingBoxRight,fontBoundingBoxAscent:r.fontBoundingBoxAscent,fontBoundingBoxDescent:r.fontBoundingBoxDescent}}const n=`${e.value}${t.font}`,i=this.cacheMeasureText.get(n);if(i)return i;const l=t.measureText(e.value);return this.cacheMeasureText.set(n,l),l}getBasisWordBoundingBoxAscent(t,e){return this.measureBasisWord(t,e).actualBoundingBoxAscent}complete(){this._render(),this.text=""}record(t,e,n,i){if(this.ctx=t,this.options.renderMode===s.RenderMode.COMPATIBILITY){this._setCurXY(n,i),this.text=e.value,this.curStyle=e.style,this.curColor=e.color,this.complete();return}this.text||this._setCurXY(n,i),(this.curStyle&&e.style!==this.curStyle||e.color!==this.curColor)&&(this.complete(),this._setCurXY(n,i)),this.text+=e.value,this.curStyle=e.style,this.curColor=e.color}_setCurXY(t,e){this.curX=t,this.curY=e}_render(){!this.text||!~this.curX||!~this.curX||(this.ctx.save(),this.ctx.font=this.curStyle,this.ctx.fillStyle=this.curColor||this.options.defaultColor,this.ctx.fillText(this.text,this.curX,this.curY),this.ctx.restore())}}class _n{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const l=i===s.NumberType.CHINESE?Ta(e):`${e}`;return t.replace(n,l)}render(t,e){const{scale:n,pageNumber:{size:i,font:l,color:r,rowFlex:a,numberType:c,format:d,startPageNo:u,fromPageNo:h}}=this.options;if(e<h)return;let R=d;const f=new RegExp(oo.PAGE_NO);f.test(R)&&(R=_n.formatNumberPlaceholder(R,e+u-h,f,c));const g=new RegExp(oo.PAGE_COUNT);g.test(R)&&(R=_n.formatNumberPlaceholder(R,this.draw.getPageCount()-h,g,c));const T=this.draw.getWidth(),C=this.draw.getHeight(),p=this.draw.getPageNumberBottom(),I=C-p;t.save(),t.fillStyle=r,t.font=`${i*n}px ${l}`;let m=0;const L=this.draw.getMargins(),{width:P}=t.measureText(R);a===s.RowFlex.CENTER?m=(T-P)/2:a===s.RowFlex.RIGHT?m=T-P-L[1]:m=L[3],t.fillText(R,m,I),t.restore()}}class Wd{draw;options;scrollContainer;constructor(t){this.draw=t,this.options=t.getOptions(),this.scrollContainer=this.getScrollContainer(),setTimeout(()=>{window.scrollY||this._observer()}),this._addEvent()}getScrollContainer(){return this.options.scrollContainerSelector&&document.querySelector(this.options.scrollContainerSelector)||document}_addEvent(){this.scrollContainer.addEventListener("scroll",this._observer)}removeEvent(){this.scrollContainer.removeEventListener("scroll",this._observer)}getElementVisibleInfo(t){const e=t.getBoundingClientRect(),n=this.scrollContainer===document?Math.max(document.documentElement.clientHeight,window.innerHeight):this.scrollContainer.clientHeight,i=Math.min(e.bottom,n)-Math.max(e.top,0);return{intersectionHeight:i>0?i:0}}getPageVisibleInfo(){const t=this.draw.getPageList(),e=[];let n=0,i=0;for(let l=0;l<t.length;l++){const r=t[l],{intersectionHeight:a}=this.getElementVisibleInfo(r);if(i&&!a)break;a&&e.push(l),a>i&&(i=a,n=l)}return{intersectionPageNo:n,visiblePageNoList:e}}_observer=ua(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150)}class Yd{draw;step=5;thresholdPoints=[70,40,10,20];selectionContainer;rangeManager;requestAnimationFrameId;isMousedown;isMoving;clientWidth;clientHeight;containerRect;constructor(t){this.draw=t,this.rangeManager=t.getRange();const{scrollContainerSelector:e}=t.getOptions();this.selectionContainer=e&&document.querySelector(e)||document,this.requestAnimationFrameId=null,this.isMousedown=!1,this.isMoving=!1,this.clientWidth=0,this.clientHeight=0,this.containerRect=null,this._addEvent()}_addEvent(){const t=this.selectionContainer;t.addEventListener("mousedown",this._mousedown),t.addEventListener("mousemove",this._mousemove),t.addEventListener("mouseup",this._mouseup),document.addEventListener("mouseleave",this._mouseup)}removeEvent(){const t=this.selectionContainer;t.removeEventListener("mousedown",this._mousedown),t.removeEventListener("mousemove",this._mousemove),t.removeEventListener("mouseup",this._mouseup),document.removeEventListener("mouseleave",this._mouseup)}_mousedown=t=>{if(this.draw.isInteractionSuspended()){this._mouseup();return}if(!this.draw.isTargetInsideEditor(t.target)){this._mouseup();return}if(this.isMousedown=!0,this.clientWidth=this.selectionContainer instanceof Document?document.documentElement.clientWidth:this.selectionContainer.clientWidth,this.clientHeight=this.selectionContainer instanceof Document?document.documentElement.clientHeight:this.selectionContainer.clientHeight,!(this.selectionContainer instanceof Document)){const e=this.selectionContainer.getBoundingClientRect();this.containerRect=e}};_mouseup=()=>{this.isMousedown=!1,this._stopMove()};_mousemove=t=>{if(this.draw.isInteractionSuspended()||!this.isMousedown||this.rangeManager.getIsCollapsed())return;let{x:e,y:n}=t;this.containerRect&&(e=e-this.containerRect.x,n=n-this.containerRect.y),n<this.thresholdPoints[0]?this._startMove(Jt.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove(Jt.DOWN):e<this.thresholdPoints[2]?this._startMove(Jt.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(Jt.RIGHT):this._stopMove()};_move(t){const e=this.selectionContainer instanceof Document?window:this.selectionContainer,n=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,i=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Jt.DOWN?e.scrollTo(n,i+this.step):t===Jt.UP?e.scrollTo(n,i-this.step):t===Jt.LEFT?e.scrollTo(n-this.step,i):e.scrollTo(n+this.step,i),this.requestAnimationFrameId=window.requestAnimationFrame(this._move.bind(this,t))}_startMove(t){this.isMoving||(this.isMoving=!0,this._move(t))}_stopMove(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=null,this.isMoving=!1)}}class Ud{draw;range;options;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=at(t);for(let n=0;n<t.length;n++){const i=e[n];for(let l=i.tdList.length-1;l>=0;l--){const r=i.tdList[l],{rowspan:a,rowIndex:c,colIndex:d}=r,u=c+a-1;if(u!==l){const h=i.tdList.splice(l,1)[0];e[u]?.tdList.splice(d,0,h)}}}return e}getRangeRowCol(){const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.draw.getPosition().getPositionContext();if(!t)return null;const{isCrossRowCol:l,startTdIndex:r,endTdIndex:a,startTrIndex:c,endTrIndex:d}=this.range.getRange(),R=this.draw.getOriginalElementList()[e].trList;if(!l)return[[R[n].tdList[i]]];let f=R[c].tdList[r],g=R[d].tdList[a];(f.x>g.x||f.y>g.y)&&([f,g]=[g,f]);const T=f.colIndex,C=g.colIndex+(g.colspan-1),p=f.rowIndex,I=g.rowIndex+(g.rowspan-1),m=[];for(let L=0;L<R.length;L++){const P=R[L],M=[];for(let F=0;F<P.tdList.length;F++){const N=P.tdList[F],Y=N.colIndex,b=N.rowIndex;Y>=T&&Y<=C&&b>=p&&b<=I&&M.push(N)}M.length&&m.push(M)}return m.length?m:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:i,width:l,height:r,isDrawFullBorder:a,borderExternalWidth:c,skipTopBorderRanges:d=[]}=t,{scale:u}=this.options,h=this._mergeHorizontalBorderRanges(d,l),R=e.lineWidth;c&&(e.lineWidth=c*u),e.beginPath();const f=Math.round(n),g=Math.round(i);e.translate(.5,.5),a&&!h.length?e.rect(f,g,l,r):(a?(e.moveTo(f,g),e.lineTo(f,g+r),e.lineTo(f+l,g+r),e.lineTo(f+l,g)):(e.moveTo(f,g+r),e.lineTo(f,g)),this._drawHorizontalBorder(e,f,g,l,h)),e.stroke(),c&&(e.lineWidth=R),e.translate(-.5,-.5)}_drawHorizontalBorder(t,e,n,i,l){if(!l.length){t.lineTo(e+i,n);return}let r=0;l.forEach(([a,c])=>{r<a&&(t.moveTo(e+r,n),t.lineTo(e+a,n)),r=Math.max(r,c)}),r<i&&(t.moveTo(e+r,n),t.lineTo(e+i,n))}_mergeHorizontalBorderRanges(t,e){return t.map(([i,l])=>[Math.max(0,Math.min(i,e)),Math.max(0,Math.min(l,e))]).filter(([i,l])=>l>i).sort(([i],[l])=>i-l).reduce((i,l)=>{const r=i[i.length-1];return!r||l[0]>r[1]?i.push(l):l[1]>r[1]&&(r[1]=l[1]),i},[])}_getPagingContinuationTopBorderRanges(t,e){const{scale:n}=this.options,i=[];for(let l=0;l<t.length;l++){const r=t[l];for(let a=0;a<r.tdList.length;a++){const c=r.tdList[a];!c.linkTdPrevId||c.y!==0||i.push([c.x*n,(c.x+c.width)*n])}}return this._mergeHorizontalBorderRanges(i,e)}_drawSlash(t,e,n,i){const{scale:l}=this.options;t.save();const r=e.width*l,a=e.height*l,c=Math.round(e.x*l+n),d=Math.round(e.y*l+i);e.slashTypes?.includes(s.TdSlash.FORWARD)&&(t.moveTo(c+r,d),t.lineTo(c,d+a)),e.slashTypes?.includes(s.TdSlash.BACK)&&(t.moveTo(c,d),t.lineTo(c+r,d+a)),t.stroke(),t.restore()}_drawBorder(t,e,n,i){const{colgroup:l,trList:r,borderType:a,borderColor:c,borderWidth:d=1,borderExternalWidth:u}=e;if(!l||!r)return;const{scale:h,table:{defaultBorderColor:R}}=this.options,f=e.width*h,g=e.height*h,T=this._getPagingContinuationTopBorderRanges(r,f),C=a===s.TableBorder.EMPTY,p=a===s.TableBorder.EXTERNAL,I=a===s.TableBorder.INTERNAL;t.save(),a===s.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=d*h,t.strokeStyle=c||R,!C&&!I&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:f,height:g,borderExternalWidth:u,isDrawFullBorder:p,skipTopBorderRanges:T});for(let m=0;m<r.length;m++){const L=r[m];for(let P=0;P<L.tdList.length;P++){const M=L.tdList[P];if(M.slashTypes?.length&&this._drawSlash(t,M,n,i),!M.borderTypes?.length&&(C||p))continue;const F=M.width*h,N=M.height*h,Y=Math.round(M.x*h+n+F),b=Math.round(M.y*h+i),S=!!M.linkTdPrevId,y=!!M.linkTdNextId;if(t.translate(.5,.5),t.beginPath(),!S&&M.borderTypes?.includes(s.TdBorder.TOP)&&(t.moveTo(Y-F,b),t.lineTo(Y,b),t.stroke()),M.borderTypes?.includes(s.TdBorder.RIGHT)&&(t.moveTo(Y,b),t.lineTo(Y,b+N),t.stroke()),M.borderTypes?.includes(s.TdBorder.BOTTOM)&&(t.moveTo(Y,b+N),t.lineTo(Y-F,b+N),t.stroke()),M.borderTypes?.includes(s.TdBorder.LEFT)&&(t.moveTo(Y-F,b),t.lineTo(Y-F,b+N),t.stroke()),!C&&!p){if((!I||M.colIndex+M.colspan<l.length)&&(t.moveTo(Y,b),t.lineTo(Y,b+N),u&&u!==d&&M.colIndex+M.colspan===l.length)){const V=t.lineWidth;t.lineWidth=u*h,t.stroke(),t.beginPath(),t.lineWidth=V}if(y||!I||M.rowIndex+M.rowspan<r.length){const V=u&&u!==d&&M.rowIndex+M.rowspan===r.length;if(V&&(t.stroke(),t.beginPath()),t.moveTo(Y,b+N),t.lineTo(Y-F,b+N),V){const X=t.lineWidth;t.lineWidth=u*h,t.stroke(),t.beginPath(),t.lineWidth=X}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,i){const{trList:l}=e;if(!l)return;const{scale:r}=this.options;for(let a=0;a<l.length;a++){const c=l[a];for(let d=0;d<c.tdList.length;d++){const u=c.tdList[d];if(!u.backgroundColor)continue;t.save();const h=u.width*r,R=u.height*r,f=Math.round(u.x*r+n),g=Math.round(u.y*r+i);t.fillStyle=u.backgroundColor,t.fillRect(f,g,h,R),t.restore()}}}getTableWidth(t){return t.colgroup.reduce((e,n)=>e+n.width,0)}getTableHeight(t){const e=t.trList;return e?.length?this.getTdListByColIndex(e,0).reduce((n,i)=>n+i.height,0):0}getRowCountByColIndex(t,e){return this.getTdListByColIndex(t,e).reduce((n,i)=>n+i.rowspan,0)}getTdListByColIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const l=t[i].tdList;for(let r=0;r<l.length;r++){const a=l[r],c=a.colIndex,d=c+a.colspan-1;e>=c&&e<=d&&n.push(a)}}return n}getTdListByRowIndex(t,e){const n=[];for(let i=0;i<t.length;i++){const l=t[i].tdList;for(let r=0;r<l.length;r++){const a=l[r],c=a.rowIndex,d=c+a.rowspan-1;e>=c&&e<=d&&n.push(a)}}return n}computeRowColInfo(t){const{colgroup:e,trList:n}=t;if(!e||!n)return;let i=0;for(let l=0;l<n.length;l++){const r=n[l],a=n.length-1===l;for(let c=0;c<r.tdList.length;c++){const d=r.tdList[c];let u=0;if(n.length>1&&l!==0){const p=r.tdList[c-1],I=p?p.colIndex+p.colspan:c;for(let m=I;m<e.length;m++)if(this.getRowCountByColIndex(n.slice(0,l),m)===l){u=m;let P=0;for(let M=0;M<m;M++)P+=e[M].width;i=P;break}}else{const p=r.tdList[c-1];p&&(u=p.colIndex+p.colspan)}let h=0;for(let p=0;p<d.colspan;p++)h+=e[p+u].width;let R=0;for(let p=0;p<d.rowspan;p++){const I=n[p+l]||n[l];R+=I.height}const f=r.tdList.length-1===c;let g=a;if(!g&&d.rowspan>1){const p=n.length-1-l;g=d.rowspan-1===p}const T=a&&f;d.isLastRowTd=f,d.isLastColTd=g,d.isLastTd=T,d.x=i;let C=0;for(let p=0;p<l;p++){const I=n[p].tdList;for(let m=0;m<I.length;m++){const L=I[m];if(u>=L.colIndex&&u<L.colIndex+L.colspan){C+=L.height;break}}}d.y=C,d.width=h,d.height=R,d.rowIndex=l,d.colIndex=u,d.trIndex=l,d.tdIndex=c,i+=h,f&&!T&&(i=0)}}}drawRange(t,e,n,i){const{scale:l,rangeAlpha:r,rangeColor:a}=this.options,{type:c,trList:d}=e;if(!d||c!==s.ElementType.TABLE)return;const{isCrossRowCol:u,startTdIndex:h,endTdIndex:R,startTrIndex:f,endTrIndex:g}=this.range.getRange();if(!u)return;let T=d[f].tdList[h],C=d[g].tdList[R];(T.x>C.x||T.y>C.y)&&([T,C]=[C,T]);const p=T.colIndex,I=C.colIndex+(C.colspan-1),m=T.rowIndex,L=C.rowIndex+(C.rowspan-1);t.save();for(let P=0;P<d.length;P++){const M=d[P];for(let F=0;F<M.tdList.length;F++){const N=M.tdList[F],Y=N.colIndex,b=N.rowIndex;if(Y>=p&&Y<=I&&b>=m&&b<=L){const S=N.x*l,y=N.y*l,V=N.width*l,X=N.height*l;t.globalAlpha=r,t.fillStyle=a,t.fillRect(S+n,y+i,V,X)}}}t.restore()}render(t,e,n,i){this._drawBackgroundColor(t,e,n,i),this._drawBorder(t,e,n,i)}findPreRowSpanTd(t,e,n){for(let i=e;i>=0;i--){const l=t[i].tdList.find(r=>r.colIndex===n);if(l)return l}}computeTrHeight(t,e){const{scale:n,table:{tdPadding:i,defaultTrMinHeight:l}}=this.options,r=t.tdPadding||i,a=r[0]+r[2],c=t.trList;for(let h=0;h<c.length;h++){const R=c[h];R.height=R.minHeight||l,R.minHeight=R.height}this.computeRowColInfo(t);const d={},u={};for(let h=0;h<c.length;h++){const R=c[h];if(!R.tdList.length){R.height=0;continue}const f=[],g=[];for(let C=0;C<t.colgroup.length;C++){const p=R.tdList.find(I=>I.colIndex===C);if(p){const I=e?e(p):p.rowList,m=I.reduce((P,M)=>P+M.height,0);p.rowList=I;const L=m/n+a;p.mainHeight=L,p.rowspan>1?(u[p.colIndex]=p.id,d[p.id]={td:p,rowSpan:[h,h+p.rowspan-1],preHeight:0,preMinHeight:0,extraHeight:L},g.push(L)):p.height<L?(p.height=L,p.realHeight=L,f.push(L)):f.push(p.height)}else{const I=d[u[C]];I?.rowSpan[1]==h&&f.push(I.extraHeight)}}const T=Math.max(...f.length?f:g);Object.values(d).forEach(C=>{C.rowSpan[0]<=h&&C.rowSpan[1]>=h&&(C.extraHeight-=T,C.preHeight+=T,C.preMinHeight+=R.minHeight)}),R.height=T;for(let C=0;C<t.colgroup.length;C++){const p=R.tdList.find(I=>I.colIndex===C)??this.findPreRowSpanTd(c,h,C);if(p){const I=d[p.id]?.preHeight??0,m=d[p.id]?.preMinHeight??R.minHeight;p.height=T+I,p.realHeight=T+I,p.realMinHeight=m}}}this.computeRowColInfo(t)}}var _e;(function(o){o.ROW="row",o.COL="col"})(_e||(_e={}));class wd{MIN_TD_WIDTH=20;ROW_COL_OFFSET=18;ROW_COL_QUICK_WIDTH=16;ROW_COL_QUICK_OFFSET=5;ROW_COL_QUICK_POSITION=this.ROW_COL_OFFSET+(this.ROW_COL_OFFSET-this.ROW_COL_QUICK_WIDTH)/2;BORDER_VALUE=4;TABLE_SELECT_OFFSET=20;draw;canvas;options;position;range;container;toolRowContainer;toolRowAddBtn;toolColAddBtn;toolTableSelectBtn;toolColContainer;toolBorderContainer;anchorLine;mousedownX;mousedownY;constructor(t){this.draw=t,this.canvas=t.getPage(),this.options=t.getOptions(),this.position=t.getPosition(),this.range=t.getRange(),this.container=t.getContainer(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null,this.anchorLine=null,this.mousedownX=0,this.mousedownY=0}dispose(){this.toolRowContainer?.remove(),this.toolRowAddBtn?.remove(),this.toolColAddBtn?.remove(),this.toolTableSelectBtn?.remove(),this.toolColContainer?.remove(),this.toolBorderContainer?.remove(),this.toolRowContainer=null,this.toolRowAddBtn=null,this.toolColAddBtn=null,this.toolTableSelectBtn=null,this.toolColContainer=null,this.toolBorderContainer=null}render(){if(this.draw.getMode()===s.EditorMode.FORM){this.dispose();return}const{isTable:t,index:e,trIndex:n,tdIndex:i}=this.position.getPositionContext();if(!t)return;this.dispose();const l=this.draw.getOriginalElementList(),r=this.position.getOriginalPositionList(),a=l[e];if(a.tableToolDisabled&&!this.draw.isDesignMode())return;const{scale:c,table:{overflow:d}}=this.options,u=r[e],{colgroup:h,trList:R}=a,{coordinate:{leftTop:f}}=u,g=this.draw.getHeight(),T=this.draw.getPageGap(),C=this.draw.getPageNo()*(g+T),p=f[0],I=f[1]+C,m=a.trList[n].tdList[i],L=m.rowIndex,P=m.colIndex,M=a.height*c,F=a.width*c,N=document.createElement("div");N.classList.add(`${rt}-table-tool__select`),N.style.height=`${M*c}`,N.style.left=`${p}px`,N.style.top=`${I}px`,N.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*c}px, ${-this.TABLE_SELECT_OFFSET*c}px)`,N.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(N),this.toolTableSelectBtn=N;const Y=R.map(E=>E.height),b=document.createElement("div");b.classList.add(`${rt}-table-tool__row`),b.style.transform=`translateX(-${this.ROW_COL_OFFSET*c}px)`;for(let E=0;E<Y.length;E++){const W=Y[E]*c,D=document.createElement("div");D.classList.add(`${rt}-table-tool__row__item`),E===L&&D.classList.add("active"),D.onclick=()=>{const Z=this.draw.getTableParticle().getTdListByRowIndex(R,E),Q=Z[0],v=Z[Z.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:Q.trIndex,tdIndex:Q.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,Q.tdIndex,v.tdIndex,Q.trIndex,v.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(b,E)};const U=document.createElement("div");U.classList.add(`${rt}-table-tool__anchor`),U.onmousedown=Z=>{this._mousedown({evt:Z,element:a,index:E,order:_e.ROW})},D.append(U),D.style.height=`${W}px`,b.append(D)}b.style.left=`${p}px`,b.style.top=`${I}px`,this.container.append(b),this.toolRowContainer=b;const S=document.createElement("div");S.classList.add(`${rt}-table-tool__quick__add`),S.style.height=`${M*c}`,S.style.left=`${p}px`,S.style.top=`${I+M}px`,S.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*c}px, ${this.ROW_COL_QUICK_OFFSET*c}px)`,S.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:R.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(S),this.toolRowAddBtn=S;const y=h.map(E=>E.width),V=document.createElement("div");V.classList.add(`${rt}-table-tool__col`),V.style.transform=`translateY(-${this.ROW_COL_OFFSET*c}px)`;for(let E=0;E<y.length;E++){const W=y[E]*c,D=document.createElement("div");D.classList.add(`${rt}-table-tool__col__item`),E===P&&D.classList.add("active"),D.onclick=()=>{const Z=this.draw.getTableParticle().getTdListByColIndex(R,E),Q=Z[0],v=Z[Z.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:Q.trIndex,tdIndex:Q.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,Q.tdIndex,v.tdIndex,Q.trIndex,v.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(V,E)};const U=document.createElement("div");U.classList.add(`${rt}-table-tool__anchor`),U.onmousedown=Z=>{this._mousedown({evt:Z,element:a,index:E,order:_e.COL})},D.append(U),D.style.width=`${W}px`,V.append(D)}V.style.left=`${p}px`,V.style.top=`${I}px`,this.container.append(V),this.toolColContainer=V;const X=document.createElement("div");X.classList.add(`${rt}-table-tool__quick__add`),X.style.height=`${M*c}`,X.style.left=`${p+F}px`,X.style.top=`${I}px`,X.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*c}px, -${this.ROW_COL_QUICK_POSITION*c}px)`,X.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:R[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(X),this.toolColAddBtn=X;const O=document.createElement("div");O.classList.add(`${rt}-table-tool__border`),O.style.height=`${M}px`,O.style.width=`${F}px`,O.style.left=`${p}px`,O.style.top=`${I}px`;for(let E=0;E<R.length;E++){const W=R[E];for(let D=0;D<W.tdList.length;D++){const U=W.tdList[D],Z=document.createElement("div");Z.classList.add(`${rt}-table-tool__border__row`),Z.style.width=`${U.width*c}px`,Z.style.height=`${this.BORDER_VALUE}px`,Z.style.top=`${(U.y+U.height)*c-this.BORDER_VALUE/2}px`,Z.style.left=`${U.x*c}px`,Z.onmousedown=v=>{this._mousedown({evt:v,element:a,index:U.rowIndex+U.rowspan-1,order:_e.ROW})},O.appendChild(Z);const Q=document.createElement("div");if(Q.classList.add(`${rt}-table-tool__border__col`),Q.style.width=`${this.BORDER_VALUE}px`,Q.style.height=`${U.height*c}px`,Q.style.top=`${U.y*c}px`,Q.style.left=`${(U.x+U.width)*c-this.BORDER_VALUE/2}px`,Q.onmousedown=v=>{this._mousedown({evt:v,element:a,index:U.colIndex+U.colspan-1,order:_e.COL})},O.appendChild(Q),d&&U.colIndex===0){const v=document.createElement("div");v.classList.add(`${rt}-table-tool__border__col`),v.style.width=`${this.BORDER_VALUE}px`,v.style.height=`${U.height*c}px`,v.style.top=`${U.y*c}px`,v.style.left=`${U.x*c-this.BORDER_VALUE/2}px`,v.onmousedown=st=>{this._mousedown({evt:st,element:a,index:0,isLeftStartBorder:!0,order:_e.COL})},O.appendChild(v)}}}this.container.append(O),this.toolBorderContainer=O}_setAnchorActive(t,e){const n=t.children;for(let i=0;i<n.length;i++){const l=n[i];i===e?l.classList.add("active"):l.classList.remove("active")}}_mousedown(t){const{evt:e,index:n,order:i,element:l,isLeftStartBorder:r}=t;this.canvas=this.draw.getPage();const{scale:a,table:{overflow:c}}=this.options,d=this.draw.getWidth(),u=this.draw.getHeight(),h=this.draw.getPageGap(),R=this.draw.getPageNo()*(u+h),f=this.position.getPositionContext(),C=(this.position.getOriginalPositionList()[f.index]?.coordinate?.leftTop?.[0]||0)*a,p=this.draw.getMargins(),I=p[0],m=p[1],L=I,P=d-m;this.mousedownX=e.x,this.mousedownY=e.y;const M=e.target,F=this.canvas.getBoundingClientRect(),N=window.getComputedStyle(M).cursor;document.body.style.cursor=N,this.canvas.style.cursor=N;let Y=0,b=0;const S=document.createElement("div");S.classList.add(`${rt}-table-anchor__line`),i===_e.ROW?(S.classList.add(`${rt}-table-anchor__line__row`),S.style.width=`${d}px`,Y=0,b=R+this.mousedownY-F.top):(S.classList.add(`${rt}-table-anchor__line__col`),S.style.height=`${u}px`,Y=this.mousedownX-F.left,b=R),S.style.left=`${Y}px`,S.style.top=`${b}px`,this.container.append(S),this.anchorLine=S;let y=0,V=0;const X=O=>{const E=this._mousemove(O,i,Y,b);E&&(y=E.dx,V=E.dy)};document.addEventListener("mousemove",X),document.addEventListener("mouseup",()=>{let O=!1;if(i===_e.ROW){const E=l.trList,W=E[n]||E[n-1],{defaultTrMinHeight:D}=this.options.table;V<0&&W.height+V<D&&(V=D-W.height),V&&(W.height+=V,W.minHeight=W.height,O=!0)}else{const{colgroup:E}=l;if(E&&y)if(c&&r){E[n].width-y/a<=this.MIN_TD_WIDTH&&(y=(E[n].width-this.MIN_TD_WIDTH)*a);const W=C+(l.translateX||0)*a;W+y<L&&(y=L-W),E[n].width-=y/a,l.width-=y/a,l.translateX=(l.translateX||0)+y/a,O=!0}else{const W=E[n].width;y<0&&W*a+y<this.MIN_TD_WIDTH*a&&(y=this.MIN_TD_WIDTH*a-W*a);const D=E[n+1]?.width;if(y>0&&D&&D*a-y<this.MIN_TD_WIDTH*a&&(y=D*a-this.MIN_TD_WIDTH*a),n===E.length-1){const Z=C+(l.translateX||0)*a+l.width*a;Z+y>P&&(y=P-Z)}y&&(E.length-1!==n&&(E[n+1].width-=y/a),E[n].width+=y/a,O=!0)}}O&&this.draw.render({isSetCursor:!1}),S.remove(),document.removeEventListener("mousemove",X),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,i){if(!this.anchorLine)return null;const l=t.x-this.mousedownX,r=t.y-this.mousedownY;return e===_e.ROW?this.anchorLine.style.top=`${i+r}px`:this.anchorLine.style.left=`${n+l}px`,t.preventDefault(),{dx:l,dy:r}}}class Zd{draw;options;container;hyperlinkPopupContainer;hyperlinkDom;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:n}=this._createHyperlinkPopupDom();this.hyperlinkDom=n,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${rt}-hyperlink-popup`);const e=document.createElement("a");return e.target="_blank",e.rel="noopener",t.append(e),this.container.append(t),{hyperlinkPopupContainer:t,hyperlinkDom:e}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[n,i]},lineHeight:l}=e,r=this.draw.getHeight(),a=this.draw.getPageGap(),c=this.draw.getPageNo()*(r+a);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${i+c+l}px`;const d=t.url||"#";this.hyperlinkDom.href=d,this.hyperlinkDom.title=d,this.hyperlinkDom.innerText=d}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,i){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),t.fillText(e.value,n,i),t.restore()}}class vd{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:l,label:{defaultBackgroundColor:r,defaultColor:a,defaultBorderRadius:c,defaultPadding:d}}=this.options,u=e.label?.backgroundColor||r,h=e.label?.color||a,R=e.label?.borderRadius||c,f=e.label?.padding||d;t.save(),t.font=e.style;const{width:g,height:T,boundingBoxAscent:C}=e.metrics;t.fillStyle=u,this._drawRoundedRect(t,n,i-C,g,T+(f[0]+f[3])*l,R*l),t.fill(),t.fillStyle=h,t.fillText(e.value,n+f[3]*l,i),t.restore()}_drawRoundedRect(t,e,n,i,l,r){t.beginPath(),t.moveTo(e+r,n),t.lineTo(e+i-r,n),t.quadraticCurveTo(e+i,n,e+i,n+r),t.lineTo(e+i,n+l-r),t.quadraticCurveTo(e+i,n+l,e+i-r,n+l),t.lineTo(e+r,n+l),t.quadraticCurveTo(e,n+l,e,n+l-r),t.lineTo(e,n+r),t.quadraticCurveTo(e,n,e+r,n),t.closePath()}}class Qd{options;draw;activeInlineEditor;constructor(t){this.draw=t,this.options=t.getOptions(),this.activeInlineEditor=null}render(t,e,n,i){const l=this.draw.getMode(),r=e.macroConfig;if(l===s.EditorMode.READONLY&&e.type!=="subTemplate"){this._renderPlainText(t,e,n,i,Xo(e));return}if(l===s.EditorMode.EDIT){const c=e.label||e.value||"";this._renderEditMode(t,e,n,i,c);return}if(e.type==="macro"){const c=e.label||"",d=e.value||`获取 ${c}`;this._renderPlainText(t,e,n,i,d);return}if(e.type==="customMacro"){const c=r?.type||"text",d=r?.value||"",u=e.label||"";if(l===s.EditorMode.FORM)c==="select"?this._renderSelectControl(t,e,n,i,d):this._renderTextControl(t,e,n,i,d);else{const h=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,h)}return}if(e.type==="reusableItem"){const d=e.reusableItemConfig?.value||"",u=e.label||"";if(l===s.EditorMode.FORM)this._renderTextControl(t,e,n,i,d);else{const h=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,h)}return}if(e.type==="subTemplate"){const c=e.label||"子模板";l===s.EditorMode.FORM?e.subTemplateExpanded||this._renderEditMode(t,e,n,i,c):this._renderPlainText(t,e,n,i,c);return}const a=e.value||e.label||"";this._renderPlainText(t,e,n,i,a)}activateInlineEditor(t,e,n){const i=t.type===s.ElementType.CUSTOM_MACRO,l=t.type===s.ElementType.REUSABLE_ITEM;if(this.draw.getMode()!==s.EditorMode.FORM||!i&&!l)return!1;const r=i?this._ensureMacroConfig(t):void 0,a=r?.type||"text",c=this.activeInlineEditor;if(c&&c.elementId===t.id&&c.elementType===t.type&&(t.id||c.index===e)&&c.type===a){if(a==="text"){const f=this._getCursorOffset(t,e,n);c.cursorOffset=f,c.selectionOffset=f,this._syncInlineCursor()}return this._focusInputAgent(),!0}this.clearInlineEditor();const d=f=>{const g=f.target,T=this.activeInlineEditor?.popup;g instanceof Node&&T?.contains(g)||g!==this.draw.getCursor().getAgentDom()&&this.clearInlineEditor()},u=this._getCursorOffset(t,e,n),h=this.draw.getPosition(),R=h.getPositionList()[e];return this.draw.getRange().setRange(e,e),R&&h.setCursorPosition(R),this.activeInlineEditor={elementId:t.id,index:e,elementType:t.type,type:a,popup:null,cursorOffset:u,selectionOffset:u,compositionRange:null,initialValue:this._getInlineEditorValue(t),initialCode:r?.code,initialUnderline:t.underline,initialStrikeout:t.strikeout,initialTextDecoration:t.textDecoration?{...t.textDecoration}:void 0,outsideHandler:d},window.setTimeout(()=>{this.activeInlineEditor?.outsideHandler===d&&document.addEventListener("mousedown",d,!0)}),a==="select"?(this._createSelectPopup(t),this.draw.getCursor().recoveryCursor()):this._syncInlineCursor(),this._focusInputAgent(),!0}input(t,e=!1){const n=this.activeInlineEditor;if(!n||n.type!=="text"||!t)return!1;const i=t.replace(/[\r\n]/g,"");if(!i)return!0;const l=this._getInlineEditorElement(n);if(!l)return this.clearInlineEditor({isSubmitHistory:!1}),!0;const r=Array.from(this._getInlineEditorValue(l));let a=Math.min(n.cursorOffset,n.selectionOffset),c=Math.max(n.cursorOffset,n.selectionOffset);e&&n.compositionRange&&(a=n.compositionRange.start,c=n.compositionRange.end);const d=Array.from(i);r.splice(a,c-a,...d);const u=a+d.length;return n.cursorOffset=u,n.selectionOffset=u,n.compositionRange=e?{start:a,end:u}:null,this._setInlineEditorValue(l,r.join("")),this._renderActiveEditor(),!0}compositionStart(){const t=this.activeInlineEditor;return!t||t.type!=="text"?!1:(t.compositionRange={start:Math.min(t.cursorOffset,t.selectionOffset),end:Math.max(t.cursorOffset,t.selectionOffset)},!0)}compositionEnd(t){const e=this.activeInlineEditor;if(!e||e.type!=="text")return!1;if(e.compositionRange){const n=this._getInlineEditorElement(e);if(n){if(!t){const r=Array.from(this._getInlineEditorValue(n));return r.splice(e.compositionRange.start,e.compositionRange.end-e.compositionRange.start),e.cursorOffset=e.compositionRange.start,e.selectionOffset=e.cursorOffset,this._setInlineEditorValue(n,r.join("")),this._renderActiveEditor(),e.compositionRange=null,!0}const i=this._getInlineEditorValue(n),l=Array.from(i).slice(e.compositionRange.start,e.compositionRange.end).join("");t&&l!==t&&this.input(t,!0)}}else t&&this.input(t);return e.compositionRange=null,!0}keydown(t){const e=this.activeInlineEditor;if(!e)return!1;if(e.type==="select")return t.key==="Escape"&&this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0}),t.key==="Escape"||t.key==="Enter"||t.key==="Backspace"||t.key==="Delete"||t.key.startsWith("Arrow")?(t.preventDefault(),t.stopImmediatePropagation(),!0):!1;const n=this._getInlineEditorElement(e);if(!n)return!1;const i=Array.from(this._getInlineEditorValue(n)),l=Math.min(e.cursorOffset,e.selectionOffset),r=Math.max(e.cursorOffset,e.selectionOffset),a=l!==r;if((t.ctrlKey||t.metaKey)&&t.key.toLowerCase()==="a")e.selectionOffset=0,e.cursorOffset=i.length,this._renderActiveEditor();else if(t.key==="ArrowLeft"||t.key==="ArrowRight"){const c=t.key==="ArrowLeft"?-1:1;!t.shiftKey&&a?(e.cursorOffset=c<0?l:r,e.selectionOffset=e.cursorOffset):(e.cursorOffset=Math.max(0,Math.min(i.length,e.cursorOffset+c)),t.shiftKey||(e.selectionOffset=e.cursorOffset)),this._renderActiveEditor()}else if(t.key==="Home"||t.key==="End")e.cursorOffset=t.key==="Home"?0:i.length,t.shiftKey||(e.selectionOffset=e.cursorOffset),this._renderActiveEditor();else if(t.key==="Backspace"||t.key==="Delete")a?(i.splice(l,r-l),e.cursorOffset=l):t.key==="Backspace"&&e.cursorOffset>0?(i.splice(e.cursorOffset-1,1),e.cursorOffset--):t.key==="Delete"&&e.cursorOffset<i.length&&i.splice(e.cursorOffset,1),e.selectionOffset=e.cursorOffset,this._setInlineEditorValue(n,i.join("")),this._renderActiveEditor();else if(t.key==="Enter"||t.key==="Tab")this.clearInlineEditor();else if(t.key==="Escape")this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0});else return!1;return t.preventDefault(),t.stopImmediatePropagation(),!0}clearInlineEditor(t={}){const e=this.activeInlineEditor;if(!e)return;this.activeInlineEditor=null;const{isSubmitHistory:n=!0,isRestore:i=!1}=t;document.removeEventListener("mousedown",e.outsideHandler,!0);const l=this._getInlineEditorElement(e);if(l&&i&&this._restoreInlineEditorValue(l,e),e.popup?.remove(),l){const r=this._getInlineEditorValue(l),a=l.macroConfig?.code,c=r!==e.initialValue||a!==e.initialCode;this.draw.render({curIndex:e.index,isSubmitHistory:c&&!i&&n})}}_renderPlainText(t,e,n,i,l){t.save(),t.font=e.style,t.fillStyle=e.color||"#000000",t.textBaseline="alphabetic",t.fillText(l,n,i),t.restore()}_renderEditMode(t,e,n,i,l){const{scale:r}=this.options,a=e.type==="customMacro",c=e.type==="reusableItem",d=e.type==="subTemplate";let u,h;d?(u="#722ed1",h="#f9f0ff"):c?(u="#52c41a",h="#f6ffed"):a?(u="#fa8c16",h="#fff7e6"):(u="#1677ff",h="#e6f4ff"),t.save(),t.font=e.style;const R=t.measureText(l),f=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent,g=8*r,T=4*r,C=4*r,p=R.width+g*2,I=f+T*2,m=e.metrics,L=n,P=i-m.boundingBoxAscent+(m.boundingBoxAscent+m.boundingBoxDescent-I)/2;t.fillStyle=h,this._drawRoundedRect(t,L,P,p,I,C),t.fill(),t.fillStyle=u,t.textBaseline="middle",t.fillText(l,n+g,P+I/2),t.restore()}_renderTextControl(t,e,n,i,l){const{control:r}=this.options,{placeholderColor:a}=r;t.save(),t.font=e.style;const d=`请输入${e.label||""}`,u=l||d,R=t.measureText(u).width;t.fillStyle=this._getControlColor(e),t.textBaseline="alphabetic",t.fillText("[",n,i);const f=n+t.measureText("[").width;this._renderTextSelection(t,e,f,i,l),t.fillStyle=l?this._getValueColor(e):a,t.fillText(u,f,i);const g=f+R;t.fillStyle=this._getControlColor(e),t.fillText("]",g,i),t.restore()}_renderSelectControl(t,e,n,i,l){const{scale:r,control:a}=this.options,{placeholderColor:c}=a;t.save(),t.font=e.style;const u=`请选择${e.label||""}`,h=l||u,R=t.measureText(h),f=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent;t.fillStyle=this._getControlColor(e),t.textBaseline="alphabetic",t.fillText("[",n,i);const g=n+t.measureText("[").width;t.fillStyle=l?this._getValueColor(e):c,t.fillText(h,g,i);const T=g+R.width+2*r,C=i-f/2;t.beginPath(),t.moveTo(T,C-2*r),t.lineTo(T+5*r,C-2*r),t.lineTo(T+2.5*r,C+2*r),t.closePath(),t.fillStyle=this._getControlColor(e),t.fill();const p=T+6*r;t.fillStyle=this._getControlColor(e),t.fillText("]",p,i),t.restore()}_drawRoundedRect(t,e,n,i,l,r){t.beginPath(),t.moveTo(e+r,n),t.lineTo(e+i-r,n),t.quadraticCurveTo(e+i,n,e+i,n+r),t.lineTo(e+i,n+l-r),t.quadraticCurveTo(e+i,n+l,e+i-r,n+l),t.lineTo(e+r,n+l),t.quadraticCurveTo(e,n+l,e,n+l-r),t.lineTo(e,n+r),t.quadraticCurveTo(e,n,e+r,n),t.closePath()}_createSelectPopup(t){const e=this.activeInlineEditor;if(!e)return;const n=this._ensureMacroConfig(t);if(!n.items?.length)return;const i=this._getInlineEditorPosition(e);if(!i)return;const l=document.createElement("div");l.classList.add(`${rt}-select-control-popup`,`${rt}-macro-select-popup`),l.setAttribute(Ze,s.EditorComponent.POPUP),l.style.setProperty("--COLOR-HOVER",this._getControlColor(t));const r=document.createElement("ul"),a=n.code||n.items?.find(h=>h.value===n.value)?.code||"";n.items.forEach(h=>{const R=document.createElement("li");R.textContent=h.value,R.dataset.code=h.code,h.code===a&&R.classList.add("active"),R.onclick=()=>{const f=h.code===a?"":h.code;this._setInlineEditorValue(t,"",f),this.clearInlineEditor()},r.append(R)}),l.append(r);const c=i.pageNo*(this.draw.getHeight()+this.draw.getPageGap()),[d,u]=i.coordinate.leftTop;l.style.left=`${d}px`,l.style.top=`${u+c+i.lineHeight}px`,this.draw.getContainer().append(l),e.popup=l}_getCursorOffset(t,e,n){const i=Array.from(this._getInlineEditorValue(t));if(n===void 0||!i.length)return i.length;const l=this.draw.getPosition().getPositionList()[e];if(!l)return i.length;const r=this.draw.getCtx();r.save(),r.font=this.draw.getElementFont(t);const a=l.coordinate.leftTop[0]+r.measureText("[").width;let c=0;for(let d=0;d<i.length;d++){const u=r.measureText(i[d]).width;if(n<a+c+u/2)return r.restore(),d;c+=u}return r.restore(),i.length}_focusInputAgent(){window.setTimeout(()=>{this.activeInlineEditor&&this.draw.getCursor().focus()})}_renderActiveEditor(){const t=this.activeInlineEditor;t&&(this.draw.render({curIndex:t.index,isSubmitHistory:!1}),this._syncInlineCursor())}_syncInlineCursor(){const t=this.activeInlineEditor;if(!t||t.type!=="text")return;const e=this._getInlineEditorElement(t),n=this._getInlineEditorPosition(t);if(!e||!n)return;const i=this.draw.getCtx();i.save(),i.font=this.draw.getElementFont(e);const l=Array.from(this._getInlineEditorValue(e)).slice(0,t.cursorOffset).join(""),r=n.coordinate.leftTop[0]+i.measureText("[").width+i.measureText(l).width;i.restore();const a=this.draw.getCursor(),c=a.getCursorDom(),{scale:d}=this.options,u=Qs*d,h=Math.min(n.metrics.height/4,u),R=n.metrics.height+h*2,f=Math.max(n.metrics.boundingBoxDescent,0),g=n.pageNo*(this.draw.getHeight()+this.draw.getPageGap()),T=n.coordinate.leftTop[1]+n.ascent+f-(R-h)+g,C=a.getAgentDom();c.style.left=`${r}px`,c.style.top=`${T}px`,c.style.height=`${R}px`,c.style.backgroundColor=this._getControlColor(e),c.style.display="block",C.style.left=`${r}px`,C.style.top=`${T+R-u}px`}_renderTextSelection(t,e,n,i,l){const r=this.activeInlineEditor;if(!r||r.type!=="text"||!l||!this._getIsActiveElement(e,r))return;const a=Math.min(r.cursorOffset,r.selectionOffset),c=Math.max(r.cursorOffset,r.selectionOffset);if(a===c)return;const d=Array.from(l),u=n+t.measureText(d.slice(0,a).join("")).width,h=t.measureText(d.slice(a,c).join("")).width,R=t.measureText(l);t.save(),t.globalAlpha=.2,t.fillStyle=this._getControlColor(e),t.fillRect(u,i-R.actualBoundingBoxAscent,h,R.actualBoundingBoxAscent+R.actualBoundingBoxDescent),t.restore()}_getIsActiveElement(t,e){const n=this._getInlineEditorElement(e);return!!(n&&(n===t||n.id&&n.id===t.id))}_getControlColor(t){return t.type===s.ElementType.REUSABLE_ITEM?"#1677ff":"#fa8c16"}_getValueColor(t){return t.color||this.options.defaultColor}_getInlineEditorElement(t){const e=this.draw.getElementList()[t.index];return e?.id===t.elementId?e:t.elementId?this.draw.getElementList().find(n=>n.id===t.elementId)||null:e||null}_getInlineEditorPosition(t){return this.draw.getPosition().getPositionList()[t.index]||null}_ensureMacroConfig(t){return t.macroConfig||(t.macroConfig={type:"text"}),t.macroConfig}_getInlineEditorValue(t){return t.type===s.ElementType.REUSABLE_ITEM?t.reusableItemConfig?.value||"":t.macroConfig?.value||""}_setInlineEditorValue(t,e,n){if(t.type===s.ElementType.REUSABLE_ITEM){t.reusableItemConfig?t.reusableItemConfig.value=e:t.reusableItemConfig={value:e};return}const i=this._ensureMacroConfig(t);i.type==="select"?(i.code=n||void 0,i.value=this._getSelectLabelByCode(i,n)):i.value=e}_restoreInlineEditorValue(t,e){if(t.type===s.ElementType.REUSABLE_ITEM){this._setInlineEditorValue(t,e.initialValue),t.underline=e.initialUnderline,t.strikeout=e.initialStrikeout,t.textDecoration=e.initialTextDecoration;return}const n=this._ensureMacroConfig(t);n.value=e.initialValue,e.type==="select"&&(n.code=e.initialCode)}_getSelectLabelByCode(t,e){return e&&t.items?.find(n=>n.code===e)?.value||""}}class Kd{draw;position;zone;options;elementList;rowList;positionList;constructor(t,e){this.draw=t,this.position=t.getPosition(),this.zone=t.getZone(),this.options=t.getOptions(),this.elementList=e||[],this.rowList=[],this.positionList=[]}getRowList(){return this.rowList}setElementList(t){this.elementList=t}getElementList(){return this.elementList}getPositionList(){return this.positionList}compute(){this.recovery(),this._computeRowList(),this._computePositionList()}recovery(){this.rowList=[],this.positionList=[]}_computeRowList(){const t=this.draw.getInnerWidth(),e=this.draw.getMargins(),n=bi(this.elementList);this.rowList=this.draw.computeRowList({startX:e[3],startY:this.getHeaderTop(),innerWidth:t,elementList:this.elementList,surroundElementList:n})}_computePositionList(){const t=this.getHeaderTop(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],l=t;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:l,innerWidth:e,zone:s.EditorZone.HEADER})}getHeaderTop(){const{header:{top:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{header:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*ys[t])}getHeight(){if(this.options.header.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getHeaderTop()+e-t[0];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isHeaderActive()?1:this.options.header.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),l=[];let r=0;for(let a=0;a<this.rowList.length;a++){const c=this.rowList[a];if(r+c.height>i)break;l.push(c),r+=c.height}this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:l,pageNo:e,startIndex:0,innerWidth:n,zone:s.EditorZone.HEADER}),t.restore()}}class Hd{getOffsetY(t){return-t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class Ad{getOffsetY(t){return t.metrics.height/2}render(t,e,n,i){t.save(),t.font=e.style,e.color&&(t.fillStyle=e.color),t.fillText(e.value,n,i+this.getOffsetY(e)),t.restore()}}class _d{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){t.save();const{scale:l,separator:{lineWidth:r,strokeStyle:a}}=this.options;t.lineWidth=(e.lineWidth||r)*l,t.strokeStyle=e.color||a,e.dashArray?.length&&t.setLineDash(e.dashArray);const c=Math.round(i);t.translate(0,t.lineWidth/2),t.beginPath(),t.moveTo(n,c),t.lineTo(n+e.width*l,c),t.stroke(),t.restore()}}class Bd{draw;options;i18n;constructor(t){this.draw=t,this.options=t.getOptions(),this.i18n=t.getI18n()}render(t,e,n,i){const{pageBreak:{font:l,fontSize:r,lineDash:a}}=this.options,c=this.i18n.t("pageBreak.displayName"),{scale:d,defaultRowMargin:u}=this.options,h=r*d,R=e.width*d,f=this.draw.getDefaultBasicRowMarginHeight()*u;t.save(),t.font=`${h}px ${l}`;const g=t.measureText(c),T=(R-g.width)/2;t.setLineDash(a),t.translate(0,.5+f),t.beginPath(),t.moveTo(n,i),t.lineTo(n+T,i),t.moveTo(n+T+g.width,i),t.lineTo(n+R,i),t.stroke(),t.fillText(c,n+T,i+g.actualBoundingBoxAscent-h/2),t.restore()}}class kd{draw;options;imageCache;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map}renderText(t,e){const{watermark:{data:n,opacity:i,font:l,size:r,color:a,repeat:c,gap:d,numberType:u},scale:h}=this.options,R=this.draw.getWidth(),f=this.draw.getHeight();t.save(),t.globalAlpha=i,t.font=`${r*h}px ${l}`;let g=n;const T=new RegExp(oo.PAGE_NO);T.test(g)&&(g=_n.formatNumberPlaceholder(g,e+1,T,u));const C=new RegExp(oo.PAGE_COUNT);C.test(g)&&(g=_n.formatNumberPlaceholder(g,this.draw.getPageCount(),C,u));const p=t.measureText(g);if(c){const I=this.draw.getPagePixelRatio(),m=document.createElement("canvas"),L=m.getContext("2d"),P=p.width,M=p.actualBoundingBoxAscent+p.actualBoundingBoxDescent,F=Math.sqrt(Math.pow(P,2)+Math.pow(M,2)),N=F+2*d[0]*h,Y=F+2*d[1]*h;m.width=N,m.height=Y,m.style.width=`${N*I}px`,m.style.height=`${Y*I}px`,L.translate(N/2,Y/2),L.rotate(-45*Math.PI/180),L.translate(-N/2,-Y/2),L.font=`${r*h}px ${l}`,L.fillStyle=a,L.fillText(g,(N-P)/2,(Y-M)/2+p.actualBoundingBoxAscent);const b=t.createPattern(m,"repeat");b&&(t.fillStyle=b,t.fillRect(0,0,R,f))}else{const I=R/2,m=f/2;t.fillStyle=a,t.translate(I,m),t.rotate(-45*Math.PI/180),t.fillText(g,-p.width/2,p.actualBoundingBoxAscent-r*h/2)}t.restore()}renderImage(t){const{watermark:{width:e,height:n,data:i,opacity:l,repeat:r,gap:a},scale:c}=this.options;if(!this.imageCache.has(i)){const f=new Image;f.setAttribute("crossOrigin","Anonymous"),f.src=i,f.onload=()=>{this.imageCache.set(i,f),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const d=this.draw.getWidth(),u=this.draw.getHeight(),h=e*c,R=n*c;if(t.save(),t.globalAlpha=l,r){const f=this.draw.getPagePixelRatio(),g=document.createElement("canvas"),T=g.getContext("2d"),C=Math.sqrt(Math.pow(h,2)+Math.pow(R,2)),p=C+2*a[0]*c,I=C+2*a[1]*c;g.width=p,g.height=I,g.style.width=`${p*f}px`,g.style.height=`${I*f}px`,T.translate(p/2,I/2),T.rotate(-45*Math.PI/180),T.translate(-p/2,-I/2),T.drawImage(this.imageCache.get(i),(p-h)/2,(I-R)/2,h,R);const m=t.createPattern(g,"repeat");m&&(t.fillStyle=m,t.fillRect(0,0,d,u))}else{const f=d/2,g=u/2;t.translate(f,g),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(i),-h/2,-R/2,h,R)}t.restore()}render(t,e){this.options.watermark.type===s.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class Gd{draw;control;options;highlightList;highlightMatchResult;constructor(t){this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){const{control:{activeBackgroundColor:n,disabledBackgroundColor:i,existValueBackgroundColor:l,noValueBackgroundColor:r,inlineControlBackgroundColor:a}}=this.options,c=t[e],d=this.draw.isPrintLikeMode(),u=this.draw.getMode(),h=u===s.EditorMode.EDIT||u===s.EditorMode.FORM,R=this.control.getActiveControl()?.getElement(),f=this._getControlType(t,e);let g=!1,T=!1,C=!1,p=!1;c.highlight||(g=!d&&!!n&&!!R&&c.controlId===R.controlId&&!this.control.getIsRangeInPostfix()),g||(T=!d&&!!i&&!!c.control?.disabled),T||(C=!d&&!!l&&!!c.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),C||(p=!d&&!!r&&!!c.controlId&&!this.control.getIsExistValueByElementListIndex(t,e));const I=h&&!!a&&(f===s.ControlType.SELECT||f===s.ControlType.DATE);return(g?n:"")||(T?i:"")||(C?l:"")||(p?r:"")||(I?a:"")}getIsInlineControlBackground(t,e){const n=this.draw.getMode(),i=this._getControlType(t,e);return!!((n===s.EditorMode.EDIT||n===s.EditorMode.FORM)&&this.options.control.inlineControlBackgroundColor&&(i===s.ControlType.SELECT||i===s.ControlType.DATE))}_getControlType(t,e){const n=t[e];if(n.control?.type)return n.control.type;if(n.controlId){for(let i=e-1;i>=0;i--){const l=t[i];if(l.controlId!==n.controlId)break;if(l.control?.type)return l.control.type}for(let i=e+1;i<t.length;i++){const l=t[i];if(l.controlId!==n.controlId)break;if(l.control?.type)return l.control.type}}}getHighlightMatchResult(){return this.highlightMatchResult}getHighlightList(){return this.highlightList}setHighlightList(t){this.highlightList=t}computeHighlightList(){const t=this.draw.getSearch(),e=(n,i)=>{let l=0;for(;l<n.length;){const r=n[l];if(l++,r.type===s.ElementType.TABLE){const g=r.trList;for(let T=0;T<g.length;T++){const C=g[T];for(let p=0;p<C.tdList.length;p++){const I=C.tdList[p],m={tableId:r.id,tableIndex:l-1,trIndex:T,tdIndex:p,tdId:I.id};e(I.value,m)}}}const a=r?.control;if(!a)continue;const c=this.highlightList.findIndex(g=>g.id===r.controlId||a.conceptId&&a.conceptId===g.conceptId);if(!~c)continue;const d=l;let u=l;for(;u<n.length&&n[u].controlId===r.controlId;)u++;l=u;const h=n.slice(d,u).map(g=>g.controlComponent===s.ControlComponent.VALUE?g:{value:K}),R=this.highlightList[c],{ruleList:f}=R;for(let g=0;g<f.length;g++){const T=f[g],C=t.getMatchList(T.keyword,h);this.highlightMatchResult.push(...C.map(p=>({...p,...T,...i,index:p.index+d})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){if(!this.highlightMatchResult?.length)return;const{searchMatchAlpha:n,searchMatchColor:i}=this.options,l=this.draw.getPosition().getOriginalPositionList(),r=this.draw.getOriginalElementList();t.save();for(let a=0;a<this.highlightMatchResult.length;a++){const c=this.highlightMatchResult[a];let d=null;if(c.tableId){const{tableIndex:I,trIndex:m,tdIndex:L,index:P}=c;d=r[I]?.trList[m].tdList[L]?.positionList[P]}else d=l[c.index];if(!d)continue;const{coordinate:{leftTop:u,leftBottom:h,rightTop:R},pageNo:f}=d;if(f!==e)continue;t.fillStyle=c.backgroundColor||i,t.globalAlpha=c.alpha||n;const g=u[0],T=u[1],C=R[0]-u[0],p=h[1]-u[1];t.fillRect(g,T,C,p)}t.restore()}}const Or={error:{borderColor:"#ff4d4f",backgroundColor:"rgba(255,77,79,0.08)"},warning:{borderColor:"#faad14",backgroundColor:"rgba(250,173,20,0.08)"},warn:{borderColor:"#faad14",backgroundColor:"rgba(250,173,20,0.08)"},info:{borderColor:"#1677ff",backgroundColor:"rgba(22,119,255,0.08)"}},xd="#ff4d4f",Jd=5e3,_i=4;class $d{draw;options;marks;underlineTimer;underlineVisible;constructor(t){this.draw=t,this.options=t.getOptions(),this.marks=[],this.underlineTimer=null,this.underlineVisible=!1}setMarks(t){this._clearUnderlineTimer(),this.marks=t.slice(),this.underlineVisible=this.marks.length>0,this.marks.length&&(this.underlineTimer=window.setTimeout(()=>{this.underlineVisible=!1,this.underlineTimer=null,this.draw.render({isSetCursor:!1,isSubmitHistory:!1})},Jd))}getMarks(){return this.marks}render(t,e,n,i,l,r,a){if(!this.marks.length||this.draw.isPrintLikeMode())return;const c=this._getRegions(e,n,i,l,r,a);if(c.length){t.save();for(let d=0;d<c.length;d++){const u=c[d],h=this._getStyle(u.mark),R=Math.max(1,this.options.scale),f=u.x-R,g=u.y-R,T=Math.max(1,u.width+R*2),C=Math.max(1,u.height+R*2),p=Math.max(2,this.options.scale*2);if(this.underlineVisible&&h.borderColor&&u.hasUnderline&&(t.lineWidth=p,t.strokeStyle=h.borderColor,t.beginPath(),t.moveTo(u.underlineX,u.underlineY),t.lineTo(u.underlineRight,u.underlineY),t.stroke()),u.drawRequired){this._renderRequiredMark(t,u,f);continue}if(h.borderColor){t.lineWidth=p;const I=Math.min(Math.max(8*this.options.scale,C*.3),C/2),m=f+T,L=g+C;t.beginPath(),u.drawLeft&&(t.moveTo(f+I,g),t.lineTo(f,g),t.lineTo(f,L)),u.drawRight&&(t.moveTo(m-I,L),t.lineTo(m,L),t.lineTo(m,g)),t.stroke()}}t.restore()}}_getRegions(t,e,n,i,l,r){const a=this._getParentMap(t),c=this.marks.map(R=>this._getTargetControlIds(t,R)),d=c.map(R=>this._getTitleTargets(t,R)),u=[];for(let R=0;R<n.length;R++){const f=n[R],g=new Map,T=e[f.startIndex],C=T?Math.min(T.coordinate.leftTop[0],T.coordinate.leftBottom[0])-(f.offsetX||0):0,p=T?C+(r||this.draw.getInnerWidth()):0;for(let I=0;I<f.elementList.length;I++){const m=f.elementList[I],L=f.startIndex+I,P=e[L];if(!P||l===s.EditorZone.MAIN&&P.pageNo!==i)continue;const M=this._getTargetIdsForElement(this._getQualityTargetId(m),c,a);for(let Q=0;Q<d.length;Q++){const v=d[Q].get(L);v&&v.forEach(st=>{M.some(B=>B.markIndex===Q&&B.controlId===st)||M.push({markIndex:Q,controlId:st})})}if(!M.length)continue;const F=P.coordinate.leftTop,N=P.coordinate.rightTop,Y=P.coordinate.leftBottom,b=P.coordinate.rightBottom,S=Math.min(F[0],Y[0]),y=Math.max(N[0],b[0]),V=Math.min(F[1],N[1]),X=Math.max(Y[1],b[1]),O=P.metrics.boundingBoxAscent+P.metrics.boundingBoxDescent,E=V+P.ascent-P.metrics.boundingBoxAscent,W=O>0?E:V,D=O>0?E+O:X,U=this._isButtonElement(m),Z=T?Math.max(S,Math.min(y,p)):y;for(let Q=0;Q<M.length;Q++){const{markIndex:v,controlId:st}=M[Q],B=`${v}:${st}:${f.startIndex}`,H=g.get(B),k={x:S,y:W,right:y,bottom:D};if(H){const q=this._mergeBounds(H,k);H.x=q.x,H.y=q.y,H.width=Math.max(1,q.right-q.x),H.height=Math.max(1,q.bottom-q.y),U||(H.hasUnderline?(H.underlineX=Math.min(H.underlineX,S),H.underlineY=Math.max(H.underlineY,D+_i),H.underlineRight=Math.max(H.underlineRight,Z)):(H.underlineX=S,H.underlineY=D+_i,H.underlineRight=Z),H.hasUnderline=!0)}else g.set(B,{mark:this.marks[v],targetKey:`${v}:${st}`,x:S,y:W,width:Math.max(1,y-S),height:Math.max(1,D-W),baseline:V+P.ascent,font:m.style||this.draw.getElementFont(m,this.options.scale),underlineX:S,underlineY:D+_i,underlineRight:Z,hasUnderline:!U,drawLeft:!1,drawRight:!1,drawRequired:!1})}}u.push(...g.values())}const h=new Map;for(let R=0;R<u.length;R++){const f=u[R],g=h.get(f.targetKey)||[];g.push(f),h.set(f.targetKey,g)}return h.forEach(R=>{this._isRequiredMark(R[0].mark)?R[0].drawRequired=!0:(R[0].drawLeft=!0,R[R.length-1].drawRight=!0)}),u}_renderRequiredMark(t,e,n){t.save(),t.font=e.font,t.fillStyle=e.mark.style?.borderColor||xd,t.textBaseline="alphabetic";const i=t.measureText("*").width,l=Math.max(2,this.options.scale*2);t.fillText("*",n-i-l,e.baseline),t.restore()}_clearUnderlineTimer(){this.underlineTimer!==null&&(window.clearTimeout(this.underlineTimer),this.underlineTimer=null)}_mergeBounds(t,e){return{x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),right:Math.max(t.x+t.width,e.right),bottom:Math.max(t.y+t.height,e.bottom)}}_getParentMap(t){const e=new Map;for(let n=0;n<t.length;n++){const i=t[n],l=this._getQualityTargetId(i);l&&i.originControlId&&e.set(l,i.originControlId)}return e}_getTitleTargets(t,e){const n=new Map;return e.forEach(i=>{const l=t.findIndex(R=>this._getQualityTargetId(R)===i);if(l<0)return;const r=t[l],a=r.control,c=this._getTitleTextBefore(t,l);if(!c)return;const d=[a?.label,a?.placeholder].concat(this._isMacroElement(r)?[r.label]:[]).filter(Boolean).map(R=>this._normalizeTitleText(R)),u=this._normalizeTitleText(c);if(!d.some(R=>R===u||R.includes(u)||u.includes(R)))return;let h=l-1;for(;h>=0&&this._isTitleValueElement(t[h]);){let R=n.get(h);R||(R=new Set,n.set(h,R)),R.add(i),h--}}),n}_getTitleTextBefore(t,e){const n=t[e-1];if(n?.type===s.ElementType.TITLE)return n.valueList?.map(r=>r.value).join("")||"";if(!this._isTitleValueElement(n))return"";const i=n.titleId;let l=e-1;for(;l>=0&&this._isTitleValueElement(t[l])&&t[l].titleId===i;)l--;return t.slice(l+1,e).map(r=>r.value).join("")}_isTitleValueElement(t){return!!t?.titleId&&!!t.level}_normalizeTitleText(t){return t.replace(/\s/g,"").replace(/[::]+$/,"")}_getTargetControlIds(t,e){const n=new Set,i=e.id?"id":e.conceptId?"conceptId":e.code?"code":null;if(!i)return n;for(let l=0;l<t.length;l++){const r=t[l],a=this._getQualityTargetId(r);if(!a)continue;const c=r.control?.conceptId||r.conceptId,d=r.control?.code||r.macroConfig?.code||r.dictCode;(i==="id"&&a===e.id||i==="conceptId"&&c===e.conceptId||i==="code"&&d===e.code)&&n.add(a)}return n}_getQualityTargetId(t){if(t.controlId)return t.controlId;if(this._isMacroElement(t))return t.id}_isMacroElement(t){return[s.ElementType.MACRO,s.ElementType.CUSTOM_MACRO,s.ElementType.REUSABLE_ITEM].includes(t.type)}_getTargetIdsForElement(t,e,n){if(!t)return[];const i=[];for(let l=0;l<e.length;l++){const r=e[l];let a=t;const c=new Set;for(;a&&!c.has(a);){if(r.has(a)){i.push({markIndex:l,controlId:a});break}c.add(a),a=n.get(a)}}return i}_getStyle(t){return{...Or[t.type?.toLowerCase()||"error"]||Or.error,...t.style}}_isRequiredMark(t){return t.required===!0||["required","required-empty","required_empty"].includes(t.type?.toLowerCase()||"")}_isButtonElement(t){return t.type===s.ElementType.BUTTON||t.control?.type===s.ControlType.BUTTON&&!t.control.buttonText}}class zd{borderRect;options;constructor(t){this.borderRect=this.clearBorderInfo(),this.options=t.getOptions()}clearBorderInfo(){return this.borderRect={x:0,y:0,width:0,height:0},this.borderRect}recordBorderInfo(t,e,n,i){!this.borderRect.width&&(this.borderRect.x=t,this.borderRect.y=e,this.borderRect.height=i),this.borderRect.width+=n}render(t){if(!this.borderRect.width)return;const{scale:e,control:{borderWidth:n,borderColor:i}}=this.options,{x:l,y:r,width:a,height:c}=this.borderRect;t.save(),t.translate(0,1*e),t.lineWidth=n*e,t.strokeStyle=i,t.beginPath(),t.rect(l,r,a,c),t.stroke(),t.restore(),this.clearBorderInfo()}}class so{draw;element;control;isPopup;selectDom;options;VALUE_DELIMITER=",";DEFAULT_MULTI_SELECT_DELIMITER=",";constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.selectDom=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getCodes(){return this.element?.control?.code?this.element.control.code.split(","):[]}getText(t){if(!this.element?.control)return null;const e=this.element.control;if(!e.valueSets?.length)return null;const n=e?.multiSelectDelimiter||this.DEFAULT_MULTI_SELECT_DELIMITER,i=e.valueSets,l=[];return t.forEach(r=>{const a=i.find(c=>c.code===r);a&&!ws(a.value)&&l.push(a.value)}),l.join(n)||null}getValue(t={}){const{elementList:e,range:n}=this.control.mergeControl(t),{startIndex:i}=n,l=e[i],r=[];let a=i;for(;a>=0;){const d=e[a];if(!d||d.controlId!==l.controlId||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT)break;d.controlComponent===s.ControlComponent.VALUE&&r.unshift(d),a--}let c=i+1;for(;c<e.length;){const d=e[c];if(d.controlId!==l.controlId||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POST_TEXT)break;d.controlComponent===s.ControlComponent.VALUE&&r.push(d),c++}return r}setValue(t,e={},n={}){if(!this.element.control?.selectExclusiveOptions?.inputAble||!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:r,endIndex:a}=l,c=this.control.getDraw();r!==a?c.spliceElementList(i,r+1,a-r):this.control.removePlaceholder(r,{elementList:i});const d=i[r],u=d.type&&!Le.includes(d.type)||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT?xt(d,["control","controlId",...Re]):Ee(d,["type"]),h=l.startIndex+1;for(let R=0;R<t.length;R++){const f={...u,...t[R],controlComponent:s.ControlComponent.VALUE};se(i,[f],r,{editorOptions:this.options}),c.spliceElementList(i,h+R,0,[f])}return h+t.length-1}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.element.control?.selectExclusiveOptions?.inputAble;if(t.key===s.KeyMap.Backspace)return i!==l?c?(this.draw.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect():r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1):this.clearSelect();if(t.key===s.KeyMap.Delete){if(i!==l)return c?(this.draw.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect();{const d=e[l+1];return(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT)&&d.controlComponent===s.ControlComponent.PLACEHOLDER||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):c?(this.draw.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):this.clearSelect()}}return l}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();return t===e?t:this.clearSelect()}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const l=t.elementList||this.control.getElementList(),{startIndex:r}=t.range||this.control.getRange(),a=l[r];let c=-1,d=-1,u=r;for(;u>0;){const f=l[u];if(f.controlId!==a.controlId||f.controlComponent===s.ControlComponent.PREFIX||f.controlComponent===s.ControlComponent.PRE_TEXT){c=u;break}u--}let h=r+1;for(;h<l.length;){const f=l[h];if(f.controlId!==a.controlId||f.controlComponent===s.ControlComponent.POSTFIX||f.controlComponent===s.ControlComponent.POST_TEXT){d=h-1;break}h++}return!~c||!~d?-1:(this.control.getDraw().spliceElementList(l,c+1,d-c,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(u,t),this.control.setControlProperties({code:void 0},{elementList:l,range:{startIndex:u,endIndex:u}}),u)}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),r=this.element.control,a=t?.split(this.VALUE_DELIMITER)||[],c=r.code,d=r.code?.split(this.VALUE_DELIMITER)||[],u=r.isMultiSelect;if(!u&&t===c||u&&Us(d,a)){this.control.repaintControl({curIndex:l.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const h=r.valueSets;if(!Array.isArray(h)||!h.length)return;const R=this.getText(a);if(!R){if(c){const L=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~L&&(this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({controlValue:[]}))}return}const f=this.getValue(e)[0],g=f?xt(f,Ne):xt(i[l.startIndex],Re),T=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~T)return;c||this.control.removePlaceholder(T,e);const C=Ee(i[T],Ne),p=T+1,I=Dt(R),m=this.control.getDraw();for(let L=0;L<I.length;L++){const P={...g,...C,type:s.ElementType.TEXT,value:I[L],controlComponent:s.ControlComponent.VALUE};(P.color===this.options.control.bracketColor||P.color===this.options.control.placeholderColor)&&(P.color=this.options.defaultColor),se(i,[P],T,{editorOptions:this.options}),m.spliceElementList(i,p+L,0,[P])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:T,endIndex:T}}),!e.range){const L=p+I.length-1;this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({context:e}),u||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const n=this.control.getPosition();if(!n)return;const i=document.createElement("div");i.classList.add(`${rt}-select-control-popup`),i.setAttribute(Ze,s.EditorComponent.POPUP);const l=document.createElement("ul");let r=null;for(let R=0;R<e.length;R++){const f=e[R],g=document.createElement("li");let T=this.getCodes();T.includes(f.code)&&(g.classList.add("active"),r=g),g.onclick=()=>{const C=T.findIndex(p=>p===f.code);t.isMultiSelect?~C?T.splice(C,1):T.push(f.code):~C?T=[]:T=[f.code],this.setSelect(T.join(this.VALUE_DELIMITER))},g.append(document.createTextNode(f.value)),l.append(g)}i.append(l);const{coordinate:{leftTop:[a,c]},lineHeight:d}=n,u=this.control.getPreY();i.style.left=`${a}px`,i.style.top=`${c+u+d}px`,this.control.getContainer().append(i),this.selectDom=i,r&&vs(i,r)}awake(){if(this.isPopup||this.control.getIsDisabledControl())return;const{startIndex:t}=this.control.getRange(),n=this.control.getElementList()[t];if(!n||n.controlId!==this.element.controlId||n.controlComponent===s.ControlComponent.POSTFIX||n.controlComponent===s.ControlComponent.POSTTEXTFIX||n.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||n.controlComponent===s.ControlComponent.POST_TEXT)return;const l=n.controlComponent===s.ControlComponent.PREFIX||n.controlComponent===s.ControlComponent.PRE_TEXT||n.controlComponent===s.ControlComponent.PLACEHOLDER;!this.control.getIsRangeWithinControl()&&!l||(this._createSelectPopupDom(),this.isPopup=!0)}destroy(){this.isPopup&&(this.selectDom?.remove(),this.isPopup=!1)}}var Sr;function lt(){return Sr.apply(null,arguments)}function jd(o){Sr=o}function Ve(o){return o instanceof Array||Object.prototype.toString.call(o)==="[object Array]"}function Sn(o){return o!=null&&Object.prototype.toString.call(o)==="[object Object]"}function Kt(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function Bi(o){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(o).length===0;var t;for(t in o)if(Kt(o,t))return!1;return!0}function pe(o){return o===void 0}function qe(o){return typeof o=="number"||Object.prototype.toString.call(o)==="[object Number]"}function ro(o){return o instanceof Date||Object.prototype.toString.call(o)==="[object Date]"}function Dr(o,t){var e=[],n,i=o.length;for(n=0;n<i;++n)e.push(t(o[n],n));return e}function fn(o,t){for(var e in t)Kt(t,e)&&(o[e]=t[e]);return Kt(t,"toString")&&(o.toString=t.toString),Kt(t,"valueOf")&&(o.valueOf=t.valueOf),o}function Be(o,t,e,n){return tl(o,t,e,n,!0).utc()}function qd(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function Ot(o){return o._pf==null&&(o._pf=qd()),o._pf}var ki;Array.prototype.some?ki=Array.prototype.some:ki=function(o){var t=Object(this),e=t.length>>>0,n;for(n=0;n<e;n++)if(n in t&&o.call(this,t[n],n,t))return!0;return!1};function Gi(o){var t=null,e=!1,n=o._d&&!isNaN(o._d.getTime());if(n&&(t=Ot(o),e=ki.call(t.parsedDateParts,function(i){return i!=null}),n=t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&e),o._strict&&(n=n&&t.charsLeftOver===0&&t.unusedTokens.length===0&&t.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(o))o._isValid=n;else return n;return o._isValid}function wo(o){var t=Be(NaN);return o!=null?fn(Ot(t),o):Ot(t).userInvalidated=!0,t}var Fr=lt.momentProperties=[],xi=!1;function Ji(o,t){var e,n,i,l=Fr.length;if(pe(t._isAMomentObject)||(o._isAMomentObject=t._isAMomentObject),pe(t._i)||(o._i=t._i),pe(t._f)||(o._f=t._f),pe(t._l)||(o._l=t._l),pe(t._strict)||(o._strict=t._strict),pe(t._tzm)||(o._tzm=t._tzm),pe(t._isUTC)||(o._isUTC=t._isUTC),pe(t._offset)||(o._offset=t._offset),pe(t._pf)||(o._pf=Ot(t)),pe(t._locale)||(o._locale=t._locale),l>0)for(e=0;e<l;e++)n=Fr[e],i=t[n],pe(i)||(o[n]=i);return o}function lo(o){Ji(this,o),this._d=new Date(o._d!=null?o._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),xi===!1&&(xi=!0,lt.updateOffset(this),xi=!1)}function We(o){return o instanceof lo||o!=null&&o._isAMomentObject!=null}function Xr(o){lt.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+o)}function De(o,t){var e=!0;return fn(function(){if(lt.deprecationHandler!=null&&lt.deprecationHandler(null,o),e){var n=[],i,l,r,a=arguments.length;for(l=0;l<a;l++){if(i="",typeof arguments[l]=="object"){i+=`
120
120
  [`+l+"] ";for(r in arguments[0])Kt(arguments[0],r)&&(i+=r+": "+arguments[0][r]+", ");i=i.slice(0,-2)}else i=arguments[l];n.push(i)}Xr(o+`
121
121
  Arguments: `+Array.prototype.slice.call(n).join("")+`
122
- `+new Error().stack),e=!1}return t.apply(this,arguments)},t)}var Nr={};function yr(o,t){lt.deprecationHandler!=null&&lt.deprecationHandler(o,t),Nr[o]||(Xr(t),Nr[o]=!0)}lt.suppressDeprecationWarnings=!1,lt.deprecationHandler=null;function ke(o){return typeof Function<"u"&&o instanceof Function||Object.prototype.toString.call(o)==="[object Function]"}function tu(o){var t,e;for(e in o)Kt(o,e)&&(t=o[e],ke(t)?this[e]=t:this["_"+e]=t);this._config=o,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function $i(o,t){var e=fn({},o),n;for(n in t)Kt(t,n)&&(Sn(o[n])&&Sn(t[n])?(e[n]={},fn(e[n],o[n]),fn(e[n],t[n])):t[n]!=null?e[n]=t[n]:delete e[n]);for(n in o)Kt(o,n)&&!Kt(t,n)&&Sn(o[n])&&(e[n]=fn({},e[n]));return e}function zi(o){o!=null&&this.set(o)}var ji;Object.keys?ji=Object.keys:ji=function(o){var t,e=[];for(t in o)Kt(o,t)&&e.push(t);return e};var eu={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function nu(o,t,e){var n=this._calendar[o]||this._calendar.sameElse;return ke(n)?n.call(t,e):n}function Ge(o,t,e){var n=""+Math.abs(o),i=t-n.length,l=o>=0;return(l?e?"+":"":"-")+Math.pow(10,Math.max(0,i)).toString().substr(1)+n}var qi=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,Zo=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ts={},Bn={};function ht(o,t,e,n){var i=n;typeof n=="string"&&(i=function(){return this[n]()}),o&&(Bn[o]=i),t&&(Bn[t[0]]=function(){return Ge(i.apply(this,arguments),t[1],t[2])}),e&&(Bn[e]=function(){return this.localeData().ordinal(i.apply(this,arguments),o)})}function ou(o){return o.match(/\[[\s\S]/)?o.replace(/^\[|\]$/g,""):o.replace(/\\/g,"")}function iu(o){var t=o.match(qi),e,n;for(e=0,n=t.length;e<n;e++)Bn[t[e]]?t[e]=Bn[t[e]]:t[e]=ou(t[e]);return function(i){var l="",r;for(r=0;r<n;r++)l+=ke(t[r])?t[r].call(i,o):t[r];return l}}function vo(o,t){return o.isValid()?(t=br(t,o.localeData()),ts[t]=ts[t]||iu(t),ts[t](o)):o.localeData().invalidDate()}function br(o,t){var e=5;function n(i){return t.longDateFormat(i)||i}for(Zo.lastIndex=0;e>=0&&Zo.test(o);)o=o.replace(Zo,n),Zo.lastIndex=0,e-=1;return o}var su={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function ru(o){var t=this._longDateFormat[o],e=this._longDateFormat[o.toUpperCase()];return t||!e?t:(this._longDateFormat[o]=e.match(qi).map(function(n){return n==="MMMM"||n==="MM"||n==="DD"||n==="dddd"?n.slice(1):n}).join(""),this._longDateFormat[o])}var lu="Invalid date";function au(){return this._invalidDate}var cu="%d",du=/\d{1,2}/;function uu(o){return this._ordinal.replace("%d",o)}var Ru={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function hu(o,t,e,n){var i=this._relativeTime[e];return ke(i)?i(o,t,e,n):i.replace(/%d/i,o)}function gu(o,t){var e=this._relativeTime[o>0?"future":"past"];return ke(e)?e(t):e.replace(/%s/i,t)}var Vr={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function Fe(o){return typeof o=="string"?Vr[o]||Vr[o.toLowerCase()]:void 0}function es(o){var t={},e,n;for(n in o)Kt(o,n)&&(e=Fe(n),e&&(t[e]=o[n]));return t}var fu={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function Tu(o){var t=[],e;for(e in o)Kt(o,e)&&t.push({unit:e,priority:fu[e]});return t.sort(function(n,i){return n.priority-i.priority}),t}var Wr=/\d/,Pe=/\d\d/,Yr=/\d{3}/,ns=/\d{4}/,Qo=/[+-]?\d{6}/,te=/\d\d?/,Ur=/\d\d\d\d?/,wr=/\d\d\d\d\d\d?/,Ko=/\d{1,3}/,os=/\d{1,4}/,Ho=/[+-]?\d{1,6}/,kn=/\d+/,Ao=/[+-]?\d+/,mu=/Z|[+-]\d\d:?\d\d/gi,_o=/Z|[+-]\d\d(?::?\d\d)?/gi,Cu=/[+-]?\d+(\.\d{1,3})?/,ao=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,Gn=/^[1-9]\d?/,is=/^([1-9]\d|\d)/,Bo;Bo={};function ct(o,t,e){Bo[o]=ke(t)?t:function(n,i){return n&&e?e:t}}function pu(o,t){return Kt(Bo,o)?Bo[o](t._strict,t._locale):new RegExp(Iu(o))}function Iu(o){return tn(o.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,i,l){return e||n||i||l}))}function tn(o){return o.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Xe(o){return o<0?Math.ceil(o)||0:Math.floor(o)}function Wt(o){var t=+o,e=0;return t!==0&&isFinite(t)&&(e=Xe(t)),e}var ss={};function kt(o,t){var e,n=t,i;for(typeof o=="string"&&(o=[o]),qe(t)&&(n=function(l,r){r[t]=Wt(l)}),i=o.length,e=0;e<i;e++)ss[o[e]]=n}function co(o,t){kt(o,function(e,n,i,l){i._w=i._w||{},t(e,i._w,i,l)})}function Eu(o,t,e){t!=null&&Kt(ss,o)&&ss[o](t,e._a,e,o)}function ko(o){return o%4===0&&o%100!==0||o%400===0}var ge=0,en=1,xe=2,he=3,Ye=4,nn=5,Dn=6,Lu=7,Pu=8;ht("Y",0,0,function(){var o=this.year();return o<=9999?Ge(o,4):"+"+o}),ht(0,["YY",2],0,function(){return this.year()%100}),ht(0,["YYYY",4],0,"year"),ht(0,["YYYYY",5],0,"year"),ht(0,["YYYYYY",6,!0],0,"year"),ct("Y",Ao),ct("YY",te,Pe),ct("YYYY",os,ns),ct("YYYYY",Ho,Qo),ct("YYYYYY",Ho,Qo),kt(["YYYYY","YYYYYY"],ge),kt("YYYY",function(o,t){t[ge]=o.length===2?lt.parseTwoDigitYear(o):Wt(o)}),kt("YY",function(o,t){t[ge]=lt.parseTwoDigitYear(o)}),kt("Y",function(o,t){t[ge]=parseInt(o,10)});function uo(o){return ko(o)?366:365}lt.parseTwoDigitYear=function(o){return Wt(o)+(Wt(o)>68?1900:2e3)};var Zr=xn("FullYear",!0);function Mu(){return ko(this.year())}function xn(o,t){return function(e){return e!=null?(vr(this,o,e),lt.updateOffset(this,t),this):Ro(this,o)}}function Ro(o,t){if(!o.isValid())return NaN;var e=o._d,n=o._isUTC;switch(t){case"Milliseconds":return n?e.getUTCMilliseconds():e.getMilliseconds();case"Seconds":return n?e.getUTCSeconds():e.getSeconds();case"Minutes":return n?e.getUTCMinutes():e.getMinutes();case"Hours":return n?e.getUTCHours():e.getHours();case"Date":return n?e.getUTCDate():e.getDate();case"Day":return n?e.getUTCDay():e.getDay();case"Month":return n?e.getUTCMonth():e.getMonth();case"FullYear":return n?e.getUTCFullYear():e.getFullYear();default:return NaN}}function vr(o,t,e){var n,i,l,r,a;if(!(!o.isValid()||isNaN(e))){switch(n=o._d,i=o._isUTC,t){case"Milliseconds":return void(i?n.setUTCMilliseconds(e):n.setMilliseconds(e));case"Seconds":return void(i?n.setUTCSeconds(e):n.setSeconds(e));case"Minutes":return void(i?n.setUTCMinutes(e):n.setMinutes(e));case"Hours":return void(i?n.setUTCHours(e):n.setHours(e));case"Date":return void(i?n.setUTCDate(e):n.setDate(e));case"FullYear":break;default:return}l=e,r=o.month(),a=o.date(),a=a===29&&r===1&&!ko(l)?28:a,i?n.setUTCFullYear(l,r,a):n.setFullYear(l,r,a)}}function Ou(o){return o=Fe(o),ke(this[o])?this[o]():this}function Su(o,t){if(typeof o=="object"){o=es(o);var e=Tu(o),n,i=e.length;for(n=0;n<i;n++)this[e[n].unit](o[e[n].unit])}else if(o=Fe(o),ke(this[o]))return this[o](t);return this}function Du(o,t){return(o%t+t)%t}var ae;Array.prototype.indexOf?ae=Array.prototype.indexOf:ae=function(o){var t;for(t=0;t<this.length;++t)if(this[t]===o)return t;return-1};function rs(o,t){if(isNaN(o)||isNaN(t))return NaN;var e=Du(t,12);return o+=(t-e)/12,e===1?ko(o)?29:28:31-e%7%2}ht("M",["MM",2],"Mo",function(){return this.month()+1}),ht("MMM",0,0,function(o){return this.localeData().monthsShort(this,o)}),ht("MMMM",0,0,function(o){return this.localeData().months(this,o)}),ct("M",te,Gn),ct("MM",te,Pe),ct("MMM",function(o,t){return t.monthsShortRegex(o)}),ct("MMMM",function(o,t){return t.monthsRegex(o)}),kt(["M","MM"],function(o,t){t[en]=Wt(o)-1}),kt(["MMM","MMMM"],function(o,t,e,n){var i=e._locale.monthsParse(o,n,e._strict);i!=null?t[en]=i:Ot(e).invalidMonth=o});var Fu="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Qr="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Kr=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Xu=ao,Nu=ao;function yu(o,t){return o?Ve(this._months)?this._months[o.month()]:this._months[(this._months.isFormat||Kr).test(t)?"format":"standalone"][o.month()]:Ve(this._months)?this._months:this._months.standalone}function bu(o,t){return o?Ve(this._monthsShort)?this._monthsShort[o.month()]:this._monthsShort[Kr.test(t)?"format":"standalone"][o.month()]:Ve(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Vu(o,t,e){var n,i,l,r=o.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],n=0;n<12;++n)l=Be([2e3,n]),this._shortMonthsParse[n]=this.monthsShort(l,"").toLocaleLowerCase(),this._longMonthsParse[n]=this.months(l,"").toLocaleLowerCase();return e?t==="MMM"?(i=ae.call(this._shortMonthsParse,r),i!==-1?i:null):(i=ae.call(this._longMonthsParse,r),i!==-1?i:null):t==="MMM"?(i=ae.call(this._shortMonthsParse,r),i!==-1?i:(i=ae.call(this._longMonthsParse,r),i!==-1?i:null)):(i=ae.call(this._longMonthsParse,r),i!==-1?i:(i=ae.call(this._shortMonthsParse,r),i!==-1?i:null))}function Wu(o,t,e){var n,i,l;if(this._monthsParseExact)return Vu.call(this,o,t,e);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(i=Be([2e3,n]),e&&!this._longMonthsParse[n]&&(this._longMonthsParse[n]=new RegExp("^"+this.months(i,"").replace(".","")+"$","i"),this._shortMonthsParse[n]=new RegExp("^"+this.monthsShort(i,"").replace(".","")+"$","i")),!e&&!this._monthsParse[n]&&(l="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[n]=new RegExp(l.replace(".",""),"i")),e&&t==="MMMM"&&this._longMonthsParse[n].test(o))return n;if(e&&t==="MMM"&&this._shortMonthsParse[n].test(o))return n;if(!e&&this._monthsParse[n].test(o))return n}}function Hr(o,t){if(!o.isValid())return o;if(typeof t=="string"){if(/^\d+$/.test(t))t=Wt(t);else if(t=o.localeData().monthsParse(t),!qe(t))return o}var e=t,n=o.date();return n=n<29?n:Math.min(n,rs(o.year(),e)),o._isUTC?o._d.setUTCMonth(e,n):o._d.setMonth(e,n),o}function Ar(o){return o!=null?(Hr(this,o),lt.updateOffset(this,!0),this):Ro(this,"Month")}function Yu(){return rs(this.year(),this.month())}function Uu(o){return this._monthsParseExact?(Kt(this,"_monthsRegex")||_r.call(this),o?this._monthsShortStrictRegex:this._monthsShortRegex):(Kt(this,"_monthsShortRegex")||(this._monthsShortRegex=Xu),this._monthsShortStrictRegex&&o?this._monthsShortStrictRegex:this._monthsShortRegex)}function wu(o){return this._monthsParseExact?(Kt(this,"_monthsRegex")||_r.call(this),o?this._monthsStrictRegex:this._monthsRegex):(Kt(this,"_monthsRegex")||(this._monthsRegex=Nu),this._monthsStrictRegex&&o?this._monthsStrictRegex:this._monthsRegex)}function _r(){function o(c,d){return d.length-c.length}var t=[],e=[],n=[],i,l,r,a;for(i=0;i<12;i++)l=Be([2e3,i]),r=tn(this.monthsShort(l,"")),a=tn(this.months(l,"")),t.push(r),e.push(a),n.push(a),n.push(r);t.sort(o),e.sort(o),n.sort(o),this._monthsRegex=new RegExp("^("+n.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+t.join("|")+")","i")}function Zu(o,t,e,n,i,l,r){var a;return o<100&&o>=0?(a=new Date(o+400,t,e,n,i,l,r),isFinite(a.getFullYear())&&a.setFullYear(o)):a=new Date(o,t,e,n,i,l,r),a}function ho(o){var t,e;return o<100&&o>=0?(e=Array.prototype.slice.call(arguments),e[0]=o+400,t=new Date(Date.UTC.apply(null,e)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(o)):t=new Date(Date.UTC.apply(null,arguments)),t}function Go(o,t,e){var n=7+t-e,i=(7+ho(o,0,n).getUTCDay()-t)%7;return-i+n-1}function Br(o,t,e,n,i){var l=(7+e-n)%7,r=Go(o,n,i),a=1+7*(t-1)+l+r,c,d;return a<=0?(c=o-1,d=uo(c)+a):a>uo(o)?(c=o+1,d=a-uo(o)):(c=o,d=a),{year:c,dayOfYear:d}}function go(o,t,e){var n=Go(o.year(),t,e),i=Math.floor((o.dayOfYear()-n-1)/7)+1,l,r;return i<1?(r=o.year()-1,l=i+on(r,t,e)):i>on(o.year(),t,e)?(l=i-on(o.year(),t,e),r=o.year()+1):(r=o.year(),l=i),{week:l,year:r}}function on(o,t,e){var n=Go(o,t,e),i=Go(o+1,t,e);return(uo(o)-n+i)/7}ht("w",["ww",2],"wo","week"),ht("W",["WW",2],"Wo","isoWeek"),ct("w",te,Gn),ct("ww",te,Pe),ct("W",te,Gn),ct("WW",te,Pe),co(["w","ww","W","WW"],function(o,t,e,n){t[n.substr(0,1)]=Wt(o)});function vu(o){return go(o,this._week.dow,this._week.doy).week}var Qu={dow:0,doy:6};function Ku(){return this._week.dow}function Hu(){return this._week.doy}function Au(o){var t=this.localeData().week(this);return o==null?t:this.add((o-t)*7,"d")}function _u(o){var t=go(this,1,4).week;return o==null?t:this.add((o-t)*7,"d")}ht("d",0,"do","day"),ht("dd",0,0,function(o){return this.localeData().weekdaysMin(this,o)}),ht("ddd",0,0,function(o){return this.localeData().weekdaysShort(this,o)}),ht("dddd",0,0,function(o){return this.localeData().weekdays(this,o)}),ht("e",0,0,"weekday"),ht("E",0,0,"isoWeekday"),ct("d",te),ct("e",te),ct("E",te),ct("dd",function(o,t){return t.weekdaysMinRegex(o)}),ct("ddd",function(o,t){return t.weekdaysShortRegex(o)}),ct("dddd",function(o,t){return t.weekdaysRegex(o)}),co(["dd","ddd","dddd"],function(o,t,e,n){var i=e._locale.weekdaysParse(o,n,e._strict);i!=null?t.d=i:Ot(e).invalidWeekday=o}),co(["d","e","E"],function(o,t,e,n){t[n]=Wt(o)});function Bu(o,t){return typeof o!="string"?o:isNaN(o)?(o=t.weekdaysParse(o),typeof o=="number"?o:null):parseInt(o,10)}function ku(o,t){return typeof o=="string"?t.weekdaysParse(o)%7||7:isNaN(o)?null:o}function ls(o,t){return o.slice(t,7).concat(o.slice(0,t))}var Gu="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),kr="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),xu="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Ju=ao,$u=ao,zu=ao;function ju(o,t){var e=Ve(this._weekdays)?this._weekdays:this._weekdays[o&&o!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return o===!0?ls(e,this._week.dow):o?e[o.day()]:e}function qu(o){return o===!0?ls(this._weekdaysShort,this._week.dow):o?this._weekdaysShort[o.day()]:this._weekdaysShort}function tR(o){return o===!0?ls(this._weekdaysMin,this._week.dow):o?this._weekdaysMin[o.day()]:this._weekdaysMin}function eR(o,t,e){var n,i,l,r=o.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],n=0;n<7;++n)l=Be([2e3,1]).day(n),this._minWeekdaysParse[n]=this.weekdaysMin(l,"").toLocaleLowerCase(),this._shortWeekdaysParse[n]=this.weekdaysShort(l,"").toLocaleLowerCase(),this._weekdaysParse[n]=this.weekdays(l,"").toLocaleLowerCase();return e?t==="dddd"?(i=ae.call(this._weekdaysParse,r),i!==-1?i:null):t==="ddd"?(i=ae.call(this._shortWeekdaysParse,r),i!==-1?i:null):(i=ae.call(this._minWeekdaysParse,r),i!==-1?i:null):t==="dddd"?(i=ae.call(this._weekdaysParse,r),i!==-1||(i=ae.call(this._shortWeekdaysParse,r),i!==-1)?i:(i=ae.call(this._minWeekdaysParse,r),i!==-1?i:null)):t==="ddd"?(i=ae.call(this._shortWeekdaysParse,r),i!==-1||(i=ae.call(this._weekdaysParse,r),i!==-1)?i:(i=ae.call(this._minWeekdaysParse,r),i!==-1?i:null)):(i=ae.call(this._minWeekdaysParse,r),i!==-1||(i=ae.call(this._weekdaysParse,r),i!==-1)?i:(i=ae.call(this._shortWeekdaysParse,r),i!==-1?i:null))}function nR(o,t,e){var n,i,l;if(this._weekdaysParseExact)return eR.call(this,o,t,e);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(i=Be([2e3,1]).day(n),e&&!this._fullWeekdaysParse[n]&&(this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(i,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(i,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(i,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[n]||(l="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[n]=new RegExp(l.replace(".",""),"i")),e&&t==="dddd"&&this._fullWeekdaysParse[n].test(o))return n;if(e&&t==="ddd"&&this._shortWeekdaysParse[n].test(o))return n;if(e&&t==="dd"&&this._minWeekdaysParse[n].test(o))return n;if(!e&&this._weekdaysParse[n].test(o))return n}}function oR(o){if(!this.isValid())return o!=null?this:NaN;var t=Ro(this,"Day");return o!=null?(o=Bu(o,this.localeData()),this.add(o-t,"d")):t}function iR(o){if(!this.isValid())return o!=null?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return o==null?t:this.add(o-t,"d")}function sR(o){if(!this.isValid())return o!=null?this:NaN;if(o!=null){var t=ku(o,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function rR(o){return this._weekdaysParseExact?(Kt(this,"_weekdaysRegex")||as.call(this),o?this._weekdaysStrictRegex:this._weekdaysRegex):(Kt(this,"_weekdaysRegex")||(this._weekdaysRegex=Ju),this._weekdaysStrictRegex&&o?this._weekdaysStrictRegex:this._weekdaysRegex)}function lR(o){return this._weekdaysParseExact?(Kt(this,"_weekdaysRegex")||as.call(this),o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(Kt(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=$u),this._weekdaysShortStrictRegex&&o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function aR(o){return this._weekdaysParseExact?(Kt(this,"_weekdaysRegex")||as.call(this),o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(Kt(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=zu),this._weekdaysMinStrictRegex&&o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function as(){function o(u,h){return h.length-u.length}var t=[],e=[],n=[],i=[],l,r,a,c,d;for(l=0;l<7;l++)r=Be([2e3,1]).day(l),a=tn(this.weekdaysMin(r,"")),c=tn(this.weekdaysShort(r,"")),d=tn(this.weekdays(r,"")),t.push(a),e.push(c),n.push(d),i.push(a),i.push(c),i.push(d);t.sort(o),e.sort(o),n.sort(o),i.sort(o),this._weekdaysRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+t.join("|")+")","i")}function cs(){return this.hours()%12||12}function cR(){return this.hours()||24}ht("H",["HH",2],0,"hour"),ht("h",["hh",2],0,cs),ht("k",["kk",2],0,cR),ht("hmm",0,0,function(){return""+cs.apply(this)+Ge(this.minutes(),2)}),ht("hmmss",0,0,function(){return""+cs.apply(this)+Ge(this.minutes(),2)+Ge(this.seconds(),2)}),ht("Hmm",0,0,function(){return""+this.hours()+Ge(this.minutes(),2)}),ht("Hmmss",0,0,function(){return""+this.hours()+Ge(this.minutes(),2)+Ge(this.seconds(),2)});function Gr(o,t){ht(o,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}Gr("a",!0),Gr("A",!1);function xr(o,t){return t._meridiemParse}ct("a",xr),ct("A",xr),ct("H",te,is),ct("h",te,Gn),ct("k",te,Gn),ct("HH",te,Pe),ct("hh",te,Pe),ct("kk",te,Pe),ct("hmm",Ur),ct("hmmss",wr),ct("Hmm",Ur),ct("Hmmss",wr),kt(["H","HH"],he),kt(["k","kk"],function(o,t,e){var n=Wt(o);t[he]=n===24?0:n}),kt(["a","A"],function(o,t,e){e._isPm=e._locale.isPM(o),e._meridiem=o}),kt(["h","hh"],function(o,t,e){t[he]=Wt(o),Ot(e).bigHour=!0}),kt("hmm",function(o,t,e){var n=o.length-2;t[he]=Wt(o.substr(0,n)),t[Ye]=Wt(o.substr(n)),Ot(e).bigHour=!0}),kt("hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[he]=Wt(o.substr(0,n)),t[Ye]=Wt(o.substr(n,2)),t[nn]=Wt(o.substr(i)),Ot(e).bigHour=!0}),kt("Hmm",function(o,t,e){var n=o.length-2;t[he]=Wt(o.substr(0,n)),t[Ye]=Wt(o.substr(n))}),kt("Hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[he]=Wt(o.substr(0,n)),t[Ye]=Wt(o.substr(n,2)),t[nn]=Wt(o.substr(i))});function dR(o){return(o+"").toLowerCase().charAt(0)==="p"}var uR=/[ap]\.?m?\.?/i,RR=xn("Hours",!0);function hR(o,t,e){return o>11?e?"pm":"PM":e?"am":"AM"}var Jr={calendar:eu,longDateFormat:su,invalidDate:lu,ordinal:cu,dayOfMonthOrdinalParse:du,relativeTime:Ru,months:Fu,monthsShort:Qr,week:Qu,weekdays:Gu,weekdaysMin:xu,weekdaysShort:kr,meridiemParse:uR},oe={},fo={},To;function gR(o,t){var e,n=Math.min(o.length,t.length);for(e=0;e<n;e+=1)if(o[e]!==t[e])return e;return n}function $r(o){return o&&o.toLowerCase().replace("_","-")}function fR(o){for(var t=0,e,n,i,l;t<o.length;){for(l=$r(o[t]).split("-"),e=l.length,n=$r(o[t+1]),n=n?n.split("-"):null;e>0;){if(i=xo(l.slice(0,e).join("-")),i)return i;if(n&&n.length>=e&&gR(l,n)>=e-1)break;e--}t++}return To}function TR(o){return!!(o&&o.match("^[^/\\\\]*$"))}function xo(o){var t=null,e;if(oe[o]===void 0&&typeof module<"u"&&module&&module.exports&&TR(o))try{t=To._abbr,e=require,e("./locale/"+o),Tn(t)}catch{oe[o]=null}return oe[o]}function Tn(o,t){var e;return o&&(pe(t)?e=sn(o):e=ds(o,t),e?To=e:typeof console<"u"&&console.warn&&console.warn("Locale "+o+" not found. Did you forget to load it?")),To._abbr}function ds(o,t){if(t!==null){var e,n=Jr;if(t.abbr=o,oe[o]!=null)yr("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=oe[o]._config;else if(t.parentLocale!=null)if(oe[t.parentLocale]!=null)n=oe[t.parentLocale]._config;else if(e=xo(t.parentLocale),e!=null)n=e._config;else return fo[t.parentLocale]||(fo[t.parentLocale]=[]),fo[t.parentLocale].push({name:o,config:t}),null;return oe[o]=new zi($i(n,t)),fo[o]&&fo[o].forEach(function(i){ds(i.name,i.config)}),Tn(o),oe[o]}else return delete oe[o],null}function mR(o,t){if(t!=null){var e,n,i=Jr;oe[o]!=null&&oe[o].parentLocale!=null?oe[o].set($i(oe[o]._config,t)):(n=xo(o),n!=null&&(i=n._config),t=$i(i,t),n==null&&(t.abbr=o),e=new zi(t),e.parentLocale=oe[o],oe[o]=e),Tn(o)}else oe[o]!=null&&(oe[o].parentLocale!=null?(oe[o]=oe[o].parentLocale,o===Tn()&&Tn(o)):oe[o]!=null&&delete oe[o]);return oe[o]}function sn(o){var t;if(o&&o._locale&&o._locale._abbr&&(o=o._locale._abbr),!o)return To;if(!Ve(o)){if(t=xo(o),t)return t;o=[o]}return fR(o)}function CR(){return ji(oe)}function us(o){var t,e=o._a;return e&&Ot(o).overflow===-2&&(t=e[en]<0||e[en]>11?en:e[xe]<1||e[xe]>rs(e[ge],e[en])?xe:e[he]<0||e[he]>24||e[he]===24&&(e[Ye]!==0||e[nn]!==0||e[Dn]!==0)?he:e[Ye]<0||e[Ye]>59?Ye:e[nn]<0||e[nn]>59?nn:e[Dn]<0||e[Dn]>999?Dn:-1,Ot(o)._overflowDayOfYear&&(t<ge||t>xe)&&(t=xe),Ot(o)._overflowWeeks&&t===-1&&(t=Lu),Ot(o)._overflowWeekday&&t===-1&&(t=Pu),Ot(o).overflow=t),o}var pR=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,IR=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ER=/Z|[+-]\d\d(?::?\d\d)?/,Jo=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],Rs=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],LR=/^\/?Date\((-?\d+)/i,PR=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,MR={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function zr(o){var t,e,n=o._i,i=pR.exec(n)||IR.exec(n),l,r,a,c,d=Jo.length,u=Rs.length;if(i){for(Ot(o).iso=!0,t=0,e=d;t<e;t++)if(Jo[t][1].exec(i[1])){r=Jo[t][0],l=Jo[t][2]!==!1;break}if(r==null){o._isValid=!1;return}if(i[3]){for(t=0,e=u;t<e;t++)if(Rs[t][1].exec(i[3])){a=(i[2]||" ")+Rs[t][0];break}if(a==null){o._isValid=!1;return}}if(!l&&a!=null){o._isValid=!1;return}if(i[4])if(ER.exec(i[4]))c="Z";else{o._isValid=!1;return}o._f=r+(a||"")+(c||""),gs(o)}else o._isValid=!1}function OR(o,t,e,n,i,l){var r=[SR(o),Qr.indexOf(t),parseInt(e,10),parseInt(n,10),parseInt(i,10)];return l&&r.push(parseInt(l,10)),r}function SR(o){var t=parseInt(o,10);return t<=49?2e3+t:t<=999?1900+t:t}function DR(o){return o.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function FR(o,t,e){if(o){var n=kr.indexOf(o),i=new Date(t[0],t[1],t[2]).getDay();if(n!==i)return Ot(e).weekdayMismatch=!0,e._isValid=!1,!1}return!0}function XR(o,t,e){if(o)return MR[o];if(t)return 0;var n=parseInt(e,10),i=n%100,l=(n-i)/100;return l*60+i}function jr(o){var t=PR.exec(DR(o._i)),e;if(t){if(e=OR(t[4],t[3],t[2],t[5],t[6],t[7]),!FR(t[1],e,o))return;o._a=e,o._tzm=XR(t[8],t[9],t[10]),o._d=ho.apply(null,o._a),o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),Ot(o).rfc2822=!0}else o._isValid=!1}function NR(o){var t=LR.exec(o._i);if(t!==null){o._d=new Date(+t[1]);return}if(zr(o),o._isValid===!1)delete o._isValid;else return;if(jr(o),o._isValid===!1)delete o._isValid;else return;o._strict?o._isValid=!1:lt.createFromInputFallback(o)}lt.createFromInputFallback=De("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(o){o._d=new Date(o._i+(o._useUTC?" UTC":""))});function Jn(o,t,e){return o??t??e}function yR(o){var t=new Date(lt.now());return o._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function hs(o){var t,e,n=[],i,l,r;if(!o._d){for(i=yR(o),o._w&&o._a[xe]==null&&o._a[en]==null&&bR(o),o._dayOfYear!=null&&(r=Jn(o._a[ge],i[ge]),(o._dayOfYear>uo(r)||o._dayOfYear===0)&&(Ot(o)._overflowDayOfYear=!0),e=ho(r,0,o._dayOfYear),o._a[en]=e.getUTCMonth(),o._a[xe]=e.getUTCDate()),t=0;t<3&&o._a[t]==null;++t)o._a[t]=n[t]=i[t];for(;t<7;t++)o._a[t]=n[t]=o._a[t]==null?t===2?1:0:o._a[t];o._a[he]===24&&o._a[Ye]===0&&o._a[nn]===0&&o._a[Dn]===0&&(o._nextDay=!0,o._a[he]=0),o._d=(o._useUTC?ho:Zu).apply(null,n),l=o._useUTC?o._d.getUTCDay():o._d.getDay(),o._tzm!=null&&o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),o._nextDay&&(o._a[he]=24),o._w&&typeof o._w.d<"u"&&o._w.d!==l&&(Ot(o).weekdayMismatch=!0)}}function bR(o){var t,e,n,i,l,r,a,c,d;t=o._w,t.GG!=null||t.W!=null||t.E!=null?(l=1,r=4,e=Jn(t.GG,o._a[ge],go(ee(),1,4).year),n=Jn(t.W,1),i=Jn(t.E,1),(i<1||i>7)&&(c=!0)):(l=o._locale._week.dow,r=o._locale._week.doy,d=go(ee(),l,r),e=Jn(t.gg,o._a[ge],d.year),n=Jn(t.w,d.week),t.d!=null?(i=t.d,(i<0||i>6)&&(c=!0)):t.e!=null?(i=t.e+l,(t.e<0||t.e>6)&&(c=!0)):i=l),n<1||n>on(e,l,r)?Ot(o)._overflowWeeks=!0:c!=null?Ot(o)._overflowWeekday=!0:(a=Br(e,n,i,l,r),o._a[ge]=a.year,o._dayOfYear=a.dayOfYear)}lt.ISO_8601=function(){},lt.RFC_2822=function(){};function gs(o){if(o._f===lt.ISO_8601){zr(o);return}if(o._f===lt.RFC_2822){jr(o);return}o._a=[],Ot(o).empty=!0;var t=""+o._i,e,n,i,l,r,a=t.length,c=0,d,u;for(i=br(o._f,o._locale).match(qi)||[],u=i.length,e=0;e<u;e++)l=i[e],n=(t.match(pu(l,o))||[])[0],n&&(r=t.substr(0,t.indexOf(n)),r.length>0&&Ot(o).unusedInput.push(r),t=t.slice(t.indexOf(n)+n.length),c+=n.length),Bn[l]?(n?Ot(o).empty=!1:Ot(o).unusedTokens.push(l),Eu(l,n,o)):o._strict&&!n&&Ot(o).unusedTokens.push(l);Ot(o).charsLeftOver=a-c,t.length>0&&Ot(o).unusedInput.push(t),o._a[he]<=12&&Ot(o).bigHour===!0&&o._a[he]>0&&(Ot(o).bigHour=void 0),Ot(o).parsedDateParts=o._a.slice(0),Ot(o).meridiem=o._meridiem,o._a[he]=VR(o._locale,o._a[he],o._meridiem),d=Ot(o).era,d!==null&&(o._a[ge]=o._locale.erasConvertYear(d,o._a[ge])),hs(o),us(o)}function VR(o,t,e){var n;return e==null?t:o.meridiemHour!=null?o.meridiemHour(t,e):(o.isPM!=null&&(n=o.isPM(e),n&&t<12&&(t+=12),!n&&t===12&&(t=0)),t)}function WR(o){var t,e,n,i,l,r,a=!1,c=o._f.length;if(c===0){Ot(o).invalidFormat=!0,o._d=new Date(NaN);return}for(i=0;i<c;i++)l=0,r=!1,t=Ji({},o),o._useUTC!=null&&(t._useUTC=o._useUTC),t._f=o._f[i],gs(t),Gi(t)&&(r=!0),l+=Ot(t).charsLeftOver,l+=Ot(t).unusedTokens.length*10,Ot(t).score=l,a?l<n&&(n=l,e=t):(n==null||l<n||r)&&(n=l,e=t,r&&(a=!0));fn(o,e||t)}function YR(o){if(!o._d){var t=es(o._i),e=t.day===void 0?t.date:t.day;o._a=Dr([t.year,t.month,e,t.hour,t.minute,t.second,t.millisecond],function(n){return n&&parseInt(n,10)}),hs(o)}}function UR(o){var t=new lo(us(qr(o)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function qr(o){var t=o._i,e=o._f;return o._locale=o._locale||sn(o._l),t===null||e===void 0&&t===""?wo({nullInput:!0}):(typeof t=="string"&&(o._i=t=o._locale.preparse(t)),We(t)?new lo(us(t)):(ro(t)?o._d=t:Ve(e)?WR(o):e?gs(o):wR(o),Gi(o)||(o._d=null),o))}function wR(o){var t=o._i;pe(t)?o._d=new Date(lt.now()):ro(t)?o._d=new Date(t.valueOf()):typeof t=="string"?NR(o):Ve(t)?(o._a=Dr(t.slice(0),function(e){return parseInt(e,10)}),hs(o)):Sn(t)?YR(o):qe(t)?o._d=new Date(t):lt.createFromInputFallback(o)}function tl(o,t,e,n,i){var l={};return(t===!0||t===!1)&&(n=t,t=void 0),(e===!0||e===!1)&&(n=e,e=void 0),(Sn(o)&&Bi(o)||Ve(o)&&o.length===0)&&(o=void 0),l._isAMomentObject=!0,l._useUTC=l._isUTC=i,l._l=e,l._i=o,l._f=t,l._strict=n,UR(l)}function ee(o,t,e,n){return tl(o,t,e,n,!1)}var ZR=De("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=ee.apply(null,arguments);return this.isValid()&&o.isValid()?o<this?this:o:wo()}),vR=De("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=ee.apply(null,arguments);return this.isValid()&&o.isValid()?o>this?this:o:wo()});function el(o,t){var e,n;if(t.length===1&&Ve(t[0])&&(t=t[0]),!t.length)return ee();for(e=t[0],n=1;n<t.length;++n)(!t[n].isValid()||t[n][o](e))&&(e=t[n]);return e}function QR(){var o=[].slice.call(arguments,0);return el("isBefore",o)}function KR(){var o=[].slice.call(arguments,0);return el("isAfter",o)}var HR=function(){return Date.now?Date.now():+new Date},mo=["year","quarter","month","week","day","hour","minute","second","millisecond"];function AR(o){var t,e=!1,n,i=mo.length;for(t in o)if(Kt(o,t)&&!(ae.call(mo,t)!==-1&&(o[t]==null||!isNaN(o[t]))))return!1;for(n=0;n<i;++n)if(o[mo[n]]){if(e)return!1;parseFloat(o[mo[n]])!==Wt(o[mo[n]])&&(e=!0)}return!0}function _R(){return this._isValid}function BR(){return Ue(NaN)}function $o(o){var t=es(o),e=t.year||0,n=t.quarter||0,i=t.month||0,l=t.week||t.isoWeek||0,r=t.day||0,a=t.hour||0,c=t.minute||0,d=t.second||0,u=t.millisecond||0;this._isValid=AR(t),this._milliseconds=+u+d*1e3+c*6e4+a*1e3*60*60,this._days=+r+l*7,this._months=+i+n*3+e*12,this._data={},this._locale=sn(),this._bubble()}function zo(o){return o instanceof $o}function fs(o){return o<0?Math.round(-1*o)*-1:Math.round(o)}function kR(o,t,e){var n=Math.min(o.length,t.length),i=Math.abs(o.length-t.length),l=0,r;for(r=0;r<n;r++)Wt(o[r])!==Wt(t[r])&&l++;return l+i}function nl(o,t){ht(o,0,0,function(){var e=this.utcOffset(),n="+";return e<0&&(e=-e,n="-"),n+Ge(~~(e/60),2)+t+Ge(~~e%60,2)})}nl("Z",":"),nl("ZZ",""),ct("Z",_o),ct("ZZ",_o),kt(["Z","ZZ"],function(o,t,e){e._useUTC=!0,e._tzm=Ts(_o,o)});var GR=/([\+\-]|\d\d)/gi;function Ts(o,t){var e=(t||"").match(o),n,i,l;return e===null?null:(n=e[e.length-1]||[],i=(n+"").match(GR)||["-",0,0],l=+(i[1]*60)+Wt(i[2]),l===0?0:i[0]==="+"?l:-l)}function ms(o,t){var e,n;return t._isUTC?(e=t.clone(),n=(We(o)||ro(o)?o.valueOf():ee(o).valueOf())-e.valueOf(),e._d.setTime(e._d.valueOf()+n),lt.updateOffset(e,!1),e):ee(o).local()}function Cs(o){return-Math.round(o._d.getTimezoneOffset())}lt.updateOffset=function(){};function xR(o,t,e){var n=this._offset||0,i;if(!this.isValid())return o!=null?this:NaN;if(o!=null){if(typeof o=="string"){if(o=Ts(_o,o),o===null)return this}else Math.abs(o)<16&&!e&&(o=o*60);return!this._isUTC&&t&&(i=Cs(this)),this._offset=o,this._isUTC=!0,i!=null&&this.add(i,"m"),n!==o&&(!t||this._changeInProgress?rl(this,Ue(o-n,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,lt.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?n:Cs(this)}function JR(o,t){return o!=null?(typeof o!="string"&&(o=-o),this.utcOffset(o,t),this):-this.utcOffset()}function $R(o){return this.utcOffset(0,o)}function zR(o){return this._isUTC&&(this.utcOffset(0,o),this._isUTC=!1,o&&this.subtract(Cs(this),"m")),this}function jR(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var o=Ts(mu,this._i);o!=null?this.utcOffset(o):this.utcOffset(0,!0)}return this}function qR(o){return this.isValid()?(o=o?ee(o).utcOffset():0,(this.utcOffset()-o)%60===0):!1}function th(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function eh(){if(!pe(this._isDSTShifted))return this._isDSTShifted;var o={},t;return Ji(o,this),o=qr(o),o._a?(t=o._isUTC?Be(o._a):ee(o._a),this._isDSTShifted=this.isValid()&&kR(o._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function nh(){return this.isValid()?!this._isUTC:!1}function oh(){return this.isValid()?this._isUTC:!1}function ol(){return this.isValid()?this._isUTC&&this._offset===0:!1}var ih=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,sh=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Ue(o,t){var e=o,n=null,i,l,r;return zo(o)?e={ms:o._milliseconds,d:o._days,M:o._months}:qe(o)||!isNaN(+o)?(e={},t?e[t]=+o:e.milliseconds=+o):(n=ih.exec(o))?(i=n[1]==="-"?-1:1,e={y:0,d:Wt(n[xe])*i,h:Wt(n[he])*i,m:Wt(n[Ye])*i,s:Wt(n[nn])*i,ms:Wt(fs(n[Dn]*1e3))*i}):(n=sh.exec(o))?(i=n[1]==="-"?-1:1,e={y:Fn(n[2],i),M:Fn(n[3],i),w:Fn(n[4],i),d:Fn(n[5],i),h:Fn(n[6],i),m:Fn(n[7],i),s:Fn(n[8],i)}):e==null?e={}:typeof e=="object"&&("from"in e||"to"in e)&&(r=rh(ee(e.from),ee(e.to)),e={},e.ms=r.milliseconds,e.M=r.months),l=new $o(e),zo(o)&&Kt(o,"_locale")&&(l._locale=o._locale),zo(o)&&Kt(o,"_isValid")&&(l._isValid=o._isValid),l}Ue.fn=$o.prototype,Ue.invalid=BR;function Fn(o,t){var e=o&&parseFloat(o.replace(",","."));return(isNaN(e)?0:e)*t}function il(o,t){var e={};return e.months=t.month()-o.month()+(t.year()-o.year())*12,o.clone().add(e.months,"M").isAfter(t)&&--e.months,e.milliseconds=+t-+o.clone().add(e.months,"M"),e}function rh(o,t){var e;return o.isValid()&&t.isValid()?(t=ms(t,o),o.isBefore(t)?e=il(o,t):(e=il(t,o),e.milliseconds=-e.milliseconds,e.months=-e.months),e):{milliseconds:0,months:0}}function sl(o,t){return function(e,n){var i,l;return n!==null&&!isNaN(+n)&&(yr(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),l=e,e=n,n=l),i=Ue(e,n),rl(this,i,o),this}}function rl(o,t,e,n){var i=t._milliseconds,l=fs(t._days),r=fs(t._months);o.isValid()&&(n=n??!0,r&&Hr(o,Ro(o,"Month")+r*e),l&&vr(o,"Date",Ro(o,"Date")+l*e),i&&o._d.setTime(o._d.valueOf()+i*e),n&&lt.updateOffset(o,l||r))}var lh=sl(1,"add"),ah=sl(-1,"subtract");function ll(o){return typeof o=="string"||o instanceof String}function ch(o){return We(o)||ro(o)||ll(o)||qe(o)||uh(o)||dh(o)||o===null||o===void 0}function dh(o){var t=Sn(o)&&!Bi(o),e=!1,n=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],i,l,r=n.length;for(i=0;i<r;i+=1)l=n[i],e=e||Kt(o,l);return t&&e}function uh(o){var t=Ve(o),e=!1;return t&&(e=o.filter(function(n){return!qe(n)&&ll(o)}).length===0),t&&e}function Rh(o){var t=Sn(o)&&!Bi(o),e=!1,n=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],i,l;for(i=0;i<n.length;i+=1)l=n[i],e=e||Kt(o,l);return t&&e}function hh(o,t){var e=o.diff(t,"days",!0);return e<-6?"sameElse":e<-1?"lastWeek":e<0?"lastDay":e<1?"sameDay":e<2?"nextDay":e<7?"nextWeek":"sameElse"}function gh(o,t){arguments.length===1&&(arguments[0]?ch(arguments[0])?(o=arguments[0],t=void 0):Rh(arguments[0])&&(t=arguments[0],o=void 0):(o=void 0,t=void 0));var e=o||ee(),n=ms(e,this).startOf("day"),i=lt.calendarFormat(this,n)||"sameElse",l=t&&(ke(t[i])?t[i].call(this,e):t[i]);return this.format(l||this.localeData().calendar(i,this,ee(e)))}function fh(){return new lo(this)}function Th(o,t){var e=We(o)?o:ee(o);return this.isValid()&&e.isValid()?(t=Fe(t)||"millisecond",t==="millisecond"?this.valueOf()>e.valueOf():e.valueOf()<this.clone().startOf(t).valueOf()):!1}function mh(o,t){var e=We(o)?o:ee(o);return this.isValid()&&e.isValid()?(t=Fe(t)||"millisecond",t==="millisecond"?this.valueOf()<e.valueOf():this.clone().endOf(t).valueOf()<e.valueOf()):!1}function Ch(o,t,e,n){var i=We(o)?o:ee(o),l=We(t)?t:ee(t);return this.isValid()&&i.isValid()&&l.isValid()?(n=n||"()",(n[0]==="("?this.isAfter(i,e):!this.isBefore(i,e))&&(n[1]===")"?this.isBefore(l,e):!this.isAfter(l,e))):!1}function ph(o,t){var e=We(o)?o:ee(o),n;return this.isValid()&&e.isValid()?(t=Fe(t)||"millisecond",t==="millisecond"?this.valueOf()===e.valueOf():(n=e.valueOf(),this.clone().startOf(t).valueOf()<=n&&n<=this.clone().endOf(t).valueOf())):!1}function Ih(o,t){return this.isSame(o,t)||this.isAfter(o,t)}function Eh(o,t){return this.isSame(o,t)||this.isBefore(o,t)}function Lh(o,t,e){var n,i,l;if(!this.isValid())return NaN;if(n=ms(o,this),!n.isValid())return NaN;switch(i=(n.utcOffset()-this.utcOffset())*6e4,t=Fe(t),t){case"year":l=jo(this,n)/12;break;case"month":l=jo(this,n);break;case"quarter":l=jo(this,n)/3;break;case"second":l=(this-n)/1e3;break;case"minute":l=(this-n)/6e4;break;case"hour":l=(this-n)/36e5;break;case"day":l=(this-n-i)/864e5;break;case"week":l=(this-n-i)/6048e5;break;default:l=this-n}return e?l:Xe(l)}function jo(o,t){if(o.date()<t.date())return-jo(t,o);var e=(t.year()-o.year())*12+(t.month()-o.month()),n=o.clone().add(e,"months"),i,l;return t-n<0?(i=o.clone().add(e-1,"months"),l=(t-n)/(n-i)):(i=o.clone().add(e+1,"months"),l=(t-n)/(i-n)),-(e+l)||0}lt.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",lt.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function Ph(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function Mh(o){if(!this.isValid())return null;var t=o!==!0,e=t?this.clone().utc():this;return e.year()<0||e.year()>9999?vo(e,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):ke(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",vo(e,"Z")):vo(e,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function Oh(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var o="moment",t="",e,n,i,l;return this.isLocal()||(o=this.utcOffset()===0?"moment.utc":"moment.parseZone",t="Z"),e="["+o+'("]',n=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i="-MM-DD[T]HH:mm:ss.SSS",l=t+'[")]',this.format(e+n+i+l)}function Sh(o){o||(o=this.isUtc()?lt.defaultFormatUtc:lt.defaultFormat);var t=vo(this,o);return this.localeData().postformat(t)}function Dh(o,t){return this.isValid()&&(We(o)&&o.isValid()||ee(o).isValid())?Ue({to:this,from:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Fh(o){return this.from(ee(),o)}function Xh(o,t){return this.isValid()&&(We(o)&&o.isValid()||ee(o).isValid())?Ue({from:this,to:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Nh(o){return this.to(ee(),o)}function al(o){var t;return o===void 0?this._locale._abbr:(t=sn(o),t!=null&&(this._locale=t),this)}var cl=De("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(o){return o===void 0?this.localeData():this.locale(o)});function dl(){return this._locale}var qo=1e3,$n=60*qo,ti=60*$n,ul=(365*400+97)*24*ti;function zn(o,t){return(o%t+t)%t}function Rl(o,t,e){return o<100&&o>=0?new Date(o+400,t,e)-ul:new Date(o,t,e).valueOf()}function hl(o,t,e){return o<100&&o>=0?Date.UTC(o+400,t,e)-ul:Date.UTC(o,t,e)}function yh(o){var t,e;if(o=Fe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?hl:Rl,o){case"year":t=e(this.year(),0,1);break;case"quarter":t=e(this.year(),this.month()-this.month()%3,1);break;case"month":t=e(this.year(),this.month(),1);break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":t=e(this.year(),this.month(),this.date());break;case"hour":t=this._d.valueOf(),t-=zn(t+(this._isUTC?0:this.utcOffset()*$n),ti);break;case"minute":t=this._d.valueOf(),t-=zn(t,$n);break;case"second":t=this._d.valueOf(),t-=zn(t,qo);break}return this._d.setTime(t),lt.updateOffset(this,!0),this}function bh(o){var t,e;if(o=Fe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?hl:Rl,o){case"year":t=e(this.year()+1,0,1)-1;break;case"quarter":t=e(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":t=e(this.year(),this.month()+1,1)-1;break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":t=e(this.year(),this.month(),this.date()+1)-1;break;case"hour":t=this._d.valueOf(),t+=ti-zn(t+(this._isUTC?0:this.utcOffset()*$n),ti)-1;break;case"minute":t=this._d.valueOf(),t+=$n-zn(t,$n)-1;break;case"second":t=this._d.valueOf(),t+=qo-zn(t,qo)-1;break}return this._d.setTime(t),lt.updateOffset(this,!0),this}function Vh(){return this._d.valueOf()-(this._offset||0)*6e4}function Wh(){return Math.floor(this.valueOf()/1e3)}function Yh(){return new Date(this.valueOf())}function Uh(){var o=this;return[o.year(),o.month(),o.date(),o.hour(),o.minute(),o.second(),o.millisecond()]}function wh(){var o=this;return{years:o.year(),months:o.month(),date:o.date(),hours:o.hours(),minutes:o.minutes(),seconds:o.seconds(),milliseconds:o.milliseconds()}}function Zh(){return this.isValid()?this.toISOString():null}function vh(){return Gi(this)}function Qh(){return fn({},Ot(this))}function Kh(){return Ot(this).overflow}function Hh(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}ht("N",0,0,"eraAbbr"),ht("NN",0,0,"eraAbbr"),ht("NNN",0,0,"eraAbbr"),ht("NNNN",0,0,"eraName"),ht("NNNNN",0,0,"eraNarrow"),ht("y",["y",1],"yo","eraYear"),ht("y",["yy",2],0,"eraYear"),ht("y",["yyy",3],0,"eraYear"),ht("y",["yyyy",4],0,"eraYear"),ct("N",ps),ct("NN",ps),ct("NNN",ps),ct("NNNN",qh),ct("NNNNN",tg),kt(["N","NN","NNN","NNNN","NNNNN"],function(o,t,e,n){var i=e._locale.erasParse(o,n,e._strict);i?Ot(e).era=i:Ot(e).invalidEra=o}),ct("y",kn),ct("yy",kn),ct("yyy",kn),ct("yyyy",kn),ct("yo",eg),kt(["y","yy","yyy","yyyy"],ge),kt(["yo"],function(o,t,e,n){var i;e._locale._eraYearOrdinalRegex&&(i=o.match(e._locale._eraYearOrdinalRegex)),e._locale.eraYearOrdinalParse?t[ge]=e._locale.eraYearOrdinalParse(o,i):t[ge]=parseInt(o,10)});function Ah(o,t){var e,n,i,l=this._eras||sn("en")._eras;for(e=0,n=l.length;e<n;++e)switch(typeof l[e].since==="string"&&(i=lt(l[e].since).startOf("day"),l[e].since=i.valueOf()),typeof l[e].until){case"undefined":l[e].until=1/0;break;case"string":i=lt(l[e].until).startOf("day").valueOf(),l[e].until=i.valueOf();break}return l}function _h(o,t,e){var n,i,l=this.eras(),r,a,c;for(o=o.toUpperCase(),n=0,i=l.length;n<i;++n)if(r=l[n].name.toUpperCase(),a=l[n].abbr.toUpperCase(),c=l[n].narrow.toUpperCase(),e)switch(t){case"N":case"NN":case"NNN":if(a===o)return l[n];break;case"NNNN":if(r===o)return l[n];break;case"NNNNN":if(c===o)return l[n];break}else if([r,a,c].indexOf(o)>=0)return l[n]}function Bh(o,t){var e=o.since<=o.until?1:-1;return t===void 0?lt(o.since).year():lt(o.since).year()+(t-o.offset)*e}function kh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].name;return""}function Gh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].narrow;return""}function xh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].abbr;return""}function Jh(){var o,t,e,n,i=this.localeData().eras();for(o=0,t=i.length;o<t;++o)if(e=i[o].since<=i[o].until?1:-1,n=this.clone().startOf("day").valueOf(),i[o].since<=n&&n<=i[o].until||i[o].until<=n&&n<=i[o].since)return(this.year()-lt(i[o].since).year())*e+i[o].offset;return this.year()}function $h(o){return Kt(this,"_erasNameRegex")||Is.call(this),o?this._erasNameRegex:this._erasRegex}function zh(o){return Kt(this,"_erasAbbrRegex")||Is.call(this),o?this._erasAbbrRegex:this._erasRegex}function jh(o){return Kt(this,"_erasNarrowRegex")||Is.call(this),o?this._erasNarrowRegex:this._erasRegex}function ps(o,t){return t.erasAbbrRegex(o)}function qh(o,t){return t.erasNameRegex(o)}function tg(o,t){return t.erasNarrowRegex(o)}function eg(o,t){return t._eraYearOrdinalRegex||kn}function Is(){var o=[],t=[],e=[],n=[],i,l,r,a,c,d=this.eras();for(i=0,l=d.length;i<l;++i)r=tn(d[i].name),a=tn(d[i].abbr),c=tn(d[i].narrow),t.push(r),o.push(a),e.push(c),n.push(r),n.push(a),n.push(c);this._erasRegex=new RegExp("^("+n.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+t.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+o.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+e.join("|")+")","i")}ht(0,["gg",2],0,function(){return this.weekYear()%100}),ht(0,["GG",2],0,function(){return this.isoWeekYear()%100});function ei(o,t){ht(0,[o,o.length],0,t)}ei("gggg","weekYear"),ei("ggggg","weekYear"),ei("GGGG","isoWeekYear"),ei("GGGGG","isoWeekYear"),ct("G",Ao),ct("g",Ao),ct("GG",te,Pe),ct("gg",te,Pe),ct("GGGG",os,ns),ct("gggg",os,ns),ct("GGGGG",Ho,Qo),ct("ggggg",Ho,Qo),co(["gggg","ggggg","GGGG","GGGGG"],function(o,t,e,n){t[n.substr(0,2)]=Wt(o)}),co(["gg","GG"],function(o,t,e,n){t[n]=lt.parseTwoDigitYear(o)});function ng(o){return gl.call(this,o,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function og(o){return gl.call(this,o,this.isoWeek(),this.isoWeekday(),1,4)}function ig(){return on(this.year(),1,4)}function sg(){return on(this.isoWeekYear(),1,4)}function rg(){var o=this.localeData()._week;return on(this.year(),o.dow,o.doy)}function lg(){var o=this.localeData()._week;return on(this.weekYear(),o.dow,o.doy)}function gl(o,t,e,n,i){var l;return o==null?go(this,n,i).year:(l=on(o,n,i),t>l&&(t=l),ag.call(this,o,t,e,n,i))}function ag(o,t,e,n,i){var l=Br(o,t,e,n,i),r=ho(l.year,0,l.dayOfYear);return this.year(r.getUTCFullYear()),this.month(r.getUTCMonth()),this.date(r.getUTCDate()),this}ht("Q",0,"Qo","quarter"),ct("Q",Wr),kt("Q",function(o,t){t[en]=(Wt(o)-1)*3});function cg(o){return o==null?Math.ceil((this.month()+1)/3):this.month((o-1)*3+this.month()%3)}ht("D",["DD",2],"Do","date"),ct("D",te,Gn),ct("DD",te,Pe),ct("Do",function(o,t){return o?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),kt(["D","DD"],xe),kt("Do",function(o,t){t[xe]=Wt(o.match(te)[0])});var fl=xn("Date",!0);ht("DDD",["DDDD",3],"DDDo","dayOfYear"),ct("DDD",Ko),ct("DDDD",Yr),kt(["DDD","DDDD"],function(o,t,e){e._dayOfYear=Wt(o)});function dg(o){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return o==null?t:this.add(o-t,"d")}ht("m",["mm",2],0,"minute"),ct("m",te,is),ct("mm",te,Pe),kt(["m","mm"],Ye);var ug=xn("Minutes",!1);ht("s",["ss",2],0,"second"),ct("s",te,is),ct("ss",te,Pe),kt(["s","ss"],nn);var Rg=xn("Seconds",!1);ht("S",0,0,function(){return~~(this.millisecond()/100)}),ht(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),ht(0,["SSS",3],0,"millisecond"),ht(0,["SSSS",4],0,function(){return this.millisecond()*10}),ht(0,["SSSSS",5],0,function(){return this.millisecond()*100}),ht(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),ht(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),ht(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),ht(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),ct("S",Ko,Wr),ct("SS",Ko,Pe),ct("SSS",Ko,Yr);var mn,Tl;for(mn="SSSS";mn.length<=9;mn+="S")ct(mn,kn);function hg(o,t){t[Dn]=Wt(("0."+o)*1e3)}for(mn="S";mn.length<=9;mn+="S")kt(mn,hg);Tl=xn("Milliseconds",!1),ht("z",0,0,"zoneAbbr"),ht("zz",0,0,"zoneName");function gg(){return this._isUTC?"UTC":""}function fg(){return this._isUTC?"Coordinated Universal Time":""}var $=lo.prototype;$.add=lh,$.calendar=gh,$.clone=fh,$.diff=Lh,$.endOf=bh,$.format=Sh,$.from=Dh,$.fromNow=Fh,$.to=Xh,$.toNow=Nh,$.get=Ou,$.invalidAt=Kh,$.isAfter=Th,$.isBefore=mh,$.isBetween=Ch,$.isSame=ph,$.isSameOrAfter=Ih,$.isSameOrBefore=Eh,$.isValid=vh,$.lang=cl,$.locale=al,$.localeData=dl,$.max=vR,$.min=ZR,$.parsingFlags=Qh,$.set=Su,$.startOf=yh,$.subtract=ah,$.toArray=Uh,$.toObject=wh,$.toDate=Yh,$.toISOString=Mh,$.inspect=Oh,typeof Symbol<"u"&&Symbol.for!=null&&($[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),$.toJSON=Zh,$.toString=Ph,$.unix=Wh,$.valueOf=Vh,$.creationData=Hh,$.eraName=kh,$.eraNarrow=Gh,$.eraAbbr=xh,$.eraYear=Jh,$.year=Zr,$.isLeapYear=Mu,$.weekYear=ng,$.isoWeekYear=og,$.quarter=$.quarters=cg,$.month=Ar,$.daysInMonth=Yu,$.week=$.weeks=Au,$.isoWeek=$.isoWeeks=_u,$.weeksInYear=rg,$.weeksInWeekYear=lg,$.isoWeeksInYear=ig,$.isoWeeksInISOWeekYear=sg,$.date=fl,$.day=$.days=oR,$.weekday=iR,$.isoWeekday=sR,$.dayOfYear=dg,$.hour=$.hours=RR,$.minute=$.minutes=ug,$.second=$.seconds=Rg,$.millisecond=$.milliseconds=Tl,$.utcOffset=xR,$.utc=$R,$.local=zR,$.parseZone=jR,$.hasAlignedHourOffset=qR,$.isDST=th,$.isLocal=nh,$.isUtcOffset=oh,$.isUtc=ol,$.isUTC=ol,$.zoneAbbr=gg,$.zoneName=fg,$.dates=De("dates accessor is deprecated. Use date instead.",fl),$.months=De("months accessor is deprecated. Use month instead",Ar),$.years=De("years accessor is deprecated. Use year instead",Zr),$.zone=De("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",JR),$.isDSTShifted=De("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",eh);function Tg(o){return ee(o*1e3)}function mg(){return ee.apply(null,arguments).parseZone()}function ml(o){return o}var Ht=zi.prototype;Ht.calendar=nu,Ht.longDateFormat=ru,Ht.invalidDate=au,Ht.ordinal=uu,Ht.preparse=ml,Ht.postformat=ml,Ht.relativeTime=hu,Ht.pastFuture=gu,Ht.set=tu,Ht.eras=Ah,Ht.erasParse=_h,Ht.erasConvertYear=Bh,Ht.erasAbbrRegex=zh,Ht.erasNameRegex=$h,Ht.erasNarrowRegex=jh,Ht.months=yu,Ht.monthsShort=bu,Ht.monthsParse=Wu,Ht.monthsRegex=wu,Ht.monthsShortRegex=Uu,Ht.week=vu,Ht.firstDayOfYear=Hu,Ht.firstDayOfWeek=Ku,Ht.weekdays=ju,Ht.weekdaysMin=tR,Ht.weekdaysShort=qu,Ht.weekdaysParse=nR,Ht.weekdaysRegex=rR,Ht.weekdaysShortRegex=lR,Ht.weekdaysMinRegex=aR,Ht.isPM=dR,Ht.meridiem=hR;function ni(o,t,e,n){var i=sn(),l=Be().set(n,t);return i[e](l,o)}function Cl(o,t,e){if(qe(o)&&(t=o,o=void 0),o=o||"",t!=null)return ni(o,t,e,"month");var n,i=[];for(n=0;n<12;n++)i[n]=ni(o,n,e,"month");return i}function Es(o,t,e,n){typeof o=="boolean"?(qe(t)&&(e=t,t=void 0),t=t||""):(t=o,e=t,o=!1,qe(t)&&(e=t,t=void 0),t=t||"");var i=sn(),l=o?i._week.dow:0,r,a=[];if(e!=null)return ni(t,(e+l)%7,n,"day");for(r=0;r<7;r++)a[r]=ni(t,(r+l)%7,n,"day");return a}function Cg(o,t){return Cl(o,t,"months")}function pg(o,t){return Cl(o,t,"monthsShort")}function Ig(o,t,e){return Es(o,t,e,"weekdays")}function Eg(o,t,e){return Es(o,t,e,"weekdaysShort")}function Lg(o,t,e){return Es(o,t,e,"weekdaysMin")}Tn("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(o){var t=o%10,e=Wt(o%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return o+e}}),lt.lang=De("moment.lang is deprecated. Use moment.locale instead.",Tn),lt.langData=De("moment.langData is deprecated. Use moment.localeData instead.",sn);var rn=Math.abs;function Pg(){var o=this._data;return this._milliseconds=rn(this._milliseconds),this._days=rn(this._days),this._months=rn(this._months),o.milliseconds=rn(o.milliseconds),o.seconds=rn(o.seconds),o.minutes=rn(o.minutes),o.hours=rn(o.hours),o.months=rn(o.months),o.years=rn(o.years),this}function pl(o,t,e,n){var i=Ue(t,e);return o._milliseconds+=n*i._milliseconds,o._days+=n*i._days,o._months+=n*i._months,o._bubble()}function Mg(o,t){return pl(this,o,t,1)}function Og(o,t){return pl(this,o,t,-1)}function Il(o){return o<0?Math.floor(o):Math.ceil(o)}function Sg(){var o=this._milliseconds,t=this._days,e=this._months,n=this._data,i,l,r,a,c;return o>=0&&t>=0&&e>=0||o<=0&&t<=0&&e<=0||(o+=Il(Ls(e)+t)*864e5,t=0,e=0),n.milliseconds=o%1e3,i=Xe(o/1e3),n.seconds=i%60,l=Xe(i/60),n.minutes=l%60,r=Xe(l/60),n.hours=r%24,t+=Xe(r/24),c=Xe(El(t)),e+=c,t-=Il(Ls(c)),a=Xe(e/12),e%=12,n.days=t,n.months=e,n.years=a,this}function El(o){return o*4800/146097}function Ls(o){return o*146097/4800}function Dg(o){if(!this.isValid())return NaN;var t,e,n=this._milliseconds;if(o=Fe(o),o==="month"||o==="quarter"||o==="year")switch(t=this._days+n/864e5,e=this._months+El(t),o){case"month":return e;case"quarter":return e/3;case"year":return e/12}else switch(t=this._days+Math.round(Ls(this._months)),o){case"week":return t/7+n/6048e5;case"day":return t+n/864e5;case"hour":return t*24+n/36e5;case"minute":return t*1440+n/6e4;case"second":return t*86400+n/1e3;case"millisecond":return Math.floor(t*864e5)+n;default:throw new Error("Unknown unit "+o)}}function ln(o){return function(){return this.as(o)}}var Ll=ln("ms"),Fg=ln("s"),Xg=ln("m"),Ng=ln("h"),yg=ln("d"),bg=ln("w"),Vg=ln("M"),Wg=ln("Q"),Yg=ln("y"),Ug=Ll;function wg(){return Ue(this)}function Zg(o){return o=Fe(o),this.isValid()?this[o+"s"]():NaN}function Xn(o){return function(){return this.isValid()?this._data[o]:NaN}}var vg=Xn("milliseconds"),Qg=Xn("seconds"),Kg=Xn("minutes"),Hg=Xn("hours"),Ag=Xn("days"),_g=Xn("months"),Bg=Xn("years");function kg(){return Xe(this.days()/7)}var an=Math.round,jn={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Gg(o,t,e,n,i){return i.relativeTime(t||1,!!e,o,n)}function xg(o,t,e,n){var i=Ue(o).abs(),l=an(i.as("s")),r=an(i.as("m")),a=an(i.as("h")),c=an(i.as("d")),d=an(i.as("M")),u=an(i.as("w")),h=an(i.as("y")),R=l<=e.ss&&["s",l]||l<e.s&&["ss",l]||r<=1&&["m"]||r<e.m&&["mm",r]||a<=1&&["h"]||a<e.h&&["hh",a]||c<=1&&["d"]||c<e.d&&["dd",c];return e.w!=null&&(R=R||u<=1&&["w"]||u<e.w&&["ww",u]),R=R||d<=1&&["M"]||d<e.M&&["MM",d]||h<=1&&["y"]||["yy",h],R[2]=t,R[3]=+o>0,R[4]=n,Gg.apply(null,R)}function Jg(o){return o===void 0?an:typeof o=="function"?(an=o,!0):!1}function $g(o,t){return jn[o]===void 0?!1:t===void 0?jn[o]:(jn[o]=t,o==="s"&&(jn.ss=t-1),!0)}function zg(o,t){if(!this.isValid())return this.localeData().invalidDate();var e=!1,n=jn,i,l;return typeof o=="object"&&(t=o,o=!1),typeof o=="boolean"&&(e=o),typeof t=="object"&&(n=Object.assign({},jn,t),t.s!=null&&t.ss==null&&(n.ss=t.s-1)),i=this.localeData(),l=xg(this,!e,n,i),e&&(l=i.pastFuture(+this,l)),i.postformat(l)}var Ps=Math.abs;function qn(o){return(o>0)-(o<0)||+o}function oi(){if(!this.isValid())return this.localeData().invalidDate();var o=Ps(this._milliseconds)/1e3,t=Ps(this._days),e=Ps(this._months),n,i,l,r,a=this.asSeconds(),c,d,u,h;return a?(n=Xe(o/60),i=Xe(n/60),o%=60,n%=60,l=Xe(e/12),e%=12,r=o?o.toFixed(3).replace(/\.?0+$/,""):"",c=a<0?"-":"",d=qn(this._months)!==qn(a)?"-":"",u=qn(this._days)!==qn(a)?"-":"",h=qn(this._milliseconds)!==qn(a)?"-":"",c+"P"+(l?d+l+"Y":"")+(e?d+e+"M":"")+(t?u+t+"D":"")+(i||n||o?"T":"")+(i?h+i+"H":"")+(n?h+n+"M":"")+(o?h+r+"S":"")):"P0D"}var Ut=$o.prototype;Ut.isValid=_R,Ut.abs=Pg,Ut.add=Mg,Ut.subtract=Og,Ut.as=Dg,Ut.asMilliseconds=Ll,Ut.asSeconds=Fg,Ut.asMinutes=Xg,Ut.asHours=Ng,Ut.asDays=yg,Ut.asWeeks=bg,Ut.asMonths=Vg,Ut.asQuarters=Wg,Ut.asYears=Yg,Ut.valueOf=Ug,Ut._bubble=Sg,Ut.clone=wg,Ut.get=Zg,Ut.milliseconds=vg,Ut.seconds=Qg,Ut.minutes=Kg,Ut.hours=Hg,Ut.days=Ag,Ut.weeks=kg,Ut.months=_g,Ut.years=Bg,Ut.humanize=zg,Ut.toISOString=oi,Ut.toString=oi,Ut.toJSON=oi,Ut.locale=al,Ut.localeData=dl,Ut.toIsoString=De("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",oi),Ut.lang=cl,ht("X",0,0,"unix"),ht("x",0,0,"valueOf"),ct("x",Ao),ct("X",Cu),kt("X",function(o,t,e){e._d=new Date(parseFloat(o)*1e3)}),kt("x",function(o,t,e){e._d=new Date(Wt(o))});lt.version="2.30.1",jd(ee),lt.fn=$,lt.min=QR,lt.max=KR,lt.now=HR,lt.utc=Be,lt.unix=Tg,lt.months=Cg,lt.isDate=ro,lt.locale=Tn,lt.invalid=wo,lt.duration=Ue,lt.isMoment=We,lt.weekdays=Ig,lt.parseZone=mg,lt.localeData=sn,lt.isDuration=zo,lt.monthsShort=pg,lt.weekdaysMin=Lg,lt.defineLocale=ds,lt.updateLocale=mR,lt.locales=CR,lt.weekdaysShort=Eg,lt.normalizeUnits=Fe,lt.relativeTimeRounding=Jg,lt.relativeTimeThreshold=$g,lt.calendarFormat=hh,lt.prototype=$,lt.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};class Ms{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),l=t?null:i.getTd();n>=e.length&&(n=e.length-1);const r=e[n],a=[];let c=l,d=e,u=n;for(;;){if(u<0&&c?.linkTdPrevId){const T=i.getTdById(c.linkTdPrevId);if(T){d=T.value,u=d.length-1,c=T;continue}}if(u<0)break;const g=d[u];if(g.controlId!==r.controlId||g.controlComponent===s.ControlComponent.PREFIX||g.controlComponent===s.ControlComponent.PRE_TEXT)break;g.controlComponent===s.ControlComponent.VALUE&&a.unshift(g),u--}c=l;let h=e,R=n+1;for(;;){if(R>=h.length&&c?.linkTdNextId){const T=i.getTdById(c.linkTdNextId);if(T){h=T.value,R=0,c=T;continue}}const g=h[R];if(!g||g.controlId!==r.controlId||g.controlComponent===s.ControlComponent.POSTFIX||g.controlComponent===s.ControlComponent.POST_TEXT)break;g.controlComponent===s.ControlComponent.VALUE&&a.push(g),R++}return a.filter(g=>g.type!==s.ElementType.SPLIT_TAG)}removeNextControlElement(t,e){const n=this.control.getDraw();if(e=e??n.getTd()?.linkTdNextId,e){const i=n.getTdById(e);if(i){if(i.value.length){if(i.value[1].controlId===t)return n.spliceElementList(i.value,1,1),i.value[1]}else if(i.linkTdNextId)return this.removeNextControlElement(t,i.linkTdNextId)}}}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const i=e.range||this.control.getRange(),l=e.elementList||this.control.getElementList(),r=l[i.startIndex],a=l[i.startIndex+1],c=b=>!!(b&&(b.controlComponent===s.ControlComponent.POSTFIX||b.controlComponent===s.ControlComponent.POST_TEXT||b.controlComponent===s.ControlComponent.POSTTEXTFIX||b.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)),d=!!(r?.originControlId&&c(r)&&a?.controlId===r.originControlId&&!a.originControlId&&a.control?.type===s.ControlType.TEXTFIELD&&c(a));let u=this.element.controlId||r?.controlId,h=this.element.originControlId||(this.element.controlId===r?.controlId?r?.originControlId:void 0),R=this.element.control||r.control;const f=!!(r?.controlId&&r.controlId!==this.element.controlId&&!r.originControlId&&r.control?.type===s.ControlType.TEXTFIELD);d?(u=r.originControlId,h=void 0,R=a.control):f&&(u=r.controlId,h=void 0,R=r.control);const g=!!u&&r?.controlId!==u&&this._findNearestTextAncestorId(l,r?.originControlId)===u;!g&&!d&&!f&&(this.control.mergeControl(e),this.control.shrinkBoundary(e));const{startIndex:T,endIndex:C}=i,p=this.control.getDraw();T!==C?p.spliceElementList(l,T+1,C-T,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):g||d||f?this._removePlaceholdersByControl(l,u,h||null):this.control.removePlaceholder(T,{elementList:l});const I=l[T];g||d||f?this._removePlaceholdersByControl(l,u,h||null):this._removeControlPlaceholders(l,T);const m=I.type&&!Le.includes(I.type)||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRE_TEXT?xt(I,["control","controlId","originControlId",...Re]):Ee(I,["type"]),L=g||d||f,P=b=>{Re.forEach(S=>{delete b[S];const y=R?.[S];y!==void 0&&(b[S]=y)}),delete b.underline,delete b.textDecoration,R?.type===s.ControlType.TEXT&&b.color?.toLowerCase()==="#87d068"?b.color=this.options.defaultColor:b.color||(b.color=this.options.defaultColor)};L&&P(m),m.controlId=u,R&&(m.control=R),h?m.originControlId=h:delete m.originControlId;const M=this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.inputTraceEnabled,F=i.startIndex+1,N=[],Y=b=>{const S=N.length?N:l,y=N.length?N.length-1:d?i.startIndex+1:i.startIndex;se(S,[b],y,{editorOptions:this.options}),N.push(b)};for(let b=0;b<t.length;b++){const S=t[b];if(S.type===s.ElementType.CONTROL&&S.control){const y=S,V=y.controlId||mt(),X=y.control?.value||[],O=y.control?.type,E=O===s.ControlType.TEXTFIELD,W=E?this.options.control.textFixColor:O===s.ControlType.TEXT||O===s.ControlType.NUMBER?"#87d068":this.options.control.bracketColor,U={...Ee(m,["underline","textDecoration"]),controlId:V,type:s.ElementType.CONTROL,control:y.control,originControlId:u},Z=E?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,Q=E?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,v=E?y.control?.preTextFix||this.options.control.preTextFix:y.control?.prefix||this.options.control.prefix;for(let B=0;B<v.length;B++){const H={...U,color:W,value:v[B],controlComponent:Z};Y(H)}for(let B=0;B<X.length;B++){const H=X[B],k={...U,...H,controlComponent:s.ControlComponent.VALUE};(k.color===this.options.control.bracketColor||k.color===this.options.control.placeholderColor)&&(k.color=this.options.defaultColor),Y(k)}if(X.length===0){const B=y.control?.placeholder||"";for(let H=0;H<B.length;H++){const k={...U,value:B[H],controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};Y(k)}}const st=E?y.control?.postTextFix||this.options.control.postTextFix:y.control?.postfix||this.options.control.postfix;for(let B=0;B<st.length;B++){const H={...U,color:W,value:st[B],controlComponent:Q};Y(H)}}else if(S.type||S.value){(I.controlComponent===s.ControlComponent.PRE_TEXT||I.controlComponent===s.ControlComponent.POST_TEXT||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.POSTFIX)&&(m.color=this.options.defaultColor);const V=Ee(S,["control","controlId","controlComponent","originControlId"]),X={...m,...V,controlComponent:s.ControlComponent.VALUE};L&&P(X),(X.color===this.options.control.bracketColor||X.color===this.options.control.placeholderColor||X.color===this.options.control.textFixColor)&&(X.color=this.options.defaultColor),X.strikeout&&delete X.strikeout,M&&(X.textDecoration={style:s.TextDecorationStyle.DOUBLE},X.underline=!0),Y(X)}}return N.length&&p.spliceElementList(l,F,0,N),i.startIndex+N.length}_removeControlPlaceholders(t,e){const n=t[e];if(!n?.controlId)return;const i=a=>!!a&&a.controlId===n.controlId&&a.originControlId===n.originControlId;let l=e;for(;l>=0&&i(t[l]);)l--;let r=e+1;for(;r<t.length&&i(t[r]);)r++;for(let a=r-1;a>l;a--)t[a].controlComponent===s.ControlComponent.PLACEHOLDER&&t.splice(a,1)}_removePlaceholdersByControl(t,e,n){if(e)for(let i=t.length-1;i>=0;i--){const l=t[i];l.controlId===e&&(l.originControlId||null)===n&&l.controlComponent===s.ControlComponent.PLACEHOLDER&&t.splice(i,1)}}_findNearestTextAncestorId(t,e){if(!e)return null;const n=new Set;let i=e,l=null;for(;i&&!n.has(i);){n.add(i);let r;for(let a=0;a<t.length;a++){const c=t[a];if(c.controlId===i&&c.control?.type&&(r=c,c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRE_TEXT||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!r)break;(r.control?.type===s.ControlType.TEXT||this.options.mode===s.EditorMode.EDIT&&r.control?.type===s.ControlType.TEXTFIELD)&&(l=i),i=r.originControlId||null}return l}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange();this.control.shrinkBoundary(t);const{startIndex:l,endIndex:r}=i;return this.control.getDraw().spliceElementList(n,l+1,r-l,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),e.isAddPlaceholder!==!1&&(this.getValue(t).length||this.control.addPlaceholder(l,t)),l}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.control.getDraw(),d=this.options.mode===s.EditorMode.FORM,u=this.element.controlId||r.controlId,h=this.element.originControlId||r.originControlId||null,R=E=>{if(!E)return null;const W=new Set;let D=E,U=null;for(;D&&!W.has(D);){W.add(D);let Z;for(let Q=0;Q<e.length;Q++){const v=e[Q];if(v.controlId===D&&v.control?.type&&(Z=v,v.controlComponent===s.ControlComponent.PREFIX||v.controlComponent===s.ControlComponent.PRE_TEXT||v.controlComponent===s.ControlComponent.PRETEXTFIX||v.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!Z)break;(Z.control?.type===s.ControlType.TEXT||this.options.mode===s.EditorMode.EDIT&&Z.control?.type===s.ControlType.TEXTFIELD)&&(U=D),D=Z.originControlId||null}return U},f=R(h),g=!!f,T=r.controlId===u&&(r.originControlId||null)===h,C=r.controlComponent===s.ControlComponent.VALUE,p=E=>{for(let W=i-1;W>=0;W--){const D=e[W];if(D.controlId===E&&!D.originControlId){if(D.controlComponent===s.ControlComponent.VALUE||D.controlComponent===s.ControlComponent.PLACEHOLDER)return W;if(D.controlComponent===s.ControlComponent.PREFIX||D.controlComponent===s.ControlComponent.PRE_TEXT||D.controlComponent===s.ControlComponent.PRETEXTFIX||D.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)break}if(D.controlId&&D.controlId!==E&&D.originControlId!==E)break}return-1},I=(E,W)=>{for(let D=E;D>=0;D--){const U=e[D];if(U.controlId===W&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.PREFIX||U.controlComponent===s.ControlComponent.PRE_TEXT||U.controlComponent===s.ControlComponent.PRETEXTFIX||U.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))return D;if(U.controlId&&U.controlId!==W&&U.originControlId!==W)break}for(let D=E+1;D<e.length;D++){const U=e[D];if(U.controlId===W&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.POSTFIX||U.controlComponent===s.ControlComponent.POST_TEXT||U.controlComponent===s.ControlComponent.POSTTEXTFIX||U.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return D;if(U.controlId&&U.controlId!==W&&U.originControlId!==W)break}return E},L=g&&T&&(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PRETEXTFIX||r.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.TEXTFIXLABEL),P=e[l+1],M=!!P?.originControlId&&!!P?.controlId&&P.originControlId!==P.controlId&&(P.controlComponent===s.ControlComponent.PREFIX||P.controlComponent===s.ControlComponent.PRE_TEXT||P.controlComponent===s.ControlComponent.PRETEXTFIX||P.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===s.ControlComponent.PLACEHOLDER||P.controlComponent===s.ControlComponent.TEXTFIXLABEL),F=!!P?.originControlId&&!!P?.controlId&&P.originControlId!==P.controlId&&(P.controlComponent===s.ControlComponent.PREFIX||P.controlComponent===s.ControlComponent.PRE_TEXT||P.controlComponent===s.ControlComponent.PRETEXTFIX||P.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===s.ControlComponent.POSTFIX||P.controlComponent===s.ControlComponent.POST_TEXT||P.controlComponent===s.ControlComponent.POSTTEXTFIX||P.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||P.controlComponent===s.ControlComponent.PLACEHOLDER||P.controlComponent===s.ControlComponent.TEXTFIXLABEL),N=E=>this.options.mode===s.EditorMode.FORM?i:this.control.removeControl(E),Y=r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId&&!!P?.originControlId&&!!u&&R(P.originControlId)===u,b=E=>!!E&&E.controlId===r.controlId&&(E.originControlId||null)===(r.originControlId||null),S=E=>E?.controlComponent===s.ControlComponent.POSTFIX||E?.controlComponent===s.ControlComponent.POST_TEXT||E?.controlComponent===s.ControlComponent.POSTTEXTFIX||E?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT,y=()=>{const E=r.controlId,W=r.originControlId||null;return c.spliceElementList(e,i,1),e.some(U=>U.controlId===E&&(U.originControlId||null)===W&&U.controlComponent===s.ControlComponent.VALUE)||this.control.addPlaceholder(i-1),Math.max(i-1,0)},V=r.controlComponent===s.ControlComponent.VALUE&&!!r.originControlId&&b(P)&&S(P),X=!!u&&!this.control.getIsExistValueByElementListIndex(e,i),O=()=>{if(r.controlComponent!==s.ControlComponent.VALUE)return null;let E=i;for(let U=i;U>=0;U--){const Z=e[U];if(!(Z.controlId===r.controlId&&(Z.originControlId||null)===(r.originControlId||null))||Z.controlComponent!==s.ControlComponent.VALUE)break;if(!Z.strikeout){E=U;break}}const W=e[E];if(!W||W.strikeout)return null;W.strikeout=!0,W.deletePerson="SWJ",W.deleteTime=lt(new Date).format("YYYY-MM-DD HH:mm:ss");let D=Math.max(E-1,0);for(let U=E-1;U>=0;U--){const Z=e[U];if(!(Z.controlId===W.controlId&&(Z.originControlId||null)===(W.originControlId||null))){D=U;break}if(Z.controlComponent!==s.ControlComponent.VALUE){D=U;break}if(!Z.strikeout){D=U;break}D=Math.max(U-1,0)}return this.draws.render({curIndex:D,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),queueMicrotask(()=>{this.ranges.setRange(D,D),this.draws.setCursor(D)}),D};if(t.key===s.KeyMap.Backspace){if(i===l&&X&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return i;if(d&&i===l&&f&&!T&&(r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)){const W=p(f);return W>=0?W:i}if(i===l&&L&&!(d&&r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId))return N(i);if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!g||C)){if(i===l&&r.controlComponent===s.ControlComponent.VALUE){const W=O();if(W!==null)return W}return r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?i:this.strikeout()}else{if(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER)return i;if(i!==l){c.spliceElementList(e,i+1,l-i);const W=e[i+1];return(W?.controlComponent===s.ControlComponent.POSTFIX||W?.controlComponent===s.ControlComponent.POST_TEXT||W?.controlComponent===s.ControlComponent.POSTTEXTFIX||W?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(i),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i}else{const W=e[i-1],D=e[i+1];return!r.originControlId&&W?.controlId===r.controlId&&W?.originControlId===r.originControlId&&W?.controlComponent===s.ControlComponent.VALUE&&(r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.options.mode!==s.EditorMode.FORM?(c.spliceElementList(e,i-1,1),this.getValue().length||this.control.addPlaceholder(i-2),i-2):S(D)?D.originControlId?V?y():Y?(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):N(i):(c.spliceElementList(e,i,1),this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):(c.spliceElementList(e,i,1),i===1&&e[0].type===s.ElementType.SPLIT_TAG||i===0?c.fixPosition(!0)??i-1:I(Math.max(i-1,0),r.controlId))}}}else if(t.key===s.KeyMap.Delete){if(i===l&&X&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return l;if(i===l&&(M||F)){if(Y){const U=e[l+1];if(U?.controlComponent===s.ControlComponent.VALUE&&U.controlId===r.controlId&&!U.originControlId)return c.spliceElementList(e,l+1,1),this.getValue().length||this.control.addPlaceholder(i),i}return N(l+1)}const E=e[l+1],W=!!r.originControlId;if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!W||r.controlComponent===s.ControlComponent.VALUE))return a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||a.controlComponent===s.ControlComponent.POSTTEXTFIX||a.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?l:E?.controlComponent===s.ControlComponent.POSTFIX||E?.controlComponent===s.ControlComponent.POST_TEXT||E?.controlComponent===s.ControlComponent.POSTTEXTFIX||E?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?E.originControlId?Y?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):N(i+1):(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):this.strikeout();{const U=e[l+1];return r.controlComponent===s.ControlComponent.PLACEHOLDER?l:U?.controlComponent===s.ControlComponent.POSTFIX||U?.controlComponent===s.ControlComponent.POST_TEXT||U?.controlComponent===s.ControlComponent.POSTTEXTFIX||U?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?U.originControlId?Y?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):N(i+1):(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):i!==l?(c.spliceElementList(e,i+1,l-i),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):U?(c.spliceElementList(e,i+1,1),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):(c.getTd()?.linkTdNextId&&r.controlId&&this.removeNextControlElement(r.controlId),l)}}return l}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();n.spliceElementList(i,t+1,e-t);const l=i[t+1];return(l?.controlComponent===s.ControlComponent.POSTFIX||l?.controlComponent===s.ControlComponent.POST_TEXT||l?.controlComponent===s.ControlComponent.POSTTEXTFIX||l?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(t),t}strikeout(t){const e=this.control.getRange(),{endIndex:n}=e,{isIgnoreDisabledRule:i=!1}=t||{};if(!i&&(this.draws.isReadonly()||this.draws.isDisabled()))return null;const r=this.ranges.getSelectionElementList(),a=this.position.getCursorPosition(),c=lt(new Date).format("YYYY-MM-DD HH:mm:ss"),d=R=>{queueMicrotask(()=>{this.ranges.setRange(R,R),this.draws.setCursor(R),this.options.mode===s.EditorMode.FORM&&console.log("[text-sync-trace-cursor]",{index:R,range:this.ranges.getRange(),cursorIndex:this.position.getCursorPosition()?.index})})},u=R=>{const f=this.control.getElementList(),g=f[R],T=g?.controlId,C=g?.originControlId||null;let p=-1;for(let I=R-1;I>=0;I--){const m=f[I];if(m.controlId===T&&(m.originControlId||null)===C&&m.controlComponent===s.ControlComponent.VALUE)return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:R,to:I,reason:"prev-value"}),I;if(C){if(m.controlId&&m.controlId!==T&&m.originControlId!==C)break}else{if(m.controlId===T&&(m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRE_TEXT||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){p=I;break}if(m.controlId&&m.controlId!==T&&!m.originControlId)break;if(m.originControlId===T&&(m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POST_TEXT||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:R,to:I,reason:"nested-postfix"}),I}}if(p>=0){const I=p+1,m=f[I];return m?.controlId===T&&(m.controlComponent===s.ControlComponent.PLACEHOLDER||m.controlComponent===s.ControlComponent.VALUE)?(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:R,to:I,reason:"prefix-next-editable"}),I):(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:R,to:p,reason:"prefix"}),p)}return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:R,to:R,reason:"self"}),R},h=R=>{const f=this.control.getElementList(),g=f[R];if(!g?.controlId||g.controlComponent===s.ControlComponent.VALUE&&(g.metrics?.width??0)>0)return R;for(let T=R+1;T<f.length;T++){const C=f[T];if(C.controlId!==g.controlId||(C.originControlId||null)!==(g.originControlId||null))break;if(C.controlComponent===s.ControlComponent.VALUE&&(C.metrics?.width??0)>0)return T}for(let T=R-1;T>=0;T--){const C=f[T];if(C.controlId!==g.controlId||(C.originControlId||null)!==(g.originControlId||null))break;if(C.controlComponent===s.ControlComponent.VALUE&&(C.metrics?.width??0)>0)return T}return R};if(r?.length){if(!this.element.strikeout){const R=r.findIndex(f=>!f.strikeout);return r.forEach(f=>{f.deletePerson="SWJ",f.deleteTime=c,f.strikeout=!!~R}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),this.control.getRange().endIndex??null}}else{const R=h(a.index),f=this.control.getElementList()[R],g=this.control.getElementList();if(this.options.mode===s.EditorMode.FORM&&console.log("[text-strikeout]",{cursorIndex:a.index,targetIndex:R,targetValue:f?.value,targetComponent:f?.controlComponent,targetControlId:f?.controlId,targetOriginControlId:f?.originControlId||null}),!this.control.getElementList()[R].strikeout&&f?.metrics.width>0){this.control.getElementList()[R].strikeout=!0,this.control.getElementList()[R].deletePerson="SWJ",this.control.getElementList()[R].deleteTime=c;const T=u(R);return this.options.mode===s.EditorMode.FORM&&console.log("[text-strikeout:after]",{targetIndex:R,newIndex:T}),this.ranges.setRange(T,T),this.draws.render({curIndex:T,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),d(T),T??null}else if(n>=0&&n<g.length&&g[n]?.metrics?.width!==void 0&&g[n].metrics.width<=0&&!g[n]?.strikeout){g.splice(n,1);const T=n-1;return this.ranges.setRange(T,T),this.draws.render({curIndex:T,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),d(T),T??null}}return n??null}strikeoute(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draws.isReadonly()||this.draws.isDisabled()))return;if(!this.ranges.getSelectionElementList()?.length){const{endIndex:l}=this.ranges.getRange(),a=this.draws.getElementList()[l];this.ranges.setDefaultStyle({strikeout:a.strikeout?!1:!this.ranges.getDefaultStyle()?.strikeout})}}}class Pl{draw;options;now;dom;renderOptions;isDatePicker;pickDate;lang;constructor(t,e={}){this.draw=t,this.options=e,this.lang=this._getLang(),this.now=new Date,this.dom=this._createDom(),this.renderOptions=null,this.isDatePicker=!0,this.pickDate=null,this._bindEvent()}_createDom(){const t=document.createElement("div");t.classList.add(`${rt}-date-container`),t.setAttribute(Ze,s.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${rt}-date-wrap`);const n=document.createElement("div");n.classList.add(`${rt}-date-title`);const i=document.createElement("span");i.classList.add(`${rt}-date-title__pre-year`),i.innerText="<<";const l=document.createElement("span");l.classList.add(`${rt}-date-title__pre-month`),l.innerText="<";const r=document.createElement("span");r.classList.add(`${rt}-date-title__now`);const a=document.createElement("span");a.classList.add(`${rt}-date-title__next-month`),a.innerText=">";const c=document.createElement("span");c.classList.add(`${rt}-date-title__next-year`),c.innerText=">>",n.append(i),n.append(l),n.append(r),n.append(a),n.append(c);const d=document.createElement("div");d.classList.add(`${rt}-date-week`);const{weeks:{sun:u,mon:h,tue:R,wed:f,thu:g,fri:T,sat:C}}=this.lang;[u,h,R,f,g,T,C].forEach(y=>{const V=document.createElement("span");V.innerText=`${y}`,d.append(V)});const I=document.createElement("div");I.classList.add(`${rt}-date-day`),e.append(n),e.append(d),e.append(I);const m=document.createElement("ul");m.classList.add(`${rt}-time-wrap`);let L,P,M;[this.lang.hour,this.lang.minute,this.lang.second].forEach((y,V)=>{const X=document.createElement("li"),O=document.createElement("span");O.innerText=y,X.append(O);const E=document.createElement("ol"),W=V===0,D=V===1,U=W?24:60;for(let Z=0;Z<U;Z++){const Q=document.createElement("li");Q.innerText=`${String(Z).padStart(2,"0")}`,Q.setAttribute("data-id",`${Z}`),E.append(Q)}W?L=E:D?P=E:M=E,X.append(E),m.append(X)});const N=document.createElement("div");N.classList.add(`${rt}-date-menu`);const Y=document.createElement("button");Y.classList.add(`${rt}-date-menu__time`),Y.innerText=this.lang.timeSelect;const b=document.createElement("button");b.classList.add(`${rt}-date-menu__now`),b.innerText=this.lang.now;const S=document.createElement("button");return S.classList.add(`${rt}-date-menu__submit`),S.innerText=this.lang.confirm,N.append(Y),N.append(b),N.append(S),t.append(e),t.append(m),t.append(N),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:d,timeWrap:m,title:{preYear:i,preMonth:l,now:r,nextMonth:a,nextYear:c},day:I,time:{hour:L,minute:P,second:M},menu:{time:Y,now:b,submit:S}}}_bindEvent(){this.dom.title.preYear.onclick=()=>{this._preYear()},this.dom.title.preMonth.onclick=()=>{this._preMonth()},this.dom.title.nextMonth.onclick=()=>{this._nextMonth()},this.dom.title.nextYear.onclick=()=>{this._nextYear()},this.dom.menu.time.onclick=()=>{this.isDatePicker=!this.isDatePicker,this._toggleDateTimePicker()},this.dom.menu.now.onclick=()=>{this._now(),this._submit()},this.dom.menu.submit.onclick=()=>{this.dispose(),this._submit()},this.dom.time.hour.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setHours(Number(n)),this._setTimePick(!1))},this.dom.time.minute.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setMinutes(Number(n)),this._setTimePick(!1))},this.dom.time.second.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setSeconds(Number(n)),this._setTimePick(!1))}}_setPosition(){if(!this.renderOptions)return;const{position:{coordinate:{leftTop:[t,e]},lineHeight:n,pageNo:i}}=this.renderOptions,l=this.draw.getHeight(),r=this.draw.getPageGap(),c=(i??this.draw.getPageNo())*(l+r);this.dom.container.style.left=`${t}px`,this.dom.container.style.top=`${e+c+n}px`}isInvalidDate(t){return t.toDateString()==="Invalid Date"}_setValue(){const t=this.renderOptions?.value;if(t){const e=new Date(t);this.now=this.isInvalidDate(e)?new Date:e}else this.now=new Date;this.pickDate=new Date(this.now)}_getLang(){const t=this.draw.getI18n(),e=t.t.bind(t);return{now:e("datePicker.now"),confirm:e("datePicker.confirm"),return:e("datePicker.return"),timeSelect:e("datePicker.timeSelect"),weeks:{sun:e("datePicker.weeks.sun"),mon:e("datePicker.weeks.mon"),tue:e("datePicker.weeks.tue"),wed:e("datePicker.weeks.wed"),thu:e("datePicker.weeks.thu"),fri:e("datePicker.weeks.fri"),sat:e("datePicker.weeks.sat")},year:e("datePicker.year"),month:e("datePicker.month"),hour:e("datePicker.hour"),minute:e("datePicker.minute"),second:e("datePicker.second")}}_setLangChange(){this.dom.menu.time.innerText=this.lang.timeSelect,this.dom.menu.now.innerText=this.lang.now,this.dom.menu.submit.innerText=this.lang.confirm;const{weeks:{sun:t,mon:e,tue:n,wed:i,thu:l,fri:r,sat:a}}=this.lang,c=[t,e,n,i,l,r,a];this.dom.datePickerWeek.childNodes.forEach((R,f)=>{const g=R;g.innerText=c[f]});const d=this.dom.time.hour.previousElementSibling;d.innerText=this.lang.hour;const u=this.dom.time.minute.previousElementSibling;u.innerText=this.lang.minute;const h=this.dom.time.second.previousElementSibling;h.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),n=t.getMonth()+1,i=t.getDate();let l=null,r=null,a=null;this.pickDate&&(l=this.pickDate.getFullYear(),r=this.pickDate.getMonth()+1,a=this.pickDate.getDate());const c=this.now.getFullYear(),d=this.now.getMonth()+1;this.dom.title.now.innerText=`${c}${this.lang.year} ${String(d).padStart(2,"0")}${this.lang.month}`;const h=new Date(c,d,0).getDate();let R=new Date(c,d-1,1).getDay();R===0&&(R=7);const f=new Date(c,d-1,0).getDate();this.dom.day.innerHTML="";const g=f-R+1;for(let C=g;C<=f;C++){const p=document.createElement("div");p.classList.add("disable"),p.innerText=`${C}`,p.onclick=()=>{const I=d-2;this.now=new Date(c,I,C),this._setDatePick(c,I,C)},this.dom.day.append(p)}for(let C=1;C<=h;C++){const p=document.createElement("div");e===c&&n===d&&i===C&&p.classList.add("active"),this.pickDate&&l===c&&r===d&&a===C&&p.classList.add("select"),p.innerText=`${C}`,p.onclick=I=>{const m=d-1;this.now=new Date(c,m,C),this._setDatePick(c,m,C),I.stopPropagation()},this.dom.day.append(p)}const T=42-R-h;for(let C=1;C<=T;C++){const p=document.createElement("div");p.classList.add("disable"),p.innerText=`${C}`,p.onclick=()=>{this.now=new Date(c,d,C),this._setDatePick(c,d,C)},this.dom.day.append(p)}}_toggleDateTimePicker(){this.isDatePicker?(this.dom.dateWrap.classList.add("active"),this.dom.timeWrap.classList.remove("active"),this.dom.menu.time.innerText=this.lang.timeSelect):(this.dom.dateWrap.classList.remove("active"),this.dom.timeWrap.classList.add("active"),this.dom.menu.time.innerText=this.lang.return,this._setTimePick())}_setDatePick(t,e,n){this.now=new Date(t,e,n),this.pickDate?.setFullYear(t),this.pickDate?.setMonth(e),this.pickDate?.setDate(n),this._update()}_setTimePick(t=!0){const e=this.pickDate?.getHours()||0,n=this.pickDate?.getMinutes()||0,i=this.pickDate?.getSeconds()||0,{hour:l,minute:r,second:a}=this.dom.time;[l,r,a].forEach(u=>{u.querySelectorAll("li").forEach(h=>h.classList.remove("active"))}),[[l,e],[r,n],[a,i]].forEach(([u,h])=>{const R=u.querySelector(`[data-id='${h}']`);R.classList.add("active"),t&&vs(u,R)})}_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(){if(this.options.onSubmit&&this.pickDate){const t=this.renderOptions?.dateFormat,e=this.formatDate(this.pickDate,t);this.options.onSubmit(e)}}formatDate(t,e="YYYY-MM-DD HH:mm:ss"){let n=e;const i=t.getFullYear().toString(),l=(t.getMonth()+1).toString(),r=t.getDate().toString(),a=t.getHours(),c=a%12===0?12:a%12,d=t.getMinutes().toString(),u=t.getSeconds().toString(),h=t.getMilliseconds().toString(),R={"y+":i,"Y+":i,"M+":l,"d+":r,"D+":r,"h+":c.toString(),"H+":a.toString(),"m+":d,"s+":u,"S+":h};for(const f in R){const g=new RegExp("("+f+")").exec(e),T=f;g&&(n=n.replace(g[1],g[1].length===1?R[T]:R[T].padStart(g[1].length,"0")))}return n}render(t){this.renderOptions=t,this.lang=this._getLang(),this._setLangChange(),this._setValue(),this._update(),this._setPosition(),this.isDatePicker=!0,this._toggleDateTimePicker(),this._toggleVisible(!0)}dispose(){this._toggleVisible(!1)}destroy(){this.dom.container.remove()}}class Co{draw;element;control;isPopup;datePicker;options;constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:l,endIndex:r}=n;for(let a=l;a<=r;a++){const c=e[a];c.controlComponent===s.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:r,endIndex:a}=l,c=this.control.getDraw();r!==a?c.spliceElementList(i,r+1,a-r):this.control.removePlaceholder(r,{elementList:i});const d=i[r],u=d.type&&!Le.includes(d.type)||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT?xt(d,["control","controlId",...Re]):Ee(d,["type"]),h=l.startIndex+1;for(let R=0;R<t.length;R++){const f={...u,...t[R],controlComponent:s.ControlComponent.VALUE};se(i,[f],r,{editorOptions:this.options}),c.spliceElementList(i,h+R,0,[f])}return h+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const l=this.control.getValueRange(t);if(!l)return-1;const{startIndex:r,endIndex:a}=l;if(!~r||!~a)return-1;const c=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(c,r+1,a-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(r,t),r}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),r=this.getValue(e)[0],a=r?xt(r,Ne):xt(i[l.startIndex],Re),c=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~c)return;const d=Ee(i[c],Ne),u=c+1,h=this.control.getDraw();for(let R=0;R<t.length;R++){const f={...a,...d,type:s.ElementType.TEXT,value:t[R],controlComponent:s.ControlComponent.VALUE};(f.color===this.options.control.bracketColor||f.color===this.options.control.placeholderColor)&&(f.color=this.options.defaultColor),se(i,[f],c,{editorOptions:this.options}),h.spliceElementList(i,u+R,0,[f])}if(!e.range){const R=u+t.length-1;this.control.repaintControl({curIndex:R}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.control.getDraw();if(t.key===s.KeyMap.Backspace)return i!==l?(c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key===s.KeyMap.Delete){if(i!==l)return c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i;{const d=e[l+1];return(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT)&&d.controlComponent===s.ControlComponent.PLACEHOLDER||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}}return l}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getPosition();if(!t)return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(e[n+1]?.controlId!==this.element.controlId)return;this.datePicker=new Pl(this.draw,{onSubmit:this._setDate.bind(this)});const i=this.getValue().map(r=>r.value).join("")||"",l=this.element.control?.dateFormat;this.datePicker.render({value:i,position:t,dateFormat:l}),this.isPopup=!0}destroy(){this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}_setDate(t){t?this.setSelect(t):this.clearSelect(),this.destroy()}}class ii extends Ms{isPopup;inputPopup;constructor(t,e){super(t,e),this.isPopup=!1,this.inputPopup=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(I=>!Pc(I)))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange();this.control.shrinkBoundary(e);const r=at(t),{startIndex:a,endIndex:c}=l,d=i[a];let u=null;for(let I=a;I>=0;I--)if(i[I].controlComponent===s.ControlComponent.PREFIX){u=i[I];break}const h=u?.control||this.element.control;if(this.control.getIsExistValueByElementListIndex(i,a)){let I=a;for(;I>0;){const L=i[I];if(L.controlId!==d.controlId||L.controlComponent===s.ControlComponent.PREFIX||L.controlComponent===s.ControlComponent.PRE_TEXT)break;r.unshift(L),I--}let m=c+1;for(;m<i.length;){const L=i[m];if(L.controlId!==d.controlId||L.controlComponent===s.ControlComponent.POSTFIX||L.controlComponent===s.ControlComponent.POST_TEXT)break;r.push(L),m++}}const R=or(r);if(!/^[+-]?(?:\d+)?(?:\.\d*)?(?:[eE][+-]?\d*)?$/.test(R))return-1;const g=h?.numberExclusiveOptions,T=g?.maxLength??null,C=g?.decimalPlaces??null,p=R.replace(/[+\-.eE]/g,"").length;if(T!=null&&p>T||C!=null&&(R.split(/[eE]/)[0].split(".")[1]||"").length>C)return-1;if(e.range||e.elementList){const I=Number(R),m=g?.minValue,L=g?.maxValue;if(!Number.isFinite(I)||m!=null&&I<m||L!=null&&I>L)return-1}return super.setValue(t,e,n)}_setNumberValue(t){const e=this.control.getElementList(),n=this.control.getRange(),{startIndex:i}=n;let l=null;for(let F=i;F>=0;F--)if(e[F].controlComponent===s.ControlComponent.PREFIX){l=e[F];break}const a=(l?.control||this.element.control)?.numberExclusiveOptions,c=a?.minValue,d=a?.maxValue,u=a?.minLength,h=a?.maxLength,R=t.trim(),f=R.replace(/[+\-.eE]/g,"").length,g=Number(R);if(u!=null&&f<u||h!=null&&f>h||c!=null&&g<c||d!=null&&g>d)return!1;let T=i;for(let F=i;F>=0;F--)if(e[F].controlComponent===s.ControlComponent.PREFIX){T=F;break}let C=T+1;for(let F=T+1;F<e.length;F++)if(e[F].controlComponent===s.ControlComponent.POSTFIX){C=F;break}const p=this.options.mode===s.EditorMode.FORM,I=p&&this.options.modeRule.form.inputTraceEnabled,m=p&&this.options.modeRule.form.deleteTraceEnabled,L=lt(new Date).format("YYYY-MM-DD HH:mm:ss");if(m)for(let F=T+1;F<C;F++){const N=e[F];N.controlComponent===s.ControlComponent.VALUE&&!N.strikeout&&N.value&&(N.strikeout=!0,N.deletePerson="SYSTEM",N.deleteTime=L),N.controlComponent===s.ControlComponent.PLACEHOLDER&&(this.control.getDraw().spliceElementList(e,F,1),C--,F--)}else{const F=T+1,N=C-F;N>0&&this.control.getDraw().spliceElementList(e,F,N),C=T+1}C=T+1;for(let F=T+1;F<e.length;F++)if(e[F].controlComponent===s.ControlComponent.POSTFIX){C=F;break}const P=[];for(let F=0;F<R.length;F++){const N={type:s.ElementType.TEXT,value:R[F],controlComponent:s.ControlComponent.VALUE,controlId:e[T].controlId,originControlId:e[T].originControlId,control:e[T].control};I&&(N.textDecoration={style:s.TextDecorationStyle.DOUBLE},N.underline=!0),P.push(N)}for(let F=0;F<P.length;F++)this.control.getDraw().spliceElementList(e,C+F,0,[P[F]]);const M=C+P.length-1;return this.control.getDraw().getRange().setRange(M,M),this.control.emitControlContentChange(),this.control.repaintControl({curIndex:M}),!0}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e,i=t[n];if(!i||i.controlId!==this.element.controlId)return;let l=null;for(let g=n;g>=0;g--)if(t[g].controlComponent===s.ControlComponent.PREFIX){l=t[g];break}const r=l?.control||this.element.control,c=this.getValue().filter(g=>!g.strikeout),d=c.length>0?or(c):"",u=r?.numberExclusiveOptions,h=u?.minValue,R=u?.maxValue,f=u?.decimalPlaces;this.inputPopup=new jg({control:this.control,currentValue:d,minValue:h,maxValue:R,decimalPlaces:f,onConfirm:g=>{if(!g||g.trim()==="")return this._clearNumberValue(),!0;const T=Number(g);return Number.isNaN(T)||!Number.isFinite(T)?!1:this._setNumberValue(g)},onTab:g=>{this.destroy(),setTimeout(()=>{this.control.initNextControl({direction:g})})},onClose:()=>{this.destroy()}}),this.inputPopup.create(),this.isPopup=!0}_clearNumberValue(){const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e;let i=n;for(let c=n;c>=0;c--)if(t[c].controlComponent===s.ControlComponent.PREFIX){i=c;break}let l=i+1;for(let c=i+1;c<t.length;c++)if(t[c].controlComponent===s.ControlComponent.POSTFIX){l=c;break}const r=i+1,a=l-r;a>0&&this.control.getDraw().spliceElementList(t,r,a),this.control.addPlaceholder(i),this.control.getDraw().getRange().setRange(i,i),this.control.emitControlContentChange(),this.control.repaintControl({curIndex:i})}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.control.getDraw(),d=c.getMode()===s.EditorMode.FORM;if(t.key==="Backspace")return r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?d?i:this.control.removeControl(i):a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT?i:i!==l?(c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key==="Delete"){const u=e[l+1];return r.controlComponent===s.ControlComponent.PLACEHOLDER||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT?d?l:this.control.removeControl(i):r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||u?.controlComponent===s.ControlComponent.POSTFIX||u?.controlComponent===s.ControlComponent.POST_TEXT?l:i!==l?(c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}return l}destroy(){this.inputPopup&&(this.inputPopup.destroy(),this.inputPopup=null),this.isPopup=!1}}class jg{options;popupDom;constructor(t){this.options=t,this.popupDom=null}create(){const{currentValue:t,minValue:e,maxValue:n,decimalPlaces:i,onConfirm:l,onTab:r,onClose:a}=this.options,c=document.createElement("div");c.classList.add(`${rt}-number-input-modal`),c.setAttribute(Ze,s.EditorComponent.POPUP);const d=m=>{if(m.type==="mouseup"){const L=this.options.control.getDraw().getCanvasEvent();L.setIsAllowDrag(!1),L.setIsAllowSelection(!1)}m.stopPropagation()};c.addEventListener("mousedown",d),c.addEventListener("mouseup",d),c.addEventListener("click",d),c.addEventListener("keydown",d),c.addEventListener("input",d);const u=document.createElement("div");u.classList.add(`${rt}-number-input-modal__content`);const h=document.createElement("div");if(h.classList.add(`${rt}-number-input-modal__title`),h.textContent="请输入数值",u.appendChild(h),e!==void 0||n!==void 0){const m=document.createElement("div");m.classList.add(`${rt}-number-input-modal__hint`);let L="有效范围:";e!==void 0&&n!==void 0?L+=`${e} ~ ${n}`:e!==void 0?L+=`≥ ${e}`:L+=`≤ ${n}`,i!=null&&(L+=`,保留${i}位小数`),m.textContent=L,u.appendChild(m)}const R=document.createElement("input");R.classList.add(`${rt}-number-input-modal__input`),R.type="number",R.value=t,R.placeholder="请输入数值",e!==void 0&&(R.min=String(e)),n!==void 0&&(R.max=String(n)),i!=null&&(R.step=(1/Math.pow(10,i)).toString()),setTimeout(()=>{R.focus(),R.select()},100),u.appendChild(R);const f=document.createElement("div");f.classList.add(`${rt}-number-input-modal__error`),f.style.display="none",u.appendChild(f);const g=document.createElement("div");g.classList.add(`${rt}-number-input-modal__buttons`);const T=document.createElement("button");T.classList.add(`${rt}-number-input-modal__cancel`),T.textContent="取消",T.onclick=()=>{a()},g.appendChild(T);const C=document.createElement("button");C.classList.add(`${rt}-number-input-modal__confirm`),C.textContent="确定";const p=()=>{const m=R.value.trim();if(!m)return l("");const L=parseFloat(m);return Number.isNaN(L)||!Number.isFinite(L)?(f.textContent="请输入有效的数值",f.style.display="block",!1):i!=null&&(m.split(".")[1]||"").length>i?(f.textContent=`小数位数不能超过${i}位`,f.style.display="block",!1):e!==void 0&&L<e?(f.textContent=`数值不能小于 ${e}`,f.style.display="block",!1):n!==void 0&&L>n?(f.textContent=`数值不能大于 ${n}`,f.style.display="block",!1):(f.style.display="none",l(m))};C.onclick=()=>{p()&&a()},g.appendChild(C),u.appendChild(g),c.appendChild(u),R.onkeydown=m=>{m.key==="Enter"?C.click():m.key==="Tab"?(m.preventDefault(),p()&&(a(),r(m.shiftKey?Jt.UP:Jt.DOWN))):m.key==="Escape"&&a()},this.options.control.getContainer().appendChild(c),this.popupDom=c}destroy(){this.popupDom&&(this.popupDom.remove(),this.popupDom=null)}}class qg{options;mask;container;inputList;optionItemContainers;data;constructor(t){this.options=t,this.mask=null,this.container=null,this.inputList=[],this.optionItemContainers=[],this.data=t.data,this._render()}_getFieldValue(t){const e=this.inputList.filter(n=>n.name===t);if(e.length!==0){for(const n of e)if(n instanceof HTMLInputElement&&n.type==="radio"&&n.checked)return n.value;return e[0].value}}_updateFieldVisibility(){this.data.forEach((t,e)=>{if(t.visibleWhen){const{field:n,value:i}=t.visibleWhen,l=this._getFieldValue(n),r=this.optionItemContainers[e];if(r){const a=l===i;r.style.display=a?"":"none"}}})}_render(){const{title:t,onClose:e,onCancel:n,onConfirm:i}=this.options,l=document.createElement("div");l.classList.add("dialog-mask"),l.setAttribute(Ze,s.EditorComponent.COMPONENT),document.body.append(l);const r=document.createElement("div");r.classList.add("dialog-container"),r.setAttribute(Ze,s.EditorComponent.COMPONENT);const a=document.createElement("div");a.classList.add("dialog"),r.append(a);const c=document.createElement("div");c.classList.add("dialog-title");const d=document.createElement("span");d.append(document.createTextNode(t));const u=document.createElement("i");u.onclick=()=>{e&&e(),this._dispose()},c.append(d),c.append(u),a.append(c);const h=document.createElement("div");h.classList.add("dialog-option");for(let T=0;T<this.data.length;T++){const C=this.data[T],p=document.createElement("div");if(p.classList.add("dialog-option__item"),C.visible===!1&&(p.style.display="none"),C.label){const I=document.createElement("span");I.append(document.createTextNode(C.label)),p.append(I),C.required&&I.classList.add("dialog-option__item--require")}if(C.type==="radio"){const I=document.createElement("div");I.classList.add("dialog-radio-group"),C.horizontal&&I.classList.add("dialog-radio-group--horizontal"),C.options?.forEach(m=>{const L=document.createElement("label");L.classList.add("dialog-radio-item");const P=document.createElement("input");P.type="radio",P.name=C.name,P.value=m.value,m.value===(C.value||"")&&(P.checked=!0);const M=document.createElement("span");M.textContent=m.label,L.append(P),L.append(M),I.append(L),P.addEventListener("change",()=>{this._updateFieldVisibility()}),this.inputList.push(P)}),p.append(I)}else if(C.type==="select"){const I=document.createElement("select"),m=C.value||"";C.options?.forEach(L=>{const P=document.createElement("option");P.value=L.value,P.label=L.label,L.value===m&&(P.selected=!0),I.append(P)}),I.name=C.name,I.value=m,I.addEventListener("change",()=>{this._updateFieldVisibility()}),C.width&&(I.style.width=`${C.width}px`),p.append(I),this.inputList.push(I)}else if(C.type==="textarea"){const I=document.createElement("textarea");I.name=C.name,I.value=C.value||"",I.placeholder=C.placeholder||"",C.width&&(I.style.width=`${C.width}px`),C.height&&(I.style.height=`${C.height}px`),p.append(I),this.inputList.push(I)}else{const I=document.createElement("input");I.type=C.type,I.name=C.name,I.value=C.value||"",I.placeholder=C.placeholder||"",C.width&&(I.style.width=`${C.width}px`),C.height&&(I.style.height=`${C.height}px`),p.append(I),this.inputList.push(I)}h.append(p),this.optionItemContainers.push(p)}a.append(h);const R=document.createElement("div");R.classList.add("dialog-menu");const f=document.createElement("button");f.classList.add("dialog-menu__cancel"),f.append(document.createTextNode("取消")),f.type="button",f.onclick=()=>{n&&n(),this._dispose()},R.append(f);const g=document.createElement("button");g.append(document.createTextNode("确定")),g.type="submit",g.onclick=()=>{if(i){const T=new Set,C=[];for(const p of this.inputList)if(!T.has(p.name))if(p instanceof HTMLInputElement&&p.type==="radio"){const I=this.inputList.find(m=>m.name===p.name&&m instanceof HTMLInputElement&&m.checked);I&&(C.push({name:p.name,value:I.value}),T.add(p.name))}else C.push({name:p.name,value:p.value}),T.add(p.name);i(C)}this._dispose()},R.append(g),a.append(R),document.body.append(r),this.container=r,this.mask=l,this._updateFieldVisibility()}_dispose(){this.mask?.remove(),this.container?.remove()}}function tf(o,t){const e=o.trim();if(!e)return;const n=t?.key===e;return{...n?t:{},key:e,label:n&&t?.label?t.label:e,writeTarget:t?.writeTarget||"self",writeMode:t?.writeMode||"replaceOnConfirm"}}class Nn{draw;element;control;isPopup;datePicker;options;range;static isDeleting=!1;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.range=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:l,endIndex:r}=n;for(let a=l;a<=r;a++){const c=e[a];c.controlComponent===s.ControlComponent.VALUE&&!Te(c)&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&(this.control.getIsDisabledControl(e)||this.element.control?.editable===!1))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),{startIndex:r,endIndex:a}=l,c=i[r],d=this.element.controlId||c.controlId,u=this.element.originControlId||c.originControlId||null;if(!d)return-1;const h=this.getButtonControlBounds(i,d,u);if(!h)return-1;const R=this.getButtonBusinessOffset(i,h,r),f=this.getButtonBusinessOffset(i,h,a),g=this.getButtonBusinessElements(i,h),T=this.splitButtonBusinessElements(t),C=[...g.slice(0,R),...T,...g.slice(f)];return this.replaceButtonBusinessElements(i,h,C,R+T.length)}isSameButtonElement(t,e,n){return!!(t&&t.controlId===e&&(t.originControlId||null)===n)}getButtonControlBounds(t,e,n){let i=-1,l=-1;for(let r=0;r<t.length;r++){const a=t[r];this.isSameButtonElement(a,e,n)&&(i===-1&&a.controlComponent===s.ControlComponent.PREFIX&&(i=r),a.controlComponent===s.ControlComponent.POSTFIX&&(l=r))}return i===-1||l===-1?null:{controlId:e,originControlId:n,prefixIndex:i,postfixIndex:l}}getButtonBusinessOffset(t,e,n){let i=0;const l=Math.min(n,e.postfixIndex-1);for(let r=e.prefixIndex+1;r<=l;r++){const a=t[r];this.isSameButtonElement(a,e.controlId,e.originControlId)&&a.controlComponent===s.ControlComponent.VALUE&&!Te(a)&&i++}return i}toButtonBusinessElement(t){const e={value:t.value===`
122
+ `+new Error().stack),e=!1}return t.apply(this,arguments)},t)}var Nr={};function yr(o,t){lt.deprecationHandler!=null&&lt.deprecationHandler(o,t),Nr[o]||(Xr(t),Nr[o]=!0)}lt.suppressDeprecationWarnings=!1,lt.deprecationHandler=null;function ke(o){return typeof Function<"u"&&o instanceof Function||Object.prototype.toString.call(o)==="[object Function]"}function tu(o){var t,e;for(e in o)Kt(o,e)&&(t=o[e],ke(t)?this[e]=t:this["_"+e]=t);this._config=o,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function $i(o,t){var e=fn({},o),n;for(n in t)Kt(t,n)&&(Sn(o[n])&&Sn(t[n])?(e[n]={},fn(e[n],o[n]),fn(e[n],t[n])):t[n]!=null?e[n]=t[n]:delete e[n]);for(n in o)Kt(o,n)&&!Kt(t,n)&&Sn(o[n])&&(e[n]=fn({},e[n]));return e}function zi(o){o!=null&&this.set(o)}var ji;Object.keys?ji=Object.keys:ji=function(o){var t,e=[];for(t in o)Kt(o,t)&&e.push(t);return e};var eu={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function nu(o,t,e){var n=this._calendar[o]||this._calendar.sameElse;return ke(n)?n.call(t,e):n}function Ge(o,t,e){var n=""+Math.abs(o),i=t-n.length,l=o>=0;return(l?e?"+":"":"-")+Math.pow(10,Math.max(0,i)).toString().substr(1)+n}var qi=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,Zo=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ts={},Bn={};function ht(o,t,e,n){var i=n;typeof n=="string"&&(i=function(){return this[n]()}),o&&(Bn[o]=i),t&&(Bn[t[0]]=function(){return Ge(i.apply(this,arguments),t[1],t[2])}),e&&(Bn[e]=function(){return this.localeData().ordinal(i.apply(this,arguments),o)})}function ou(o){return o.match(/\[[\s\S]/)?o.replace(/^\[|\]$/g,""):o.replace(/\\/g,"")}function iu(o){var t=o.match(qi),e,n;for(e=0,n=t.length;e<n;e++)Bn[t[e]]?t[e]=Bn[t[e]]:t[e]=ou(t[e]);return function(i){var l="",r;for(r=0;r<n;r++)l+=ke(t[r])?t[r].call(i,o):t[r];return l}}function vo(o,t){return o.isValid()?(t=br(t,o.localeData()),ts[t]=ts[t]||iu(t),ts[t](o)):o.localeData().invalidDate()}function br(o,t){var e=5;function n(i){return t.longDateFormat(i)||i}for(Zo.lastIndex=0;e>=0&&Zo.test(o);)o=o.replace(Zo,n),Zo.lastIndex=0,e-=1;return o}var su={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function ru(o){var t=this._longDateFormat[o],e=this._longDateFormat[o.toUpperCase()];return t||!e?t:(this._longDateFormat[o]=e.match(qi).map(function(n){return n==="MMMM"||n==="MM"||n==="DD"||n==="dddd"?n.slice(1):n}).join(""),this._longDateFormat[o])}var lu="Invalid date";function au(){return this._invalidDate}var cu="%d",du=/\d{1,2}/;function uu(o){return this._ordinal.replace("%d",o)}var Ru={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function hu(o,t,e,n){var i=this._relativeTime[e];return ke(i)?i(o,t,e,n):i.replace(/%d/i,o)}function gu(o,t){var e=this._relativeTime[o>0?"future":"past"];return ke(e)?e(t):e.replace(/%s/i,t)}var Vr={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function Fe(o){return typeof o=="string"?Vr[o]||Vr[o.toLowerCase()]:void 0}function es(o){var t={},e,n;for(n in o)Kt(o,n)&&(e=Fe(n),e&&(t[e]=o[n]));return t}var fu={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function Tu(o){var t=[],e;for(e in o)Kt(o,e)&&t.push({unit:e,priority:fu[e]});return t.sort(function(n,i){return n.priority-i.priority}),t}var Wr=/\d/,Pe=/\d\d/,Yr=/\d{3}/,ns=/\d{4}/,Qo=/[+-]?\d{6}/,te=/\d\d?/,Ur=/\d\d\d\d?/,wr=/\d\d\d\d\d\d?/,Ko=/\d{1,3}/,os=/\d{1,4}/,Ho=/[+-]?\d{1,6}/,kn=/\d+/,Ao=/[+-]?\d+/,mu=/Z|[+-]\d\d:?\d\d/gi,_o=/Z|[+-]\d\d(?::?\d\d)?/gi,Cu=/[+-]?\d+(\.\d{1,3})?/,ao=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,Gn=/^[1-9]\d?/,is=/^([1-9]\d|\d)/,Bo;Bo={};function ct(o,t,e){Bo[o]=ke(t)?t:function(n,i){return n&&e?e:t}}function pu(o,t){return Kt(Bo,o)?Bo[o](t._strict,t._locale):new RegExp(Iu(o))}function Iu(o){return tn(o.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,i,l){return e||n||i||l}))}function tn(o){return o.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Xe(o){return o<0?Math.ceil(o)||0:Math.floor(o)}function Wt(o){var t=+o,e=0;return t!==0&&isFinite(t)&&(e=Xe(t)),e}var ss={};function kt(o,t){var e,n=t,i;for(typeof o=="string"&&(o=[o]),qe(t)&&(n=function(l,r){r[t]=Wt(l)}),i=o.length,e=0;e<i;e++)ss[o[e]]=n}function co(o,t){kt(o,function(e,n,i,l){i._w=i._w||{},t(e,i._w,i,l)})}function Eu(o,t,e){t!=null&&Kt(ss,o)&&ss[o](t,e._a,e,o)}function ko(o){return o%4===0&&o%100!==0||o%400===0}var ge=0,en=1,xe=2,he=3,Ye=4,nn=5,Dn=6,Lu=7,Pu=8;ht("Y",0,0,function(){var o=this.year();return o<=9999?Ge(o,4):"+"+o}),ht(0,["YY",2],0,function(){return this.year()%100}),ht(0,["YYYY",4],0,"year"),ht(0,["YYYYY",5],0,"year"),ht(0,["YYYYYY",6,!0],0,"year"),ct("Y",Ao),ct("YY",te,Pe),ct("YYYY",os,ns),ct("YYYYY",Ho,Qo),ct("YYYYYY",Ho,Qo),kt(["YYYYY","YYYYYY"],ge),kt("YYYY",function(o,t){t[ge]=o.length===2?lt.parseTwoDigitYear(o):Wt(o)}),kt("YY",function(o,t){t[ge]=lt.parseTwoDigitYear(o)}),kt("Y",function(o,t){t[ge]=parseInt(o,10)});function uo(o){return ko(o)?366:365}lt.parseTwoDigitYear=function(o){return Wt(o)+(Wt(o)>68?1900:2e3)};var Zr=xn("FullYear",!0);function Mu(){return ko(this.year())}function xn(o,t){return function(e){return e!=null?(vr(this,o,e),lt.updateOffset(this,t),this):Ro(this,o)}}function Ro(o,t){if(!o.isValid())return NaN;var e=o._d,n=o._isUTC;switch(t){case"Milliseconds":return n?e.getUTCMilliseconds():e.getMilliseconds();case"Seconds":return n?e.getUTCSeconds():e.getSeconds();case"Minutes":return n?e.getUTCMinutes():e.getMinutes();case"Hours":return n?e.getUTCHours():e.getHours();case"Date":return n?e.getUTCDate():e.getDate();case"Day":return n?e.getUTCDay():e.getDay();case"Month":return n?e.getUTCMonth():e.getMonth();case"FullYear":return n?e.getUTCFullYear():e.getFullYear();default:return NaN}}function vr(o,t,e){var n,i,l,r,a;if(!(!o.isValid()||isNaN(e))){switch(n=o._d,i=o._isUTC,t){case"Milliseconds":return void(i?n.setUTCMilliseconds(e):n.setMilliseconds(e));case"Seconds":return void(i?n.setUTCSeconds(e):n.setSeconds(e));case"Minutes":return void(i?n.setUTCMinutes(e):n.setMinutes(e));case"Hours":return void(i?n.setUTCHours(e):n.setHours(e));case"Date":return void(i?n.setUTCDate(e):n.setDate(e));case"FullYear":break;default:return}l=e,r=o.month(),a=o.date(),a=a===29&&r===1&&!ko(l)?28:a,i?n.setUTCFullYear(l,r,a):n.setFullYear(l,r,a)}}function Ou(o){return o=Fe(o),ke(this[o])?this[o]():this}function Su(o,t){if(typeof o=="object"){o=es(o);var e=Tu(o),n,i=e.length;for(n=0;n<i;n++)this[e[n].unit](o[e[n].unit])}else if(o=Fe(o),ke(this[o]))return this[o](t);return this}function Du(o,t){return(o%t+t)%t}var ae;Array.prototype.indexOf?ae=Array.prototype.indexOf:ae=function(o){var t;for(t=0;t<this.length;++t)if(this[t]===o)return t;return-1};function rs(o,t){if(isNaN(o)||isNaN(t))return NaN;var e=Du(t,12);return o+=(t-e)/12,e===1?ko(o)?29:28:31-e%7%2}ht("M",["MM",2],"Mo",function(){return this.month()+1}),ht("MMM",0,0,function(o){return this.localeData().monthsShort(this,o)}),ht("MMMM",0,0,function(o){return this.localeData().months(this,o)}),ct("M",te,Gn),ct("MM",te,Pe),ct("MMM",function(o,t){return t.monthsShortRegex(o)}),ct("MMMM",function(o,t){return t.monthsRegex(o)}),kt(["M","MM"],function(o,t){t[en]=Wt(o)-1}),kt(["MMM","MMMM"],function(o,t,e,n){var i=e._locale.monthsParse(o,n,e._strict);i!=null?t[en]=i:Ot(e).invalidMonth=o});var Fu="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Qr="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Kr=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Xu=ao,Nu=ao;function yu(o,t){return o?Ve(this._months)?this._months[o.month()]:this._months[(this._months.isFormat||Kr).test(t)?"format":"standalone"][o.month()]:Ve(this._months)?this._months:this._months.standalone}function bu(o,t){return o?Ve(this._monthsShort)?this._monthsShort[o.month()]:this._monthsShort[Kr.test(t)?"format":"standalone"][o.month()]:Ve(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Vu(o,t,e){var n,i,l,r=o.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],n=0;n<12;++n)l=Be([2e3,n]),this._shortMonthsParse[n]=this.monthsShort(l,"").toLocaleLowerCase(),this._longMonthsParse[n]=this.months(l,"").toLocaleLowerCase();return e?t==="MMM"?(i=ae.call(this._shortMonthsParse,r),i!==-1?i:null):(i=ae.call(this._longMonthsParse,r),i!==-1?i:null):t==="MMM"?(i=ae.call(this._shortMonthsParse,r),i!==-1?i:(i=ae.call(this._longMonthsParse,r),i!==-1?i:null)):(i=ae.call(this._longMonthsParse,r),i!==-1?i:(i=ae.call(this._shortMonthsParse,r),i!==-1?i:null))}function Wu(o,t,e){var n,i,l;if(this._monthsParseExact)return Vu.call(this,o,t,e);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(i=Be([2e3,n]),e&&!this._longMonthsParse[n]&&(this._longMonthsParse[n]=new RegExp("^"+this.months(i,"").replace(".","")+"$","i"),this._shortMonthsParse[n]=new RegExp("^"+this.monthsShort(i,"").replace(".","")+"$","i")),!e&&!this._monthsParse[n]&&(l="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[n]=new RegExp(l.replace(".",""),"i")),e&&t==="MMMM"&&this._longMonthsParse[n].test(o))return n;if(e&&t==="MMM"&&this._shortMonthsParse[n].test(o))return n;if(!e&&this._monthsParse[n].test(o))return n}}function Hr(o,t){if(!o.isValid())return o;if(typeof t=="string"){if(/^\d+$/.test(t))t=Wt(t);else if(t=o.localeData().monthsParse(t),!qe(t))return o}var e=t,n=o.date();return n=n<29?n:Math.min(n,rs(o.year(),e)),o._isUTC?o._d.setUTCMonth(e,n):o._d.setMonth(e,n),o}function Ar(o){return o!=null?(Hr(this,o),lt.updateOffset(this,!0),this):Ro(this,"Month")}function Yu(){return rs(this.year(),this.month())}function Uu(o){return this._monthsParseExact?(Kt(this,"_monthsRegex")||_r.call(this),o?this._monthsShortStrictRegex:this._monthsShortRegex):(Kt(this,"_monthsShortRegex")||(this._monthsShortRegex=Xu),this._monthsShortStrictRegex&&o?this._monthsShortStrictRegex:this._monthsShortRegex)}function wu(o){return this._monthsParseExact?(Kt(this,"_monthsRegex")||_r.call(this),o?this._monthsStrictRegex:this._monthsRegex):(Kt(this,"_monthsRegex")||(this._monthsRegex=Nu),this._monthsStrictRegex&&o?this._monthsStrictRegex:this._monthsRegex)}function _r(){function o(c,d){return d.length-c.length}var t=[],e=[],n=[],i,l,r,a;for(i=0;i<12;i++)l=Be([2e3,i]),r=tn(this.monthsShort(l,"")),a=tn(this.months(l,"")),t.push(r),e.push(a),n.push(a),n.push(r);t.sort(o),e.sort(o),n.sort(o),this._monthsRegex=new RegExp("^("+n.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+t.join("|")+")","i")}function Zu(o,t,e,n,i,l,r){var a;return o<100&&o>=0?(a=new Date(o+400,t,e,n,i,l,r),isFinite(a.getFullYear())&&a.setFullYear(o)):a=new Date(o,t,e,n,i,l,r),a}function ho(o){var t,e;return o<100&&o>=0?(e=Array.prototype.slice.call(arguments),e[0]=o+400,t=new Date(Date.UTC.apply(null,e)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(o)):t=new Date(Date.UTC.apply(null,arguments)),t}function Go(o,t,e){var n=7+t-e,i=(7+ho(o,0,n).getUTCDay()-t)%7;return-i+n-1}function Br(o,t,e,n,i){var l=(7+e-n)%7,r=Go(o,n,i),a=1+7*(t-1)+l+r,c,d;return a<=0?(c=o-1,d=uo(c)+a):a>uo(o)?(c=o+1,d=a-uo(o)):(c=o,d=a),{year:c,dayOfYear:d}}function go(o,t,e){var n=Go(o.year(),t,e),i=Math.floor((o.dayOfYear()-n-1)/7)+1,l,r;return i<1?(r=o.year()-1,l=i+on(r,t,e)):i>on(o.year(),t,e)?(l=i-on(o.year(),t,e),r=o.year()+1):(r=o.year(),l=i),{week:l,year:r}}function on(o,t,e){var n=Go(o,t,e),i=Go(o+1,t,e);return(uo(o)-n+i)/7}ht("w",["ww",2],"wo","week"),ht("W",["WW",2],"Wo","isoWeek"),ct("w",te,Gn),ct("ww",te,Pe),ct("W",te,Gn),ct("WW",te,Pe),co(["w","ww","W","WW"],function(o,t,e,n){t[n.substr(0,1)]=Wt(o)});function vu(o){return go(o,this._week.dow,this._week.doy).week}var Qu={dow:0,doy:6};function Ku(){return this._week.dow}function Hu(){return this._week.doy}function Au(o){var t=this.localeData().week(this);return o==null?t:this.add((o-t)*7,"d")}function _u(o){var t=go(this,1,4).week;return o==null?t:this.add((o-t)*7,"d")}ht("d",0,"do","day"),ht("dd",0,0,function(o){return this.localeData().weekdaysMin(this,o)}),ht("ddd",0,0,function(o){return this.localeData().weekdaysShort(this,o)}),ht("dddd",0,0,function(o){return this.localeData().weekdays(this,o)}),ht("e",0,0,"weekday"),ht("E",0,0,"isoWeekday"),ct("d",te),ct("e",te),ct("E",te),ct("dd",function(o,t){return t.weekdaysMinRegex(o)}),ct("ddd",function(o,t){return t.weekdaysShortRegex(o)}),ct("dddd",function(o,t){return t.weekdaysRegex(o)}),co(["dd","ddd","dddd"],function(o,t,e,n){var i=e._locale.weekdaysParse(o,n,e._strict);i!=null?t.d=i:Ot(e).invalidWeekday=o}),co(["d","e","E"],function(o,t,e,n){t[n]=Wt(o)});function Bu(o,t){return typeof o!="string"?o:isNaN(o)?(o=t.weekdaysParse(o),typeof o=="number"?o:null):parseInt(o,10)}function ku(o,t){return typeof o=="string"?t.weekdaysParse(o)%7||7:isNaN(o)?null:o}function ls(o,t){return o.slice(t,7).concat(o.slice(0,t))}var Gu="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),kr="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),xu="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Ju=ao,$u=ao,zu=ao;function ju(o,t){var e=Ve(this._weekdays)?this._weekdays:this._weekdays[o&&o!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return o===!0?ls(e,this._week.dow):o?e[o.day()]:e}function qu(o){return o===!0?ls(this._weekdaysShort,this._week.dow):o?this._weekdaysShort[o.day()]:this._weekdaysShort}function tR(o){return o===!0?ls(this._weekdaysMin,this._week.dow):o?this._weekdaysMin[o.day()]:this._weekdaysMin}function eR(o,t,e){var n,i,l,r=o.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],n=0;n<7;++n)l=Be([2e3,1]).day(n),this._minWeekdaysParse[n]=this.weekdaysMin(l,"").toLocaleLowerCase(),this._shortWeekdaysParse[n]=this.weekdaysShort(l,"").toLocaleLowerCase(),this._weekdaysParse[n]=this.weekdays(l,"").toLocaleLowerCase();return e?t==="dddd"?(i=ae.call(this._weekdaysParse,r),i!==-1?i:null):t==="ddd"?(i=ae.call(this._shortWeekdaysParse,r),i!==-1?i:null):(i=ae.call(this._minWeekdaysParse,r),i!==-1?i:null):t==="dddd"?(i=ae.call(this._weekdaysParse,r),i!==-1||(i=ae.call(this._shortWeekdaysParse,r),i!==-1)?i:(i=ae.call(this._minWeekdaysParse,r),i!==-1?i:null)):t==="ddd"?(i=ae.call(this._shortWeekdaysParse,r),i!==-1||(i=ae.call(this._weekdaysParse,r),i!==-1)?i:(i=ae.call(this._minWeekdaysParse,r),i!==-1?i:null)):(i=ae.call(this._minWeekdaysParse,r),i!==-1||(i=ae.call(this._weekdaysParse,r),i!==-1)?i:(i=ae.call(this._shortWeekdaysParse,r),i!==-1?i:null))}function nR(o,t,e){var n,i,l;if(this._weekdaysParseExact)return eR.call(this,o,t,e);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(i=Be([2e3,1]).day(n),e&&!this._fullWeekdaysParse[n]&&(this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(i,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(i,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(i,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[n]||(l="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[n]=new RegExp(l.replace(".",""),"i")),e&&t==="dddd"&&this._fullWeekdaysParse[n].test(o))return n;if(e&&t==="ddd"&&this._shortWeekdaysParse[n].test(o))return n;if(e&&t==="dd"&&this._minWeekdaysParse[n].test(o))return n;if(!e&&this._weekdaysParse[n].test(o))return n}}function oR(o){if(!this.isValid())return o!=null?this:NaN;var t=Ro(this,"Day");return o!=null?(o=Bu(o,this.localeData()),this.add(o-t,"d")):t}function iR(o){if(!this.isValid())return o!=null?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return o==null?t:this.add(o-t,"d")}function sR(o){if(!this.isValid())return o!=null?this:NaN;if(o!=null){var t=ku(o,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function rR(o){return this._weekdaysParseExact?(Kt(this,"_weekdaysRegex")||as.call(this),o?this._weekdaysStrictRegex:this._weekdaysRegex):(Kt(this,"_weekdaysRegex")||(this._weekdaysRegex=Ju),this._weekdaysStrictRegex&&o?this._weekdaysStrictRegex:this._weekdaysRegex)}function lR(o){return this._weekdaysParseExact?(Kt(this,"_weekdaysRegex")||as.call(this),o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(Kt(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=$u),this._weekdaysShortStrictRegex&&o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function aR(o){return this._weekdaysParseExact?(Kt(this,"_weekdaysRegex")||as.call(this),o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(Kt(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=zu),this._weekdaysMinStrictRegex&&o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function as(){function o(u,h){return h.length-u.length}var t=[],e=[],n=[],i=[],l,r,a,c,d;for(l=0;l<7;l++)r=Be([2e3,1]).day(l),a=tn(this.weekdaysMin(r,"")),c=tn(this.weekdaysShort(r,"")),d=tn(this.weekdays(r,"")),t.push(a),e.push(c),n.push(d),i.push(a),i.push(c),i.push(d);t.sort(o),e.sort(o),n.sort(o),i.sort(o),this._weekdaysRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+t.join("|")+")","i")}function cs(){return this.hours()%12||12}function cR(){return this.hours()||24}ht("H",["HH",2],0,"hour"),ht("h",["hh",2],0,cs),ht("k",["kk",2],0,cR),ht("hmm",0,0,function(){return""+cs.apply(this)+Ge(this.minutes(),2)}),ht("hmmss",0,0,function(){return""+cs.apply(this)+Ge(this.minutes(),2)+Ge(this.seconds(),2)}),ht("Hmm",0,0,function(){return""+this.hours()+Ge(this.minutes(),2)}),ht("Hmmss",0,0,function(){return""+this.hours()+Ge(this.minutes(),2)+Ge(this.seconds(),2)});function Gr(o,t){ht(o,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}Gr("a",!0),Gr("A",!1);function xr(o,t){return t._meridiemParse}ct("a",xr),ct("A",xr),ct("H",te,is),ct("h",te,Gn),ct("k",te,Gn),ct("HH",te,Pe),ct("hh",te,Pe),ct("kk",te,Pe),ct("hmm",Ur),ct("hmmss",wr),ct("Hmm",Ur),ct("Hmmss",wr),kt(["H","HH"],he),kt(["k","kk"],function(o,t,e){var n=Wt(o);t[he]=n===24?0:n}),kt(["a","A"],function(o,t,e){e._isPm=e._locale.isPM(o),e._meridiem=o}),kt(["h","hh"],function(o,t,e){t[he]=Wt(o),Ot(e).bigHour=!0}),kt("hmm",function(o,t,e){var n=o.length-2;t[he]=Wt(o.substr(0,n)),t[Ye]=Wt(o.substr(n)),Ot(e).bigHour=!0}),kt("hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[he]=Wt(o.substr(0,n)),t[Ye]=Wt(o.substr(n,2)),t[nn]=Wt(o.substr(i)),Ot(e).bigHour=!0}),kt("Hmm",function(o,t,e){var n=o.length-2;t[he]=Wt(o.substr(0,n)),t[Ye]=Wt(o.substr(n))}),kt("Hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[he]=Wt(o.substr(0,n)),t[Ye]=Wt(o.substr(n,2)),t[nn]=Wt(o.substr(i))});function dR(o){return(o+"").toLowerCase().charAt(0)==="p"}var uR=/[ap]\.?m?\.?/i,RR=xn("Hours",!0);function hR(o,t,e){return o>11?e?"pm":"PM":e?"am":"AM"}var Jr={calendar:eu,longDateFormat:su,invalidDate:lu,ordinal:cu,dayOfMonthOrdinalParse:du,relativeTime:Ru,months:Fu,monthsShort:Qr,week:Qu,weekdays:Gu,weekdaysMin:xu,weekdaysShort:kr,meridiemParse:uR},oe={},fo={},To;function gR(o,t){var e,n=Math.min(o.length,t.length);for(e=0;e<n;e+=1)if(o[e]!==t[e])return e;return n}function $r(o){return o&&o.toLowerCase().replace("_","-")}function fR(o){for(var t=0,e,n,i,l;t<o.length;){for(l=$r(o[t]).split("-"),e=l.length,n=$r(o[t+1]),n=n?n.split("-"):null;e>0;){if(i=xo(l.slice(0,e).join("-")),i)return i;if(n&&n.length>=e&&gR(l,n)>=e-1)break;e--}t++}return To}function TR(o){return!!(o&&o.match("^[^/\\\\]*$"))}function xo(o){var t=null,e;if(oe[o]===void 0&&typeof module<"u"&&module&&module.exports&&TR(o))try{t=To._abbr,e=require,e("./locale/"+o),Tn(t)}catch{oe[o]=null}return oe[o]}function Tn(o,t){var e;return o&&(pe(t)?e=sn(o):e=ds(o,t),e?To=e:typeof console<"u"&&console.warn&&console.warn("Locale "+o+" not found. Did you forget to load it?")),To._abbr}function ds(o,t){if(t!==null){var e,n=Jr;if(t.abbr=o,oe[o]!=null)yr("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=oe[o]._config;else if(t.parentLocale!=null)if(oe[t.parentLocale]!=null)n=oe[t.parentLocale]._config;else if(e=xo(t.parentLocale),e!=null)n=e._config;else return fo[t.parentLocale]||(fo[t.parentLocale]=[]),fo[t.parentLocale].push({name:o,config:t}),null;return oe[o]=new zi($i(n,t)),fo[o]&&fo[o].forEach(function(i){ds(i.name,i.config)}),Tn(o),oe[o]}else return delete oe[o],null}function mR(o,t){if(t!=null){var e,n,i=Jr;oe[o]!=null&&oe[o].parentLocale!=null?oe[o].set($i(oe[o]._config,t)):(n=xo(o),n!=null&&(i=n._config),t=$i(i,t),n==null&&(t.abbr=o),e=new zi(t),e.parentLocale=oe[o],oe[o]=e),Tn(o)}else oe[o]!=null&&(oe[o].parentLocale!=null?(oe[o]=oe[o].parentLocale,o===Tn()&&Tn(o)):oe[o]!=null&&delete oe[o]);return oe[o]}function sn(o){var t;if(o&&o._locale&&o._locale._abbr&&(o=o._locale._abbr),!o)return To;if(!Ve(o)){if(t=xo(o),t)return t;o=[o]}return fR(o)}function CR(){return ji(oe)}function us(o){var t,e=o._a;return e&&Ot(o).overflow===-2&&(t=e[en]<0||e[en]>11?en:e[xe]<1||e[xe]>rs(e[ge],e[en])?xe:e[he]<0||e[he]>24||e[he]===24&&(e[Ye]!==0||e[nn]!==0||e[Dn]!==0)?he:e[Ye]<0||e[Ye]>59?Ye:e[nn]<0||e[nn]>59?nn:e[Dn]<0||e[Dn]>999?Dn:-1,Ot(o)._overflowDayOfYear&&(t<ge||t>xe)&&(t=xe),Ot(o)._overflowWeeks&&t===-1&&(t=Lu),Ot(o)._overflowWeekday&&t===-1&&(t=Pu),Ot(o).overflow=t),o}var pR=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,IR=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ER=/Z|[+-]\d\d(?::?\d\d)?/,Jo=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],Rs=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],LR=/^\/?Date\((-?\d+)/i,PR=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,MR={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function zr(o){var t,e,n=o._i,i=pR.exec(n)||IR.exec(n),l,r,a,c,d=Jo.length,u=Rs.length;if(i){for(Ot(o).iso=!0,t=0,e=d;t<e;t++)if(Jo[t][1].exec(i[1])){r=Jo[t][0],l=Jo[t][2]!==!1;break}if(r==null){o._isValid=!1;return}if(i[3]){for(t=0,e=u;t<e;t++)if(Rs[t][1].exec(i[3])){a=(i[2]||" ")+Rs[t][0];break}if(a==null){o._isValid=!1;return}}if(!l&&a!=null){o._isValid=!1;return}if(i[4])if(ER.exec(i[4]))c="Z";else{o._isValid=!1;return}o._f=r+(a||"")+(c||""),gs(o)}else o._isValid=!1}function OR(o,t,e,n,i,l){var r=[SR(o),Qr.indexOf(t),parseInt(e,10),parseInt(n,10),parseInt(i,10)];return l&&r.push(parseInt(l,10)),r}function SR(o){var t=parseInt(o,10);return t<=49?2e3+t:t<=999?1900+t:t}function DR(o){return o.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function FR(o,t,e){if(o){var n=kr.indexOf(o),i=new Date(t[0],t[1],t[2]).getDay();if(n!==i)return Ot(e).weekdayMismatch=!0,e._isValid=!1,!1}return!0}function XR(o,t,e){if(o)return MR[o];if(t)return 0;var n=parseInt(e,10),i=n%100,l=(n-i)/100;return l*60+i}function jr(o){var t=PR.exec(DR(o._i)),e;if(t){if(e=OR(t[4],t[3],t[2],t[5],t[6],t[7]),!FR(t[1],e,o))return;o._a=e,o._tzm=XR(t[8],t[9],t[10]),o._d=ho.apply(null,o._a),o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),Ot(o).rfc2822=!0}else o._isValid=!1}function NR(o){var t=LR.exec(o._i);if(t!==null){o._d=new Date(+t[1]);return}if(zr(o),o._isValid===!1)delete o._isValid;else return;if(jr(o),o._isValid===!1)delete o._isValid;else return;o._strict?o._isValid=!1:lt.createFromInputFallback(o)}lt.createFromInputFallback=De("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(o){o._d=new Date(o._i+(o._useUTC?" UTC":""))});function Jn(o,t,e){return o??t??e}function yR(o){var t=new Date(lt.now());return o._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function hs(o){var t,e,n=[],i,l,r;if(!o._d){for(i=yR(o),o._w&&o._a[xe]==null&&o._a[en]==null&&bR(o),o._dayOfYear!=null&&(r=Jn(o._a[ge],i[ge]),(o._dayOfYear>uo(r)||o._dayOfYear===0)&&(Ot(o)._overflowDayOfYear=!0),e=ho(r,0,o._dayOfYear),o._a[en]=e.getUTCMonth(),o._a[xe]=e.getUTCDate()),t=0;t<3&&o._a[t]==null;++t)o._a[t]=n[t]=i[t];for(;t<7;t++)o._a[t]=n[t]=o._a[t]==null?t===2?1:0:o._a[t];o._a[he]===24&&o._a[Ye]===0&&o._a[nn]===0&&o._a[Dn]===0&&(o._nextDay=!0,o._a[he]=0),o._d=(o._useUTC?ho:Zu).apply(null,n),l=o._useUTC?o._d.getUTCDay():o._d.getDay(),o._tzm!=null&&o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),o._nextDay&&(o._a[he]=24),o._w&&typeof o._w.d<"u"&&o._w.d!==l&&(Ot(o).weekdayMismatch=!0)}}function bR(o){var t,e,n,i,l,r,a,c,d;t=o._w,t.GG!=null||t.W!=null||t.E!=null?(l=1,r=4,e=Jn(t.GG,o._a[ge],go(ee(),1,4).year),n=Jn(t.W,1),i=Jn(t.E,1),(i<1||i>7)&&(c=!0)):(l=o._locale._week.dow,r=o._locale._week.doy,d=go(ee(),l,r),e=Jn(t.gg,o._a[ge],d.year),n=Jn(t.w,d.week),t.d!=null?(i=t.d,(i<0||i>6)&&(c=!0)):t.e!=null?(i=t.e+l,(t.e<0||t.e>6)&&(c=!0)):i=l),n<1||n>on(e,l,r)?Ot(o)._overflowWeeks=!0:c!=null?Ot(o)._overflowWeekday=!0:(a=Br(e,n,i,l,r),o._a[ge]=a.year,o._dayOfYear=a.dayOfYear)}lt.ISO_8601=function(){},lt.RFC_2822=function(){};function gs(o){if(o._f===lt.ISO_8601){zr(o);return}if(o._f===lt.RFC_2822){jr(o);return}o._a=[],Ot(o).empty=!0;var t=""+o._i,e,n,i,l,r,a=t.length,c=0,d,u;for(i=br(o._f,o._locale).match(qi)||[],u=i.length,e=0;e<u;e++)l=i[e],n=(t.match(pu(l,o))||[])[0],n&&(r=t.substr(0,t.indexOf(n)),r.length>0&&Ot(o).unusedInput.push(r),t=t.slice(t.indexOf(n)+n.length),c+=n.length),Bn[l]?(n?Ot(o).empty=!1:Ot(o).unusedTokens.push(l),Eu(l,n,o)):o._strict&&!n&&Ot(o).unusedTokens.push(l);Ot(o).charsLeftOver=a-c,t.length>0&&Ot(o).unusedInput.push(t),o._a[he]<=12&&Ot(o).bigHour===!0&&o._a[he]>0&&(Ot(o).bigHour=void 0),Ot(o).parsedDateParts=o._a.slice(0),Ot(o).meridiem=o._meridiem,o._a[he]=VR(o._locale,o._a[he],o._meridiem),d=Ot(o).era,d!==null&&(o._a[ge]=o._locale.erasConvertYear(d,o._a[ge])),hs(o),us(o)}function VR(o,t,e){var n;return e==null?t:o.meridiemHour!=null?o.meridiemHour(t,e):(o.isPM!=null&&(n=o.isPM(e),n&&t<12&&(t+=12),!n&&t===12&&(t=0)),t)}function WR(o){var t,e,n,i,l,r,a=!1,c=o._f.length;if(c===0){Ot(o).invalidFormat=!0,o._d=new Date(NaN);return}for(i=0;i<c;i++)l=0,r=!1,t=Ji({},o),o._useUTC!=null&&(t._useUTC=o._useUTC),t._f=o._f[i],gs(t),Gi(t)&&(r=!0),l+=Ot(t).charsLeftOver,l+=Ot(t).unusedTokens.length*10,Ot(t).score=l,a?l<n&&(n=l,e=t):(n==null||l<n||r)&&(n=l,e=t,r&&(a=!0));fn(o,e||t)}function YR(o){if(!o._d){var t=es(o._i),e=t.day===void 0?t.date:t.day;o._a=Dr([t.year,t.month,e,t.hour,t.minute,t.second,t.millisecond],function(n){return n&&parseInt(n,10)}),hs(o)}}function UR(o){var t=new lo(us(qr(o)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function qr(o){var t=o._i,e=o._f;return o._locale=o._locale||sn(o._l),t===null||e===void 0&&t===""?wo({nullInput:!0}):(typeof t=="string"&&(o._i=t=o._locale.preparse(t)),We(t)?new lo(us(t)):(ro(t)?o._d=t:Ve(e)?WR(o):e?gs(o):wR(o),Gi(o)||(o._d=null),o))}function wR(o){var t=o._i;pe(t)?o._d=new Date(lt.now()):ro(t)?o._d=new Date(t.valueOf()):typeof t=="string"?NR(o):Ve(t)?(o._a=Dr(t.slice(0),function(e){return parseInt(e,10)}),hs(o)):Sn(t)?YR(o):qe(t)?o._d=new Date(t):lt.createFromInputFallback(o)}function tl(o,t,e,n,i){var l={};return(t===!0||t===!1)&&(n=t,t=void 0),(e===!0||e===!1)&&(n=e,e=void 0),(Sn(o)&&Bi(o)||Ve(o)&&o.length===0)&&(o=void 0),l._isAMomentObject=!0,l._useUTC=l._isUTC=i,l._l=e,l._i=o,l._f=t,l._strict=n,UR(l)}function ee(o,t,e,n){return tl(o,t,e,n,!1)}var ZR=De("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=ee.apply(null,arguments);return this.isValid()&&o.isValid()?o<this?this:o:wo()}),vR=De("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=ee.apply(null,arguments);return this.isValid()&&o.isValid()?o>this?this:o:wo()});function el(o,t){var e,n;if(t.length===1&&Ve(t[0])&&(t=t[0]),!t.length)return ee();for(e=t[0],n=1;n<t.length;++n)(!t[n].isValid()||t[n][o](e))&&(e=t[n]);return e}function QR(){var o=[].slice.call(arguments,0);return el("isBefore",o)}function KR(){var o=[].slice.call(arguments,0);return el("isAfter",o)}var HR=function(){return Date.now?Date.now():+new Date},mo=["year","quarter","month","week","day","hour","minute","second","millisecond"];function AR(o){var t,e=!1,n,i=mo.length;for(t in o)if(Kt(o,t)&&!(ae.call(mo,t)!==-1&&(o[t]==null||!isNaN(o[t]))))return!1;for(n=0;n<i;++n)if(o[mo[n]]){if(e)return!1;parseFloat(o[mo[n]])!==Wt(o[mo[n]])&&(e=!0)}return!0}function _R(){return this._isValid}function BR(){return Ue(NaN)}function $o(o){var t=es(o),e=t.year||0,n=t.quarter||0,i=t.month||0,l=t.week||t.isoWeek||0,r=t.day||0,a=t.hour||0,c=t.minute||0,d=t.second||0,u=t.millisecond||0;this._isValid=AR(t),this._milliseconds=+u+d*1e3+c*6e4+a*1e3*60*60,this._days=+r+l*7,this._months=+i+n*3+e*12,this._data={},this._locale=sn(),this._bubble()}function zo(o){return o instanceof $o}function fs(o){return o<0?Math.round(-1*o)*-1:Math.round(o)}function kR(o,t,e){var n=Math.min(o.length,t.length),i=Math.abs(o.length-t.length),l=0,r;for(r=0;r<n;r++)Wt(o[r])!==Wt(t[r])&&l++;return l+i}function nl(o,t){ht(o,0,0,function(){var e=this.utcOffset(),n="+";return e<0&&(e=-e,n="-"),n+Ge(~~(e/60),2)+t+Ge(~~e%60,2)})}nl("Z",":"),nl("ZZ",""),ct("Z",_o),ct("ZZ",_o),kt(["Z","ZZ"],function(o,t,e){e._useUTC=!0,e._tzm=Ts(_o,o)});var GR=/([\+\-]|\d\d)/gi;function Ts(o,t){var e=(t||"").match(o),n,i,l;return e===null?null:(n=e[e.length-1]||[],i=(n+"").match(GR)||["-",0,0],l=+(i[1]*60)+Wt(i[2]),l===0?0:i[0]==="+"?l:-l)}function ms(o,t){var e,n;return t._isUTC?(e=t.clone(),n=(We(o)||ro(o)?o.valueOf():ee(o).valueOf())-e.valueOf(),e._d.setTime(e._d.valueOf()+n),lt.updateOffset(e,!1),e):ee(o).local()}function Cs(o){return-Math.round(o._d.getTimezoneOffset())}lt.updateOffset=function(){};function xR(o,t,e){var n=this._offset||0,i;if(!this.isValid())return o!=null?this:NaN;if(o!=null){if(typeof o=="string"){if(o=Ts(_o,o),o===null)return this}else Math.abs(o)<16&&!e&&(o=o*60);return!this._isUTC&&t&&(i=Cs(this)),this._offset=o,this._isUTC=!0,i!=null&&this.add(i,"m"),n!==o&&(!t||this._changeInProgress?rl(this,Ue(o-n,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,lt.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?n:Cs(this)}function JR(o,t){return o!=null?(typeof o!="string"&&(o=-o),this.utcOffset(o,t),this):-this.utcOffset()}function $R(o){return this.utcOffset(0,o)}function zR(o){return this._isUTC&&(this.utcOffset(0,o),this._isUTC=!1,o&&this.subtract(Cs(this),"m")),this}function jR(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var o=Ts(mu,this._i);o!=null?this.utcOffset(o):this.utcOffset(0,!0)}return this}function qR(o){return this.isValid()?(o=o?ee(o).utcOffset():0,(this.utcOffset()-o)%60===0):!1}function th(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function eh(){if(!pe(this._isDSTShifted))return this._isDSTShifted;var o={},t;return Ji(o,this),o=qr(o),o._a?(t=o._isUTC?Be(o._a):ee(o._a),this._isDSTShifted=this.isValid()&&kR(o._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function nh(){return this.isValid()?!this._isUTC:!1}function oh(){return this.isValid()?this._isUTC:!1}function ol(){return this.isValid()?this._isUTC&&this._offset===0:!1}var ih=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,sh=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Ue(o,t){var e=o,n=null,i,l,r;return zo(o)?e={ms:o._milliseconds,d:o._days,M:o._months}:qe(o)||!isNaN(+o)?(e={},t?e[t]=+o:e.milliseconds=+o):(n=ih.exec(o))?(i=n[1]==="-"?-1:1,e={y:0,d:Wt(n[xe])*i,h:Wt(n[he])*i,m:Wt(n[Ye])*i,s:Wt(n[nn])*i,ms:Wt(fs(n[Dn]*1e3))*i}):(n=sh.exec(o))?(i=n[1]==="-"?-1:1,e={y:Fn(n[2],i),M:Fn(n[3],i),w:Fn(n[4],i),d:Fn(n[5],i),h:Fn(n[6],i),m:Fn(n[7],i),s:Fn(n[8],i)}):e==null?e={}:typeof e=="object"&&("from"in e||"to"in e)&&(r=rh(ee(e.from),ee(e.to)),e={},e.ms=r.milliseconds,e.M=r.months),l=new $o(e),zo(o)&&Kt(o,"_locale")&&(l._locale=o._locale),zo(o)&&Kt(o,"_isValid")&&(l._isValid=o._isValid),l}Ue.fn=$o.prototype,Ue.invalid=BR;function Fn(o,t){var e=o&&parseFloat(o.replace(",","."));return(isNaN(e)?0:e)*t}function il(o,t){var e={};return e.months=t.month()-o.month()+(t.year()-o.year())*12,o.clone().add(e.months,"M").isAfter(t)&&--e.months,e.milliseconds=+t-+o.clone().add(e.months,"M"),e}function rh(o,t){var e;return o.isValid()&&t.isValid()?(t=ms(t,o),o.isBefore(t)?e=il(o,t):(e=il(t,o),e.milliseconds=-e.milliseconds,e.months=-e.months),e):{milliseconds:0,months:0}}function sl(o,t){return function(e,n){var i,l;return n!==null&&!isNaN(+n)&&(yr(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),l=e,e=n,n=l),i=Ue(e,n),rl(this,i,o),this}}function rl(o,t,e,n){var i=t._milliseconds,l=fs(t._days),r=fs(t._months);o.isValid()&&(n=n??!0,r&&Hr(o,Ro(o,"Month")+r*e),l&&vr(o,"Date",Ro(o,"Date")+l*e),i&&o._d.setTime(o._d.valueOf()+i*e),n&&lt.updateOffset(o,l||r))}var lh=sl(1,"add"),ah=sl(-1,"subtract");function ll(o){return typeof o=="string"||o instanceof String}function ch(o){return We(o)||ro(o)||ll(o)||qe(o)||uh(o)||dh(o)||o===null||o===void 0}function dh(o){var t=Sn(o)&&!Bi(o),e=!1,n=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],i,l,r=n.length;for(i=0;i<r;i+=1)l=n[i],e=e||Kt(o,l);return t&&e}function uh(o){var t=Ve(o),e=!1;return t&&(e=o.filter(function(n){return!qe(n)&&ll(o)}).length===0),t&&e}function Rh(o){var t=Sn(o)&&!Bi(o),e=!1,n=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],i,l;for(i=0;i<n.length;i+=1)l=n[i],e=e||Kt(o,l);return t&&e}function hh(o,t){var e=o.diff(t,"days",!0);return e<-6?"sameElse":e<-1?"lastWeek":e<0?"lastDay":e<1?"sameDay":e<2?"nextDay":e<7?"nextWeek":"sameElse"}function gh(o,t){arguments.length===1&&(arguments[0]?ch(arguments[0])?(o=arguments[0],t=void 0):Rh(arguments[0])&&(t=arguments[0],o=void 0):(o=void 0,t=void 0));var e=o||ee(),n=ms(e,this).startOf("day"),i=lt.calendarFormat(this,n)||"sameElse",l=t&&(ke(t[i])?t[i].call(this,e):t[i]);return this.format(l||this.localeData().calendar(i,this,ee(e)))}function fh(){return new lo(this)}function Th(o,t){var e=We(o)?o:ee(o);return this.isValid()&&e.isValid()?(t=Fe(t)||"millisecond",t==="millisecond"?this.valueOf()>e.valueOf():e.valueOf()<this.clone().startOf(t).valueOf()):!1}function mh(o,t){var e=We(o)?o:ee(o);return this.isValid()&&e.isValid()?(t=Fe(t)||"millisecond",t==="millisecond"?this.valueOf()<e.valueOf():this.clone().endOf(t).valueOf()<e.valueOf()):!1}function Ch(o,t,e,n){var i=We(o)?o:ee(o),l=We(t)?t:ee(t);return this.isValid()&&i.isValid()&&l.isValid()?(n=n||"()",(n[0]==="("?this.isAfter(i,e):!this.isBefore(i,e))&&(n[1]===")"?this.isBefore(l,e):!this.isAfter(l,e))):!1}function ph(o,t){var e=We(o)?o:ee(o),n;return this.isValid()&&e.isValid()?(t=Fe(t)||"millisecond",t==="millisecond"?this.valueOf()===e.valueOf():(n=e.valueOf(),this.clone().startOf(t).valueOf()<=n&&n<=this.clone().endOf(t).valueOf())):!1}function Ih(o,t){return this.isSame(o,t)||this.isAfter(o,t)}function Eh(o,t){return this.isSame(o,t)||this.isBefore(o,t)}function Lh(o,t,e){var n,i,l;if(!this.isValid())return NaN;if(n=ms(o,this),!n.isValid())return NaN;switch(i=(n.utcOffset()-this.utcOffset())*6e4,t=Fe(t),t){case"year":l=jo(this,n)/12;break;case"month":l=jo(this,n);break;case"quarter":l=jo(this,n)/3;break;case"second":l=(this-n)/1e3;break;case"minute":l=(this-n)/6e4;break;case"hour":l=(this-n)/36e5;break;case"day":l=(this-n-i)/864e5;break;case"week":l=(this-n-i)/6048e5;break;default:l=this-n}return e?l:Xe(l)}function jo(o,t){if(o.date()<t.date())return-jo(t,o);var e=(t.year()-o.year())*12+(t.month()-o.month()),n=o.clone().add(e,"months"),i,l;return t-n<0?(i=o.clone().add(e-1,"months"),l=(t-n)/(n-i)):(i=o.clone().add(e+1,"months"),l=(t-n)/(i-n)),-(e+l)||0}lt.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",lt.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function Ph(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function Mh(o){if(!this.isValid())return null;var t=o!==!0,e=t?this.clone().utc():this;return e.year()<0||e.year()>9999?vo(e,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):ke(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",vo(e,"Z")):vo(e,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function Oh(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var o="moment",t="",e,n,i,l;return this.isLocal()||(o=this.utcOffset()===0?"moment.utc":"moment.parseZone",t="Z"),e="["+o+'("]',n=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i="-MM-DD[T]HH:mm:ss.SSS",l=t+'[")]',this.format(e+n+i+l)}function Sh(o){o||(o=this.isUtc()?lt.defaultFormatUtc:lt.defaultFormat);var t=vo(this,o);return this.localeData().postformat(t)}function Dh(o,t){return this.isValid()&&(We(o)&&o.isValid()||ee(o).isValid())?Ue({to:this,from:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Fh(o){return this.from(ee(),o)}function Xh(o,t){return this.isValid()&&(We(o)&&o.isValid()||ee(o).isValid())?Ue({from:this,to:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Nh(o){return this.to(ee(),o)}function al(o){var t;return o===void 0?this._locale._abbr:(t=sn(o),t!=null&&(this._locale=t),this)}var cl=De("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(o){return o===void 0?this.localeData():this.locale(o)});function dl(){return this._locale}var qo=1e3,$n=60*qo,ti=60*$n,ul=(365*400+97)*24*ti;function zn(o,t){return(o%t+t)%t}function Rl(o,t,e){return o<100&&o>=0?new Date(o+400,t,e)-ul:new Date(o,t,e).valueOf()}function hl(o,t,e){return o<100&&o>=0?Date.UTC(o+400,t,e)-ul:Date.UTC(o,t,e)}function yh(o){var t,e;if(o=Fe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?hl:Rl,o){case"year":t=e(this.year(),0,1);break;case"quarter":t=e(this.year(),this.month()-this.month()%3,1);break;case"month":t=e(this.year(),this.month(),1);break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":t=e(this.year(),this.month(),this.date());break;case"hour":t=this._d.valueOf(),t-=zn(t+(this._isUTC?0:this.utcOffset()*$n),ti);break;case"minute":t=this._d.valueOf(),t-=zn(t,$n);break;case"second":t=this._d.valueOf(),t-=zn(t,qo);break}return this._d.setTime(t),lt.updateOffset(this,!0),this}function bh(o){var t,e;if(o=Fe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?hl:Rl,o){case"year":t=e(this.year()+1,0,1)-1;break;case"quarter":t=e(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":t=e(this.year(),this.month()+1,1)-1;break;case"week":t=e(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":t=e(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":t=e(this.year(),this.month(),this.date()+1)-1;break;case"hour":t=this._d.valueOf(),t+=ti-zn(t+(this._isUTC?0:this.utcOffset()*$n),ti)-1;break;case"minute":t=this._d.valueOf(),t+=$n-zn(t,$n)-1;break;case"second":t=this._d.valueOf(),t+=qo-zn(t,qo)-1;break}return this._d.setTime(t),lt.updateOffset(this,!0),this}function Vh(){return this._d.valueOf()-(this._offset||0)*6e4}function Wh(){return Math.floor(this.valueOf()/1e3)}function Yh(){return new Date(this.valueOf())}function Uh(){var o=this;return[o.year(),o.month(),o.date(),o.hour(),o.minute(),o.second(),o.millisecond()]}function wh(){var o=this;return{years:o.year(),months:o.month(),date:o.date(),hours:o.hours(),minutes:o.minutes(),seconds:o.seconds(),milliseconds:o.milliseconds()}}function Zh(){return this.isValid()?this.toISOString():null}function vh(){return Gi(this)}function Qh(){return fn({},Ot(this))}function Kh(){return Ot(this).overflow}function Hh(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}ht("N",0,0,"eraAbbr"),ht("NN",0,0,"eraAbbr"),ht("NNN",0,0,"eraAbbr"),ht("NNNN",0,0,"eraName"),ht("NNNNN",0,0,"eraNarrow"),ht("y",["y",1],"yo","eraYear"),ht("y",["yy",2],0,"eraYear"),ht("y",["yyy",3],0,"eraYear"),ht("y",["yyyy",4],0,"eraYear"),ct("N",ps),ct("NN",ps),ct("NNN",ps),ct("NNNN",qh),ct("NNNNN",tg),kt(["N","NN","NNN","NNNN","NNNNN"],function(o,t,e,n){var i=e._locale.erasParse(o,n,e._strict);i?Ot(e).era=i:Ot(e).invalidEra=o}),ct("y",kn),ct("yy",kn),ct("yyy",kn),ct("yyyy",kn),ct("yo",eg),kt(["y","yy","yyy","yyyy"],ge),kt(["yo"],function(o,t,e,n){var i;e._locale._eraYearOrdinalRegex&&(i=o.match(e._locale._eraYearOrdinalRegex)),e._locale.eraYearOrdinalParse?t[ge]=e._locale.eraYearOrdinalParse(o,i):t[ge]=parseInt(o,10)});function Ah(o,t){var e,n,i,l=this._eras||sn("en")._eras;for(e=0,n=l.length;e<n;++e)switch(typeof l[e].since==="string"&&(i=lt(l[e].since).startOf("day"),l[e].since=i.valueOf()),typeof l[e].until){case"undefined":l[e].until=1/0;break;case"string":i=lt(l[e].until).startOf("day").valueOf(),l[e].until=i.valueOf();break}return l}function _h(o,t,e){var n,i,l=this.eras(),r,a,c;for(o=o.toUpperCase(),n=0,i=l.length;n<i;++n)if(r=l[n].name.toUpperCase(),a=l[n].abbr.toUpperCase(),c=l[n].narrow.toUpperCase(),e)switch(t){case"N":case"NN":case"NNN":if(a===o)return l[n];break;case"NNNN":if(r===o)return l[n];break;case"NNNNN":if(c===o)return l[n];break}else if([r,a,c].indexOf(o)>=0)return l[n]}function Bh(o,t){var e=o.since<=o.until?1:-1;return t===void 0?lt(o.since).year():lt(o.since).year()+(t-o.offset)*e}function kh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].name;return""}function Gh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].narrow;return""}function xh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].abbr;return""}function Jh(){var o,t,e,n,i=this.localeData().eras();for(o=0,t=i.length;o<t;++o)if(e=i[o].since<=i[o].until?1:-1,n=this.clone().startOf("day").valueOf(),i[o].since<=n&&n<=i[o].until||i[o].until<=n&&n<=i[o].since)return(this.year()-lt(i[o].since).year())*e+i[o].offset;return this.year()}function $h(o){return Kt(this,"_erasNameRegex")||Is.call(this),o?this._erasNameRegex:this._erasRegex}function zh(o){return Kt(this,"_erasAbbrRegex")||Is.call(this),o?this._erasAbbrRegex:this._erasRegex}function jh(o){return Kt(this,"_erasNarrowRegex")||Is.call(this),o?this._erasNarrowRegex:this._erasRegex}function ps(o,t){return t.erasAbbrRegex(o)}function qh(o,t){return t.erasNameRegex(o)}function tg(o,t){return t.erasNarrowRegex(o)}function eg(o,t){return t._eraYearOrdinalRegex||kn}function Is(){var o=[],t=[],e=[],n=[],i,l,r,a,c,d=this.eras();for(i=0,l=d.length;i<l;++i)r=tn(d[i].name),a=tn(d[i].abbr),c=tn(d[i].narrow),t.push(r),o.push(a),e.push(c),n.push(r),n.push(a),n.push(c);this._erasRegex=new RegExp("^("+n.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+t.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+o.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+e.join("|")+")","i")}ht(0,["gg",2],0,function(){return this.weekYear()%100}),ht(0,["GG",2],0,function(){return this.isoWeekYear()%100});function ei(o,t){ht(0,[o,o.length],0,t)}ei("gggg","weekYear"),ei("ggggg","weekYear"),ei("GGGG","isoWeekYear"),ei("GGGGG","isoWeekYear"),ct("G",Ao),ct("g",Ao),ct("GG",te,Pe),ct("gg",te,Pe),ct("GGGG",os,ns),ct("gggg",os,ns),ct("GGGGG",Ho,Qo),ct("ggggg",Ho,Qo),co(["gggg","ggggg","GGGG","GGGGG"],function(o,t,e,n){t[n.substr(0,2)]=Wt(o)}),co(["gg","GG"],function(o,t,e,n){t[n]=lt.parseTwoDigitYear(o)});function ng(o){return gl.call(this,o,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function og(o){return gl.call(this,o,this.isoWeek(),this.isoWeekday(),1,4)}function ig(){return on(this.year(),1,4)}function sg(){return on(this.isoWeekYear(),1,4)}function rg(){var o=this.localeData()._week;return on(this.year(),o.dow,o.doy)}function lg(){var o=this.localeData()._week;return on(this.weekYear(),o.dow,o.doy)}function gl(o,t,e,n,i){var l;return o==null?go(this,n,i).year:(l=on(o,n,i),t>l&&(t=l),ag.call(this,o,t,e,n,i))}function ag(o,t,e,n,i){var l=Br(o,t,e,n,i),r=ho(l.year,0,l.dayOfYear);return this.year(r.getUTCFullYear()),this.month(r.getUTCMonth()),this.date(r.getUTCDate()),this}ht("Q",0,"Qo","quarter"),ct("Q",Wr),kt("Q",function(o,t){t[en]=(Wt(o)-1)*3});function cg(o){return o==null?Math.ceil((this.month()+1)/3):this.month((o-1)*3+this.month()%3)}ht("D",["DD",2],"Do","date"),ct("D",te,Gn),ct("DD",te,Pe),ct("Do",function(o,t){return o?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),kt(["D","DD"],xe),kt("Do",function(o,t){t[xe]=Wt(o.match(te)[0])});var fl=xn("Date",!0);ht("DDD",["DDDD",3],"DDDo","dayOfYear"),ct("DDD",Ko),ct("DDDD",Yr),kt(["DDD","DDDD"],function(o,t,e){e._dayOfYear=Wt(o)});function dg(o){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return o==null?t:this.add(o-t,"d")}ht("m",["mm",2],0,"minute"),ct("m",te,is),ct("mm",te,Pe),kt(["m","mm"],Ye);var ug=xn("Minutes",!1);ht("s",["ss",2],0,"second"),ct("s",te,is),ct("ss",te,Pe),kt(["s","ss"],nn);var Rg=xn("Seconds",!1);ht("S",0,0,function(){return~~(this.millisecond()/100)}),ht(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),ht(0,["SSS",3],0,"millisecond"),ht(0,["SSSS",4],0,function(){return this.millisecond()*10}),ht(0,["SSSSS",5],0,function(){return this.millisecond()*100}),ht(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),ht(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),ht(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),ht(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),ct("S",Ko,Wr),ct("SS",Ko,Pe),ct("SSS",Ko,Yr);var mn,Tl;for(mn="SSSS";mn.length<=9;mn+="S")ct(mn,kn);function hg(o,t){t[Dn]=Wt(("0."+o)*1e3)}for(mn="S";mn.length<=9;mn+="S")kt(mn,hg);Tl=xn("Milliseconds",!1),ht("z",0,0,"zoneAbbr"),ht("zz",0,0,"zoneName");function gg(){return this._isUTC?"UTC":""}function fg(){return this._isUTC?"Coordinated Universal Time":""}var $=lo.prototype;$.add=lh,$.calendar=gh,$.clone=fh,$.diff=Lh,$.endOf=bh,$.format=Sh,$.from=Dh,$.fromNow=Fh,$.to=Xh,$.toNow=Nh,$.get=Ou,$.invalidAt=Kh,$.isAfter=Th,$.isBefore=mh,$.isBetween=Ch,$.isSame=ph,$.isSameOrAfter=Ih,$.isSameOrBefore=Eh,$.isValid=vh,$.lang=cl,$.locale=al,$.localeData=dl,$.max=vR,$.min=ZR,$.parsingFlags=Qh,$.set=Su,$.startOf=yh,$.subtract=ah,$.toArray=Uh,$.toObject=wh,$.toDate=Yh,$.toISOString=Mh,$.inspect=Oh,typeof Symbol<"u"&&Symbol.for!=null&&($[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),$.toJSON=Zh,$.toString=Ph,$.unix=Wh,$.valueOf=Vh,$.creationData=Hh,$.eraName=kh,$.eraNarrow=Gh,$.eraAbbr=xh,$.eraYear=Jh,$.year=Zr,$.isLeapYear=Mu,$.weekYear=ng,$.isoWeekYear=og,$.quarter=$.quarters=cg,$.month=Ar,$.daysInMonth=Yu,$.week=$.weeks=Au,$.isoWeek=$.isoWeeks=_u,$.weeksInYear=rg,$.weeksInWeekYear=lg,$.isoWeeksInYear=ig,$.isoWeeksInISOWeekYear=sg,$.date=fl,$.day=$.days=oR,$.weekday=iR,$.isoWeekday=sR,$.dayOfYear=dg,$.hour=$.hours=RR,$.minute=$.minutes=ug,$.second=$.seconds=Rg,$.millisecond=$.milliseconds=Tl,$.utcOffset=xR,$.utc=$R,$.local=zR,$.parseZone=jR,$.hasAlignedHourOffset=qR,$.isDST=th,$.isLocal=nh,$.isUtcOffset=oh,$.isUtc=ol,$.isUTC=ol,$.zoneAbbr=gg,$.zoneName=fg,$.dates=De("dates accessor is deprecated. Use date instead.",fl),$.months=De("months accessor is deprecated. Use month instead",Ar),$.years=De("years accessor is deprecated. Use year instead",Zr),$.zone=De("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",JR),$.isDSTShifted=De("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",eh);function Tg(o){return ee(o*1e3)}function mg(){return ee.apply(null,arguments).parseZone()}function ml(o){return o}var Ht=zi.prototype;Ht.calendar=nu,Ht.longDateFormat=ru,Ht.invalidDate=au,Ht.ordinal=uu,Ht.preparse=ml,Ht.postformat=ml,Ht.relativeTime=hu,Ht.pastFuture=gu,Ht.set=tu,Ht.eras=Ah,Ht.erasParse=_h,Ht.erasConvertYear=Bh,Ht.erasAbbrRegex=zh,Ht.erasNameRegex=$h,Ht.erasNarrowRegex=jh,Ht.months=yu,Ht.monthsShort=bu,Ht.monthsParse=Wu,Ht.monthsRegex=wu,Ht.monthsShortRegex=Uu,Ht.week=vu,Ht.firstDayOfYear=Hu,Ht.firstDayOfWeek=Ku,Ht.weekdays=ju,Ht.weekdaysMin=tR,Ht.weekdaysShort=qu,Ht.weekdaysParse=nR,Ht.weekdaysRegex=rR,Ht.weekdaysShortRegex=lR,Ht.weekdaysMinRegex=aR,Ht.isPM=dR,Ht.meridiem=hR;function ni(o,t,e,n){var i=sn(),l=Be().set(n,t);return i[e](l,o)}function Cl(o,t,e){if(qe(o)&&(t=o,o=void 0),o=o||"",t!=null)return ni(o,t,e,"month");var n,i=[];for(n=0;n<12;n++)i[n]=ni(o,n,e,"month");return i}function Es(o,t,e,n){typeof o=="boolean"?(qe(t)&&(e=t,t=void 0),t=t||""):(t=o,e=t,o=!1,qe(t)&&(e=t,t=void 0),t=t||"");var i=sn(),l=o?i._week.dow:0,r,a=[];if(e!=null)return ni(t,(e+l)%7,n,"day");for(r=0;r<7;r++)a[r]=ni(t,(r+l)%7,n,"day");return a}function Cg(o,t){return Cl(o,t,"months")}function pg(o,t){return Cl(o,t,"monthsShort")}function Ig(o,t,e){return Es(o,t,e,"weekdays")}function Eg(o,t,e){return Es(o,t,e,"weekdaysShort")}function Lg(o,t,e){return Es(o,t,e,"weekdaysMin")}Tn("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(o){var t=o%10,e=Wt(o%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return o+e}}),lt.lang=De("moment.lang is deprecated. Use moment.locale instead.",Tn),lt.langData=De("moment.langData is deprecated. Use moment.localeData instead.",sn);var rn=Math.abs;function Pg(){var o=this._data;return this._milliseconds=rn(this._milliseconds),this._days=rn(this._days),this._months=rn(this._months),o.milliseconds=rn(o.milliseconds),o.seconds=rn(o.seconds),o.minutes=rn(o.minutes),o.hours=rn(o.hours),o.months=rn(o.months),o.years=rn(o.years),this}function pl(o,t,e,n){var i=Ue(t,e);return o._milliseconds+=n*i._milliseconds,o._days+=n*i._days,o._months+=n*i._months,o._bubble()}function Mg(o,t){return pl(this,o,t,1)}function Og(o,t){return pl(this,o,t,-1)}function Il(o){return o<0?Math.floor(o):Math.ceil(o)}function Sg(){var o=this._milliseconds,t=this._days,e=this._months,n=this._data,i,l,r,a,c;return o>=0&&t>=0&&e>=0||o<=0&&t<=0&&e<=0||(o+=Il(Ls(e)+t)*864e5,t=0,e=0),n.milliseconds=o%1e3,i=Xe(o/1e3),n.seconds=i%60,l=Xe(i/60),n.minutes=l%60,r=Xe(l/60),n.hours=r%24,t+=Xe(r/24),c=Xe(El(t)),e+=c,t-=Il(Ls(c)),a=Xe(e/12),e%=12,n.days=t,n.months=e,n.years=a,this}function El(o){return o*4800/146097}function Ls(o){return o*146097/4800}function Dg(o){if(!this.isValid())return NaN;var t,e,n=this._milliseconds;if(o=Fe(o),o==="month"||o==="quarter"||o==="year")switch(t=this._days+n/864e5,e=this._months+El(t),o){case"month":return e;case"quarter":return e/3;case"year":return e/12}else switch(t=this._days+Math.round(Ls(this._months)),o){case"week":return t/7+n/6048e5;case"day":return t+n/864e5;case"hour":return t*24+n/36e5;case"minute":return t*1440+n/6e4;case"second":return t*86400+n/1e3;case"millisecond":return Math.floor(t*864e5)+n;default:throw new Error("Unknown unit "+o)}}function ln(o){return function(){return this.as(o)}}var Ll=ln("ms"),Fg=ln("s"),Xg=ln("m"),Ng=ln("h"),yg=ln("d"),bg=ln("w"),Vg=ln("M"),Wg=ln("Q"),Yg=ln("y"),Ug=Ll;function wg(){return Ue(this)}function Zg(o){return o=Fe(o),this.isValid()?this[o+"s"]():NaN}function Xn(o){return function(){return this.isValid()?this._data[o]:NaN}}var vg=Xn("milliseconds"),Qg=Xn("seconds"),Kg=Xn("minutes"),Hg=Xn("hours"),Ag=Xn("days"),_g=Xn("months"),Bg=Xn("years");function kg(){return Xe(this.days()/7)}var an=Math.round,jn={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Gg(o,t,e,n,i){return i.relativeTime(t||1,!!e,o,n)}function xg(o,t,e,n){var i=Ue(o).abs(),l=an(i.as("s")),r=an(i.as("m")),a=an(i.as("h")),c=an(i.as("d")),d=an(i.as("M")),u=an(i.as("w")),h=an(i.as("y")),R=l<=e.ss&&["s",l]||l<e.s&&["ss",l]||r<=1&&["m"]||r<e.m&&["mm",r]||a<=1&&["h"]||a<e.h&&["hh",a]||c<=1&&["d"]||c<e.d&&["dd",c];return e.w!=null&&(R=R||u<=1&&["w"]||u<e.w&&["ww",u]),R=R||d<=1&&["M"]||d<e.M&&["MM",d]||h<=1&&["y"]||["yy",h],R[2]=t,R[3]=+o>0,R[4]=n,Gg.apply(null,R)}function Jg(o){return o===void 0?an:typeof o=="function"?(an=o,!0):!1}function $g(o,t){return jn[o]===void 0?!1:t===void 0?jn[o]:(jn[o]=t,o==="s"&&(jn.ss=t-1),!0)}function zg(o,t){if(!this.isValid())return this.localeData().invalidDate();var e=!1,n=jn,i,l;return typeof o=="object"&&(t=o,o=!1),typeof o=="boolean"&&(e=o),typeof t=="object"&&(n=Object.assign({},jn,t),t.s!=null&&t.ss==null&&(n.ss=t.s-1)),i=this.localeData(),l=xg(this,!e,n,i),e&&(l=i.pastFuture(+this,l)),i.postformat(l)}var Ps=Math.abs;function qn(o){return(o>0)-(o<0)||+o}function oi(){if(!this.isValid())return this.localeData().invalidDate();var o=Ps(this._milliseconds)/1e3,t=Ps(this._days),e=Ps(this._months),n,i,l,r,a=this.asSeconds(),c,d,u,h;return a?(n=Xe(o/60),i=Xe(n/60),o%=60,n%=60,l=Xe(e/12),e%=12,r=o?o.toFixed(3).replace(/\.?0+$/,""):"",c=a<0?"-":"",d=qn(this._months)!==qn(a)?"-":"",u=qn(this._days)!==qn(a)?"-":"",h=qn(this._milliseconds)!==qn(a)?"-":"",c+"P"+(l?d+l+"Y":"")+(e?d+e+"M":"")+(t?u+t+"D":"")+(i||n||o?"T":"")+(i?h+i+"H":"")+(n?h+n+"M":"")+(o?h+r+"S":"")):"P0D"}var Ut=$o.prototype;Ut.isValid=_R,Ut.abs=Pg,Ut.add=Mg,Ut.subtract=Og,Ut.as=Dg,Ut.asMilliseconds=Ll,Ut.asSeconds=Fg,Ut.asMinutes=Xg,Ut.asHours=Ng,Ut.asDays=yg,Ut.asWeeks=bg,Ut.asMonths=Vg,Ut.asQuarters=Wg,Ut.asYears=Yg,Ut.valueOf=Ug,Ut._bubble=Sg,Ut.clone=wg,Ut.get=Zg,Ut.milliseconds=vg,Ut.seconds=Qg,Ut.minutes=Kg,Ut.hours=Hg,Ut.days=Ag,Ut.weeks=kg,Ut.months=_g,Ut.years=Bg,Ut.humanize=zg,Ut.toISOString=oi,Ut.toString=oi,Ut.toJSON=oi,Ut.locale=al,Ut.localeData=dl,Ut.toIsoString=De("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",oi),Ut.lang=cl,ht("X",0,0,"unix"),ht("x",0,0,"valueOf"),ct("x",Ao),ct("X",Cu),kt("X",function(o,t,e){e._d=new Date(parseFloat(o)*1e3)}),kt("x",function(o,t,e){e._d=new Date(Wt(o))});lt.version="2.30.1",jd(ee),lt.fn=$,lt.min=QR,lt.max=KR,lt.now=HR,lt.utc=Be,lt.unix=Tg,lt.months=Cg,lt.isDate=ro,lt.locale=Tn,lt.invalid=wo,lt.duration=Ue,lt.isMoment=We,lt.weekdays=Ig,lt.parseZone=mg,lt.localeData=sn,lt.isDuration=zo,lt.monthsShort=pg,lt.weekdaysMin=Lg,lt.defineLocale=ds,lt.updateLocale=mR,lt.locales=CR,lt.weekdaysShort=Eg,lt.normalizeUnits=Fe,lt.relativeTimeRounding=Jg,lt.relativeTimeThreshold=$g,lt.calendarFormat=hh,lt.prototype=$,lt.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};class Ms{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),l=t?null:i.getTd();n>=e.length&&(n=e.length-1);const r=e[n],a=[];let c=l,d=e,u=n;for(;;){if(u<0&&c?.linkTdPrevId){const T=i.getTdById(c.linkTdPrevId);if(T){d=T.value,u=d.length-1,c=T;continue}}if(u<0)break;const g=d[u];if(g.controlId!==r.controlId||g.controlComponent===s.ControlComponent.PREFIX||g.controlComponent===s.ControlComponent.PRE_TEXT)break;g.controlComponent===s.ControlComponent.VALUE&&a.unshift(g),u--}c=l;let h=e,R=n+1;for(;;){if(R>=h.length&&c?.linkTdNextId){const T=i.getTdById(c.linkTdNextId);if(T){h=T.value,R=0,c=T;continue}}const g=h[R];if(!g||g.controlId!==r.controlId||g.controlComponent===s.ControlComponent.POSTFIX||g.controlComponent===s.ControlComponent.POST_TEXT)break;g.controlComponent===s.ControlComponent.VALUE&&a.push(g),R++}return a.filter(g=>g.type!==s.ElementType.SPLIT_TAG)}removeNextControlElement(t,e){const n=this.control.getDraw();if(e=e??n.getTd()?.linkTdNextId,e){const i=n.getTdById(e);if(i){if(i.value.length){if(i.value[1].controlId===t)return n.spliceElementList(i.value,1,1),i.value[1]}else if(i.linkTdNextId)return this.removeNextControlElement(t,i.linkTdNextId)}}}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const i=e.range||this.control.getRange(),l=e.elementList||this.control.getElementList(),r=l[i.startIndex],a=l[i.startIndex+1],c=b=>!!(b&&(b.controlComponent===s.ControlComponent.POSTFIX||b.controlComponent===s.ControlComponent.POST_TEXT||b.controlComponent===s.ControlComponent.POSTTEXTFIX||b.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)),d=!!(r?.originControlId&&c(r)&&a?.controlId===r.originControlId&&!a.originControlId&&a.control?.type===s.ControlType.TEXTFIELD&&c(a));let u=this.element.controlId||r?.controlId,h=this.element.originControlId||(this.element.controlId===r?.controlId?r?.originControlId:void 0),R=this.element.control||r.control;const f=!!(r?.controlId&&r.controlId!==this.element.controlId&&!r.originControlId&&r.control?.type===s.ControlType.TEXTFIELD);d?(u=r.originControlId,h=void 0,R=a.control):f&&(u=r.controlId,h=void 0,R=r.control);const g=!!u&&r?.controlId!==u&&this._findNearestTextAncestorId(l,r?.originControlId)===u;!g&&!d&&!f&&(this.control.mergeControl(e),this.control.shrinkBoundary(e));const{startIndex:T,endIndex:C}=i,p=this.control.getDraw();T!==C?p.spliceElementList(l,T+1,C-T,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):g||d||f?this._removePlaceholdersByControl(l,u,h||null):this.control.removePlaceholder(T,{elementList:l});const I=l[T];g||d||f?this._removePlaceholdersByControl(l,u,h||null):this._removeControlPlaceholders(l,T);const m=I.type&&!Le.includes(I.type)||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRE_TEXT?xt(I,["control","controlId","originControlId",...Re]):Ee(I,["type"]),L=g||d||f,P=b=>{Re.forEach(S=>{delete b[S];const y=R?.[S];y!==void 0&&(b[S]=y)}),delete b.underline,delete b.textDecoration,R?.type===s.ControlType.TEXT&&b.color?.toLowerCase()==="#87d068"?b.color=this.options.defaultColor:b.color||(b.color=this.options.defaultColor)};L&&P(m),m.controlId=u,R&&(m.control=R),h?m.originControlId=h:delete m.originControlId;const M=this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.inputTraceEnabled,F=i.startIndex+1,N=[],Y=b=>{const S=N.length?N:l,y=N.length?N.length-1:d?i.startIndex+1:i.startIndex;se(S,[b],y,{editorOptions:this.options}),N.push(b)};for(let b=0;b<t.length;b++){const S=t[b];if(S.type===s.ElementType.CONTROL&&S.control){const y=S,V=y.controlId||mt(),X=y.control?.value||[],O=y.control?.type,E=O===s.ControlType.TEXTFIELD,W=E?this.options.control.textFixColor:O===s.ControlType.TEXT||O===s.ControlType.NUMBER?"#87d068":this.options.control.bracketColor,U={...Ee(m,["underline","textDecoration"]),controlId:V,type:s.ElementType.CONTROL,control:y.control,originControlId:u},Z=E?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,Q=E?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,v=E?y.control?.preTextFix||this.options.control.preTextFix:y.control?.prefix||this.options.control.prefix;for(let B=0;B<v.length;B++){const H={...U,color:W,value:v[B],controlComponent:Z};Y(H)}for(let B=0;B<X.length;B++){const H=X[B],k={...U,...H,controlComponent:s.ControlComponent.VALUE};(k.color===this.options.control.bracketColor||k.color===this.options.control.placeholderColor)&&(k.color=this.options.defaultColor),Y(k)}if(X.length===0){const B=y.control?.placeholder||"";for(let H=0;H<B.length;H++){const k={...U,value:B[H],controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};Y(k)}}const st=E?y.control?.postTextFix||this.options.control.postTextFix:y.control?.postfix||this.options.control.postfix;for(let B=0;B<st.length;B++){const H={...U,color:W,value:st[B],controlComponent:Q};Y(H)}}else if(S.type||S.value){(I.controlComponent===s.ControlComponent.PRE_TEXT||I.controlComponent===s.ControlComponent.POST_TEXT||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.POSTFIX)&&(m.color=this.options.defaultColor);const V=Ee(S,["control","controlId","controlComponent","originControlId"]),X={...m,...V,controlComponent:s.ControlComponent.VALUE};L&&P(X),(X.color===this.options.control.bracketColor||X.color===this.options.control.placeholderColor||X.color===this.options.control.textFixColor)&&(X.color=this.options.defaultColor),X.strikeout&&delete X.strikeout,M&&(X.textDecoration={style:s.TextDecorationStyle.DOUBLE},X.underline=!0),Y(X)}}return N.length&&p.spliceElementList(l,F,0,N),i.startIndex+N.length}_removeControlPlaceholders(t,e){const n=t[e];if(!n?.controlId)return;const i=a=>!!a&&a.controlId===n.controlId&&a.originControlId===n.originControlId;let l=e;for(;l>=0&&i(t[l]);)l--;let r=e+1;for(;r<t.length&&i(t[r]);)r++;for(let a=r-1;a>l;a--)t[a].controlComponent===s.ControlComponent.PLACEHOLDER&&t.splice(a,1)}_removePlaceholdersByControl(t,e,n){if(e)for(let i=t.length-1;i>=0;i--){const l=t[i];l.controlId===e&&(l.originControlId||null)===n&&l.controlComponent===s.ControlComponent.PLACEHOLDER&&t.splice(i,1)}}_findNearestTextAncestorId(t,e){if(!e)return null;const n=new Set;let i=e,l=null;for(;i&&!n.has(i);){n.add(i);let r;for(let a=0;a<t.length;a++){const c=t[a];if(c.controlId===i&&c.control?.type&&(r=c,c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRE_TEXT||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!r)break;(r.control?.type===s.ControlType.TEXT||this.options.mode===s.EditorMode.EDIT&&r.control?.type===s.ControlType.TEXTFIELD)&&(l=i),i=r.originControlId||null}return l}clearValue(t={},e={}){if(!e.isIgnoreDisabledRule&&this.control.getIsDisabledControl(t))return-1;const n=t.elementList||this.control.getElementList(),i=t.range||this.control.getValueRange()||this.control.getRange();this.control.shrinkBoundary(t);const{startIndex:l,endIndex:r}=i;return this.control.getDraw().spliceElementList(n,l+1,r-l,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),e.isAddPlaceholder!==!1&&(this.getValue(t).length||this.control.addPlaceholder(l,t)),l}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.control.getDraw(),d=this.options.mode===s.EditorMode.FORM,u=this.element.controlId||r.controlId,h=this.element.originControlId||r.originControlId||null,R=E=>{if(!E)return null;const W=new Set;let D=E,U=null;for(;D&&!W.has(D);){W.add(D);let Z;for(let Q=0;Q<e.length;Q++){const v=e[Q];if(v.controlId===D&&v.control?.type&&(Z=v,v.controlComponent===s.ControlComponent.PREFIX||v.controlComponent===s.ControlComponent.PRE_TEXT||v.controlComponent===s.ControlComponent.PRETEXTFIX||v.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!Z)break;(Z.control?.type===s.ControlType.TEXT||this.options.mode===s.EditorMode.EDIT&&Z.control?.type===s.ControlType.TEXTFIELD)&&(U=D),D=Z.originControlId||null}return U},f=R(h),g=!!f,T=r.controlId===u&&(r.originControlId||null)===h,C=r.controlComponent===s.ControlComponent.VALUE,p=E=>{for(let W=i-1;W>=0;W--){const D=e[W];if(D.controlId===E&&!D.originControlId){if(D.controlComponent===s.ControlComponent.VALUE||D.controlComponent===s.ControlComponent.PLACEHOLDER)return W;if(D.controlComponent===s.ControlComponent.PREFIX||D.controlComponent===s.ControlComponent.PRE_TEXT||D.controlComponent===s.ControlComponent.PRETEXTFIX||D.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)break}if(D.controlId&&D.controlId!==E&&D.originControlId!==E)break}return-1},I=(E,W)=>{for(let D=E;D>=0;D--){const U=e[D];if(U.controlId===W&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.PREFIX||U.controlComponent===s.ControlComponent.PRE_TEXT||U.controlComponent===s.ControlComponent.PRETEXTFIX||U.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))return D;if(U.controlId&&U.controlId!==W&&U.originControlId!==W)break}for(let D=E+1;D<e.length;D++){const U=e[D];if(U.controlId===W&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.POSTFIX||U.controlComponent===s.ControlComponent.POST_TEXT||U.controlComponent===s.ControlComponent.POSTTEXTFIX||U.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return D;if(U.controlId&&U.controlId!==W&&U.originControlId!==W)break}return E},L=g&&T&&(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PRETEXTFIX||r.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.TEXTFIXLABEL),P=e[l+1],M=!!P?.originControlId&&!!P?.controlId&&P.originControlId!==P.controlId&&(P.controlComponent===s.ControlComponent.PREFIX||P.controlComponent===s.ControlComponent.PRE_TEXT||P.controlComponent===s.ControlComponent.PRETEXTFIX||P.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===s.ControlComponent.PLACEHOLDER||P.controlComponent===s.ControlComponent.TEXTFIXLABEL),F=!!P?.originControlId&&!!P?.controlId&&P.originControlId!==P.controlId&&(P.controlComponent===s.ControlComponent.PREFIX||P.controlComponent===s.ControlComponent.PRE_TEXT||P.controlComponent===s.ControlComponent.PRETEXTFIX||P.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===s.ControlComponent.POSTFIX||P.controlComponent===s.ControlComponent.POST_TEXT||P.controlComponent===s.ControlComponent.POSTTEXTFIX||P.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||P.controlComponent===s.ControlComponent.PLACEHOLDER||P.controlComponent===s.ControlComponent.TEXTFIXLABEL),N=E=>this.options.mode===s.EditorMode.FORM?i:this.control.removeControl(E),Y=r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId&&!!P?.originControlId&&!!u&&R(P.originControlId)===u,b=E=>!!E&&E.controlId===r.controlId&&(E.originControlId||null)===(r.originControlId||null),S=E=>E?.controlComponent===s.ControlComponent.POSTFIX||E?.controlComponent===s.ControlComponent.POST_TEXT||E?.controlComponent===s.ControlComponent.POSTTEXTFIX||E?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT,y=()=>{const E=r.controlId,W=r.originControlId||null;return c.spliceElementList(e,i,1),e.some(U=>U.controlId===E&&(U.originControlId||null)===W&&U.controlComponent===s.ControlComponent.VALUE)||this.control.addPlaceholder(i-1),Math.max(i-1,0)},V=r.controlComponent===s.ControlComponent.VALUE&&!!r.originControlId&&b(P)&&S(P),X=!!u&&!this.control.getIsExistValueByElementListIndex(e,i),O=()=>{if(r.controlComponent!==s.ControlComponent.VALUE)return null;let E=i;for(let U=i;U>=0;U--){const Z=e[U];if(!(Z.controlId===r.controlId&&(Z.originControlId||null)===(r.originControlId||null))||Z.controlComponent!==s.ControlComponent.VALUE)break;if(!Z.strikeout){E=U;break}}const W=e[E];if(!W||W.strikeout)return null;W.strikeout=!0,W.deletePerson="SWJ",W.deleteTime=lt(new Date).format("YYYY-MM-DD HH:mm:ss");let D=Math.max(E-1,0);for(let U=E-1;U>=0;U--){const Z=e[U];if(!(Z.controlId===W.controlId&&(Z.originControlId||null)===(W.originControlId||null))){D=U;break}if(Z.controlComponent!==s.ControlComponent.VALUE){D=U;break}if(!Z.strikeout){D=U;break}D=Math.max(U-1,0)}return this.draws.render({curIndex:D,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),queueMicrotask(()=>{this.ranges.setRange(D,D),this.draws.setCursor(D)}),D};if(t.key===s.KeyMap.Backspace){if(i===l&&X&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return i;if(d&&i===l&&f&&!T&&(r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)){const W=p(f);return W>=0?W:i}if(i===l&&L&&!(d&&r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId))return N(i);if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!g||C)){if(i===l&&r.controlComponent===s.ControlComponent.VALUE){const W=O();if(W!==null)return W}return r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?i:this.strikeout()}else{if(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER)return i;if(i!==l){c.spliceElementList(e,i+1,l-i);const W=e[i+1];return(W?.controlComponent===s.ControlComponent.POSTFIX||W?.controlComponent===s.ControlComponent.POST_TEXT||W?.controlComponent===s.ControlComponent.POSTTEXTFIX||W?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(i),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i}else{const W=e[i-1],D=e[i+1];return!r.originControlId&&W?.controlId===r.controlId&&W?.originControlId===r.originControlId&&W?.controlComponent===s.ControlComponent.VALUE&&(r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.options.mode!==s.EditorMode.FORM?(c.spliceElementList(e,i-1,1),this.getValue().length||this.control.addPlaceholder(i-2),i-2):S(D)?D.originControlId?V?y():Y?(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):N(i):(c.spliceElementList(e,i,1),this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):(c.spliceElementList(e,i,1),i===1&&e[0].type===s.ElementType.SPLIT_TAG||i===0?c.fixPosition(!0)??i-1:I(Math.max(i-1,0),r.controlId))}}}else if(t.key===s.KeyMap.Delete){if(i===l&&X&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return l;if(i===l&&(M||F)){if(Y){const U=e[l+1];if(U?.controlComponent===s.ControlComponent.VALUE&&U.controlId===r.controlId&&!U.originControlId)return c.spliceElementList(e,l+1,1),this.getValue().length||this.control.addPlaceholder(i),i}return N(l+1)}const E=e[l+1],W=!!r.originControlId;if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!W||r.controlComponent===s.ControlComponent.VALUE))return a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||a.controlComponent===s.ControlComponent.POSTTEXTFIX||a.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?l:E?.controlComponent===s.ControlComponent.POSTFIX||E?.controlComponent===s.ControlComponent.POST_TEXT||E?.controlComponent===s.ControlComponent.POSTTEXTFIX||E?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?E.originControlId?Y?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):N(i+1):(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):this.strikeout();{const U=e[l+1];return r.controlComponent===s.ControlComponent.PLACEHOLDER?l:U?.controlComponent===s.ControlComponent.POSTFIX||U?.controlComponent===s.ControlComponent.POST_TEXT||U?.controlComponent===s.ControlComponent.POSTTEXTFIX||U?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?U.originControlId?Y?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):N(i+1):(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):i!==l?(c.spliceElementList(e,i+1,l-i),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):U?(c.spliceElementList(e,i+1,1),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i):(c.getTd()?.linkTdNextId&&r.controlId&&this.removeNextControlElement(r.controlId),l)}}return l}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();n.spliceElementList(i,t+1,e-t);const l=i[t+1];return(l?.controlComponent===s.ControlComponent.POSTFIX||l?.controlComponent===s.ControlComponent.POST_TEXT||l?.controlComponent===s.ControlComponent.POSTTEXTFIX||l?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(t),t}strikeout(t){const e=this.control.getRange(),{endIndex:n}=e,{isIgnoreDisabledRule:i=!1}=t||{};if(!i&&(this.draws.isReadonly()||this.draws.isDisabled()))return null;const r=this.ranges.getSelectionElementList(),a=this.position.getCursorPosition(),c=lt(new Date).format("YYYY-MM-DD HH:mm:ss"),d=R=>{queueMicrotask(()=>{this.ranges.setRange(R,R),this.draws.setCursor(R)})},u=R=>{const f=this.control.getElementList(),g=f[R],T=g?.controlId,C=g?.originControlId||null;let p=-1;for(let I=R-1;I>=0;I--){const m=f[I];if(m.controlId===T&&(m.originControlId||null)===C&&m.controlComponent===s.ControlComponent.VALUE)return I;if(C){if(m.controlId&&m.controlId!==T&&m.originControlId!==C)break}else{if(m.controlId===T&&(m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRE_TEXT||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){p=I;break}if(m.controlId&&m.controlId!==T&&!m.originControlId)break;if(m.originControlId===T&&(m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POST_TEXT||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return I}}if(p>=0){const I=p+1,m=f[I];return m?.controlId===T&&(m.controlComponent===s.ControlComponent.PLACEHOLDER||m.controlComponent===s.ControlComponent.VALUE)?I:p}return R},h=R=>{const f=this.control.getElementList(),g=f[R];if(!g?.controlId||g.controlComponent===s.ControlComponent.VALUE&&(g.metrics?.width??0)>0)return R;for(let T=R+1;T<f.length;T++){const C=f[T];if(C.controlId!==g.controlId||(C.originControlId||null)!==(g.originControlId||null))break;if(C.controlComponent===s.ControlComponent.VALUE&&(C.metrics?.width??0)>0)return T}for(let T=R-1;T>=0;T--){const C=f[T];if(C.controlId!==g.controlId||(C.originControlId||null)!==(g.originControlId||null))break;if(C.controlComponent===s.ControlComponent.VALUE&&(C.metrics?.width??0)>0)return T}return R};if(r?.length){if(!this.element.strikeout){const R=r.findIndex(f=>!f.strikeout);return r.forEach(f=>{f.deletePerson="SWJ",f.deleteTime=c,f.strikeout=!!~R}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),this.control.getRange().endIndex??null}}else{const R=h(a.index),f=this.control.getElementList()[R],g=this.control.getElementList();if(!this.control.getElementList()[R].strikeout&&f?.metrics.width>0){this.control.getElementList()[R].strikeout=!0,this.control.getElementList()[R].deletePerson="SWJ",this.control.getElementList()[R].deleteTime=c;const T=u(R);return this.ranges.setRange(T,T),this.draws.render({curIndex:T,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),d(T),T??null}else if(n>=0&&n<g.length&&g[n]?.metrics?.width!==void 0&&g[n].metrics.width<=0&&!g[n]?.strikeout){g.splice(n,1);const T=n-1;return this.ranges.setRange(T,T),this.draws.render({curIndex:T,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),d(T),T??null}}return n??null}strikeoute(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draws.isReadonly()||this.draws.isDisabled()))return;if(!this.ranges.getSelectionElementList()?.length){const{endIndex:l}=this.ranges.getRange(),a=this.draws.getElementList()[l];this.ranges.setDefaultStyle({strikeout:a.strikeout?!1:!this.ranges.getDefaultStyle()?.strikeout})}}}class Pl{draw;options;now;dom;renderOptions;isDatePicker;pickDate;lang;constructor(t,e={}){this.draw=t,this.options=e,this.lang=this._getLang(),this.now=new Date,this.dom=this._createDom(),this.renderOptions=null,this.isDatePicker=!0,this.pickDate=null,this._bindEvent()}_createDom(){const t=document.createElement("div");t.classList.add(`${rt}-date-container`),t.setAttribute(Ze,s.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${rt}-date-wrap`);const n=document.createElement("div");n.classList.add(`${rt}-date-title`);const i=document.createElement("span");i.classList.add(`${rt}-date-title__pre-year`),i.innerText="<<";const l=document.createElement("span");l.classList.add(`${rt}-date-title__pre-month`),l.innerText="<";const r=document.createElement("span");r.classList.add(`${rt}-date-title__now`);const a=document.createElement("span");a.classList.add(`${rt}-date-title__next-month`),a.innerText=">";const c=document.createElement("span");c.classList.add(`${rt}-date-title__next-year`),c.innerText=">>",n.append(i),n.append(l),n.append(r),n.append(a),n.append(c);const d=document.createElement("div");d.classList.add(`${rt}-date-week`);const{weeks:{sun:u,mon:h,tue:R,wed:f,thu:g,fri:T,sat:C}}=this.lang;[u,h,R,f,g,T,C].forEach(y=>{const V=document.createElement("span");V.innerText=`${y}`,d.append(V)});const I=document.createElement("div");I.classList.add(`${rt}-date-day`),e.append(n),e.append(d),e.append(I);const m=document.createElement("ul");m.classList.add(`${rt}-time-wrap`);let L,P,M;[this.lang.hour,this.lang.minute,this.lang.second].forEach((y,V)=>{const X=document.createElement("li"),O=document.createElement("span");O.innerText=y,X.append(O);const E=document.createElement("ol"),W=V===0,D=V===1,U=W?24:60;for(let Z=0;Z<U;Z++){const Q=document.createElement("li");Q.innerText=`${String(Z).padStart(2,"0")}`,Q.setAttribute("data-id",`${Z}`),E.append(Q)}W?L=E:D?P=E:M=E,X.append(E),m.append(X)});const N=document.createElement("div");N.classList.add(`${rt}-date-menu`);const Y=document.createElement("button");Y.classList.add(`${rt}-date-menu__time`),Y.innerText=this.lang.timeSelect;const b=document.createElement("button");b.classList.add(`${rt}-date-menu__now`),b.innerText=this.lang.now;const S=document.createElement("button");return S.classList.add(`${rt}-date-menu__submit`),S.innerText=this.lang.confirm,N.append(Y),N.append(b),N.append(S),t.append(e),t.append(m),t.append(N),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:d,timeWrap:m,title:{preYear:i,preMonth:l,now:r,nextMonth:a,nextYear:c},day:I,time:{hour:L,minute:P,second:M},menu:{time:Y,now:b,submit:S}}}_bindEvent(){this.dom.title.preYear.onclick=()=>{this._preYear()},this.dom.title.preMonth.onclick=()=>{this._preMonth()},this.dom.title.nextMonth.onclick=()=>{this._nextMonth()},this.dom.title.nextYear.onclick=()=>{this._nextYear()},this.dom.menu.time.onclick=()=>{this.isDatePicker=!this.isDatePicker,this._toggleDateTimePicker()},this.dom.menu.now.onclick=()=>{this._now(),this._submit()},this.dom.menu.submit.onclick=()=>{this.dispose(),this._submit()},this.dom.time.hour.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setHours(Number(n)),this._setTimePick(!1))},this.dom.time.minute.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setMinutes(Number(n)),this._setTimePick(!1))},this.dom.time.second.onclick=t=>{if(!this.pickDate)return;const n=t.target.dataset.id;n&&(this.pickDate.setSeconds(Number(n)),this._setTimePick(!1))}}_setPosition(){if(!this.renderOptions)return;const{position:{coordinate:{leftTop:[t,e]},lineHeight:n,pageNo:i}}=this.renderOptions,l=this.draw.getHeight(),r=this.draw.getPageGap(),c=(i??this.draw.getPageNo())*(l+r);this.dom.container.style.left=`${t}px`,this.dom.container.style.top=`${e+c+n}px`}isInvalidDate(t){return t.toDateString()==="Invalid Date"}_setValue(){const t=this.renderOptions?.value;if(t){const e=new Date(t);this.now=this.isInvalidDate(e)?new Date:e}else this.now=new Date;this.pickDate=new Date(this.now)}_getLang(){const t=this.draw.getI18n(),e=t.t.bind(t);return{now:e("datePicker.now"),confirm:e("datePicker.confirm"),return:e("datePicker.return"),timeSelect:e("datePicker.timeSelect"),weeks:{sun:e("datePicker.weeks.sun"),mon:e("datePicker.weeks.mon"),tue:e("datePicker.weeks.tue"),wed:e("datePicker.weeks.wed"),thu:e("datePicker.weeks.thu"),fri:e("datePicker.weeks.fri"),sat:e("datePicker.weeks.sat")},year:e("datePicker.year"),month:e("datePicker.month"),hour:e("datePicker.hour"),minute:e("datePicker.minute"),second:e("datePicker.second")}}_setLangChange(){this.dom.menu.time.innerText=this.lang.timeSelect,this.dom.menu.now.innerText=this.lang.now,this.dom.menu.submit.innerText=this.lang.confirm;const{weeks:{sun:t,mon:e,tue:n,wed:i,thu:l,fri:r,sat:a}}=this.lang,c=[t,e,n,i,l,r,a];this.dom.datePickerWeek.childNodes.forEach((R,f)=>{const g=R;g.innerText=c[f]});const d=this.dom.time.hour.previousElementSibling;d.innerText=this.lang.hour;const u=this.dom.time.minute.previousElementSibling;u.innerText=this.lang.minute;const h=this.dom.time.second.previousElementSibling;h.innerText=this.lang.second}_update(){const t=new Date,e=t.getFullYear(),n=t.getMonth()+1,i=t.getDate();let l=null,r=null,a=null;this.pickDate&&(l=this.pickDate.getFullYear(),r=this.pickDate.getMonth()+1,a=this.pickDate.getDate());const c=this.now.getFullYear(),d=this.now.getMonth()+1;this.dom.title.now.innerText=`${c}${this.lang.year} ${String(d).padStart(2,"0")}${this.lang.month}`;const h=new Date(c,d,0).getDate();let R=new Date(c,d-1,1).getDay();R===0&&(R=7);const f=new Date(c,d-1,0).getDate();this.dom.day.innerHTML="";const g=f-R+1;for(let C=g;C<=f;C++){const p=document.createElement("div");p.classList.add("disable"),p.innerText=`${C}`,p.onclick=()=>{const I=d-2;this.now=new Date(c,I,C),this._setDatePick(c,I,C)},this.dom.day.append(p)}for(let C=1;C<=h;C++){const p=document.createElement("div");e===c&&n===d&&i===C&&p.classList.add("active"),this.pickDate&&l===c&&r===d&&a===C&&p.classList.add("select"),p.innerText=`${C}`,p.onclick=I=>{const m=d-1;this.now=new Date(c,m,C),this._setDatePick(c,m,C),I.stopPropagation()},this.dom.day.append(p)}const T=42-R-h;for(let C=1;C<=T;C++){const p=document.createElement("div");p.classList.add("disable"),p.innerText=`${C}`,p.onclick=()=>{this.now=new Date(c,d,C),this._setDatePick(c,d,C)},this.dom.day.append(p)}}_toggleDateTimePicker(){this.isDatePicker?(this.dom.dateWrap.classList.add("active"),this.dom.timeWrap.classList.remove("active"),this.dom.menu.time.innerText=this.lang.timeSelect):(this.dom.dateWrap.classList.remove("active"),this.dom.timeWrap.classList.add("active"),this.dom.menu.time.innerText=this.lang.return,this._setTimePick())}_setDatePick(t,e,n){this.now=new Date(t,e,n),this.pickDate?.setFullYear(t),this.pickDate?.setMonth(e),this.pickDate?.setDate(n),this._update()}_setTimePick(t=!0){const e=this.pickDate?.getHours()||0,n=this.pickDate?.getMinutes()||0,i=this.pickDate?.getSeconds()||0,{hour:l,minute:r,second:a}=this.dom.time;[l,r,a].forEach(u=>{u.querySelectorAll("li").forEach(h=>h.classList.remove("active"))}),[[l,e],[r,n],[a,i]].forEach(([u,h])=>{const R=u.querySelector(`[data-id='${h}']`);R.classList.add("active"),t&&vs(u,R)})}_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(){if(this.options.onSubmit&&this.pickDate){const t=this.renderOptions?.dateFormat,e=this.formatDate(this.pickDate,t);this.options.onSubmit(e)}}formatDate(t,e="YYYY-MM-DD HH:mm:ss"){let n=e;const i=t.getFullYear().toString(),l=(t.getMonth()+1).toString(),r=t.getDate().toString(),a=t.getHours(),c=a%12===0?12:a%12,d=t.getMinutes().toString(),u=t.getSeconds().toString(),h=t.getMilliseconds().toString(),R={"y+":i,"Y+":i,"M+":l,"d+":r,"D+":r,"h+":c.toString(),"H+":a.toString(),"m+":d,"s+":u,"S+":h};for(const f in R){const g=new RegExp("("+f+")").exec(e),T=f;g&&(n=n.replace(g[1],g[1].length===1?R[T]:R[T].padStart(g[1].length,"0")))}return n}render(t){this.renderOptions=t,this.lang=this._getLang(),this._setLangChange(),this._setValue(),this._update(),this._setPosition(),this.isDatePicker=!0,this._toggleDateTimePicker(),this._toggleVisible(!0)}dispose(){this._toggleVisible(!1)}destroy(){this.dom.container.remove()}}class Co{draw;element;control;isPopup;datePicker;options;constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:l,endIndex:r}=n;for(let a=l;a<=r;a++){const c=e[a];c.controlComponent===s.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e);this.control.shrinkBoundary(e);const{startIndex:r,endIndex:a}=l,c=this.control.getDraw();r!==a?c.spliceElementList(i,r+1,a-r):this.control.removePlaceholder(r,{elementList:i});const d=i[r],u=d.type&&!Le.includes(d.type)||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT?xt(d,["control","controlId",...Re]):Ee(d,["type"]),h=l.startIndex+1;for(let R=0;R<t.length;R++){const f={...u,...t[R],controlComponent:s.ControlComponent.VALUE};se(i,[f],r,{editorOptions:this.options}),c.spliceElementList(i,h+R,0,[f])}return h+t.length-1}clearSelect(t={},e={}){const{isIgnoreDisabledRule:n=!1,isAddPlaceholder:i=!0}=e;if(!n&&this.control.getIsDisabledControl(t))return-1;const l=this.control.getValueRange(t);if(!l)return-1;const{startIndex:r,endIndex:a}=l;if(!~r||!~a)return-1;const c=t.elementList||this.control.getElementList();return this.control.getDraw().spliceElementList(c,r+1,a-r,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule}),i&&this.control.addPlaceholder(r,t),r}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),r=this.getValue(e)[0],a=r?xt(r,Ne):xt(i[l.startIndex],Re),c=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~c)return;const d=Ee(i[c],Ne),u=c+1,h=this.control.getDraw();for(let R=0;R<t.length;R++){const f={...a,...d,type:s.ElementType.TEXT,value:t[R],controlComponent:s.ControlComponent.VALUE};(f.color===this.options.control.bracketColor||f.color===this.options.control.placeholderColor)&&(f.color=this.options.defaultColor),se(i,[f],c,{editorOptions:this.options}),h.spliceElementList(i,u+R,0,[f])}if(!e.range){const R=u+t.length-1;this.control.repaintControl({curIndex:R}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.control.getDraw();if(t.key===s.KeyMap.Backspace)return i!==l?(c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key===s.KeyMap.Delete){if(i!==l)return c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i;{const d=e[l+1];return(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT)&&d.controlComponent===s.ControlComponent.PLACEHOLDER||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?this.control.removeControl(i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}}return l}cut(){if(this.control.getIsDisabledControl())return-1;this.control.shrinkBoundary();const{startIndex:t,endIndex:e}=this.control.getRange();if(t===e)return t;const n=this.control.getDraw(),i=this.control.getElementList();return n.spliceElementList(i,t+1,e-t),this.getValue().length||this.control.addPlaceholder(t),t}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getPosition();if(!t)return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(e[n+1]?.controlId!==this.element.controlId)return;this.datePicker=new Pl(this.draw,{onSubmit:this._setDate.bind(this)});const i=this.getValue().map(r=>r.value).join("")||"",l=this.element.control?.dateFormat;this.datePicker.render({value:i,position:t,dateFormat:l}),this.isPopup=!0}destroy(){this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}_setDate(t){t?this.setSelect(t):this.clearSelect(),this.destroy()}}class ii extends Ms{isPopup;inputPopup;constructor(t,e){super(t,e),this.isPopup=!1,this.inputPopup=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(I=>!Pc(I)))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange();this.control.shrinkBoundary(e);const r=at(t),{startIndex:a,endIndex:c}=l,d=i[a];let u=null;for(let I=a;I>=0;I--)if(i[I].controlComponent===s.ControlComponent.PREFIX){u=i[I];break}const h=u?.control||this.element.control;if(this.control.getIsExistValueByElementListIndex(i,a)){let I=a;for(;I>0;){const L=i[I];if(L.controlId!==d.controlId||L.controlComponent===s.ControlComponent.PREFIX||L.controlComponent===s.ControlComponent.PRE_TEXT)break;r.unshift(L),I--}let m=c+1;for(;m<i.length;){const L=i[m];if(L.controlId!==d.controlId||L.controlComponent===s.ControlComponent.POSTFIX||L.controlComponent===s.ControlComponent.POST_TEXT)break;r.push(L),m++}}const R=or(r);if(!/^[+-]?(?:\d+)?(?:\.\d*)?(?:[eE][+-]?\d*)?$/.test(R))return-1;const g=h?.numberExclusiveOptions,T=g?.maxLength??null,C=g?.decimalPlaces??null,p=R.replace(/[+\-.eE]/g,"").length;if(T!=null&&p>T||C!=null&&(R.split(/[eE]/)[0].split(".")[1]||"").length>C)return-1;if(e.range||e.elementList){const I=Number(R),m=g?.minValue,L=g?.maxValue;if(!Number.isFinite(I)||m!=null&&I<m||L!=null&&I>L)return-1}return super.setValue(t,e,n)}_setNumberValue(t){const e=this.control.getElementList(),n=this.control.getRange(),{startIndex:i}=n;let l=null;for(let F=i;F>=0;F--)if(e[F].controlComponent===s.ControlComponent.PREFIX){l=e[F];break}const a=(l?.control||this.element.control)?.numberExclusiveOptions,c=a?.minValue,d=a?.maxValue,u=a?.minLength,h=a?.maxLength,R=t.trim(),f=R.replace(/[+\-.eE]/g,"").length,g=Number(R);if(u!=null&&f<u||h!=null&&f>h||c!=null&&g<c||d!=null&&g>d)return!1;let T=i;for(let F=i;F>=0;F--)if(e[F].controlComponent===s.ControlComponent.PREFIX){T=F;break}let C=T+1;for(let F=T+1;F<e.length;F++)if(e[F].controlComponent===s.ControlComponent.POSTFIX){C=F;break}const p=this.options.mode===s.EditorMode.FORM,I=p&&this.options.modeRule.form.inputTraceEnabled,m=p&&this.options.modeRule.form.deleteTraceEnabled,L=lt(new Date).format("YYYY-MM-DD HH:mm:ss");if(m)for(let F=T+1;F<C;F++){const N=e[F];N.controlComponent===s.ControlComponent.VALUE&&!N.strikeout&&N.value&&(N.strikeout=!0,N.deletePerson="SYSTEM",N.deleteTime=L),N.controlComponent===s.ControlComponent.PLACEHOLDER&&(this.control.getDraw().spliceElementList(e,F,1),C--,F--)}else{const F=T+1,N=C-F;N>0&&this.control.getDraw().spliceElementList(e,F,N),C=T+1}C=T+1;for(let F=T+1;F<e.length;F++)if(e[F].controlComponent===s.ControlComponent.POSTFIX){C=F;break}const P=[];for(let F=0;F<R.length;F++){const N={type:s.ElementType.TEXT,value:R[F],controlComponent:s.ControlComponent.VALUE,controlId:e[T].controlId,originControlId:e[T].originControlId,control:e[T].control};I&&(N.textDecoration={style:s.TextDecorationStyle.DOUBLE},N.underline=!0),P.push(N)}for(let F=0;F<P.length;F++)this.control.getDraw().spliceElementList(e,C+F,0,[P[F]]);const M=C+P.length-1;return this.control.getDraw().getRange().setRange(M,M),this.control.emitControlContentChange(),this.control.repaintControl({curIndex:M}),!0}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e,i=t[n];if(!i||i.controlId!==this.element.controlId)return;let l=null;for(let g=n;g>=0;g--)if(t[g].controlComponent===s.ControlComponent.PREFIX){l=t[g];break}const r=l?.control||this.element.control,c=this.getValue().filter(g=>!g.strikeout),d=c.length>0?or(c):"",u=r?.numberExclusiveOptions,h=u?.minValue,R=u?.maxValue,f=u?.decimalPlaces;this.inputPopup=new jg({control:this.control,currentValue:d,minValue:h,maxValue:R,decimalPlaces:f,onConfirm:g=>{if(!g||g.trim()==="")return this._clearNumberValue(),!0;const T=Number(g);return Number.isNaN(T)||!Number.isFinite(T)?!1:this._setNumberValue(g)},onTab:g=>{this.destroy(),setTimeout(()=>{this.control.initNextControl({direction:g})})},onClose:()=>{this.destroy()}}),this.inputPopup.create(),this.isPopup=!0}_clearNumberValue(){const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e;let i=n;for(let c=n;c>=0;c--)if(t[c].controlComponent===s.ControlComponent.PREFIX){i=c;break}let l=i+1;for(let c=i+1;c<t.length;c++)if(t[c].controlComponent===s.ControlComponent.POSTFIX){l=c;break}const r=i+1,a=l-r;a>0&&this.control.getDraw().spliceElementList(t,r,a),this.control.addPlaceholder(i),this.control.getDraw().getRange().setRange(i,i),this.control.emitControlContentChange(),this.control.repaintControl({curIndex:i})}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex:l}=n,r=e[i],a=e[l],c=this.control.getDraw(),d=c.getMode()===s.EditorMode.FORM;if(t.key==="Backspace")return r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?d?i:this.control.removeControl(i):a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT?i:i!==l?(c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),i-1);if(t.key==="Delete"){const u=e[l+1];return r.controlComponent===s.ControlComponent.PLACEHOLDER||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT?d?l:this.control.removeControl(i):r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||u?.controlComponent===s.ControlComponent.POSTFIX||u?.controlComponent===s.ControlComponent.POST_TEXT?l:i!==l?(c.spliceElementList(e,i+1,l-i),this.getValue().length||this.control.addPlaceholder(i),i):(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i)}return l}destroy(){this.inputPopup&&(this.inputPopup.destroy(),this.inputPopup=null),this.isPopup=!1}}class jg{options;popupDom;constructor(t){this.options=t,this.popupDom=null}create(){const{currentValue:t,minValue:e,maxValue:n,decimalPlaces:i,onConfirm:l,onTab:r,onClose:a}=this.options,c=document.createElement("div");c.classList.add(`${rt}-number-input-modal`),c.setAttribute(Ze,s.EditorComponent.POPUP);const d=m=>{if(m.type==="mouseup"){const L=this.options.control.getDraw().getCanvasEvent();L.setIsAllowDrag(!1),L.setIsAllowSelection(!1)}m.stopPropagation()};c.addEventListener("mousedown",d),c.addEventListener("mouseup",d),c.addEventListener("click",d),c.addEventListener("keydown",d),c.addEventListener("input",d);const u=document.createElement("div");u.classList.add(`${rt}-number-input-modal__content`);const h=document.createElement("div");if(h.classList.add(`${rt}-number-input-modal__title`),h.textContent="请输入数值",u.appendChild(h),e!==void 0||n!==void 0){const m=document.createElement("div");m.classList.add(`${rt}-number-input-modal__hint`);let L="有效范围:";e!==void 0&&n!==void 0?L+=`${e} ~ ${n}`:e!==void 0?L+=`≥ ${e}`:L+=`≤ ${n}`,i!=null&&(L+=`,保留${i}位小数`),m.textContent=L,u.appendChild(m)}const R=document.createElement("input");R.classList.add(`${rt}-number-input-modal__input`),R.type="number",R.value=t,R.placeholder="请输入数值",e!==void 0&&(R.min=String(e)),n!==void 0&&(R.max=String(n)),i!=null&&(R.step=(1/Math.pow(10,i)).toString()),setTimeout(()=>{R.focus(),R.select()},100),u.appendChild(R);const f=document.createElement("div");f.classList.add(`${rt}-number-input-modal__error`),f.style.display="none",u.appendChild(f);const g=document.createElement("div");g.classList.add(`${rt}-number-input-modal__buttons`);const T=document.createElement("button");T.classList.add(`${rt}-number-input-modal__cancel`),T.textContent="取消",T.onclick=()=>{a()},g.appendChild(T);const C=document.createElement("button");C.classList.add(`${rt}-number-input-modal__confirm`),C.textContent="确定";const p=()=>{const m=R.value.trim();if(!m)return l("");const L=parseFloat(m);return Number.isNaN(L)||!Number.isFinite(L)?(f.textContent="请输入有效的数值",f.style.display="block",!1):i!=null&&(m.split(".")[1]||"").length>i?(f.textContent=`小数位数不能超过${i}位`,f.style.display="block",!1):e!==void 0&&L<e?(f.textContent=`数值不能小于 ${e}`,f.style.display="block",!1):n!==void 0&&L>n?(f.textContent=`数值不能大于 ${n}`,f.style.display="block",!1):(f.style.display="none",l(m))};C.onclick=()=>{p()&&a()},g.appendChild(C),u.appendChild(g),c.appendChild(u),R.onkeydown=m=>{m.key==="Enter"?C.click():m.key==="Tab"?(m.preventDefault(),p()&&(a(),r(m.shiftKey?Jt.UP:Jt.DOWN))):m.key==="Escape"&&a()},this.options.control.getContainer().appendChild(c),this.popupDom=c}destroy(){this.popupDom&&(this.popupDom.remove(),this.popupDom=null)}}class qg{options;mask;container;inputList;optionItemContainers;data;constructor(t){this.options=t,this.mask=null,this.container=null,this.inputList=[],this.optionItemContainers=[],this.data=t.data,this._render()}_getFieldValue(t){const e=this.inputList.filter(n=>n.name===t);if(e.length!==0){for(const n of e)if(n instanceof HTMLInputElement&&n.type==="radio"&&n.checked)return n.value;return e[0].value}}_updateFieldVisibility(){this.data.forEach((t,e)=>{if(t.visibleWhen){const{field:n,value:i}=t.visibleWhen,l=this._getFieldValue(n),r=this.optionItemContainers[e];if(r){const a=l===i;r.style.display=a?"":"none"}}})}_render(){const{title:t,onClose:e,onCancel:n,onConfirm:i}=this.options,l=document.createElement("div");l.classList.add("dialog-mask"),l.setAttribute(Ze,s.EditorComponent.COMPONENT),document.body.append(l);const r=document.createElement("div");r.classList.add("dialog-container"),r.setAttribute(Ze,s.EditorComponent.COMPONENT);const a=document.createElement("div");a.classList.add("dialog"),r.append(a);const c=document.createElement("div");c.classList.add("dialog-title");const d=document.createElement("span");d.append(document.createTextNode(t));const u=document.createElement("i");u.onclick=()=>{e&&e(),this._dispose()},c.append(d),c.append(u),a.append(c);const h=document.createElement("div");h.classList.add("dialog-option");for(let T=0;T<this.data.length;T++){const C=this.data[T],p=document.createElement("div");if(p.classList.add("dialog-option__item"),C.visible===!1&&(p.style.display="none"),C.label){const I=document.createElement("span");I.append(document.createTextNode(C.label)),p.append(I),C.required&&I.classList.add("dialog-option__item--require")}if(C.type==="radio"){const I=document.createElement("div");I.classList.add("dialog-radio-group"),C.horizontal&&I.classList.add("dialog-radio-group--horizontal"),C.options?.forEach(m=>{const L=document.createElement("label");L.classList.add("dialog-radio-item");const P=document.createElement("input");P.type="radio",P.name=C.name,P.value=m.value,m.value===(C.value||"")&&(P.checked=!0);const M=document.createElement("span");M.textContent=m.label,L.append(P),L.append(M),I.append(L),P.addEventListener("change",()=>{this._updateFieldVisibility()}),this.inputList.push(P)}),p.append(I)}else if(C.type==="select"){const I=document.createElement("select"),m=C.value||"";C.options?.forEach(L=>{const P=document.createElement("option");P.value=L.value,P.label=L.label,L.value===m&&(P.selected=!0),I.append(P)}),I.name=C.name,I.value=m,I.addEventListener("change",()=>{this._updateFieldVisibility()}),C.width&&(I.style.width=`${C.width}px`),p.append(I),this.inputList.push(I)}else if(C.type==="textarea"){const I=document.createElement("textarea");I.name=C.name,I.value=C.value||"",I.placeholder=C.placeholder||"",C.width&&(I.style.width=`${C.width}px`),C.height&&(I.style.height=`${C.height}px`),p.append(I),this.inputList.push(I)}else{const I=document.createElement("input");I.type=C.type,I.name=C.name,I.value=C.value||"",I.placeholder=C.placeholder||"",C.width&&(I.style.width=`${C.width}px`),C.height&&(I.style.height=`${C.height}px`),p.append(I),this.inputList.push(I)}h.append(p),this.optionItemContainers.push(p)}a.append(h);const R=document.createElement("div");R.classList.add("dialog-menu");const f=document.createElement("button");f.classList.add("dialog-menu__cancel"),f.append(document.createTextNode("取消")),f.type="button",f.onclick=()=>{n&&n(),this._dispose()},R.append(f);const g=document.createElement("button");g.append(document.createTextNode("确定")),g.type="submit",g.onclick=()=>{if(i){const T=new Set,C=[];for(const p of this.inputList)if(!T.has(p.name))if(p instanceof HTMLInputElement&&p.type==="radio"){const I=this.inputList.find(m=>m.name===p.name&&m instanceof HTMLInputElement&&m.checked);I&&(C.push({name:p.name,value:I.value}),T.add(p.name))}else C.push({name:p.name,value:p.value}),T.add(p.name);i(C)}this._dispose()},R.append(g),a.append(R),document.body.append(r),this.container=r,this.mask=l,this._updateFieldVisibility()}_dispose(){this.mask?.remove(),this.container?.remove()}}function tf(o,t){const e=o.trim();if(!e)return;const n=t?.key===e;return{...n?t:{},key:e,label:n&&t?.label?t.label:e,writeTarget:t?.writeTarget||"self",writeMode:t?.writeMode||"replaceOnConfirm"}}class Nn{draw;element;control;isPopup;datePicker;options;range;static isDeleting=!1;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.range=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:l,endIndex:r}=n;for(let a=l;a<=r;a++){const c=e[a];c.controlComponent===s.ControlComponent.VALUE&&!Te(c)&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&(this.control.getIsDisabledControl(e)||this.element.control?.editable===!1))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),{startIndex:r,endIndex:a}=l,c=i[r],d=this.element.controlId||c.controlId,u=this.element.originControlId||c.originControlId||null;if(!d)return-1;const h=this.getButtonControlBounds(i,d,u);if(!h)return-1;const R=this.getButtonBusinessOffset(i,h,r),f=this.getButtonBusinessOffset(i,h,a),g=this.getButtonBusinessElements(i,h),T=this.splitButtonBusinessElements(t),C=[...g.slice(0,R),...T,...g.slice(f)];return this.replaceButtonBusinessElements(i,h,C,R+T.length)}isSameButtonElement(t,e,n){return!!(t&&t.controlId===e&&(t.originControlId||null)===n)}getButtonControlBounds(t,e,n){let i=-1,l=-1;for(let r=0;r<t.length;r++){const a=t[r];this.isSameButtonElement(a,e,n)&&(i===-1&&a.controlComponent===s.ControlComponent.PREFIX&&(i=r),a.controlComponent===s.ControlComponent.POSTFIX&&(l=r))}return i===-1||l===-1?null:{controlId:e,originControlId:n,prefixIndex:i,postfixIndex:l}}getButtonBusinessOffset(t,e,n){let i=0;const l=Math.min(n,e.postfixIndex-1);for(let r=e.prefixIndex+1;r<=l;r++){const a=t[r];this.isSameButtonElement(a,e.controlId,e.originControlId)&&a.controlComponent===s.ControlComponent.VALUE&&!Te(a)&&i++}return i}toButtonBusinessElement(t){const e={value:t.value===`
123
123
  `?K:t.value||""};return[...le,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"].forEach(i=>{const l=t[i];l!==void 0&&(e[i]=l)}),e}splitButtonBusinessElements(t){const e=[];return t.forEach(n=>{Te(n)||Dt(n.value===K?`
124
124
  `:n.value||"").forEach(i=>{e.push(this.toButtonBusinessElement({...n,value:i===`
125
125
  `?K:i}))})}),e}getButtonBusinessElements(t,e){const n=[];for(let i=e.prefixIndex+1;i<e.postfixIndex;i++){const l=t[i];this.isSameButtonElement(l,e.controlId,e.originControlId)&&l.controlComponent===s.ControlComponent.VALUE&&!Te(l)&&n.push(this.toButtonBusinessElement(l))}return n}getButtonBusinessText(t){return t.map(e=>e.value===K?`
@@ -561,7 +561,7 @@ ${h} `}textToElements(t){const e=[],n=t.split(`
561
561
  <button class="btn-confirm">确定</button>
562
562
  </div>
563
563
  </div>
564
- `,document.body.appendChild(a);const c=a.querySelector(".table-properties-modal__mask"),d=a.querySelector(".table-properties-modal__close"),u=a.querySelector(".btn-cancel"),h=a.querySelector(".btn-confirm"),R=()=>{a.remove()};c.addEventListener("click",R),d.addEventListener("click",R),u.addEventListener("click",R),h.addEventListener("click",()=>{const f=parseInt(a.querySelector("#tdPaddingTop").value)||0,g=parseInt(a.querySelector("#tdPaddingRight").value)||0,T=parseInt(a.querySelector("#tdPaddingBottom").value)||0,C=parseInt(a.querySelector("#tdPaddingLeft").value)||0;i.tdPadding=[f,g,T,C],R();const{endIndex:p}=this.range.getRange();this.draw.render({curIndex:p,isCompute:!0})})}}s.AreaMode=void 0,(function(o){o.EDIT="edit",o.READONLY="readonly",o.FORM="form"})(s.AreaMode||(s.AreaMode={}));class wf{draw;zone;range;position;options;areaInfoMap=new Map;constructor(t){this.draw=t,this.options=t.getOptions(),this.zone=t.getZone(),this.range=t.getRange(),this.position=t.getPosition()}getAreaInfo(){return this.areaInfoMap}getActiveAreaId(){if(!this.areaInfoMap.size)return null;const{startIndex:t}=this.range.getRange();return this.draw.getElementList()[t]?.areaId||null}getActiveAreaInfo(){const t=this.getActiveAreaId();return t&&this.areaInfoMap.get(t)||null}isReadonly(){const t=this.getActiveAreaInfo();if(!t?.area)return!1;switch(t.area.mode){case s.AreaMode.EDIT:return!1;case s.AreaMode.READONLY:return!0;case s.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:l,range:r}=t;if(this.zone.getZone()!==s.EditorZone.MAIN&&this.zone.setZone(s.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),r&&!this.getActiveAreaId()){const{startIndex:c,endIndex:d}=r,u=this.draw.getOriginalMainElementList();if(!u[c]||!u[d])return null;this.range.setRange(r.startIndex,r.endIndex)}else if(l===s.LocationPosition.BEFORE)this.range.setRange(0,0);else{const d=this.draw.getOriginalMainElementList().length-1;this.range.setRange(d,d)}const a=e||mt();return this.draw.insertElementList([{type:s.ElementType.AREA,value:"",areaId:a,valueList:n,area:at(i)}]),a}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const l of this.areaInfoMap){const{area:r,positionList:a}=l[1];if(r?.hide||!r?.backgroundColor&&!r?.borderColor&&!r?.placeholder)continue;const c=a.filter(g=>g.pageNo===e);if(!c.length)continue;t.translate(.5,.5);const d=c[0],u=c[c.length-1],h=n[3],R=Math.ceil(d.coordinate.leftTop[1]),f=Math.ceil(u.coordinate.rightBottom[1]-R);t.textBaseline="middle",r.backgroundColor&&(t.fillStyle=r.backgroundColor,t.fillRect(h,R,i,f)),r.borderColor&&(t.strokeStyle=r.borderColor,t.strokeRect(h,R,i,f)),r.placeholder&&a.length<=1&&new Zl(this.draw).render(t,{placeholder:{...xs,...r.placeholder},startY:d.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],l=i.areaId;if(l){const r=this.areaInfoMap.get(l);r?(r.elementList.push(i),r.positionList.push(e[n])):this.areaInfoMap.set(l,{id:l,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:Yt(n.elementList)}:null}getContextByAreaId(t,e){const n=this.draw.getOriginalMainElementList();for(let i=0;i<n.length;i++){const l=n[i];if(e?.position===s.LocationPosition.OUTER_BEFORE){if(n[i+1]?.areaId!==t)continue}else if(e?.position===s.LocationPosition.AFTER){if(!(l.areaId===t&&n[i+1]?.areaId!==t))continue}else if(e?.position===s.LocationPosition.OUTER_AFTER){if(!(l.areaId!==t&&n[i-1]?.areaId===t))continue}else if(l.areaId!==t)continue;const r=this.position.getOriginalMainPositionList();return{range:{startIndex:i,endIndex:i},elementPosition:r[i]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const l=["top","hide"];Object.entries(t.properties).forEach(([r,a])=>{if(ws(a))return;const c=r;n.area[c]=a,l.includes(c)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,l=this.draw.getOriginalMainElementList(),r=t.value;qt([{type:s.ElementType.AREA,value:"",valueList:r,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(l,i[0].index,i.length,r,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class Zf{draw;options;imageCache;mainBadge;areaBadgeMap;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,i,l,r){if(this.imageCache.has(r)){const a=this.imageCache.get(r);t.drawImage(a,e,n,i,l)}else{const a=new Image;a.setAttribute("crossOrigin","Anonymous"),a.src=r,a.onload=()=>{this.imageCache.set(r,a),t.drawImage(a,e,n,i,l)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:l,top:r,width:a,height:c,value:d}=this.mainBadge,u=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),h=(l||i.left)*n,R=(r||i.top)*n+u;this._drawImage(t,h,R,a*n,c*n,d)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:l}=this.options;for(const r of n){const{positionList:a}=r[1],c=a[0];if(c.pageNo!==e)continue;const d=this.areaBadgeMap.get(r[0]);if(!d)continue;const{left:u,top:h,width:R,height:f,value:g}=d,T=(u||l.left)*i,C=(h||l.top)*i+c.coordinate.leftTop[1];this._drawImage(t,T,C,R*i,f*i,g)}}}}}class vf{draw;options;data;pageContainer;isDrawing=!1;startStroke=null;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const l=this.draw.getPageNo();let r=this.data.find(d=>d.pageNo===l);if(this.startStroke&&(r||(r={pageNo:l,strokes:[]},this.data.push(r)),r.strokes.push(this.startStroke),this.startStroke=null),!r?.strokes?.length)return;const{scale:a}=this.options;r.strokes[r.strokes.length-1].points.push(e/a,n/a),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){const n=this.data.find(a=>a.pageNo===e)?.strokes;if(!n?.length)return;const{graffiti:{defaultLineColor:i,defaultLineWidth:l},scale:r}=this.options;t.save();for(let a=0;a<n.length;a++){const c=n[a];t.beginPath(),t.strokeStyle=c.lineColor||i,t.lineWidth=(c.lineWidth||l)*r,t.moveTo(c.points[0]*r,c.points[1]*r);for(let d=2;d<c.points.length;d+=2)t.lineTo(c.points[d]*r,c.points[d+1]*r);t.stroke()}t.restore()}}const vl=1024,Qf=['[aria-modal="true"]','[role="dialog"]','[data-overlay-active="true"]',".ant-modal-root",".ant-modal-wrap",".ant-modal",".ant-drawer",".ant-select-dropdown",".ant-picker-dropdown",".ant-dropdown",".ant-popover",".ant-tooltip",".ant-cascader-dropdown",".ant-mentions-dropdown"].join(", ");function Ql(o,t,e){for(let n=0;n<e.length;n+=vl){const i=e.slice(n,n+vl);o.splice(t+n,0,...i)}}class Kf{container;pageContainer;pageList;ctxList;pageNo;renderCount;pagePixelRatio;mode;options;position;zone;elementList;listener;eventBus;override;i18n;canvasEvent;globalEvent;cursor;range;margin;background;badge;search;group;area;underline;strikeout;highlight;historyManager;previewer;imageParticle;laTexParticle;textParticle;tableParticle;tableTool;tableOperate;pageNumber;lineNumber;waterMark;placeholder;header;footer;hyperlinkParticle;labelParticle;macroParticle;dateParticle;separatorParticle;pageBreakParticle;superscriptParticle;subscriptParticle;checkboxParticle;radioParticle;menstrualHistoryParticle;fetalHeartPositionParticle;toothPositionParticle;blockParticle;listParticle;lineBreakParticle;whiteSpaceParticle;control;pageBorder;workerManager;scrollObserver;selectionObserver;imageObserver;graffiti;command;interactionPaused;overlayActiveCount;globalShortcutSuspended;LETTER_REG;WORD_LIKE_REG;rowList;pageRowList;painterStyle;painterOptions;visiblePageNoList;intersectionPageNo;lazyRenderIntersectionObserver;printModeData;readonlyModeData;splitTdValueMap=new Map;tdMap=new Map;constructor(t,e,n,i,l,r){this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.renderCount=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=n.main,this.listener=i,this.eventBus=l,this.override=r,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new Pf(e.locale),this.historyManager=new Md(this),this.position=new Od(this),this.zone=new Sf(this),this.range=new Sd(this),this.margin=new Xd(this),this.background=new Dd(this),this.badge=new Zf(this),this.search=new Nd(this),this.group=new Xf(this),this.area=new wf(this),this.underline=new bd(this),this.strikeout=new yd(this),this.highlight=new Fd(this),this.previewer=new Cf(this),this.imageParticle=new Ks(this),this.laTexParticle=new _s(this),this.textParticle=new Vd(this),this.tableParticle=new Ud(this),this.tableTool=new wd(this),this.tableOperate=new Uf(this),this.pageNumber=new _n(this),this.lineNumber=new bf(this),this.waterMark=new kd(this),this.placeholder=new Zl(this),this.header=new Kd(this,n.header),this.footer=new Df(this,n.footer),this.hyperlinkParticle=new Zd(this),this.labelParticle=new vd(this),this.macroParticle=new Qd(this),this.dateParticle=new pf(this),this.separatorParticle=new _d(this),this.pageBreakParticle=new Bd(this),this.superscriptParticle=new Hd,this.subscriptParticle=new Ad,this.checkboxParticle=new af(this),this.radioParticle=new cf(this),this.menstrualHistoryParticle=new df(this),this.fetalHeartPositionParticle=new uf(this),this.toothPositionParticle=new Rf(this),this.blockParticle=new Ef(this),this.listParticle=new Ff(this),this.lineBreakParticle=new po(this),this.whiteSpaceParticle=new Nf(this),this.control=new nf(this),this.pageBorder=new Vf(this),this.graffiti=new vf(this,n.graffiti),this.scrollObserver=new Wd(this),this.selectionObserver=new Yd(this),this.imageObserver=new Mf,new yf(this),this.canvasEvent=new Ld(this),this.cursor=new wc(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new Pd(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new mf(this),new Yf(this);const{letterClass:a}=e;this.LETTER_REG=new RegExp(`[${a.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${a.map(c=>`[^${c}][${c}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.readonlyModeData=null,this.interactionPaused=!1,this.overlayActiveCount=0,this.globalShortcutSuspended=!1,this.isPrintLikeMode()&&this.setPrintData(),this.mode===s.EditorMode.READONLY&&this.setReadonlyData(),this.mode,s.EditorMode.FORM,this.render({isInit:!0,isSetCursor:!1,isFirstRender:!0})}setPrintData(){this.printModeData||(this.printModeData=at({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const t=at(this.printModeData);["header","main","footer"].forEach(l=>{t[l]=this.control.filterAssistElement(t[l])});const n=t,i=this.removeStrikeout(n);t.main=i.main.filter(l=>!l.strikeout),this.setEditorData(i)}removeStrikeout(t){if(Array.isArray(t))return t.map(e=>this.removeStrikeout(e)).filter(e=>!(e&&typeof e=="object"&&"strikeout"in e&&e.strikeout===!0));if(t&&typeof t=="object"){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this.removeStrikeout(t[n]));return e}return t}clearPrintData(){this.printModeData&&(this.setEditorData(at(this.printModeData)),this.printModeData=null)}setReadonlyData(){this.readonlyModeData||(this.readonlyModeData=at({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const t=at(this.readonlyModeData);["header","main","footer"].forEach(n=>{const i=Yt(t[n],{editorOptions:this.options});t[n]=wn(i),qt(t[n],{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData(t)}clearReadonlyData(){if(this.readonlyModeData){const t=at(this.readonlyModeData);this.readonlyModeData=null,this.setEditorData(t)}}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}isPrintLikeMode(t=this.mode){return t===s.EditorMode.PRINT||t===s.EditorMode.COMPARE}getIsButtonRowStartPrefix(t,e,n){const i=t[e];if(this.isPrintLikeMode()||i.control?.type!==s.ControlType.BUTTON||i.control.buttonText||i.control.minWidth||i.controlComponent!==s.ControlComponent.PREFIX||!i.value)return!1;const l=t[e+1];return!l||l.controlId!==i.controlId||(l.originControlId||null)!==(i.originControlId||null)||l.controlComponent!==s.ControlComponent.VALUE||l.buttonValueLayout?!1:n.elementList.every(r=>r.value===K||de(r))}getElementLayoutWidth(t){return t.control?.type===s.ControlType.BUTTON&&!t.control.buttonText&&t.controlComponent===s.ControlComponent.PREFIX&&t.left&&t.left<0?Math.max(0,t.metrics.width+t.left):t.metrics.width}isContentReadonly(){if(this.mode===s.EditorMode.COMPARE)return!0;if(this.area.getActiveAreaInfo()?.area?.mode)return this.area.isReadonly();switch(this.mode){case s.EditorMode.DESIGN:return!1;case s.EditorMode.READONLY:case s.EditorMode.PRINT:case s.EditorMode.GRAFFITI:return!0;case s.EditorMode.FORM:if(this.control.getIsRangeWithinControl()){const t=this.getElementList(),{startIndex:e}=this.range.getRange(),n=t[e];if(n?.control?.type===s.ControlType.TEXTFIELD){const i=n.controlId;if(i){for(let l=0;l<t.length;l++)if(t[l].originControlId===i&&t[l].controlId!==i)return!1}return!0}}return!this.control.getIsRangeWithinControl();default:return!1}}isSelectionDisabled(){return this.mode===s.EditorMode.COMPARE?!1:this.area.getActiveAreaInfo()?.area?.mode?this.area.isReadonly():this.mode===s.EditorMode.READONLY||this.mode===s.EditorMode.PRINT||this.mode===s.EditorMode.GRAFFITI}setMode(t){if(this.mode===t)return;const e=this.mode;this.macroParticle.clearInlineEditor({isSubmitHistory:!1}),this.mode=t,this.options.mode=t;const n=this.isPrintLikeMode(t);this.isPrintLikeMode(e)&&this.clearPrintData(),e===s.EditorMode.READONLY&&t!==s.EditorMode.READONLY&&this.clearReadonlyData(),n&&!this.printModeData&&(this.printModeData=at({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const i=new Map,l=a=>{a.forEach(c=>{c.controlId&&(c.controlComponent==="value"&&i.set(c.controlId,!0),c.checked&&i.set(c.controlId,!0))})};l(this.elementList),this.elementList.forEach(a=>{a.type==="table"&&a.trList?.forEach(c=>{c.tdList?.forEach(d=>{l(d.value)})})});const r=a=>{a.forEach(c=>{if(!(!c.control&&!c.controlId)&&(c.controlComponent==="value"&&c.strikeout&&(n?c.hide=!0:c.hide=!1),!!c.control&&!(c.type!=="control"&&c.control.type!=="button"))){if(c.control.type==="TextField"&&(c.controlComponent==="placeholder"||c.controlComponent==="preTextFix"||c.controlComponent==="preTextFixText"||c.controlComponent==="postTextFix"||c.controlComponent==="postTextFixText"||c.controlComponent==="textFixLabel")&&(t===s.EditorMode.EDIT?c.hide=!1:c.hide=!0),c.control.type==="text"&&(c.controlComponent==="placeholder"||c.controlComponent==="prefix"||c.controlComponent==="postfix")&&(t===s.EditorMode.EDIT||t===s.EditorMode.FORM?c.hide=!1:c.hide=!0),c.control.type==="number"||c.control.type==="select"||c.control.type==="date"||c.control.type==="checkbox"||c.control.type==="radio"){if(c.controlComponent==="placeholder"||c.controlComponent==="prefix"||c.controlComponent==="postfix"){const u=i.get(c.controlId);c.control.type==="select"&&n||n&&!u?c.hide=!0:c.hide=!1}c.control.type==="number"&&c.controlComponent==="value"&&(n&&c.strikeout?c.hide=!0:!n&&c.strikeout&&(c.hide=!1))}c.control.type==="button"&&(c.hide=!1,c.control.hide=!1),c.control.type==="menstrualHistory"&&(c.controlComponent==="prefix"||c.controlComponent==="postfix")&&(n?c.hide=!0:c.hide=!1)}})};r(this.elementList),this.elementList.forEach(a=>{a.type==="table"&&a.trList.forEach(c=>{c.tdList.forEach(d=>{r(d.value)})})}),t===s.EditorMode.FORM?(this.elementList.filter(a=>a.type==="control").map(a=>{a.control?.type==="button"&&(a.controlComponent==="prefix"||a.controlComponent==="postfix"?(a.color="#1677FF",a.highlight="transparent"):a.controlComponent==="value"&&(a.color=this.options.defaultColor,a.highlight="transparent"))}),this.hideTextFieldWhitespace(this.elementList,!0),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):t===s.EditorMode.EDIT?(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!1,!0)),n?(this.elementList.filter(a=>a?.control?.type==="button").map(a=>{(a?.controlComponent==="prefix"||a?.controlComponent==="postfix")&&(a.color="transparent",a.highlight="transparent"),a?.controlComponent==="value"&&!a.control.buttonText&&(a.color=this.options.defaultColor,a.highlight="transparent")}),this.setPrintData()):(this.clearPrintData(),this.elementList.filter(a=>a?.control?.type==="button").map(a=>{(a?.controlComponent==="prefix"||a?.controlComponent==="postfix")&&(a.color="#1677FF",a.highlight="transparent"),a?.controlComponent==="value"&&!a.control.buttonText&&(a.color=this.options.defaultColor,a.highlight="transparent"),a?.type==="text"&&a.control.buttonText&&(a.color="#000"),a?.type==="control"&&a?.controlComponent==="value"&&a.control.buttonText&&(a.color="#000",a.highlight="transparent")})),t===s.EditorMode.READONLY&&this.setReadonlyData(),this.clearSideEffect(),this.control.destroyControl(),this.range.clearRange(),this.render({isSetCursor:!1,isSubmitHistory:!1})}hideTextFieldWhitespace(t,e){const n=a=>a?/^[\s\u00A0\u2000-\u200B\u3000\n\r\t]+$/.test(a):!1,i=(a,c)=>{for(let d=0;d<a.length;d++){const u=a[d];if(u.type===s.ElementType.TABLE&&u.trList)for(const h of u.trList)for(const R of h.tdList)i(R.value,c);u.originControlId&&u.controlId&&u.originControlId!==u.controlId&&c.add(u.originControlId)}},l=new Set;e&&i(t,l),(a=>{for(let c=0;c<a.length;c++){const d=a[c];if(d.type===s.ElementType.TABLE&&d.trList)for(const u of d.trList)for(const h of u.tdList)this.hideTextFieldWhitespace(h.value,e);d.control?.type===s.ControlType.TEXTFIELD&&d.controlComponent===s.ControlComponent.VALUE&&n(d.value)&&(d.controlId&&l.has(d.controlId)?d.hide=!1:d.hide=e)}})(t)}getSubTemplateRuntimeEndIndex(t,e,n){let i=e+1;for(;i<t.length&&t[i].subTemplateParentId===n;)i++;return i}syncSubTemplateExpandedState(t,e,n,i,l){let r=!1;const a=this.getSubTemplateRuntimeEndIndex(t,e,n.id);if(i&&!n.subTemplateContent?.length&&(i=!1),n.subTemplateExpanded!==i&&(n.subTemplateExpanded=i,r=!0),!!n.hide!==l&&(n.hide=l,r=!0),!i)return a>e+1&&(t.splice(e+1,a-e-1),r=!0),r;if(a===e+1){const c=at(n.subTemplateContent||[]);qt(c,{isHandleFirstElement:!1,editorOptions:this.options});for(let d=0;d<c.length;d++)c[d].subTemplateParentId=n.id;c.length&&(t.splice(e+1,0,...c),r=!0)}return r}applySubTemplateRuntimeState(t,e){const n=i=>{let l=!1,r=0;for(;r<i.length;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE){const c=!!a.subTemplateConditions?.length;if(this.mode===s.EditorMode.EDIT&&c)l=this.syncSubTemplateExpandedState(i,r,a,!0,!0)||l;else if((this.mode===s.EditorMode.FORM||this.isPrintLikeMode())&&c){const d=e?lf(a.subTemplateConditions,e,a.subTemplateRelation):!1;l=this.syncSubTemplateExpandedState(i,r,a,d,!0)||l}else this.mode!==s.EditorMode.FORM&&!this.isPrintLikeMode()&&(l=this.syncSubTemplateExpandedState(i,r,a,!1,!1)||l)}if(a.valueList?.length&&(l=n(a.valueList)||l),a.control?.value?.length&&(l=n(a.control.value)||l),a.type===s.ElementType.TABLE&&a.trList?.length)for(let c=0;c<a.trList.length;c++){const d=a.trList[c];for(let u=0;u<d.tdList.length;u++)l=n(d.tdList[u].value)||l}r++}return l};return n(t)}updateTextFieldPlaceholderVisibility(t,e,n){const i=[s.ControlType.TEXT,s.ControlType.TEXTFIELD,s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.CHECKBOX,s.ControlType.RADIO,s.ControlType.NUMBER];(r=>{let a=0;for(;a<r.length;){const c=r[a];if(c.type===s.ElementType.TABLE&&c.trList)for(const d of c.trList)for(const u of d.tdList)this.updateTextFieldPlaceholderVisibility(u.value,e,n);if(c.control?.type&&i.includes(c.control.type)&&(c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PRE_TEXT)){const d=c.controlId,u=c.control.type;let h=!1,R=!1,f=!1;const g=[],T=[],C=[];let p=-1,I=a;for(;I<r.length;){const m=r[I];if(m.controlId!==d){const L=m.controlId;let P=u===s.ControlType.TEXT,M=I;if(P)for(;M<r.length&&r[M].controlId===L;)M++;else for(;M<r.length;){const F=r[M];if(F.controlId!==L)break;F.controlComponent===s.ControlComponent.VALUE&&(F.value&&F.value.trim()||F.type===s.ElementType.MENSTRUAL_HISTORY||F.type===s.ElementType.FETAL_HEART_POSITION||F.type===s.ElementType.TOOTH_POSITION||F.type===s.ElementType.MACRO||F.type===s.ElementType.CUSTOM_MACRO)&&(P=!0),M++}P&&(R=!0),I=M;continue}if((m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&T.push(I),m.controlComponent===s.ControlComponent.VALUE&&m.value&&m.value.trim()&&(h=!0),m.controlComponent===s.ControlComponent.VALUE&&(m.type===s.ElementType.MENSTRUAL_HISTORY||m.type===s.ElementType.FETAL_HEART_POSITION||m.type===s.ElementType.TOOTH_POSITION||m.type===s.ElementType.MACRO||m.type===s.ElementType.CUSTOM_MACRO)&&(h=!0),m.controlComponent===s.ControlComponent.VALUE&&m.control&&m.control.type!==u&&(R=!0),m.controlComponent===s.ControlComponent.PLACEHOLDER&&(f=!0,g.push(I)),m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT){C.push(I),p=I;break}I++}if(h||R){if(f&&g.length>0)for(const m of g)r[m].hide=!0}else if(f&&g.length>0)for(const m of g)r[m].hide=!e;else e&&c.control?.placeholder&&(p>0?this.control.addPlaceholder(p-1):this.control.addPlaceholder(a));if(n)if(e&&(h||R)){for(const m of T)r[m].hide=!0;for(const m of C)r[m].hide=!0}else if(e){for(const m of T)r[m].hide=!1;for(const m of C)r[m].hide=!1}else{for(const m of T)r[m].hide=!0;for(const m of C)r[m].hide=!0}else{for(const m of T)r[m].hide=!1;for(const m of C)r[m].hide=!1}a=I}a++}})(t)}isReadonly(){return this.isContentReadonly()}isDisabled(){if(this.mode===s.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if(this.getTd()?.disabled)return!0;if(t===e){const l=n[t],r=n[t+1];return!!(l?.title?.disabled&&r?.title?.disabled&&l.titleId===r.titleId||l?.control?.disabled&&r?.control?.disabled&&l.controlId===r.controlId)}return n.slice(t+1,e+1).some(l=>l.title?.disabled||l.control?.disabled)}isDesignMode(){return this.mode===s.EditorMode.DESIGN}isPrintMode(){return this.mode===s.EditorMode.PRINT}isGraffitiMode(){return this.mode===s.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===s.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===s.PaperDirection.VERTICAL?n:e}getWidth(){return Math.floor(this.getOriginalWidth()*this.options.scale)}getHeight(){return Math.floor(this.getOriginalHeight()*this.options.scale)}getMainHeight(){return this.getHeight()-this.getMainOuterHeight()}getMainOuterHeight(){const t=this.getMargins(),e=this.header.getExtraHeight(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}getCanvasWidth(t=-1){return this.getPage(t).width}getCanvasHeight(t=-1){return this.getPage(t).height}getInnerWidth(){const t=this.getWidth(),e=this.getMargins();return t-e[1]-e[3]}getOriginalInnerWidth(){const t=this.getOriginalWidth(),e=this.getOriginalMargins();return t-e[1]-e[3]}getContextInnerWidth(){const t=this.position.getPositionContext();if(t.isTable){const{index:e,trIndex:n,tdIndex:i}=t,r=this.getOriginalElementList()[e],a=r.trList[n].tdList[i],c=this.getTdPadding(r);return a.width-c[1]-c[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===s.PaperDirection.VERTICAL?t:[t[1],t[2],t[3],t[0]]}getPageGap(){return this.options.pageGap*this.options.scale}getOriginalPageGap(){return this.options.pageGap}getPageNumberBottom(){const{pageNumber:{bottom:t},scale:e}=this.options;return t*e}getMarginIndicatorSize(){return this.options.marginIndicatorSize*this.options.scale}getDefaultBasicRowMarginHeight(){return this.options.defaultBasicRowMarginHeight*this.options.scale}getHighlightMarginHeight(){return this.options.highlightMarginHeight*this.options.scale}getTdPadding(t){const{table:{tdPadding:e},scale:n}=this.options;return(t?.tdPadding||e).map(l=>l*n)}getContainer(){return this.container}getPageContainer(){return this.pageContainer}getEventTarget(t){return t instanceof Element?t:t instanceof Node?t.parentElement:null}isTargetInsideEditor(t){const e=this.getEventTarget(t);return e?this.container.contains(e)?!0:!!bs(e,n=>!!n&&n.nodeType===1&&!!n.getAttribute(Ze)):!1}isTargetInsideExternalOverlay(t){const e=this.getEventTarget(t);return!e||this.isTargetInsideEditor(e)?!1:!!e.closest(Qf)}pauseInteraction(){this.interactionPaused=!0,this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect()}resumeInteraction(){this.interactionPaused=!1}setOverlayActive(t){this.overlayActiveCount=t?1:0,t&&(this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect())}suspendGlobalShortcut(t){this.globalShortcutSuspended=t}isInteractionSuspended(){return this.interactionPaused||this.overlayActiveCount>0}isGlobalShortcutActive(){return!this.globalShortcutSuspended&&!this.isInteractionSuspended()}getVisiblePageNoList(){return this.visiblePageNoList}setVisiblePageNoList(t){this.visiblePageNoList=t,this.listener.visiblePageNoListChange&&this.listener.visiblePageNoListChange(this.visiblePageNoList),this.eventBus.isSubscribe("visiblePageNoListChange")&&this.eventBus.emit("visiblePageNoListChange",this.visiblePageNoList)}getIntersectionPageNo(){return this.intersectionPageNo}setIntersectionPageNo(t){this.intersectionPageNo=t,this.listener.intersectionPageNoChange&&this.listener.intersectionPageNoChange(this.intersectionPageNo),this.eventBus.isSubscribe("intersectionPageNoChange")&&this.eventBus.emit("intersectionPageNoChange",this.intersectionPageNo)}getPageNo(){return this.pageNo}setPageNo(t){this.pageNo=t}getRenderCount(){return this.renderCount}getPage(t=-1){return this.pageList[~t?t:this.pageNo]}getPageList(){return this.pageList}getPageCount(){return this.pageList.length}getTableRowList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:l}=e;return t[n].trList[i].tdList[l].rowList}getOriginalRowList(){const t=this.getZone();return t.isHeaderActive()?this.header.getRowList():t.isFooterActive()?this.footer.getRowList():this.rowList}getRowList(){return this.position.getPositionContext().isTable?this.getTableRowList(this.getOriginalElementList()):this.getOriginalRowList()}getPageRowList(){return this.pageRowList}getCtx(){return this.ctxList[this.pageNo]}getOptions(){return this.options}getSearch(){return this.search}getGroup(){return this.group}getArea(){return this.area}getBadge(){return this.badge}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getLineBreakParticle(){return this.lineBreakParticle}getTextParticle(){return this.textParticle}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:l}=e;return t[n]?.trList?.[i].tdList[l].value||[]}getElementList(){const t=this.position.getPositionContext(),e=this.getOriginalElementList();return t.isTable?this.getTableElementList(e):e}getMainElementList(){return this.position.getPositionContext().isTable?this.getTableElementList(this.elementList):this.elementList}getOriginalElementList(){const t=this.getZone();return t.isHeaderActive()?this.getHeaderElementList():t.isFooterActive()?this.getFooterElementList():this.elementList}getOriginalMainElementList(){return this.elementList}getFooterElementList(){return this.footer.getElementList()}getTd(){const t=this.position.getPositionContext(),{index:e,trIndex:n,tdIndex:i,isTable:l}=t;return l?this.getOriginalElementList()[e].trList[n].tdList[i]:null}getTdByPosition(t){const{index:e,trIndex:n,tdIndex:i,isTable:l}=t;return l?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementTextField(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.getElementList(),{isSubmitHistory:r=!0}=e;qt(t,{isHandleFirstElement:!1,editorOptions:this.options});let a=-1,c=this.control.getActiveControl();if(!c&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),c=this.control.getActiveControl()),c&&this.control.getIsRangeWithinControl()){const d=n===i,u=n+1;d||this.newSpliceElementList(l,u,i-n),this.newSpliceElementList(l,u,0,t),a=n+t.length}else{const d=n===i,u=n+1;d||this.newSpliceElementList(l,u,i-n),this.newSpliceElementList(l,u,0,t),a=n+t.length;const h=l[u-1];t[0].listId&&h&&!h.listId&&h?.value===K&&(!h.type||h.type===s.ElementType.TEXTFIELD)&&(l.splice(n,1),a-=1)}this.control.destroyControl(),~a&&(this.range.setRange(a,a),this.render({curIndex:a,isSubmitHistory:r}))}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:l=!0}=e;qt(t,{isHandleFirstElement:!1,editorOptions:this.options});let r=-1,a=this.control.getActiveControl();if(!a&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),a=this.control.getActiveControl()),a&&this.control.getIsRangeWithinControl()){const c=this.getElementList(),d=n===i,u=n+1,h=c[n],R=c[u],f=M=>!!(M&&(M.controlComponent===s.ControlComponent.POSTFIX||M.controlComponent===s.ControlComponent.POST_TEXT||M.controlComponent===s.ControlComponent.POSTTEXTFIX||M.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)),g=M=>!!(M&&(M.controlComponent===s.ControlComponent.PREFIX||M.controlComponent===s.ControlComponent.PRE_TEXT||M.controlComponent===s.ControlComponent.PRETEXTFIX||M.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)),T=M=>{if(M)return c.find(F=>F.controlId===M&&!F.originControlId&&!!F.control?.type)},C=h?.originControlId&&R?.originControlId===h.originControlId&&h.controlId&&R.controlId&&h.controlId!==R.controlId&&f(h)&&g(R)?T(h.originControlId):void 0,p=C?.control?.type===s.ControlType.TEXTFIELD,I=!!(h?.originControlId&&f(h)&&R?.controlId===h.originControlId&&!R.originControlId&&R.control?.type===s.ControlType.TEXTFIELD&&f(R)),m=!!(h?.originControlId&&f(h)&&R?.controlId===h.originControlId&&!R.originControlId&&R.control?.type===s.ControlType.TEXTFIELD&&R.controlComponent===s.ControlComponent.VALUE);if(h?.controlComponent===s.ControlComponent.PRE_TEXT||h?.controlComponent===s.ControlComponent.POST_TEXT||h?.controlComponent===s.ControlComponent.PREFIX||h?.controlComponent===s.ControlComponent.POSTFIX)for(let M=0;M<t.length;M++)t[M].control||(t[M].color=this.options.defaultColor);d&&!I&&!m&&(c[n]?.control?.type===s.ControlType.TEXTFIELD||c[n]?.control?.type===s.ControlType.TEXT)&&this.control.removePlaceholder(n),d||this.newSpliceElementList(c,u,i-n);const P=I||m||p?h.originControlId:c[n]?.controlId||c[n-1]?.controlId||c[n+1]?.controlId;for(let M=0;M<t.length;M++){if((I||m||p)&&!t[M].control&&(t[M].controlId=P,t[M].control=p?C?.control:R.control,t[M].controlComponent=s.ControlComponent.VALUE,delete t[M].originControlId),t[M]?.control?.type=="button"&&!t[M]?.control?.buttonText&&(t[M]?.controlComponent==="prefix"||t[M]?.controlComponent==="postfix"?(t[M].color="#1677FF",t[M].highlight="transparent"):(t[M].color=this.options.defaultColor,t[M].highlight="transparent")),t[M]?.type===s.ElementType.MENSTRUAL_HISTORY||t[M]?.type===s.ElementType.FETAL_HEART_POSITION||t[M]?.type===s.ElementType.TOOTH_POSITION||t[M]?.type===s.ElementType.MACRO||t[M]?.type===s.ElementType.CUSTOM_MACRO||t[M]?.type===s.ElementType.REUSABLE_ITEM||t[M]?.type===s.ElementType.SUB_TEMPLATE||t[M]?.type===s.ElementType.SPECIAL_SYMBOLS){t[M].controlComponent=s.ControlComponent.VALUE;let F=c[n]?.controlId;F||(F=c[n-1]?.controlId),F||(F=c[n+1]?.controlId),!t[M].controlId&&F&&(t[M].controlId=F)}P&&t[M]?.control&&t[M].controlId&&t[M].controlId!==P&&(t[M].originControlId=P)}this.newSpliceElementList(c,u,0,t),r=n+t.length}else{const c=this.getElementList(),d=n===i,u=n+1;if(c[u]?.control?.type=="TextField"||c[n]?.control?.type=="TextField"){d||this.newSpliceElementList(c,u,i-n);for(let h=0;h<t.length;h++)if(t[h]?.type===s.ElementType.MENSTRUAL_HISTORY||t[h]?.type===s.ElementType.FETAL_HEART_POSITION||t[h]?.type===s.ElementType.TOOTH_POSITION||t[h]?.type===s.ElementType.MACRO||t[h]?.type===s.ElementType.CUSTOM_MACRO||t[h]?.type===s.ElementType.REUSABLE_ITEM||t[h]?.type===s.ElementType.SUB_TEMPLATE||t[h]?.type===s.ElementType.SPECIAL_SYMBOLS){t[h].controlComponent=s.ControlComponent.VALUE;const R=c[n]?.controlId||c[u]?.controlId;!t[h].controlId&&R&&(t[h].controlId=R)}this.newSpliceElementList(c,u,0,t),r=n+t.length}else{d||this.spliceElementList(c,u,i-n);for(let R=0;R<t.length;R++)t[R]?.control?.type=="button"&&!t[R]?.control?.buttonText&&(t[R]?.controlComponent==="prefix"||t[R]?.controlComponent==="postfix"?(t[R].color="#1677FF",t[R].highlight="transparent"):(t[R].color=this.options.defaultColor,t[R].highlight="transparent"));this.spliceElementList(c,u,0,t),r=n+t.length;const h=c[u-1];t[0].listId&&h&&!h.listId&&h?.value===K&&(!h.type||h.type===s.ElementType.TEXT)&&(c.splice(n,1),r-=1)}}~r&&(this.range.setRange(r,r),this.render({curIndex:r,isSubmitHistory:l}))}appendElementList(t,e={}){if(!t.length)return;qt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:l=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:l})}spliceElementList(t,e,n,i,l){const{isIgnoreDeletedRule:r=!1}=l||{},{group:a,modeRule:c}=this.options;if(n>0){const d=e+n,h=t[d]?.listId;if(h&&t[e-1]?.listId!==h){let R=d;for(;R<t.length;){const f=t[R];if(f.listId!==h||f.value===K)break;delete f.listId,delete f.listType,delete f.listStyle,R++}}if(!r&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const R=this.getTd()?.deletable;let f=d-1;for(;f>=e;){const g=t[f];(de(g)||R!==!1&&g?.control?.deletable!==!1&&(!g.controlId||this.mode!==s.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&g?.title?.deletable!==!1&&(a.deletable!==!1||!g.groupIds?.length)&&(g?.area?.deletable!==!1||g?.areaIndex!==0))&&t.splice(f,1),f--}}else t.splice(e,n)}if(i?.length){let d=t[e];for(let u=0;u<i.length;u++){const h=i[u].value===K&&(d?.controlComponent===s.ControlComponent.PREFIX||d?.controlComponent===s.ControlComponent.PRE_TEXT||d?.controlComponent===s.ControlComponent.PRETEXTFIX||d?.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT);!i[u].controlComponent&&d?.controlComponent&&!h&&(i[u].controlId=d.controlId,i[u].control=d.control,i[u].controlComponent=d.controlComponent),d=i[u]}Ql(t,e,i)}}newSpliceElementList(t,e,n,i,l){const{isIgnoreDeletedRule:r=!1}=l||{},{group:a,modeRule:c}=this.options;if(n>0){const u=e+n,R=t[u]?.listId;if(R&&t[e-1]?.listId!==R){let f=u;for(;f<t.length;){const g=t[f];if(g.listId!==R||g.value===K)break;delete g.listId,delete g.listType,delete g.listStyle,f++}}if(!r&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const f=this.getTd()?.deletable;let g=u-1;for(;g>=e;){const T=t[g];(de(T)||f!==!1&&T?.control?.deletable!==!1&&(!T.controlId||this.mode!==s.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&T?.title?.deletable!==!1&&(a.deletable!==!1||!T.groupIds?.length)&&(T?.area?.deletable!==!1||T?.areaIndex!==0))&&t.splice(g,1),g--}}else t.splice(e,n)}const d=t[e]?.controlId;if(i?.length){for(let u=0;u<i.length;u++)d&&i[u].controlId!==d&&(i[u].originControlId=d);Ql(t,e,i)}}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}getTableTool(){return this.tableTool}getTableOperate(){return this.tableOperate}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getMacroParticle(){return this.macroParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getMenstrualHistoryParticle(){return this.menstrualHistoryParticle}getFetalHeartPositionParticle(){return this.fetalHeartPositionParticle}getToothPositionParticle(){return this.toothPositionParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}setCommand(t){this.command=t}getCommand(){return this.command}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,l=!!n&&i!==n;l&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const r=this.pageList.map(a=>a.toDataURL());return e&&this.setPagePixelRatio(null),l&&this.setMode(i),r}getPainterStyle(){return this.painterStyle&&Object.keys(this.painterStyle).length?this.painterStyle:null}getPainterOptions(){return this.painterOptions}setPainterStyle(t,e){this.painterStyle=t,this.painterOptions=e||null,this.getPainterStyle()&&this.pageList.forEach(n=>n.style.cursor="copy")}setDefaultRange(){this.elementList.length&&setTimeout(()=>{const t=this.elementList.length-1;this.range.setRange(t,t),this.range.setRangeStyle()})}getIsPagingMode(){return this.options.pageMode===s.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===s.PageMode.PAGING){const{height:i}=this.options,l=this.getPagePixelRatio(),r=this.pageList[0];r.style.height=`${i}px`,r.height=i*l,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(s.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,a)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,r.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[a])});const l=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!l,curIndex:l?.index}),this.listener.pageScaleChange&&this.listener.pageScaleChange(t),this.eventBus.isSubscribe("pageScaleChange")&&this.eventBus.emit("pageScaleChange",t)}getPagePixelRatio(){return this.pagePixelRatio||window.devicePixelRatio}setPagePixelRatio(t){!this.pagePixelRatio&&t===window.devicePixelRatio||t===this.pagePixelRatio||(this.pagePixelRatio=t,this.setPageDevicePixel())}setPageDevicePixel(){const t=this.getPagePixelRatio(),e=this.getWidth(),n=this.getHeight();this.pageList.forEach((i,l)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[l])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),l=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((r,a)=>{r.width=i*n,r.height=l*n,r.style.width=`${i}px`,r.style.height=`${l}px`,this._initPageContext(this.ctxList[a])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((l,r)=>{l.width=n*e,l.height=i*e,l.style.width=`${n}px`,l.style.height=`${i}px`,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getOriginValue(t={}){const{pageNo:e}=t,n=this.readonlyModeData;let i=n?.main||this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(i=this.pageRowList[e].flatMap(r=>r.elementList)),{header:n?.header||this.getHeaderElementList(),main:i,footer:n?.footer||this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t);console.log(this.elementList,"所有元素");const{extraPickAttrs:n}=t,i={header:Yt(e.header,{extraPickAttrs:n,editorOptions:this.options}),main:Yt(e.main,{extraPickAttrs:n,isClassifyArea:!0,editorOptions:this.options}),footer:Yt(e.footer,{extraPickAttrs:n,editorOptions:this.options}),graffiti:e.graffiti};return{version:pn,data:i,options:at(this.options)}}setValue(t,e){const{header:n,main:i,footer:l}=at(t);if(!n&&!i&&!l)return;const{isSetCursor:r=!1}=e||{};[n,i,l].forEach(d=>{d&&qt(d,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:l}),this.mode===s.EditorMode.READONLY?(this.readonlyModeData=null,this.setReadonlyData()):this.isPrintLikeMode()&&(this.printModeData=null,this.setPrintData()),this.historyManager.recovery();const c=r?i?.length?i.length-1:0:void 0;c!==void 0&&this.range.setRange(c,c),this.render({curIndex:c,isSetCursor:r,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_wrapContainer(t){const e=document.createElement("div");return t.append(e),e}_formatContainer(){this.container.style.position="relative",this.container.style.width=`${this.getWidth()}px`,this.container.setAttribute(Ze,s.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const l=this.getPagePixelRatio();i.width=e*l,i.height=n*l,i.style.cursor="text";const r=i.getContext("2d");this._initPageContext(r),this.pageList.push(i),this.ctxList.push(r)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}getElementFont(t,e=1){const{defaultSize:n,defaultFont:i}=this.options,l=t.font||i,r=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${r*e}px ${l}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:l}=this.options,r=t.size||e;let a=1;return r<12?a=r/12:r>30&&(a=1+(r-30)/30),n*a*(t.rowMargin??i)*l}computeRowList(t){const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:l=!1,startX:r=0,startY:a=0,pageHeight:c=0,mainOuterHeight:d=0,surroundElementList:u=[]}=t,{defaultSize:h,scale:R,imgCaption:f,table:{tdPadding:g,defaultTrMinHeight:T},defaultTabWidth:C}=this.options,p=this.getDefaultBasicRowMarginHeight(),m=document.createElement("canvas").getContext("2d"),L=this.listParticle.computeListStyle(m,n),P=[],M=this._collectTextControlValueSet(n),F=this._collectTextControlHasContentSet(n);n.length&&P.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:n?.[0]?.rowFlex||n?.[1]?.rowFlex});let N=r,Y=a,b=0,S,y=0,V=0;for(let X=0;X<n.length;X++){const O=P[P.length-1],E=n[X];this.clearElementEffect(E);const W=this.getElementRowMargin(E),D={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},U=O.offsetX||E.listId&&L.get(E.listId)||0,Z=e-U,Q=O.elementList.length===1;if(N+=Q?U:0,Y+=Q&&O.offsetY||0,(E.control?.type===s.ControlType.TEXTFIELD||E.control?.type===s.ControlType.TEXT)&&!this.isDesignMode()&&(E.controlComponent===s.ControlComponent.PRETEXTFIX||E.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||E.controlComponent===s.ControlComponent.POSTTEXTFIX||E.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||E.controlComponent===s.ControlComponent.TEXTFIXLABEL||E.controlComponent===s.ControlComponent.PLACEHOLDER||E.controlComponent===s.ControlComponent.PREFIX||E.controlComponent===s.ControlComponent.POSTFIX)){const tt=E.control?.type===s.ControlType.TEXTFIELD,J=E.controlId,_=!!J&&!!M?.has(J);if(tt){const G=!!J&&!!F?.has(J);this.mode===s.EditorMode.EDIT?E.controlComponent===s.ControlComponent.PLACEHOLDER||E.controlComponent===s.ControlComponent.TEXTFIXLABEL?E.hide=G:E.hide=!1:E.hide=!0}else{const G=!!J&&!!F?.has(J);this.mode===s.EditorMode.EDIT||this.mode===s.EditorMode.FORM?E.controlComponent===s.ControlComponent.PLACEHOLDER||E.controlComponent===s.ControlComponent.TEXTFIXLABEL?E.hide=G:E.hide=!1:E.hide=!0}}if(de(E)&&!this.isDesignMode()){const tt=O.elementList[O.elementList.length-1];D.height=tt?.metrics.height||this.options.defaultSize*R,D.boundingBoxAscent=tt?.metrics.boundingBoxAscent||0,D.boundingBoxDescent=tt?.metrics.boundingBoxDescent||0}else if(E.type===s.ElementType.IMAGE||E.type===s.ElementType.LATEX)if(E.imgDisplay===s.ImageDisplay.SURROUND||E.imgDisplay===s.ImageDisplay.FLOAT_TOP||E.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)D.width=0,D.height=0,D.boundingBoxDescent=0;else{const tt=E.width*R,J=E.height*R;if(tt>Z){const _=J*Z/tt;E.width=Z/R,E.height=_/R,D.width=Z,D.height=_,D.boundingBoxDescent=_}else D.width=tt,D.height=J,D.boundingBoxDescent=J;if(E.imgCaption?.value){const _=E.imgCaption.size||f.size,G=E.imgCaption.top??f.top,it=(_+G)*R;D.boundingBoxAscent+=it}}else if(E.type===s.ElementType.TABLE){const tt=E.tdPadding||g;if(E.pagingId){let z=X+1,ut=0;for(;z<n.length;){const Rt=n[z];if(Rt.pagingId===E.pagingId){const St=Rt.trList.filter(Nt=>!Nt.pagingRepeat).filter(Nt=>(Nt.tdList=Nt.tdList.filter(At=>{if(At.originalId){for(let Ft=0;Ft<E.trList.length;Ft++){const Bt=E.trList[Ft],_t=Bt.tdList.find(({id:re})=>re===At.originalId);if(_t){At.value[0]?.type===s.ElementType.SPLIT_TAG&&At.value.splice(0,1),_t.value.push(...At.value.map(re=>this.updateElementTableInfo(re,E,Bt,_t))),_t.rowspan=_t.originalRowspan??_t.rowspan;break}}return!1}return!0}),!Nt.originalId));E.trList.push(...St),E.height+=Rt.height,z++,ut++}else break}ut&&n.splice(X+1,ut)}E.pagingIndex=E.pagingIndex??0,this.tableParticle.computeTrHeight(E,z=>this.computeRowList({innerWidth:(z.width-(tt[1]+tt[3]))*R,elementList:z.value,isFromTable:!0,isPagingMode:i})),E.trList?.forEach(z=>{z.tdList.forEach(ut=>{this.tdMap.set(ut.id,ut)})});const J=this.tableParticle.getTableHeight(E),_=this.tableParticle.getTableWidth(E);E.width=_,E.height=J;const G=_*R,it=J*R;if(D.width=G,D.height=it,D.boundingBoxDescent=it,D.boundingBoxAscent=-W,n[X+1]?.type===s.ElementType.TABLE&&(D.boundingBoxAscent-=W),i){const z=this.getHeight(),ut=this.getMainOuterHeight();let Rt=ut;for(let Ft=0;Ft<P.length;Ft++){const Bt=P[Ft],_t=Bt.offsetY||0;Bt.height+Rt+_t>z||P[Ft-1]?.isPageBreak?Rt=ut+Bt.height+_t:Rt+=Bt.height+_t}const St=W*2,Nt=E.trList[0].height*R;(Rt+Nt+St>z||E.pagingIndex!==0&&E.trList[0].pagingRepeat||n[X-1]?.type===s.ElementType.PAGE_BREAK)&&(Rt=ut);let At=z-(Rt+St);if(it>At){const Ft=E.trList;let Bt=0,_t=0,re=0;for(let ft=0;ft<Ft.length;ft++){const Lt=Ft[ft],Vt=Lt.height*R;if(Rt+St+re+Vt>z){const Pt=Lt;let Et=0;const Mt={...at(Pt),id:mt(),originalId:Pt.originalId??Pt.id,minHeight:void 0,tdList:E.colgroup.map((Tt,It)=>{if(Et--,Et>0)return;const gt=Pt.tdList.find($t=>$t.colIndex===It),et=gt??this.tableParticle.findPreRowSpanTd(Ft,ft,It);gt&&(Et=gt.colspan);const j=mt();return et.originalRowspan=et.rowspan,gt?{...gt,id:j,originalId:gt.originalId??gt.id,linkTdPrevId:gt.id,tdIndex:It,original:et}:{id:j,originalId:et.originalId??et.id,linkTdPrevId:et.id,tdIndex:It,colIndex:It,colspan:1,rowspan:1,value:[],rowList:[],original:et}}).filter(Tt=>!!Tt)},Qt=Mt.tdList,ce=Qt.map(Tt=>Tt.original);ce.forEach((Tt,It)=>{const gt=[];let et=At;if(Tt.rowspan>1){const $t=Ft.slice(Tt.trIndex,Tt.trIndex+ft-Tt.trIndex);et+=$t.reduce((fe,me)=>me.height*R+fe,0)}for(;Tt.mainHeight*R>et&&Tt.rowList?.length;){const $t=Tt.rowList.pop();Tt.value.splice(Tt.value.length-$t.elementList.length),gt.unshift($t),Tt.mainHeight-=$t.height}const j=Qt[It];j.rowList=gt,j.value=gt.map($t=>$t.elementList).flat()});let Ct=!0;const ot=Pt.tdList.some(Tt=>Tt.rowList?.length),Zt=Mt.tdList.some(Tt=>Tt.rowList?.length),yt=Pt.minHeight>At;if(Zt||yt){(ot||!Zt&&yt)&&(yt&&(Pt.originalMinHeight=Pt.minHeight,Pt.minHeight=At,Mt.minHeight=Math.max(Pt.originalMinHeight-At,T)),Mt.tdList.forEach(Tt=>{Tt.original.linkTdNextId=Tt.id,Tt.value.length&&Tt.value[0].value!==K&&Tt.value.unshift({...Tt.original.value.slice(-1).pop(),value:K,type:s.ElementType.SPLIT_TAG})}),Ft.splice(Bt+1,0,Mt),Bt+=1,_t=Ft.length-Bt,Ct=!1),ce.forEach(Tt=>{if(Tt.rowspan>1){const It=Tt.rowspan-(ft-Tt.trIndex);Tt.rowspan=ft-Tt.trIndex+(ot?1:0);const gt=Mt.tdList.find(et=>et.colIndex===Tt.colIndex);ot?gt.rowspan=It:(gt.original.linkTdNextId=gt.id,Pt.tdList.push({...Tt,...gt,rowspan:It}),Pt.tdList.sort((et,j)=>et.colIndex-j.colIndex),gt.value=[])}}),Ct&&ce.forEach((Tt,It)=>{Tt.value.push(...Qt[It].value)});break}}Bt=ft+1,_t=Ft.length-Bt,re+=Vt,At-=Vt}if(_t){const ft=Ft.splice(Bt,_t),Lt=E.pagingId||mt();E.pagingId=Lt;const Vt=at(E);Vt.originalId=E.originalId??E.id,Vt.pagingId=Lt,Vt.pagingIndex=E.pagingIndex+1;const Pt=Ft.filter(Qt=>Qt.pagingRepeat);if(Pt.length){const Qt=at(Pt);Qt.forEach(ce=>ce.id=mt()),ft.unshift(...Qt)}Vt.trList=ft,Vt.id=mt(),Vt.trList?.forEach(Qt=>{Qt.tdList.forEach(ce=>{if(delete ce.valueStartIndex,ce.linkTdPrevId){const Ct=this.getTdById(ce.linkTdPrevId);ce.valueStartIndex=Ct?(Ct.valueStartIndex??0)+Ct.value.length:0,this.splitTdValueMap.has(ce.originalId)?this.splitTdValueMap.get(ce.originalId).push(...ce.value):Ct&&this.splitTdValueMap.set(ce.originalId,[...Ct.value,...ce.value])}ce.value.forEach(Ct=>this.updateElementTableInfo(Ct,Vt,Qt,ce))})}),this.spliceElementList(n,X+1,0,[Vt]),this.tableParticle.computeTrHeight(E);const Et=this.tableParticle.getTableHeight(E),Mt=Et*R;E.height=Et,D.height=Mt,D.boundingBoxDescent=Mt}}if(E.pagingId){const Ft=this.position.getPositionContext();if(Ft.isTable){let Bt=-1,_t=-1,re=X;for(;re<n.length;){const ft=n[re];if(ft.pagingId!==E.pagingId)break;const Lt=ft.trList.findIndex(Vt=>Vt.id===Ft.trId);if(~Lt){Bt=re,_t=Lt;break}re++}~Bt&&(Ft.index=Bt,Ft.trIndex=_t,this.position.setPositionContext(Ft))}}}this.initTableElementIndex(E,X)}else if(E.type===s.ElementType.SEPARATOR){const{separator:{lineWidth:tt}}=this.options,J=E.lineWidth||tt;E.width=Z/R,D.width=Z,D.height=J*R,D.boundingBoxAscent=-W,D.boundingBoxDescent=-W+D.height}else if(E.type===s.ElementType.PAGE_BREAK)E.width=Z/R,D.width=Z,D.height=h;else if(E.type===s.ElementType.RADIO||E.controlComponent===s.ControlComponent.RADIO){const{width:tt,height:J,gap:_}=this.options.radio,G=tt+_*(E.controlComponent?1:2);E.width=G,D.width=G*R,D.height=J*R}else if(E.type===s.ElementType.CHECKBOX||E.controlComponent===s.ControlComponent.CHECKBOX){const{width:tt,height:J,gap:_}=this.options.checkbox,G=tt+_*(E.controlComponent?1:2);E.width=G,D.width=G*R,D.height=J*R}else if(E.type===s.ElementType.MENSTRUAL_HISTORY){const tt=this.menstrualHistoryParticle.computeSize(E);E.width=tt.width/R,D.width=tt.width,D.height=tt.height,D.boundingBoxAscent=tt.height,D.boundingBoxDescent=0}else if(E.type===s.ElementType.FETAL_HEART_POSITION){const tt=this.fetalHeartPositionParticle.computeSize();E.width=tt.width/R,D.width=tt.width,D.height=tt.height,D.boundingBoxAscent=tt.height/2,D.boundingBoxDescent=tt.height/2}else if(E.type===s.ElementType.TOOTH_POSITION){const tt=this.toothPositionParticle.computeSize(E);E.width=tt.width/R,D.width=tt.width,D.height=tt.height,D.boundingBoxAscent=tt.height/2,D.boundingBoxDescent=tt.height/2}else if(E.type===s.ElementType.TAB)D.width=C*R,D.height=h*R,D.boundingBoxDescent=0,D.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(m,m.font);else if(E.type===s.ElementType.BLOCK){if(!E.width)D.width=Z;else{const tt=E.width*R;D.width=Math.min(tt,Z)}D.height=E.height*R,D.boundingBoxDescent=D.height,D.boundingBoxAscent=0}else if(E.type===s.ElementType.LABEL){const{defaultSize:tt,label:{defaultPadding:J}}=this.options;m.font=this.getElementFont(E);const _=this.textParticle.measureText(m,E);D.width=(_.width+J[1]+J[3])*R,D.height=(E.size||tt)*R,D.boundingBoxDescent=0,D.boundingBoxAscent=(J[0]+_.actualBoundingBoxAscent)*R}else if(E.type===s.ElementType.MACRO||E.type===s.ElementType.CUSTOM_MACRO||E.type===s.ElementType.REUSABLE_ITEM||E.type===s.ElementType.SUB_TEMPLATE){const{defaultSize:tt}=this.options;m.font=this.getElementFont(E);const J=this.getMode(),_=J===s.EditorMode.EDIT,G=J===s.EditorMode.FORM;if(J===s.EditorMode.READONLY&&E.type!==s.ElementType.SUB_TEMPLATE){const it=Xo(E),z=m.measureText(it);D.width=z.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=z.actualBoundingBoxDescent,D.boundingBoxAscent=z.actualBoundingBoxAscent}else if(_){const it=E.label||E.value||"";m.font=this.getElementFont(E);const z=m.measureText(it),ut=8*R,Rt=4*R;D.width=z.width+ut*2;const St=z.actualBoundingBoxAscent+z.actualBoundingBoxDescent;D.height=St+Rt*2;const Nt=this.textParticle.measureBasisWord(m,this.getElementFont(E));D.boundingBoxAscent=Nt.actualBoundingBoxAscent*R,D.boundingBoxDescent=Nt.actualBoundingBoxDescent*R}else if(E.type===s.ElementType.CUSTOM_MACRO){const it=E.macroConfig,z=it?.value||"";if(G){const ut=it?.type||"text",Rt=this.textParticle.measureText(m,E),St=E.label||"";if(ut==="select"){const Nt=z||`请选择${St}`,At=m.measureText(Nt),Ft=m.measureText("[").width,Bt=6*R+2*R;D.width=Ft+At.width+Bt+Ft}else{const Nt=z||`请输入${St}`,At=m.measureText(Nt),Ft=m.measureText("[").width;D.width=Ft+At.width+Ft}D.height=(E.size||tt)*R,D.boundingBoxDescent=Rt.actualBoundingBoxDescent*R,D.boundingBoxAscent=Rt.actualBoundingBoxAscent*R}else{const ut=E.label||"",Rt=z||`请输入${ut}`,St=m.measureText(Rt);D.width=St.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=St.actualBoundingBoxDescent,D.boundingBoxAscent=St.actualBoundingBoxAscent}}else if(E.type===s.ElementType.REUSABLE_ITEM){const z=E.reusableItemConfig?.value||"",ut=E.label||"";if(G){const Rt=this.textParticle.measureText(m,E),St=z||`请输入${ut}`,Nt=m.measureText(St),At=m.measureText("[").width;D.width=At+Nt.width+At,D.height=(E.size||tt)*R,D.boundingBoxDescent=Rt.actualBoundingBoxDescent*R,D.boundingBoxAscent=Rt.actualBoundingBoxAscent*R}else{const Rt=z||`获取 ${ut}`,St=m.measureText(Rt);D.width=St.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=St.actualBoundingBoxDescent,D.boundingBoxAscent=St.actualBoundingBoxAscent}}else if(E.type===s.ElementType.SUB_TEMPLATE){const it=E.label||"子模板";if(G){const z=m.measureText(it),ut=8*R,Rt=4*R,St=z.actualBoundingBoxAscent+z.actualBoundingBoxDescent;D.width=z.width+ut*2,D.height=St+Rt*2;const Nt=this.textParticle.measureBasisWord(m,this.getElementFont(E));D.boundingBoxAscent=Nt.actualBoundingBoxAscent*R,D.boundingBoxDescent=Nt.actualBoundingBoxDescent*R}else{const z=m.measureText(it);D.width=z.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=z.actualBoundingBoxDescent,D.boundingBoxAscent=z.actualBoundingBoxAscent}}else{const it=E.label||"",z=E.value||`获取 ${it}`,ut=m.measureText(z);D.width=ut.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=ut.actualBoundingBoxDescent,D.boundingBoxAscent=ut.actualBoundingBoxAscent}}else{const tt=E.size||h;(E.type===s.ElementType.SUPERSCRIPT||E.type===s.ElementType.SUBSCRIPT)&&(E.actualSize=Math.ceil(tt*.6)),D.height=(E.actualSize||tt)*R,m.font=this.getElementFont(E);const J=this.textParticle.measureText(m,E),_=E.buttonValueLayoutPrefixOffset?m.measureText("[").width:0;D.width=Math.max(0,J.width-_)*R,E.letterSpacing&&(D.width+=E.letterSpacing*R);const G=this.textParticle.measureBasisWord(m,E.font);D.boundingBoxAscent=G.actualBoundingBoxAscent*R,D.boundingBoxDescent=G.actualBoundingBoxDescent*R,E.type===s.ElementType.SUPERSCRIPT?D.boundingBoxAscent+=D.height/2:E.type===s.ElementType.SUBSCRIPT&&(D.boundingBoxDescent+=D.height/2)}const v=!de(E)&&(E.imgDisplay!==s.ImageDisplay.INLINE&&E.type===s.ElementType.IMAGE||E.type===s.ElementType.LATEX)?D.height+W:D.boundingBoxAscent+W,st=W+D.boundingBoxAscent+D.boundingBoxDescent+W,B=Object.assign(E,{metrics:D,left:0,style:this.getElementFont(E,R)});this.getIsButtonRowStartPrefix(n,X,O)&&(B.left=-D.width);const H=this.getElementLayoutWidth(B);B.control?.minWidth&&(B.controlComponent&&(V+=D.width),B.controlComponent===s.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:O,rowElement:B,availableWidth:Z,controlRealWidth:V}),V=0));const k=n[X-1];let q=n[X+1],x=O.width+H;if(this.options.wordBreak===s.WordBreak.BREAK_WORD&&(!k?.type||k?.type===s.ElementType.TEXT)&&(!E.type||E.type===s.ElementType.TEXT)){const tt=`${k?.value||""}${E.value}`;if(this.WORD_LIKE_REG.test(tt)){const{width:_,endElement:G}=this.textParticle.measureWord(m,n,X),it=_*R;G&&it<=Z?(x+=it,q=G):k&&(x+=it)}const J=this.textParticle.measurePunctuationWidth(m,q);x+=J*R}E.listId&&(E.listId!==S?y=0:E.value===K&&!E.listWrap&&y++),S=E.listId;const Xt=this.position.setSurroundPosition({pageNo:b,rowElement:B,row:O,rowElementRect:{x:N,y:Y,height:st,width:H},availableWidth:Z,surroundElementList:u});N=Xt.x,x+=Xt.rowIncreaseWidth,N+=H;let wt=!1;if(this.mode===s.EditorMode.FORM&&E.control?.type===s.ControlType.BUTTON&&E.controlComponent===s.ControlComponent.PREFIX&&O.elementList.filter(tt=>tt.controlId!==E.controlId).length>0){const tt=E.controlId;if(n.some(_=>_.controlId===`${tt}_text`&&_.control?.type===s.ControlType.BUTTON)){let _=0;for(let G=X;G<n.length;G++){const it=n[G];if(it.controlId!==tt)break;m.font=this.getElementFont(it);const z=this.textParticle.measureText(m,it);if(_+=z.width*R,it.controlComponent===s.ControlComponent.POSTFIX)break}for(let G=0;G<n.length;G++){const it=n[G];if(it.controlId===`${tt}_text`){m.font=this.getElementFont(it);const z=this.textParticle.measureText(m,it);_+=z.width*R}}wt=O.width+_>Z}}const Ie=E.type===s.ElementType.SEPARATOR||E.type===s.ElementType.TABLE||k?.type===s.ElementType.TABLE||k?.type===s.ElementType.BLOCK||E.type===s.ElementType.BLOCK||k?.imgDisplay===s.ImageDisplay.INLINE||E.imgDisplay===s.ImageDisplay.INLINE||k?.listId!==E.listId||k?.areaId!==E.areaId&&!E.area?.hide||E.control?.flexDirection===s.FlexDirection.COLUMN&&(E.controlComponent===s.ControlComponent.CHECKBOX||E.controlComponent===s.ControlComponent.RADIO)&&k?.controlComponent===s.ControlComponent.VALUE||X!==0&&E.value===K&&!E.area?.hide||wt,ne=x>Z,ue=Ie||ne;if(ue){const tt={width:H,height:st,startIndex:X,elementList:[B],ascent:v,rowIndex:O.rowIndex+1,rowFlex:n[X]?.rowFlex||n[X+1]?.rowFlex,isPageBreak:E.type===s.ElementType.PAGE_BREAK};if(B.controlComponent!==s.ControlComponent.PREFIX&&B.control?.indentation===s.ControlIndentation.VALUE_START){const J=O.elementList.findIndex(_=>_.controlId===B.controlId&&_.controlComponent!==s.ControlComponent.PREFIX);if(~J){const G=this.position.computeRowPosition({row:O,innerWidth:this.getInnerWidth()})[J];G&&(tt.offsetX=G.coordinate.leftTop[0])}}E.listId&&(tt.isList=!0,tt.offsetX=L.get(E.listId),tt.listIndex=y),tt.offsetY=!l&&E.area?.top&&E.areaId!==n[X-1]?.areaId?E.area.top*R:0,P.push(tt)}else O.width+=H,X===0&&(Kn(n[1])||n[1]?.areaId)?(O.height=p,O.ascent=p):O.height<st&&(O.height=st,O.ascent=v),O.elementList.push(B);if((ue||X===n.length-1)&&(O.isWidthNotEnough=ne&&!Ie,!O.isSurround&&(k?.rowFlex===s.RowFlex.JUSTIFY||k?.rowFlex===s.RowFlex.ALIGNMENT&&O.isWidthNotEnough))){const tt=O.elementList[0]?.value===K?O.elementList.slice(1):O.elementList,J=(Z-O.width)/(tt.length-1);for(let _=0;_<tt.length-1;_++){const G=tt[_];G.metrics.width+=J}O.width=Z}if(ue){N=r,Y+=O.height,i&&!l&&c&&(Y-a+d+st>c||E.type===s.ElementType.PAGE_BREAK)&&(Y=a,Fc(u,b),b+=1),B.left=0;const tt=P[P.length-1];N=this.position.setSurroundPosition({pageNo:b,rowElement:B,row:tt,rowElementRect:{x:N,y:Y,height:st,width:H},availableWidth:Z,surroundElementList:u}).x,N+=H}}return P}_collectTextControlValueSet(t){if(this.isDesignMode()||this.mode===s.EditorMode.EDIT)return null;const e=new Set;for(let i=0;i<t.length;i++){const l=t[i];l.controlId&&(l.control?.type===s.ControlType.TEXT||l.control?.type===s.ControlType.TEXTFIELD)&&e.add(l.controlId)}const n=new Set;for(let i=0;i<t.length;i++){const l=t[i];l.controlId&&l.controlComponent===s.ControlComponent.VALUE&&e.has(l.controlId)&&n.add(l.controlId)}return n}_collectTextControlHasContentSet(t){if(this.isDesignMode())return null;const e=new Set;let n=0;for(;n<t.length;){const i=t[n];if(i.controlId&&(i.control?.type===s.ControlType.TEXT||i.control?.type===s.ControlType.TEXTFIELD)&&(i.controlComponent===s.ControlComponent.PREFIX||i.controlComponent===s.ControlComponent.PRE_TEXT||i.controlComponent===s.ControlComponent.PRETEXTFIX||i.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){const l=i.controlId;let r=!1,a=n+1;for(;a<t.length;){const c=t[a];if(c.controlId===l&&(c.controlComponent===s.ControlComponent.POSTFIX||c.controlComponent===s.ControlComponent.POST_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))break;if(c.controlId===l&&c.controlComponent===s.ControlComponent.VALUE&&(r=!0),c.controlId!==l&&c.controlId){(i.control?.type===s.ControlType.TEXT||c.controlComponent===s.ControlComponent.VALUE)&&(r=!0);const d=c.controlId;for(a++;a<t.length&&t[a].controlId===d;)a++;continue}a++}r&&e.add(l)}n++}return e}_computePageList(){const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),l=this.getMainOuterHeight();let r=l,a=0;if(e===s.PageMode.CONTINUITY){t[0]=this.rowList,r+=this.rowList.reduce((h,R)=>h+R.height+(R.offsetY||0),0);const c=this.getPagePixelRatio(),d=this.pageList[0],u=Number(d.style.height.replace("px",""));if(r>u)d.style.height=`${r}px`,d.height=r*c;else{const h=r<i?i:r;d.style.height=`${h}px`,d.height=h*c}this._initPageContext(this.ctxList[0])}else for(let c=0;c<this.rowList.length;c++){const d=this.rowList[c],u=d.offsetY||0;if(d.height+u+r>i||this.rowList[c-1]?.isPageBreak){if(Number.isInteger(n)&&a>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}r=l+d.height+u,t.push([d]),a++}else r+=d.height+u,t[a].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:l}=e,r=this.getDefaultBasicRowMarginHeight(),a=this.getHighlightMarginHeight();for(let c=0;c<n.length;c++){const d=n[c];let u="";for(let h=0;h<d.elementList.length;h++){const R=d.elementList[h],f=d.startIndex+h,g=l[f]===R?f:l.indexOf(R),T=~g?g:f,C=this.control.getControlHighlight(l,T),p=R.highlight||C;if(p){u&&u!==p&&this.highlight.render(t);const I=i[T],{coordinate:{leftTop:[m,L]}}=I,P=R.left||0,M=!R.highlight&&!!C&&this.control.getIsInlineControlBackground(l,T),F=M?L+I.ascent-R.metrics.boundingBoxAscent-a:L+r-a,N=M?R.metrics.boundingBoxAscent+R.metrics.boundingBoxDescent+2*a:d.height-2*r+2*a;this.highlight.recordFillInfo(t,m-P,F,R.metrics.width+P,N,p)}else u&&this.highlight.render(t);u=p}this.highlight.render(t)}}validateNumber(t){return/^\d+$/.test(t)}drawRow(t,e){this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:l,lineBreak:r,whiteSpace:a}=this.options,{rowList:c,pageNo:d,elementList:u,positionList:h,startIndex:R,zone:f,isDrawLineBreak:g=!r.disabled,td:T,isDrawWhiteSpace:C=!a.disabled}=e,p=this.isPrintLikeMode(),I=this.isSelectionDisabled(),{isCrossRowCol:m,tableId:L}=this.range.getRange();let P=R;for(let M=0;M<c.length;M++){const F=c[M],N={x:0,y:0,width:0,height:0};let Y=null;for(let b=0;b<F.elementList.length;b++){const S=F.elementList[b],y=S.metrics,{ascent:V,coordinate:{leftTop:[X,O]}}=h[F.startIndex+b],E=F.elementList[b-1];if(de(S)&&!this.isDesignMode())this.textParticle.complete();else if(S.type===s.ElementType.IMAGE)this.textParticle.complete(),S.imgDisplay!==s.ImageDisplay.SURROUND&&S.imgDisplay!==s.ImageDisplay.FLOAT_TOP&&S.imgDisplay!==s.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.TABLE)m&&(N.x=X,N.y=O,Y=S),this.tableParticle.render(t,S,X,O);else if(S.type===s.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.MACRO||S.type===s.ElementType.CUSTOM_MACRO||S.type===s.ElementType.REUSABLE_ITEM||S.type===s.ElementType.SUB_TEMPLATE)this.textParticle.complete(),this.macroParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.DATE){const v=F.elementList[b+1];(!E||E.dateId!==S.dateId)&&this.textParticle.complete(),this.textParticle.record(t,S,X,O+V),(!v||v.dateId!==S.dateId)&&this.textParticle.complete()}else if(S.type===s.ElementType.SUPERSCRIPT)this.textParticle.complete(),this.superscriptParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.SUBSCRIPT)this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.SEPARATOR)this.separatorParticle.render(t,S,X,O);else if(S.type===s.ElementType.PAGE_BREAK)this.mode!==s.EditorMode.CLEAN&&!p&&this.pageBreakParticle.render(t,S,X,O);else if(S.type===s.ElementType.CHECKBOX||S.controlComponent===s.ControlComponent.CHECKBOX)this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:X,y:O+V,index:b,row:F});else if(S.type===s.ElementType.RADIO||S.controlComponent===s.ControlComponent.RADIO)this.textParticle.complete(),this.radioParticle.render({ctx:t,x:X,y:O+V,index:b,row:F});else if(S.type===s.ElementType.MENSTRUAL_HISTORY)this.textParticle.complete(),this.menstrualHistoryParticle.render({ctx:t,x:X,y:O+V,index:b,row:F,element:S});else if(S.type===s.ElementType.FETAL_HEART_POSITION)this.textParticle.complete(),this.fetalHeartPositionParticle.render({ctx:t,x:X,y:O+V,index:b,row:F,element:S});else if(S.type===s.ElementType.TOOTH_POSITION)this.textParticle.complete(),this.toothPositionParticle.render({ctx:t,x:X,y:O+V,index:b,row:F,element:S});else if(S.type===s.ElementType.TAB)this.textParticle.complete();else if(S.rowFlex===s.RowFlex.ALIGNMENT||S.rowFlex===s.RowFlex.JUSTIFY)this.textParticle.record(t,S,X,O+V),this.textParticle.complete();else if(S.type===s.ElementType.BLOCK)this.textParticle.complete(),this.blockParticle.render(t,d,S,X,O+V);else{const v=S.buttonValueLayoutPrefixOffset===!0;(S.left||v)&&this.textParticle.complete(),this.textParticle.record(t,S,X,O+V),(v||S.width||S.letterSpacing||ca.test(S.value))&&this.textParticle.complete()}if(g&&!p&&this.mode!==s.EditorMode.CLEAN&&!F.isWidthNotEnough&&b===F.elementList.length-1&&this.lineBreakParticle.render(t,S,X,O+F.height/2),C&&da.test(S.value)&&this.whiteSpaceParticle.render(t,S,X,O+F.height/2),S.control?.border){E?.control?.border&&E.controlId!==S.controlId&&this.control.drawBorder(t);const v=this.getElementRowMargin(S);this.control.recordBorderInfo(X,O+v,S.metrics.width,F.height-2*v)}else E?.control?.border&&this.control.drawBorder(t);if(S.control?.type===s.ControlType.TEXT){const v=S.controlComponent===s.ControlComponent.VALUE,st=S.controlComponent===s.ControlComponent.POSTFIX||S.controlComponent===s.ControlComponent.POST_TEXT,B=!!E&&E.originControlId===S.controlId&&(E.controlComponent===s.ControlComponent.POSTFIX||E.controlComponent===s.ControlComponent.POST_TEXT||E.controlComponent===s.ControlComponent.POSTTEXTFIX||E.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT);S.originControlId&&(S.controlComponent===s.ControlComponent.PREFIX||S.controlComponent===s.ControlComponent.PRE_TEXT||S.controlComponent===s.ControlComponent.PRETEXTFIX||S.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&this.control.drawTextFieldUnderline(t),v&&S.control?.underline&&!S.underline&&((!E||E.controlId!==S.controlId||B||E.controlComponent!==s.ControlComponent.VALUE&&E.controlComponent!==s.ControlComponent.PLACEHOLDER)&&this.control.startTextFieldUnderline(S.controlId,X,O+F.height),this.control.recordTextFieldUnderlineWidth(S.metrics.width)),st&&this.control.drawTextFieldUnderline(t),S.originControlId&&(S.controlComponent===s.ControlComponent.POSTFIX||S.controlComponent===s.ControlComponent.POST_TEXT||S.controlComponent===s.ControlComponent.POSTTEXTFIX||S.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.drawTextFieldUnderline(t)}else E?.control?.type===s.ControlType.TEXT&&this.control.drawTextFieldUnderline(t);if(S.type!==s.ElementType.REUSABLE_ITEM&&(S.underline||S.control?.underline)&&S.controlComponent!==s.ControlComponent.PLACEHOLDER&&!(S.control?.type===s.ControlType.TEXT&&S.control?.underline&&!S.underline)){E?.type===s.ElementType.SUBSCRIPT&&S.type!==s.ElementType.SUBSCRIPT&&this.underline.render(t);const v=this.getElementRowMargin(S),st=S.left||0;let B=0;S.type===s.ElementType.SUBSCRIPT&&(B=this.subscriptParticle.getOffsetY(S));const H=S.control?.underline?this.options.underlineColor:S.color;this.underline.recordFillInfo(t,X-st,O+F.height-v+B,y.width+st,0,H,S.textDecoration?.style)}else(E?.underline||E?.control?.underline)&&(E?.control?.type===s.ControlType.TEXT&&E?.control?.underline&&!E.underline||this.underline.render(t));if(S.type!==s.ElementType.REUSABLE_ITEM&&S.strikeout){if(!S.type||Le.includes(S.type)){E&&(E.type===s.ElementType.SUBSCRIPT&&S.type!==s.ElementType.SUBSCRIPT||E.type===s.ElementType.SUPERSCRIPT&&S.type!==s.ElementType.SUPERSCRIPT||this.getElementSize(E)!==this.getElementSize(S))&&this.strikeout.render(t);const v=this.textParticle.measureBasisWord(t,this.getElementFont(S));let st=O+V+v.actualBoundingBoxDescent*n-y.height/2;S.type===s.ElementType.SUBSCRIPT?st+=this.subscriptParticle.getOffsetY(S):S.type===s.ElementType.SUPERSCRIPT&&(st+=this.superscriptParticle.getOffsetY(S)),this.strikeout.recordFillInfo(t,X,st,y.width)}}else E?.strikeout&&this.strikeout.render(t);const{zone:W,splitTdRange:D}=this.range.getRange();let{startIndex:U,endIndex:Z}=this.range.getRange(),Q=!1;if(T&&D&&[T.originalId,T.id].includes(D.originalId)&&(Q=!0,U=D.startIndex-(T.valueStartIndex??0),Z=D.endIndex-(T.valueStartIndex??0)),W===f&&U!==Z&&U<=P&&P<=Z){const v=this.position.getPositionContext();if(!v.isTable&&!S.tdId||v.tdId===S.tdId||Q)if(U===P){const st=u[U+1];st&&st.value===K&&(N.x=X+y.width,N.y=O,N.height=F.height,N.width+=this.options.rangeMinWidth)}else{let st=y.width;st===0&&F.elementList.length===1&&(st=this.options.rangeMinWidth),N.width||(N.x=X,N.y=O,N.height=F.height),N.width+=st}}if(!l.disabled&&S.groupIds&&this.group.recordFillInfo(S,X,O,y.width,F.height),P++,S.type===s.ElementType.TABLE&&!de(S)){const v=S.tdPadding||i,st=v[1]+v[3];for(let B=0;B<S.trList.length;B++){const H=S.trList[B];for(let k=0;k<H.tdList.length;k++){const q=H.tdList[k];this.drawRow(t,{elementList:q.value,positionList:q.positionList,rowList:q.rowList,pageNo:d,startIndex:0,innerWidth:(q.width-st)*n,zone:f,isDrawLineBreak:g,td:q})}}}}if(F.isList&&this.listParticle.drawListStyle(t,F,h[F.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!I){if(N.width&&N.height){const{x:b,y:S,width:y,height:V}=N;this.range.render(t,b,S,y,V)}if(m&&Y&&Y.id===L){const{coordinate:{leftTop:[b,S]}}=h[F.startIndex];this.tableParticle.drawRange(t,Y,b,S)}}}this.control.renderQualityMarks(t,e.elementList,e.positionList,e.rowList,e.pageNo,e.zone,e.innerWidth)}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:l,pageNo:r}=e;for(let a=0;a<i.length;a++){const c=i[a],d=c.element;if((r===c.pageNo||c.zone===s.EditorZone.HEADER||c.zone==s.EditorZone.FOOTER)&&d.imgDisplay&&l.includes(d.imgDisplay)&&d.type===s.ElementType.IMAGE){const u=d.imgFloatPosition;this.imageParticle.render(t,d,u.x*n,u.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){const{elementList:e,positionList:n,rowList:i,pageNo:l}=t,{inactiveAlpha:r,pageMode:a,header:c,footer:d,pageNumber:u,lineNumber:h,pageBorder:R}=this.options,f=this.isPrintLikeMode(),g=this.mode===s.EditorMode.COMPARE?this.options.modeRule[s.EditorMode.COMPARE]:this.options.modeRule[s.EditorMode.PRINT],T=this.getInnerWidth(),C=this.ctxList[l];C.globalAlpha=this.zone.isMainActive()?1:r,this._clearPage(l),(!f||!g?.backgroundDisabled)&&this.background.render(C,l),f||this.area.render(C,l),a!==s.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(C,l),f||this.margin.render(C,l),this._drawFloat(C,{pageNo:l,imgDisplays:[s.ImageDisplay.FLOAT_BOTTOM]}),f||this.control.renderHighlightList(C,l);const p=i[0]?.startIndex;this.drawRow(C,{elementList:e,positionList:n,rowList:i,pageNo:l,startIndex:p,innerWidth:T,zone:s.EditorZone.MAIN}),this.getIsPagingMode()&&(c.disabled||this.header.render(C,l),u.disabled||this.pageNumber.render(C,l),d.disabled||this.footer.render(C,l)),this._drawFloat(C,{pageNo:l,imgDisplays:[s.ImageDisplay.FLOAT_TOP,s.ImageDisplay.SURROUND]}),!f&&this.search.getSearchKeyword()&&this.search.render(C,l),this.elementList.length<=1&&!this.elementList[0]?.listId&&this.placeholder.render(C),h.disabled||this.lineNumber.render(C,l),R.disabled||this.pageBorder.render(C),this.badge.render(C,l),this.isGraffitiMode()&&this.graffiti.render(C,l)}_disconnectLazyRender(){this.lazyRenderIntersectionObserver?.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const l=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[l],pageNo:l})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){const e=ie(),n=[],i=(X,O)=>{n.push({label:X,duration:ie()-O})};this.renderCount++;const l=this.mode===s.EditorMode.EDIT||this.mode===s.EditorMode.FORM||this.isPrintLikeMode()?rf([...this.getHeaderElementList(),...this.elementList,...this.getFooterElementList()]):null,r=this.applySubTemplateRuntimeState(this.getHeaderElementList(),l)||this.applySubTemplateRuntimeState(this.elementList,l)||this.applySubTemplateRuntimeState(this.getFooterElementList(),l);let{endIndex:a}=this.range.getRange();const{isCrossRowCol:c}=this.range.getRange();if(!c&&~a){const X=this.getElementList(),O=X[a],W=O?.type===s.ElementType.SUB_TEMPLATE&&O.subTemplateExpanded?s.LocationPosition.AFTER:s.LocationPosition.BEFORE,D=Hn(X,a,W);D!==a&&!de(X[D])&&(this.range.setRange(D,D),a=D)}let d;const u=this.position.getPositionContext();if(c)d=this.getOriginalElementList()[u.index];else{const X=~a?a:0,O=this.getElementList();d=Zn(O,X)}const{header:h,footer:R}=this.options,{isSubmitHistory:f=!0,isSetCursor:g=!0,isLazy:T=!0,isInit:C=!1,isSourceHistory:p=!1,isFirstRender:I=!1,isDel:m=!1}=t||{};let{isCompute:L=!0}=t||{};r&&(L=!0);let{curIndex:P}=t||{};const{traceLabel:M}=t||{},F=this.getInnerWidth(),N=this.getIsPagingMode(),Y=this.pageRowList.length;if(L){if(this.splitTdValueMap.clear(),this.tdMap.clear(),this.position.setFloatPositionList([]),N){if(!h.disabled){const H=ie();this.header.compute(),i("header.compute",H)}if(!R.disabled){const H=ie();this.footer.compute(),i("footer.compute",H)}}const X=this.getMargins(),O=this.getHeight(),E=this.header.getExtraHeight(),W=this.getMainOuterHeight(),D=X[3],U=X[0]+E,Z=bi(this.elementList),Q=ie();this.rowList=this.computeRowList({startX:D,startY:U,pageHeight:O,mainOuterHeight:W,isPagingMode:N,innerWidth:F,surroundElementList:Z,elementList:this.elementList}),i("computeRowList",Q);const v=ie();this.pageRowList=this._computePageList(),i("computePageList",v);const st=ie();this.position.computePositionList(),i("computePositionList",st);const B=ie();if(this.area.compute(),i("area.compute",B),!this.isPrintLikeMode()){const H=this.search.getSearchKeyword();if(H){const q=ie();this.search.compute(H),i("search.compute",q)}const k=ie();this.control.computeHighlightList(),i("control.computeHighlightList",k)}if(this.isGraffitiMode()){const H=ie();this.graffiti.compute(),i("graffiti.compute",H)}}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let X=0;X<this.pageRowList.length;X++)this.pageList[X]||this._createPage(X);const b=this.pageRowList.length,S=this.pageList.length;if(S>b){const X=S-b;this.ctxList.splice(b,X),this.pageList.splice(b,X).forEach(O=>O.remove())}const y=ie();if(T&&N?this._lazyRender():this._immediateRender(),i(T&&N?"lazyRender":"immediateRender",y),g){if(L&&d?.tableId){const{index:X}=u,E=this.getOriginalElementList()[X];if(d.tableId!==E?.id){const D=this.findTableChildrenElement(!0,d.tableId,d);D&&u.index!==D.originalIndex&&(u.index=D.originalIndex,u.tableId=D.table.id,u.trIndex=D.trIndex,u.trId=D.tr.id,u.tdIndex=D.tdIndex,u.tdId=D.td.id,P=D.elementIndex,this.position.setPositionContext(u),this.range.setRange(P,P),this.updateTableTool())}const W=this.getElementList();W[a]!==d&&(P=W.findIndex(D=>D===d))}P=this.setCursor(P)}else this.range.getIsSelection()&&this.cursor.focus();if(m){let X;const O=this.position.getPositionContext();X=this.range.getRange().startIndex-1,O.index=X}(f&&!I||P!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(P);const V=ie();Ti(()=>{const X=ie();this.range.setRangeStyle(),L&&this.control.getActiveControl()&&this.control.reAwakeControl(),L&&!this.isReadonly()&&this.getMode()!==s.EditorMode.FORM&&u.isTable&&this.getOriginalElementList()[u.index].type===s.ElementType.TABLE&&this.tableTool.render(),L&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),Y!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(f||p)&&!C&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"));const O=ie();mi(this.options,M||"render",O-e,[...n,{label:"nextTick.wait",duration:X-V},{label:"nextTick.callback",duration:O-X}],{isCompute:L,pageCount:this.pageRowList.length})}),g&&this.fixPosition()}fixPosition(t=!1){let e;const n=this.position.getPositionContext();if(n.isTable){const i=this.getElementList(),l=this.range.getRange().startIndex;if(t||l>=i.length){const r=this.getTd(),a=n.index+(t?-1:1),d=this.getOriginalElementList()[a];if(!d?.trList)return;e=l-i.length;for(let u=0;u<d.trList.length;u++){const h=d.trList[u],R=h.tdList.find(f=>t?r?.linkTdPrevId===f.id:r?.id===f.linkTdPrevId);if(R){n.index=a,n.trIndex=u,n.tableId=d.id,n.trId=h.id,n.tdId=R?.id,e=t?R.value.length-1:e+(R.value[0]?.type===s.ElementType.SPLIT_TAG?1:0);break}}if(this.position.setPositionContext(n),this.range.setRange(e,e),this.setCursor(e),e===0)return this.fixPosition(t);this.updateTableTool()}}return e}getInlineBackgroundControlType(t,e){if(e===void 0)return;const n=t[e],i=n?.controlId;return i?n.control?.type?n.control.type:t.find(r=>r.controlId===i&&r.originControlId===n.originControlId&&!!r.control?.type)?.control?.type:void 0}getIsHideInlineBackgroundControlCursor(t,e){if(this.options.mode!==s.EditorMode.EDIT&&this.options.mode!==s.EditorMode.FORM)return!1;const n=e!==void 0?t[e]:void 0;if(n?.controlComponent===s.ControlComponent.POSTFIX||n?.controlComponent===s.ControlComponent.POST_TEXT||n?.controlComponent===s.ControlComponent.POSTTEXTFIX||n?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)return!1;const i=this.getInlineBackgroundControlType(t,e);return!!(i&&[s.ControlType.SELECT,s.ControlType.DATE].includes(i))}setCursor(t){const e=this.position.getPositionContext(),n=this.position.getPositionList(),i=this.getElementList();if(e.isTable){const{index:r,trIndex:a,tdIndex:c}=e,u=this.getOriginalElementList()[r].trList?.[a].tdList[c].positionList;t===void 0&&u&&(t=u.length-1);const h=u?.[t];this.position.setCursorPosition(h||null)}else t!==void 0&&t>=n.length&&(t=n.length-1),this.position.setCursorPosition(t!==void 0&&t>=0?n[t]:null);let l=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const r=i[t];if(r&&Xa.includes(r.type)){l=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(r,a)}}return l&&this.getIsHideInlineBackgroundControlCursor(i,t)&&(l=!1),this.cursor.drawCursor({isShow:l}),t}submitHistory(t){const e=this.position.getPositionContext(),n=yi(this.elementList),i=yi(this.header.getElementList()),l=yi(this.footer.getElementList()),r=at(this.range.getRange()),a=this.pageNo,c=at(e),d=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(d),this.setPageNo(a),this.position.setPositionContext(at(c)),this.header.setElementList(at(i)),this.footer.setElementList(at(l)),this.elementList=at(n),this.range.replaceRange(at(r)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.macroParticle.clearInlineEditor({isSubmitHistory:!1}),this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getMacroParticle().clearInlineEditor({isSubmitHistory:!1}),this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}updateTableTool(){if(this.getMode()===s.EditorMode.FORM){this.getTableTool().dispose();return}if(this.position.getPositionContext().isTable){const t=this.position.getPositionList();t.length&&(this.setPageNo(t[0].pageNo),this.getTableTool().render())}}initTableElementIndex(t,e){t.trList?.forEach((n,i)=>{n.tdList.forEach((l,r)=>{l.tableIndex=e,l.tableId=t.id,l.trIndex=i,l.trId=n.id,l.tdIndex=r,this.tdMap.set(l.id,l)})})}clearElementEffect(t){t.trList?.forEach(e=>{e.minHeight=e.originalMinHeight??e.minHeight,delete e.originalMinHeight,e.tdList.forEach(n=>{delete n.linkTdNextId})})}updateElementTableInfo(t,e,n,i){return t.tableId=e.id,t.trId=n.id,t.tdId=i.id,t}findTableChildrenElement(t,e,n){const i=this.position.getPositionContext(),{index:l}=i,r=this.getOriginalElementList();let a=l;t&&(a=l>r.length?r.length-1:l);for(let c=a;t?c>=0:c<r.length;t?c--:c++){const d=r[c];if(d&&[d.originalId,d.id].includes(e))for(const[u,h]of d.trList.entries())for(const[R,f]of h.tdList.entries()){const g=f.value.findIndex(typeof n=="function"?n:T=>T===n);if(g>=0)return{originalIndex:c,table:d,tr:h,trIndex:u,td:f,tdIndex:R,elementIndex:g}}}}getTdById(t){return this.tdMap.get(t)}getLinkTdPrevHasValue(t){const e=this.getTdById(t);if(e)return e.value.length?e:this.getLinkTdPrevHasValue(e.linkTdPrevId)}getFirstLinkTd(t){const e=this.getTdById(t);return e?.linkTdPrevId?this.getLastLinkTd(e.linkTdPrevId):e}getLastLinkTd(t){const e=this.getTdById(t);return e?.linkTdNextId?this.getLastLinkTd(e.linkTdNextId):e}removeLinkTd(t,e){const n=this.getTdById(e);if(n){if(n.linkTdPrevId){const i=this.getTdById(n.linkTdPrevId);i&&(delete i.linkTdNextId,this.removeLinkTd(t,n.linkTdPrevId))}if(n.linkTdNextId){const i=this.getTdById(n.linkTdNextId);i&&(delete i.linkTdPrevId,this.removeLinkTd(t,n.linkTdNextId))}t[n.tableIndex].trList[n.trIndex].tdList.splice(n.tdIndex,1),this.initTableElementIndex(t[n.tableIndex],n.tableIndex)}}removeLinkTdControl(t,e){const n=this.getTdById(t);if(n){for(let i=0;i<n.value.length;i++)n.value[i].control===e&&(n.value.splice(i,1),i--);n.linkTdNextId&&this.removeLinkTdControl(n.linkTdNextId,e)}}isSplitTd(t,e){return(!!t?.originalId||!!e?.originalId)&&(t?.originalId===e?.originalId||t?.id===e?.originalId||t?.originalId===e?.id)}getSplitTdValues(t){return this.splitTdValueMap.get(t)}removeSplitTdOtherRangeElements(){const{splitTdRange:t}=this.range.getRange();if(!t)return;const{startIndex:e,endIndex:n}=t;let i=this.getTd();if(i)if((i.valueStartIndex??0)>=e){let l=-1;for(;l<0;){const r=this.getTdById(i.linkTdPrevId);if(r){l=e-(r.valueStartIndex??0);const a=Math.max(0,l);this.spliceElementList(r.value,a+1,r.value.length-a-1),i=r}else l=0}}else{let l=1;for(;l>0;){const r=this.getTdById(i.linkTdNextId);if(r){const a=r.valueStartIndex??0;l=n-(a+r.value.length);const c=Math.min(r.value.length,n-a+1);this.spliceElementList(r.value,0,c),i=r}else l=0}}}getTablesByPagingId(t,e,n){const i=[],l=[];if(t[n].pagingId===e){i.push(n),l.push(t[n]);for(let r=n-1;r>=0&&t[r].pagingId===e;r--)l.unshift(t[r]),i.push(r);for(let r=n+1;r<t.length&&t[r].pagingId===e;r++)l.push(t[r]),i.push(r)}return{list:l,startIndex:i.sort()[0]}}}class Kl{executeMode;executeCut;executeCopy;executePaste;executeSelectAll;executeBackspace;executeSetRange;executeReplaceRange;executeSetPositionContext;executeForceUpdate;executeBlur;executeHideCursor;executeUndo;executeRedo;executePainter;executeApplyPainterStyle;executeFormat;executeFont;executeButton;executeEditElementAttribute;executeTriggerControlEditAttribute;executeCopyControl;executePasteControl;executeSize;executeSizeAdd;executeSizeMinus;executeBold;executeItalic;executeUnderline;executeStrikeout;executeSuperscript;executeSubscript;executeColor;executeHighlight;executeTitle;executeList;executeRowFlex;executeVertical;executeRowMargin;executeInsertTable;executeInsertTableTopRow;executeInsertTableBottomRow;executeInsertTableLeftCol;executeInsertTableRightCol;executeDeleteTableRow;executeDeleteTableCol;executeDeleteTable;executeMergeTableCell;executeCancelMergeTableCell;executeSplitVerticalTableCell;executeSplitHorizontalTableCell;executeTableTdVerticalAlign;executeTableBorderType;executeTableBorderColor;executeTableTdBorderType;executeTableTdSlashType;executeTableTdBackgroundColor;executeTableSelectAll;executeTableProperties;executeImage;executeHyperlink;executeDeleteHyperlink;executeCancelHyperlink;executeEditHyperlink;executeSeparator;executePageBreak;executeAddWatermark;executeDeleteWatermark;executeSearch;executeSearchNavigatePre;executeSearchNavigateNext;executeReplace;executePrint;executeReplaceImageElement;executeSaveAsImageElement;executeSetImageCrop;executeSetImageCaption;executeChangeImageDisplay;executePageMode;executePageScale;executePageScaleRecovery;executePageScaleMinus;executePageScaleAdd;executePaperSize;executePaperDirection;executeSetPaperMargin;executeSetMainBadge;executeSetAreaBadge;executeInsertElementList;executeInsertArea;executeSetAreaValue;executeSetAreaProperties;executeLocationArea;executeClearGraffiti;executeAppendElementList;executeUpdateElementById;executeDeleteElementById;executeSetValue;executeRemoveControl;executeTranslate;executeSetLocale;executeLocationCatalog;executeWordTool;executeSetHTML;executeSetGroup;executeDeleteGroup;executeLocationGroup;executeSetZone;executeSetControlValue;executeSetControlValueList;executeSetControlExtension;executeSetControlExtensionList;executeSetControlProperties;executeSetControlPropertiesList;executeSetControlHighlight;executeSetControlQualityMarks;executeSetButtonContent;executeLocationControl;executeInsertControl;executeInsertTextField;executeJumpControl;executeUpdateOptions;executeSetFormModeTrace;executeInsertTitle;executeFocus;executeComputeElementListHeight;getCatalog;getImage;getPageMode;getOptions;getValue;getValueAsync;getAreaValue;getHTML;getText;getWordCount;getCursorPosition;getRemainingContentHeight;getRange;getRangeText;getRangeContext;getRangeRow;getRangeParagraph;getKeywordRangeList;getKeywordContext;getPaperMargin;getSearchNavigateInfo;getLocale;getGroupIds;getControlValue;getButtonContent;getControlList;getContainer;getTitleValue;getPositionContextByEvent;getElementById;getMacroValue;getMacroList;setMacroValue;setMacroValueList;updateMacroProperties;locationMacro;insertSubTemplate;updateSubTemplate;expandSubTemplate;collapseSubTemplate;toggleSubTemplate;constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeButton=t.buttonText.bind(t),this.executeEditElementAttribute=t.editElementAttribute.bind(t),this.executeTriggerControlEditAttribute=t.triggerControlEditAttribute.bind(t),this.executeCopyControl=t.copyControl.bind(t),this.executePasteControl=t.pasteControl.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.executeVertical=t.vertical.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeTableProperties=t.tableProperties.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeSetFormModeTrace=t.setFormModeTrace.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getPageMode=t.getPageMode.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.executeSetControlQualityMarks=t.setControlQualityMarks.bind(t),this.executeSetButtonContent=t.setButtonContent.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getButtonContent=t.getButtonContent.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeInsertTextField=t.insertTextField.bind(t),this.executeJumpControl=t.jumpControl.bind(t),this.getMacroValue=t.getMacroValue.bind(t),this.getMacroList=t.getMacroList.bind(t),this.setMacroValue=t.setMacroValue.bind(t),this.setMacroValueList=t.setMacroValueList.bind(t),this.updateMacroProperties=t.updateMacroProperties.bind(t),this.locationMacro=t.locationMacro.bind(t),this.insertSubTemplate=t.insertSubTemplate.bind(t),this.updateSubTemplate=t.updateSubTemplate.bind(t),this.expandSubTemplate=t.expandSubTemplate.bind(t),this.collapseSubTemplate=t.collapseSubTemplate.bind(t),this.toggleSubTemplate=t.toggleSubTemplate.bind(t)}}function Hf(o,t){return o===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:o===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:o===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${o}px`,height:`${t}px`}}function Af(o,t){const{width:e,height:n,direction:i=s.PaperDirection.VERTICAL}=t,l=document.createElement("iframe");l.style.visibility="hidden",l.style.position="absolute",l.style.left="0",l.style.top="0",l.style.width="0",l.style.height="0",l.style.border="none",document.body.append(l);const r=l.contentWindow,a=r.document;a.open();const c=document.createElement("div"),d=Hf(e,n);o.forEach(R=>{const f=document.createElement("img");f.style.width=i===s.PaperDirection.HORIZONTAL?d.height:d.width,f.style.height=i===s.PaperDirection.HORIZONTAL?d.width:d.height,f.src=R,c.append(f)});const u=document.createElement("style"),h=`
564
+ `,document.body.appendChild(a);const c=a.querySelector(".table-properties-modal__mask"),d=a.querySelector(".table-properties-modal__close"),u=a.querySelector(".btn-cancel"),h=a.querySelector(".btn-confirm"),R=()=>{a.remove()};c.addEventListener("click",R),d.addEventListener("click",R),u.addEventListener("click",R),h.addEventListener("click",()=>{const f=parseInt(a.querySelector("#tdPaddingTop").value)||0,g=parseInt(a.querySelector("#tdPaddingRight").value)||0,T=parseInt(a.querySelector("#tdPaddingBottom").value)||0,C=parseInt(a.querySelector("#tdPaddingLeft").value)||0;i.tdPadding=[f,g,T,C],R();const{endIndex:p}=this.range.getRange();this.draw.render({curIndex:p,isCompute:!0})})}}s.AreaMode=void 0,(function(o){o.EDIT="edit",o.READONLY="readonly",o.FORM="form"})(s.AreaMode||(s.AreaMode={}));class wf{draw;zone;range;position;options;areaInfoMap=new Map;constructor(t){this.draw=t,this.options=t.getOptions(),this.zone=t.getZone(),this.range=t.getRange(),this.position=t.getPosition()}getAreaInfo(){return this.areaInfoMap}getActiveAreaId(){if(!this.areaInfoMap.size)return null;const{startIndex:t}=this.range.getRange();return this.draw.getElementList()[t]?.areaId||null}getActiveAreaInfo(){const t=this.getActiveAreaId();return t&&this.areaInfoMap.get(t)||null}isReadonly(){const t=this.getActiveAreaInfo();if(!t?.area)return!1;switch(t.area.mode){case s.AreaMode.EDIT:return!1;case s.AreaMode.READONLY:return!0;case s.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:l,range:r}=t;if(this.zone.getZone()!==s.EditorZone.MAIN&&this.zone.setZone(s.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),r&&!this.getActiveAreaId()){const{startIndex:c,endIndex:d}=r,u=this.draw.getOriginalMainElementList();if(!u[c]||!u[d])return null;this.range.setRange(r.startIndex,r.endIndex)}else if(l===s.LocationPosition.BEFORE)this.range.setRange(0,0);else{const d=this.draw.getOriginalMainElementList().length-1;this.range.setRange(d,d)}const a=e||mt();return this.draw.insertElementList([{type:s.ElementType.AREA,value:"",areaId:a,valueList:n,area:at(i)}]),a}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const l of this.areaInfoMap){const{area:r,positionList:a}=l[1];if(r?.hide||!r?.backgroundColor&&!r?.borderColor&&!r?.placeholder)continue;const c=a.filter(g=>g.pageNo===e);if(!c.length)continue;t.translate(.5,.5);const d=c[0],u=c[c.length-1],h=n[3],R=Math.ceil(d.coordinate.leftTop[1]),f=Math.ceil(u.coordinate.rightBottom[1]-R);t.textBaseline="middle",r.backgroundColor&&(t.fillStyle=r.backgroundColor,t.fillRect(h,R,i,f)),r.borderColor&&(t.strokeStyle=r.borderColor,t.strokeRect(h,R,i,f)),r.placeholder&&a.length<=1&&new Zl(this.draw).render(t,{placeholder:{...xs,...r.placeholder},startY:d.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],l=i.areaId;if(l){const r=this.areaInfoMap.get(l);r?(r.elementList.push(i),r.positionList.push(e[n])):this.areaInfoMap.set(l,{id:l,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:Yt(n.elementList)}:null}getContextByAreaId(t,e){const n=this.draw.getOriginalMainElementList();for(let i=0;i<n.length;i++){const l=n[i];if(e?.position===s.LocationPosition.OUTER_BEFORE){if(n[i+1]?.areaId!==t)continue}else if(e?.position===s.LocationPosition.AFTER){if(!(l.areaId===t&&n[i+1]?.areaId!==t))continue}else if(e?.position===s.LocationPosition.OUTER_AFTER){if(!(l.areaId!==t&&n[i-1]?.areaId===t))continue}else if(l.areaId!==t)continue;const r=this.position.getOriginalMainPositionList();return{range:{startIndex:i,endIndex:i},elementPosition:r[i]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const l=["top","hide"];Object.entries(t.properties).forEach(([r,a])=>{if(ws(a))return;const c=r;n.area[c]=a,l.includes(c)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,l=this.draw.getOriginalMainElementList(),r=t.value;qt([{type:s.ElementType.AREA,value:"",valueList:r,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(l,i[0].index,i.length,r,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class Zf{draw;options;imageCache;mainBadge;areaBadgeMap;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,i,l,r){if(this.imageCache.has(r)){const a=this.imageCache.get(r);t.drawImage(a,e,n,i,l)}else{const a=new Image;a.setAttribute("crossOrigin","Anonymous"),a.src=r,a.onload=()=>{this.imageCache.set(r,a),t.drawImage(a,e,n,i,l)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:l,top:r,width:a,height:c,value:d}=this.mainBadge,u=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),h=(l||i.left)*n,R=(r||i.top)*n+u;this._drawImage(t,h,R,a*n,c*n,d)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:l}=this.options;for(const r of n){const{positionList:a}=r[1],c=a[0];if(c.pageNo!==e)continue;const d=this.areaBadgeMap.get(r[0]);if(!d)continue;const{left:u,top:h,width:R,height:f,value:g}=d,T=(u||l.left)*i,C=(h||l.top)*i+c.coordinate.leftTop[1];this._drawImage(t,T,C,R*i,f*i,g)}}}}}class vf{draw;options;data;pageContainer;isDrawing=!1;startStroke=null;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const l=this.draw.getPageNo();let r=this.data.find(d=>d.pageNo===l);if(this.startStroke&&(r||(r={pageNo:l,strokes:[]},this.data.push(r)),r.strokes.push(this.startStroke),this.startStroke=null),!r?.strokes?.length)return;const{scale:a}=this.options;r.strokes[r.strokes.length-1].points.push(e/a,n/a),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){const n=this.data.find(a=>a.pageNo===e)?.strokes;if(!n?.length)return;const{graffiti:{defaultLineColor:i,defaultLineWidth:l},scale:r}=this.options;t.save();for(let a=0;a<n.length;a++){const c=n[a];t.beginPath(),t.strokeStyle=c.lineColor||i,t.lineWidth=(c.lineWidth||l)*r,t.moveTo(c.points[0]*r,c.points[1]*r);for(let d=2;d<c.points.length;d+=2)t.lineTo(c.points[d]*r,c.points[d+1]*r);t.stroke()}t.restore()}}const vl=1024,Qf=['[aria-modal="true"]','[role="dialog"]','[data-overlay-active="true"]',".ant-modal-root",".ant-modal-wrap",".ant-modal",".ant-drawer",".ant-select-dropdown",".ant-picker-dropdown",".ant-dropdown",".ant-popover",".ant-tooltip",".ant-cascader-dropdown",".ant-mentions-dropdown"].join(", ");function Ql(o,t,e){for(let n=0;n<e.length;n+=vl){const i=e.slice(n,n+vl);o.splice(t+n,0,...i)}}class Kf{container;pageContainer;pageList;ctxList;pageNo;renderCount;pagePixelRatio;mode;options;position;zone;elementList;listener;eventBus;override;i18n;canvasEvent;globalEvent;cursor;range;margin;background;badge;search;group;area;underline;strikeout;highlight;historyManager;previewer;imageParticle;laTexParticle;textParticle;tableParticle;tableTool;tableOperate;pageNumber;lineNumber;waterMark;placeholder;header;footer;hyperlinkParticle;labelParticle;macroParticle;dateParticle;separatorParticle;pageBreakParticle;superscriptParticle;subscriptParticle;checkboxParticle;radioParticle;menstrualHistoryParticle;fetalHeartPositionParticle;toothPositionParticle;blockParticle;listParticle;lineBreakParticle;whiteSpaceParticle;control;pageBorder;workerManager;scrollObserver;selectionObserver;imageObserver;graffiti;command;interactionPaused;overlayActiveCount;globalShortcutSuspended;LETTER_REG;WORD_LIKE_REG;rowList;pageRowList;painterStyle;painterOptions;visiblePageNoList;intersectionPageNo;lazyRenderIntersectionObserver;printModeData;readonlyModeData;splitTdValueMap=new Map;tdMap=new Map;constructor(t,e,n,i,l,r){this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.renderCount=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=n.main,this.listener=i,this.eventBus=l,this.override=r,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new Pf(e.locale),this.historyManager=new Md(this),this.position=new Od(this),this.zone=new Sf(this),this.range=new Sd(this),this.margin=new Xd(this),this.background=new Dd(this),this.badge=new Zf(this),this.search=new Nd(this),this.group=new Xf(this),this.area=new wf(this),this.underline=new bd(this),this.strikeout=new yd(this),this.highlight=new Fd(this),this.previewer=new Cf(this),this.imageParticle=new Ks(this),this.laTexParticle=new _s(this),this.textParticle=new Vd(this),this.tableParticle=new Ud(this),this.tableTool=new wd(this),this.tableOperate=new Uf(this),this.pageNumber=new _n(this),this.lineNumber=new bf(this),this.waterMark=new kd(this),this.placeholder=new Zl(this),this.header=new Kd(this,n.header),this.footer=new Df(this,n.footer),this.hyperlinkParticle=new Zd(this),this.labelParticle=new vd(this),this.macroParticle=new Qd(this),this.dateParticle=new pf(this),this.separatorParticle=new _d(this),this.pageBreakParticle=new Bd(this),this.superscriptParticle=new Hd,this.subscriptParticle=new Ad,this.checkboxParticle=new af(this),this.radioParticle=new cf(this),this.menstrualHistoryParticle=new df(this),this.fetalHeartPositionParticle=new uf(this),this.toothPositionParticle=new Rf(this),this.blockParticle=new Ef(this),this.listParticle=new Ff(this),this.lineBreakParticle=new po(this),this.whiteSpaceParticle=new Nf(this),this.control=new nf(this),this.pageBorder=new Vf(this),this.graffiti=new vf(this,n.graffiti),this.scrollObserver=new Wd(this),this.selectionObserver=new Yd(this),this.imageObserver=new Mf,new yf(this),this.canvasEvent=new Ld(this),this.cursor=new wc(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new Pd(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new mf(this),new Yf(this);const{letterClass:a}=e;this.LETTER_REG=new RegExp(`[${a.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${a.map(c=>`[^${c}][${c}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.readonlyModeData=null,this.interactionPaused=!1,this.overlayActiveCount=0,this.globalShortcutSuspended=!1,this.isPrintLikeMode()&&this.setPrintData(),this.mode===s.EditorMode.READONLY&&this.setReadonlyData(),this.mode,s.EditorMode.FORM,this.render({isInit:!0,isSetCursor:!1,isFirstRender:!0})}setPrintData(){this.printModeData||(this.printModeData=at({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const t=at(this.printModeData);["header","main","footer"].forEach(l=>{t[l]=this.control.filterAssistElement(t[l])});const n=t,i=this.removeStrikeout(n);t.main=i.main.filter(l=>!l.strikeout),this.setEditorData(i)}removeStrikeout(t){if(Array.isArray(t))return t.map(e=>this.removeStrikeout(e)).filter(e=>!(e&&typeof e=="object"&&"strikeout"in e&&e.strikeout===!0));if(t&&typeof t=="object"){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this.removeStrikeout(t[n]));return e}return t}clearPrintData(){this.printModeData&&(this.setEditorData(at(this.printModeData)),this.printModeData=null)}setReadonlyData(){this.readonlyModeData||(this.readonlyModeData=at({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const t=at(this.readonlyModeData);["header","main","footer"].forEach(n=>{const i=Yt(t[n],{editorOptions:this.options});t[n]=wn(i),qt(t[n],{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData(t)}clearReadonlyData(){if(this.readonlyModeData){const t=at(this.readonlyModeData);this.readonlyModeData=null,this.setEditorData(t)}}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}isPrintLikeMode(t=this.mode){return t===s.EditorMode.PRINT||t===s.EditorMode.COMPARE}getIsButtonRowStartPrefix(t,e,n){const i=t[e];if(this.isPrintLikeMode()||i.control?.type!==s.ControlType.BUTTON||i.control.buttonText||i.control.minWidth||i.controlComponent!==s.ControlComponent.PREFIX||!i.value)return!1;const l=t[e+1];return!l||l.controlId!==i.controlId||(l.originControlId||null)!==(i.originControlId||null)||l.controlComponent!==s.ControlComponent.VALUE||l.buttonValueLayout?!1:n.elementList.every(r=>r.value===K||de(r))}getElementLayoutWidth(t){return t.control?.type===s.ControlType.BUTTON&&!t.control.buttonText&&t.controlComponent===s.ControlComponent.PREFIX&&t.left&&t.left<0?Math.max(0,t.metrics.width+t.left):t.metrics.width}isContentReadonly(){if(this.mode===s.EditorMode.COMPARE)return!0;if(this.area.getActiveAreaInfo()?.area?.mode)return this.area.isReadonly();switch(this.mode){case s.EditorMode.DESIGN:return!1;case s.EditorMode.READONLY:case s.EditorMode.PRINT:case s.EditorMode.GRAFFITI:return!0;case s.EditorMode.FORM:if(this.control.getIsRangeWithinControl()){const t=this.getElementList(),{startIndex:e}=this.range.getRange(),n=t[e];if(n?.control?.type===s.ControlType.TEXTFIELD){const i=n.controlId;if(i){for(let l=0;l<t.length;l++)if(t[l].originControlId===i&&t[l].controlId!==i)return!1}return!0}}return!this.control.getIsRangeWithinControl();default:return!1}}isSelectionDisabled(){return this.mode===s.EditorMode.COMPARE?!1:this.area.getActiveAreaInfo()?.area?.mode?this.area.isReadonly():this.mode===s.EditorMode.READONLY||this.mode===s.EditorMode.PRINT||this.mode===s.EditorMode.GRAFFITI}setMode(t){if(this.mode===t)return;const e=this.mode;this.macroParticle.clearInlineEditor({isSubmitHistory:!1}),this.mode=t,this.options.mode=t;const n=this.isPrintLikeMode(t);this.isPrintLikeMode(e)&&this.clearPrintData(),e===s.EditorMode.READONLY&&t!==s.EditorMode.READONLY&&this.clearReadonlyData(),n&&!this.printModeData&&(this.printModeData=at({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const i=new Map,l=a=>{a.forEach(c=>{c.controlId&&(c.controlComponent==="value"&&i.set(c.controlId,!0),c.checked&&i.set(c.controlId,!0))})};l(this.elementList),this.elementList.forEach(a=>{a.type==="table"&&a.trList?.forEach(c=>{c.tdList?.forEach(d=>{l(d.value)})})});const r=a=>{a.forEach(c=>{if(!(!c.control&&!c.controlId)&&(c.controlComponent==="value"&&c.strikeout&&(n?c.hide=!0:c.hide=!1),!!c.control&&!(c.type!=="control"&&c.control.type!=="button"))){if(c.control.type==="TextField"&&(c.controlComponent==="placeholder"||c.controlComponent==="preTextFix"||c.controlComponent==="preTextFixText"||c.controlComponent==="postTextFix"||c.controlComponent==="postTextFixText"||c.controlComponent==="textFixLabel")&&(t===s.EditorMode.EDIT?c.hide=!1:c.hide=!0),c.control.type==="text"&&(c.controlComponent==="placeholder"||c.controlComponent==="prefix"||c.controlComponent==="postfix")&&(t===s.EditorMode.EDIT||t===s.EditorMode.FORM?c.hide=!1:c.hide=!0),c.control.type==="number"||c.control.type==="select"||c.control.type==="date"||c.control.type==="checkbox"||c.control.type==="radio"){if(c.controlComponent==="placeholder"||c.controlComponent==="prefix"||c.controlComponent==="postfix"){const u=i.get(c.controlId);c.control.type==="select"&&n||n&&!u?c.hide=!0:c.hide=!1}c.control.type==="number"&&c.controlComponent==="value"&&(n&&c.strikeout?c.hide=!0:!n&&c.strikeout&&(c.hide=!1))}c.control.type==="button"&&(c.hide=!1,c.control.hide=!1),c.control.type==="menstrualHistory"&&(c.controlComponent==="prefix"||c.controlComponent==="postfix")&&(n?c.hide=!0:c.hide=!1)}})};r(this.elementList),this.elementList.forEach(a=>{a.type==="table"&&a.trList.forEach(c=>{c.tdList.forEach(d=>{r(d.value)})})}),t===s.EditorMode.FORM?(this.elementList.filter(a=>a.type==="control").map(a=>{a.control?.type==="button"&&(a.controlComponent==="prefix"||a.controlComponent==="postfix"?(a.color="#1677FF",a.highlight="transparent"):a.controlComponent==="value"&&(a.color=this.options.defaultColor,a.highlight="transparent"))}),this.hideTextFieldWhitespace(this.elementList,!0),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):t===s.EditorMode.EDIT?(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!1,!0)),n?(this.elementList.filter(a=>a?.control?.type==="button").map(a=>{(a?.controlComponent==="prefix"||a?.controlComponent==="postfix")&&(a.color="transparent",a.highlight="transparent"),a?.controlComponent==="value"&&!a.control.buttonText&&(a.color=this.options.defaultColor,a.highlight="transparent")}),this.setPrintData()):(this.clearPrintData(),this.elementList.filter(a=>a?.control?.type==="button").map(a=>{(a?.controlComponent==="prefix"||a?.controlComponent==="postfix")&&(a.color="#1677FF",a.highlight="transparent"),a?.controlComponent==="value"&&!a.control.buttonText&&(a.color=this.options.defaultColor,a.highlight="transparent"),a?.type==="text"&&a.control.buttonText&&(a.color="#000"),a?.type==="control"&&a?.controlComponent==="value"&&a.control.buttonText&&(a.color="#000",a.highlight="transparent")})),t===s.EditorMode.READONLY&&this.setReadonlyData(),this.clearSideEffect(),this.control.destroyControl(),this.range.clearRange(),this.render({isSetCursor:!1,isSubmitHistory:!1})}hideTextFieldWhitespace(t,e){const n=a=>a?/^[\s\u00A0\u2000-\u200B\u3000\n\r\t]+$/.test(a):!1,i=(a,c)=>{for(let d=0;d<a.length;d++){const u=a[d];if(u.type===s.ElementType.TABLE&&u.trList)for(const h of u.trList)for(const R of h.tdList)i(R.value,c);u.originControlId&&u.controlId&&u.originControlId!==u.controlId&&c.add(u.originControlId)}},l=new Set;e&&i(t,l),(a=>{for(let c=0;c<a.length;c++){const d=a[c];if(d.type===s.ElementType.TABLE&&d.trList)for(const u of d.trList)for(const h of u.tdList)this.hideTextFieldWhitespace(h.value,e);d.control?.type===s.ControlType.TEXTFIELD&&d.controlComponent===s.ControlComponent.VALUE&&n(d.value)&&(d.controlId&&l.has(d.controlId)?d.hide=!1:d.hide=e)}})(t)}getSubTemplateRuntimeEndIndex(t,e,n){let i=e+1;for(;i<t.length&&t[i].subTemplateParentId===n;)i++;return i}syncSubTemplateExpandedState(t,e,n,i,l){let r=!1;const a=this.getSubTemplateRuntimeEndIndex(t,e,n.id);if(i&&!n.subTemplateContent?.length&&(i=!1),n.subTemplateExpanded!==i&&(n.subTemplateExpanded=i,r=!0),!!n.hide!==l&&(n.hide=l,r=!0),!i)return a>e+1&&(t.splice(e+1,a-e-1),r=!0),r;if(a===e+1){const c=at(n.subTemplateContent||[]);qt(c,{isHandleFirstElement:!1,editorOptions:this.options});for(let d=0;d<c.length;d++)c[d].subTemplateParentId=n.id;c.length&&(t.splice(e+1,0,...c),r=!0)}return r}applySubTemplateRuntimeState(t,e){const n=i=>{let l=!1,r=0;for(;r<i.length;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE){const c=!!a.subTemplateConditions?.length;if(this.mode===s.EditorMode.EDIT&&c)l=this.syncSubTemplateExpandedState(i,r,a,!0,!0)||l;else if((this.mode===s.EditorMode.FORM||this.isPrintLikeMode())&&c){const d=e?lf(a.subTemplateConditions,e,a.subTemplateRelation):!1;l=this.syncSubTemplateExpandedState(i,r,a,d,!0)||l}else this.mode!==s.EditorMode.FORM&&!this.isPrintLikeMode()&&(l=this.syncSubTemplateExpandedState(i,r,a,!1,!1)||l)}if(a.valueList?.length&&(l=n(a.valueList)||l),a.control?.value?.length&&(l=n(a.control.value)||l),a.type===s.ElementType.TABLE&&a.trList?.length)for(let c=0;c<a.trList.length;c++){const d=a.trList[c];for(let u=0;u<d.tdList.length;u++)l=n(d.tdList[u].value)||l}r++}return l};return n(t)}updateTextFieldPlaceholderVisibility(t,e,n){const i=[s.ControlType.TEXT,s.ControlType.TEXTFIELD,s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.CHECKBOX,s.ControlType.RADIO,s.ControlType.NUMBER];(r=>{let a=0;for(;a<r.length;){const c=r[a];if(c.type===s.ElementType.TABLE&&c.trList)for(const d of c.trList)for(const u of d.tdList)this.updateTextFieldPlaceholderVisibility(u.value,e,n);if(c.control?.type&&i.includes(c.control.type)&&(c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PRE_TEXT)){const d=c.controlId,u=c.control.type;let h=!1,R=!1,f=!1;const g=[],T=[],C=[];let p=-1,I=a;for(;I<r.length;){const m=r[I];if(m.controlId!==d){const L=m.controlId;let P=u===s.ControlType.TEXT,M=I;if(P)for(;M<r.length&&r[M].controlId===L;)M++;else for(;M<r.length;){const F=r[M];if(F.controlId!==L)break;F.controlComponent===s.ControlComponent.VALUE&&(F.value&&F.value.trim()||F.type===s.ElementType.MENSTRUAL_HISTORY||F.type===s.ElementType.FETAL_HEART_POSITION||F.type===s.ElementType.TOOTH_POSITION||F.type===s.ElementType.MACRO||F.type===s.ElementType.CUSTOM_MACRO)&&(P=!0),M++}P&&(R=!0),I=M;continue}if((m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&T.push(I),m.controlComponent===s.ControlComponent.VALUE&&m.value&&m.value.trim()&&(h=!0),m.controlComponent===s.ControlComponent.VALUE&&(m.type===s.ElementType.MENSTRUAL_HISTORY||m.type===s.ElementType.FETAL_HEART_POSITION||m.type===s.ElementType.TOOTH_POSITION||m.type===s.ElementType.MACRO||m.type===s.ElementType.CUSTOM_MACRO)&&(h=!0),m.controlComponent===s.ControlComponent.VALUE&&m.control&&m.control.type!==u&&(R=!0),m.controlComponent===s.ControlComponent.PLACEHOLDER&&(f=!0,g.push(I)),m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT){C.push(I),p=I;break}I++}if(h||R){if(f&&g.length>0)for(const m of g)r[m].hide=!0}else if(f&&g.length>0)for(const m of g)r[m].hide=!e;else e&&c.control?.placeholder&&(p>0?this.control.addPlaceholder(p-1):this.control.addPlaceholder(a));if(n)if(e&&(h||R)){for(const m of T)r[m].hide=!0;for(const m of C)r[m].hide=!0}else if(e){for(const m of T)r[m].hide=!1;for(const m of C)r[m].hide=!1}else{for(const m of T)r[m].hide=!0;for(const m of C)r[m].hide=!0}else{for(const m of T)r[m].hide=!1;for(const m of C)r[m].hide=!1}a=I}a++}})(t)}isReadonly(){return this.isContentReadonly()}isDisabled(){if(this.mode===s.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if(this.getTd()?.disabled)return!0;if(t===e){const l=n[t],r=n[t+1];return!!(l?.title?.disabled&&r?.title?.disabled&&l.titleId===r.titleId||l?.control?.disabled&&r?.control?.disabled&&l.controlId===r.controlId)}return n.slice(t+1,e+1).some(l=>l.title?.disabled||l.control?.disabled)}isDesignMode(){return this.mode===s.EditorMode.DESIGN}isPrintMode(){return this.mode===s.EditorMode.PRINT}isGraffitiMode(){return this.mode===s.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===s.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===s.PaperDirection.VERTICAL?n:e}getWidth(){return Math.floor(this.getOriginalWidth()*this.options.scale)}getHeight(){return Math.floor(this.getOriginalHeight()*this.options.scale)}getMainHeight(){return this.getHeight()-this.getMainOuterHeight()}getMainOuterHeight(){const t=this.getMargins(),e=this.header.getExtraHeight(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}getCanvasWidth(t=-1){return this.getPage(t).width}getCanvasHeight(t=-1){return this.getPage(t).height}getInnerWidth(){const t=this.getWidth(),e=this.getMargins();return t-e[1]-e[3]}getOriginalInnerWidth(){const t=this.getOriginalWidth(),e=this.getOriginalMargins();return t-e[1]-e[3]}getContextInnerWidth(){const t=this.position.getPositionContext();if(t.isTable){const{index:e,trIndex:n,tdIndex:i}=t,r=this.getOriginalElementList()[e],a=r.trList[n].tdList[i],c=this.getTdPadding(r);return a.width-c[1]-c[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===s.PaperDirection.VERTICAL?t:[t[1],t[2],t[3],t[0]]}getPageGap(){return this.options.pageGap*this.options.scale}getOriginalPageGap(){return this.options.pageGap}getPageNumberBottom(){const{pageNumber:{bottom:t},scale:e}=this.options;return t*e}getMarginIndicatorSize(){return this.options.marginIndicatorSize*this.options.scale}getDefaultBasicRowMarginHeight(){return this.options.defaultBasicRowMarginHeight*this.options.scale}getHighlightMarginHeight(){return this.options.highlightMarginHeight*this.options.scale}getTdPadding(t){const{table:{tdPadding:e},scale:n}=this.options;return(t?.tdPadding||e).map(l=>l*n)}getContainer(){return this.container}getPageContainer(){return this.pageContainer}getEventTarget(t){return t instanceof Element?t:t instanceof Node?t.parentElement:null}isTargetInsideEditor(t){const e=this.getEventTarget(t);return e?this.container.contains(e)?!0:!!bs(e,n=>!!n&&n.nodeType===1&&!!n.getAttribute(Ze)):!1}isTargetInsideExternalOverlay(t){const e=this.getEventTarget(t);return!e||this.isTargetInsideEditor(e)?!1:!!e.closest(Qf)}pauseInteraction(){this.interactionPaused=!0,this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect()}resumeInteraction(){this.interactionPaused=!1}setOverlayActive(t){this.overlayActiveCount=t?1:0,t&&(this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect())}suspendGlobalShortcut(t){this.globalShortcutSuspended=t}isInteractionSuspended(){return this.interactionPaused||this.overlayActiveCount>0}isGlobalShortcutActive(){return!this.globalShortcutSuspended&&!this.isInteractionSuspended()}getVisiblePageNoList(){return this.visiblePageNoList}setVisiblePageNoList(t){this.visiblePageNoList=t,this.listener.visiblePageNoListChange&&this.listener.visiblePageNoListChange(this.visiblePageNoList),this.eventBus.isSubscribe("visiblePageNoListChange")&&this.eventBus.emit("visiblePageNoListChange",this.visiblePageNoList)}getIntersectionPageNo(){return this.intersectionPageNo}setIntersectionPageNo(t){this.intersectionPageNo=t,this.listener.intersectionPageNoChange&&this.listener.intersectionPageNoChange(this.intersectionPageNo),this.eventBus.isSubscribe("intersectionPageNoChange")&&this.eventBus.emit("intersectionPageNoChange",this.intersectionPageNo)}getPageNo(){return this.pageNo}setPageNo(t){this.pageNo=t}getRenderCount(){return this.renderCount}getPage(t=-1){return this.pageList[~t?t:this.pageNo]}getPageList(){return this.pageList}getPageCount(){return this.pageList.length}getTableRowList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:l}=e;return t[n].trList[i].tdList[l].rowList}getOriginalRowList(){const t=this.getZone();return t.isHeaderActive()?this.header.getRowList():t.isFooterActive()?this.footer.getRowList():this.rowList}getRowList(){return this.position.getPositionContext().isTable?this.getTableRowList(this.getOriginalElementList()):this.getOriginalRowList()}getPageRowList(){return this.pageRowList}getCtx(){return this.ctxList[this.pageNo]}getOptions(){return this.options}getSearch(){return this.search}getGroup(){return this.group}getArea(){return this.area}getBadge(){return this.badge}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getLineBreakParticle(){return this.lineBreakParticle}getTextParticle(){return this.textParticle}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:l}=e;return t[n]?.trList?.[i].tdList[l].value||[]}getElementList(){const t=this.position.getPositionContext(),e=this.getOriginalElementList();return t.isTable?this.getTableElementList(e):e}getMainElementList(){return this.position.getPositionContext().isTable?this.getTableElementList(this.elementList):this.elementList}getOriginalElementList(){const t=this.getZone();return t.isHeaderActive()?this.getHeaderElementList():t.isFooterActive()?this.getFooterElementList():this.elementList}getOriginalMainElementList(){return this.elementList}getFooterElementList(){return this.footer.getElementList()}getTd(){const t=this.position.getPositionContext(),{index:e,trIndex:n,tdIndex:i,isTable:l}=t;return l?this.getOriginalElementList()[e].trList[n].tdList[i]:null}getTdByPosition(t){const{index:e,trIndex:n,tdIndex:i,isTable:l}=t;return l?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementTextField(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.getElementList(),{isSubmitHistory:r=!0}=e;qt(t,{isHandleFirstElement:!1,editorOptions:this.options});let a=-1,c=this.control.getActiveControl();if(!c&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),c=this.control.getActiveControl()),c&&this.control.getIsRangeWithinControl()){const d=n===i,u=n+1;d||this.newSpliceElementList(l,u,i-n),this.newSpliceElementList(l,u,0,t),a=n+t.length}else{const d=n===i,u=n+1;d||this.newSpliceElementList(l,u,i-n),this.newSpliceElementList(l,u,0,t),a=n+t.length;const h=l[u-1];t[0].listId&&h&&!h.listId&&h?.value===K&&(!h.type||h.type===s.ElementType.TEXTFIELD)&&(l.splice(n,1),a-=1)}this.control.destroyControl(),~a&&(this.range.setRange(a,a),this.render({curIndex:a,isSubmitHistory:r}))}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:l=!0}=e;qt(t,{isHandleFirstElement:!1,editorOptions:this.options});let r=-1,a=this.control.getActiveControl();if(!a&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),a=this.control.getActiveControl()),a&&this.control.getIsRangeWithinControl()){const c=this.getElementList(),d=n===i,u=n+1,h=c[n],R=c[u],f=M=>!!(M&&(M.controlComponent===s.ControlComponent.POSTFIX||M.controlComponent===s.ControlComponent.POST_TEXT||M.controlComponent===s.ControlComponent.POSTTEXTFIX||M.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)),g=M=>!!(M&&(M.controlComponent===s.ControlComponent.PREFIX||M.controlComponent===s.ControlComponent.PRE_TEXT||M.controlComponent===s.ControlComponent.PRETEXTFIX||M.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)),T=M=>{if(M)return c.find(F=>F.controlId===M&&!F.originControlId&&!!F.control?.type)},C=h?.originControlId&&R?.originControlId===h.originControlId&&h.controlId&&R.controlId&&h.controlId!==R.controlId&&f(h)&&g(R)?T(h.originControlId):void 0,p=C?.control?.type===s.ControlType.TEXTFIELD,I=!!(h?.originControlId&&f(h)&&R?.controlId===h.originControlId&&!R.originControlId&&R.control?.type===s.ControlType.TEXTFIELD&&f(R)),m=!!(h?.originControlId&&f(h)&&R?.controlId===h.originControlId&&!R.originControlId&&R.control?.type===s.ControlType.TEXTFIELD&&R.controlComponent===s.ControlComponent.VALUE);if(h?.controlComponent===s.ControlComponent.PRE_TEXT||h?.controlComponent===s.ControlComponent.POST_TEXT||h?.controlComponent===s.ControlComponent.PREFIX||h?.controlComponent===s.ControlComponent.POSTFIX)for(let M=0;M<t.length;M++)t[M].control||(t[M].color=this.options.defaultColor);d&&!I&&!m&&(c[n]?.control?.type===s.ControlType.TEXTFIELD||c[n]?.control?.type===s.ControlType.TEXT)&&this.control.removePlaceholder(n),d||this.newSpliceElementList(c,u,i-n);const P=I||m||p?h.originControlId:c[n]?.controlId||c[n-1]?.controlId||c[n+1]?.controlId;for(let M=0;M<t.length;M++){if((I||m||p)&&!t[M].control&&(t[M].controlId=P,t[M].control=p?C?.control:R.control,t[M].controlComponent=s.ControlComponent.VALUE,delete t[M].originControlId),t[M]?.control?.type=="button"&&!t[M]?.control?.buttonText&&(t[M]?.controlComponent==="prefix"||t[M]?.controlComponent==="postfix"?(t[M].color="#1677FF",t[M].highlight="transparent"):(t[M].color=this.options.defaultColor,t[M].highlight="transparent")),t[M]?.type===s.ElementType.MENSTRUAL_HISTORY||t[M]?.type===s.ElementType.FETAL_HEART_POSITION||t[M]?.type===s.ElementType.TOOTH_POSITION||t[M]?.type===s.ElementType.MACRO||t[M]?.type===s.ElementType.CUSTOM_MACRO||t[M]?.type===s.ElementType.REUSABLE_ITEM||t[M]?.type===s.ElementType.SUB_TEMPLATE||t[M]?.type===s.ElementType.SPECIAL_SYMBOLS){t[M].controlComponent=s.ControlComponent.VALUE;let F=c[n]?.controlId;F||(F=c[n-1]?.controlId),F||(F=c[n+1]?.controlId),!t[M].controlId&&F&&(t[M].controlId=F)}P&&t[M]?.control&&t[M].controlId&&t[M].controlId!==P&&(t[M].originControlId=P)}this.newSpliceElementList(c,u,0,t),r=n+t.length}else{const c=this.getElementList(),d=n===i,u=n+1;if(c[u]?.control?.type=="TextField"||c[n]?.control?.type=="TextField"){d||this.newSpliceElementList(c,u,i-n);for(let h=0;h<t.length;h++)if(t[h]?.type===s.ElementType.MENSTRUAL_HISTORY||t[h]?.type===s.ElementType.FETAL_HEART_POSITION||t[h]?.type===s.ElementType.TOOTH_POSITION||t[h]?.type===s.ElementType.MACRO||t[h]?.type===s.ElementType.CUSTOM_MACRO||t[h]?.type===s.ElementType.REUSABLE_ITEM||t[h]?.type===s.ElementType.SUB_TEMPLATE||t[h]?.type===s.ElementType.SPECIAL_SYMBOLS){t[h].controlComponent=s.ControlComponent.VALUE;const R=c[n]?.controlId||c[u]?.controlId;!t[h].controlId&&R&&(t[h].controlId=R)}this.newSpliceElementList(c,u,0,t),r=n+t.length}else{d||this.spliceElementList(c,u,i-n);for(let R=0;R<t.length;R++)t[R]?.control?.type=="button"&&!t[R]?.control?.buttonText&&(t[R]?.controlComponent==="prefix"||t[R]?.controlComponent==="postfix"?(t[R].color="#1677FF",t[R].highlight="transparent"):(t[R].color=this.options.defaultColor,t[R].highlight="transparent"));this.spliceElementList(c,u,0,t),r=n+t.length;const h=c[u-1];t[0].listId&&h&&!h.listId&&h?.value===K&&(!h.type||h.type===s.ElementType.TEXT)&&(c.splice(n,1),r-=1)}}~r&&(this.range.setRange(r,r),this.render({curIndex:r,isSubmitHistory:l}))}appendElementList(t,e={}){if(!t.length)return;qt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:l=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:l})}spliceElementList(t,e,n,i,l){const{isIgnoreDeletedRule:r=!1}=l||{},{group:a,modeRule:c}=this.options;if(n>0){const d=e+n,h=t[d]?.listId;if(h&&t[e-1]?.listId!==h){let R=d;for(;R<t.length;){const f=t[R];if(f.listId!==h||f.value===K)break;delete f.listId,delete f.listType,delete f.listStyle,R++}}if(!r&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const R=this.getTd()?.deletable;let f=d-1;for(;f>=e;){const g=t[f];(de(g)||R!==!1&&g?.control?.deletable!==!1&&(!g.controlId||this.mode!==s.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&g?.title?.deletable!==!1&&(a.deletable!==!1||!g.groupIds?.length)&&(g?.area?.deletable!==!1||g?.areaIndex!==0))&&t.splice(f,1),f--}}else t.splice(e,n)}if(i?.length){let d=t[e];for(let u=0;u<i.length;u++){const h=i[u].value===K&&(d?.controlComponent===s.ControlComponent.PREFIX||d?.controlComponent===s.ControlComponent.PRE_TEXT||d?.controlComponent===s.ControlComponent.PRETEXTFIX||d?.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT);!i[u].controlComponent&&d?.controlComponent&&!h&&(i[u].controlId=d.controlId,i[u].control=d.control,i[u].controlComponent=d.controlComponent),d=i[u]}Ql(t,e,i)}}newSpliceElementList(t,e,n,i,l){const{isIgnoreDeletedRule:r=!1}=l||{},{group:a,modeRule:c}=this.options;if(n>0){const u=e+n,R=t[u]?.listId;if(R&&t[e-1]?.listId!==R){let f=u;for(;f<t.length;){const g=t[f];if(g.listId!==R||g.value===K)break;delete g.listId,delete g.listType,delete g.listStyle,f++}}if(!r&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const f=this.getTd()?.deletable;let g=u-1;for(;g>=e;){const T=t[g];(de(T)||f!==!1&&T?.control?.deletable!==!1&&(!T.controlId||this.mode!==s.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&T?.title?.deletable!==!1&&(a.deletable!==!1||!T.groupIds?.length)&&(T?.area?.deletable!==!1||T?.areaIndex!==0))&&t.splice(g,1),g--}}else t.splice(e,n)}const d=t[e]?.controlId;if(i?.length){for(let u=0;u<i.length;u++)d&&i[u].controlId!==d&&(i[u].originControlId=d);Ql(t,e,i)}}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}getTableTool(){return this.tableTool}getTableOperate(){return this.tableOperate}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getMacroParticle(){return this.macroParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getMenstrualHistoryParticle(){return this.menstrualHistoryParticle}getFetalHeartPositionParticle(){return this.fetalHeartPositionParticle}getToothPositionParticle(){return this.toothPositionParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}setCommand(t){this.command=t}getCommand(){return this.command}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,l=!!n&&i!==n;l&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const r=this.pageList.map(a=>a.toDataURL());return e&&this.setPagePixelRatio(null),l&&this.setMode(i),r}getPainterStyle(){return this.painterStyle&&Object.keys(this.painterStyle).length?this.painterStyle:null}getPainterOptions(){return this.painterOptions}setPainterStyle(t,e){this.painterStyle=t,this.painterOptions=e||null,this.getPainterStyle()&&this.pageList.forEach(n=>n.style.cursor="copy")}setDefaultRange(){this.elementList.length&&setTimeout(()=>{const t=this.elementList.length-1;this.range.setRange(t,t),this.range.setRangeStyle()})}getIsPagingMode(){return this.options.pageMode===s.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===s.PageMode.PAGING){const{height:i}=this.options,l=this.getPagePixelRatio(),r=this.pageList[0];r.style.height=`${i}px`,r.height=i*l,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(s.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,a)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,r.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[a])});const l=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!l,curIndex:l?.index}),this.listener.pageScaleChange&&this.listener.pageScaleChange(t),this.eventBus.isSubscribe("pageScaleChange")&&this.eventBus.emit("pageScaleChange",t)}getPagePixelRatio(){return this.pagePixelRatio||window.devicePixelRatio}setPagePixelRatio(t){!this.pagePixelRatio&&t===window.devicePixelRatio||t===this.pagePixelRatio||(this.pagePixelRatio=t,this.setPageDevicePixel())}setPageDevicePixel(){const t=this.getPagePixelRatio(),e=this.getWidth(),n=this.getHeight();this.pageList.forEach((i,l)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[l])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),l=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((r,a)=>{r.width=i*n,r.height=l*n,r.style.width=`${i}px`,r.style.height=`${l}px`,this._initPageContext(this.ctxList[a])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((l,r)=>{l.width=n*e,l.height=i*e,l.style.width=`${n}px`,l.style.height=`${i}px`,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getOriginValue(t={}){const{pageNo:e}=t,n=this.readonlyModeData;let i=n?.main||this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(i=this.pageRowList[e].flatMap(r=>r.elementList)),{header:n?.header||this.getHeaderElementList(),main:i,footer:n?.footer||this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t),{extraPickAttrs:n}=t,i={header:Yt(e.header,{extraPickAttrs:n,editorOptions:this.options}),main:Yt(e.main,{extraPickAttrs:n,isClassifyArea:!0,editorOptions:this.options}),footer:Yt(e.footer,{extraPickAttrs:n,editorOptions:this.options}),graffiti:e.graffiti};return{version:pn,data:i,options:at(this.options)}}setValue(t,e){const{header:n,main:i,footer:l}=at(t);if(!n&&!i&&!l)return;const{isSetCursor:r=!1}=e||{};[n,i,l].forEach(d=>{d&&qt(d,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:l}),this.mode===s.EditorMode.READONLY?(this.readonlyModeData=null,this.setReadonlyData()):this.isPrintLikeMode()&&(this.printModeData=null,this.setPrintData()),this.historyManager.recovery();const c=r?i?.length?i.length-1:0:void 0;c!==void 0&&this.range.setRange(c,c),this.render({curIndex:c,isSetCursor:r,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_wrapContainer(t){const e=document.createElement("div");return t.append(e),e}_formatContainer(){this.container.style.position="relative",this.container.style.width=`${this.getWidth()}px`,this.container.setAttribute(Ze,s.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const l=this.getPagePixelRatio();i.width=e*l,i.height=n*l,i.style.cursor="text";const r=i.getContext("2d");this._initPageContext(r),this.pageList.push(i),this.ctxList.push(r)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}getElementFont(t,e=1){const{defaultSize:n,defaultFont:i}=this.options,l=t.font||i,r=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${r*e}px ${l}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:l}=this.options,r=t.size||e;let a=1;return r<12?a=r/12:r>30&&(a=1+(r-30)/30),n*a*(t.rowMargin??i)*l}computeRowList(t){const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:l=!1,startX:r=0,startY:a=0,pageHeight:c=0,mainOuterHeight:d=0,surroundElementList:u=[]}=t,{defaultSize:h,scale:R,imgCaption:f,table:{tdPadding:g,defaultTrMinHeight:T},defaultTabWidth:C}=this.options,p=this.getDefaultBasicRowMarginHeight(),m=document.createElement("canvas").getContext("2d"),L=this.listParticle.computeListStyle(m,n),P=[],M=this._collectTextControlValueSet(n),F=this._collectTextControlHasContentSet(n);n.length&&P.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:n?.[0]?.rowFlex||n?.[1]?.rowFlex});let N=r,Y=a,b=0,S,y=0,V=0;for(let X=0;X<n.length;X++){const O=P[P.length-1],E=n[X];this.clearElementEffect(E);const W=this.getElementRowMargin(E),D={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},U=O.offsetX||E.listId&&L.get(E.listId)||0,Z=e-U,Q=O.elementList.length===1;if(N+=Q?U:0,Y+=Q&&O.offsetY||0,(E.control?.type===s.ControlType.TEXTFIELD||E.control?.type===s.ControlType.TEXT)&&!this.isDesignMode()&&(E.controlComponent===s.ControlComponent.PRETEXTFIX||E.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||E.controlComponent===s.ControlComponent.POSTTEXTFIX||E.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||E.controlComponent===s.ControlComponent.TEXTFIXLABEL||E.controlComponent===s.ControlComponent.PLACEHOLDER||E.controlComponent===s.ControlComponent.PREFIX||E.controlComponent===s.ControlComponent.POSTFIX)){const tt=E.control?.type===s.ControlType.TEXTFIELD,J=E.controlId,_=!!J&&!!M?.has(J);if(tt){const G=!!J&&!!F?.has(J);this.mode===s.EditorMode.EDIT?E.controlComponent===s.ControlComponent.PLACEHOLDER||E.controlComponent===s.ControlComponent.TEXTFIXLABEL?E.hide=G:E.hide=!1:E.hide=!0}else{const G=!!J&&!!F?.has(J);this.mode===s.EditorMode.EDIT||this.mode===s.EditorMode.FORM?E.controlComponent===s.ControlComponent.PLACEHOLDER||E.controlComponent===s.ControlComponent.TEXTFIXLABEL?E.hide=G:E.hide=!1:E.hide=!0}}if(de(E)&&!this.isDesignMode()){const tt=O.elementList[O.elementList.length-1];D.height=tt?.metrics.height||this.options.defaultSize*R,D.boundingBoxAscent=tt?.metrics.boundingBoxAscent||0,D.boundingBoxDescent=tt?.metrics.boundingBoxDescent||0}else if(E.type===s.ElementType.IMAGE||E.type===s.ElementType.LATEX)if(E.imgDisplay===s.ImageDisplay.SURROUND||E.imgDisplay===s.ImageDisplay.FLOAT_TOP||E.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)D.width=0,D.height=0,D.boundingBoxDescent=0;else{const tt=E.width*R,J=E.height*R;if(tt>Z){const _=J*Z/tt;E.width=Z/R,E.height=_/R,D.width=Z,D.height=_,D.boundingBoxDescent=_}else D.width=tt,D.height=J,D.boundingBoxDescent=J;if(E.imgCaption?.value){const _=E.imgCaption.size||f.size,G=E.imgCaption.top??f.top,it=(_+G)*R;D.boundingBoxAscent+=it}}else if(E.type===s.ElementType.TABLE){const tt=E.tdPadding||g;if(E.pagingId){let z=X+1,ut=0;for(;z<n.length;){const Rt=n[z];if(Rt.pagingId===E.pagingId){const St=Rt.trList.filter(Nt=>!Nt.pagingRepeat).filter(Nt=>(Nt.tdList=Nt.tdList.filter(At=>{if(At.originalId){for(let Ft=0;Ft<E.trList.length;Ft++){const Bt=E.trList[Ft],_t=Bt.tdList.find(({id:re})=>re===At.originalId);if(_t){At.value[0]?.type===s.ElementType.SPLIT_TAG&&At.value.splice(0,1),_t.value.push(...At.value.map(re=>this.updateElementTableInfo(re,E,Bt,_t))),_t.rowspan=_t.originalRowspan??_t.rowspan;break}}return!1}return!0}),!Nt.originalId));E.trList.push(...St),E.height+=Rt.height,z++,ut++}else break}ut&&n.splice(X+1,ut)}E.pagingIndex=E.pagingIndex??0,this.tableParticle.computeTrHeight(E,z=>this.computeRowList({innerWidth:(z.width-(tt[1]+tt[3]))*R,elementList:z.value,isFromTable:!0,isPagingMode:i})),E.trList?.forEach(z=>{z.tdList.forEach(ut=>{this.tdMap.set(ut.id,ut)})});const J=this.tableParticle.getTableHeight(E),_=this.tableParticle.getTableWidth(E);E.width=_,E.height=J;const G=_*R,it=J*R;if(D.width=G,D.height=it,D.boundingBoxDescent=it,D.boundingBoxAscent=-W,n[X+1]?.type===s.ElementType.TABLE&&(D.boundingBoxAscent-=W),i){const z=this.getHeight(),ut=this.getMainOuterHeight();let Rt=ut;for(let Ft=0;Ft<P.length;Ft++){const Bt=P[Ft],_t=Bt.offsetY||0;Bt.height+Rt+_t>z||P[Ft-1]?.isPageBreak?Rt=ut+Bt.height+_t:Rt+=Bt.height+_t}const St=W*2,Nt=E.trList[0].height*R;(Rt+Nt+St>z||E.pagingIndex!==0&&E.trList[0].pagingRepeat||n[X-1]?.type===s.ElementType.PAGE_BREAK)&&(Rt=ut);let At=z-(Rt+St);if(it>At){const Ft=E.trList;let Bt=0,_t=0,re=0;for(let ft=0;ft<Ft.length;ft++){const Lt=Ft[ft],Vt=Lt.height*R;if(Rt+St+re+Vt>z){const Pt=Lt;let Et=0;const Mt={...at(Pt),id:mt(),originalId:Pt.originalId??Pt.id,minHeight:void 0,tdList:E.colgroup.map((Tt,It)=>{if(Et--,Et>0)return;const gt=Pt.tdList.find($t=>$t.colIndex===It),et=gt??this.tableParticle.findPreRowSpanTd(Ft,ft,It);gt&&(Et=gt.colspan);const j=mt();return et.originalRowspan=et.rowspan,gt?{...gt,id:j,originalId:gt.originalId??gt.id,linkTdPrevId:gt.id,tdIndex:It,original:et}:{id:j,originalId:et.originalId??et.id,linkTdPrevId:et.id,tdIndex:It,colIndex:It,colspan:1,rowspan:1,value:[],rowList:[],original:et}}).filter(Tt=>!!Tt)},Qt=Mt.tdList,ce=Qt.map(Tt=>Tt.original);ce.forEach((Tt,It)=>{const gt=[];let et=At;if(Tt.rowspan>1){const $t=Ft.slice(Tt.trIndex,Tt.trIndex+ft-Tt.trIndex);et+=$t.reduce((fe,me)=>me.height*R+fe,0)}for(;Tt.mainHeight*R>et&&Tt.rowList?.length;){const $t=Tt.rowList.pop();Tt.value.splice(Tt.value.length-$t.elementList.length),gt.unshift($t),Tt.mainHeight-=$t.height}const j=Qt[It];j.rowList=gt,j.value=gt.map($t=>$t.elementList).flat()});let Ct=!0;const ot=Pt.tdList.some(Tt=>Tt.rowList?.length),Zt=Mt.tdList.some(Tt=>Tt.rowList?.length),yt=Pt.minHeight>At;if(Zt||yt){(ot||!Zt&&yt)&&(yt&&(Pt.originalMinHeight=Pt.minHeight,Pt.minHeight=At,Mt.minHeight=Math.max(Pt.originalMinHeight-At,T)),Mt.tdList.forEach(Tt=>{Tt.original.linkTdNextId=Tt.id,Tt.value.length&&Tt.value[0].value!==K&&Tt.value.unshift({...Tt.original.value.slice(-1).pop(),value:K,type:s.ElementType.SPLIT_TAG})}),Ft.splice(Bt+1,0,Mt),Bt+=1,_t=Ft.length-Bt,Ct=!1),ce.forEach(Tt=>{if(Tt.rowspan>1){const It=Tt.rowspan-(ft-Tt.trIndex);Tt.rowspan=ft-Tt.trIndex+(ot?1:0);const gt=Mt.tdList.find(et=>et.colIndex===Tt.colIndex);ot?gt.rowspan=It:(gt.original.linkTdNextId=gt.id,Pt.tdList.push({...Tt,...gt,rowspan:It}),Pt.tdList.sort((et,j)=>et.colIndex-j.colIndex),gt.value=[])}}),Ct&&ce.forEach((Tt,It)=>{Tt.value.push(...Qt[It].value)});break}}Bt=ft+1,_t=Ft.length-Bt,re+=Vt,At-=Vt}if(_t){const ft=Ft.splice(Bt,_t),Lt=E.pagingId||mt();E.pagingId=Lt;const Vt=at(E);Vt.originalId=E.originalId??E.id,Vt.pagingId=Lt,Vt.pagingIndex=E.pagingIndex+1;const Pt=Ft.filter(Qt=>Qt.pagingRepeat);if(Pt.length){const Qt=at(Pt);Qt.forEach(ce=>ce.id=mt()),ft.unshift(...Qt)}Vt.trList=ft,Vt.id=mt(),Vt.trList?.forEach(Qt=>{Qt.tdList.forEach(ce=>{if(delete ce.valueStartIndex,ce.linkTdPrevId){const Ct=this.getTdById(ce.linkTdPrevId);ce.valueStartIndex=Ct?(Ct.valueStartIndex??0)+Ct.value.length:0,this.splitTdValueMap.has(ce.originalId)?this.splitTdValueMap.get(ce.originalId).push(...ce.value):Ct&&this.splitTdValueMap.set(ce.originalId,[...Ct.value,...ce.value])}ce.value.forEach(Ct=>this.updateElementTableInfo(Ct,Vt,Qt,ce))})}),this.spliceElementList(n,X+1,0,[Vt]),this.tableParticle.computeTrHeight(E);const Et=this.tableParticle.getTableHeight(E),Mt=Et*R;E.height=Et,D.height=Mt,D.boundingBoxDescent=Mt}}if(E.pagingId){const Ft=this.position.getPositionContext();if(Ft.isTable){let Bt=-1,_t=-1,re=X;for(;re<n.length;){const ft=n[re];if(ft.pagingId!==E.pagingId)break;const Lt=ft.trList.findIndex(Vt=>Vt.id===Ft.trId);if(~Lt){Bt=re,_t=Lt;break}re++}~Bt&&(Ft.index=Bt,Ft.trIndex=_t,this.position.setPositionContext(Ft))}}}this.initTableElementIndex(E,X)}else if(E.type===s.ElementType.SEPARATOR){const{separator:{lineWidth:tt}}=this.options,J=E.lineWidth||tt;E.width=Z/R,D.width=Z,D.height=J*R,D.boundingBoxAscent=-W,D.boundingBoxDescent=-W+D.height}else if(E.type===s.ElementType.PAGE_BREAK)E.width=Z/R,D.width=Z,D.height=h;else if(E.type===s.ElementType.RADIO||E.controlComponent===s.ControlComponent.RADIO){const{width:tt,height:J,gap:_}=this.options.radio,G=tt+_*(E.controlComponent?1:2);E.width=G,D.width=G*R,D.height=J*R}else if(E.type===s.ElementType.CHECKBOX||E.controlComponent===s.ControlComponent.CHECKBOX){const{width:tt,height:J,gap:_}=this.options.checkbox,G=tt+_*(E.controlComponent?1:2);E.width=G,D.width=G*R,D.height=J*R}else if(E.type===s.ElementType.MENSTRUAL_HISTORY){const tt=this.menstrualHistoryParticle.computeSize(E);E.width=tt.width/R,D.width=tt.width,D.height=tt.height,D.boundingBoxAscent=tt.height,D.boundingBoxDescent=0}else if(E.type===s.ElementType.FETAL_HEART_POSITION){const tt=this.fetalHeartPositionParticle.computeSize();E.width=tt.width/R,D.width=tt.width,D.height=tt.height,D.boundingBoxAscent=tt.height/2,D.boundingBoxDescent=tt.height/2}else if(E.type===s.ElementType.TOOTH_POSITION){const tt=this.toothPositionParticle.computeSize(E);E.width=tt.width/R,D.width=tt.width,D.height=tt.height,D.boundingBoxAscent=tt.height/2,D.boundingBoxDescent=tt.height/2}else if(E.type===s.ElementType.TAB)D.width=C*R,D.height=h*R,D.boundingBoxDescent=0,D.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(m,m.font);else if(E.type===s.ElementType.BLOCK){if(!E.width)D.width=Z;else{const tt=E.width*R;D.width=Math.min(tt,Z)}D.height=E.height*R,D.boundingBoxDescent=D.height,D.boundingBoxAscent=0}else if(E.type===s.ElementType.LABEL){const{defaultSize:tt,label:{defaultPadding:J}}=this.options;m.font=this.getElementFont(E);const _=this.textParticle.measureText(m,E);D.width=(_.width+J[1]+J[3])*R,D.height=(E.size||tt)*R,D.boundingBoxDescent=0,D.boundingBoxAscent=(J[0]+_.actualBoundingBoxAscent)*R}else if(E.type===s.ElementType.MACRO||E.type===s.ElementType.CUSTOM_MACRO||E.type===s.ElementType.REUSABLE_ITEM||E.type===s.ElementType.SUB_TEMPLATE){const{defaultSize:tt}=this.options;m.font=this.getElementFont(E);const J=this.getMode(),_=J===s.EditorMode.EDIT,G=J===s.EditorMode.FORM;if(J===s.EditorMode.READONLY&&E.type!==s.ElementType.SUB_TEMPLATE){const it=Xo(E),z=m.measureText(it);D.width=z.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=z.actualBoundingBoxDescent,D.boundingBoxAscent=z.actualBoundingBoxAscent}else if(_){const it=E.label||E.value||"";m.font=this.getElementFont(E);const z=m.measureText(it),ut=8*R,Rt=4*R;D.width=z.width+ut*2;const St=z.actualBoundingBoxAscent+z.actualBoundingBoxDescent;D.height=St+Rt*2;const Nt=this.textParticle.measureBasisWord(m,this.getElementFont(E));D.boundingBoxAscent=Nt.actualBoundingBoxAscent*R,D.boundingBoxDescent=Nt.actualBoundingBoxDescent*R}else if(E.type===s.ElementType.CUSTOM_MACRO){const it=E.macroConfig,z=it?.value||"";if(G){const ut=it?.type||"text",Rt=this.textParticle.measureText(m,E),St=E.label||"";if(ut==="select"){const Nt=z||`请选择${St}`,At=m.measureText(Nt),Ft=m.measureText("[").width,Bt=6*R+2*R;D.width=Ft+At.width+Bt+Ft}else{const Nt=z||`请输入${St}`,At=m.measureText(Nt),Ft=m.measureText("[").width;D.width=Ft+At.width+Ft}D.height=(E.size||tt)*R,D.boundingBoxDescent=Rt.actualBoundingBoxDescent*R,D.boundingBoxAscent=Rt.actualBoundingBoxAscent*R}else{const ut=E.label||"",Rt=z||`请输入${ut}`,St=m.measureText(Rt);D.width=St.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=St.actualBoundingBoxDescent,D.boundingBoxAscent=St.actualBoundingBoxAscent}}else if(E.type===s.ElementType.REUSABLE_ITEM){const z=E.reusableItemConfig?.value||"",ut=E.label||"";if(G){const Rt=this.textParticle.measureText(m,E),St=z||`请输入${ut}`,Nt=m.measureText(St),At=m.measureText("[").width;D.width=At+Nt.width+At,D.height=(E.size||tt)*R,D.boundingBoxDescent=Rt.actualBoundingBoxDescent*R,D.boundingBoxAscent=Rt.actualBoundingBoxAscent*R}else{const Rt=z||`获取 ${ut}`,St=m.measureText(Rt);D.width=St.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=St.actualBoundingBoxDescent,D.boundingBoxAscent=St.actualBoundingBoxAscent}}else if(E.type===s.ElementType.SUB_TEMPLATE){const it=E.label||"子模板";if(G){const z=m.measureText(it),ut=8*R,Rt=4*R,St=z.actualBoundingBoxAscent+z.actualBoundingBoxDescent;D.width=z.width+ut*2,D.height=St+Rt*2;const Nt=this.textParticle.measureBasisWord(m,this.getElementFont(E));D.boundingBoxAscent=Nt.actualBoundingBoxAscent*R,D.boundingBoxDescent=Nt.actualBoundingBoxDescent*R}else{const z=m.measureText(it);D.width=z.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=z.actualBoundingBoxDescent,D.boundingBoxAscent=z.actualBoundingBoxAscent}}else{const it=E.label||"",z=E.value||`获取 ${it}`,ut=m.measureText(z);D.width=ut.width,D.height=(E.size||tt)*R,D.boundingBoxDescent=ut.actualBoundingBoxDescent,D.boundingBoxAscent=ut.actualBoundingBoxAscent}}else{const tt=E.size||h;(E.type===s.ElementType.SUPERSCRIPT||E.type===s.ElementType.SUBSCRIPT)&&(E.actualSize=Math.ceil(tt*.6)),D.height=(E.actualSize||tt)*R,m.font=this.getElementFont(E);const J=this.textParticle.measureText(m,E),_=E.buttonValueLayoutPrefixOffset?m.measureText("[").width:0;D.width=Math.max(0,J.width-_)*R,E.letterSpacing&&(D.width+=E.letterSpacing*R);const G=this.textParticle.measureBasisWord(m,E.font);D.boundingBoxAscent=G.actualBoundingBoxAscent*R,D.boundingBoxDescent=G.actualBoundingBoxDescent*R,E.type===s.ElementType.SUPERSCRIPT?D.boundingBoxAscent+=D.height/2:E.type===s.ElementType.SUBSCRIPT&&(D.boundingBoxDescent+=D.height/2)}const v=!de(E)&&(E.imgDisplay!==s.ImageDisplay.INLINE&&E.type===s.ElementType.IMAGE||E.type===s.ElementType.LATEX)?D.height+W:D.boundingBoxAscent+W,st=W+D.boundingBoxAscent+D.boundingBoxDescent+W,B=Object.assign(E,{metrics:D,left:0,style:this.getElementFont(E,R)});this.getIsButtonRowStartPrefix(n,X,O)&&(B.left=-D.width);const H=this.getElementLayoutWidth(B);B.control?.minWidth&&(B.controlComponent&&(V+=D.width),B.controlComponent===s.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:O,rowElement:B,availableWidth:Z,controlRealWidth:V}),V=0));const k=n[X-1];let q=n[X+1],x=O.width+H;if(this.options.wordBreak===s.WordBreak.BREAK_WORD&&(!k?.type||k?.type===s.ElementType.TEXT)&&(!E.type||E.type===s.ElementType.TEXT)){const tt=`${k?.value||""}${E.value}`;if(this.WORD_LIKE_REG.test(tt)){const{width:_,endElement:G}=this.textParticle.measureWord(m,n,X),it=_*R;G&&it<=Z?(x+=it,q=G):k&&(x+=it)}const J=this.textParticle.measurePunctuationWidth(m,q);x+=J*R}E.listId&&(E.listId!==S?y=0:E.value===K&&!E.listWrap&&y++),S=E.listId;const Xt=this.position.setSurroundPosition({pageNo:b,rowElement:B,row:O,rowElementRect:{x:N,y:Y,height:st,width:H},availableWidth:Z,surroundElementList:u});N=Xt.x,x+=Xt.rowIncreaseWidth,N+=H;let wt=!1;if(this.mode===s.EditorMode.FORM&&E.control?.type===s.ControlType.BUTTON&&E.controlComponent===s.ControlComponent.PREFIX&&O.elementList.filter(tt=>tt.controlId!==E.controlId).length>0){const tt=E.controlId;if(n.some(_=>_.controlId===`${tt}_text`&&_.control?.type===s.ControlType.BUTTON)){let _=0;for(let G=X;G<n.length;G++){const it=n[G];if(it.controlId!==tt)break;m.font=this.getElementFont(it);const z=this.textParticle.measureText(m,it);if(_+=z.width*R,it.controlComponent===s.ControlComponent.POSTFIX)break}for(let G=0;G<n.length;G++){const it=n[G];if(it.controlId===`${tt}_text`){m.font=this.getElementFont(it);const z=this.textParticle.measureText(m,it);_+=z.width*R}}wt=O.width+_>Z}}const Ie=E.type===s.ElementType.SEPARATOR||E.type===s.ElementType.TABLE||k?.type===s.ElementType.TABLE||k?.type===s.ElementType.BLOCK||E.type===s.ElementType.BLOCK||k?.imgDisplay===s.ImageDisplay.INLINE||E.imgDisplay===s.ImageDisplay.INLINE||k?.listId!==E.listId||k?.areaId!==E.areaId&&!E.area?.hide||E.control?.flexDirection===s.FlexDirection.COLUMN&&(E.controlComponent===s.ControlComponent.CHECKBOX||E.controlComponent===s.ControlComponent.RADIO)&&k?.controlComponent===s.ControlComponent.VALUE||X!==0&&E.value===K&&!E.area?.hide||wt,ne=x>Z,ue=Ie||ne;if(ue){const tt={width:H,height:st,startIndex:X,elementList:[B],ascent:v,rowIndex:O.rowIndex+1,rowFlex:n[X]?.rowFlex||n[X+1]?.rowFlex,isPageBreak:E.type===s.ElementType.PAGE_BREAK};if(B.controlComponent!==s.ControlComponent.PREFIX&&B.control?.indentation===s.ControlIndentation.VALUE_START){const J=O.elementList.findIndex(_=>_.controlId===B.controlId&&_.controlComponent!==s.ControlComponent.PREFIX);if(~J){const G=this.position.computeRowPosition({row:O,innerWidth:this.getInnerWidth()})[J];G&&(tt.offsetX=G.coordinate.leftTop[0])}}E.listId&&(tt.isList=!0,tt.offsetX=L.get(E.listId),tt.listIndex=y),tt.offsetY=!l&&E.area?.top&&E.areaId!==n[X-1]?.areaId?E.area.top*R:0,P.push(tt)}else O.width+=H,X===0&&(Kn(n[1])||n[1]?.areaId)?(O.height=p,O.ascent=p):O.height<st&&(O.height=st,O.ascent=v),O.elementList.push(B);if((ue||X===n.length-1)&&(O.isWidthNotEnough=ne&&!Ie,!O.isSurround&&(k?.rowFlex===s.RowFlex.JUSTIFY||k?.rowFlex===s.RowFlex.ALIGNMENT&&O.isWidthNotEnough))){const tt=O.elementList[0]?.value===K?O.elementList.slice(1):O.elementList,J=(Z-O.width)/(tt.length-1);for(let _=0;_<tt.length-1;_++){const G=tt[_];G.metrics.width+=J}O.width=Z}if(ue){N=r,Y+=O.height,i&&!l&&c&&(Y-a+d+st>c||E.type===s.ElementType.PAGE_BREAK)&&(Y=a,Fc(u,b),b+=1),B.left=0;const tt=P[P.length-1];N=this.position.setSurroundPosition({pageNo:b,rowElement:B,row:tt,rowElementRect:{x:N,y:Y,height:st,width:H},availableWidth:Z,surroundElementList:u}).x,N+=H}}return P}_collectTextControlValueSet(t){if(this.isDesignMode()||this.mode===s.EditorMode.EDIT)return null;const e=new Set;for(let i=0;i<t.length;i++){const l=t[i];l.controlId&&(l.control?.type===s.ControlType.TEXT||l.control?.type===s.ControlType.TEXTFIELD)&&e.add(l.controlId)}const n=new Set;for(let i=0;i<t.length;i++){const l=t[i];l.controlId&&l.controlComponent===s.ControlComponent.VALUE&&e.has(l.controlId)&&n.add(l.controlId)}return n}_collectTextControlHasContentSet(t){if(this.isDesignMode())return null;const e=new Set;let n=0;for(;n<t.length;){const i=t[n];if(i.controlId&&(i.control?.type===s.ControlType.TEXT||i.control?.type===s.ControlType.TEXTFIELD)&&(i.controlComponent===s.ControlComponent.PREFIX||i.controlComponent===s.ControlComponent.PRE_TEXT||i.controlComponent===s.ControlComponent.PRETEXTFIX||i.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){const l=i.controlId;let r=!1,a=n+1;for(;a<t.length;){const c=t[a];if(c.controlId===l&&(c.controlComponent===s.ControlComponent.POSTFIX||c.controlComponent===s.ControlComponent.POST_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))break;if(c.controlId===l&&c.controlComponent===s.ControlComponent.VALUE&&(r=!0),c.controlId!==l&&c.controlId){(i.control?.type===s.ControlType.TEXT||c.controlComponent===s.ControlComponent.VALUE)&&(r=!0);const d=c.controlId;for(a++;a<t.length&&t[a].controlId===d;)a++;continue}a++}r&&e.add(l)}n++}return e}_computePageList(){const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),l=this.getMainOuterHeight();let r=l,a=0;if(e===s.PageMode.CONTINUITY){t[0]=this.rowList,r+=this.rowList.reduce((h,R)=>h+R.height+(R.offsetY||0),0);const c=this.getPagePixelRatio(),d=this.pageList[0],u=Number(d.style.height.replace("px",""));if(r>u)d.style.height=`${r}px`,d.height=r*c;else{const h=r<i?i:r;d.style.height=`${h}px`,d.height=h*c}this._initPageContext(this.ctxList[0])}else for(let c=0;c<this.rowList.length;c++){const d=this.rowList[c],u=d.offsetY||0;if(d.height+u+r>i||this.rowList[c-1]?.isPageBreak){if(Number.isInteger(n)&&a>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}r=l+d.height+u,t.push([d]),a++}else r+=d.height+u,t[a].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:l}=e,r=this.getDefaultBasicRowMarginHeight(),a=this.getHighlightMarginHeight();for(let c=0;c<n.length;c++){const d=n[c];let u="";for(let h=0;h<d.elementList.length;h++){const R=d.elementList[h],f=d.startIndex+h,g=l[f]===R?f:l.indexOf(R),T=~g?g:f,C=this.control.getControlHighlight(l,T),p=R.highlight||C;if(p){u&&u!==p&&this.highlight.render(t);const I=i[T],{coordinate:{leftTop:[m,L]}}=I,P=R.left||0,M=!R.highlight&&!!C&&this.control.getIsInlineControlBackground(l,T),F=M?L+I.ascent-R.metrics.boundingBoxAscent-a:L+r-a,N=M?R.metrics.boundingBoxAscent+R.metrics.boundingBoxDescent+2*a:d.height-2*r+2*a;this.highlight.recordFillInfo(t,m-P,F,R.metrics.width+P,N,p)}else u&&this.highlight.render(t);u=p}this.highlight.render(t)}}validateNumber(t){return/^\d+$/.test(t)}drawRow(t,e){this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:l,lineBreak:r,whiteSpace:a}=this.options,{rowList:c,pageNo:d,elementList:u,positionList:h,startIndex:R,zone:f,isDrawLineBreak:g=!r.disabled,td:T,isDrawWhiteSpace:C=!a.disabled}=e,p=this.isPrintLikeMode(),I=this.isSelectionDisabled(),{isCrossRowCol:m,tableId:L}=this.range.getRange();let P=R;for(let M=0;M<c.length;M++){const F=c[M],N={x:0,y:0,width:0,height:0};let Y=null;for(let b=0;b<F.elementList.length;b++){const S=F.elementList[b],y=S.metrics,{ascent:V,coordinate:{leftTop:[X,O]}}=h[F.startIndex+b],E=F.elementList[b-1];if(de(S)&&!this.isDesignMode())this.textParticle.complete();else if(S.type===s.ElementType.IMAGE)this.textParticle.complete(),S.imgDisplay!==s.ImageDisplay.SURROUND&&S.imgDisplay!==s.ImageDisplay.FLOAT_TOP&&S.imgDisplay!==s.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.TABLE)m&&(N.x=X,N.y=O,Y=S),this.tableParticle.render(t,S,X,O);else if(S.type===s.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.MACRO||S.type===s.ElementType.CUSTOM_MACRO||S.type===s.ElementType.REUSABLE_ITEM||S.type===s.ElementType.SUB_TEMPLATE)this.textParticle.complete(),this.macroParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.DATE){const v=F.elementList[b+1];(!E||E.dateId!==S.dateId)&&this.textParticle.complete(),this.textParticle.record(t,S,X,O+V),(!v||v.dateId!==S.dateId)&&this.textParticle.complete()}else if(S.type===s.ElementType.SUPERSCRIPT)this.textParticle.complete(),this.superscriptParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.SUBSCRIPT)this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,S,X,O+V);else if(S.type===s.ElementType.SEPARATOR)this.separatorParticle.render(t,S,X,O);else if(S.type===s.ElementType.PAGE_BREAK)this.mode!==s.EditorMode.CLEAN&&!p&&this.pageBreakParticle.render(t,S,X,O);else if(S.type===s.ElementType.CHECKBOX||S.controlComponent===s.ControlComponent.CHECKBOX)this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:X,y:O+V,index:b,row:F});else if(S.type===s.ElementType.RADIO||S.controlComponent===s.ControlComponent.RADIO)this.textParticle.complete(),this.radioParticle.render({ctx:t,x:X,y:O+V,index:b,row:F});else if(S.type===s.ElementType.MENSTRUAL_HISTORY)this.textParticle.complete(),this.menstrualHistoryParticle.render({ctx:t,x:X,y:O+V,index:b,row:F,element:S});else if(S.type===s.ElementType.FETAL_HEART_POSITION)this.textParticle.complete(),this.fetalHeartPositionParticle.render({ctx:t,x:X,y:O+V,index:b,row:F,element:S});else if(S.type===s.ElementType.TOOTH_POSITION)this.textParticle.complete(),this.toothPositionParticle.render({ctx:t,x:X,y:O+V,index:b,row:F,element:S});else if(S.type===s.ElementType.TAB)this.textParticle.complete();else if(S.rowFlex===s.RowFlex.ALIGNMENT||S.rowFlex===s.RowFlex.JUSTIFY)this.textParticle.record(t,S,X,O+V),this.textParticle.complete();else if(S.type===s.ElementType.BLOCK)this.textParticle.complete(),this.blockParticle.render(t,d,S,X,O+V);else{const v=S.buttonValueLayoutPrefixOffset===!0;(S.left||v)&&this.textParticle.complete(),this.textParticle.record(t,S,X,O+V),(v||S.width||S.letterSpacing||ca.test(S.value))&&this.textParticle.complete()}if(g&&!p&&this.mode!==s.EditorMode.CLEAN&&!F.isWidthNotEnough&&b===F.elementList.length-1&&this.lineBreakParticle.render(t,S,X,O+F.height/2),C&&da.test(S.value)&&this.whiteSpaceParticle.render(t,S,X,O+F.height/2),S.control?.border){E?.control?.border&&E.controlId!==S.controlId&&this.control.drawBorder(t);const v=this.getElementRowMargin(S);this.control.recordBorderInfo(X,O+v,S.metrics.width,F.height-2*v)}else E?.control?.border&&this.control.drawBorder(t);if(S.control?.type===s.ControlType.TEXT){const v=S.controlComponent===s.ControlComponent.VALUE,st=S.controlComponent===s.ControlComponent.POSTFIX||S.controlComponent===s.ControlComponent.POST_TEXT,B=!!E&&E.originControlId===S.controlId&&(E.controlComponent===s.ControlComponent.POSTFIX||E.controlComponent===s.ControlComponent.POST_TEXT||E.controlComponent===s.ControlComponent.POSTTEXTFIX||E.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT);S.originControlId&&(S.controlComponent===s.ControlComponent.PREFIX||S.controlComponent===s.ControlComponent.PRE_TEXT||S.controlComponent===s.ControlComponent.PRETEXTFIX||S.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&this.control.drawTextFieldUnderline(t),v&&S.control?.underline&&!S.underline&&((!E||E.controlId!==S.controlId||B||E.controlComponent!==s.ControlComponent.VALUE&&E.controlComponent!==s.ControlComponent.PLACEHOLDER)&&this.control.startTextFieldUnderline(S.controlId,X,O+F.height),this.control.recordTextFieldUnderlineWidth(S.metrics.width)),st&&this.control.drawTextFieldUnderline(t),S.originControlId&&(S.controlComponent===s.ControlComponent.POSTFIX||S.controlComponent===s.ControlComponent.POST_TEXT||S.controlComponent===s.ControlComponent.POSTTEXTFIX||S.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.drawTextFieldUnderline(t)}else E?.control?.type===s.ControlType.TEXT&&this.control.drawTextFieldUnderline(t);if(S.type!==s.ElementType.REUSABLE_ITEM&&(S.underline||S.control?.underline)&&S.controlComponent!==s.ControlComponent.PLACEHOLDER&&!(S.control?.type===s.ControlType.TEXT&&S.control?.underline&&!S.underline)){E?.type===s.ElementType.SUBSCRIPT&&S.type!==s.ElementType.SUBSCRIPT&&this.underline.render(t);const v=this.getElementRowMargin(S),st=S.left||0;let B=0;S.type===s.ElementType.SUBSCRIPT&&(B=this.subscriptParticle.getOffsetY(S));const H=S.control?.underline?this.options.underlineColor:S.color;this.underline.recordFillInfo(t,X-st,O+F.height-v+B,y.width+st,0,H,S.textDecoration?.style)}else(E?.underline||E?.control?.underline)&&(E?.control?.type===s.ControlType.TEXT&&E?.control?.underline&&!E.underline||this.underline.render(t));if(S.type!==s.ElementType.REUSABLE_ITEM&&S.strikeout){if(!S.type||Le.includes(S.type)){E&&(E.type===s.ElementType.SUBSCRIPT&&S.type!==s.ElementType.SUBSCRIPT||E.type===s.ElementType.SUPERSCRIPT&&S.type!==s.ElementType.SUPERSCRIPT||this.getElementSize(E)!==this.getElementSize(S))&&this.strikeout.render(t);const v=this.textParticle.measureBasisWord(t,this.getElementFont(S));let st=O+V+v.actualBoundingBoxDescent*n-y.height/2;S.type===s.ElementType.SUBSCRIPT?st+=this.subscriptParticle.getOffsetY(S):S.type===s.ElementType.SUPERSCRIPT&&(st+=this.superscriptParticle.getOffsetY(S)),this.strikeout.recordFillInfo(t,X,st,y.width)}}else E?.strikeout&&this.strikeout.render(t);const{zone:W,splitTdRange:D}=this.range.getRange();let{startIndex:U,endIndex:Z}=this.range.getRange(),Q=!1;if(T&&D&&[T.originalId,T.id].includes(D.originalId)&&(Q=!0,U=D.startIndex-(T.valueStartIndex??0),Z=D.endIndex-(T.valueStartIndex??0)),W===f&&U!==Z&&U<=P&&P<=Z){const v=this.position.getPositionContext();if(!v.isTable&&!S.tdId||v.tdId===S.tdId||Q)if(U===P){const st=u[U+1];st&&st.value===K&&(N.x=X+y.width,N.y=O,N.height=F.height,N.width+=this.options.rangeMinWidth)}else{let st=y.width;st===0&&F.elementList.length===1&&(st=this.options.rangeMinWidth),N.width||(N.x=X,N.y=O,N.height=F.height),N.width+=st}}if(!l.disabled&&S.groupIds&&this.group.recordFillInfo(S,X,O,y.width,F.height),P++,S.type===s.ElementType.TABLE&&!de(S)){const v=S.tdPadding||i,st=v[1]+v[3];for(let B=0;B<S.trList.length;B++){const H=S.trList[B];for(let k=0;k<H.tdList.length;k++){const q=H.tdList[k];this.drawRow(t,{elementList:q.value,positionList:q.positionList,rowList:q.rowList,pageNo:d,startIndex:0,innerWidth:(q.width-st)*n,zone:f,isDrawLineBreak:g,td:q})}}}}if(F.isList&&this.listParticle.drawListStyle(t,F,h[F.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!I){if(N.width&&N.height){const{x:b,y:S,width:y,height:V}=N;this.range.render(t,b,S,y,V)}if(m&&Y&&Y.id===L){const{coordinate:{leftTop:[b,S]}}=h[F.startIndex];this.tableParticle.drawRange(t,Y,b,S)}}}this.control.renderQualityMarks(t,e.elementList,e.positionList,e.rowList,e.pageNo,e.zone,e.innerWidth)}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:l,pageNo:r}=e;for(let a=0;a<i.length;a++){const c=i[a],d=c.element;if((r===c.pageNo||c.zone===s.EditorZone.HEADER||c.zone==s.EditorZone.FOOTER)&&d.imgDisplay&&l.includes(d.imgDisplay)&&d.type===s.ElementType.IMAGE){const u=d.imgFloatPosition;this.imageParticle.render(t,d,u.x*n,u.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){const{elementList:e,positionList:n,rowList:i,pageNo:l}=t,{inactiveAlpha:r,pageMode:a,header:c,footer:d,pageNumber:u,lineNumber:h,pageBorder:R}=this.options,f=this.isPrintLikeMode(),g=this.mode===s.EditorMode.COMPARE?this.options.modeRule[s.EditorMode.COMPARE]:this.options.modeRule[s.EditorMode.PRINT],T=this.getInnerWidth(),C=this.ctxList[l];C.globalAlpha=this.zone.isMainActive()?1:r,this._clearPage(l),(!f||!g?.backgroundDisabled)&&this.background.render(C,l),f||this.area.render(C,l),a!==s.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(C,l),f||this.margin.render(C,l),this._drawFloat(C,{pageNo:l,imgDisplays:[s.ImageDisplay.FLOAT_BOTTOM]}),f||this.control.renderHighlightList(C,l);const p=i[0]?.startIndex;this.drawRow(C,{elementList:e,positionList:n,rowList:i,pageNo:l,startIndex:p,innerWidth:T,zone:s.EditorZone.MAIN}),this.getIsPagingMode()&&(c.disabled||this.header.render(C,l),u.disabled||this.pageNumber.render(C,l),d.disabled||this.footer.render(C,l)),this._drawFloat(C,{pageNo:l,imgDisplays:[s.ImageDisplay.FLOAT_TOP,s.ImageDisplay.SURROUND]}),!f&&this.search.getSearchKeyword()&&this.search.render(C,l),this.elementList.length<=1&&!this.elementList[0]?.listId&&this.placeholder.render(C),h.disabled||this.lineNumber.render(C,l),R.disabled||this.pageBorder.render(C),this.badge.render(C,l),this.isGraffitiMode()&&this.graffiti.render(C,l)}_disconnectLazyRender(){this.lazyRenderIntersectionObserver?.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const l=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[l],pageNo:l})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){const e=ie(),n=[],i=(X,O)=>{n.push({label:X,duration:ie()-O})};this.renderCount++;const l=this.mode===s.EditorMode.EDIT||this.mode===s.EditorMode.FORM||this.isPrintLikeMode()?rf([...this.getHeaderElementList(),...this.elementList,...this.getFooterElementList()]):null,r=this.applySubTemplateRuntimeState(this.getHeaderElementList(),l)||this.applySubTemplateRuntimeState(this.elementList,l)||this.applySubTemplateRuntimeState(this.getFooterElementList(),l);let{endIndex:a}=this.range.getRange();const{isCrossRowCol:c}=this.range.getRange();if(!c&&~a){const X=this.getElementList(),O=X[a],W=O?.type===s.ElementType.SUB_TEMPLATE&&O.subTemplateExpanded?s.LocationPosition.AFTER:s.LocationPosition.BEFORE,D=Hn(X,a,W);D!==a&&!de(X[D])&&(this.range.setRange(D,D),a=D)}let d;const u=this.position.getPositionContext();if(c)d=this.getOriginalElementList()[u.index];else{const X=~a?a:0,O=this.getElementList();d=Zn(O,X)}const{header:h,footer:R}=this.options,{isSubmitHistory:f=!0,isSetCursor:g=!0,isLazy:T=!0,isInit:C=!1,isSourceHistory:p=!1,isFirstRender:I=!1,isDel:m=!1}=t||{};let{isCompute:L=!0}=t||{};r&&(L=!0);let{curIndex:P}=t||{};const{traceLabel:M}=t||{},F=this.getInnerWidth(),N=this.getIsPagingMode(),Y=this.pageRowList.length;if(L){if(this.splitTdValueMap.clear(),this.tdMap.clear(),this.position.setFloatPositionList([]),N){if(!h.disabled){const H=ie();this.header.compute(),i("header.compute",H)}if(!R.disabled){const H=ie();this.footer.compute(),i("footer.compute",H)}}const X=this.getMargins(),O=this.getHeight(),E=this.header.getExtraHeight(),W=this.getMainOuterHeight(),D=X[3],U=X[0]+E,Z=bi(this.elementList),Q=ie();this.rowList=this.computeRowList({startX:D,startY:U,pageHeight:O,mainOuterHeight:W,isPagingMode:N,innerWidth:F,surroundElementList:Z,elementList:this.elementList}),i("computeRowList",Q);const v=ie();this.pageRowList=this._computePageList(),i("computePageList",v);const st=ie();this.position.computePositionList(),i("computePositionList",st);const B=ie();if(this.area.compute(),i("area.compute",B),!this.isPrintLikeMode()){const H=this.search.getSearchKeyword();if(H){const q=ie();this.search.compute(H),i("search.compute",q)}const k=ie();this.control.computeHighlightList(),i("control.computeHighlightList",k)}if(this.isGraffitiMode()){const H=ie();this.graffiti.compute(),i("graffiti.compute",H)}}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let X=0;X<this.pageRowList.length;X++)this.pageList[X]||this._createPage(X);const b=this.pageRowList.length,S=this.pageList.length;if(S>b){const X=S-b;this.ctxList.splice(b,X),this.pageList.splice(b,X).forEach(O=>O.remove())}const y=ie();if(T&&N?this._lazyRender():this._immediateRender(),i(T&&N?"lazyRender":"immediateRender",y),g){if(L&&d?.tableId){const{index:X}=u,E=this.getOriginalElementList()[X];if(d.tableId!==E?.id){const D=this.findTableChildrenElement(!0,d.tableId,d);D&&u.index!==D.originalIndex&&(u.index=D.originalIndex,u.tableId=D.table.id,u.trIndex=D.trIndex,u.trId=D.tr.id,u.tdIndex=D.tdIndex,u.tdId=D.td.id,P=D.elementIndex,this.position.setPositionContext(u),this.range.setRange(P,P),this.updateTableTool())}const W=this.getElementList();W[a]!==d&&(P=W.findIndex(D=>D===d))}P=this.setCursor(P)}else this.range.getIsSelection()&&this.cursor.focus();if(m){let X;const O=this.position.getPositionContext();X=this.range.getRange().startIndex-1,O.index=X}(f&&!I||P!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(P);const V=ie();Ti(()=>{const X=ie();this.range.setRangeStyle(),L&&this.control.getActiveControl()&&this.control.reAwakeControl(),L&&!this.isReadonly()&&this.getMode()!==s.EditorMode.FORM&&u.isTable&&this.getOriginalElementList()[u.index].type===s.ElementType.TABLE&&this.tableTool.render(),L&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),Y!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(f||p)&&!C&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"));const O=ie();mi(this.options,M||"render",O-e,[...n,{label:"nextTick.wait",duration:X-V},{label:"nextTick.callback",duration:O-X}],{isCompute:L,pageCount:this.pageRowList.length})}),g&&this.fixPosition()}fixPosition(t=!1){let e;const n=this.position.getPositionContext();if(n.isTable){const i=this.getElementList(),l=this.range.getRange().startIndex;if(t||l>=i.length){const r=this.getTd(),a=n.index+(t?-1:1),d=this.getOriginalElementList()[a];if(!d?.trList)return;e=l-i.length;for(let u=0;u<d.trList.length;u++){const h=d.trList[u],R=h.tdList.find(f=>t?r?.linkTdPrevId===f.id:r?.id===f.linkTdPrevId);if(R){n.index=a,n.trIndex=u,n.tableId=d.id,n.trId=h.id,n.tdId=R?.id,e=t?R.value.length-1:e+(R.value[0]?.type===s.ElementType.SPLIT_TAG?1:0);break}}if(this.position.setPositionContext(n),this.range.setRange(e,e),this.setCursor(e),e===0)return this.fixPosition(t);this.updateTableTool()}}return e}getInlineBackgroundControlType(t,e){if(e===void 0)return;const n=t[e],i=n?.controlId;return i?n.control?.type?n.control.type:t.find(r=>r.controlId===i&&r.originControlId===n.originControlId&&!!r.control?.type)?.control?.type:void 0}getIsHideInlineBackgroundControlCursor(t,e){if(this.options.mode!==s.EditorMode.EDIT&&this.options.mode!==s.EditorMode.FORM)return!1;const n=e!==void 0?t[e]:void 0;if(n?.controlComponent===s.ControlComponent.POSTFIX||n?.controlComponent===s.ControlComponent.POST_TEXT||n?.controlComponent===s.ControlComponent.POSTTEXTFIX||n?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)return!1;const i=this.getInlineBackgroundControlType(t,e);return!!(i&&[s.ControlType.SELECT,s.ControlType.DATE].includes(i))}setCursor(t){const e=this.position.getPositionContext(),n=this.position.getPositionList(),i=this.getElementList();if(e.isTable){const{index:r,trIndex:a,tdIndex:c}=e,u=this.getOriginalElementList()[r].trList?.[a].tdList[c].positionList;t===void 0&&u&&(t=u.length-1);const h=u?.[t];this.position.setCursorPosition(h||null)}else t!==void 0&&t>=n.length&&(t=n.length-1),this.position.setCursorPosition(t!==void 0&&t>=0?n[t]:null);let l=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const r=i[t];if(r&&Xa.includes(r.type)){l=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(r,a)}}return l&&this.getIsHideInlineBackgroundControlCursor(i,t)&&(l=!1),this.cursor.drawCursor({isShow:l}),t}submitHistory(t){const e=this.position.getPositionContext(),n=yi(this.elementList),i=yi(this.header.getElementList()),l=yi(this.footer.getElementList()),r=at(this.range.getRange()),a=this.pageNo,c=at(e),d=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(d),this.setPageNo(a),this.position.setPositionContext(at(c)),this.header.setElementList(at(i)),this.footer.setElementList(at(l)),this.elementList=at(n),this.range.replaceRange(at(r)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.macroParticle.clearInlineEditor({isSubmitHistory:!1}),this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getMacroParticle().clearInlineEditor({isSubmitHistory:!1}),this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}updateTableTool(){if(this.getMode()===s.EditorMode.FORM){this.getTableTool().dispose();return}if(this.position.getPositionContext().isTable){const t=this.position.getPositionList();t.length&&(this.setPageNo(t[0].pageNo),this.getTableTool().render())}}initTableElementIndex(t,e){t.trList?.forEach((n,i)=>{n.tdList.forEach((l,r)=>{l.tableIndex=e,l.tableId=t.id,l.trIndex=i,l.trId=n.id,l.tdIndex=r,this.tdMap.set(l.id,l)})})}clearElementEffect(t){t.trList?.forEach(e=>{e.minHeight=e.originalMinHeight??e.minHeight,delete e.originalMinHeight,e.tdList.forEach(n=>{delete n.linkTdNextId})})}updateElementTableInfo(t,e,n,i){return t.tableId=e.id,t.trId=n.id,t.tdId=i.id,t}findTableChildrenElement(t,e,n){const i=this.position.getPositionContext(),{index:l}=i,r=this.getOriginalElementList();let a=l;t&&(a=l>r.length?r.length-1:l);for(let c=a;t?c>=0:c<r.length;t?c--:c++){const d=r[c];if(d&&[d.originalId,d.id].includes(e))for(const[u,h]of d.trList.entries())for(const[R,f]of h.tdList.entries()){const g=f.value.findIndex(typeof n=="function"?n:T=>T===n);if(g>=0)return{originalIndex:c,table:d,tr:h,trIndex:u,td:f,tdIndex:R,elementIndex:g}}}}getTdById(t){return this.tdMap.get(t)}getLinkTdPrevHasValue(t){const e=this.getTdById(t);if(e)return e.value.length?e:this.getLinkTdPrevHasValue(e.linkTdPrevId)}getFirstLinkTd(t){const e=this.getTdById(t);return e?.linkTdPrevId?this.getLastLinkTd(e.linkTdPrevId):e}getLastLinkTd(t){const e=this.getTdById(t);return e?.linkTdNextId?this.getLastLinkTd(e.linkTdNextId):e}removeLinkTd(t,e){const n=this.getTdById(e);if(n){if(n.linkTdPrevId){const i=this.getTdById(n.linkTdPrevId);i&&(delete i.linkTdNextId,this.removeLinkTd(t,n.linkTdPrevId))}if(n.linkTdNextId){const i=this.getTdById(n.linkTdNextId);i&&(delete i.linkTdPrevId,this.removeLinkTd(t,n.linkTdNextId))}t[n.tableIndex].trList[n.trIndex].tdList.splice(n.tdIndex,1),this.initTableElementIndex(t[n.tableIndex],n.tableIndex)}}removeLinkTdControl(t,e){const n=this.getTdById(t);if(n){for(let i=0;i<n.value.length;i++)n.value[i].control===e&&(n.value.splice(i,1),i--);n.linkTdNextId&&this.removeLinkTdControl(n.linkTdNextId,e)}}isSplitTd(t,e){return(!!t?.originalId||!!e?.originalId)&&(t?.originalId===e?.originalId||t?.id===e?.originalId||t?.originalId===e?.id)}getSplitTdValues(t){return this.splitTdValueMap.get(t)}removeSplitTdOtherRangeElements(){const{splitTdRange:t}=this.range.getRange();if(!t)return;const{startIndex:e,endIndex:n}=t;let i=this.getTd();if(i)if((i.valueStartIndex??0)>=e){let l=-1;for(;l<0;){const r=this.getTdById(i.linkTdPrevId);if(r){l=e-(r.valueStartIndex??0);const a=Math.max(0,l);this.spliceElementList(r.value,a+1,r.value.length-a-1),i=r}else l=0}}else{let l=1;for(;l>0;){const r=this.getTdById(i.linkTdNextId);if(r){const a=r.valueStartIndex??0;l=n-(a+r.value.length);const c=Math.min(r.value.length,n-a+1);this.spliceElementList(r.value,0,c),i=r}else l=0}}}getTablesByPagingId(t,e,n){const i=[],l=[];if(t[n].pagingId===e){i.push(n),l.push(t[n]);for(let r=n-1;r>=0&&t[r].pagingId===e;r--)l.unshift(t[r]),i.push(r);for(let r=n+1;r<t.length&&t[r].pagingId===e;r++)l.push(t[r]),i.push(r)}return{list:l,startIndex:i.sort()[0]}}}class Kl{executeMode;executeCut;executeCopy;executePaste;executeSelectAll;executeBackspace;executeSetRange;executeReplaceRange;executeSetPositionContext;executeForceUpdate;executeBlur;executeHideCursor;executeUndo;executeRedo;executePainter;executeApplyPainterStyle;executeFormat;executeFont;executeButton;executeEditElementAttribute;executeTriggerControlEditAttribute;executeCopyControl;executePasteControl;executeSize;executeSizeAdd;executeSizeMinus;executeBold;executeItalic;executeUnderline;executeStrikeout;executeSuperscript;executeSubscript;executeColor;executeHighlight;executeTitle;executeList;executeRowFlex;executeVertical;executeRowMargin;executeInsertTable;executeInsertTableTopRow;executeInsertTableBottomRow;executeInsertTableLeftCol;executeInsertTableRightCol;executeDeleteTableRow;executeDeleteTableCol;executeDeleteTable;executeMergeTableCell;executeCancelMergeTableCell;executeSplitVerticalTableCell;executeSplitHorizontalTableCell;executeTableTdVerticalAlign;executeTableBorderType;executeTableBorderColor;executeTableTdBorderType;executeTableTdSlashType;executeTableTdBackgroundColor;executeTableSelectAll;executeTableProperties;executeImage;executeHyperlink;executeDeleteHyperlink;executeCancelHyperlink;executeEditHyperlink;executeSeparator;executePageBreak;executeAddWatermark;executeDeleteWatermark;executeSearch;executeSearchNavigatePre;executeSearchNavigateNext;executeReplace;executePrint;executeReplaceImageElement;executeSaveAsImageElement;executeSetImageCrop;executeSetImageCaption;executeChangeImageDisplay;executePageMode;executePageScale;executePageScaleRecovery;executePageScaleMinus;executePageScaleAdd;executePaperSize;executePaperDirection;executeSetPaperMargin;executeSetMainBadge;executeSetAreaBadge;executeInsertElementList;executeInsertArea;executeSetAreaValue;executeSetAreaProperties;executeLocationArea;executeClearGraffiti;executeAppendElementList;executeUpdateElementById;executeDeleteElementById;executeSetValue;executeRemoveControl;executeTranslate;executeSetLocale;executeLocationCatalog;executeWordTool;executeSetHTML;executeSetGroup;executeDeleteGroup;executeLocationGroup;executeSetZone;executeSetControlValue;executeSetControlValueList;executeSetControlExtension;executeSetControlExtensionList;executeSetControlProperties;executeSetControlPropertiesList;executeSetControlHighlight;executeSetControlQualityMarks;executeSetButtonContent;executeLocationControl;executeInsertControl;executeInsertTextField;executeJumpControl;executeUpdateOptions;executeSetFormModeTrace;executeInsertTitle;executeFocus;executeComputeElementListHeight;getCatalog;getImage;getPageMode;getOptions;getValue;getValueAsync;getAreaValue;getHTML;getText;getWordCount;getCursorPosition;getRemainingContentHeight;getRange;getRangeText;getRangeContext;getRangeRow;getRangeParagraph;getKeywordRangeList;getKeywordContext;getPaperMargin;getSearchNavigateInfo;getLocale;getGroupIds;getControlValue;getButtonContent;getControlList;getContainer;getTitleValue;getPositionContextByEvent;getElementById;getMacroValue;getMacroList;setMacroValue;setMacroValueList;updateMacroProperties;locationMacro;insertSubTemplate;updateSubTemplate;expandSubTemplate;collapseSubTemplate;toggleSubTemplate;constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeButton=t.buttonText.bind(t),this.executeEditElementAttribute=t.editElementAttribute.bind(t),this.executeTriggerControlEditAttribute=t.triggerControlEditAttribute.bind(t),this.executeCopyControl=t.copyControl.bind(t),this.executePasteControl=t.pasteControl.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.executeVertical=t.vertical.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeTableProperties=t.tableProperties.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeSetFormModeTrace=t.setFormModeTrace.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getPageMode=t.getPageMode.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.executeSetControlQualityMarks=t.setControlQualityMarks.bind(t),this.executeSetButtonContent=t.setButtonContent.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getButtonContent=t.getButtonContent.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeInsertTextField=t.insertTextField.bind(t),this.executeJumpControl=t.jumpControl.bind(t),this.getMacroValue=t.getMacroValue.bind(t),this.getMacroList=t.getMacroList.bind(t),this.setMacroValue=t.setMacroValue.bind(t),this.setMacroValueList=t.setMacroValueList.bind(t),this.updateMacroProperties=t.updateMacroProperties.bind(t),this.locationMacro=t.locationMacro.bind(t),this.insertSubTemplate=t.insertSubTemplate.bind(t),this.updateSubTemplate=t.updateSubTemplate.bind(t),this.expandSubTemplate=t.expandSubTemplate.bind(t),this.collapseSubTemplate=t.collapseSubTemplate.bind(t),this.toggleSubTemplate=t.toggleSubTemplate.bind(t)}}function Hf(o,t){return o===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:o===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:o===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${o}px`,height:`${t}px`}}function Af(o,t){const{width:e,height:n,direction:i=s.PaperDirection.VERTICAL}=t,l=document.createElement("iframe");l.style.visibility="hidden",l.style.position="absolute",l.style.left="0",l.style.top="0",l.style.width="0",l.style.height="0",l.style.border="none",document.body.append(l);const r=l.contentWindow,a=r.document;a.open();const c=document.createElement("div"),d=Hf(e,n);o.forEach(R=>{const f=document.createElement("img");f.style.width=i===s.PaperDirection.HORIZONTAL?d.height:d.width,f.style.height=i===s.PaperDirection.HORIZONTAL?d.width:d.height,f.src=R,c.append(f)});const u=document.createElement("style"),h=`
565
565
  * {
566
566
  margin: 0;
567
567
  padding: 0;
@@ -579,4 +579,4 @@ ${h} `}textToElements(t){const e=[],n=t.split(`
579
579
  `?K:h.value,buttonValueLayout:h.buttonValueLayout,buttonValueLayoutPrefixOffset:h.buttonValueLayoutPrefixOffset,controlComponent:s.ControlComponent.VALUE,color:this.options.defaultColor,highlight:void 0})}),d}replaceButtonRenderedValue(t,e,n){const{startIndex:i,endIndex:l}=this.getButtonControlRange(t);let r=i,a=l;for(let f=i;f<=l;f++){const g=t.elementList[f];if(g.controlComponent===s.ControlComponent.PREFIX)r=f;else if(g.controlComponent===s.ControlComponent.POSTFIX){a=f;break}}const c=r+1,d=Math.max(a-r-1,0);t.elementList.splice(c,d,...e);const h=this.hasButtonContent(n)?at(n):null,R=r+e.length+1;for(let f=r;f<=R;f++){const g=t.elementList[f];this.isSameButtonControlElement(g,t)&&g.control&&(g.control.value=h?at(h):null,g.control.hide=!1)}return e.length?r+e.length:r}getIsRangeInTextField(){const{startIndex:t}=this.range.getRange(),e=this.draw.getElementList(),n=e[t];if(!n)return!1;let i=null;const l=r=>{if(!r)return null;for(let a=t;a>=0;a--){const c=e[a];if(c.controlId===r&&c.control?.type===s.ControlType.TEXTFIELD&&(c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRE_TEXT))return r}return null};return i=l(n.controlId)||l(n.originControlId),!!i}mode(t){this.draw.setMode(t)}async cut(){this.draw.isReadonly()||this.draw.isDisabled()||await this.canvasEvent.cut()}async copy(t){await this.canvasEvent.copy(t)}paste(t){this.draw.isReadonly()||this.draw.isDisabled()||Yc(this.canvasEvent,t)}copyControl(t){if(!t)return;const e=Yt(this.draw.getElementList(),{editorOptions:this.options}),n=ri(e,t);n&&Xc({element:n})}pasteControl(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=cr();if(!e?.element)return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.draw.getElementList(),r=Bf(e.element),a=r.controlId;if(!a)return;const c=Si([r]);if(!c.length)return;qt(c,{isHandleFirstElement:!1,editorOptions:this.options});let d=n,u=n,h=i,R=!1,f;const g=n===i;let T=this.control.getActiveControl();!T&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),T=this.control.getActiveControl());const C=T?.getElement();if(C?.control?.type&&_f.includes(C.control.type)&&this.control.getIsRangeWithinControl()){R=!0,f=C.controlId;const m=l[n];g&&(m?.control?.type===s.ControlType.TEXTFIELD||m?.control?.type===s.ControlType.TEXT)&&this.control.removePlaceholder(n)}else if(C?.controlId){const m=kf(l,C.controlId,C.originControlId);~m&&(d=m,u=m,h=m)}se(l,c,d,{isBreakWhenWrap:!0,editorOptions:this.options}),f&&c.forEach(m=>{m.controlId===a&&!m.originControlId&&(m.originControlId=f)});const p=d+1;u!==h&&this.draw.spliceElementList(l,u+1,h-u),this.draw.spliceElementList(l,p,0,c);const I=d+c.length;this.range.setRange(I,I),this.draw.render({curIndex:I}),R&&this.control.emitControlContentChange()}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.draw.getElementList(),{startIndex:n,endIndex:i}=this.range.getRange(),l=n===i;if(l&&e[n].value===K&&n===0)return;l?this.draw.spliceElementList(e,n,1):this.draw.spliceElementList(e,n+1,i-n);const r=l?n-1:n;this.range.setRange(r,r),this.draw.render({curIndex:r})}setRange(t,e,n,i,l,r,a){if(t<0||e<0||e<t)return;this.range.setRange(t,e,n,i,l,r,a);const c=t===e;this.draw.render({curIndex:c?t:void 0,isCompute:!1,isSubmitHistory:!1,isSetCursor:c})}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}setPositionContext(t){const{tableId:e,startTrIndex:n,startTdIndex:i}=t,l=this.draw.getOriginalElementList();if(e){const r=l.findIndex(u=>u.id===e);if(!~r)return;const c=l[r].trList[n],d=c.tdList[i];this.position.setPositionContext({isTable:!0,index:r,trIndex:n,tdIndex:i,tdId:d.id,trId:c.id,tableId:e})}else this.position.setPositionContext({isTable:!1})}forceUpdate(t){const{isSubmitHistory:e=!1}=t||{};this.range.clearRange(),this.draw.render({isSubmitHistory:e,isSetCursor:!1})}blur(){this.range.clearRange(),this.draw.getCursor().recoveryCursor()}hideCursor(){this.draw.getCursor().recoveryCursor()}undo(){this.draw.isReadonly()||this.historyManager.undo()}redo(){this.draw.isReadonly()||this.historyManager.redo()}painter(t){if(!t.isDblclick&&this.draw.getPainterStyle()){this.canvasEvent.clearPainterStyle();return}const e=this.range.getSelection();if(!e)return;const n={};e.forEach(i=>{Ne.forEach(r=>{const a=r;n[a]===void 0&&Reflect.set(n,a,i[a])})}),this.draw.setPainterStyle(n,t)}applyPainterStyle(){this.draw.isReadonly()||this.draw.isDisabled()||this.canvasEvent.applyPainterStyle()}format(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();let l={},r=[];if(i?.length)r=i,l={isSetCursor:!1};else{const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];d?.value===K&&(r.push(d),l={curIndex:a})}r.length&&(r.forEach(a=>{Ne.forEach(c=>{delete a[c]})}),this.draw.render(l))}buttonText(t){if(t)if([...Array.isArray(t.element)?t.element:t.elementList||[t.element]].filter(l=>l.newButtonValue&&l.newButtonValue.length>0).length){const l=t.controlId;this.removeButtonElementsByControlId(l+"_text").then(()=>{setTimeout(()=>{this.insertButtonValue(t)},500)})}else{const l=t.controlId;l&&this.removeButtonElementsByControlId(l+"_text")}}triggerControlEditAttribute(t,e){const n=this.draw.getElementList(),i=[];t&&Os(n,a=>{a.controlId===t&&i.push(a)});const l=i.length?i:e?[e]:[];this.draw.getEventBus().emit("controlEditAttribute",{controlId:t,element:l,targetElement:e||i[0]||null,isControl:!!t})}editElementAttribute(t){const e=this.draw.getElementList();if(t.controlId&&t.type==="button"){const n=Object.prototype.hasOwnProperty.call(t,"action"),i=[];let l="",r="",a=!1,c=!1,d="",u=!1;e.forEach((p,I)=>{if(p.controlId!==t.controlId||p.control?.type!==s.ControlType.BUTTON)return;const m=p.control.buttonLabel||p.control.label||"";!l&&m&&(l=m),u||(u=!0,d=p.control.placeholder||"");const L=p.control.value||[],P=this.getButtonContentText(L);P.trim()&&P!==m&&(a=!0),P.trim()&&P===m&&(c=!0),p.controlComponent===s.ControlComponent.VALUE&&(i.push(I),r+=p.value===K?`
580
580
  `:p.value||"")});const h=!!(!a&&l&&(r===l||c)),R=t.placeholder!==void 0?t.placeholder:d;if(h&&i.sort((p,I)=>I-p).forEach(p=>{e.splice(p,1)}),e.forEach(p=>{p.controlId===t.controlId&&p.control?.type===s.ControlType.BUTTON&&(t.label!==void 0&&(p.control.buttonLabel=t.label,p.control.label=t.label),p.control.placeholder=R,t.code!==void 0&&(p.control.code=t.code),h&&(p.control.value=null),p.control.hide=!1,n&&(t.action?p.control.action=t.action:delete p.control.action),t.editable!==void 0&&(p.control.editable=t.editable),t.valueLayout!==void 0&&(p.control.valueLayout=Yn(t.valueLayout)),p.hide=!1)}),t.valueLayout!==void 0){const p=this.findButtonControlContext(t.controlId);if(p){const I=this.getButtonBusinessValue(p),m=this.createButtonBusinessElements(p,I);this.replaceButtonRenderedValue(p,m,I)}}this.syncButtonPlaceholderElements(e,t.controlId,R);const{startIndex:f,endIndex:g}=this.range.getRange(),T=!0,C=g;this.draw.render({curIndex:C,isSetCursor:T})}else if(t.controlId){const n=t.controlId;if(e.forEach(l=>{l.controlId===n&&l.control&&(t.label!==void 0&&(l.control.label=t.label),t.placeholder!==void 0&&(l.control.placeholder=t.placeholder),t.code!==void 0&&(l.control.code=t.code),t.value!==void 0&&(l.control.value=t.value?[{value:t.value}]:null),t.valueSets!==void 0&&(l.control.valueSets=t.valueSets),t.dateFormat!==void 0&&(l.control.dateFormat=t.dateFormat),t.numberExclusiveOptions!==void 0&&(l.control.numberExclusiveOptions=t.numberExclusiveOptions),t.underline!==void 0&&(l.control.underline=t.underline))}),t.placeholder!==void 0){const l=t.placeholder,r=[];if(e.forEach((a,c)=>{a.controlId===n&&a.controlComponent==="placeholder"&&r.push({element:a,index:c})}),r.length===l.length)r.forEach((a,c)=>{a.element.value=l[c]===`
581
581
  `?K:l[c]});else if(r.length>0){const a={...r[0].element};r.sort((d,u)=>u.index-d.index).forEach(d=>{e.splice(d.index,1)});const c=Math.min(...r.map(d=>d.index));for(let d=0;d<l.length;d++){const u=l[d]===`
582
- `?K:l[d];e.splice(c+d,0,{...a,value:u})}}}const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isSetCursor:!0})}}delButton(t,e){return new Promise(n=>{for(let i=t.length-1;i>=0;i--)e.some(r=>r.controlId===t[i].controlId&&r.type===t[i].type)&&t.splice(i,1);n(!0)})}editButton(t,e,n){const i=this.draw.getElementList();n=n+1;for(let d=0;d<e.label.length;d++){const u={value:e.label[d],controlId:e.controlId,type:s.ElementType.CONTROL,control:{type:"button",buttonLabel:e.label,code:e.code,value:[{value:e.label}],label:e.label,hide:!1},controlComponent:"value",color:"#fff",highlight:"#1677FF",style:"16px Microsoft YaHei",hide:!1};i.splice(n+d,0,u)}const{startIndex:l,endIndex:r}=this.range.getRange(),a=!0,c=r;this.draw.render({curIndex:c,isSetCursor:a})}removeButtonElementsByControlId(t){return new Promise(e=>{const n=this.draw.getElementList();for(let c=n.length-1;c>=0;c--)n[c].controlId===t&&n.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),e(!0)})}removeByValue(t,e){return new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text"||t[c].type=="buttonText")&&t[c].control?.buttonLabel===e&&t[c].control?.buttonText&&t.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),n(!0)})}insertButtonValue(t){const e=this.draw.getElementList(),n=t.controlId,l=(Array.isArray(t.element)?t.element:t.elementList||[t.element])[0],r=l.newButtonValue,a=l.control.buttonLabel,c=l.control.code;if(!r||!r.length)return;let d=-1;for(let I=0;I<e.length;I++)if(e[I].controlId===n&&e[I].control?.type==="button"){d=I;break}if(d===-1)return;const u=n+"_text",h=[];for(let I=0;I<r.length;I++){const m=r[I];h.push({value:m.value,code:m.code})}const R={type:"button",buttonLabel:a,buttonText:!0,label:a,code:c,value:h,hide:!1},f=[];f.push({value:"[",controlId:u,type:s.ElementType.CONTROL,control:R,controlComponent:s.ControlComponent.PREFIX,color:"#1677FF",hide:!1});for(let I=0;I<r.length;I++){const m=r[I],L=r.length>1?`${I+1}.${m.value}`:m.value,P=Dt(L);for(let M=0;M<P.length;M++)f.push({value:P[M],controlId:u,type:s.ElementType.CONTROL,control:R,controlComponent:s.ControlComponent.VALUE,color:"#000",hide:!1});r.length>1&&I<r.length-1&&f.push({value:K,controlId:u,type:s.ElementType.CONTROL,control:R,controlComponent:s.ControlComponent.VALUE,color:"#000",hide:!1})}f.push({value:"]",controlId:u,type:s.ElementType.CONTROL,control:R,controlComponent:s.ControlComponent.POSTFIX,color:"#1677FF",hide:!1});for(let I=0;I<f.length;I++)e.splice(d+I,0,f[I]);const{startIndex:g,endIndex:T}=this.range.getRange(),C=!0,p=T;this.draw.render({curIndex:p,isSetCursor:C})}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{r.font=t}),this.draw.render({isSetCursor:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({font:t}),d?.value===K?d.font=t:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:l,maxSize:r,defaultSize:a}=this.options;if(t<l||t>r)return;let c={},d=[];const u=this.range.getTextLikeSelectionElementList();if(u?.length)d=u,c={isSetCursor:!1};else{const{endIndex:R}=this.range.getRange(),g=this.draw.getElementList()[R];this.range.setDefaultStyle({size:t}),g?.value===K?(d.push(g),c={curIndex:R}):this.draw.render({curIndex:R,isCompute:!1,isSubmitHistory:!1})}if(!d.length)return;let h=!1;d.forEach(R=>{!R.size&&t===a||R.size&&R.size===t||(R.size=t,h=!0)}),h&&this.draw.render(c)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,maxSize:l}=this.options,r=this.range.getTextLikeSelectionElementList();let a={},c=[];if(r?.length)c=r,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange(),R=this.draw.getElementList()[u],g=this.range.getDefaultStyle()?.size||R.size||i;this.range.setDefaultStyle({size:g+2>l?l:g+2}),R?.value===K?(c.push(R),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(u=>{u.size||(u.size=i),!(u.size>=l)&&(u.size+2>l?u.size=l:u.size+=2,d=!0)}),d&&this.draw.render(a)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,minSize:l}=this.options,r=this.range.getTextLikeSelectionElementList();let a={},c=[];if(r?.length)c=r,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange(),R=this.draw.getElementList()[u],g=this.range.getDefaultStyle()?.size||R.size||i;this.range.setDefaultStyle({size:g-2<l?l:g-2}),R?.value===K?(c.push(R),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(u=>{u.size||(u.size=i),!(u.size<=l)&&(u.size-2<l?u.size=l:u.size-=2,d=!0)}),d&&this.draw.render(a)}bold(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.bold);i.forEach(r=>{r.bold=!!~l}),this.draw.render({isSetCursor:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({bold:c.bold?!1:!this.range.getDefaultStyle()?.bold}),c?.value===K?c.bold=!c.bold:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}italic(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.italic);i.forEach(r=>{r.italic=!!~l}),this.draw.render({isSetCursor:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({italic:c.italic?!1:!this.range.getDefaultStyle()?.italic}),c?.value===K?c.italic=!c.italic:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}underline(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length){const r=l.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!pa(a.textDecoration,t));l.forEach(a=>{a.underline=r,r&&t?a.textDecoration=t:delete a.textDecoration}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({underline:d?.underline?!1:!this.range.getDefaultStyle()?.underline}),d?.value===K?d.underline=!d.underline:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}strikeout(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.strikeout);i.forEach(r=>{r.strikeout=!!~l}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({strikeout:c.strikeout?!1:!this.range.getDefaultStyle()?.strikeout}),c?.value===K?c.strikeout=!c.strikeout:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const l=i.findIndex(r=>r.type===s.ElementType.SUPERSCRIPT);i.forEach(r=>{~l?r.type===s.ElementType.SUPERSCRIPT&&(r.type=s.ElementType.TEXT,delete r.actualSize):(!r.type||r.type===s.ElementType.TEXT||r.type===s.ElementType.SUBSCRIPT)&&(r.type=s.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const l=i.findIndex(r=>r.type===s.ElementType.SUBSCRIPT);i.forEach(r=>{~l?r.type===s.ElementType.SUBSCRIPT&&(r.type=s.ElementType.TEXT,delete r.actualSize):(!r.type||r.type===s.ElementType.TEXT||r.type===s.ElementType.SUPERSCRIPT)&&(r.type=s.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{t?r.color=t:delete r.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({color:t||void 0}),d?.value===K?t?d.color=t:delete d.color:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{t?r.highlight=t:delete r.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({highlight:t||void 0}),d?.value===K?t?d.highlight=t:delete d.highlight:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.draw.getElementList(),r=n===i?this.range.getRangeParagraphElementList():l.slice(n+1,i+1);if(!r||!r.length)return;const a=mt(),c=this.draw.getOptions().title;r.forEach(h=>{!h.type&&h.value===K||(t?(h.level=t,h.titleId=a,yo(h)&&(h.size=c[ks[t]],h.bold=!0)):h.titleId&&(delete h.titleId,delete h.title,delete h.level,delete h.size,delete h.bold))});const d=n===i,u=d?i:n;this.draw.render({curIndex:u,isSetCursor:d})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.rowFlex=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}vertical(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.vertical=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.rowMargin=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}insertTable(t,e){this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl()||this.tableOperate.insertTable(t,e)}insertTableTopRow(){this.draw.isReadonly()||this.tableOperate.insertTableTopRow()}insertTableBottomRow(){this.draw.isReadonly()||this.tableOperate.insertTableBottomRow()}insertTableLeftCol(){this.draw.isReadonly()||this.tableOperate.insertTableLeftCol()}insertTableRightCol(){this.draw.isReadonly()||this.tableOperate.insertTableRightCol()}deleteTableRow(){this.draw.isReadonly()||this.tableOperate.deleteTableRow()}deleteTableCol(){this.draw.isReadonly()||this.tableOperate.deleteTableCol()}deleteTable(){this.draw.isReadonly()||this.tableOperate.deleteTable()}mergeTableCell(){this.draw.isReadonly()||this.tableOperate.mergeTableCell()}cancelMergeTableCell(){this.draw.isReadonly()||this.tableOperate.cancelMergeTableCell()}splitVerticalTableCell(){this.draw.isReadonly()||this.tableOperate.splitVerticalTableCell()}splitHorizontalTableCell(){this.draw.isReadonly()||this.tableOperate.splitHorizontalTableCell()}tableTdVerticalAlign(t){this.draw.isReadonly()||this.tableOperate.tableTdVerticalAlign(t)}tableBorderType(t){this.draw.isReadonly()||this.tableOperate.tableBorderType(t)}tableBorderColor(t){this.draw.isReadonly()||this.tableOperate.tableBorderColor(t)}tableTdBorderType(t){this.draw.isReadonly()||this.tableOperate.tableTdBorderType(t)}tableTdSlashType(t){this.draw.isReadonly()||this.tableOperate.tableTdSlashType(t)}tableTdBackgroundColor(t){this.draw.isReadonly()||this.tableOperate.tableTdBackgroundColor(t)}tableSelectAll(){this.tableOperate.tableSelectAll()}tableProperties(){this.draw.isReadonly()||this.tableOperate.tableProperties()}hyperlink(t){const{valueList:e,url:n,hyperlinkId:i}=t;if(!n||!e?.length||this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:a,endIndex:c}=this.range.getRange();!~a&&!~c||this.insertElementList([{type:s.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:i||mt()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=this.draw.getElementList(),r=l[n];if(r.type!==s.ElementType.HYPERLINK)return null;let a=n;for(;a>0;){if(l[a].hyperlinkId!==r.hyperlinkId){t=a+1;break}a--}let c=n+1;for(;c<l.length;){if(l[c].hyperlinkId!==r.hyperlinkId){e=c-1;break}c++}return c===l.length&&(e=c-1),!~t||!~e?null:[t,e]}deleteHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,l]=e;this.draw.spliceElementList(n,i,l-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const r=i-1;this.range.setRange(r,r),this.draw.render({curIndex:r})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,l]=e;for(let a=i;a<=l;a++){const c=n[a];delete c.type,delete c.url,delete c.hyperlinkId,delete c.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const i=this.draw.getElementList(),[l,r]=n;for(let c=l;c<=r;c++){const d=i[c];d.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:a}=this.range.getRange();this.draw.render({curIndex:a,isCompute:!1})}separator(t,e){if(this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl())return;const{startIndex:l,endIndex:r}=this.range.getRange();if(!~l&&!~r)return;const a=this.draw.getElementList();let c=-1;const d=a[r+1];if(d&&d.type===s.ElementType.SEPARATOR){if(d.dashArray&&d.dashArray.join()===t.join())return;c=r,Object.assign(d,{dashArray:t,...e})}else{const u={value:Xs,type:s.ElementType.SEPARATOR,dashArray:t,...e};se(a,[u],l,{editorOptions:this.options}),l!==0&&a[l].value===K?(this.draw.spliceElementList(a,l,1,[u]),c=l-1):(this.draw.spliceElementList(a,l+1,0,[u]),c=l)}this.range.setRange(c,c),this.draw.render({curIndex:c})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:s.ElementType.PAGE_BREAK,value:Xs}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:i,size:l,opacity:r,font:a,gap:c}=Oi;n.watermark.data=t.data,n.watermark.type=t.type||s.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||i,n.watermark.opacity=t.opacity||r,n.watermark.size=t.size||l,n.watermark.font=t.font||a,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||c,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={...Oi},this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=t.id||mt();return this.insertElementList([{...t,id:l,type:s.ElementType.IMAGE}]),l}search(t,e){this.searchManager.setSearchKeyword(t,e),this.draw.render({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,e){this.draw.getSearch().replace(t,e)}async print(){const{scale:t,printPixelRatio:e,paperDirection:n,width:i,height:l}=this.options;t!==1&&this.draw.setPageScale(1);const r=await this.draw.getDataURL({pixelRatio:e,mode:s.EditorMode.PRINT});Af(r,{width:i,height:l,direction:n}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==s.ElementType.IMAGE||(i.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==s.ElementType.IMAGE||Vs(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==s.ElementType.IMAGE||(i.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];i?.type===s.ElementType.IMAGE&&(i.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:i}=this.range.getRange();if(e===s.ImageDisplay.SURROUND||e===s.ImageDisplay.FLOAT_TOP||e===s.ImageDisplay.FLOAT_BOTTOM){const l=this.position.getPositionList(),{pageNo:r,coordinate:{leftTop:a}}=l[n];t.imgFloatPosition={pageNo:r,x:a[0],y:a[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:i})}getImage(t){return this.draw.getDataURL(t)}getPageMode(){return this.options}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getValueAsync(t){return this.draw.getWorkerManager().getValue(t)}getAreaValue(t){return this.draw.getArea().getAreaValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:vn(e,t).innerHTML,main:vn(n,t).innerHTML,footer:vn(i,t).innerHTML}}getText(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:Mn(e,t),main:Mn(n,t),footer:Mn(i,t)}}getWordCount(){return this.workerManager.getWordCount()}getCursorPosition(){return this.position.getCursorPosition()}getRemainingContentHeight(){if(!this.draw.getIsPagingMode())return 0;const t=this.draw.getPageRowList(),e=t.length-1,i=(t[e]||[]).reduce((c,d)=>c+d.height+(d.offsetY||0),0),l=this.draw.getHeight(),r=this.draw.getMainOuterHeight(),a=l-(r+i);return a>0?a:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=at(t);qt(n,{isHandleFirstElement:!1,editorOptions:this.options});const i=bi(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:i}).reduce((r,a)=>r+a.height+(a.offsetY||0),0)}getRange(){return at(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const i=e===n,l=this.range.toString(),r=Yt(this.range.getSelectionElementList()||[]),a=this.draw.getElementList(),c=hn(a[i?e:e+1],{extraPickAttrs:["id","controlComponent"]}),d=hn(a[n],{extraPickAttrs:["id","controlComponent"]}),u=this.draw.getRowList(),h=this.position.getPositionList(),R=h[e],f=h[n],g=R?.pageNo,T=f?.pageNo,C=R?.rowIndex,p=f?.rowIndex,I=u[C],m=u[p];let L=0,P=0;this.draw.getCursor().getHitLineStartIndex()||(L=I?.elementList[0]?.value===K?R?.index-I?.startIndex:R?.index-I?.startIndex+1),R===f?P=L:P=m.elementList[0]?.value===K?f.index-m.startIndex:f.index-m.startIndex+1;const M=[],F=this.draw.getOriginalHeight(),N=this.draw.getOriginalPageGap(),Y=this.position.getSelectionPositionList();if(Y){let U=null,Z=0,Q=null;for(let v=0;v<Y.length;v++){const{rowNo:st,pageNo:B,coordinate:{leftTop:H,rightTop:k},lineHeight:q}=Y[v];U===null||U!==st?(Q&&M.push(Q),Q={x:H[0],y:H[1]+B*(F+N),width:k[0]-H[0],height:q},U=st,Z=H[0]):Q.width=k[0]-Z,v===Y.length-1&&Q&&M.push(Q)}}else{const Z=this.position.getPositionList()[n],{coordinate:{rightTop:Q},pageNo:v,lineHeight:st}=Z;M.push({x:Q[0],y:Q[1]+v*(F+N),width:0,height:st})}const b=this.draw.getZone().getZone(),{isTable:S,trIndex:y,tdIndex:V,index:X}=this.position.getPositionContext();let O=null;if(S){const Z=this.draw.getOriginalElementList()[X]||null;Z&&(O=Yt([Z])[0])}let E=null,W=null,D=e-1;for(;D>0;){const U=a[D],Z=a[D-1];if(U.titleId&&U.titleId!==Z?.titleId){E=U.titleId,W=h[D].pageNo;break}D--}return at({isCollapsed:i,startElement:c,endElement:d,startPageNo:g,endPageNo:T,startRowNo:C,endRowNo:p,startColNo:L,endColNo:P,rangeRects:M,zone:b,isTable:S,trIndex:y??null,tdIndex:V??null,tableElement:O,selectionText:l,selectionElementList:r,titleId:E,titleStartPageNo:W})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?Yt(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?Yt(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],i=this.position.getOriginalMainPositionList(),l=this.draw.getOriginalMainElementList();for(let r=0;r<e.length;r++){const a=e[r],{startIndex:c,endIndex:d,tableId:u,startTrIndex:h,startTdIndex:R}=a;let f=i;if(a.tableId){const C=l.find(p=>p.id===u);C&&(f=C.trList?.[h]?.tdList?.[R]?.positionList||[])}const g=at(f[c]),T=at(f[d]);n.push({range:a,startPosition:g,endPosition:T})}return n}pageMode(t){this.draw.setPageMode(t)}pageScale(t){t!==this.options.scale&&this.draw.setPageScale(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)}setMainBadge(t){this.draw.getBadge().setMainBadge(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}setAreaBadge(t){this.draw.getBadge().setAreaBadgeMap(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}insertElementList(t,e={}){if(!t.length||this.draw.isReadonly()||this.draw.isDisabled())return;const{isReplace:i=!0,ignoreContextKeys:l}=e;i||this.range.shrinkRange(),console.log(t,"payload");const r=at(t),{startIndex:a}=this.range.getRange(),c=this.draw.getElementList();se(c,r,a,{ignoreContextKeys:l,isBreakWhenWrap:!0,editorOptions:this.options}),console.log(r,"cloneElementList"),this.draw.insertElementList(r,e),setTimeout(()=>{console.log(c,"elementList")},500)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(at(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const i=[];function l(a,c=!1){let d=0;for(;d<a.length;){const u=a[d];if(d++,u.type===s.ElementType.TABLE){const h=u.trList;for(let R=0;R<h.length;R++){const f=h[R];for(let g=0;g<f.tdList.length;g++){const T=f.tdList[g];l(T.value,c)}}}u.type===s.ElementType.CONTROL&&u.control?.value&&l(u.control.value,!0),(e&&u.id===e||n&&u.conceptId===n)&&i.push({elementList:a,index:d-1,isInsideControl:c})}}const r=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);if(i.length){for(let a=0;a<i.length;a++){const{elementList:c,index:d,isInsideControl:u}=i[a],h=c[d],R=h.controlId&&h.controlComponent===s.ControlComponent.VALUE;if(u||R){if(Object.assign(h,t.properties),h.id){const f=gc(h.id);f&&Object.assign(f,t.properties)}}else{const f=Yt([{...h,...t.properties}],{extraPickAttrs:["id"]});f.length>0&&f[0]?(un(Rn,h,f[0]),qt(f,{isHandleFirstElement:!1,editorOptions:this.options}),c[d]=f[0]):Object.assign(h,t.properties)}}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let i=!1;function l(a){let c=0;for(;c<a.length;){const d=a[c];if(d.type===s.ElementType.TABLE){const u=d.trList;for(let h=0;h<u.length;h++){const R=u[h];for(let f=0;f<R.tdList.length;f++){const g=R.tdList[f];l(g.value)}}}d.type===s.ElementType.CONTROL&&d.control?.value&&l(d.control.value),(e&&d.id===e||n&&d.conceptId===n)&&(i=!0,a.splice(c,1),c--),c++}}const r=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);i&&this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,i=[];if(!e&&!n)return i;const l=a=>{let c=0;for(;c<a.length;){const d=a[c];if(c++,d.type===s.ElementType.TABLE){const u=d.trList;for(let h=0;h<u.length;h++){const R=u[h];for(let f=0;f<R.tdList.length;f++){const g=R.tdList[f];l(g.value)}}}e&&d.id!==e||n&&d.conceptId!==n||i.push(d)}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);return Yt(i,{extraPickAttrs:["id"]})}setValue(t,e){this.draw.setValue(t,e)}removeControl(t){if(t?.id||t?.conceptId){const{id:e,conceptId:n}=t;let i=!1;const l=a=>{let c=a.length-1;for(;c>=0;){const d=a[c];if(d.type===s.ElementType.TABLE){const u=d.trList;for(let h=0;h<u.length;h++){const R=u[h];for(let f=0;f<R.tdList.length;f++){const g=R.tdList[f];l(g.value)}}}c--,!(!d.control||e&&d.controlId!==e||n&&d.control.conceptId!==n)&&(i=!0,a.splice(c+1,1))}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);i&&this.draw.render({isSetCursor:!1})}else{const{startIndex:e,endIndex:n}=this.range.getRange();if(e!==n||!this.draw.getElementList()[e].controlId)return;const a=this.draw.getControl().removeControl(e);if(a===null)return;this.range.setRange(a,a),this.draw.render({curIndex:a})}}translate(t){return this.i18n.t(t)}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){const e=this.draw.getOriginalElementList();function n(p,I){for(let m=0;m<p.length;m++){const L=p[m];if(L.type===s.ElementType.TABLE){const P=L.trList;for(let M=0;M<P.length;M++){const F=P[M];for(let N=0;N<F.tdList.length;N++){const Y=F.tdList[N],b=n(Y.value,I);if(b)return{...b,isTable:!0,index:m,trIndex:M,tdIndex:N,tdId:Y.id,trId:F.id,tableId:L.id}}}}if(L.titleId===I){let P=m;for(;P<p.length;){if(p[P+1]?.titleId!==I)return{isTable:!1,startIndex:P,endIndex:P};P++}}}return null}const i=n(e,t);if(!i)return;const{isTable:l,index:r,startTdIndex:a,endTdIndex:c,startTrIndex:d,endTrIndex:u,trIndex:h,tdIndex:R,tdId:f,trId:g,tableId:T,endIndex:C}=i;this.position.setPositionContext({isTable:l,index:r,trIndex:h,tdIndex:R,tdId:f,trId:g,tableId:T}),this.range.setRange(C,C,T,a,c,d,u),this.draw.render({curIndex:C,isCompute:!1,isSubmitHistory:!1})}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let n=0;n<t.length;n++)if(t[n].value===K)for(;n+1<t.length;){const l=t[n+1];if(l.value!==K&&l.value!==ai)break;t.splice(n+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const n=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:n})}}setHTML(t){const{header:e,main:n,footer:i}=t,l=this.draw.getOriginalInnerWidth(),r=a=>a!==void 0?Qn(a,{innerWidth:l}):void 0;this.setValue({header:r(e),main:r(n),footer:r(i)})}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(),n=this.draw.getGroup().getContextByGroupId(e,t);if(!n)return;const{isTable:i,index:l,trIndex:r,tdIndex:a,tdId:c,trId:d,tableId:u,endIndex:h}=n;this.position.setPositionContext({isTable:i,index:l,trIndex:r,tdIndex:a,tdId:c,trId:d,tableId:u}),this.range.setRange(h,h),this.draw.render({curIndex:h,isCompute:!1,isSubmitHistory:!1})}setZone(t){this.draw.getZone().setZone(t)}getControlValue(t){return this.draw.getControl().getValueById(t)}getButtonContent(t){const{controlId:e}=t;if(!e)return null;const n=this.findButtonControlContext(e);return n?this.getButtonContentResult(this.getButtonBusinessValue(n)):null}setButtonContent(t){if(!(this.draw.getMode()===s.EditorMode.FORM)&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{controlId:i,mode:l,isSubmitHistory:r=!0}=t;if(!i)return;const a=this.findButtonControlContext(i);if(!a)return;const c=this.getButtonBusinessValue(a),d=this.normalizeButtonContentValue(t.value),u=l==="append"?this.appendButtonContentValue(c,d):d;this.removeButtonBusinessElements(a);const h=this.findButtonControlContext(i);if(!h)return;const R=this.createButtonBusinessElements(h,u),f=this.replaceButtonRenderedValue(h,R,u);this.syncButtonPlaceholderElements(h.elementList,i,h.element.control?.placeholder||""),r||this.historyManager.recovery(),this.draw.render({curIndex:f,isSubmitHistory:r,isSetCursor:!0})}setControlValue(t){this.draw.getControl().setValueListById([t])}setControlValueList(t){this.draw.getControl().setValueListById(t)}setControlExtension(t){this.draw.getControl().setExtensionListById([t])}setControlExtensionList(t){this.draw.getControl().setExtensionListById(t)}setControlProperties(t){this.draw.getControl().setPropertiesListById([t])}setControlPropertiesList(t){this.draw.getControl().setPropertiesListById(t)}setControlHighlight(t){this.draw.getControl().setHighlightList(t),this.draw.render({isSubmitHistory:!1})}setControlQualityMarks(t){this.draw.getControl().setQualityMarks(t),this.draw.render({isSetCursor:!1,isSubmitHistory:!1})}updateOptions(t){const e=Oo(t);Object.entries(e).forEach(([n,i])=>{Reflect.set(this.options,n,i)}),this.forceUpdate()}setFormModeTrace(t){Object.assign(this.options.modeRule.form,t),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){if(!t)return;function n(r,a,c){let d=0;for(;d<r.length;){const u=r[d];if(d++,u.type===s.ElementType.TABLE){const R=u.trList;for(let f=0;f<R.length;f++){const g=R[f];for(let T=0;T<g.tdList.length;T++){const C=g.tdList[T],p=n(C.value,a,c);if(p)return{...p,positionContext:{isTable:!0,index:d-1,trIndex:f,tdIndex:T,tdId:C.id,trId:g.id,tableId:u.id}}}}}if(!c(u))continue;let h=d-1;if(e?.position===s.LocationPosition.OUTER_AFTER){if(!(u.controlComponent===s.ControlComponent.POSTFIX&&r[d+1]?.controlComponent!==s.ControlComponent.POST_TEXT))continue}else if(e?.position===s.LocationPosition.OUTER_BEFORE)h-=1;else if(e?.position===s.LocationPosition.AFTER){if(h-=1,u.controlComponent!==s.ControlComponent.PLACEHOLDER&&u.controlComponent!==s.ControlComponent.POSTFIX&&u.controlComponent!==s.ControlComponent.POST_TEXT)continue}else if(u.controlComponent!==s.ControlComponent.PREFIX&&u.controlComponent!==s.ControlComponent.PRE_TEXT||r[d]?.controlComponent===s.ControlComponent.PREFIX||r[d]?.controlComponent===s.ControlComponent.PRE_TEXT)continue;return{zone:a,range:{startIndex:h,endIndex:h},positionContext:{isTable:!1}}}return null}const i=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}],l=[r=>r.controlId===t,r=>r.control?.conceptId===t,r=>r.control?.code===t];for(let r=0;r<l.length;r++)for(const a of i){const c=n(a.elementList,a.zone,l[r]);if(c){this.setZone(c.zone),this.position.setPositionContext(c.positionContext),this.range.replaceRange(c.range),this.draw.render({curIndex:c.range.startIndex,isCompute:!1,isSubmitHistory:!1});return}}}insertTextField(t){if(this.draw.isReadonly()||this.draw.isDisabled()||!t)return;const n=at(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Zn(l,i);if(!r)return;const a=[...En,...le,...bn,...Rn];un(a,r,n),this.draw.insertElementTextField([n])}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=at(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Zn(l,i);if(!r)return;const a=l[i],c=a?.controlComponent===s.ControlComponent.POSTFIX||a?.controlComponent===s.ControlComponent.POSTTEXTFIX;let d=!1;if(a?.controlId&&!c)for(let h=i;h>=0;h--){const R=l[h];if(R.controlId!==a.controlId)break;if(R.controlComponent===s.ControlComponent.PRETEXTFIX||R.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){R.control?.type===s.ControlType.TEXTFIELD&&(d=!0);break}}if(!d&&!c){const h=l[i-1];if(h?.controlId)for(let R=i-1;R>=0;R--){const f=l[R];if(f.controlId!==h.controlId)break;if(f.controlComponent===s.ControlComponent.PRETEXTFIX||f.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){f.control?.type===s.ControlType.TEXTFIELD&&(d=!0);break}}}if(d&&t.control?.type===s.ControlType.TEXTFIELD)return;const u=[...En,...le,...bn,...Rn];un(u,r,n),this.draw.insertElementList([n])}jumpControl(t){this.draw.getControl().initNextControl({direction:t?.direction})}getContainer(){return this.draw.getContainer()}getTitleValue(t){const{conceptId:e}=t,n=[],i=(r,a)=>{let c=0;for(;c<r.length;){const d=r[c];if(c++,d.type===s.ElementType.TABLE){const R=d.trList;for(let f=0;f<R.length;f++){const g=R[f];for(let T=0;T<g.tdList.length;T++){const C=g.tdList[T];i(C.value,a)}}}if(d?.title?.conceptId!==e)continue;const u=[];let h=c;for(;h<r.length;){const R=r[h];if(h++,d.titleId!==R.titleId){if(R.level&&Mi[R.level]<=Mi[d.level])break;u.push(R)}}n.push({...d.title,value:Mn(u),elementList:Yt(u),zone:a}),c=h}},l=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:r,elementList:a}of l)i(a,r);return n}getPositionContextByEvent(t,e={}){const n=t.target?.dataset.index;if(!n)return null;const{isMustDirectHit:i=!0}=e,l=Number(n),r=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:l}),{isDirectHit:a,isTable:c,index:d,trIndex:u,tdIndex:h,tdValueIndex:R,zone:f}=r;if(i&&!a||f&&f!==this.zone.getZone())return null;let g=null,T=null;const C=this.draw.getOriginalElementList();let p=null;const I=this.position.getOriginalPositionList();if(c){const L=C[d].trList?.[u].tdList[h];T=L?.value[R]||null,p=L?.positionList?.[R]||null,g={element:C[d],trIndex:u,tdIndex:h}}else T=C[d]||null,p=I[d]||null;let m=null;if(p){const{pageNo:L,coordinate:{leftTop:P,rightTop:M},lineHeight:F}=p,N=this.draw.getOriginalHeight(),Y=this.draw.getOriginalPageGap();m={x:P[0],y:P[1]+L*(N+Y),width:M[0]-P[0],height:F}}return{pageNo:l,element:T,rangeRect:m,tableInfo:g}}insertTitle(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=at(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Zn(l,i);if(!r)return;const a=[...En,...le,...bn,...Rn];n.valueList?.forEach(c=>{un(a,r,c)}),this.draw.insertElementList([n])}focus(t){const{position:e=s.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:i,range:l}=t||{};let r=-1;if(l)this.range.replaceRange(l),r=e===s.LocationPosition.BEFORE?l.startIndex:l.endIndex;else if(fi(i)){const c=this.draw.getOriginalRowList();if(r=e===s.LocationPosition.BEFORE?c[i]?.startIndex:c[i+1]?.startIndex-1,!fi(r))return;this.range.setRange(r,r)}else r=e===s.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(r,r);const a={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~r&&this.range.getIsCollapsed()&&(a.curIndex=r,a.isSetCursor=!0),this.draw.render(a)}insertArea(t){return this.draw.getArea().insertArea(t)}setAreaValue(t){return this.draw.getArea().setAreaValue(t)}setAreaProperties(t){this.draw.getArea().setAreaProperties(t)}locationArea(t,e){if(e?.isAppendLastLineBreak&&e?.position===s.LocationPosition.OUTER_AFTER){const l=this.draw.getOriginalMainElementList();l[l.length-1].areaId===t&&this.draw.appendElementList([{value:K}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:i}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(i,i),this.draw.render({curIndex:i,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getMacroValue(t){const{id:e,dictCode:n,label:i,areaId:l}=t,r=[],a=(d,u)=>{for(const h of d){if(h.type===s.ElementType.TABLE){const f=h.trList;for(const g of f)for(const T of g.tdList)a(T.value,u);continue}if(h.type!==s.ElementType.MACRO&&h.type!==s.ElementType.CUSTOM_MACRO&&h.type!==s.ElementType.REUSABLE_ITEM||e&&h.id!==e||n&&h.dictCode!==n||i&&h.label!==i||l&&h.areaId!==l)continue;const R={id:h.id,type:h.type,label:h.label,dictCode:h.dictCode,zone:u};h.type===s.ElementType.MACRO?R.value=h.value:h.type===s.ElementType.CUSTOM_MACRO?(R.macroConfig=h.macroConfig,R.value=h.macroConfig?.value):h.type===s.ElementType.REUSABLE_ITEM&&(R.reusableItemConfig=h.reusableItemConfig,R.value=h.reusableItemConfig?.value),r.push(R)}},c=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:d,elementList:u}of c)a(u,d);return r}getMacroList(){const t=[],e=i=>{for(const l of i){if(l.type===s.ElementType.TABLE){const r=l.trList;for(const a of r)for(const c of a.tdList)e(c.value);continue}(l.type===s.ElementType.MACRO||l.type===s.ElementType.CUSTOM_MACRO||l.type===s.ElementType.REUSABLE_ITEM)&&t.push(l)}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i);return t}setMacroValue(t){const{id:e,dictCode:n,label:i,areaId:l,value:r,code:a,isSubmitHistory:c=!0}=t;let d=!1;const u=R=>{for(let f=0;f<R.length;f++){const g=R[f];if(g.type===s.ElementType.TABLE){const T=g.trList;for(const C of T)for(const p of C.tdList)u(p.value);continue}g.type!==s.ElementType.MACRO&&g.type!==s.ElementType.CUSTOM_MACRO&&g.type!==s.ElementType.REUSABLE_ITEM||e&&g.id!==e||n&&g.dictCode!==n||i&&g.label!==i||l&&g.areaId!==l||(d=!0,g.type===s.ElementType.MACRO?g.value=r:g.type===s.ElementType.CUSTOM_MACRO?g.macroConfig?(g.macroConfig.value=r,a!==void 0&&(g.macroConfig.code=a)):g.macroConfig={type:"text",value:r}:g.type===s.ElementType.REUSABLE_ITEM&&(g.reusableItemConfig?g.reusableItemConfig.value=r:g.reusableItemConfig={value:r}))}},h=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const R of h)u(R);d&&this.draw.render({isSubmitHistory:c,isSetCursor:!1})}setMacroValueList(t){if(!t.length)return;let e=!1,n=!1;const i=r=>{for(let a=0;a<r.length;a++){const c=r[a];if(c.type===s.ElementType.TABLE){const f=c.trList;for(const g of f)for(const T of g.tdList)i(T.value);continue}if(c.type!==s.ElementType.MACRO&&c.type!==s.ElementType.CUSTOM_MACRO&&c.type!==s.ElementType.REUSABLE_ITEM)continue;const d=t.find(f=>f.id&&c.id===f.id||f.dictCode&&c.dictCode===f.dictCode||f.label&&c.label===f.label||f.areaId&&c.areaId===f.areaId);if(!d)continue;const{value:u,code:h,isSubmitHistory:R=!0}=d;e=!0,R&&(n=!0),c.type===s.ElementType.MACRO?c.value=u:c.type===s.ElementType.CUSTOM_MACRO?c.macroConfig?(c.macroConfig.value=u,h!==void 0&&(c.macroConfig.code=h)):c.macroConfig={type:"text",value:u}:c.type===s.ElementType.REUSABLE_ITEM&&(c.reusableItemConfig?c.reusableItemConfig.value=u:c.reusableItemConfig={value:u})}},l=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const r of l)i(r);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}updateMacroProperties(t){const{id:e,dictCode:n,label:i,areaId:l,properties:r,isSubmitHistory:a=!0}=t;let c=!1;const d=h=>{for(let R=0;R<h.length;R++){const f=h[R];if(f.type===s.ElementType.TABLE){const g=f.trList;for(const T of g)for(const C of T.tdList)d(C.value);continue}f.type!==s.ElementType.MACRO&&f.type!==s.ElementType.CUSTOM_MACRO&&f.type!==s.ElementType.REUSABLE_ITEM||e&&f.id!==e||n&&f.dictCode!==n||i&&f.label!==i||l&&f.areaId!==l||(c=!0,Object.assign(f,r))}},u=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const h of u)d(h);c&&this.draw.render({isSubmitHistory:a,isSetCursor:!1})}locationMacro(t){const{id:e,dictCode:n,label:i,areaId:l}=t,r=(c,d)=>{for(let u=0;u<c.length;u++){const h=c[u];if(h.type===s.ElementType.TABLE){const R=h.trList;for(let f=0;f<R.length;f++){const g=R[f];for(let T=0;T<g.tdList.length;T++){const C=g.tdList[T],p=r(C.value,d);if(p)return{...p,isTable:!0,index:u,trIndex:f,tdIndex:T,tableId:h.tableId,trId:g.id,tdId:C.id}}}}if(!(h.type!==s.ElementType.MACRO&&h.type!==s.ElementType.CUSTOM_MACRO&&h.type!==s.ElementType.REUSABLE_ITEM)&&!(e&&h.id!==e)&&!(n&&h.dictCode!==n)&&!(i&&h.label!==i)&&!(l&&h.areaId!==l))return{zone:d,index:u}}return null},a=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:c,elementList:d}of a){const u=r(d,c);if(u){this.setZone(u.zone),this.position.setPositionContext({isTable:u.isTable||!1,index:u.index,trIndex:u.trIndex,tdIndex:u.tdIndex,tableId:u.tableId,trId:u.trId,tdId:u.tdId}),this.range.replaceRange({startIndex:u.index,endIndex:u.index}),this.draw.render({curIndex:u.index,isCompute:!1,isSubmitHistory:!1});break}}}insertSubTemplate(t){const{label:e,templateId:n,content:i,conditions:l,relation:r="and",isSubmitHistory:a=!0}=t,c={id:mt(),value:e,type:s.ElementType.SUB_TEMPLATE,label:e,templateId:n,subTemplateContent:i?.map(d=>at(d)),subTemplateRelation:r,subTemplateConditions:l?.map(d=>({...d})),subTemplateExpanded:!1};this.insertElementList([c],{isSubmitHistory:a})}updateSubTemplate(t){const{id:e,properties:n,isSubmitHistory:i=!0}=t;if(!e)return;const l=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];let r=!1;for(let a=0;a<l.length;a++)Os(l[a],c=>{c.id!==e||c.type!==s.ElementType.SUB_TEMPLATE||(Object.assign(c,{...n,value:n.label??c.value,subTemplateContent:n.subTemplateContent?n.subTemplateContent.map(d=>at(d)):c.subTemplateContent?.map(d=>at(d)),subTemplateConditions:n.subTemplateConditions?n.subTemplateConditions.map(d=>({...d})):c.subTemplateConditions?.map(d=>({...d}))}),r=!0)});r&&this.draw.render({isSubmitHistory:i,isCompute:!0})}expandSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,l=this.draw.getOriginalMainElementList();for(let r=0;r<l.length;r++){const a=l[r];if(a.type===s.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){const c=n||a.subTemplateContent;if(!c?.length){console.warn("子模板内容为空,无法展开");return}a.subTemplateExpanded=!0,a.hide=!0;const d=at(c);qt(d,{isHandleFirstElement:!1,editorOptions:this.options});for(let u=0;u<d.length;u++)d[u].subTemplateParentId=a.id;l.splice(r+1,0,...d),this.draw.render({isSubmitHistory:i,isCompute:!0});return}}}collapseSubTemplate(t){const{id:e,isSubmitHistory:n=!0}=t,i=this.draw.getOriginalMainElementList();for(let l=0;l<i.length;l++){const r=i[l];if(r.type===s.ElementType.SUB_TEMPLATE&&(!e||r.id===e)){r.subTemplateExpanded=!1,r.hide=!1;let a=l+1;for(;a<i.length&&i[a].subTemplateParentId===r.id;)a++;a>l+1&&i.splice(l+1,a-l-1),this.draw.render({isSubmitHistory:n,isCompute:!0});return}}}toggleSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,l=this.draw.getOriginalMainElementList();for(let r=0;r<l.length;r++){const a=l[r];if(a.type===s.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){a.subTemplateExpanded?this.collapseSubTemplate({id:e,isSubmitHistory:i}):this.expandSubTemplate({id:e,content:n,isSubmitHistory:i});return}}}}class xf{rangeStyleChange;visiblePageNoListChange;intersectionPageNoChange;pageSizeChange;pageScaleChange;saved;contentChange;controlChange;controlContentChange;pageModeChange;zoneChange;constructor(){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.controlContentChange=null,this.pageModeChange=null,this.zoneChange=null}}class Jf{contextMenu;contextMenuList;getContextMenuList;shortcutList;langMap;constructor(t){const{contextMenu:e,shortcut:n,i18n:i}=t;this.contextMenu=e,this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=i.registerLangMap.bind(i)}disposeContextMenu(){this.contextMenu.dispose()}}const Al={SELECTED_TEXT:"%s"},to={GLOBAL:{CUT:"globalCut",COPY:"globalCopy",PASTE:"globalPaste",SELECT_ALL:"globalSelectAll",PRINT:"globalPrint"},CONTROL:{DELETE:"controlDelete",EDIT_ATTRIBUTE:"controlEditAttribute",COPY:"controlCopy",PASTE:"controlPaste"},HYPERLINK:{DELETE:"hyperlinkDelete",CANCEL:"hyperlinkCancel",EDIT:"hyperlinkEdit"},IMAGE:{CHANGE:"imageChange",SAVE_AS:"imageSaveAs",TEXT_WRAP:"imageTextWrap",TEXT_WRAP_EMBED:"imageTextWrapEmbed",TEXT_WRAP_UP_DOWN:"imageTextWrapUpDown",TEXT_WRAP_SURROUND:"imageTextWrapSurround",TEXT_WRAP_FLOAT_TOP:"imageTextWrapFloatTop",TEXT_WRAP_FLOAT_BOTTOM:"imageTextWrapFloatBottom"},TABLE:{BORDER:"border",BORDER_ALL:"tableBorderAll",BORDER_EMPTY:"tableBorderEmpty",BORDER_DASH:"tableBorderDash",BORDER_EXTERNAL:"tableBorderExternal",BORDER_INTERNAL:"tableBorderInternal",BORDER_TD:"tableBorderTd",BORDER_TD_TOP:"tableBorderTdTop",BORDER_TD_RIGHT:"tableBorderTdRight",BORDER_TD_BOTTOM:"tableBorderTdBottom",BORDER_TD_LEFT:"tableBorderTdLeft",BORDER_TD_FORWARD:"tableBorderTdForward",BORDER_TD_BACK:"tableBorderTdBack",VERTICAL_ALIGN:"tableVerticalAlign",VERTICAL_ALIGN_TOP:"tableVerticalAlignTop",VERTICAL_ALIGN_MIDDLE:"tableVerticalAlignMiddle",VERTICAL_ALIGN_BOTTOM:"tableVerticalAlignBottom",INSERT_ROW_COL:"tableInsertRowCol",INSERT_TOP_ROW:"tableInsertTopRow",INSERT_BOTTOM_ROW:"tableInsertBottomRow",INSERT_LEFT_COL:"tableInsertLeftCol",INSERT_RIGHT_COL:"tableInsertRightCol",DELETE_ROW_COL:"tableDeleteRowCol",DELETE_ROW:"tableDeleteRow",DELETE_COL:"tableDeleteCol",DELETE_TABLE:"tableDeleteTable",MERGE_CELL:"tableMergeCell",CANCEL_MERGE_CELL:"tableCancelMergeCell",TABLE_PROPERTIES:"tableProperties"}},{CONTROL:{DELETE:$f,EDIT_ATTRIBUTE:zf,COPY:jf,PASTE:qf}}=to;function tT(o,t){if(t!==s.EditorMode.EDIT)return!1;const n=o?.control?.type,i=o?.controlComponent,l=n===s.ControlType.TEXT||n===s.ControlType.TEXTFIELD||n===s.ControlType.NUMBER||n===s.ControlType.SELECT||n===s.ControlType.DATE||n===s.ControlType.CHECKBOX||n===s.ControlType.RADIO||n===s.ControlType.BUTTON,r=i==="prefix"||i==="preText"||i==="preTextFix"||i==="textFixLabel"||n===s.ControlType.BUTTON&&(i==="value"||i==="placeholder");return l&&r}function _l(o){return o.hitElement||o.hitTableElement}const eT=[{key:jf,name:"复制控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&tT(o.startElement,o.options.mode),callback:(o,t)=>{const e=t.startElement?.controlId;e&&o.executeCopyControl(e)}},{key:qf,name:"粘贴控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.editorTextFocus&&o.options.mode===s.EditorMode.EDIT&&Nc(),callback:o=>{o.executePasteControl()}},{key:$f,i18nPath:"contextmenu.control.delete",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeRemoveControl()}},{key:zf,i18nPath:"contextmenu.control.editAttribute",when:o=>{const t=_l(o);return!o.isReadonly&&!o.editorHasSelection&&o.options.mode===s.EditorMode.EDIT&&!!t},callback:(o,t)=>{const e=_l(t);e&&o.executeTriggerControlEditAttribute(e.controlId,e)}}],{GLOBAL:{CUT:nT,COPY:oT,PASTE:iT,SELECT_ALL:sT,PRINT:rT}}=to,lT=[{key:nT,i18nPath:"contextmenu.global.cut",shortCut:`${In?"⌘":"Ctrl"} + X`,when:o=>!o.isReadonly,callback:o=>{o.executeCut()}},{key:oT,i18nPath:"contextmenu.global.copy",shortCut:`${In?"⌘":"Ctrl"} + C`,when:o=>o.editorHasSelection||o.isCrossRowCol,callback:o=>{o.executeCopy()}},{key:iT,i18nPath:"contextmenu.global.paste",shortCut:`${In?"⌘":"Ctrl"} + V`,when:o=>!o.isReadonly&&o.editorTextFocus,callback:o=>{o.executePaste()}},{key:sT,i18nPath:"contextmenu.global.selectAll",shortCut:`${In?"⌘":"Ctrl"} + A`,when:o=>o.editorTextFocus,callback:o=>{o.executeSelectAll()}},{isDivider:!0},{key:rT,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:o=>{o.executePrint()}}],{HYPERLINK:{DELETE:aT,CANCEL:cT,EDIT:dT}}=to,uT=[{key:aT,i18nPath:"contextmenu.hyperlink.delete",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:o=>{o.executeDeleteHyperlink()}},{key:cT,i18nPath:"contextmenu.hyperlink.cancel",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:o=>{o.executeCancelHyperlink()}},{key:dT,i18nPath:"contextmenu.hyperlink.edit",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:(o,t)=>{const e=window.prompt(o.executeTranslate("contextmenu.hyperlink.edit"),t.startElement?.url);e&&o.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:RT,SAVE_AS:hT,TEXT_WRAP:gT,TEXT_WRAP_EMBED:fT,TEXT_WRAP_UP_DOWN:TT,TEXT_WRAP_SURROUND:mT,TEXT_WRAP_FLOAT_TOP:CT,TEXT_WRAP_FLOAT_BOTTOM:pT}}=to,IT=[{key:RT,i18nPath:"contextmenu.image.change",icon:"image-change",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,callback:o=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],n=new FileReader;n.readAsDataURL(e),n.onload=()=>{const i=n.result;o.executeReplaceImageElement(i)}},t.click()}},{key:hT,i18nPath:"contextmenu.image.saveAs",icon:"image",when:o=>!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,callback:o=>{o.executeSaveAsImageElement()}},{key:gT,i18nPath:"contextmenu.image.textWrap",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,childMenus:[{key:fT,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.BLOCK)}},{key:TT,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.INLINE)}},{key:mT,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.SURROUND)}},{key:CT,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.FLOAT_TOP)}},{key:pT,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:ET,BORDER_ALL:LT,BORDER_EMPTY:PT,BORDER_DASH:MT,BORDER_EXTERNAL:OT,BORDER_INTERNAL:ST,BORDER_TD:DT,BORDER_TD_TOP:FT,BORDER_TD_LEFT:XT,BORDER_TD_BOTTOM:NT,BORDER_TD_RIGHT:yT,BORDER_TD_BACK:bT,BORDER_TD_FORWARD:VT,VERTICAL_ALIGN:WT,VERTICAL_ALIGN_TOP:YT,VERTICAL_ALIGN_MIDDLE:UT,VERTICAL_ALIGN_BOTTOM:wT,INSERT_ROW_COL:ZT,INSERT_TOP_ROW:vT,INSERT_BOTTOM_ROW:QT,INSERT_LEFT_COL:KT,INSERT_RIGHT_COL:HT,DELETE_ROW_COL:AT,DELETE_ROW:_T,DELETE_COL:BT,DELETE_TABLE:kT,MERGE_CELL:GT,CANCEL_MERGE_CELL:xT}}=to,JT=[{isDivider:!0},{key:ET,i18nPath:"contextmenu.table.border",icon:"border-all",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:LT,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.ALL)}},{key:PT,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.EMPTY)}},{key:MT,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.DASH)}},{key:OT,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.EXTERNAL)}},{key:ST,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.INTERNAL)}},{key:DT,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:FT,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.TOP)}},{key:yT,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.RIGHT)}},{key:NT,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.BOTTOM)}},{key:XT,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.LEFT)}},{key:VT,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:o=>{o.executeTableTdSlashType(s.TdSlash.FORWARD)}},{key:bT,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:o=>{o.executeTableTdSlashType(s.TdSlash.BACK)}}]}]},{key:WT,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:YT,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.TOP)}},{key:UT,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.MIDDLE)}},{key:wT,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.BOTTOM)}}]},{key:ZT,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:vT,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:o=>{o.executeInsertTableTopRow()}},{key:QT,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:o=>{o.executeInsertTableBottomRow()}},{key:KT,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:o=>{o.executeInsertTableLeftCol()}},{key:HT,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:o=>{o.executeInsertTableRightCol()}}]},{key:AT,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:_T,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:o=>{o.executeDeleteTableRow()}},{key:BT,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:o=>{o.executeDeleteTableCol()}},{key:kT,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:o=>{o.executeDeleteTable()}}]},{key:GT,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:o=>!o.isReadonly&&o.isCrossRowCol&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeMergeTableCell()}},{key:xT,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeCancelMergeTableCell()}}];class $T{options;draw;command;range;position;i18n;container;contextMenuList;contextMenuContainerList;contextMenuRelationShip;context;constructor(t,e){this.options=t.getOptions(),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=[...lT,...JT,...IT,...eT,...uT],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}getContextMenuList(){return this.contextMenuList}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_filterMenuList(t){const{contextMenuDisableKeys:e}=this.options,n=[];for(let i=0;i<t.length;i++){const l=t[i];l.disable||l.key&&e.includes(l.key)||(l.isDivider||l.when?.(this.context))&&n.push(l)}return n}_proxyContextMenuEvent=t=>{this.context=this._getContext(t);const e=this._filterMenuList(this.contextMenuList);e.some(i=>!i.isDivider)&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()};_handleSideEffect=t=>{const e=t.target;this.contextMenuContainerList.some(i=>i.contains(e))||this.dispose()};_getContext(t){const e=this.draw.isReadonly(),{isCrossRowCol:n,startIndex:i,endIndex:l}=this.range.getRange(),r=!!(~i||~l),a=r&&i!==l,{isTable:c,trIndex:d,tdIndex:u,index:h}=this.position.getPositionContext(),R=t?this.command.getPositionContextByEvent(t,{isMustDirectHit:!0}):null;let f=null;if(c){const M=this.draw.getOriginalElementList()[h]||null;M&&(f=Yt([M],{extraPickAttrs:["id"]})[0])}const g=c&&!!n,T=this.draw.getElementList();let C=T[i]||null,p=T[l]||null;R?.element&&(C=R.element,p=R.element);const I=R?.element||null,m=R?.tableInfo?.element||null;R?.tableInfo?.element&&(f=R.tableInfo.element);const L=this.draw.getZone().getZone();return{startElement:C,endElement:p,hitElement:I,hitTableElement:m,isReadonly:e,editorHasSelection:a,editorTextFocus:r,isCrossRowCol:g,zone:L,isInTable:c,trIndex:d??null,tdIndex:u??null,tableElement:f,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-contextmenu-container`),t.setAttribute(Ze,s.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){const{contextMenuList:e,left:n,top:i,parentMenuContainer:l}=t,r=this._createContextMenuContainer(),a=document.createElement("div");a.classList.add(`${rt}-contextmenu-content`);let c=null;l&&this.contextMenuRelationShip.set(l,r);for(let L=0;L<e.length;L++){const P=e[L];if(P.isDivider){if(L!==0&&L!==e.length-1&&!e[L-1]?.isDivider){const M=document.createElement("div");M.classList.add(`${rt}-contextmenu-divider`),a.append(M)}}else{const M=document.createElement("div");if(M.classList.add(`${rt}-contextmenu-item`),P.childMenus){const b=this._filterMenuList(P.childMenus);b.some(y=>!y.isDivider)&&(M.classList.add(`${rt}-contextmenu-sub-item`),M.onmouseenter=()=>{this._setHoverStatus(M,!0),this._removeSubMenu(r);const y=M.getBoundingClientRect(),V=y.left+y.width,X=y.top;c=this._render({contextMenuList:b,left:V,top:X,parentMenuContainer:r})},M.onmouseleave=y=>{(!c||!c.contains(y.relatedTarget))&&this._setHoverStatus(M,!1)})}else M.onmouseenter=()=>{this._setHoverStatus(M,!0),this._removeSubMenu(r)},M.onmouseleave=()=>{this._setHoverStatus(M,!1)},M.onclick=()=>{P.callback&&this.context&&P.callback(this.command,this.context),this.dispose()};const F=document.createElement("i");M.append(F),P.icon&&F.classList.add(`${rt}-contextmenu-${P.icon}`);const N=document.createElement("span"),Y=P.i18nPath?this._formatName(this.i18n.t(P.i18nPath)):this._formatName(P.name||"");if(N.append(document.createTextNode(Y)),M.append(N),P.shortCut){const b=document.createElement("span");b.classList.add(`${rt}-shortcut`),b.append(document.createTextNode(P.shortCut)),M.append(b)}a.append(M)}}const d=document.createElement("div");d.classList.add(`${rt}-contextmenu-divider`),a.append(d);const u=document.createElement("div");u.classList.add(`${rt}-contextmenu-item`),u.onmouseenter=()=>{this._setHoverStatus(u,!0),this._removeSubMenu(r)},u.onmouseleave=()=>{this._setHoverStatus(u,!1)},u.onclick=()=>{this.dispose()};const h=document.createElement("i");u.append(h);const R=document.createElement("span");R.append(document.createTextNode(this.i18n.t("contextmenu.global.cancel"))),u.append(R),a.append(u),r.append(a),r.style.display="block";const f=window.innerWidth,g=r.getBoundingClientRect(),T=g.width,C=n+T>f?n-T:n;r.style.left=`${C}px`;const p=window.innerHeight,I=g.height,m=i+I>p?i-I:i;return r.style.top=`${m}px`,this.contextMenuContainerList.push(r),r}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){e?(t.parentNode?.querySelectorAll(`${rt}-contextmenu-item`).forEach(n=>n.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(Al),n=new RegExp(`${e.join("|")}`);let i=t;if(n.test(i)){const l=new RegExp(Al.SELECTED_TEXT,"g");if(l.test(i)){const r=this.range.toString();i=i.replace(l,r)}}return i}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const zT=[{key:s.KeyMap.X,ctrl:!0,shift:!0,callback:o=>{o.executeStrikeout()}},{key:s.KeyMap.LEFT_BRACKET,mod:!0,callback:o=>{o.executeSizeAdd()}},{key:s.KeyMap.RIGHT_BRACKET,mod:!0,callback:o=>{o.executeSizeMinus()}},{key:s.KeyMap.B,mod:!0,callback:o=>{o.executeBold()}},{key:s.KeyMap.I,mod:!0,callback:o=>{o.executeItalic()}},{key:s.KeyMap.U,mod:!0,callback:o=>{o.executeUnderline()}},{key:In?s.KeyMap.COMMA:s.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSuperscript()}},{key:In?s.KeyMap.PERIOD:s.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSubscript()}},{key:s.KeyMap.L,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.LEFT)}},{key:s.KeyMap.E,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.CENTER)}},{key:s.KeyMap.R,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.RIGHT)}},{key:s.KeyMap.J,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.ALIGNMENT)}},{key:s.KeyMap.J,mod:!0,shift:!0,callback:o=>{o.executeRowFlex(s.RowFlex.JUSTIFY)}}],jT=[{key:s.KeyMap.ZERO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(null)}},{key:s.KeyMap.ONE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FIRST)}},{key:s.KeyMap.TWO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.SECOND)}},{key:s.KeyMap.THREE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.THIRD)}},{key:s.KeyMap.FOUR,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FOURTH)}},{key:s.KeyMap.FIVE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FIFTH)}},{key:s.KeyMap.SIX,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.SIXTH)}}],qT=[{key:s.KeyMap.I,shift:!0,mod:!0,callback:o=>{o.executeList(s.ListType.UL,s.ListStyle.DISC)}},{key:s.KeyMap.U,shift:!0,mod:!0,callback:o=>{o.executeList(s.ListType.OL)}}];class tm{draw;command;globalShortcutList;agentShortcutList;constructor(t,e){this.draw=t,this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...zT,...jT,...qT]),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 n=t[e];n.isGlobal?this.globalShortcutList.unshift(n):this.agentShortcutList.unshift(n)}}registerShortcutList(t){this._addShortcutList(t)}_globalKeydown=t=>{this.globalShortcutList.length&&this.draw.isGlobalShortcutActive()&&this.draw.isTargetInsideEditor(t.target)&&this._execute(t,this.globalShortcutList)};_agentKeydown(t){this.agentShortcutList.length&&(this.draw.isInteractionSuspended()||this._execute(t,this.agentShortcutList))}_execute(t,e){for(let n=0;n<e.length;n++){const i=e[n];if((i.mod?Ae(t)===!!i.mod:t.ctrlKey===!!i.ctrl&&t.metaKey===!!i.meta)&&t.shiftKey===!!i.shift&&t.altKey===!!i.alt&&t.key.toLowerCase()===i.key.toLowerCase()){i.disable||(i?.callback?.(this.command),t.preventDefault());break}}}}class em{editor;constructor(t){this.editor=t}use(t,e){t(this.editor,e)}}class nm{eventHub;constructor(){this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t)||new Set;n.add(e),this.eventHub.set(t,n)}emit(t,e){if(!t)return;const n=this.eventHub.get(t);if(n){if(n.size===1)return[...n][0](e);n.forEach(i=>i(e))}}off(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t);n&&n.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}dangerouslyClearAll(){this.eventHub.clear()}}class om{paste;copy;drop}class Bl{command;version;listener;eventBus;override;register;destroy;use;draw;constructor(t,e,n={}){const i=Oo(n);e=at(e);let l=[],r=[],a=[],c=[];Array.isArray(e)?r=e:(l=e.header||[],r=e.main,a=e.footer||[],c=e.graffiti||[]),[l,r,a].forEach(g=>{qt(g,{editorOptions:i,isForceCompensation:!0})}),this.version=pn,this.listener=new xf,this.eventBus=new nm,this.override=new om,this.draw=new Kf(t,i,{header:l,main:r,footer:a,graffiti:c},this.listener,this.eventBus,this.override);const u=this.draw;this.command=new Kl(new Gf(u)),u.setCommand(this.command);const h=new $T(u,this.command),R=new tm(u,this.command);this.register=new Jf({contextMenu:h,shortcut:R,i18n:u.getI18n()}),this.destroy=()=>{u.destroy(),R.removeEvent(),h.removeEvent(),this.eventBus.dangerouslyClearAll()};const f=new em(this);this.use=f.use.bind(f)}setFormModeTrace(t){this.command.executeSetFormModeTrace(t)}pauseInteraction(){this.draw.pauseInteraction()}resumeInteraction(){this.draw.resumeInteraction()}setOverlayActive(t){this.draw.setOverlayActive(t)}suspendGlobalShortcut(t){this.draw.suspendGlobalShortcut(t)}}s.Command=Kl,s.EDITOR_CLIPBOARD=no,s.EDITOR_COMPONENT=Ze,s.Editor=Bl,s.INTERNAL_CONTEXT_MENU_KEY=to,s.INTERNAL_SHORTCUT_KEY=Mr,s.LETTER_CLASS=ci,s.createDomFromElementList=vn,s.default=Bl,s.getElementListByHTML=Qn,s.getTextFromElementList=Mn,s.splitText=Dt,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
582
+ `?K:l[d];e.splice(c+d,0,{...a,value:u})}}}const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isSetCursor:!0})}}delButton(t,e){return new Promise(n=>{for(let i=t.length-1;i>=0;i--)e.some(r=>r.controlId===t[i].controlId&&r.type===t[i].type)&&t.splice(i,1);n(!0)})}editButton(t,e,n){const i=this.draw.getElementList();n=n+1;for(let d=0;d<e.label.length;d++){const u={value:e.label[d],controlId:e.controlId,type:s.ElementType.CONTROL,control:{type:"button",buttonLabel:e.label,code:e.code,value:[{value:e.label}],label:e.label,hide:!1},controlComponent:"value",color:"#fff",highlight:"#1677FF",style:"16px Microsoft YaHei",hide:!1};i.splice(n+d,0,u)}const{startIndex:l,endIndex:r}=this.range.getRange(),a=!0,c=r;this.draw.render({curIndex:c,isSetCursor:a})}removeButtonElementsByControlId(t){return new Promise(e=>{const n=this.draw.getElementList();for(let c=n.length-1;c>=0;c--)n[c].controlId===t&&n.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),e(!0)})}removeByValue(t,e){return new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text"||t[c].type=="buttonText")&&t[c].control?.buttonLabel===e&&t[c].control?.buttonText&&t.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),n(!0)})}insertButtonValue(t){const e=this.draw.getElementList(),n=t.controlId,l=(Array.isArray(t.element)?t.element:t.elementList||[t.element])[0],r=l.newButtonValue,a=l.control.buttonLabel,c=l.control.code;if(!r||!r.length)return;let d=-1;for(let I=0;I<e.length;I++)if(e[I].controlId===n&&e[I].control?.type==="button"){d=I;break}if(d===-1)return;const u=n+"_text",h=[];for(let I=0;I<r.length;I++){const m=r[I];h.push({value:m.value,code:m.code})}const R={type:"button",buttonLabel:a,buttonText:!0,label:a,code:c,value:h,hide:!1},f=[];f.push({value:"[",controlId:u,type:s.ElementType.CONTROL,control:R,controlComponent:s.ControlComponent.PREFIX,color:"#1677FF",hide:!1});for(let I=0;I<r.length;I++){const m=r[I],L=r.length>1?`${I+1}.${m.value}`:m.value,P=Dt(L);for(let M=0;M<P.length;M++)f.push({value:P[M],controlId:u,type:s.ElementType.CONTROL,control:R,controlComponent:s.ControlComponent.VALUE,color:"#000",hide:!1});r.length>1&&I<r.length-1&&f.push({value:K,controlId:u,type:s.ElementType.CONTROL,control:R,controlComponent:s.ControlComponent.VALUE,color:"#000",hide:!1})}f.push({value:"]",controlId:u,type:s.ElementType.CONTROL,control:R,controlComponent:s.ControlComponent.POSTFIX,color:"#1677FF",hide:!1});for(let I=0;I<f.length;I++)e.splice(d+I,0,f[I]);const{startIndex:g,endIndex:T}=this.range.getRange(),C=!0,p=T;this.draw.render({curIndex:p,isSetCursor:C})}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{r.font=t}),this.draw.render({isSetCursor:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({font:t}),d?.value===K?d.font=t:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:l,maxSize:r,defaultSize:a}=this.options;if(t<l||t>r)return;let c={},d=[];const u=this.range.getTextLikeSelectionElementList();if(u?.length)d=u,c={isSetCursor:!1};else{const{endIndex:R}=this.range.getRange(),g=this.draw.getElementList()[R];this.range.setDefaultStyle({size:t}),g?.value===K?(d.push(g),c={curIndex:R}):this.draw.render({curIndex:R,isCompute:!1,isSubmitHistory:!1})}if(!d.length)return;let h=!1;d.forEach(R=>{!R.size&&t===a||R.size&&R.size===t||(R.size=t,h=!0)}),h&&this.draw.render(c)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,maxSize:l}=this.options,r=this.range.getTextLikeSelectionElementList();let a={},c=[];if(r?.length)c=r,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange(),R=this.draw.getElementList()[u],g=this.range.getDefaultStyle()?.size||R.size||i;this.range.setDefaultStyle({size:g+2>l?l:g+2}),R?.value===K?(c.push(R),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(u=>{u.size||(u.size=i),!(u.size>=l)&&(u.size+2>l?u.size=l:u.size+=2,d=!0)}),d&&this.draw.render(a)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,minSize:l}=this.options,r=this.range.getTextLikeSelectionElementList();let a={},c=[];if(r?.length)c=r,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange(),R=this.draw.getElementList()[u],g=this.range.getDefaultStyle()?.size||R.size||i;this.range.setDefaultStyle({size:g-2<l?l:g-2}),R?.value===K?(c.push(R),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(u=>{u.size||(u.size=i),!(u.size<=l)&&(u.size-2<l?u.size=l:u.size-=2,d=!0)}),d&&this.draw.render(a)}bold(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.bold);i.forEach(r=>{r.bold=!!~l}),this.draw.render({isSetCursor:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({bold:c.bold?!1:!this.range.getDefaultStyle()?.bold}),c?.value===K?c.bold=!c.bold:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}italic(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.italic);i.forEach(r=>{r.italic=!!~l}),this.draw.render({isSetCursor:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({italic:c.italic?!1:!this.range.getDefaultStyle()?.italic}),c?.value===K?c.italic=!c.italic:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}underline(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length){const r=l.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!pa(a.textDecoration,t));l.forEach(a=>{a.underline=r,r&&t?a.textDecoration=t:delete a.textDecoration}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({underline:d?.underline?!1:!this.range.getDefaultStyle()?.underline}),d?.value===K?d.underline=!d.underline:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}strikeout(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.strikeout);i.forEach(r=>{r.strikeout=!!~l}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({strikeout:c.strikeout?!1:!this.range.getDefaultStyle()?.strikeout}),c?.value===K?c.strikeout=!c.strikeout:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const l=i.findIndex(r=>r.type===s.ElementType.SUPERSCRIPT);i.forEach(r=>{~l?r.type===s.ElementType.SUPERSCRIPT&&(r.type=s.ElementType.TEXT,delete r.actualSize):(!r.type||r.type===s.ElementType.TEXT||r.type===s.ElementType.SUBSCRIPT)&&(r.type=s.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const l=i.findIndex(r=>r.type===s.ElementType.SUBSCRIPT);i.forEach(r=>{~l?r.type===s.ElementType.SUBSCRIPT&&(r.type=s.ElementType.TEXT,delete r.actualSize):(!r.type||r.type===s.ElementType.TEXT||r.type===s.ElementType.SUPERSCRIPT)&&(r.type=s.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{t?r.color=t:delete r.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({color:t||void 0}),d?.value===K?t?d.color=t:delete d.color:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{t?r.highlight=t:delete r.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({highlight:t||void 0}),d?.value===K?t?d.highlight=t:delete d.highlight:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.draw.getElementList(),r=n===i?this.range.getRangeParagraphElementList():l.slice(n+1,i+1);if(!r||!r.length)return;const a=mt(),c=this.draw.getOptions().title;r.forEach(h=>{!h.type&&h.value===K||(t?(h.level=t,h.titleId=a,yo(h)&&(h.size=c[ks[t]],h.bold=!0)):h.titleId&&(delete h.titleId,delete h.title,delete h.level,delete h.size,delete h.bold))});const d=n===i,u=d?i:n;this.draw.render({curIndex:u,isSetCursor:d})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.rowFlex=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}vertical(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.vertical=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.rowMargin=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}insertTable(t,e){this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl()||this.tableOperate.insertTable(t,e)}insertTableTopRow(){this.draw.isReadonly()||this.tableOperate.insertTableTopRow()}insertTableBottomRow(){this.draw.isReadonly()||this.tableOperate.insertTableBottomRow()}insertTableLeftCol(){this.draw.isReadonly()||this.tableOperate.insertTableLeftCol()}insertTableRightCol(){this.draw.isReadonly()||this.tableOperate.insertTableRightCol()}deleteTableRow(){this.draw.isReadonly()||this.tableOperate.deleteTableRow()}deleteTableCol(){this.draw.isReadonly()||this.tableOperate.deleteTableCol()}deleteTable(){this.draw.isReadonly()||this.tableOperate.deleteTable()}mergeTableCell(){this.draw.isReadonly()||this.tableOperate.mergeTableCell()}cancelMergeTableCell(){this.draw.isReadonly()||this.tableOperate.cancelMergeTableCell()}splitVerticalTableCell(){this.draw.isReadonly()||this.tableOperate.splitVerticalTableCell()}splitHorizontalTableCell(){this.draw.isReadonly()||this.tableOperate.splitHorizontalTableCell()}tableTdVerticalAlign(t){this.draw.isReadonly()||this.tableOperate.tableTdVerticalAlign(t)}tableBorderType(t){this.draw.isReadonly()||this.tableOperate.tableBorderType(t)}tableBorderColor(t){this.draw.isReadonly()||this.tableOperate.tableBorderColor(t)}tableTdBorderType(t){this.draw.isReadonly()||this.tableOperate.tableTdBorderType(t)}tableTdSlashType(t){this.draw.isReadonly()||this.tableOperate.tableTdSlashType(t)}tableTdBackgroundColor(t){this.draw.isReadonly()||this.tableOperate.tableTdBackgroundColor(t)}tableSelectAll(){this.tableOperate.tableSelectAll()}tableProperties(){this.draw.isReadonly()||this.tableOperate.tableProperties()}hyperlink(t){const{valueList:e,url:n,hyperlinkId:i}=t;if(!n||!e?.length||this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:a,endIndex:c}=this.range.getRange();!~a&&!~c||this.insertElementList([{type:s.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:i||mt()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=this.draw.getElementList(),r=l[n];if(r.type!==s.ElementType.HYPERLINK)return null;let a=n;for(;a>0;){if(l[a].hyperlinkId!==r.hyperlinkId){t=a+1;break}a--}let c=n+1;for(;c<l.length;){if(l[c].hyperlinkId!==r.hyperlinkId){e=c-1;break}c++}return c===l.length&&(e=c-1),!~t||!~e?null:[t,e]}deleteHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,l]=e;this.draw.spliceElementList(n,i,l-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const r=i-1;this.range.setRange(r,r),this.draw.render({curIndex:r})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,l]=e;for(let a=i;a<=l;a++){const c=n[a];delete c.type,delete c.url,delete c.hyperlinkId,delete c.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const i=this.draw.getElementList(),[l,r]=n;for(let c=l;c<=r;c++){const d=i[c];d.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:a}=this.range.getRange();this.draw.render({curIndex:a,isCompute:!1})}separator(t,e){if(this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl())return;const{startIndex:l,endIndex:r}=this.range.getRange();if(!~l&&!~r)return;const a=this.draw.getElementList();let c=-1;const d=a[r+1];if(d&&d.type===s.ElementType.SEPARATOR){if(d.dashArray&&d.dashArray.join()===t.join())return;c=r,Object.assign(d,{dashArray:t,...e})}else{const u={value:Xs,type:s.ElementType.SEPARATOR,dashArray:t,...e};se(a,[u],l,{editorOptions:this.options}),l!==0&&a[l].value===K?(this.draw.spliceElementList(a,l,1,[u]),c=l-1):(this.draw.spliceElementList(a,l+1,0,[u]),c=l)}this.range.setRange(c,c),this.draw.render({curIndex:c})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:s.ElementType.PAGE_BREAK,value:Xs}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:i,size:l,opacity:r,font:a,gap:c}=Oi;n.watermark.data=t.data,n.watermark.type=t.type||s.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||i,n.watermark.opacity=t.opacity||r,n.watermark.size=t.size||l,n.watermark.font=t.font||a,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||c,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={...Oi},this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=t.id||mt();return this.insertElementList([{...t,id:l,type:s.ElementType.IMAGE}]),l}search(t,e){this.searchManager.setSearchKeyword(t,e),this.draw.render({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,e){this.draw.getSearch().replace(t,e)}async print(){const{scale:t,printPixelRatio:e,paperDirection:n,width:i,height:l}=this.options;t!==1&&this.draw.setPageScale(1);const r=await this.draw.getDataURL({pixelRatio:e,mode:s.EditorMode.PRINT});Af(r,{width:i,height:l,direction:n}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==s.ElementType.IMAGE||(i.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==s.ElementType.IMAGE||Vs(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==s.ElementType.IMAGE||(i.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];i?.type===s.ElementType.IMAGE&&(i.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:i}=this.range.getRange();if(e===s.ImageDisplay.SURROUND||e===s.ImageDisplay.FLOAT_TOP||e===s.ImageDisplay.FLOAT_BOTTOM){const l=this.position.getPositionList(),{pageNo:r,coordinate:{leftTop:a}}=l[n];t.imgFloatPosition={pageNo:r,x:a[0],y:a[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:i})}getImage(t){return this.draw.getDataURL(t)}getPageMode(){return this.options}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getValueAsync(t){return this.draw.getWorkerManager().getValue(t)}getAreaValue(t){return this.draw.getArea().getAreaValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:vn(e,t).innerHTML,main:vn(n,t).innerHTML,footer:vn(i,t).innerHTML}}getText(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:Mn(e,t),main:Mn(n,t),footer:Mn(i,t)}}getWordCount(){return this.workerManager.getWordCount()}getCursorPosition(){return this.position.getCursorPosition()}getRemainingContentHeight(){if(!this.draw.getIsPagingMode())return 0;const t=this.draw.getPageRowList(),e=t.length-1,i=(t[e]||[]).reduce((c,d)=>c+d.height+(d.offsetY||0),0),l=this.draw.getHeight(),r=this.draw.getMainOuterHeight(),a=l-(r+i);return a>0?a:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=at(t);qt(n,{isHandleFirstElement:!1,editorOptions:this.options});const i=bi(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:i}).reduce((r,a)=>r+a.height+(a.offsetY||0),0)}getRange(){return at(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const i=e===n,l=this.range.toString(),r=Yt(this.range.getSelectionElementList()||[]),a=this.draw.getElementList(),c=hn(a[i?e:e+1],{extraPickAttrs:["id","controlComponent"]}),d=hn(a[n],{extraPickAttrs:["id","controlComponent"]}),u=this.draw.getRowList(),h=this.position.getPositionList(),R=h[e],f=h[n],g=R?.pageNo,T=f?.pageNo,C=R?.rowIndex,p=f?.rowIndex,I=u[C],m=u[p];let L=0,P=0;this.draw.getCursor().getHitLineStartIndex()||(L=I?.elementList[0]?.value===K?R?.index-I?.startIndex:R?.index-I?.startIndex+1),R===f?P=L:P=m.elementList[0]?.value===K?f.index-m.startIndex:f.index-m.startIndex+1;const M=[],F=this.draw.getOriginalHeight(),N=this.draw.getOriginalPageGap(),Y=this.position.getSelectionPositionList();if(Y){let U=null,Z=0,Q=null;for(let v=0;v<Y.length;v++){const{rowNo:st,pageNo:B,coordinate:{leftTop:H,rightTop:k},lineHeight:q}=Y[v];U===null||U!==st?(Q&&M.push(Q),Q={x:H[0],y:H[1]+B*(F+N),width:k[0]-H[0],height:q},U=st,Z=H[0]):Q.width=k[0]-Z,v===Y.length-1&&Q&&M.push(Q)}}else{const Z=this.position.getPositionList()[n],{coordinate:{rightTop:Q},pageNo:v,lineHeight:st}=Z;M.push({x:Q[0],y:Q[1]+v*(F+N),width:0,height:st})}const b=this.draw.getZone().getZone(),{isTable:S,trIndex:y,tdIndex:V,index:X}=this.position.getPositionContext();let O=null;if(S){const Z=this.draw.getOriginalElementList()[X]||null;Z&&(O=Yt([Z])[0])}let E=null,W=null,D=e-1;for(;D>0;){const U=a[D],Z=a[D-1];if(U.titleId&&U.titleId!==Z?.titleId){E=U.titleId,W=h[D].pageNo;break}D--}return at({isCollapsed:i,startElement:c,endElement:d,startPageNo:g,endPageNo:T,startRowNo:C,endRowNo:p,startColNo:L,endColNo:P,rangeRects:M,zone:b,isTable:S,trIndex:y??null,tdIndex:V??null,tableElement:O,selectionText:l,selectionElementList:r,titleId:E,titleStartPageNo:W})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?Yt(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?Yt(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],i=this.position.getOriginalMainPositionList(),l=this.draw.getOriginalMainElementList();for(let r=0;r<e.length;r++){const a=e[r],{startIndex:c,endIndex:d,tableId:u,startTrIndex:h,startTdIndex:R}=a;let f=i;if(a.tableId){const C=l.find(p=>p.id===u);C&&(f=C.trList?.[h]?.tdList?.[R]?.positionList||[])}const g=at(f[c]),T=at(f[d]);n.push({range:a,startPosition:g,endPosition:T})}return n}pageMode(t){this.draw.setPageMode(t)}pageScale(t){t!==this.options.scale&&this.draw.setPageScale(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)}setMainBadge(t){this.draw.getBadge().setMainBadge(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}setAreaBadge(t){this.draw.getBadge().setAreaBadgeMap(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}insertElementList(t,e={}){if(!t.length||this.draw.isReadonly()||this.draw.isDisabled())return;const{isReplace:i=!0,ignoreContextKeys:l}=e;i||this.range.shrinkRange();const r=at(t),{startIndex:a}=this.range.getRange(),c=this.draw.getElementList();se(c,r,a,{ignoreContextKeys:l,isBreakWhenWrap:!0,editorOptions:this.options}),this.draw.insertElementList(r,e)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(at(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const i=[];function l(a,c=!1){let d=0;for(;d<a.length;){const u=a[d];if(d++,u.type===s.ElementType.TABLE){const h=u.trList;for(let R=0;R<h.length;R++){const f=h[R];for(let g=0;g<f.tdList.length;g++){const T=f.tdList[g];l(T.value,c)}}}u.type===s.ElementType.CONTROL&&u.control?.value&&l(u.control.value,!0),(e&&u.id===e||n&&u.conceptId===n)&&i.push({elementList:a,index:d-1,isInsideControl:c})}}const r=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);if(i.length){for(let a=0;a<i.length;a++){const{elementList:c,index:d,isInsideControl:u}=i[a],h=c[d],R=h.controlId&&h.controlComponent===s.ControlComponent.VALUE;if(u||R){if(Object.assign(h,t.properties),h.id){const f=gc(h.id);f&&Object.assign(f,t.properties)}}else{const f=Yt([{...h,...t.properties}],{extraPickAttrs:["id"]});f.length>0&&f[0]?(un(Rn,h,f[0]),qt(f,{isHandleFirstElement:!1,editorOptions:this.options}),c[d]=f[0]):Object.assign(h,t.properties)}}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let i=!1;function l(a){let c=0;for(;c<a.length;){const d=a[c];if(d.type===s.ElementType.TABLE){const u=d.trList;for(let h=0;h<u.length;h++){const R=u[h];for(let f=0;f<R.tdList.length;f++){const g=R.tdList[f];l(g.value)}}}d.type===s.ElementType.CONTROL&&d.control?.value&&l(d.control.value),(e&&d.id===e||n&&d.conceptId===n)&&(i=!0,a.splice(c,1),c--),c++}}const r=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);i&&this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,i=[];if(!e&&!n)return i;const l=a=>{let c=0;for(;c<a.length;){const d=a[c];if(c++,d.type===s.ElementType.TABLE){const u=d.trList;for(let h=0;h<u.length;h++){const R=u[h];for(let f=0;f<R.tdList.length;f++){const g=R.tdList[f];l(g.value)}}}e&&d.id!==e||n&&d.conceptId!==n||i.push(d)}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);return Yt(i,{extraPickAttrs:["id"]})}setValue(t,e){this.draw.setValue(t,e)}removeControl(t){if(t?.id||t?.conceptId){const{id:e,conceptId:n}=t;let i=!1;const l=a=>{let c=a.length-1;for(;c>=0;){const d=a[c];if(d.type===s.ElementType.TABLE){const u=d.trList;for(let h=0;h<u.length;h++){const R=u[h];for(let f=0;f<R.tdList.length;f++){const g=R.tdList[f];l(g.value)}}}c--,!(!d.control||e&&d.controlId!==e||n&&d.control.conceptId!==n)&&(i=!0,a.splice(c+1,1))}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);i&&this.draw.render({isSetCursor:!1})}else{const{startIndex:e,endIndex:n}=this.range.getRange();if(e!==n||!this.draw.getElementList()[e].controlId)return;const a=this.draw.getControl().removeControl(e);if(a===null)return;this.range.setRange(a,a),this.draw.render({curIndex:a})}}translate(t){return this.i18n.t(t)}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){const e=this.draw.getOriginalElementList();function n(p,I){for(let m=0;m<p.length;m++){const L=p[m];if(L.type===s.ElementType.TABLE){const P=L.trList;for(let M=0;M<P.length;M++){const F=P[M];for(let N=0;N<F.tdList.length;N++){const Y=F.tdList[N],b=n(Y.value,I);if(b)return{...b,isTable:!0,index:m,trIndex:M,tdIndex:N,tdId:Y.id,trId:F.id,tableId:L.id}}}}if(L.titleId===I){let P=m;for(;P<p.length;){if(p[P+1]?.titleId!==I)return{isTable:!1,startIndex:P,endIndex:P};P++}}}return null}const i=n(e,t);if(!i)return;const{isTable:l,index:r,startTdIndex:a,endTdIndex:c,startTrIndex:d,endTrIndex:u,trIndex:h,tdIndex:R,tdId:f,trId:g,tableId:T,endIndex:C}=i;this.position.setPositionContext({isTable:l,index:r,trIndex:h,tdIndex:R,tdId:f,trId:g,tableId:T}),this.range.setRange(C,C,T,a,c,d,u),this.draw.render({curIndex:C,isCompute:!1,isSubmitHistory:!1})}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let n=0;n<t.length;n++)if(t[n].value===K)for(;n+1<t.length;){const l=t[n+1];if(l.value!==K&&l.value!==ai)break;t.splice(n+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const n=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:n})}}setHTML(t){const{header:e,main:n,footer:i}=t,l=this.draw.getOriginalInnerWidth(),r=a=>a!==void 0?Qn(a,{innerWidth:l}):void 0;this.setValue({header:r(e),main:r(n),footer:r(i)})}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(),n=this.draw.getGroup().getContextByGroupId(e,t);if(!n)return;const{isTable:i,index:l,trIndex:r,tdIndex:a,tdId:c,trId:d,tableId:u,endIndex:h}=n;this.position.setPositionContext({isTable:i,index:l,trIndex:r,tdIndex:a,tdId:c,trId:d,tableId:u}),this.range.setRange(h,h),this.draw.render({curIndex:h,isCompute:!1,isSubmitHistory:!1})}setZone(t){this.draw.getZone().setZone(t)}getControlValue(t){return this.draw.getControl().getValueById(t)}getButtonContent(t){const{controlId:e}=t;if(!e)return null;const n=this.findButtonControlContext(e);return n?this.getButtonContentResult(this.getButtonBusinessValue(n)):null}setButtonContent(t){if(!(this.draw.getMode()===s.EditorMode.FORM)&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{controlId:i,mode:l,isSubmitHistory:r=!0}=t;if(!i)return;const a=this.findButtonControlContext(i);if(!a)return;const c=this.getButtonBusinessValue(a),d=this.normalizeButtonContentValue(t.value),u=l==="append"?this.appendButtonContentValue(c,d):d;this.removeButtonBusinessElements(a);const h=this.findButtonControlContext(i);if(!h)return;const R=this.createButtonBusinessElements(h,u),f=this.replaceButtonRenderedValue(h,R,u);this.syncButtonPlaceholderElements(h.elementList,i,h.element.control?.placeholder||""),r||this.historyManager.recovery(),this.draw.render({curIndex:f,isSubmitHistory:r,isSetCursor:!0})}setControlValue(t){this.draw.getControl().setValueListById([t])}setControlValueList(t){this.draw.getControl().setValueListById(t)}setControlExtension(t){this.draw.getControl().setExtensionListById([t])}setControlExtensionList(t){this.draw.getControl().setExtensionListById(t)}setControlProperties(t){this.draw.getControl().setPropertiesListById([t])}setControlPropertiesList(t){this.draw.getControl().setPropertiesListById(t)}setControlHighlight(t){this.draw.getControl().setHighlightList(t),this.draw.render({isSubmitHistory:!1})}setControlQualityMarks(t){this.draw.getControl().setQualityMarks(t),this.draw.render({isSetCursor:!1,isSubmitHistory:!1})}updateOptions(t){const e=Oo(t);Object.entries(e).forEach(([n,i])=>{Reflect.set(this.options,n,i)}),this.forceUpdate()}setFormModeTrace(t){Object.assign(this.options.modeRule.form,t),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){if(!t)return;function n(r,a,c){let d=0;for(;d<r.length;){const u=r[d];if(d++,u.type===s.ElementType.TABLE){const R=u.trList;for(let f=0;f<R.length;f++){const g=R[f];for(let T=0;T<g.tdList.length;T++){const C=g.tdList[T],p=n(C.value,a,c);if(p)return{...p,positionContext:{isTable:!0,index:d-1,trIndex:f,tdIndex:T,tdId:C.id,trId:g.id,tableId:u.id}}}}}if(!c(u))continue;let h=d-1;if(e?.position===s.LocationPosition.OUTER_AFTER){if(!(u.controlComponent===s.ControlComponent.POSTFIX&&r[d+1]?.controlComponent!==s.ControlComponent.POST_TEXT))continue}else if(e?.position===s.LocationPosition.OUTER_BEFORE)h-=1;else if(e?.position===s.LocationPosition.AFTER){if(h-=1,u.controlComponent!==s.ControlComponent.PLACEHOLDER&&u.controlComponent!==s.ControlComponent.POSTFIX&&u.controlComponent!==s.ControlComponent.POST_TEXT)continue}else if(u.controlComponent!==s.ControlComponent.PREFIX&&u.controlComponent!==s.ControlComponent.PRE_TEXT||r[d]?.controlComponent===s.ControlComponent.PREFIX||r[d]?.controlComponent===s.ControlComponent.PRE_TEXT)continue;return{zone:a,range:{startIndex:h,endIndex:h},positionContext:{isTable:!1}}}return null}const i=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}],l=[r=>r.controlId===t,r=>r.control?.conceptId===t,r=>r.control?.code===t];for(let r=0;r<l.length;r++)for(const a of i){const c=n(a.elementList,a.zone,l[r]);if(c){this.setZone(c.zone),this.position.setPositionContext(c.positionContext),this.range.replaceRange(c.range),this.draw.render({curIndex:c.range.startIndex,isCompute:!1,isSubmitHistory:!1});return}}}insertTextField(t){if(this.draw.isReadonly()||this.draw.isDisabled()||!t)return;const n=at(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Zn(l,i);if(!r)return;const a=[...En,...le,...bn,...Rn];un(a,r,n),this.draw.insertElementTextField([n])}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=at(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Zn(l,i);if(!r)return;const a=l[i],c=a?.controlComponent===s.ControlComponent.POSTFIX||a?.controlComponent===s.ControlComponent.POSTTEXTFIX;let d=!1;if(a?.controlId&&!c)for(let h=i;h>=0;h--){const R=l[h];if(R.controlId!==a.controlId)break;if(R.controlComponent===s.ControlComponent.PRETEXTFIX||R.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){R.control?.type===s.ControlType.TEXTFIELD&&(d=!0);break}}if(!d&&!c){const h=l[i-1];if(h?.controlId)for(let R=i-1;R>=0;R--){const f=l[R];if(f.controlId!==h.controlId)break;if(f.controlComponent===s.ControlComponent.PRETEXTFIX||f.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){f.control?.type===s.ControlType.TEXTFIELD&&(d=!0);break}}}if(d&&t.control?.type===s.ControlType.TEXTFIELD)return;const u=[...En,...le,...bn,...Rn];un(u,r,n),this.draw.insertElementList([n])}jumpControl(t){this.draw.getControl().initNextControl({direction:t?.direction})}getContainer(){return this.draw.getContainer()}getTitleValue(t){const{conceptId:e}=t,n=[],i=(r,a)=>{let c=0;for(;c<r.length;){const d=r[c];if(c++,d.type===s.ElementType.TABLE){const R=d.trList;for(let f=0;f<R.length;f++){const g=R[f];for(let T=0;T<g.tdList.length;T++){const C=g.tdList[T];i(C.value,a)}}}if(d?.title?.conceptId!==e)continue;const u=[];let h=c;for(;h<r.length;){const R=r[h];if(h++,d.titleId!==R.titleId){if(R.level&&Mi[R.level]<=Mi[d.level])break;u.push(R)}}n.push({...d.title,value:Mn(u),elementList:Yt(u),zone:a}),c=h}},l=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:r,elementList:a}of l)i(a,r);return n}getPositionContextByEvent(t,e={}){const n=t.target?.dataset.index;if(!n)return null;const{isMustDirectHit:i=!0}=e,l=Number(n),r=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:l}),{isDirectHit:a,isTable:c,index:d,trIndex:u,tdIndex:h,tdValueIndex:R,zone:f}=r;if(i&&!a||f&&f!==this.zone.getZone())return null;let g=null,T=null;const C=this.draw.getOriginalElementList();let p=null;const I=this.position.getOriginalPositionList();if(c){const L=C[d].trList?.[u].tdList[h];T=L?.value[R]||null,p=L?.positionList?.[R]||null,g={element:C[d],trIndex:u,tdIndex:h}}else T=C[d]||null,p=I[d]||null;let m=null;if(p){const{pageNo:L,coordinate:{leftTop:P,rightTop:M},lineHeight:F}=p,N=this.draw.getOriginalHeight(),Y=this.draw.getOriginalPageGap();m={x:P[0],y:P[1]+L*(N+Y),width:M[0]-P[0],height:F}}return{pageNo:l,element:T,rangeRect:m,tableInfo:g}}insertTitle(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=at(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Zn(l,i);if(!r)return;const a=[...En,...le,...bn,...Rn];n.valueList?.forEach(c=>{un(a,r,c)}),this.draw.insertElementList([n])}focus(t){const{position:e=s.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:i,range:l}=t||{};let r=-1;if(l)this.range.replaceRange(l),r=e===s.LocationPosition.BEFORE?l.startIndex:l.endIndex;else if(fi(i)){const c=this.draw.getOriginalRowList();if(r=e===s.LocationPosition.BEFORE?c[i]?.startIndex:c[i+1]?.startIndex-1,!fi(r))return;this.range.setRange(r,r)}else r=e===s.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(r,r);const a={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~r&&this.range.getIsCollapsed()&&(a.curIndex=r,a.isSetCursor=!0),this.draw.render(a)}insertArea(t){return this.draw.getArea().insertArea(t)}setAreaValue(t){return this.draw.getArea().setAreaValue(t)}setAreaProperties(t){this.draw.getArea().setAreaProperties(t)}locationArea(t,e){if(e?.isAppendLastLineBreak&&e?.position===s.LocationPosition.OUTER_AFTER){const l=this.draw.getOriginalMainElementList();l[l.length-1].areaId===t&&this.draw.appendElementList([{value:K}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:i}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(i,i),this.draw.render({curIndex:i,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getMacroValue(t){const{id:e,dictCode:n,label:i,areaId:l}=t,r=[],a=(d,u)=>{for(const h of d){if(h.type===s.ElementType.TABLE){const f=h.trList;for(const g of f)for(const T of g.tdList)a(T.value,u);continue}if(h.type!==s.ElementType.MACRO&&h.type!==s.ElementType.CUSTOM_MACRO&&h.type!==s.ElementType.REUSABLE_ITEM||e&&h.id!==e||n&&h.dictCode!==n||i&&h.label!==i||l&&h.areaId!==l)continue;const R={id:h.id,type:h.type,label:h.label,dictCode:h.dictCode,zone:u};h.type===s.ElementType.MACRO?R.value=h.value:h.type===s.ElementType.CUSTOM_MACRO?(R.macroConfig=h.macroConfig,R.value=h.macroConfig?.value):h.type===s.ElementType.REUSABLE_ITEM&&(R.reusableItemConfig=h.reusableItemConfig,R.value=h.reusableItemConfig?.value),r.push(R)}},c=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:d,elementList:u}of c)a(u,d);return r}getMacroList(){const t=[],e=i=>{for(const l of i){if(l.type===s.ElementType.TABLE){const r=l.trList;for(const a of r)for(const c of a.tdList)e(c.value);continue}(l.type===s.ElementType.MACRO||l.type===s.ElementType.CUSTOM_MACRO||l.type===s.ElementType.REUSABLE_ITEM)&&t.push(l)}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i);return t}setMacroValue(t){const{id:e,dictCode:n,label:i,areaId:l,value:r,code:a,isSubmitHistory:c=!0}=t;let d=!1;const u=R=>{for(let f=0;f<R.length;f++){const g=R[f];if(g.type===s.ElementType.TABLE){const T=g.trList;for(const C of T)for(const p of C.tdList)u(p.value);continue}g.type!==s.ElementType.MACRO&&g.type!==s.ElementType.CUSTOM_MACRO&&g.type!==s.ElementType.REUSABLE_ITEM||e&&g.id!==e||n&&g.dictCode!==n||i&&g.label!==i||l&&g.areaId!==l||(d=!0,g.type===s.ElementType.MACRO?g.value=r:g.type===s.ElementType.CUSTOM_MACRO?g.macroConfig?(g.macroConfig.value=r,a!==void 0&&(g.macroConfig.code=a)):g.macroConfig={type:"text",value:r}:g.type===s.ElementType.REUSABLE_ITEM&&(g.reusableItemConfig?g.reusableItemConfig.value=r:g.reusableItemConfig={value:r}))}},h=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const R of h)u(R);d&&this.draw.render({isSubmitHistory:c,isSetCursor:!1})}setMacroValueList(t){if(!t.length)return;let e=!1,n=!1;const i=r=>{for(let a=0;a<r.length;a++){const c=r[a];if(c.type===s.ElementType.TABLE){const f=c.trList;for(const g of f)for(const T of g.tdList)i(T.value);continue}if(c.type!==s.ElementType.MACRO&&c.type!==s.ElementType.CUSTOM_MACRO&&c.type!==s.ElementType.REUSABLE_ITEM)continue;const d=t.find(f=>f.id&&c.id===f.id||f.dictCode&&c.dictCode===f.dictCode||f.label&&c.label===f.label||f.areaId&&c.areaId===f.areaId);if(!d)continue;const{value:u,code:h,isSubmitHistory:R=!0}=d;e=!0,R&&(n=!0),c.type===s.ElementType.MACRO?c.value=u:c.type===s.ElementType.CUSTOM_MACRO?c.macroConfig?(c.macroConfig.value=u,h!==void 0&&(c.macroConfig.code=h)):c.macroConfig={type:"text",value:u}:c.type===s.ElementType.REUSABLE_ITEM&&(c.reusableItemConfig?c.reusableItemConfig.value=u:c.reusableItemConfig={value:u})}},l=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const r of l)i(r);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}updateMacroProperties(t){const{id:e,dictCode:n,label:i,areaId:l,properties:r,isSubmitHistory:a=!0}=t;let c=!1;const d=h=>{for(let R=0;R<h.length;R++){const f=h[R];if(f.type===s.ElementType.TABLE){const g=f.trList;for(const T of g)for(const C of T.tdList)d(C.value);continue}f.type!==s.ElementType.MACRO&&f.type!==s.ElementType.CUSTOM_MACRO&&f.type!==s.ElementType.REUSABLE_ITEM||e&&f.id!==e||n&&f.dictCode!==n||i&&f.label!==i||l&&f.areaId!==l||(c=!0,Object.assign(f,r))}},u=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const h of u)d(h);c&&this.draw.render({isSubmitHistory:a,isSetCursor:!1})}locationMacro(t){const{id:e,dictCode:n,label:i,areaId:l}=t,r=(c,d)=>{for(let u=0;u<c.length;u++){const h=c[u];if(h.type===s.ElementType.TABLE){const R=h.trList;for(let f=0;f<R.length;f++){const g=R[f];for(let T=0;T<g.tdList.length;T++){const C=g.tdList[T],p=r(C.value,d);if(p)return{...p,isTable:!0,index:u,trIndex:f,tdIndex:T,tableId:h.tableId,trId:g.id,tdId:C.id}}}}if(!(h.type!==s.ElementType.MACRO&&h.type!==s.ElementType.CUSTOM_MACRO&&h.type!==s.ElementType.REUSABLE_ITEM)&&!(e&&h.id!==e)&&!(n&&h.dictCode!==n)&&!(i&&h.label!==i)&&!(l&&h.areaId!==l))return{zone:d,index:u}}return null},a=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:c,elementList:d}of a){const u=r(d,c);if(u){this.setZone(u.zone),this.position.setPositionContext({isTable:u.isTable||!1,index:u.index,trIndex:u.trIndex,tdIndex:u.tdIndex,tableId:u.tableId,trId:u.trId,tdId:u.tdId}),this.range.replaceRange({startIndex:u.index,endIndex:u.index}),this.draw.render({curIndex:u.index,isCompute:!1,isSubmitHistory:!1});break}}}insertSubTemplate(t){const{label:e,templateId:n,content:i,conditions:l,relation:r="and",isSubmitHistory:a=!0}=t,c={id:mt(),value:e,type:s.ElementType.SUB_TEMPLATE,label:e,templateId:n,subTemplateContent:i?.map(d=>at(d)),subTemplateRelation:r,subTemplateConditions:l?.map(d=>({...d})),subTemplateExpanded:!1};this.insertElementList([c],{isSubmitHistory:a})}updateSubTemplate(t){const{id:e,properties:n,isSubmitHistory:i=!0}=t;if(!e)return;const l=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];let r=!1;for(let a=0;a<l.length;a++)Os(l[a],c=>{c.id!==e||c.type!==s.ElementType.SUB_TEMPLATE||(Object.assign(c,{...n,value:n.label??c.value,subTemplateContent:n.subTemplateContent?n.subTemplateContent.map(d=>at(d)):c.subTemplateContent?.map(d=>at(d)),subTemplateConditions:n.subTemplateConditions?n.subTemplateConditions.map(d=>({...d})):c.subTemplateConditions?.map(d=>({...d}))}),r=!0)});r&&this.draw.render({isSubmitHistory:i,isCompute:!0})}expandSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,l=this.draw.getOriginalMainElementList();for(let r=0;r<l.length;r++){const a=l[r];if(a.type===s.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){const c=n||a.subTemplateContent;if(!c?.length){console.warn("子模板内容为空,无法展开");return}a.subTemplateExpanded=!0,a.hide=!0;const d=at(c);qt(d,{isHandleFirstElement:!1,editorOptions:this.options});for(let u=0;u<d.length;u++)d[u].subTemplateParentId=a.id;l.splice(r+1,0,...d),this.draw.render({isSubmitHistory:i,isCompute:!0});return}}}collapseSubTemplate(t){const{id:e,isSubmitHistory:n=!0}=t,i=this.draw.getOriginalMainElementList();for(let l=0;l<i.length;l++){const r=i[l];if(r.type===s.ElementType.SUB_TEMPLATE&&(!e||r.id===e)){r.subTemplateExpanded=!1,r.hide=!1;let a=l+1;for(;a<i.length&&i[a].subTemplateParentId===r.id;)a++;a>l+1&&i.splice(l+1,a-l-1),this.draw.render({isSubmitHistory:n,isCompute:!0});return}}}toggleSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,l=this.draw.getOriginalMainElementList();for(let r=0;r<l.length;r++){const a=l[r];if(a.type===s.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){a.subTemplateExpanded?this.collapseSubTemplate({id:e,isSubmitHistory:i}):this.expandSubTemplate({id:e,content:n,isSubmitHistory:i});return}}}}class xf{rangeStyleChange;visiblePageNoListChange;intersectionPageNoChange;pageSizeChange;pageScaleChange;saved;contentChange;controlChange;controlContentChange;pageModeChange;zoneChange;constructor(){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.controlContentChange=null,this.pageModeChange=null,this.zoneChange=null}}class Jf{contextMenu;contextMenuList;getContextMenuList;shortcutList;langMap;constructor(t){const{contextMenu:e,shortcut:n,i18n:i}=t;this.contextMenu=e,this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=i.registerLangMap.bind(i)}disposeContextMenu(){this.contextMenu.dispose()}}const Al={SELECTED_TEXT:"%s"},to={GLOBAL:{CUT:"globalCut",COPY:"globalCopy",PASTE:"globalPaste",SELECT_ALL:"globalSelectAll",PRINT:"globalPrint"},CONTROL:{DELETE:"controlDelete",EDIT_ATTRIBUTE:"controlEditAttribute",COPY:"controlCopy",PASTE:"controlPaste"},HYPERLINK:{DELETE:"hyperlinkDelete",CANCEL:"hyperlinkCancel",EDIT:"hyperlinkEdit"},IMAGE:{CHANGE:"imageChange",SAVE_AS:"imageSaveAs",TEXT_WRAP:"imageTextWrap",TEXT_WRAP_EMBED:"imageTextWrapEmbed",TEXT_WRAP_UP_DOWN:"imageTextWrapUpDown",TEXT_WRAP_SURROUND:"imageTextWrapSurround",TEXT_WRAP_FLOAT_TOP:"imageTextWrapFloatTop",TEXT_WRAP_FLOAT_BOTTOM:"imageTextWrapFloatBottom"},TABLE:{BORDER:"border",BORDER_ALL:"tableBorderAll",BORDER_EMPTY:"tableBorderEmpty",BORDER_DASH:"tableBorderDash",BORDER_EXTERNAL:"tableBorderExternal",BORDER_INTERNAL:"tableBorderInternal",BORDER_TD:"tableBorderTd",BORDER_TD_TOP:"tableBorderTdTop",BORDER_TD_RIGHT:"tableBorderTdRight",BORDER_TD_BOTTOM:"tableBorderTdBottom",BORDER_TD_LEFT:"tableBorderTdLeft",BORDER_TD_FORWARD:"tableBorderTdForward",BORDER_TD_BACK:"tableBorderTdBack",VERTICAL_ALIGN:"tableVerticalAlign",VERTICAL_ALIGN_TOP:"tableVerticalAlignTop",VERTICAL_ALIGN_MIDDLE:"tableVerticalAlignMiddle",VERTICAL_ALIGN_BOTTOM:"tableVerticalAlignBottom",INSERT_ROW_COL:"tableInsertRowCol",INSERT_TOP_ROW:"tableInsertTopRow",INSERT_BOTTOM_ROW:"tableInsertBottomRow",INSERT_LEFT_COL:"tableInsertLeftCol",INSERT_RIGHT_COL:"tableInsertRightCol",DELETE_ROW_COL:"tableDeleteRowCol",DELETE_ROW:"tableDeleteRow",DELETE_COL:"tableDeleteCol",DELETE_TABLE:"tableDeleteTable",MERGE_CELL:"tableMergeCell",CANCEL_MERGE_CELL:"tableCancelMergeCell",TABLE_PROPERTIES:"tableProperties"}},{CONTROL:{DELETE:$f,EDIT_ATTRIBUTE:zf,COPY:jf,PASTE:qf}}=to;function tT(o,t){if(t!==s.EditorMode.EDIT)return!1;const n=o?.control?.type,i=o?.controlComponent,l=n===s.ControlType.TEXT||n===s.ControlType.TEXTFIELD||n===s.ControlType.NUMBER||n===s.ControlType.SELECT||n===s.ControlType.DATE||n===s.ControlType.CHECKBOX||n===s.ControlType.RADIO||n===s.ControlType.BUTTON,r=i==="prefix"||i==="preText"||i==="preTextFix"||i==="textFixLabel"||n===s.ControlType.BUTTON&&(i==="value"||i==="placeholder");return l&&r}function _l(o){return o.hitElement||o.hitTableElement}const eT=[{key:jf,name:"复制控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&tT(o.startElement,o.options.mode),callback:(o,t)=>{const e=t.startElement?.controlId;e&&o.executeCopyControl(e)}},{key:qf,name:"粘贴控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.editorTextFocus&&o.options.mode===s.EditorMode.EDIT&&Nc(),callback:o=>{o.executePasteControl()}},{key:$f,i18nPath:"contextmenu.control.delete",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeRemoveControl()}},{key:zf,i18nPath:"contextmenu.control.editAttribute",when:o=>{const t=_l(o);return!o.isReadonly&&!o.editorHasSelection&&o.options.mode===s.EditorMode.EDIT&&!!t},callback:(o,t)=>{const e=_l(t);e&&o.executeTriggerControlEditAttribute(e.controlId,e)}}],{GLOBAL:{CUT:nT,COPY:oT,PASTE:iT,SELECT_ALL:sT,PRINT:rT}}=to,lT=[{key:nT,i18nPath:"contextmenu.global.cut",shortCut:`${In?"⌘":"Ctrl"} + X`,when:o=>!o.isReadonly,callback:o=>{o.executeCut()}},{key:oT,i18nPath:"contextmenu.global.copy",shortCut:`${In?"⌘":"Ctrl"} + C`,when:o=>o.editorHasSelection||o.isCrossRowCol,callback:o=>{o.executeCopy()}},{key:iT,i18nPath:"contextmenu.global.paste",shortCut:`${In?"⌘":"Ctrl"} + V`,when:o=>!o.isReadonly&&o.editorTextFocus,callback:o=>{o.executePaste()}},{key:sT,i18nPath:"contextmenu.global.selectAll",shortCut:`${In?"⌘":"Ctrl"} + A`,when:o=>o.editorTextFocus,callback:o=>{o.executeSelectAll()}},{isDivider:!0},{key:rT,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:o=>{o.executePrint()}}],{HYPERLINK:{DELETE:aT,CANCEL:cT,EDIT:dT}}=to,uT=[{key:aT,i18nPath:"contextmenu.hyperlink.delete",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:o=>{o.executeDeleteHyperlink()}},{key:cT,i18nPath:"contextmenu.hyperlink.cancel",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:o=>{o.executeCancelHyperlink()}},{key:dT,i18nPath:"contextmenu.hyperlink.edit",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:(o,t)=>{const e=window.prompt(o.executeTranslate("contextmenu.hyperlink.edit"),t.startElement?.url);e&&o.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:RT,SAVE_AS:hT,TEXT_WRAP:gT,TEXT_WRAP_EMBED:fT,TEXT_WRAP_UP_DOWN:TT,TEXT_WRAP_SURROUND:mT,TEXT_WRAP_FLOAT_TOP:CT,TEXT_WRAP_FLOAT_BOTTOM:pT}}=to,IT=[{key:RT,i18nPath:"contextmenu.image.change",icon:"image-change",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,callback:o=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],n=new FileReader;n.readAsDataURL(e),n.onload=()=>{const i=n.result;o.executeReplaceImageElement(i)}},t.click()}},{key:hT,i18nPath:"contextmenu.image.saveAs",icon:"image",when:o=>!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,callback:o=>{o.executeSaveAsImageElement()}},{key:gT,i18nPath:"contextmenu.image.textWrap",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,childMenus:[{key:fT,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.BLOCK)}},{key:TT,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.INLINE)}},{key:mT,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.SURROUND)}},{key:CT,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.FLOAT_TOP)}},{key:pT,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:ET,BORDER_ALL:LT,BORDER_EMPTY:PT,BORDER_DASH:MT,BORDER_EXTERNAL:OT,BORDER_INTERNAL:ST,BORDER_TD:DT,BORDER_TD_TOP:FT,BORDER_TD_LEFT:XT,BORDER_TD_BOTTOM:NT,BORDER_TD_RIGHT:yT,BORDER_TD_BACK:bT,BORDER_TD_FORWARD:VT,VERTICAL_ALIGN:WT,VERTICAL_ALIGN_TOP:YT,VERTICAL_ALIGN_MIDDLE:UT,VERTICAL_ALIGN_BOTTOM:wT,INSERT_ROW_COL:ZT,INSERT_TOP_ROW:vT,INSERT_BOTTOM_ROW:QT,INSERT_LEFT_COL:KT,INSERT_RIGHT_COL:HT,DELETE_ROW_COL:AT,DELETE_ROW:_T,DELETE_COL:BT,DELETE_TABLE:kT,MERGE_CELL:GT,CANCEL_MERGE_CELL:xT}}=to,JT=[{isDivider:!0},{key:ET,i18nPath:"contextmenu.table.border",icon:"border-all",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:LT,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.ALL)}},{key:PT,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.EMPTY)}},{key:MT,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.DASH)}},{key:OT,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.EXTERNAL)}},{key:ST,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.INTERNAL)}},{key:DT,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:FT,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.TOP)}},{key:yT,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.RIGHT)}},{key:NT,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.BOTTOM)}},{key:XT,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.LEFT)}},{key:VT,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:o=>{o.executeTableTdSlashType(s.TdSlash.FORWARD)}},{key:bT,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:o=>{o.executeTableTdSlashType(s.TdSlash.BACK)}}]}]},{key:WT,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:YT,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.TOP)}},{key:UT,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.MIDDLE)}},{key:wT,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.BOTTOM)}}]},{key:ZT,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:vT,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:o=>{o.executeInsertTableTopRow()}},{key:QT,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:o=>{o.executeInsertTableBottomRow()}},{key:KT,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:o=>{o.executeInsertTableLeftCol()}},{key:HT,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:o=>{o.executeInsertTableRightCol()}}]},{key:AT,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:_T,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:o=>{o.executeDeleteTableRow()}},{key:BT,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:o=>{o.executeDeleteTableCol()}},{key:kT,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:o=>{o.executeDeleteTable()}}]},{key:GT,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:o=>!o.isReadonly&&o.isCrossRowCol&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeMergeTableCell()}},{key:xT,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeCancelMergeTableCell()}}];class $T{options;draw;command;range;position;i18n;container;contextMenuList;contextMenuContainerList;contextMenuRelationShip;context;constructor(t,e){this.options=t.getOptions(),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=[...lT,...JT,...IT,...eT,...uT],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}getContextMenuList(){return this.contextMenuList}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_filterMenuList(t){const{contextMenuDisableKeys:e}=this.options,n=[];for(let i=0;i<t.length;i++){const l=t[i];l.disable||l.key&&e.includes(l.key)||(l.isDivider||l.when?.(this.context))&&n.push(l)}return n}_proxyContextMenuEvent=t=>{this.context=this._getContext(t);const e=this._filterMenuList(this.contextMenuList);e.some(i=>!i.isDivider)&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()};_handleSideEffect=t=>{const e=t.target;this.contextMenuContainerList.some(i=>i.contains(e))||this.dispose()};_getContext(t){const e=this.draw.isReadonly(),{isCrossRowCol:n,startIndex:i,endIndex:l}=this.range.getRange(),r=!!(~i||~l),a=r&&i!==l,{isTable:c,trIndex:d,tdIndex:u,index:h}=this.position.getPositionContext(),R=t?this.command.getPositionContextByEvent(t,{isMustDirectHit:!0}):null;let f=null;if(c){const M=this.draw.getOriginalElementList()[h]||null;M&&(f=Yt([M],{extraPickAttrs:["id"]})[0])}const g=c&&!!n,T=this.draw.getElementList();let C=T[i]||null,p=T[l]||null;R?.element&&(C=R.element,p=R.element);const I=R?.element||null,m=R?.tableInfo?.element||null;R?.tableInfo?.element&&(f=R.tableInfo.element);const L=this.draw.getZone().getZone();return{startElement:C,endElement:p,hitElement:I,hitTableElement:m,isReadonly:e,editorHasSelection:a,editorTextFocus:r,isCrossRowCol:g,zone:L,isInTable:c,trIndex:d??null,tdIndex:u??null,tableElement:f,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-contextmenu-container`),t.setAttribute(Ze,s.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){const{contextMenuList:e,left:n,top:i,parentMenuContainer:l}=t,r=this._createContextMenuContainer(),a=document.createElement("div");a.classList.add(`${rt}-contextmenu-content`);let c=null;l&&this.contextMenuRelationShip.set(l,r);for(let L=0;L<e.length;L++){const P=e[L];if(P.isDivider){if(L!==0&&L!==e.length-1&&!e[L-1]?.isDivider){const M=document.createElement("div");M.classList.add(`${rt}-contextmenu-divider`),a.append(M)}}else{const M=document.createElement("div");if(M.classList.add(`${rt}-contextmenu-item`),P.childMenus){const b=this._filterMenuList(P.childMenus);b.some(y=>!y.isDivider)&&(M.classList.add(`${rt}-contextmenu-sub-item`),M.onmouseenter=()=>{this._setHoverStatus(M,!0),this._removeSubMenu(r);const y=M.getBoundingClientRect(),V=y.left+y.width,X=y.top;c=this._render({contextMenuList:b,left:V,top:X,parentMenuContainer:r})},M.onmouseleave=y=>{(!c||!c.contains(y.relatedTarget))&&this._setHoverStatus(M,!1)})}else M.onmouseenter=()=>{this._setHoverStatus(M,!0),this._removeSubMenu(r)},M.onmouseleave=()=>{this._setHoverStatus(M,!1)},M.onclick=()=>{P.callback&&this.context&&P.callback(this.command,this.context),this.dispose()};const F=document.createElement("i");M.append(F),P.icon&&F.classList.add(`${rt}-contextmenu-${P.icon}`);const N=document.createElement("span"),Y=P.i18nPath?this._formatName(this.i18n.t(P.i18nPath)):this._formatName(P.name||"");if(N.append(document.createTextNode(Y)),M.append(N),P.shortCut){const b=document.createElement("span");b.classList.add(`${rt}-shortcut`),b.append(document.createTextNode(P.shortCut)),M.append(b)}a.append(M)}}const d=document.createElement("div");d.classList.add(`${rt}-contextmenu-divider`),a.append(d);const u=document.createElement("div");u.classList.add(`${rt}-contextmenu-item`),u.onmouseenter=()=>{this._setHoverStatus(u,!0),this._removeSubMenu(r)},u.onmouseleave=()=>{this._setHoverStatus(u,!1)},u.onclick=()=>{this.dispose()};const h=document.createElement("i");u.append(h);const R=document.createElement("span");R.append(document.createTextNode(this.i18n.t("contextmenu.global.cancel"))),u.append(R),a.append(u),r.append(a),r.style.display="block";const f=window.innerWidth,g=r.getBoundingClientRect(),T=g.width,C=n+T>f?n-T:n;r.style.left=`${C}px`;const p=window.innerHeight,I=g.height,m=i+I>p?i-I:i;return r.style.top=`${m}px`,this.contextMenuContainerList.push(r),r}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){e?(t.parentNode?.querySelectorAll(`${rt}-contextmenu-item`).forEach(n=>n.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(Al),n=new RegExp(`${e.join("|")}`);let i=t;if(n.test(i)){const l=new RegExp(Al.SELECTED_TEXT,"g");if(l.test(i)){const r=this.range.toString();i=i.replace(l,r)}}return i}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const zT=[{key:s.KeyMap.X,ctrl:!0,shift:!0,callback:o=>{o.executeStrikeout()}},{key:s.KeyMap.LEFT_BRACKET,mod:!0,callback:o=>{o.executeSizeAdd()}},{key:s.KeyMap.RIGHT_BRACKET,mod:!0,callback:o=>{o.executeSizeMinus()}},{key:s.KeyMap.B,mod:!0,callback:o=>{o.executeBold()}},{key:s.KeyMap.I,mod:!0,callback:o=>{o.executeItalic()}},{key:s.KeyMap.U,mod:!0,callback:o=>{o.executeUnderline()}},{key:In?s.KeyMap.COMMA:s.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSuperscript()}},{key:In?s.KeyMap.PERIOD:s.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSubscript()}},{key:s.KeyMap.L,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.LEFT)}},{key:s.KeyMap.E,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.CENTER)}},{key:s.KeyMap.R,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.RIGHT)}},{key:s.KeyMap.J,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.ALIGNMENT)}},{key:s.KeyMap.J,mod:!0,shift:!0,callback:o=>{o.executeRowFlex(s.RowFlex.JUSTIFY)}}],jT=[{key:s.KeyMap.ZERO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(null)}},{key:s.KeyMap.ONE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FIRST)}},{key:s.KeyMap.TWO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.SECOND)}},{key:s.KeyMap.THREE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.THIRD)}},{key:s.KeyMap.FOUR,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FOURTH)}},{key:s.KeyMap.FIVE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FIFTH)}},{key:s.KeyMap.SIX,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.SIXTH)}}],qT=[{key:s.KeyMap.I,shift:!0,mod:!0,callback:o=>{o.executeList(s.ListType.UL,s.ListStyle.DISC)}},{key:s.KeyMap.U,shift:!0,mod:!0,callback:o=>{o.executeList(s.ListType.OL)}}];class tm{draw;command;globalShortcutList;agentShortcutList;constructor(t,e){this.draw=t,this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...zT,...jT,...qT]),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 n=t[e];n.isGlobal?this.globalShortcutList.unshift(n):this.agentShortcutList.unshift(n)}}registerShortcutList(t){this._addShortcutList(t)}_globalKeydown=t=>{this.globalShortcutList.length&&this.draw.isGlobalShortcutActive()&&this.draw.isTargetInsideEditor(t.target)&&this._execute(t,this.globalShortcutList)};_agentKeydown(t){this.agentShortcutList.length&&(this.draw.isInteractionSuspended()||this._execute(t,this.agentShortcutList))}_execute(t,e){for(let n=0;n<e.length;n++){const i=e[n];if((i.mod?Ae(t)===!!i.mod:t.ctrlKey===!!i.ctrl&&t.metaKey===!!i.meta)&&t.shiftKey===!!i.shift&&t.altKey===!!i.alt&&t.key.toLowerCase()===i.key.toLowerCase()){i.disable||(i?.callback?.(this.command),t.preventDefault());break}}}}class em{editor;constructor(t){this.editor=t}use(t,e){t(this.editor,e)}}class nm{eventHub;constructor(){this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t)||new Set;n.add(e),this.eventHub.set(t,n)}emit(t,e){if(!t)return;const n=this.eventHub.get(t);if(n){if(n.size===1)return[...n][0](e);n.forEach(i=>i(e))}}off(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t);n&&n.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}dangerouslyClearAll(){this.eventHub.clear()}}class om{paste;copy;drop}class Bl{command;version;listener;eventBus;override;register;destroy;use;draw;constructor(t,e,n={}){const i=Oo(n);e=at(e);let l=[],r=[],a=[],c=[];Array.isArray(e)?r=e:(l=e.header||[],r=e.main,a=e.footer||[],c=e.graffiti||[]),[l,r,a].forEach(g=>{qt(g,{editorOptions:i,isForceCompensation:!0})}),this.version=pn,this.listener=new xf,this.eventBus=new nm,this.override=new om,this.draw=new Kf(t,i,{header:l,main:r,footer:a,graffiti:c},this.listener,this.eventBus,this.override);const u=this.draw;this.command=new Kl(new Gf(u)),u.setCommand(this.command);const h=new $T(u,this.command),R=new tm(u,this.command);this.register=new Jf({contextMenu:h,shortcut:R,i18n:u.getI18n()}),this.destroy=()=>{u.destroy(),R.removeEvent(),h.removeEvent(),this.eventBus.dangerouslyClearAll()};const f=new em(this);this.use=f.use.bind(f)}setFormModeTrace(t){this.command.executeSetFormModeTrace(t)}pauseInteraction(){this.draw.pauseInteraction()}resumeInteraction(){this.draw.resumeInteraction()}setOverlayActive(t){this.draw.setOverlayActive(t)}suspendGlobalShortcut(t){this.draw.suspendGlobalShortcut(t)}}s.Command=Kl,s.EDITOR_CLIPBOARD=no,s.EDITOR_COMPONENT=Ze,s.Editor=Bl,s.INTERNAL_CONTEXT_MENU_KEY=to,s.INTERNAL_SHORTCUT_KEY=Mr,s.LETTER_CLASS=ci,s.createDomFromElementList=vn,s.default=Bl,s.getElementListByHTML=Qn,s.getTextFromElementList=Mn,s.splitText=Dt,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));