ht-emr 0.7.17 → 0.7.18

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-color:#00000080;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-color:#00000080;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-color:#00000080;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__mask{position:absolute;top:0;left:0;width:100%;height:100%;background:#00000080}.tooth-position-modal__container{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background:#fff;border-radius:8px;box-shadow:0 4px 12px #00000026;min-width:400px;max-width:90vw}.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}.dialog-mask{position:fixed;left:0;top:0;width:100%;height:100%;opacity:.5;background:#000;z-index:99}.dialog-container{position:fixed;inset:0;overflow:auto;z-index:999;margin:0;display:flex;justify-content:center;align-items:center}.dialog{position:absolute;padding:0 30px 30px;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px}.dialog-title{position:relative;border-bottom:1px solid #e2e6ed;margin-bottom:30px;height:60px;display:flex;align-items:center;justify-content:space-between}.dialog-title i{width:16px;height:16px;cursor:pointer;display:inline-block;background:url("data:image/svg+xml,%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(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
- (function(s,Tn){typeof exports=="object"&&typeof module<"u"?Tn(exports):typeof define=="function"&&define.amd?define(["exports"],Tn):(s=typeof globalThis<"u"?globalThis:s||self,Tn(s["canvas-editor"]={}))})(this,(function(s){"use strict";const Tn="0.7.17";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="​",ms=`
2
+ (function(s,Tn){typeof exports=="object"&&typeof module<"u"?Tn(exports):typeof define=="function"&&define.amd?define(["exports"],Tn):(s=typeof globalThis<"u"?globalThis:s||self,Tn(s["canvas-editor"]={}))})(this,(function(s){"use strict";const Tn="0.7.18";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="​",ms=`
3
3
  `,zo=" ",ps="&nbsp;",Hl=["·","、",":",":",",",",",".","。",";",";","?","?","!","!"],Is={[s.MaxHeightRatio.HALF]:1/2,[s.MaxHeightRatio.ONE_THIRD]:1/3,[s.MaxHeightRatio.QUARTER]:1/4},jo={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:"ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΛλΜμΝνΞξΟοΠπΡρΣσςΤτΥυΦφΧχΨψΩω"},_l="中";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 qo=/[0-9.]/,Al=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,Gl=/[#*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,kl=new RegExp(`${Gl.source}|${Al.source}`,"g"),xl=/[、,。?!;:……「」“”‘’*()【】〔〕〖〗〘〙〚〛《》———﹝﹞–—\\/·.,!?;:`~<>()[\]{}'"|]/,ti=new RegExp(`^[${K}
4
4
  ]`),Bl=/[^0-9\+\-\.eE,]/,Jl=/\s/;function $l(o,t){let e;return function(...n){e&&window.clearTimeout(e),e=window.setTimeout(()=>{o.apply(this,n)},t)}}function zl(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 ei(o,t){if(!o||typeof o!="object")return o;let e={};return Array.isArray(o)?e=o.map(n=>ei(n,t)):Object.keys(o).forEach(n=>{t.includes(n)||(e[n]=ei(o[n],t))}),e}function ht(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=>ht(e)):Object.keys(o).forEach(e=>{t[e]=ht(o[e])}),t}function ni(o){return o&&o.nodeType===1&&o.tagName.toLowerCase()==="body"}function Cs(o,t,e){if(o&&!ni(o))for(o=o;o;){if(!t||t(o)||ni(o))return t&&!t(o)&&ni(o)?null:o;o=o.parentNode}return null}function Tt(){function o(){return((1+Math.random())*65536|0).toString(16).substring(1)}return o()+o()+"-"+o()+"-"+o()+"-"+o()+"-"+o()+o()+o()}function yt(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(kl))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 Ls(o,t){const e=document.createElement("a");e.href=o,e.download=t,e.click()}function jl(o,t){ql(3,o,t)}function ql(o,t,e){let n=0,i=0;const l=function(r){n=new Date().getTime()-i<300?n+1:0,i=new Date().getTime(),n>=o-1&&(e(r),n=0)};t.addEventListener("click",l)}function go(o){return Object.prototype.toString.call(o)==="[object Object]"}function oi(o){return Array.isArray(o)}function ii(o){return Object.prototype.toString.call(o)==="[object Number]"}function ta(o){return Object.prototype.toString.call(o)==="[object String]"}function Ps(o,t){if(go(o)&&go(t)){const e=t;for(const[n,i]of Object.entries(o))e[n]?e[n]=Ps(i,e[n]):e[n]=i}else oi(o)&&oi(t)&&t.push(...o);return t}function si(o){if(typeof queueMicrotask=="function"){queueMicrotask(()=>{o()});return}if(typeof Promise<"u"){Promise.resolve().then(()=>{o()});return}setTimeout(()=>{o()},0)}function ea(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 an(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 Es(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 ie(o,t){const e={};for(const n in o)t.includes(n)&&(e[n]=o[n]);return e}function Ie(o,t){const e={};for(const n in o)t.includes(n)||(e[n]=o[n]);return e}function na(o){const e=new TextEncoder().encode(o),n=Array.from(e,l=>String.fromCharCode(l));return window.btoa(n.join(""))}function oa(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 Ms(o,t){return o.length!==t.length?!1:!o.some(e=>!t.includes(e))}function ia(o,t){if(!go(o)||!go(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 sa(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 Os(o){return o==null}function To(o){return o.replace(/\r\n|\r/g,`
5
5
  `)}function Ss(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 Xs(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 se(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function ra(o,t){return o.performance.enabled&&t>=o.performance.threshold}function ri(o,t,e,n=[],i){if(!ra(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 la=12,aa={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},Ue="editor-component",j="ce",Bn=`${j}-clipboard`,li={print:{imagePreviewerDisabled:!1,backgroundDisabled:!1},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1,inputTraceEnabled:!0,deleteTraceEnabled:!0}};var $t;(function(o){o.UP="top",o.DOWN="down",o.LEFT="left",o.RIGHT="right"})($t||($t={}));const fn=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),ca=typeof navigator<"u"&&/iPad|iPhone/.test(navigator.userAgent),da=/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),ua=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"],Te=["rowFlex","rowMargin"],Ra=["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"],ha=["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"],ga=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],Sn=["tdId","trId","tableId"],ai=["level","titleId","title"],Jn=["listId","listType","listStyle"],ci=["control","controlId","controlComponent"],Re=["font","size","bold","highlight","italic","strikeout","deletePerson","newElEditPerson","deleteTime","color","newElEditTime"],mn=["areaId","area"],di=[...Sn,...ai,...Jn,...mn],Ce=[s.ElementType.TEXT,s.ElementType.HYPERLINK,s.ElementType.SUBSCRIPT,s.ElementType.SUPERSCRIPT,s.ElementType.CONTROL,s.ElementType.DATE],Ta=[s.ElementType.IMAGE,s.ElementType.LATEX],fa=[s.ElementType.BLOCK,s.ElementType.PAGE_BREAK,s.ElementType.SEPARATOR,s.ElementType.TABLE],ma=["HR","TABLE","UL","OL"],pa=[s.ElementType.TITLE,s.ElementType.LIST];class Xn{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||Xn.sandbox),n.setAttribute("allow",[e?.allow||Xn.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 Ns{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(`${j}-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}">
@@ -103,7 +103,7 @@ ${R||`${g+1}.`}${i(h)}${T?`
103
103
  `)}}return r}return i(n)}function Ii(o){return ei(o,["metrics","style"])}function Vn(o){return!!o?.type&&(fa.includes(o.type)||o.imgDisplay===s.ImageDisplay.INLINE)}function uc(o,t){const e=document.createElement(t);for(let n=0;n<o.attributes.length;n++){const i=o.attributes[n];e.setAttribute(i.name,i.value)}return e.innerHTML=o.innerHTML,e}function Ci(o){const t=[];for(let e=0;e<o.length;e++){const n=o[e];n?.imgDisplay===s.ImageDisplay.SURROUND&&t.push(n)}return t}function Rc(o,t){for(let e=o.length-1;e>=0;e--)o[e].imgFloatPosition?.pageNo===t&&o.splice(e,1)}function ue(o){return o?!!(o.hide||o.control?.hide||o.area?.hide):!0}function Wn(o,t,e=s.LocationPosition.BEFORE){if(!ue(o[t]))return t;let n=t;if(e===s.LocationPosition.BEFORE)for(n=t-1;n>0;){if(!ue(o[n]))return n;n--}else for(n=t+1;n<o.length;){if(!ue(o[n]))return n;n++}return n}const _s=`${Bn}-control`;function hc(o){localStorage.setItem(Bn,JSON.stringify({text:o.text,elementList:o.elementList}))}function As(){const o=localStorage.getItem(Bn);return o?JSON.parse(o):null}function Gs(){localStorage.removeItem(Bn)}function gc(o){localStorage.setItem(_s,JSON.stringify(o))}function ks(){const o=localStorage.getItem(_s);return o?JSON.parse(o):null}function Tc(){return!!ks()?.element}async function fc(o,t,e){if(!o&&!t&&!e.length)return;const n=new Blob([o],{type:"text/plain"}),i=new Blob([t],{type:"text/html"});if(window.ClipboardItem){const l=new ClipboardItem({[n.type]:n,[i.type]:i});await window.navigator.clipboard.write([l])}else{const l=document.createElement("div");l.setAttribute("contenteditable","true"),l.innerHTML=t,document.body.append(l);const r=window.getSelection(),a=document.createRange(),c=document.createElement("span");c.innerText=`
104
104
  `,l.append(c),a.selectNodeContents(l),r?.removeAllRanges(),r?.addRange(a),document.execCommand("copy"),l.remove()}hc({text:o,elementList:e})}async function xs(o,t){const e=bn(o,t);document.body.append(e);const n=e.innerText;e.remove();const i=e.innerHTML;!n&&!i&&!o.length||await fc(n,i,Vt(o))}function mc(o){let t=!1;for(let e=0;e<o.items.length;e++)if(o.items[e].kind==="file"){t=!0;break}return t}function Li(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled()||e.getControl().getIsDisabledPasteControl())return;const n=e.getRange(),{startIndex:i}=n.getRange(),l=e.getElementList();if(~i&&!n.getIsSelectAll()){const r=l[i];if(r?.titleId||r?.listId){let a=0;for(;a<t.length;){const c=t[a];if(r.titleId&&/^\n/.test(c.value))break;if(pa.includes(c.type)){if(t.splice(a,1),c.valueList)for(let d=0;d<c.valueList.length;d++){const u=c.valueList[d];u.value===K||u.value===`
105
105
  `||(t.splice(a,0,u),a++)}a--}a++}}re(l,t,i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function Bs(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=Dn(t,{innerWidth:e.getOriginalInnerWidth()});Li(o,n)}function Pi(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=e.getRange(),{startIndex:i}=n.getRange(),l=e.getElementList(),r=new FileReader;r.readAsDataURL(t),r.onload=()=>{const a=new Image,c=r.result;a.src=c,a.onload=()=>{const d={value:c,type:s.ElementType.IMAGE,width:a.width,height:a.height};~i&&re(l,[d],i,{editorOptions:e.getOptions()}),e.insertElementList([d])}}}function pc(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=t.clipboardData;if(!n)return;const{paste:i}=e.getOverride();if(i&&i(t)?.preventDefault!==!1)return;if(!mc(n)){const r=n.getData("text"),a=As();if(a&&To(r)===To(a.text)){Li(o,a.elementList);return}}Gs();let l=!1;for(let r=0;r<n.items.length;r++)if(n.items[r].type==="text/html"){l=!0;break}for(let r=0;r<n.items.length;r++){const a=n.items[r];if(a.kind==="string"){if(a.type==="text/plain"&&!l){a.getAsString(c=>{o.input(c)});break}if(a.type==="text/html"&&l){a.getAsString(c=>{Bs(o,c)});break}}else if(a.kind==="file"&&a.type.includes("image")){const c=a.getAsFile();c&&Pi(o,c)}}}async function Ic(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const{paste:n}=e.getOverride();if(n&&n()?.preventDefault!==!1)return;const i=await navigator.clipboard.readText(),l=As();if(l&&To(i)===To(l.text)){Li(o,l.elementList);return}if(Gs(),t?.isPlainText)i&&o.input(i);else{const r=await navigator.clipboard.read();let a=!1;for(const c of r)if(c.types.includes("text/html")){a=!0;break}for(const c of r)if(c.types.includes("text/plain")&&!a){const u=await(await c.getType("text/plain")).text();u&&o.input(u)}else if(c.types.includes("text/html")&&a){const u=await(await c.getType("text/html")).text();u&&Bs(o,u)}else if(c.types.some(d=>d.startsWith("image/"))){const d=c.types.find(R=>R.startsWith("image/")),u=await c.getType(d);Pi(o,u)}}}class Cc{draw;container;agentCursorDom;canvasEvent;eventBus;constructor(t,e){this.draw=t,this.container=t.getContainer(),this.canvasEvent=e,this.eventBus=t.getEventBus();const n=document.createElement("textarea");n.autocomplete="off",n.classList.add(`${j}-inputarea`),n.innerText="",this.container.append(n),this.agentCursorDom=n,n.onkeydown=i=>this._keyDown(i),n.oninput=this._input.bind(this),n.onpaste=i=>this._paste(i),n.addEventListener("compositionstart",this._compositionstart.bind(this)),n.addEventListener("compositionupdate",this._compositionupdate.bind(this)),n.addEventListener("compositionend",this._compositionend.bind(this)),n.addEventListener("keydown",this._keydown.bind(this)),this.eventBus.on("rangeStyleChange",i=>{this.agentCursorDom.style.fontSize=Math.max(i.size,18)+"px"})}getAgentCursorDom(){return this.agentCursorDom}_keyDown(t){this.draw.isInteractionSuspended()||this.canvasEvent.keydown(t)}_input(t){if(this.draw.isInteractionSuspended())return;const e=t.data;e&&this.canvasEvent.input(e),this.eventBus.isSubscribe("input")&&this.eventBus.emit("input",t)}_paste(t){this.draw.isInteractionSuspended()||this.draw.isReadonly()||!t.clipboardData||(pc(this.canvasEvent,t),t.preventDefault())}_compositionstart(){this.draw.isInteractionSuspended()||(this.agentCursorDom.style.zIndex="1000",this.agentCursorDom.style.width="0px",this.agentCursorDom.style.color="#000",this.agentCursorDom.style.background="#fff",this.canvasEvent.compositionstart())}_compositionupdate(){if(this.draw.isInteractionSuspended())return;this.agentCursorDom.style.width="9999px";let t=this.agentCursorDom.scrollWidth;const e=this.container.clientWidth,n=Math.max(e-this.agentCursorDom.offsetLeft,100);t>n&&(t=n),this.agentCursorDom.style.width=t+"px"}_compositionend(t){this.draw.isInteractionSuspended()||(this.agentCursorDom.style.zIndex="-1",this.agentCursorDom.style.width="0px",this.agentCursorDom.style.color="",this.agentCursorDom.style.background="",this.canvasEvent.compositionend(t))}_keydown(t){this.draw.isInteractionSuspended()||this.canvasEvent.isComposing&&t.code==="Escape"&&this.canvasEvent.compositionCancel()}}class Lc{ANIMATION_CLASS=`${j}-cursor--animation`;draw;container;options;position;cursorDom;cursorAgent;blinkTimeout;hitLineStartIndex;constructor(t,e){this.draw=t,this.container=t.getContainer(),this.position=t.getPosition(),this.options=t.getOptions(),this.cursorDom=document.createElement("div"),this.cursorDom.classList.add(`${j}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new Cc(t,e),this.blinkTimeout=null}getCursorDom(){return this.cursorDom}getAgentDom(){return this.cursorAgent.getAgentCursorDom()}getAgentIsActive(){return this.getAgentDom()===document.activeElement}getAgentDomValue(){return this.getAgentDom().value}clearAgentDomValue(){this.getAgentDom().value=""}getHitLineStartIndex(){return this.hitLineStartIndex}_blinkStart(){this.cursorDom.classList.add(this.ANIMATION_CLASS)}_blinkStop(){this.cursorDom.classList.remove(this.ANIMATION_CLASS)}_setBlinkTimeout(){this._clearBlinkTimeout(),this.blinkTimeout=window.setTimeout(()=>{this._blinkStart()},500)}_clearBlinkTimeout(){this.blinkTimeout&&(this._blinkStop(),window.clearTimeout(this.blinkTimeout),this.blinkTimeout=null)}focus(){if(da&&this.draw.isReadonly())return;const t=this.cursorAgent.getAgentCursorDom();document.activeElement!==t&&(t.focus(),t.setSelectionRange(0,0))}drawCursor(t){let e=this.position.getCursorPosition();if(!e)return;const{scale:n,cursor:i}=this.options,{color:l,width:r,isShow:a=!0,isBlink:c=!0,isFocus:d=!0,hitLineStartIndex:u}={...i,...t},R=this.draw.getHeight(),h=this.draw.getPageGap();this.hitLineStartIndex=u,u&&(e=this.position.getPositionList()[u]);const{metrics:g,coordinate:{leftTop:T,rightTop:f},ascent:p,pageNo:m}=e,L=(this.draw.getZone().isMainActive()?m:this.draw.getPageNo())*(R+h),E=la*n,O=Math.min(g.height/4,E),F=g.height+O*2,V=this.cursorAgent.getAgentCursorDom();d&&setTimeout(()=>{this.focus()});const D=g.boundingBoxDescent<0?0:g.boundingBoxDescent,b=T[1]+p+D-(F-O)+L,N=u?T[0]:f[0];if(V.style.left=`${N}px`,V.style.top=`${b+F-E}px`,!a){this.recoveryCursor();return}const W=this.cursorDom.style.top,y=this.draw.isReadonly();this.cursorDom.style.width=`${r*n}px`,this.cursorDom.style.backgroundColor=l,this.cursorDom.style.left=`${N}px`,this.cursorDom.style.top=`${b}px`,this.cursorDom.style.display=y?"none":"block",this.cursorDom.style.height=`${F}px`,c?this._setBlinkTimeout():this._clearBlinkTimeout(),si(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(W)>b?$t.UP:$t.DOWN})})}recoveryCursor(){this.cursorDom.style.display="none",this._clearBlinkTimeout()}moveCursorToVisible(t){const{cursorPosition:e,direction:n}=t;if(!e||!n)return;const{pageNo:i,coordinate:{leftTop:l,leftBottom:r}}=e,a=oa(this.container),c={left:0,right:0,top:0,bottom:0},d=a===document.documentElement;if(d)c.right=window.innerWidth,c.bottom=window.innerHeight;else{const{left:f,right:p,top:m,bottom:C}=a.getBoundingClientRect();c.left=f,c.right=p,c.top=m,c.bottom=C}const u=i*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,R=n===$t.UP,h=r[0]+(d?0:c.left),g=R?l[1]+u:r[1]+u,{maskMargin:T}=this.options;if(c.top+=T[0],c.bottom-=T[2],!(h>=c.left&&h<=c.right&&g>=c.top&&g<=c.bottom)){const{scrollLeft:f,scrollTop:p}=a;R?a.scroll(f,p-(c.top-g)):a.scroll(f,p+g-c.bottom)}}}var Cn;(function(o){o[o.LEFT=0]="LEFT",o[o.CENTER=1]="CENTER",o[o.RIGHT=2]="RIGHT"})(Cn||(Cn={}));function He(o){return fn?o.metaKey:o.ctrlKey}s.KeyMap=void 0,(function(o){o.Delete="Delete",o.Backspace="Backspace",o.Enter="Enter",o.Left="ArrowLeft",o.Right="ArrowRight",o.Up="ArrowUp",o.Down="ArrowDown",o.ESC="Escape",o.TAB="Tab",o.META="Meta",o.LEFT_BRACKET="[",o.RIGHT_BRACKET="]",o.COMMA=",",o.PERIOD=".",o.LEFT_ANGLE_BRACKET="<",o.RIGHT_ANGLE_BRACKET=">",o.EQUAL="=",o.MINUS="-",o.PLUS="+",o.A="a",o.B="b",o.C="c",o.D="d",o.E="e",o.F="f",o.G="g",o.H="h",o.I="i",o.J="j",o.K="k",o.L="l",o.M="m",o.N="n",o.O="o",o.P="p",o.Q="q",o.R="r",o.S="s",o.T="t",o.U="u",o.V="v",o.W="w",o.X="x",o.Y="y",o.Z="z",o.A_UPPERCASE="A",o.B_UPPERCASE="B",o.C_UPPERCASE="C",o.D_UPPERCASE="D",o.E_UPPERCASE="E",o.F_UPPERCASE="F",o.G_UPPERCASE="G",o.H_UPPERCASE="H",o.I_UPPERCASE="I",o.J_UPPERCASE="J",o.K_UPPERCASE="K",o.L_UPPERCASE="L",o.M_UPPERCASE="M",o.N_UPPERCASE="N",o.O_UPPERCASE="O",o.P_UPPERCASE="P",o.Q_UPPERCASE="Q",o.R_UPPERCASE="R",o.S_UPPERCASE="S",o.T_UPPERCASE="T",o.U_UPPERCASE="U",o.V_UPPERCASE="V",o.W_UPPERCASE="W",o.X_UPPERCASE="X",o.Y_UPPERCASE="Y",o.Z_UPPERCASE="Z",o.ZERO="0",o.ONE="1",o.TWO="2",o.THREE="3",o.FOUR="4",o.FIVE="5",o.SIX="6",o.SEVEN="7",o.EIGHT="8",o.NINE="9"})(s.KeyMap||(s.KeyMap={}));class Eo{element;control;constructor(t,e){this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getCode(){return this.element.control?.code||null}getValue(){const t=this.control.getElementList(),{startIndex:e}=this.control.getRange(),n=t[e],i=[];let l=e;for(;l>0;){const a=t[l];if(a.controlId!==n.controlId||a.controlComponent===s.ControlComponent.PREFIX||a.controlComponent===s.ControlComponent.PRE_TEXT)break;a.controlComponent===s.ControlComponent.VALUE&&i.unshift(a),l--}let r=e+1;for(;r<t.length;){const a=t[r];if(a.controlId!==n.controlId||a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT)break;a.controlComponent===s.ControlComponent.VALUE&&i.push(a),r++}return i}setValue(){return-1}setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,l=e.elementList||this.control.getElementList(),{startIndex:r}=e.range||this.control.getRange(),a=l[r];let c=r;for(;c>0;){const u=l[c];if(u.controlId!==a.controlId||u.controlComponent===s.ControlComponent.PREFIX||u.controlComponent===s.ControlComponent.PRE_TEXT)break;if(u.controlComponent===s.ControlComponent.CHECKBOX){const R=u.checkbox;R.value=t.includes(R.code)}c--}let d=r+1;for(;d<l.length;){const u=l[d];if(u.controlId!==a.controlId||u.controlComponent===s.ControlComponent.POSTFIX||u.controlComponent===s.ControlComponent.POST_TEXT)break;if(u.controlComponent===s.ControlComponent.CHECKBOX){const R=u.checkbox;R.value=t.includes(R.code)}d++}i.code=t.join(","),this.control.repaintControl({curIndex:r,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getRange();this.control.shrinkBoundary();const{startIndex:n,endIndex:i}=e;return t.key===s.KeyMap.Backspace||t.key===s.KeyMap.Delete?this.control.removeControl(n):i}cut(){return-1}}class Ei extends Eo{setSelect(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return;const{control:i}=this.element,l=e.elementList||this.control.getElementList(),{startIndex:r}=e.range||this.control.getRange(),a=l[r];let c=r;for(;c>0;){const u=l[c];if(u.controlId!==a.controlId||u.controlComponent===s.ControlComponent.PREFIX||u.controlComponent===s.ControlComponent.PRE_TEXT)break;if(u.controlComponent===s.ControlComponent.RADIO){const R=u.radio;R.value=t.includes(R.code)}c--}let d=r+1;for(;d<l.length;){const u=l[d];if(u.controlId!==a.controlId||u.controlComponent===s.ControlComponent.POSTFIX||u.controlComponent===s.ControlComponent.POST_TEXT)break;if(u.controlComponent===s.ControlComponent.RADIO){const R=u.radio;R.value=t.includes(R.code)}d++}i.code=t.join(","),this.control.repaintControl({curIndex:r,isSetCursor:!1}),this.control.emitControlContentChange({context:e})}}function Js(o){const t=o.getDraw(),e=t.getPosition(),n=t.getRange();o.isAllowDrag=!0,o.cacheRange=ht(n.getRange()),o.cacheElementList=t.getElementList(),o.cachePositionList=e.getPositionList(),o.cachePositionContext=e.getPositionContext()}function $s(o,t){const{checkbox:e,control:n}=o;if(!n)t.getCheckboxParticle().setSelect(o);else{const i=n?.code?n.code.split(","):[];if(e?.value){const r=i.findIndex(a=>a===e.code);i.splice(r,1)}else e?.code&&i.push(e.code);const l=t.getControl().getActiveControl();l instanceof Eo&&l.setSelect(i)}}function zs(o,t){const{radio:e,control:n}=o;if(!n)t.getRadioParticle().setSelect(o);else{const i=e?.code?[e.code]:[],l=t.getControl().getActiveControl();l instanceof Ei&&l.setSelect(i)}}function Pc(o,t){const e=t.getDraw();let n=e.isReadonly();const i=e.getRange(),l=e.getPosition(),r=i.getRange();if(o.button===Cn.RIGHT&&(r.isCrossRowCol||!i.getIsCollapsed()))return;const c=o.target.dataset.index;if(c&&e.setPageNo(Number(c)),!t.isAllowDrag&&!n&&r.startIndex!==r.endIndex&&i.getIsPointInRange(o.offsetX,o.offsetY,e.getPageNo())){Js(t);return}t.isAllowSelection=!0;const d=ht(l.getPositionContext()),u=l.getPositionByXY({x:o.offsetX,y:o.offsetY}),R=l.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!R)return;const{index:h,isDirectHit:g,isCheckbox:T,isRadio:f,isControl:p,isImage:m,isLabel:C,isMacro:I,isTable:L,tdValueIndex:E,hitLineStartIndex:O}=R;t.mouseDownStartPosition={...R,index:L?E:h,originalIndex:h,x:o.offsetX,y:o.offsetY};const F=e.getElementList(),V=l.getPositionList(),D=L?E:h;let b;L?b=e.getTd().value[E]:b=F[D];const N=L&&e.getTd()?.value||F,W=L&&e.getTd()?.positionList||V,y=!!(g&&m),M=!!(g&&T),X=!!(g&&f),P=!!(g&&C),Y=!!(g&&I),S=Z=>Z&&(Z.type===s.ElementType.MACRO||Z.type===s.ElementType.CUSTOM_MACRO||Z.type===s.ElementType.REUSABLE_ITEM||Z.type===s.ElementType.SUB_TEMPLATE||Z.type===s.ElementType.MENSTRUAL_HISTORY||Z.type===s.ElementType.FETAL_HEART_POSITION||Z.type===s.ElementType.TOOTH_POSITION||Z.type===s.ElementType.LIST||Z.type===s.ElementType.SPECIAL_SYMBOLS),U=Z=>Z&&!!Z.originControlId&&!!Z.controlId,Q=Z=>!!(Z&&Z.originControlId&&Z.controlId&&(Z.controlComponent===s.ControlComponent.POSTFIX||Z.controlComponent===s.ControlComponent.POSTTEXTFIX||Z.controlComponent===s.ControlComponent.POST_TEXT||Z.controlComponent===s.ControlComponent.PLACEHOLDER)),v=Z=>!!(Z&&Z.originControlId&&Z.controlId&&(Z.controlComponent===s.ControlComponent.PREFIX||Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||Z.controlComponent===s.ControlComponent.PLACEHOLDER)),w=Z=>{if(!Z)return null;const G=new Set;let z=Z,Rt=null;for(;z&&!G.has(z);){G.add(z);let pt;for(let At=0;At<F.length;At++){const Zt=F[At];if(Zt.controlId===z&&Zt.control?.type&&(pt=Zt,Zt.controlComponent===s.ControlComponent.PREFIX||Zt.controlComponent===s.ControlComponent.PRE_TEXT||Zt.controlComponent===s.ControlComponent.PRETEXTFIX||Zt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!pt)break;pt.control?.type===s.ControlType.TEXT&&(Rt=z),z=pt.originControlId||null}return Rt},x=e.getMode()===s.EditorMode.FORM,rt=x&&b?.control?.type===s.ControlType.TEXT,A=x&&!rt?e.getControl().getActiveTextControlLimit():null;let k=D;const ot=(Z,G)=>!!Z&&!!G&&Z.controlId===G,it=(Z,G,z)=>{if(z){for(let Rt=G;Rt>=0;Rt--){const pt=Z[Rt];if(ot(pt,z)&&!pt.originControlId&&pt.control?.type)return pt.control.type;if(pt.controlId&&pt.controlId!==z&&pt.originControlId!==z)break}for(let Rt=G+1;Rt<Z.length;Rt++){const pt=Z[Rt];if(ot(pt,z)&&!pt.originControlId&&pt.control?.type)return pt.control.type;if(pt.controlId&&pt.controlId!==z&&pt.originControlId!==z)break}}},Wt=(Z,G)=>!!(x&&Z?.controlId&&!Z.originControlId&&it(N,G,Z.controlId)===s.ControlType.TEXTFIELD),Kt=(Z,G)=>!!(x&&Z?.controlId&&!Z.originControlId&&it(N,G,Z.controlId)===s.ControlType.TEXT),ne=W[D],ce=N[D-1],H=N[D+1],$=6,_=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],tt=(Z,G)=>!!(Z?.controlId&&Z.controlId===G?.controlId&&(Z.originControlId||null)===(G.originControlId||null)),ct=(Z,G)=>{if(Z?.control?.type)return Z.control.type;if(Z?.controlId){for(let z=G;z>=0;z--){const Rt=N[z];if(!tt(Z,Rt))break;if(Rt.control?.type)return Rt.control.type}for(let z=G+1;z<N.length;z++){const Rt=N[z];if(!tt(Z,Rt))break;if(Rt.control?.type)return Rt.control.type}}},nt=(Z,G)=>{const z=ct(Z,G);return!!(z&&_.includes(z))},ut=Z=>!!(Z&&(Z.controlComponent===s.ControlComponent.POSTFIX||Z.controlComponent===s.ControlComponent.POST_TEXT||Z.controlComponent===s.ControlComponent.POSTTEXTFIX||Z.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)),mt=Z=>!!(Z&&(Z.controlComponent===s.ControlComponent.PREFIX||Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)),Lt=(Z,G)=>{if(!Z?.controlId)return-1;for(let z=G;z>=0;z--){const Rt=N[z];if(!tt(Z,Rt))break;if(Rt.controlComponent===s.ControlComponent.VALUE)return z}for(let z=G+1;z<N.length;z++){const Rt=N[z];if(!tt(Z,Rt))break;if(Rt.controlComponent===s.ControlComponent.VALUE)return z}return-1},wt=(Z,G)=>{if(!Z)return!1;if(Z.controlComponent===s.ControlComponent.VALUE||Z.controlComponent===s.ControlComponent.PLACEHOLDER)return!0;const z=ct(Z,G),Rt=z===s.ControlType.SELECT||z===s.ControlType.DATE,pt=Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||Z.controlComponent===s.ControlComponent.TEXTFIXLABEL;return!!(Rt&&pt&&Z.value&&Lt(Z,G)===-1)},_t=Z=>{const G=W[Z];if(!G)return!1;const{coordinate:{leftTop:z,rightTop:Rt,leftBottom:pt}}=G;return o.offsetX>=z[0]&&o.offsetX<Rt[0]&&o.offsetY>=z[1]&&o.offsetY<=pt[1]},Ot=(Z,G)=>{if(e.getMode()!==s.EditorMode.EDIT||!Z?.originControlId||Z.controlComponent!==s.ControlComponent.VALUE||ct(Z,G)!==s.ControlType.BUTTON||Z.control?.buttonText||it(N,G,Z.originControlId)!==s.ControlType.TEXTFIELD||!_t(G))return!1;let z=-1;for(let Xe=G;Xe<N.length;Xe++){const ln=N[Xe];if(!tt(Z,ln))break;const he=W[Xe];ln.controlComponent===s.ControlComponent.VALUE&&he&&he.coordinate.rightTop[0]>he.coordinate.leftTop[0]&&(z=Xe)}if(z===-1)return!1;const Rt=W[z],{coordinate:{leftTop:pt,rightTop:At,leftBottom:Zt}}=Rt;return o.offsetX>=pt[0]-2&&o.offsetX<=At[0]&&o.offsetY>=pt[1]&&o.offsetY<=Zt[1]},Gt=(Z,G)=>!(!g||!nt(Z,G)||!_t(G)||Ot(Z,G)||!wt(Z,G)||ut(Z)||mt(Z)&&!Z?.value),Jt=()=>[u.isTable?u.tdValueIndex:u.index,D,D+1,D-1,D+2,D-2].filter((G,z,Rt)=>typeof G=="number"&&G>=0&&G<N.length&&Rt.indexOf(G)===z),Yt=()=>{if(!g)return null;for(const Z of Jt()){const G=N[Z];if(Gt(G,Z))return{element:G,index:Z}}return null},St=()=>{if(!g)return-1;for(const Z of Jt())if(Ot(N[Z],Z))return Z;return-1},Pt=Z=>{const G=N[Z];let z=Z;for(let Rt=Z+1;Rt<N.length&&tt(G,N[Rt]);Rt++)z=Rt;return z},oe=Jt().some(Z=>nt(N[Z],Z)),Et=Yt(),Ht=St(),It=Z=>(Z?.control?.type===s.ControlType.TEXTFIELD||Z?.control?.type===s.ControlType.TEXT)&&(Z.controlComponent===s.ControlComponent.POSTFIX||Z.controlComponent===s.ControlComponent.POST_TEXT||Z.controlComponent===s.ControlComponent.POSTTEXTFIX||Z.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT),Xt=Z=>Z?.type===s.ElementType.CONTROL&&(Z.controlComponent===s.ControlComponent.POSTFIX||Z.controlComponent===s.ControlComponent.POST_TEXT||Z.controlComponent===s.ControlComponent.POSTTEXTFIX||Z.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT),Ft=Z=>Z?.type===s.ElementType.CONTROL&&(Z.controlComponent===s.ControlComponent.PREFIX||Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT),pe=(Z,G)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&It(Z)&&G?.controlId===Z.originControlId&&!G.originControlId&&G.control?.type===s.ControlType.TEXTFIELD&&It(G)),Ct=(Z,G)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&It(Z)&&G?.controlId===Z.originControlId&&!G.originControlId&&G.control?.type===s.ControlType.TEXTFIELD&&G.controlComponent===s.ControlComponent.VALUE),q=(Z,G,z)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&z?.originControlId===Z.originControlId&&Z.controlId&&z.controlId&&Z.controlId!==z.controlId&&Xt(Z)&&Ft(z)&&it(N,G,Z.originControlId)===s.ControlType.TEXTFIELD),Dt=pe(b,H),at=Ct(b,H),kt=q(b,D,H),B=q(ce,D-1,b),et=!!(e.getMode()===s.EditorMode.EDIT&&p&&g&&It(b)&&!Dt&&!at&&!kt&&ce?.controlId===b.controlId&&(ce.originControlId||null)===(b.originControlId||null)&&(ce.controlComponent===s.ControlComponent.VALUE||ce.controlComponent===s.ControlComponent.PLACEHOLDER)),ft=(Z,G,z)=>!!(x&&Q(Z)&&it(N,G,Z?.originControlId)===z&&(z===s.ControlType.TEXTFIELD?Wt(N[G+1],G+1):Kt(N[G+1],G+1))),lt=(Z,G,z)=>!!(x&&v(Z)&&it(N,G,Z?.originControlId)===z&&(z===s.ControlType.TEXTFIELD?Wt(N[G-1],G-1):Kt(N[G-1],G-1))),de=ft(b,D,s.ControlType.TEXTFIELD),xt=!!(x&&ne&&Wt(b,D)&&ft(ce,D-1,s.ControlType.TEXTFIELD)&&o.offsetX<=ne.coordinate.leftTop[0]+$),zt=!!(x&&ne&&Wt(b,D)&&lt(H,D+1,s.ControlType.TEXTFIELD)&&o.offsetX>=ne.coordinate.rightTop[0]-$),xn=!!(x&&ne&&de&&o.offsetX>ne.coordinate.rightTop[0]),gn=!!(x&&ne&&v(b)&&it(N,D,b.originControlId)===s.ControlType.TEXTFIELD&&Wt(ce,D-1)&&o.offsetX<ne.coordinate.leftTop[0]),Pe=Wt(b,D)||de||xt||zt||xn||gn,We=ft(b,D,s.ControlType.TEXT),Fl=Z=>{const G=N[Z],z=V[Z];if(!z||!Kt(G,Z))return-1;const Rt=N[Z-1];return!ft(Rt,Z-1,s.ControlType.TEXT)||o.offsetX>z.coordinate.leftTop[0]+$?-1:Z-1},Ts=Fl(D),yl=Fl(D-1),bl=Ts!==-1||yl!==-1,Dl=!!(x&&ne&&v(b)&&it(N,D,b.originControlId)===s.ControlType.TEXT&&Kt(ce,D-1)&&o.offsetX<ne.coordinate.leftTop[0]),Zf=!!(x&&ne&&Kt(b,D)&&lt(H,D+1,s.ControlType.TEXT)&&o.offsetX>=ne.coordinate.rightTop[0]-$),Qf=We||bl||Dl||Zf;Dt||at||kt?k=D:B||et?k=Math.max(D-1,0):bl?k=Ts!==-1?Ts:yl:Dl&&(k=Math.max(D-1,0)),Et?(k=Et.index,l.setPositionContext({...l.getPositionContext(),index:Et.index,isControl:!0,isDirectHit:!0})):Ht!==-1?k=Pt(Ht):nt(b,D)&&ne&&!_t(D)&&o.offsetX>ne.coordinate.rightTop[0]&&(k=Pt(D));let Vl=!1;if(x&&A?.parentControlId&&b?.controlId===A.parentControlId&&!b?.originControlId)for(let Z=D;Z>=0;Z--){const G=F[Z];if(ot(G,A.parentControlId)){G.control?.type===s.ControlType.TEXTFIELD&&(Vl=!0);break}if(G.controlId!==A.parentControlId)break}const Wl=!!(A&&(!b?.controlId||b.controlId===A.controlId&&(b.originControlId||null)===A.originControlId||A.parentControlId&&b.controlId===A.parentControlId&&!b.originControlId&&Vl));if(x&&!rt&&(b?.controlId||b?.originControlId)){let Z;const G=b.originControlId||b.controlId;for(let z=D;z>=0;z--){const Rt=F[z];if(ot(Rt,G)&&Rt.control?.type){Z=Rt.control.type;break}if(Rt.controlId!==b.controlId&&Rt.controlId!==G)break}if(Z!==s.ControlType.TEXT){if(Z===s.ControlType.TEXTFIELD){const z=b.controlComponent;if(!U(b)){if(!(b.controlComponent===s.ControlComponent.VALUE&&S(b))){if(z===s.ControlComponent.PRETEXTFIX||z===s.ControlComponent.PRETEXTFIX_TEXT||z===s.ControlComponent.POSTTEXTFIX||z===s.ControlComponent.POSTTEXTFIX_TEXT||z===s.ControlComponent.TEXTFIXLABEL||z===s.ControlComponent.PREFIX||z===s.ControlComponent.POSTFIX||z===s.ControlComponent.PRE_TEXT||z===s.ControlComponent.POST_TEXT||z===s.ControlComponent.PLACEHOLDER)for(let Rt=D+1;Rt<F.length;Rt++){const pt=F[Rt];if(pt.controlId!==G&&pt.originControlId!==G)break;if(pt.controlComponent===s.ControlComponent.VALUE&&!S(pt)){k=Rt;break}if(pt.controlComponent===s.ControlComponent.POSTTEXTFIX||pt.controlComponent===s.ControlComponent.POSTFIX){for(let At=D-1;At>=0;At--){const Zt=F[At];if(Zt.controlId!==G&&Zt.originControlId!==G)break;if(Zt.controlComponent===s.ControlComponent.VALUE&&!S(Zt)){k=At;break}}break}}else if(z===s.ControlComponent.VALUE&&D>0){const Rt=F[D-1];if(Rt&&(Rt.controlId===G||Rt.originControlId===G)&&Rt.controlComponent===s.ControlComponent.VALUE&&S(Rt)){let pt=!1;for(let At=D-2;At>=0;At--){const Zt=F[At];if(Zt.controlId!==G&&Zt.originControlId!==G||Zt.controlComponent!==s.ControlComponent.VALUE&&!Zt.originControlId&&Zt.controlId===G)break;if(!S(Zt)){k=At+1,pt=!0;break}}if(!pt)for(let At=D;At<F.length;At++){const Zt=F[At];if(Zt.controlId!==G&&Zt.originControlId!==G||(Zt.controlComponent===s.ControlComponent.POSTTEXTFIX||Zt.controlComponent===s.ControlComponent.POSTFIX)&&!Zt.originControlId&&Zt.controlId===G)break;if(!S(Zt)){k=At,pt=!0;break}}}}}}}}}if(x&&b?.control?.type===s.ControlType.TEXT&&b?.originControlId&&b.controlComponent===s.ControlComponent.PLACEHOLDER&&w(b.originControlId)&&(k=D),~h&&Pe&&!Et)t.isAllowSelection=!1,e.getControl().destroyControl({isEmitEvent:!1}),e.render({isCompute:!1,isSubmitHistory:!1,isSetCursor:!1});else if(~h){Wl&&(k=Math.min(Math.max(k,A.startIndex),A.endIndex));let Z=k,G=k;if(o.shiftKey){const{startIndex:pt}=i.getRange();~pt&&l.getPositionContext().tdId===d.tdId&&(D>pt?Z=pt:G=pt)}Wl&&(Z=Math.min(Math.max(Z,A.startIndex),A.endIndex),G=Math.min(Math.max(G,A.startIndex),A.endIndex),k=Math.min(Math.max(k,A.startIndex),A.endIndex));const z=e.getControl(),Rt=!!Et;z.setPopupAwakeDisabled(o.button===Cn.RIGHT||Qf&&!Rt||oe&&!Rt);try{i.setRange(Z,G)}finally{z.setPopupAwakeDisabled(!1)}if(l.setCursorPosition(V[k]),n=e.isReadonly(),M&&!n)$s(b,e);else if(X&&!n)zs(b,e);else if(b.controlComponent===s.ControlComponent.VALUE&&(b.control?.type===s.ControlType.CHECKBOX||b.control?.type===s.ControlType.RADIO)){let pt=D;for(;pt>0;){const At=F[pt];if(At.controlComponent===s.ControlComponent.CHECKBOX){$s(At,e);break}else if(At.controlComponent===s.ControlComponent.RADIO){zs(At,e);break}pt--}}else{const pt=!!(Et&&ct(Et.element,Et.index)===s.ControlType.BUTTON&&!Et.element.control?.buttonText);let At=!1;if(x&&b?.controlId&&b?.controlComponent===s.ControlComponent.VALUE&&!b.originControlId){let ln=!1;for(let he=D;he>=0;he--){const Ye=F[he];if(Ye.controlId!==b.controlId){if(Ye.originControlId===b.controlId){ln=!0;continue}break}if(Ye.control?.type===s.ControlType.TEXTFIELD){if(ln)break;At=!0;break}}if(!ln&&!At)for(let he=D+1;he<F.length;he++){const Ye=F[he];if(Ye.controlId!==b.controlId){if(Ye.originControlId===b.controlId){ln=!0;continue}break}}ln&&(At=!1)}const Zt=At&&S(b),Kl=Y&&!Zt?k+1:void 0;e.render({curIndex:Y&&!Zt?Kl:k,isCompute:!1,isSubmitHistory:!1,isSetCursor:!y&&!M&&!X&&!(pt&&x)&&!Zt});const Xe=F[k];if(!n&&Rt&&Xe?.controlId&&o.button===Cn.LEFT){const he=e.getControl().getActiveControl(),Ye=he?.getElement()?.control?.type;he&&(Ye===s.ControlType.NUMBER||Ye===s.ControlType.SELECT||Ye===s.ControlType.DATE||Ye===s.ControlType.BUTTON)&&he.getElement()?.controlId===Xe.controlId&&Xe.controlComponent!==s.ControlComponent.POSTFIX&&Xe.controlComponent!==s.ControlComponent.POSTTEXTFIX&&Xe.controlComponent!==s.ControlComponent.POSTTEXTFIX_TEXT&&Xe.controlComponent!==s.ControlComponent.POST_TEXT&&typeof he.awake=="function"&&he.awake()}}O&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:O})}const Be=e.getEventBus();if(P&&Be.isSubscribe("labelMousedown")&&Be.emit("labelMousedown",{evt:o,element:b}),Y&&(b.type===s.ElementType.MACRO||b.type===s.ElementType.CUSTOM_MACRO||b.type===s.ElementType.REUSABLE_ITEM)){const Z=e.getMode();if(Z===s.EditorMode.EDIT&&b.type===s.ElementType.CUSTOM_MACRO)Be.isSubscribe("macroClick")&&Be.emit("macroClick",{evt:o,element:b});else if(Z===s.EditorMode.FORM){let G=!1;b.type===s.ElementType.CUSTOM_MACRO&&o.button===Cn.LEFT&&!n&&(G=e.getMacroParticle().activateInlineEditor(b,D)),!G&&Be.isSubscribe("macroValueChange")&&Be.emit("macroValueChange",{evt:o,element:b})}}o.button===Cn.LEFT&&Y&&b.type===s.ElementType.SUB_TEMPLATE&&e.getMode()===s.EditorMode.FORM&&Be.isSubscribe("subTemplateClick")&&Be.emit("subTemplateClick",{evt:o,element:b});const Yl=e.getPreviewer();if(Yl.clearResizer(),y){const Z={dragDisable:n||!b.controlId&&e.getMode()===s.EditorMode.FORM};b.type===s.ElementType.LATEX&&(Z.mime="svg",Z.srcKey="laTexSVG"),Yl.drawResizer(b,V[D],Z),e.getCursor().drawCursor({isShow:!1}),Js(t),(b.imgDisplay===s.ImageDisplay.SURROUND||b.imgDisplay===s.ImageDisplay.FLOAT_TOP||b.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(b),Be.isSubscribe("imageMousedown")&&Be.emit("imageMousedown",{evt:o,element:b})}const Ul=e.getTableTool();Ul.dispose(),L&&!n&&e.getMode()!==s.EditorMode.FORM&&Ul.render();const fs=e.getHyperlinkParticle();fs.clearHyperlinkPopup(),b.type===s.ElementType.HYPERLINK&&(He(o)?fs.openHyperlink(b):fs.drawHyperlinkPopup(b,V[D]));const wl=e.getDateParticle();wl.clearDatePicker(),b.type===s.ElementType.DATE&&!n&&wl.renderDatePicker(b,V[D]);const Zl=e.getMenstrualHistoryParticle();Zl.clearMenstrualHistoryEditor(),b.type===s.ElementType.MENSTRUAL_HISTORY&&g&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&Zl.renderMenstrualHistoryEditor(b,V[D]);const Ql=e.getFetalHeartPositionParticle();Ql.clearFetalHeartPositionEditor(),b.type===s.ElementType.FETAL_HEART_POSITION&&g&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&Ql.renderFetalHeartPositionEditor(b,V[D]);const vl=e.getToothPositionParticle();vl.clearToothPositionEditor(),b.type===s.ElementType.TOOTH_POSITION&&g&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&vl.renderToothPositionEditor(b,V[D])}function Mo(o){const t=Tt();return Reflect.set(o,"dragId",t),t}function Oo(o,t){return t.findIndex(e=>e.dragId===o)}function js(o,t,e){const n=e.getDraw();if(o.imgDisplay===s.ImageDisplay.SURROUND||o.imgDisplay===s.ImageDisplay.FLOAT_TOP||o.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM){const i=t.offsetX-e.mouseDownStartPosition.x,l=t.offsetY-e.mouseDownStartPosition.y,r=o.imgFloatPosition;o.imgFloatPosition={x:r.x+i,y:r.y+l,pageNo:n.getPageNo()}}n.getImageParticle().destroyFloatImage()}function Ec(o,t){if(t.isAllowDrop){const e=t.getDraw();if(e.isReadonly()||e.isDisabled()){t.mousedown(o);return}const n=e.getPosition(),i=n.getPositionList(),l=n.getPositionContext(),r=e.getRange(),a=t.cacheRange,c=t.cacheElementList,d=t.cachePositionList,u=t.cachePositionContext,R=r.getRange(),h=a.startIndex===a.endIndex,g=h?a.startIndex-1:a.startIndex,T=a.endIndex;if(R.startIndex>=g&&R.endIndex<=T&&t.cachePositionContext?.tdId===l.tdId){e.clearSideEffect();let A=!1,k=!1;if(h){const ot=c[T];if(ot.type===s.ElementType.IMAGE||ot.type===s.ElementType.LATEX){if(js(ot,o,t),ot.imgDisplay===s.ImageDisplay.SURROUND||ot.imgDisplay===s.ImageDisplay.FLOAT_TOP||ot.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(ot),A=!0;else{const it=d[T];e.getPreviewer().drawResizer(ot,it)}k=ot.imgDisplay===s.ImageDisplay.SURROUND}}r.replaceRange({...a}),e.render({isCompute:k,isSubmitHistory:A,isSetCursor:!1});return}const f=c.slice(g+1,T+1),p=f.find(A=>A.controlId);if(p){const A=c[g+1],k=c[T];if(!((!A.controlId||A.controlComponent===s.ControlComponent.PREFIX)&&(!k.controlId||k.controlComponent===s.ControlComponent.POSTFIX)||A.controlId===k.controlId&&A.controlComponent===s.ControlComponent.PREFIX&&k.controlComponent===s.ControlComponent.POSTFIX||A.control?.type===s.ControlType.TEXT&&A.controlComponent===s.ControlComponent.VALUE&&k.control?.type===s.ControlType.TEXT&&k.controlComponent===s.ControlComponent.VALUE)){e.render({curIndex:R.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const m=e.getControl(),C=e.getElementList(),I=!p||!!C[R.startIndex].controlId||!m.getIsElementListContainFullControl(f),L=e.getOptions(),E=f.map(A=>{if(!A.type||A.type===s.ElementType.TEXT){const k={value:A.value},ot=Ne;return I||ot.push(...ci),ot.forEach(it=>{const Wt=A[it];Wt!==void 0&&(k[it]=Wt)}),k}else{let k=ht(A);return I&&(k=Ie(k,ci)),jt([k],{isHandleFirstElement:!1,editorOptions:L}),k}});re(C,E,R.startIndex,{editorOptions:e.getOptions()});const O=c[g],F=d[g],V=Mo(c[g]),D=Mo(c[T]),b=E.length;let N=R.startIndex,W=N+b;const y=m.getActiveControl();if(y&&c[N].controlComponent!==s.ControlComponent.POSTFIX?(W=y.setValue(E),N=W-b):e.spliceElementList(C,N+1,0,E),!~W){e.render({isSetCursor:!1});return}const M=Mo(C[N]),X=Mo(C[W]),P=Oo(V,c),Y=Oo(D,c),S=c[Y];if(S.controlId&&S.controlComponent!==s.ControlComponent.POSTFIX)r.replaceRange({...a,startIndex:P,endIndex:Y}),m.getActiveControl()?.cut();else{let A=!0;if(u?.isTable){const{tableId:k,trIndex:ot,tdIndex:it}=u;A=!e.getOriginalElementList().some(Kt=>Kt.id===k&&Kt?.trList?.[ot]?.tdList?.[it]?.deletable===!1)}A&&e.spliceElementList(c,P+1,Y-P)}const U=C[R.startIndex],Q=i[R.startIndex];let v=l.index;v&&(U.tableId&&!O.tableId?F.index<v&&(v-=b):!U.tableId&&O.tableId&&Q.index<v&&(v+=b),n.setPositionContext({...l,index:v}));const w=Oo(M,C),x=Oo(X,C);r.setRange(h?x:w,x,R.tableId,R.startTdIndex,R.endTdIndex,R.startTrIndex,R.endTrIndex),e.clearSideEffect();let rt=null;if(h){const k=e.getElementList()[x];(k.type===s.ElementType.IMAGE||k.type===s.ElementType.LATEX)&&(js(k,o,t),rt=k)}if(e.render({isSetCursor:!1}),y?m.emitControlContentChange():O.controlId&&m.emitControlContentChange({context:{range:a,elementList:c},controlElement:O}),rt)if(rt.imgDisplay===s.ImageDisplay.SURROUND||rt.imgDisplay===s.ImageDisplay.FLOAT_TOP||rt.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(rt);else{const k=n.getPositionList()[x];e.getPreviewer().drawResizer(rt,k)}}else t.isAllowDrag&&t.cacheRange?.startIndex!==t.cacheRange?.endIndex&&t.mousedown(o)}function Mc(o,t){const e=t.getDraw();if(!e.getOptions().pageOuterSelectionDisable)return;const n=e.getPageContainer(),{x:i,y:l,width:r,height:a}=n.getBoundingClientRect();o.x>=i&&o.x<=i+r&&o.y>=l&&o.y<=l+a||t.setIsAllowSelection(!1)}function Oc(o,t){const e=t.getDraw(),n=e.getControl(),i=e.getPageList(),l=e.getPageNo(),r=i[l],a=e.getPosition(),c=a.getPositionByXY({x:o.offsetX,y:o.offsetY});if(~c.index){const X=c.isTable?e.getTdByPosition({...c,isTable:!0,index:c.index}):null,P=c.isTable&&X?.value||e.getElementList(),Y=c.isTable&&X?.positionList||a.getPositionList(),S=c.isTable?c.tdValueIndex:c.index,U=e.getMode(),Q=U===s.EditorMode.EDIT||U===s.EditorMode.FORM,v=[S,S+1,S-1,S+2,S-2].filter((A,k,ot)=>A>=0&&A<P.length&&ot.indexOf(A)===k),w=A=>{const k=Y[A];if(!k)return!1;const{coordinate:{leftTop:ot,rightTop:it,leftBottom:Wt}}=k;return it[0]>ot[0]&&o.offsetX>=ot[0]&&o.offsetX<it[0]&&o.offsetY>=ot[1]&&o.offsetY<=Wt[1]},x=Q&&v.some(A=>{const ot=P[A]?.control?.type;return ot!==s.ControlType.NUMBER&&ot!==s.ControlType.SELECT&&ot!==s.ControlType.DATE?!1:w(A)}),rt=v.some(A=>{const k=P[A];return!!(k?.control?.type===s.ControlType.BUTTON&&!k.control.buttonText&&(k.controlComponent===s.ControlComponent.VALUE||k.controlComponent===s.ControlComponent.PLACEHOLDER)&&w(A))});r&&(x||rt)?r.style.cursor="pointer":r&&(r.style.cursor="text")}else r&&(r.style.cursor="text");if(t.isAllowDrag){const X=o.offsetX,P=o.offsetY,{startIndex:Y,endIndex:S}=t.cacheRange,U=t.cachePositionList;for(let v=Y+1;v<=S;v++){const{coordinate:{leftTop:w,rightBottom:x}}=U[v];if(X>=w[0]&&X<=x[0]&&P>=w[1]&&P<=x[1])return}const Q=t.cacheRange?.startIndex;if(Q){const v=t.cacheElementList[Q];v?.type===s.ElementType.IMAGE&&(v.imgDisplay===s.ImageDisplay.SURROUND||v.imgDisplay===s.ImageDisplay.FLOAT_TOP||v.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)&&(e.getPreviewer().clearResizer(),e.getImageParticle().dragFloatImage(o.movementX,o.movementY))}t.dragover(o),t.isAllowDrop=!0;return}if(!t.isAllowSelection||!t.mouseDownStartPosition)return;const u=o.target.dataset.index;u&&e.setPageNo(Number(u));const R=e.getPosition(),h=R.getPositionByXY({x:o.offsetX,y:o.offsetY});if(!~h.index)return;const{index:g,isTable:T,tdValueIndex:f,tdIndex:p,trIndex:m,tableId:C,trId:I,tdId:L}=h;let E=T?f:g;if(h.isControl&&e.getMode()!==s.EditorMode.READONLY){const{newIndex:X}=n.moveCursor({index:g,isTable:T,trIndex:m,tdIndex:p,tdValueIndex:f});E=X}const{index:O,isTable:F,tdIndex:V,tdId:D,trIndex:b,tableId:N}=t.mouseDownStartPosition,W=E,y=e.getRange();let M;if(L!==D&&L&&D){const X=e.getTdByPosition({...t.mouseDownStartPosition,isTable:!!t.mouseDownStartPosition.tableId,index:t.mouseDownStartPosition.originalIndex??t.mouseDownStartPosition.index}),P=e.getTdByPosition({...h,isTable:!!h.tableId,index:h.index});if(e.isSplitTd(X,P)){const Y=(X.valueStartIndex??0)+O,S=(P.valueStartIndex??0)+f;M=[{index:Y,element:X.value[O],originalId:X.originalId,isCurrent:!1,length:X.value.length,startIndex:X.valueStartIndex??0},{index:S,element:P.value[f],originalId:P.originalId,isCurrent:!0,length:P.value.length,startIndex:P.valueStartIndex??0}]}}if(T&&F&&L!==D&&!M)y.setRange(W,W,C,V,p,b,m),R.setPositionContext({isTable:!!T,index:g,trIndex:m,tdIndex:p,tdId:L,trId:I,tableId:C});else{let X=~W?W:0;if((F||T)&&N!==C&&!M)return;R.setPositionContext({isTable:!!T,index:g,trIndex:m,tdIndex:p,tdId:L,trId:I,tableId:C});let P=O,Y,S;if(M)[{element:Y},{element:S}]=M;else{const v=e.getElementList();Y=v[P+1],S=v[X]}if(P===X||Y?.controlComponent===s.ControlComponent.PLACEHOLDER&&S?.controlComponent===s.ControlComponent.PLACEHOLDER&&Y.controlId===S.controlId)return;if(P>X&&([P,X]=[X,P]),e.getMode()===s.EditorMode.FORM){const w=n.getActiveControl()?.getElement()?.control?.type===s.ControlType.TEXT?null:n.getActiveTextControlLimit();w&&(P=Math.min(Math.max(P,w.startIndex),w.endIndex),X=Math.min(Math.max(X,w.startIndex),w.endIndex));const x=e.getElementList(),rt=x[P],A=x[X];if(rt?.control?.type===s.ControlType.TEXTFIELD||A?.control?.type===s.ControlType.TEXTFIELD){const k=rt?.controlId||A?.controlId;if(k){let ot=-1,it=-1;for(let Wt=P;Wt>=0;Wt--){const Kt=x[Wt];if(Kt.controlId!==k)break;if(Kt.controlComponent===s.ControlComponent.PRETEXTFIX||Kt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||Kt.controlComponent===s.ControlComponent.TEXTFIXLABEL||Kt.controlComponent===s.ControlComponent.PREFIX||Kt.controlComponent===s.ControlComponent.PRE_TEXT){ot=Wt+1;break}}for(let Wt=X;Wt<x.length;Wt++){const Kt=x[Wt];if(Kt.controlId!==k)break;if(Kt.controlComponent===s.ControlComponent.POSTTEXTFIX||Kt.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||Kt.controlComponent===s.ControlComponent.POSTFIX||Kt.controlComponent===s.ControlComponent.POST_TEXT){it=Wt-1;break}}ot!==-1&&P<ot&&(P=ot),it!==-1&&X>it&&(X=it)}}}let Q;if(M){const[v,w]=M.sort((x,rt)=>x.index-rt.index);Q={originalId:M[0].originalId??M[1].originalId,startIndex:v.index,endIndex:w.index},v.isCurrent?(P=v.index,X=v.length-1):(P=0,X=Q.endIndex-w.startIndex)}y.setRange(P,X,void 0,void 0,void 0,void 0,void 0,Q)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function So(o,t){if(!t)return null;const e=new Set;let n=t,i=null;for(;n&&!e.has(n);){e.add(n);let l=null;for(let r=0;r<o.length;r++){const a=o[r];if(a.controlId===n&&a.control?.type&&(l=a,a.controlComponent===s.ControlComponent.PREFIX||a.controlComponent===s.ControlComponent.PRE_TEXT||a.controlComponent===s.ControlComponent.PRETEXTFIX||a.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!l)break;l.control?.type==="text"&&(i=n),n=l.originControlId||null}return i}function Mi(o,t){return!!o&&!!t&&o.controlId===t}function Sc(o,t){const e=o[t];if(!e?.subTemplateParentId)return null;const n=e.subTemplateParentId;for(let i=t-1;i>=0;i--){const l=o[i];if(l.type===s.ElementType.SUB_TEMPLATE&&l.id===n)return{labelIndex:i,labelElement:l};if(l.type===s.ElementType.SUB_TEMPLATE&&l.id!==n)break}return null}function qs(o,t,e){const n=o[t];n.subTemplateExpanded=!1,n.hide=!1;let i=t+1;for(;i<o.length&&o[i].subTemplateParentId===n.id;)i++;const l=i-t-1;return l>0&&e.spliceElementList(o,t+1,l),t}function Xc(o){const t=o.getDraw(),e=t.getRange(),n=e.getRange(),i=t.getElementList(),l=i[n.startIndex];if(!ue(l))return;let r=n.startIndex;for(;r>0;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE&&a.subTemplateExpanded){const u=qs(i,r,t);n.startIndex=u,n.endIndex=u,e.replaceRange(n);const R=t.getPosition(),h=R.getPositionList();R.setCursorPosition(h[u]);return}let c=null;a.controlId?(c=t.getControl().removeControl(r),c!==null&&(r=c)):(t.spliceElementList(i,r,1),c=r-1,r--);const d=i[c];if(!d||!ue(d)){if(c){n.startIndex=c,n.endIndex=c,e.replaceRange(n);const u=t.getPosition(),R=u.getPositionList();u.setCursorPosition(R[c])}break}}}function Nc(o,t,e){if(e.originControlId){const n=So(o,e.originControlId);if(!n)return{isInParent:!1};for(let i=t;i<o.length;i++){const l=o[i];if(l.controlId===n)return l.controlComponent===s.ControlComponent.POSTFIX||l.controlComponent===s.ControlComponent.POSTTEXTFIX||l.controlComponent===s.ControlComponent.POST_TEXT?{isInParent:!1}:{isInParent:!0,parentControlId:n};if(l.controlId&&l.controlId!==n&&l.originControlId!==n)break}}if(!e.originControlId&&e.controlId){const n=o[t];if(n?.controlId&&n.controlId!==e.controlId&&(n.controlComponent===s.ControlComponent.PREFIX||n.controlComponent===s.ControlComponent.PRETEXTFIX))for(let i=t-1;i>=0;i--){const l=o[i];if(l.controlId===e.controlId&&(l.controlComponent===s.ControlComponent.PREFIX||l.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let r=i-1;r>=0;r--){const a=o[r],c=So(o,a.controlId);if(c&&c!==e.controlId&&(a.controlComponent===s.ControlComponent.PRETEXTFIX||a.controlComponent===s.ControlComponent.PREFIX))return{isInParent:!0,parentControlId:c};if(a.controlId&&a.controlId!==e.controlId&&(a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POSTTEXTFIX))return{isInParent:!1}}break}}if(n?.controlId&&n.controlId!==e.controlId&&!n.originControlId&&(n.controlComponent===s.ControlComponent.POSTFIX||n.controlComponent===s.ControlComponent.POSTTEXTFIX)){if(e.originControlId===n.controlId){const i=So(o,n.controlId);if(i)return{isInParent:!0,parentControlId:i}}return{isInParent:!1}}}return{isInParent:!1}}function Fc(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&Xc(t);const i=e.getControl(),{startIndex:l,endIndex:r,isCrossRowCol:a}=n.getRange();let c;const d=e.getElementList();if(n.getIsCollapsed()&&l>0){const R=d[l-1],h=d[l],g=h?.control?.type===s.ControlType.TEXT&&h.controlComponent===s.ControlComponent.PLACEHOLDER&&!i.getIsExistValueByElementListIndex(d,l);if(R?.subTemplateParentId){const y=Sc(d,l-1);if(y){const M=qs(d,y.labelIndex,e);e.getGlobalEvent().setCanvasEventAbility(),n.setRange(M,M),e.render({curIndex:M});return}}const f=e.getPosition().getPositionList(),p=f[l],m=f[l-1],C=p&&m&&p.rowIndex===m.rowIndex,I=R?.controlComponent===s.ControlComponent.PREFIX||R?.controlComponent===s.ControlComponent.PRETEXTFIX||R?.controlComponent===s.ControlComponent.PRE_TEXT||R?.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT,L=R?.controlComponent===s.ControlComponent.POSTFIX||R?.controlComponent===s.ControlComponent.POSTTEXTFIX||R?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||R?.controlComponent===s.ControlComponent.POST_TEXT,E=!!R?.controlId,O=h?.controlComponent===s.ControlComponent.PLACEHOLDER,F=h?.controlComponent===s.ControlComponent.POSTFIX||h?.controlComponent===s.ControlComponent.POSTTEXTFIX||h?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||h?.controlComponent===s.ControlComponent.POST_TEXT,V=h?.control?.type===s.ControlType.TEXT&&(h.controlComponent===s.ControlComponent.PREFIX||h.controlComponent===s.ControlComponent.PRE_TEXT),D=F&&R?.controlId===h?.controlId&&R?.originControlId===h?.originControlId&&R?.controlComponent===s.ControlComponent.VALUE,b=!!h&&!h.controlId&&!h.control;if(O&&I&&E&&C)return;const{isInParent:N,parentControlId:W}=Nc(d,l,R);if(L&&E&&C&&N&&!(h?.controlId===W&&!h?.originControlId&&(h?.controlComponent===s.ControlComponent.VALUE||h?.controlComponent===s.ControlComponent.PLACEHOLDER))){if(R.originControlId&&W)for(let M=l;M<d.length;M++){const X=d[M];if(Mi(X,W)){if(X.controlComponent===s.ControlComponent.VALUE){n.setRange(M,M),e.render({curIndex:M,isSubmitHistory:!1});return}if(X.controlComponent===s.ControlComponent.POSTFIX||X.controlComponent===s.ControlComponent.POSTTEXTFIX||X.controlComponent===s.ControlComponent.POST_TEXT)return}X.controlId!==W&&X.originControlId}return}if(L&&E&&C&&!N&&!(b&&!O&&!F)){if(V)return;if(g)return;{const y=l-1;c=i.removeControl(y),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(y,y),e.render({curIndex:y,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}}if(F&&h?.originControlId&&N&&W&&C){for(let y=l+1;y<d.length;y++){const M=d[y];if(Mi(M,W)){if(M.controlComponent===s.ControlComponent.VALUE||M.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(y,y),e.render({curIndex:y,isSubmitHistory:!1});return}break}if(M.controlId&&M.controlId!==W&&M.originControlId!==W)break}for(let y=l-1;y>=0;y--){const M=d[y];if(Mi(M,W)){if(M.controlComponent===s.ControlComponent.VALUE||M.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(y,y),e.render({curIndex:y,isSubmitHistory:!1});return}break}if(M.controlId&&M.controlId!==W&&M.originControlId!==W)break}return}if(e.getMode()===s.EditorMode.FORM&&F&&h?.originControlId&&C){const y=So(d,h.originControlId);if(!y)return;for(let M=l-1;M>=0;M--){const X=d[M];if(X.controlId===y&&!X.originControlId){if(X.controlComponent===s.ControlComponent.VALUE||X.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(M,M),e.render({curIndex:M,isSubmitHistory:!1});return}if(X.controlComponent===s.ControlComponent.PREFIX||X.controlComponent===s.ControlComponent.PRE_TEXT||X.controlComponent===s.ControlComponent.PRETEXTFIX||X.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)return}if(X.controlId&&X.controlId!==y&&X.originControlId!==y)break}return}if(F&&h?.controlId&&C&&!D){const y=l;c=i.removeControl(y),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(y,y),e.render({curIndex:y,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}}if(a){const R=e.getTableParticle().getRangeRowCol();if(!R)return;let h=!1;for(let g=0;g<R.length;g++){const T=R[g];for(let f=0;f<T.length;f++){const p=T[f];p.value.length>1&&(e.spliceElementList(p.value,1,p.value.length-1),h=!0)}}c=h?0:null}else if(i.getActiveControl()&&i.getIsRangeCanCaptureEvent())c=i.keydown(o),c!==null&&i.emitControlContentChange();else{const R=e.getPosition().getCursorPosition();if(!R)return;const{index:h}=R,g=n.getIsCollapsed(),T=e.getElementList();if(g&&h===0){const C=T[h];if(C.value===K){C.listId&&e.getListParticle().unsetList(),o.preventDefault();return}}const f=T[l];if(g&&f.rowFlex&&f.value===K){const C=n.getRangeRowElementList();if(C){const I=T[l-1];C.forEach(L=>{L.rowFlex=I?.rowFlex})}}const p=f.value===K?T[l-1]:f,m=T[r+1];if(p?.titleId&&m?.titleId&&p.level===m.level&&p.titleId!==m.titleId){const C=p.titleId,I=m.titleId;let L=r+1;for(;L<T.length&&T[L]?.titleId===I;)T[L].titleId=C,L++}g?e.spliceElementList(T,h,1):e.spliceElementList(T,l+1,r-l),c=g?h-1:l}e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(l,l),e.render({curIndex:l,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}))}function tr(o,t,e){const n=o[t];n.subTemplateExpanded=!1,n.hide=!1;let i=t+1;for(;i<o.length&&o[i].subTemplateParentId===n.id;)i++;const l=i-t-1;return l>0&&e.spliceElementList(o,t+1,l),t}function yc(o){const t=o.getDraw(),n=t.getRange().getRange(),i=t.getElementList(),l=i[n.startIndex+1];if(!ue(l))return;const r=n.startIndex+1;for(;r<i.length;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE&&a.subTemplateExpanded){tr(i,r,t);return}let c=null;a.controlId?c=t.getControl().removeControl(r):(t.spliceElementList(i,r,1),c=r);const d=i[c];if(!d||!ue(d))break}}function bc(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:l,isCrossRowCol:r,splitTdRange:a}=n.getRange(),c=e.getElementList(),d=e.getControl();n.getIsCollapsed()&&yc(t);let u;if(r){const R=e.getTableParticle().getRangeRowCol();if(!R)return;let h=!1;for(let g=0;g<R.length;g++){const T=R[g];for(let f=0;f<T.length;f++){const p=T[f];p.value.length>1&&(e.spliceElementList(p.value,1,p.value.length-1),h=!0)}}u=h?0:null}else if(d.getActiveControl()&&d.getIsRangeWithinControl())u=d.keydown(o),u!==null&&d.emitControlContentChange();else if(c[l+1]?.controlId)u=d.removeControl(l+1);else if(n.getIsCollapsed()&&c[l+1]?.subTemplateParentId){const R=c[l+1].subTemplateParentId;let h=-1;for(let g=l;g>=0;g--){const T=c[g];if(T.type===s.ElementType.SUB_TEMPLATE&&T.id===R){h=g;break}}h!==-1?u=tr(c,h,e):u=null}else{e.removeSplitTdOtherRangeElements();const R=e.getPosition(),h=R.getCursorPosition();if(!h)return;const{index:g}=h,T=R.getPositionContext();if(T.isDirectHit&&T.isImage)e.spliceElementList(c,g,1),u=g-1;else{const f=n.getIsCollapsed();if(!f)e.spliceElementList(c,i+1,l-i);else if(c[g+1])e.spliceElementList(c,g+1,1);else{let p=!0;if(T.isTable){const m=e.getTd();if(m?.linkTdNextId){const C=e.getTdById(m.linkTdNextId);C&&(p=!1,e.spliceElementList(C.value,1,1))}}if(p)return}u=f?g:i,u===0&&a&&(u=e.fixPosition(!0)??u)}}e.getGlobalEvent().setCanvasEventAbility(),u===null?(n.setRange(i,i),e.render({curIndex:i,isSubmitHistory:!1})):(n.setRange(u,u),e.render({curIndex:u}))}function Dc(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;const{startIndex:i,endIndex:l}=n.getRange(),r=n.getIsCollapsed(),a=e.getElementList(),c=a[i],d=a[l];if(r&&d.listId&&d.value===K&&a[l+1]?.listId!==d.listId){e.getListParticle().unsetList();return}let u={value:K};if(o.shiftKey&&c.listId&&(u.listWrap=!0),re(a,[u],i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),o.shiftKey&&d.areaId&&d.areaId!==a[l+1]?.areaId&&(u=Ie(u,mn)),!(a[i+1]?.titleId&&(!c.titleId||c.titleId!==a[i+1]?.titleId))&&!(d.titleId&&d.titleId!==a[l+1]?.titleId)){const p=n.getRangeAnchorStyle(a,l);if(p){const m=[...Te],C=p.controlComponent===s.ControlComponent.POSTFIX||p.controlComponent===s.ControlComponent.POSTTEXTFIX||p.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||p.controlComponent===s.ControlComponent.POST_TEXT,I=p.control?.type===s.ControlType.BUTTON&&!p.control?.buttonText;!C&&!I&&m.push(...Ne),m.forEach(L=>{const E=p[L];E!==void 0&&(u[L]=E)})}}const R=e.getControl(),h=R.getActiveControl();let g;const T=h?.getElement();if(T?.control?.type===s.ControlType.BUTTON&&!T.control?.buttonText&&T?.controlId){const p=T.controlId;let m=l;for(;m+1<a.length&&a[m+1]?.controlId===p;)m++;e.spliceElementList(a,m+1,0,[u]),g=m+1}else if(h&&R.getIsRangeWithinControl())g=R.setValue([u]),R.emitControlContentChange();else{const m=e.getPosition().getCursorPosition();if(!m)return;const{index:C}=m;if(r){if(e.spliceElementList(a,C+1,0,[u]),d.titleId&&a[C+2]?.titleId===d.titleId){const I=Tt();let L=C+2;for(;L<a.length&&a[L]?.titleId===d.titleId;)a[L].titleId=I,L++}}else e.spliceElementList(a,i+1,l-i,[u]);g=C+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),o.preventDefault()}function er(o){return o&&(o.type===s.ElementType.MACRO||o.type===s.ElementType.CUSTOM_MACRO||o.type===s.ElementType.REUSABLE_ITEM||o.type===s.ElementType.SUB_TEMPLATE||o.type===s.ElementType.MENSTRUAL_HISTORY||o.type===s.ElementType.FETAL_HEART_POSITION||o.type===s.ElementType.TOOTH_POSITION||o.type===s.ElementType.LIST||o.type===s.ElementType.SPECIAL_SYMBOLS)}function Vc(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),l=i.getCursorPosition();if(!l)return;const r=i.getPositionContext(),{index:a}=l;if(a<=0&&!r.isTable)return;const c=e.getRange(),{startIndex:d,endIndex:u}=c.getRange(),R=c.getIsCollapsed(),h=e.getElementList(),g=e.getControl(),T=e.getMode()===s.EditorMode.FORM,f=g.getActiveControl()?.getElement()?.control?.type,p=T&&f===s.ControlType.TEXT,m=T&&!p?g.getActiveTextControlLimit():null,C=h[a],I=C?.controlComponent===s.ControlComponent.PREFIX||C?.controlComponent===s.ControlComponent.PRETEXTFIX||C?.controlComponent===s.ControlComponent.PRE_TEXT;let L=!1;if(I&&C?.originControlId){const N=C.originControlId;for(let W=a-1;W>=0;W--){const y=h[W];if(y.controlId===N&&!y.originControlId){L=!0;break}if(y.controlId&&y.controlId!==N&&y.originControlId!==N)break}}if(T&&!p&&g.getActiveControl()&&I&&!m&&!L){g.initNextControl({direction:$t.UP});return}let E=1;if(He(o)){const N=e.getLetterReg(),W=o.shiftKey&&!R&&d===l?.index?u:d;if(N.test(h[W]?.value)){let y=W-1;for(;y>0;){const M=h[y];if(!N.test(M.value))break;E++,y--}}}if(T&&!p){const N=h[d],W=N?.controlId;if(W&&N?.controlComponent===s.ControlComponent.VALUE){let y=!1;for(let M=d;M>=0;M--){const X=h[M];if(X.controlId!==W)break;if(X.control?.type===s.ControlType.TEXTFIELD){y=!0;break}}if(y){if(N.controlComponent===s.ControlComponent.VALUE&&er(N))return;const M=d-E;if(M>=0){const X=h[M];if(X&&X.controlId===W&&X.controlComponent===s.ControlComponent.VALUE&&er(X))return}}}}const O=m?Math.max(d-E,m.startIndex):d-E;let F=O,V=O;if(o.shiftKey&&l&&(d!==u?d===l.index?(F=d,V=u-E):(F=O,V=u):V=u),!o.shiftKey){const N=h[d];if(N.type===s.ElementType.TABLE){const W=N.trList,y=W.length-1,M=W[y],X=M.tdList.length-1,P=M.tdList[X];i.setPositionContext({isTable:!0,index:d,trIndex:y,tdIndex:X,tdId:P.id,trId:M.id,tableId:N.id}),F=P.value.length-1,V=F}else if(N.tableId&&d===0){const y=e.getOriginalElementList()[r.index],M=e.getTd();if(M?.linkTdPrevId){const X=e.getTdById(M.linkTdPrevId);X&&(i.setPositionContext({...r,isTable:!0,index:X.tableIndex,trIndex:X.trIndex,tdId:X.id,trId:X.trId,tableId:X.tableId}),F=X.value.length-1,V=F)}else{const X=y.trList;t:for(let P=0;P<X.length;P++){const Y=X[P];if(Y.id!==N.trId)continue;const S=Y.tdList;for(let U=0;U<S.length;U++)if(S[U].id===N.tdId){if(P===0&&U===0)i.setPositionContext({isTable:!1}),F=r.index-1,V=F,e.getTableTool().dispose();else{let v=P,w=U-1;w<0&&(v=P-1,w=X[v].tdList.length-1);const x=X[v],rt=x.tdList[w];i.setPositionContext({isTable:!0,index:r.index,trIndex:v,tdIndex:w,tdId:rt.id,trId:x.id,tableId:N.tableId}),F=rt.value.length-1,V=F}break t}}}}}if(!~F||!~V)return;const D=e.getElementList();F=Wn(D,F),V=Wn(D,V),c.setRange(F,V);const b=F===V;e.updateTableTool(),e.render({curIndex:b?F:void 0,isSetCursor:b,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function nr(o){return o&&(o.type===s.ElementType.MACRO||o.type===s.ElementType.CUSTOM_MACRO||o.type===s.ElementType.REUSABLE_ITEM||o.type===s.ElementType.SUB_TEMPLATE||o.type===s.ElementType.MENSTRUAL_HISTORY||o.type===s.ElementType.FETAL_HEART_POSITION||o.type===s.ElementType.TOOTH_POSITION||o.type===s.ElementType.LIST||o.type===s.ElementType.SPECIAL_SYMBOLS)}function Wc(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),l=i.getCursorPosition();if(!l)return;const{index:r}=l,a=i.getPositionList(),c=i.getPositionContext();if(r>a.length-1&&!c.isTable)return;const d=e.getRange(),{startIndex:u,endIndex:R}=d.getRange(),h=d.getIsCollapsed();let g=e.getElementList();const T=e.getControl(),f=e.getMode()===s.EditorMode.FORM,p=T.getActiveControl()?.getElement()?.control?.type,m=f&&p===s.ControlType.TEXT,C=f&&!m?T.getActiveTextControlLimit():null,I=g[r],L=I?.controlComponent===s.ControlComponent.POSTFIX||I?.controlComponent===s.ControlComponent.POSTTEXTFIX||I?.controlComponent===s.ControlComponent.POST_TEXT;let E=!1;if(L&&I?.originControlId){const y=I.originControlId;for(let M=r+1;M<g.length;M++){const X=g[M];if(X.controlId===y&&!X.originControlId){E=!0;break}if(X.controlId&&X.controlId!==y&&X.originControlId!==y)break}}if(f&&!m&&T.getActiveControl()&&L&&!C&&!E){T.initNextControl({direction:$t.DOWN});return}let O=1;if(He(o)){const y=e.getLetterReg(),M=o.shiftKey&&!h&&u===l?.index?R:u;if(y.test(g[M+1]?.value)){let X=M+2;for(;X<g.length;){const P=g[X];if(!y.test(P.value))break;O++,X++}}}if(f&&!m){const y=g[R],M=y?.controlId;if(M&&y?.controlComponent===s.ControlComponent.VALUE){let X=!1;for(let P=R;P>=0;P--){const Y=g[P];if(Y.controlId!==M)break;if(Y.control?.type===s.ControlType.TEXTFIELD){X=!0;break}}if(X){if(y.controlComponent===s.ControlComponent.VALUE&&nr(y))return;const P=R+O;if(P<g.length){const Y=g[P];if(Y&&Y.controlId===M&&Y.controlComponent===s.ControlComponent.VALUE&&nr(Y))return}}}}const F=C?Math.min(R+O,C.endIndex):R+O;let V=F,D=F;if(o.shiftKey&&l&&(u!==R?u===l.index?(V=u,D=F):(V=u+O,D=R):V=u),!o.shiftKey){const y=g[R],M=g[R+1];if(M?.type===s.ElementType.TABLE){const P=M.trList[0],Y=P.tdList[0];i.setPositionContext({isTable:!0,index:R+1,trIndex:0,tdIndex:0,tdId:Y.id,trId:P.id,tableId:M.id}),V=0,D=0}else if(y.tableId&&!M){const X=e.getTd(),P=X?.linkTdNextId?e.getTdById(X.linkTdNextId):void 0;if(P?.value.length)i.setPositionContext({...c,isTable:!0,index:P.tableIndex,trIndex:P.trIndex,tdId:P.id,trId:P.trId,tableId:P.tableId}),V=0,D=V;else{const S=e.getOriginalElementList()[c.index].trList;t:for(let U=0;U<S.length;U++){const Q=S[U];if(Q.id!==y.trId)continue;const v=Q.tdList;for(let w=0;w<v.length;w++)if(v[w].id===y.tdId){if(U===S.length-1&&w===v.length-1)i.setPositionContext({isTable:!1}),V=c.index,D=V,g=e.getElementList(),e.getTableTool().dispose();else{let rt=U,A=w+1;A>v.length-1&&(rt=U+1,A=0);const k=S[rt],ot=k.tdList[A];i.setPositionContext({isTable:!0,index:c.index,trIndex:rt,tdIndex:A,tdId:ot.id,trId:k.id,tableId:y.tableId}),V=0,D=V}break t}}}}}const b=g.length-1;if(V>b||D>b)return;const N=e.getElementList();V=Wn(N,V,s.LocationPosition.AFTER),D=Wn(N,D,s.LocationPosition.AFTER),d.setRange(V,D);const W=V===D;e.updateTableTool(),e.render({curIndex:W?V:void 0,isSetCursor:W,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function Yc(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getMode()===s.EditorMode.FORM,l=e.getControl(),r=e.getRange(),a=e.getElementList(),{startIndex:c,endIndex:d}=r.getRange(),u=a[c],R=a[d],h=c>0?a[c-1]:null,g=l.getIsRangeWithinControl()||!!u?.controlId||!!R?.controlId||!!h?.controlId;let T=l.getActiveControl();if(i&&g&&(l.initControl(),T=l.getActiveControl()),i&&g)o.preventDefault(),l.initNextControl({direction:o.shiftKey?$t.UP:$t.DOWN});else if(T&&l.getIsRangeWithinControl())o.preventDefault(),l.initNextControl({direction:o.shiftKey?$t.UP:$t.DOWN});else{o.preventDefault();const f=r.getRangeAnchorStyle(a,d),m={...f?ie(f,Ne):null,type:s.ElementType.TAB,value:""};re(a,[m],c,{editorOptions:e.getOptions()}),e.insertElementList([m])}}function Oi(o){const{positionList:t,index:e,isUp:n,rowNo:i,cursorX:l}=o;let r=-1;const a=[];if(n){let c=e-1;for(;c>=0;){const d=t[c];if(c--,d.rowNo!==i){if(a[0]&&a[0].rowNo!==d.rowNo)break;a.unshift(d)}}}else{let c=e+1;for(;c<t.length;){const d=t[c];if(c++,d.rowNo!==i){if(a[0]&&a[0].rowNo!==d.rowNo)break;a.push(d)}}}for(let c=0;c<a.length;c++){const d=a[c],{coordinate:{leftTop:[u],rightTop:[R]}}=d;if(c===a.length-1&&(r=d.index),!(l<u||l>R)){r=d.index;break}}return r}function Uc(o,t){const e=t.getDraw();if(e.isReadonly())return;const i=e.getPosition(),l=i.getCursorPosition();if(!l)return;const r=e.getRange(),{startIndex:a,endIndex:c}=r.getRange();let d=i.getPositionList();const u=o.key===s.KeyMap.Up;let R=-1,h=-1;const g=i.getPositionContext();if(!o.shiftKey&&g.isTable&&(u&&l.rowIndex===0||!u&&l.rowIndex===e.getRowCount()-1)){const{index:f,trIndex:p,tdIndex:m,tableId:C}=g;if(u){const I=e.getOriginalElementList();if(p===0)if(I[f].originalId){const E=f-1,O=I[E];for(let F=O.trList.length-1;F>=0;F--){const V=O.trList[F].tdList.find(D=>D.tdIndex===m);if(V?.value.length){i.setPositionContext({isTable:!0,tableId:O.id,index:E,trIndex:F,tdIndex:m}),R=V.value.length-1,h=V.value.length-1;break}}}else i.setPositionContext({isTable:!1}),R=f-1,h=R,e.getTableTool().dispose();else{let L=-1,E=-1;const O=I[f].trList,F=O[p].tdList[m].colIndex;t:for(let b=p-1;b>=0;b--){const W=O[b].tdList;for(let y=0;y<W.length;y++){const M=W[y];if(M.colIndex===F||M.colIndex+M.colspan-1>=F&&M.colIndex<=F){L=b,E=y;break t}}}if(!~L||!~E)return;const V=O[L],D=V.tdList[E];i.setPositionContext({isTable:!0,index:f,trIndex:L,tdIndex:E,tdId:D.id,trId:V.id,tableId:C}),R=D.value.length-1,h=R}}else{const I=e.getOriginalElementList(),L=I[f],E=L.trList;if(p===E.length-1){const O=f+1,F=I[O];if(F&&[L.id,L.originalId].includes(F.originalId)){for(let D=m;D>=0;D--)if(F.trList[0].tdList[D].value.length){i.setPositionContext({isTable:!0,index:O,tableId:F.id,trIndex:0,tdIndex:D}),R=0,h=0;break}}else i.setPositionContext({isTable:!1}),R=f,h=R,e.getTableTool().dispose()}else{let O=-1,F=-1;const V=E[p].tdList[m].colIndex;t:for(let N=p+1;N<E.length;N++){const y=E[N].tdList;for(let M=0;M<y.length;M++){const X=y[M];if(X.colIndex===V||X.colIndex+X.colspan-1>=V&&X.colIndex<=V){O=N,F=M;break t}}}if(!~O||!~F)return;const D=E[O],b=D.tdList[F];i.setPositionContext({isTable:!0,index:f,trIndex:O,tdIndex:F,tdId:b.id,trId:D.id,tableId:C}),R=b.value.length-1,h=R}}}else{let f=l;o.shiftKey&&(a===l.index?f=d[c]:f=d[a]);const{index:p,rowNo:m,rowIndex:C,coordinate:{rightTop:[I]}}=f;if(u&&C===0||!u&&C===e.getRowCount()-1)return;const L=Oi({positionList:d,index:p,rowNo:m,isUp:u,cursorX:I});if(L<0)return;R=L,h=L,o.shiftKey&&(a!==c?a===l.index?R=a:h=c:u?h=c:R=a);const O=e.getElementList()[L];if(O.type===s.ElementType.TABLE){const{scale:F}=e.getOptions(),V=e.getMargins(),D=O.trList;let b=-1,N=-1,W=-1;if(u)t:for(let y=D.length-1;y>=0;y--){const X=D[y].tdList;for(let P=0;P<X.length;P++){const Y=X[P],S=Y.x*F+V[3],U=Y.width*F;if(I>=S&&I<=S+U){const Q=Y.positionList,v=Q[Q.length-1],w=Oi({positionList:Q,index:v.index+1,rowNo:v.rowNo-1,isUp:u,cursorX:I})||v.index;b=y,N=P,W=w;break t}}}else t:for(let y=0;y<D.length;y++){const X=D[y].tdList;for(let P=0;P<X.length;P++){const Y=X[P],S=Y.x*F+V[3],U=Y.width*F;if(I>=S&&I<=S+U){const Q=Y.positionList,v=Oi({positionList:Q,index:-1,rowNo:-1,isUp:u,cursorX:I})||0;b=y,N=P,W=v;break t}}}if(~b&&~N&&~W){const y=D[b],M=y.tdList[N];i.setPositionContext({isTable:!0,index:L,trIndex:b,tdIndex:N,tdId:M.id,trId:y.id,tableId:O.id}),R=W,h=R,d=i.getPositionList()}}}if(!~R||!~h)return;R>h&&([R,h]=[h,R]),r.setRange(R,h);const T=R===h;e.render({curIndex:T?R:void 0,isSetCursor:T,isSubmitHistory:!1,isCompute:!1}),T||(e.getCursor().moveCursorToVisible({cursorPosition:d[u?R:h],direction:u?$t.UP:$t.DOWN}),e.updateTableTool())}function wc(o){return o.key.length===1&&!o.ctrlKey&&!o.metaKey&&!o.altKey}function Zc(o,t){const e=t.getDraw();if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return!1;const n=e.getRange();if(!n.getIsCanInput())return!1;const i=e.getControl();if(!i.getActiveControl()&&i.getIsRangeWithinControl()){i.setPopupAwakeDisabled(!0);try{i.initControl()}finally{i.setPopupAwakeDisabled(!1)}}const l=i.getActiveControl();if(l?.getElement()?.control?.type!==s.ControlType.DATE||!i.getIsRangeWithinControl())return!1;const{startIndex:r,endIndex:a}=n.getRange(),c=e.getElementList(),d=c[r],u=c[a],R=l.getElement(),h=m=>!!m?.controlId&&m.controlId===R.controlId&&(m.originControlId||null)===(R.originControlId||null),g=u?.controlComponent===s.ControlComponent.POSTFIX||u?.controlComponent===s.ControlComponent.POST_TEXT||u?.controlComponent===s.ControlComponent.POSTTEXTFIX||u?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT,T=c[a+1],f=!!(u?.originControlId&&u.controlComponent===s.ControlComponent.VALUE&&h(T)&&(T.controlComponent===s.ControlComponent.POSTFIX||T.controlComponent===s.ControlComponent.POST_TEXT||T.controlComponent===s.ControlComponent.POSTTEXTFIX||T.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT));return!h(d)||!h(u)||g||f?!1:(o.preventDefault(),l.awake?.(),!0)}function Qc(o,t){if(t.isComposing)return;const e=t.getDraw();if(o.key===s.KeyMap.Backspace)Fc(o,t);else if(o.key===s.KeyMap.Delete)bc(o,t);else if(o.key===s.KeyMap.Enter)Dc(o,t);else if(o.key===s.KeyMap.Left)Vc(o,t);else if(o.key===s.KeyMap.Right)Wc(o,t);else if(o.key===s.KeyMap.Up||o.key===s.KeyMap.Down)Uc(o,t);else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return;e.getHistoryManager().undo(),o.preventDefault()}else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return;e.getHistoryManager().redo(),o.preventDefault()}else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.C)t.copy(),o.preventDefault();else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.X)t.cut(),o.preventDefault();else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.A)t.selectAll(),o.preventDefault();else if(He(o)&&o.key.toLocaleLowerCase()===s.KeyMap.S){if(e.isReadonly())return;const n=e.getListener();n.saved&&n.saved(e.getValue());const i=e.getEventBus();i.isSubscribe("saved")&&i.emit("saved",e.getValue()),o.preventDefault()}else if(o.key===s.KeyMap.ESC){t.clearPainterStyle();const n=e.getZone();n.isMainActive()||n.setZone(s.EditorZone.MAIN),o.preventDefault()}else o.key===s.KeyMap.TAB?Yc(o,t):wc(o)&&Zc(o,t)}function vc(o){return/[\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]/.test(o)}function Kc(o){return/[a-zA-Z]/.test(o)}function Hc(o,t){return vc(o)?t:Kc(o)?"Times New Roman":t}function Xo(o){return o?.type===s.ElementType.CONTROL&&(o.controlComponent===s.ControlComponent.PREFIX||o.controlComponent===s.ControlComponent.PRE_TEXT||o.controlComponent===s.ControlComponent.PRETEXTFIX||o.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)}function Fe(o){return o?.type===s.ElementType.CONTROL&&(o.controlComponent===s.ControlComponent.POSTFIX||o.controlComponent===s.ControlComponent.POST_TEXT||o.controlComponent===s.ControlComponent.POSTTEXTFIX||o.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)}function Si(o){return!!o?.originControlId&&Xo(o)}function zn(o){return!!o?.originControlId&&Fe(o)}function _c(o,t){return!o||!t?!1:!!o.originControlId&&!!t.originControlId&&o.originControlId===t.originControlId&&o.controlId!==t.controlId}function dn(o,t,e){if(!t)return null;const n=new Set;let i=t,l=null;for(;i&&!n.has(i);){n.add(i);let r;for(let a=0;a<o.length;a++){const c=o[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||e===s.EditorMode.EDIT&&r.control?.type===s.ControlType.TEXTFIELD)&&(l=i),i=r.originControlId||null}return l}function Je(o,t){return!!o&&!!t&&o.controlId===t}function or(o,t){if(t)return o.find(e=>e.controlId===t&&!e.originControlId&&!!e.control?.type)}function ir(o,t,e){if(!t?.originControlId||e?.originControlId!==t.originControlId||!t.controlId||!e.controlId||t.controlId===e.controlId||!Fe(t)||!Xo(e))return;const n=or(o,t.originControlId);if(n?.control?.type===s.ControlType.TEXTFIELD)return n}function Xi(o,t,e){Ne.forEach(n=>{delete o[n]}),Re.forEach(n=>{const i=t?.[n];i!==void 0&&(o[n]=i)}),t?.type===s.ControlType.TEXT&&o.color?.toLowerCase()==="#87d068"?o.color=e:o.color||(o.color=e)}function Ni(o,t,e,n){o.controlId=t,o.control=e,o.controlComponent=s.ControlComponent.VALUE,delete o.originControlId,Xi(o,e,n)}function Fi(o,t,e="input"){const n=se(),i=t.getDraw(),l=i.getControl(),r=i.getOptions(),a=i.getElementList(),u=i.getPosition().getCursorPosition()?.index;if(i.isReadonly()||i.isDisabled())return;const h=i.getPosition().getCursorPosition();if(!o||!h)return;const g=t.isComposing;if(g&&t.compositionInfo?.value===o)return;const T=i.getRange();if(!T.getIsCanInput())return;const f=Ct=>{l.setPopupAwakeDisabled(!0);try{return Ct()}finally{l.setPopupAwakeDisabled(!1)}},p=()=>{f(()=>l.initControl())},m=(Ct,q)=>{f(()=>{T.setRange(Ct,q)})};let C=l.getActiveControl();const I=i.getElementList()[T.getRange().endIndex],L=I?.control?.type===s.ControlType.TEXT&&!!I?.originControlId&&(I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRE_TEXT||I.controlComponent===s.ControlComponent.PRETEXTFIX||I.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||I.controlComponent===s.ControlComponent.POSTFIX||I.controlComponent===s.ControlComponent.POST_TEXT||I.controlComponent===s.ControlComponent.POSTTEXTFIX||I.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||I.controlComponent===s.ControlComponent.PLACEHOLDER);if(!C&&(l.getIsRangeWithinControl()||L)&&(p(),C=l.getActiveControl()),C){const Ct=C.getElement(),q=i.getElementList()[T.getRange().endIndex],Dt=Ct?.controlId===q?.controlId&&(Ct?.originControlId||null)===(q?.originControlId||null),at=!!q&&q.controlComponent===s.ControlComponent.VALUE&&!!q.controlId&&!q.originControlId&&T.getRange().endIndex>0&&i.getElementList()[T.getRange().endIndex-1]?.originControlId===q.controlId;(!Dt||at)&&(p(),C=l.getActiveControl())}const{endIndex:E}=T.getRange(),O=i.getElementList(),F=O[E],V=O[E+1];if(F?.type===s.ElementType.SUB_TEMPLATE&&V?.type===s.ElementType.SUB_TEMPLATE)return;const D=i.getMode()===s.EditorMode.FORM;if(D){const Ct=T.getRange();if(!(i.getElementList()[Ct.endIndex]?.control?.type===s.ControlType.TEXT)){const at=l.getActiveTextControlLimit();if(!C||!l.getIsRangeWithinControl()&&!l.getIsRangeInPostfix())return;if(at){const ft=T.getRange();if(ft.startIndex<at.startIndex||ft.endIndex>at.endIndex){const lt=Math.min(Math.max(ft.endIndex,at.startIndex),at.endIndex);f(()=>{T.setRange(lt,lt),i.render({curIndex:lt,isSubmitHistory:!1})});return}}const{endIndex:kt}=T.getRange(),B=i.getElementList(),et=B[kt];if(!et?.originControlId){if(et?.controlId&&et?.controlComponent===s.ControlComponent.VALUE){let ft=!1;for(let lt=kt;lt>=0;lt--){const de=B[lt];if(de.controlId!==et.controlId||de.originControlId)break;if(de.control?.type===s.ControlType.TEXTFIELD){ft=!0;break}}if(ft)return}}}}const b=T.getDefaultStyle()||t.compositionInfo?.defaultStyle||null,N=t.compositionInfo?.perfStartTime,W=Gc(t,i.getElementList());g||i.getCursor().clearAgentDomValue();const{TEXT:y,HYPERLINK:M,SUBSCRIPT:X,SUPERSCRIPT:P,DATE:Y,TAB:S}=s.ElementType,U=o.replaceAll(`
106
- `,K),{startIndex:Q,endIndex:v}=T.getRange(),w=T.getRangeAnchorStyle(W,Q);if(!w)return;const x=Q>0?W[Q-1]:null,rt=!!(w.controlId||w.control),k={...!rt&&x?x:w,...b},ot=i.isDesignMode(),it=W[v+1],Wt=dn(W,w.originControlId,i.getMode()),Kt=dn(W,it?.originControlId,i.getMode()),ne=!w.originControlId&&!it?.originControlId&&Fe(w)&&Xo(it)&&!!w.controlId&&!!it.controlId&&w.controlId!==it.controlId,ce=zn(w)&&Si(it)&&!Wt&&!Kt,H=i.getMode()===s.EditorMode.EDIT?ir(W,w,it):void 0,$=!!w.originControlId&&Fe(w)&&it?.controlId===w.originControlId&&!it.originControlId&&it.control?.type===s.ControlType.TEXTFIELD&&Fe(it),_=!!w.originControlId&&Fe(w)&&it?.controlId===w.originControlId&&!it.originControlId&&it.control?.type===s.ControlType.TEXTFIELD&&it.controlComponent===s.ControlComponent.VALUE,ct=!!Wt&&Wt===Kt&&!!w.controlId&&!!it?.controlId&&w.controlId!==it.controlId&&(zn(w)||Si(it))?Wt:null;if(D&&(ne||ce))return;const nt=Xo(it)&&!it?.originControlId,ut=Fe(w)&&!w.originControlId||w.type===s.ElementType.CONTROL&&w.controlComponent===s.ControlComponent.VALUE&&it?.type!==s.ElementType.CONTROL&&!w.originControlId,mt=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],Lt=(Ct,q)=>!!(Ct?.controlId&&Ct.controlId===q?.controlId&&(Ct.originControlId||null)===(q.originControlId||null)),wt=(Ct,q)=>{if(Ct?.control?.type)return Ct.control.type;if(Ct?.controlId){for(let Dt=q;Dt>=0;Dt--){const at=W[Dt];if(!Lt(Ct,at))break;if(at.control?.type)return at.control.type}for(let Dt=q+1;Dt<W.length;Dt++){const at=W[Dt];if(!Lt(Ct,at))break;if(at.control?.type)return at.control.type}}},_t=(Ct,q)=>{const Dt=wt(Ct,q);return!!(Dt&&mt.includes(Dt))},Ot=Ct=>{const q=W[Ct];let Dt=Ct;for(let at=Ct+1;at<W.length&&Lt(q,W[at]);at++)Dt=at;return Dt},Gt=!!(_t(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&!w.originControlId&&Lt(w,it)&&Fe(it)&&!it?.value),Yt=!!(_t(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&w.originControlId&&Lt(w,it)&&Fe(it))?dn(W,w.originControlId,i.getMode()):null,St=or(W,Yt),Pt=nt||ut||Gt,oe=Pt?{...w,type:void 0,control:void 0,controlId:void 0,controlComponent:void 0,originControlId:void 0,color:r.defaultColor,highlight:void 0}:w,Et=Pt||rt?oe:k,Ht=yt(U).map(Ct=>{const q={value:Ct};if(ot||!Et.title?.disabled&&!Et.control?.disabled){const Dt=W[v+1];(!Et.type||Et.type===y||Et.type===M&&Dt?.type===M||Et.type===Y&&Dt?.type===Y||Et.type===X&&Dt?.type===X||Et.type===P&&Dt?.type===P)&&Ra.forEach(at=>{if(at==="groupIds"&&!Dt?.groupIds)return;const kt=Et[at];kt!==void 0&&(q[at]=kt)}),(b||Et.type===S)&&Ne.forEach(at=>{const kt=b?.[at]||Et[at];kt!==void 0&&(q[at]=kt)}),g&&(q.underline=!0)}if(!Pt){const Dt=w.originControlId&&(w.controlComponent===s.ControlComponent.POSTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||w.controlComponent===s.ControlComponent.POST_TEXT);if($||_||H){const B=H||it;q.controlId=B.controlId,q.control=B.control,q.controlComponent=s.ControlComponent.VALUE,delete q.originControlId,Xi(q,B.control,r.defaultColor)}const at=!w.originControlId&&w.controlId&&(w.controlComponent===s.ControlComponent.POSTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||w.controlComponent===s.ControlComponent.POST_TEXT)&&it?.controlId&&it.controlId!==w.controlId&&_c(w,it),kt=w.controlId&&w.originControlId&&(w.controlComponent===s.ControlComponent.VALUE||w.controlComponent===s.ControlComponent.PLACEHOLDER);if(!$&&!_&&!H&&Dt&&!q.controlId){const B=dn(W,w.originControlId,i.getMode());if(!B)return q;let et=null;for(let ft=Q;ft>=0;ft--){const lt=W[ft];if(Je(lt,B)&&lt.control){et=lt.control;break}}q.controlId=B,q.controlComponent=s.ControlComponent.VALUE,et&&(q.control=et),Xi(q,et,r.defaultColor)}else if(at&&!q.controlId){if(it?.controlId&&it.controlId!==w.controlId)if(it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX)for(let B=Q;B>=0;B--){const et=W[B];if(et.controlId===w.controlId&&(et.controlComponent===s.ControlComponent.PREFIX||et.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let ft=B-1;ft>=0;ft--){const lt=W[ft];if(lt.controlId&&lt.controlId!==w.controlId&&(lt.controlComponent===s.ControlComponent.PRETEXTFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRE_TEXT)){q.controlId=lt.controlId,q.controlComponent=s.ControlComponent.VALUE,lt.control&&(q.control=lt.control);break}if(lt.controlId&&lt.controlId!==w.controlId&&(lt.controlComponent===s.ControlComponent.POSTFIX||lt.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}else(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX)&&(q.controlId=it.controlId,q.controlComponent=s.ControlComponent.VALUE,it.control&&(q.control=it.control));if(!q.controlId)for(let B=Q;B>=0;B--){const et=W[B];if(et.controlId===w.controlId&&(et.controlComponent===s.ControlComponent.PREFIX||et.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let ft=B-1;ft>=0;ft--){const lt=W[ft];if(lt.controlId&&lt.controlId!==w.controlId&&(lt.controlComponent===s.ControlComponent.PRETEXTFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRE_TEXT)){q.controlId=lt.controlId,q.controlComponent=s.ControlComponent.VALUE,lt.control&&(q.control=lt.control);break}if(lt.controlId&&lt.controlId!==w.controlId&&(lt.controlComponent===s.ControlComponent.POSTFIX||lt.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}}else if(kt&&!q.controlId){const B=w.controlId;let et=w.control;if(!et)for(let ft=Q;ft>=0;ft--){const lt=W[ft];if(lt.controlId===B&&lt.control&&(et=lt.control,lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX))break}q.controlId=B,q.originControlId=w.originControlId,q.controlComponent=s.ControlComponent.VALUE,et&&(q.control=et)}else if(w.controlId){let B=w.control;if(!B)for(let et=Q;et>=0;et--){const ft=W[et];if(Je(ft,w.controlId)&&ft.control){B=ft.control;break}}q.controlId||(q.controlId=w.controlId),B&&!q.control&&(q.control=B),q.controlComponent||(q.controlComponent=s.ControlComponent.VALUE)}else if(!q.controlId&&!q.control&&it?.originControlId&&(it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX)){const B=dn(W,it.originControlId,i.getMode());if(!B)return q;let et=null;for(let ft=v;ft>=0;ft--){const lt=W[ft];if(Je(lt,B)&&lt.control){et=lt.control;break}}q.controlId=B,q.controlComponent=s.ControlComponent.VALUE,et&&(q.control=et)}}if(Ct&&Ct!==K){const Dt=Hc(Ct,r.defaultFont);q.font=Dt}return q});let It;const Xt=a[u],Ft=a[u+1],pe=a[u-1];if(g)It=Q;else{const Ct=B=>{if(Ht?.length)for(let et=0;et<Ht.length;et++)W.splice(B+et,0,Ht[et]);return B+Ht.length-1},q=Q+1,Dt=Gt?Ot(Q)+1:q,at=()=>{let B=null,et,ft=null;const lt=i.getMode()===s.EditorMode.EDIT?ir(a,Xt,Ft):void 0;if(lt?.controlId?(B=lt.controlId,et=lt.control?.type):i.getMode()===s.EditorMode.EDIT&&zn(Xt)&&Ft?.controlId===Xt.originControlId&&!Ft.originControlId&&Ft.control?.type===s.ControlType.TEXTFIELD&&(Ft.controlComponent===s.ControlComponent.VALUE||Fe(Ft))?(B=Xt.originControlId,et=s.ControlType.TEXTFIELD):zn(Xt)?B=dn(a,Xt.originControlId,i.getMode()):Si(Ft)?B=dn(a,Ft.originControlId,i.getMode()):ct?B=ct:Xt?.control?.type===s.ControlType.TEXT&&Xt.controlId&&!Xt.originControlId&&Fe(Xt)&&pe?.originControlId===Xt.controlId&&(B=Xt.controlId,ft={startIndex:u-1,endIndex:u-1}),!B)return null;if(!et)for(let xt=u;xt>=0;xt--){const zt=a[xt];if(Je(zt,B)&&zt.control?.type){et=zt.control.type;break}if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}return et!==s.ControlType.TEXT&&!(i.getMode()===s.EditorMode.EDIT&&et===s.ControlType.TEXTFIELD)?null:{parentControlId:B,activationIndex:(()=>{for(let xt=u+1;xt<a.length;xt++){const zt=a[xt];if(Je(zt,B))return xt;if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}for(let xt=u;xt>=0;xt--){const zt=a[xt];if(Je(zt,B))return xt;if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}return u})(),boundaryRange:ft}};Q!==v&&(i.removeSplitTdOtherRangeElements(),i.spliceElementList(W,q,v-Q));const kt=at();if(Yt&&St?.control){const B=Ot(Q);Ht.forEach(et=>{Ni(et,Yt,St.control,r.defaultColor)}),re(W,Ht,B,{editorOptions:r}),i.spliceElementList(W,B+1,0,Ht),It=B+Ht.length}else if(kt){const{parentControlId:B,activationIndex:et,boundaryRange:ft}=kt;m(et,et),p();const lt=l.getActiveControl(),de=Ft?.controlId===B&&!Ft?.originControlId&&Ft?.controlComponent===s.ControlComponent.VALUE?u+1:-1,xt=!!(Xt?.originControlId&&zn(Xt)&&de!==-1),zt=ft||(xt?{startIndex:u,endIndex:u}:de!==-1?{startIndex:u,endIndex:de}:{startIndex:Q,endIndex:v});m(zt.startIndex,zt.endIndex),lt&&lt.getElement()?.controlId===B&&(lt.getElement()?.control?.type===s.ControlType.TEXT||lt.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Ht.forEach(xn=>{Ni(xn,B,lt.getElement().control,r.defaultColor)}),It=lt.setValue(Ht,{range:zt,elementList:W}),l.emitControlContentChange(),m(It,It),p()):Pt?It=Ct(Dt):(It=l.setValue(Ht),l.emitControlContentChange())}else if(Pt)It=Ct(Dt);else if(Xt?.originControlId&&(Xt.controlComponent===s.ControlComponent.POSTFIX||Xt.controlComponent===s.ControlComponent.POST_TEXT||Xt.controlComponent===s.ControlComponent.POSTTEXTFIX||Xt.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))if(C?.getElement()?.control?.type===s.ControlType.TEXT&&C.getElement()?.controlId===Xt.controlId&&(C.getElement()?.originControlId||null)===(Xt.originControlId||null))It=l.setValue(Ht),l.emitControlContentChange();else{const et=dn(a,Xt.originControlId,i.getMode());if(!et){It=Ct(q);return}let ft;for(let de=u;de>=0;de--){const xt=a[de];if(Je(xt,et)&&xt.control?.type){ft=xt.control.type;break}if(xt.controlId&&xt.controlId!==et&&xt.originControlId!==et)break}if(ft===s.ControlType.TEXT||i.getMode()===s.EditorMode.EDIT&&ft===s.ControlType.TEXTFIELD){const de=()=>{for(let Pe=u+1;Pe<a.length;Pe++){const We=a[Pe];if(Je(We,et))return Pe;if(We.controlId&&We.controlId!==et&&We.originControlId!==et)break}for(let Pe=u;Pe>=0;Pe--){const We=a[Pe];if(Je(We,et))return Pe;if(We.controlId&&We.controlId!==et&&We.originControlId!==et)break}return u},xt=Ft?.controlId===et&&Ft?.controlComponent===s.ControlComponent.VALUE?u+1:-1,zt=xt!==-1?{startIndex:u,endIndex:xt}:{startIndex:u,endIndex:u},xn=de();m(xn,xn),p();const gn=l.getActiveControl();m(zt.startIndex,zt.endIndex),gn&&gn.getElement()?.controlId===et&&(gn.getElement()?.control?.type===s.ControlType.TEXT||gn.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Ht.forEach(Pe=>{Ni(Pe,et,gn.getElement().control,r.defaultColor)}),It=gn.setValue(Ht,{range:zt,elementList:W}),l.emitControlContentChange(),m(It,It),p()):It=Ct(q)}else It=Ct(q)}else if((Xt?.control?.type===s.ControlType.NUMBER||Ft?.control?.type===s.ControlType.NUMBER)&&C?.getElement()?.control?.type===s.ControlType.NUMBER&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),It=Q}else if((Xt?.control?.type===s.ControlType.SELECT||Ft?.control?.type===s.ControlType.SELECT)&&C?.getElement()?.control?.type===s.ControlType.SELECT&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),It=Q}else if(C?.getElement()?.control?.type===s.ControlType.DATE&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),It=Q}else Xt?.control?.type==="button"||Ft?.control?.type==="button"?It=Q:C&&l.getIsRangeWithinControl()?(It=l.setValue(Ht),l.emitControlContentChange()):(Xt?.type==="control"||Ft?.type==="control")&&!Pt?It=Ct(q):(re(W,Ht,Q,{editorOptions:r}),i.spliceElementList(W,q,0,Ht),It=Q+Ht.length)}if(~It&&!g){const Ct=se()-n,q=se();f(()=>{T.setRange(It,It),i.render({curIndex:It,isSubmitHistory:!g,traceLabel:`input:${e}`})}),ri(r,`input:${e}`,se()-n,[{label:"mutate",duration:Ct},{label:"renderCall",duration:se()-q}],{isComposing:g,textLength:Ht.length,compositionChainDuration:e==="compositionend"&&N!==void 0?Number((se()-N).toFixed(2)):void 0})}g&&(t.compositionInfo={value:U,startIndex:It,endIndex:v,defaultStyle:b,perfStartTime:n})}function Ac(o){o.compositionInfo&&(o.compositionInfo=null)}function Gc(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 kc(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 h=t.getPosition().getPositionList(),g=h[n],T=g.rowNo,f=g.pageNo,p=[];for(let C=0;C<h.length;C++){const I=h[C];if(I.pageNo>f)break;I.pageNo===f&&I.rowNo===T&&p.push(C)}const m=p[0]-1;r=m<0?0:m,a=p[p.length-1]}const c=t.getOptions();await xs(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})}async function xc(o,t){const e=o.getDraw(),{copy:n}=e.getOverride();if(n&&n()?.preventDefault!==!1)return;const i=e.getRange();let l=null;if(i.getRange().isCrossRowCol){const a=i.getRangeTableElement();if(!a)return;const c=e.getTableParticle().getRangeRowCol();if(!c)return;const d={type:s.ElementType.TABLE,value:"",colgroup:[],trList:[]},u=c[0],R=u[0].colIndex,h=u[u.length-1],g=h.colIndex+h.colspan-1;for(let T=R;T<=g;T++)d.colgroup.push(a.colgroup[T]);for(let T=0;T<c.length;T++){const f=c[T],p=a.trList[f[0].rowIndex],m={tdList:[],height:p.height,minHeight:p.minHeight};for(let C=0;C<f.length;C++)m.tdList.push(f[C]);d.trList.push(m)}l=Vt([d])}else l=i.getIsCollapsed()?i.getRangeRowElementList():i.getSelectionElementList();t?.isPlainText&&l?.length&&(l=[{value:In(l,e.getOptions())}]),l?.length&&await xs(l,e.getOptions())}function Bc(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")&&Pi(t,a)}}}function sr(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(h=>!h.type||h.type!==s.ElementType.CONTROL&&Ce.includes(h.type)?h.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,R=-1;for(const{segment:h,index:g,isWordLike:T}of d){const f=g+a;if(T&&r>=f&&r<f+h.length){u=f-1,R=u+h.length;break}}return~u&&~R?{startIndex:u,endIndex:R}:null}function Jc(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=qo.test(n);if(c||l.test(n)){const u=t.getElementList();let R=i-1;for(;R>0;){const g=u[R].value;if(c&&qo.test(g)||!c&&l.test(g))r++,R--;else break}let h=i+1;for(;h<u.length;){const g=u[h].value;if(c&&qo.test(g)||!c&&l.test(g))a++,h++;else break}}const d=i-r-1;return d<0?null:{startIndex:d,endIndex:i+a}}function $c(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});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=sr(o)||Jc(o);r&&(l.setRange(r.startIndex,r.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),l.setRangeStyle())}function zc(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 T=r[d],f=r[d-1];if(T.value===K&&!T.listWrap||T.listId!==f?.listId||T.titleId!==f?.titleId)break;a++,d--}let u=l+1;for(;u<r.length;){const T=r[u],f=r[u+1];if(T.value===K&&!T.listWrap||T.listId!==f?.listId||T.titleId!==f?.titleId)break;c++,u++}const R=t.getRange();let h=l-a-1;if(r[h]?.value!==K&&(h-=1),h<0)return;let g=l+c+1;(r[g]?.value===K||g>r.length-1)&&(g-=1),R.setRange(h,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}const rr={dblclick:$c,threeClick:zc};function jc(o){o.isComposing=!0}function qc(o,t){const e=se();o.isComposing=!1;const n=o.getDraw(),i=n.getOptions();if(t.data)o.compositionInfo&&(o.compositionInfo.perfStartTime=e),ua?setTimeout(()=>{o.compositionInfo&&Fi(t.data,o,"compositionend")},1):o.compositionInfo&&Fi(t.data,o,"compositionend");else{const r=o.compositionInfo?.cancel;if(Ac(o),!r){const a=n.getRange(),{endIndex:c}=a.getRange();n.render({curIndex:c,isSubmitHistory:!1,traceLabel:"compositionend:empty"})}}n.getCursor().clearAgentDomValue(),ri(i,"compositionend",se()-e,[],{hasData:!!t.data,dataLength:t.data?.length||0})}function td(o){o.compositionInfo&&(o.compositionInfo.cancel=!0)}const yi={compositionstart:jc,compositionend:qc,compositionCancel:td};function ed(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!Cs(o.target,I=>I===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:R,index:h}=d,g=c.getPositionList(),T=u?R:h;~h&&(e.getRange().setRange(T,T),c.setCursorPosition(g[T]));const f=e.getCursor(),{cursor:{dragColor:p,dragWidth:m,dragFloatImageDisabled:C}}=e.getOptions();if(C){const I=t.cacheElementList?.[t.cacheRange.startIndex];if(I?.type===s.ElementType.IMAGE&&(I.imgDisplay===s.ImageDisplay.FLOAT_TOP||I.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM||I.imgDisplay===s.ImageDisplay.SURROUND))return}f.drawCursor({width:m,color:p,isBlink:!1,isFocus:!1})}const nd={dragover:ed};class od{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)),jl(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=sr(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.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()||Oc(t,this)}mousedown(t){this.draw.isInteractionSuspended()||Pc(t,this)}click(){this.draw.isInteractionSuspended()||ca&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){this.draw.isInteractionSuspended()||Ec(t,this)}mouseleave(t){this.draw.isInteractionSuspended()||Mc(t,this)}keydown(t){this.draw.isInteractionSuspended()||Qc(t,this)}dblclick(t){this.draw.isInteractionSuspended()||rr.dblclick(this,t)}threeClick(){this.draw.isInteractionSuspended()||rr.threeClick(this)}input(t,e="input"){this.draw.isInteractionSuspended()||Fi(t,this,e)}async cut(){this.draw.isInteractionSuspended()||await kc(this)}async copy(t){this.draw.isInteractionSuspended()||await xc(this,t)}compositionstart(){this.draw.isInteractionSuspended()||yi.compositionstart(this)}compositionend(t){this.draw.isInteractionSuspended()||yi.compositionend(this,t)}compositionCancel(){this.draw.isInteractionSuspended()||yi.compositionCancel(this)}drop(t){this.draw.isInteractionSuspended()||Bc(t,this)}dragover(t){this.draw.isInteractionSuspended()||nd.dragover(t,this)}}const lr={PAGE_SCALE:"pageScale"};class id{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(lr.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 sd{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 rd{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:R,table:{tdPadding:h}}=this.options;let g=l,T=r,f=c;for(let p=0;p<n.length;p++){const m=n[p];if(!m.isSurround){const L=m.width+(m.offsetX||0);m.rowFlex===s.RowFlex.CENTER?g+=(d-L)/2:m.rowFlex===s.RowFlex.RIGHT&&(g+=d-L)}g+=m.offsetX||0,T+=m.offsetY||0;const C=g,I=T;for(let L=0;L<m.elementList.length;L++){const E=m.elementList[L],O=E.metrics,F=!ue(E)&&(E.imgDisplay!==s.ImageDisplay.INLINE&&E.type===s.ElementType.IMAGE||E.type===s.ElementType.LATEX)?m.ascent-O.height:m.ascent;E.left&&(g+=E.left),E.translateX&&(g+=E.translateX*R);const V={pageNo:i,index:f,value:E.value,rowIndex:a+p,rowNo:p,metrics:O,left:E.left||0,ascent:F,lineHeight:m.height,isFirstLetter:L===0,isLastLetter:L===m.elementList.length-1,coordinate:{leftTop:[g,T],leftBottom:[g,T+m.height],rightTop:[g+O.width,T],rightBottom:[g+O.width,T+m.height]}};if(E.imgDisplay===s.ImageDisplay.SURROUND||E.imgDisplay===s.ImageDisplay.FLOAT_TOP||E.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM){const D=e[e.length-1];D&&(V.metrics=D.metrics,V.coordinate=D.coordinate),E.imgFloatPosition||(E.imgFloatPosition={x:g,y:T,pageNo:i}),this.floatPositionList.push({pageNo:i,element:E,position:V,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:f,zone:u})}if(e.push(V),f++,g+=O.width,E.type===s.ElementType.TABLE&&!ue(E)){const D=E.tdPadding||h,b=D[1]+D[3],N=D[0]+D[2];for(let W=0;W<E.trList.length;W++){const y=E.trList[W];for(let M=0;M<y.tdList.length;M++){const X=y.tdList[M];X.positionList=[];const P=X.rowList,Y=this.computePageRowPosition({positionList:X.positionList,rowList:P,pageNo:i,startRowIndex:0,startIndex:0,startX:(X.x+D[3])*R+C+(E.translateX||0)*R,startY:(X.y+D[0])*R+I,innerWidth:(X.width-b)*R,isTable:!0,index:f-1,tdIndex:M,trIndex:W,zone:u});if(X.verticalAlign===s.VerticalAlign.MIDDLE||X.verticalAlign===s.VerticalAlign.BOTTOM){const S=P.reduce((v,w)=>v+w.height,0),U=(X.height-N)*R-S,Q=X.verticalAlign===s.VerticalAlign.MIDDLE?U/2:U;Math.floor(Q)>0&&X.positionList.forEach(v=>{const{coordinate:{leftTop:w,leftBottom:x,rightBottom:rt,rightTop:A}}=v;w[1]+=Q,x[1]+=Q,rt[1]+=Q,A[1]+=Q})}g=Y.x,T=Y.y}}g=C,T=I}}g=l,T+=m.height}return{x:g,y:T,index:f}}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 R=u[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:u,pageNo:d,startRowIndex:c,startIndex:R,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:[ht(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 f=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_TOP,s.ImageDisplay.SURROUND]});if(f)return f}for(let f=0;f<r.length;f++){const{index:p,pageNo:m,left:C,isFirstLetter:I,coordinate:{leftTop:L,rightTop:E,leftBottom:O}}=r[f];if(u===m){if(m>u)break;if(L[0]-C<=e&&E[0]>=e&&L[1]<=n&&O[1]>=n){let F=f;const V=l[f];if(V.type===s.ElementType.TABLE)for(let b=0;b<V.trList.length;b++){const N=V.trList[b];for(let W=0;W<N.tdList.length;W++){const y=N.tdList[W],M=this.getPositionByXY({x:e,y:n,td:y,pageNo:c,tablePosition:r[f],isTable:!0,elementList:y.value,positionList:y.positionList});if(~M.index){const{index:X,hitLineStartIndex:P}=M,Y=y.value[X];return{index:p,isCheckbox:M.isCheckbox||Y.type===s.ElementType.CHECKBOX||Y.controlComponent===s.ControlComponent.CHECKBOX,isRadio:Y.type===s.ElementType.RADIO||Y.controlComponent===s.ControlComponent.RADIO,isControl:!!Y.controlId,isImage:M.isImage,isLabel:M.isLabel,isMacro:M.isMacro,isDirectHit:M.isDirectHit,isTable:!0,tdIndex:W,trIndex:b,tdValueIndex:X,tdId:y.id,trId:N.id,tableId:V.id,hitLineStartIndex:P}}}}if(V.type===s.ElementType.IMAGE||V.type===s.ElementType.LATEX)return{index:F,isDirectHit:!0,isImage:!0};if(V.type===s.ElementType.MENSTRUAL_HISTORY)return{index:F,isDirectHit:!0};if(V.type===s.ElementType.FETAL_HEART_POSITION)return{index:F,isDirectHit:!0};if(V.type===s.ElementType.TOOTH_POSITION){const{scale:b}=this.options,N=V.width*b;return e>=L[0]&&e<=L[0]+N?{index:F,isDirectHit:!0}:{index:F}}if(V.type===s.ElementType.CHECKBOX||V.controlComponent===s.ControlComponent.CHECKBOX)return{index:F,isDirectHit:!0,isCheckbox:!0};if(V.type===s.ElementType.LABEL)return{index:F,isDirectHit:!0,isLabel:!0};if(V.type===s.ElementType.MACRO||V.type===s.ElementType.CUSTOM_MACRO||V.type===s.ElementType.REUSABLE_ITEM||V.type===s.ElementType.SUB_TEMPLATE)return{index:F,isDirectHit:!0,isMacro:!0};if(V.type===s.ElementType.TAB&&V.listStyle===s.ListStyle.CHECKBOX){let b=F-1;for(;b>0;){const N=l[b];if(N.value===K&&N.listStyle===s.ListStyle.CHECKBOX)break;b--}return{index:b,isDirectHit:!0,isCheckbox:!0}}if(V.type===s.ElementType.RADIO||V.controlComponent===s.ControlComponent.RADIO)return{index:F,isDirectHit:!0,isRadio:!0};let D;if(l[p].value!==K){const b=E[0]-L[0];e<L[0]+b/2&&(F=f-1,I&&(D=f))}return{isDirectHit:!0,hitLineStartIndex:D,index:F,isControl:!!V.controlId}}}}if(!i){const f=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_BOTTOM]});if(f)return f}let R=!1,h=-1,g;if(i){const{scale:f}=this.options,{td:p,tablePosition:m}=t;if(p&&m){const{leftTop:C}=m.coordinate,I=p.x*f+C[0],L=p.y*f+C[1],E=p.width*f,O=p.height*f;if(!(I<e&&e<I+E&&L<n&&n<L+O))return{index:h}}}const T=r.filter(f=>f.isLastLetter&&f.pageNo===u);for(let f=0;f<T.length;f++){const{index:p,rowNo:m,coordinate:{leftTop:C,leftBottom:I}}=T[f];if(n>C[1]&&n<=I[1]){const L=r.findIndex(V=>V.pageNo===u&&V.rowNo===m),E=l[L],O=r[L],F=E.listStyle===s.ListStyle.CHECKBOX?this.draw.getMargins()[3]:O.coordinate.leftTop[0];if(e<F)~L?O.value===K?h=L:(h=L-1,g=L):h=p;else{if(E.listStyle===s.ListStyle.CHECKBOX&&e<C[0])return{index:L,isDirectHit:!0,isCheckbox:!0};h=p}R=!0;break}}if(!R){if(this.draw.getIsPagingMode()){const p=this.draw.getHeader(),m=p.getHeight(),C=p.getHeaderTop()+m,I=this.draw.getFooter(),E=this.draw.getHeight()-(I.getFooterBottom()+I.getHeight());if(d){if(n<C)return{index:-1,zone:s.EditorZone.HEADER};if(n>E)return{index:-1,zone:s.EditorZone.FOOTER}}else if(n<=E&&n>=C)return{index:-1,zone:s.EditorZone.MAIN}}const f=this.draw.getMargins();if(n<=f[0])for(let p=0;p<r.length;p++){const m=r[p];if(m.pageNo!==u||m.rowNo!==0)continue;const{leftTop:C,rightTop:I}=m.coordinate;if(e<=f[3]||e>=C[0]&&e<=I[0]||r[p+1]?.rowNo!==0)return{index:m.index}}else{const p=T[T.length-1];if(p){const m=p.rowNo;for(let C=0;C<r.length;C++){const I=r[C];if(I.pageNo!==u||I.rowNo!==m)continue;const{leftTop:L,rightTop:E}=I.coordinate;if(e<=f[3]||e>=L[0]&&e<=E[0]||r[C+1]?.rowNo!==m)return{index:I.index}}}}return{index:T[T.length-1]?.index||r.length-1}}return{hitLineStartIndex:g,index:h,isControl:!!l[h]?.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:R,trIndex:h,tdIndex:g,tdValueIndex:T,zone:f,pageNo:p}=this.floatPositionList[a];if(i===p&&d.type===s.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!f||f===l)){const m=d.imgFloatPosition,C=m.x*r,I=m.y*r,L=d.width*r,E=d.height*r;if(e>=C&&e<=C+L&&n>=I&&n<=I+E)return u?{index:R,isDirectHit:!0,isImage:!0,isTable:u,trIndex:h,tdIndex:g,tdValueIndex:T,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:p,isTable:m,trIndex:C,tdIndex:I,tdValueIndex:L}=e,E=this.draw.getControl(),{newIndex:O}=E.moveCursor({index:p,isTable:m,trIndex:C,tdIndex:I,tdValueIndex:L});m?e.tdValueIndex=O:e.index=O}const{index:n,isCheckbox:i,isRadio:l,isControl:r,isImage:a,isLabel:c,isDirectHit:d,isTable:u,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f}=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:R,tdIndex:h,tdId:g,trId:T,tableId:f}),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&&!Vn(l)&&!l.control?.minWidth)for(let R=0;R<a.length;R++){const h=a[R],g=h.imgFloatPosition;if(g.pageNo!==n)continue;const T={...g,x:g.x*e,y:g.y*e,width:h.width*e,height:h.height*e};if(sa(r,T)){i.isSurround=!0;const f=T.width+T.x-r.x;if(l.left=f,i.width+=f,u+=f,d=T.x+T.width,i.width+l.metrics.width>c){l.left=0,i.width-=u;break}}}return{x:d,rowIncreaseWidth:u}}}class ld{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=yn(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||Ce.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Ce.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 R=l.get(d);R||(R=[],l.set(d,R)),R.includes(u)||R.unshift(u);const h=i[r],g=i[r-1];if(h.value===K&&!h.listWrap||h.listId!==g?.listId||h.titleId!==g?.titleId)break;r--}const a=t===e;if(!a){let d=t+1;for(;d<e;){const{pageNo:u,rowNo:R}=n[d];let h=l.get(u);h||(h=[],l.set(u,h)),h.includes(R)||h.push(R),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:R,rowNo:h}=n[c];let g=l.get(R);g||(g=[],l.set(R,g)),g.includes(h)||g.push(h),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:R}=r[a];if(n===R&&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:R,trIndex:h}=l,g={startIndex:u,endIndex:u};a===Qe.TABLE&&(g.tableId=d,g.startTdIndex=R,g.endTdIndex=R,g.startTrIndex=h,g.endTrIndex=h),n.set(c,g)}}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){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 P=this.draw.getOriginalElementList(),Y=this.position.getPositionContext();r=P[Y.index]}else{const P=~i?i:0,Y=this.draw.getElementList();r=this.getRangeAnchorStyle(Y,P)}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,R=!~a.findIndex(P=>!P.bold),h=!~a.findIndex(P=>!P.italic),g=!~a.findIndex(P=>!P.underline&&!P.control?.underline),T=!~a.findIndex(P=>!P.strikeout),f=r.color||null,p=r.highlight||null,m=r.rowFlex||null,C=r.vertical||null,I=r.rowMargin??this.options.defaultRowMargin,L=r.dashArray||[],E=r.level||null,O=r.listType||null,F=r.listStyle||null,V=g&&r.textDecoration||null,D=!!this.draw.getPainterStyle(),b=this.historyManager.isCanUndo(),N=this.historyManager.isCanRedo(),W=r.groupIds||null,y=r.extension??null,M=r.deletePerson??"",X={type:c,undo:b,redo:N,painter:D,font:d,size:u,bold:R,italic:h,underline:g,strikeout:T,deletePerson:M,color:f,highlight:p,rowFlex:m,vertical:C,rowMargin:I,dashArray:L,level:E,listType:O,listStyle:F,groupIds:W,textDecoration:V,extension:y};this._emitRangeStyle(X)}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 ad{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 R=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_X?Math.ceil(n*r/a):1,h=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_Y?Math.ceil(i*r/c):1;for(let g=0;g<R;g++){for(let T=0;T<h;T++)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 bi{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 cd extends bi{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 dd{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]],R=[a[3],r-a[2]],h=[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(R[0]-c,R[1]),t.lineTo(...R),t.lineTo(R[0],R[1]+c),t.moveTo(h[0]+c,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+c),t.stroke(),t.restore()}}class ud{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 g=0;g<c;g++)e[g].type===s.ElementType.TABLE&&d.push(g);let u=0,R=0;for(;R<c-1;){const g=d.length?d[u]:c,T=e.slice(R,g);T.length&&a.push({index:R,type:Qe.PAGE,elementList:T});const f=e[g];f&&a.push({index:g,type:Qe.TABLE,elementList:[f]}),R=g+1,u++}function h(g,T,f,p){if(!g)return;let m=f.map(O=>!O.type||Ce.includes(O.type)&&O.controlComponent!==s.ControlComponent.CHECKBOX&&O.controlComponent!==s.ControlComponent.RADIO&&!O.hide&&!O.control?.hide&&!O.area?.hide?O.value:K).filter(Boolean).join("");i&&(m=m.toLocaleLowerCase());const C=[],I=n?new RegExp(g):g;let{index:L,length:E}=Ss(m,I);for(;L!==-1&&E!==0;){C.push({index:L,length:E});const O=Ss(m,I,L+E);L=O.index,E=O.length}for(let O=0;O<C.length;O++){const{index:F,length:V}=C[O],D=Tt();for(let b=0;b<V;b++){const N=F+b+(p?.startIndex||0);r.push({type:T,index:N,groupId:D,...p})}}}for(let g=0;g<a.length;g++){const T=a[g];if(T.type===Qe.TABLE){const f=T.elementList[0];for(let p=0;p<f.trList.length;p++){const m=f.trList[p];for(let C=0;C<m.tdList.length;C++){const I=m.tdList[C],L={tableId:f.id,tableIndex:T.index,trIndex:p,tdIndex:C,tdId:I.id};h(l,T.type,I.value,L)}}}else h(l,T.type,T.elementList,{startIndex:T.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===Qe.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===Qe.TABLE){const{tableIndex:L,trIndex:E,tdIndex:O,index:F}=d;u=a[L]?.trList[E].tdList[O]?.positionList[F]}else u=r[d.index];if(!u)continue;const{coordinate:{leftTop:R,leftBottom:h,rightTop:g},pageNo:T}=u;if(T!==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 p=R[0],m=R[1],C=g[0]-R[0],I=h[1]-R[1];t.fillRect(p,m,C,I)}t.restore()}replace(t,e){if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const l=e?.index;if(ii(l)){const f=[];i.forEach(p=>{const m=f[f.length-1];!m||m[0].groupId!==p.groupId?f.push([p]):m.push(p)}),i=f[l]}if(!i?.length)return;const r=this.draw.isDesignMode();let a=0,c=0,d="",u="",R=-1;const h=this.draw.getOriginalElementList();for(let f=0;f<i.length;f++){const p=i[f];if(p.type===Qe.TABLE){const{tableIndex:m,trIndex:C,tdIndex:I,index:L,tdId:E}=p;u&&E!==u&&(c=0),u=E;const O=m+a,F=h[O].trList[C].tdList[I].value,V=L+c,D=F[V];if(!r&&(D?.control?.deletable===!1||D?.title?.deletable===!1))continue;if(t===""){this.draw.spliceElementList(F,V,1),c--,~R||(R=f);continue}if(d===p.groupId){this.draw.spliceElementList(F,V,1),c--;continue}~R||(R=f);for(let b=0;b<t.length;b++){const N=t[b];b===0?D.value=N:(this.draw.spliceElementList(F,V+b,0,[{...D,value:N}]),c++)}}else{const m=p.index+a,C=h[m];if(!r&&(C?.control?.deletable===!1||C?.title?.deletable===!1)||C.type===s.ElementType.CONTROL&&C.controlComponent!==s.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,m,1),a--,~R||(R=f);continue}if(~R||(R=f),d===p.groupId){this.draw.spliceElementList(h,m,1),a--;continue}for(let I=0;I<t.length;I++){const L=t[I];I===0?C.value=L:(this.draw.spliceElementList(h,m+I,0,[{...C,value:L}]),a++)}}d=p.groupId}if(!~R)return;const g=i[R],T=g.index+(t.length-1);if(g.type===Qe.TABLE){const{tableIndex:f,trIndex:p,tdIndex:m,index:C}=g,I=h[f].trList[p].tdList[m].value[C];this.position.setPositionContext({isTable:!0,index:f,trIndex:p,tdIndex:m,tdId:I.tdId,trId:I.trId,tableId:I.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(T,T),this.draw.render({curIndex:T})}}class Rd extends bi{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 Yn;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(Yn||(Yn={}));class hd extends bi{options;constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,l){const r=e+i;switch(t.beginPath(),l){case Yn.DASHED:t.setLineDash([3,1]);break;case Yn.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?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,Yn.DASHED);break;case s.TextDecorationStyle.DOTTED:this._drawLine(t,i,a,r,Yn.DOTTED);break;default:this._drawLine(t,i,a,r);break}t.restore(),this.clearFillInfo()}}class gd{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:_l});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||!Hl.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 Un{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const l=i===s.NumberType.CHINESE?ea(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:R}}=this.options;if(e<R)return;let h=d;const g=new RegExp($n.PAGE_NO);g.test(h)&&(h=Un.formatNumberPlaceholder(h,e+u-R,g,c));const T=new RegExp($n.PAGE_COUNT);T.test(h)&&(h=Un.formatNumberPlaceholder(h,this.draw.getPageCount()-R,T,c));const f=this.draw.getWidth(),p=this.draw.getHeight(),m=this.draw.getPageNumberBottom(),C=p-m;t.save(),t.fillStyle=r,t.font=`${i*n}px ${l}`;let I=0;const L=this.draw.getMargins(),{width:E}=t.measureText(h);a===s.RowFlex.CENTER?I=(f-E)/2:a===s.RowFlex.RIGHT?I=f-E-L[1]:I=L[3],t.fillText(h,I,C),t.restore()}}class Td{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=$l(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150)}class fd{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($t.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove($t.DOWN):e<this.thresholdPoints[2]?this._startMove($t.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove($t.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===$t.DOWN?e.scrollTo(n,i+this.step):t===$t.UP?e.scrollTo(n,i-this.step):t===$t.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 md{draw;range;options;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=ht(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 R=i.tdList.splice(l,1)[0];e[u]?.tdList.splice(d,0,R)}}}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(),h=this.draw.getOriginalElementList()[e].trList;if(!l)return[[h[n].tdList[i]]];let g=h[c].tdList[r],T=h[d].tdList[a];(g.x>T.x||g.y>T.y)&&([g,T]=[T,g]);const f=g.colIndex,p=T.colIndex+(T.colspan-1),m=g.rowIndex,C=T.rowIndex+(T.rowspan-1),I=[];for(let L=0;L<h.length;L++){const E=h[L],O=[];for(let F=0;F<E.tdList.length;F++){const V=E.tdList[F],D=V.colIndex,b=V.rowIndex;D>=f&&D<=p&&b>=m&&b<=C&&O.push(V)}O.length&&I.push(O)}return I.length?I: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,R=this._mergeHorizontalBorderRanges(d,l),h=e.lineWidth;c&&(e.lineWidth=c*u),e.beginPath();const g=Math.round(n),T=Math.round(i);e.translate(.5,.5),a&&!R.length?e.rect(g,T,l,r):(a?(e.moveTo(g,T),e.lineTo(g,T+r),e.lineTo(g+l,T+r),e.lineTo(g+l,T)):(e.moveTo(g,T+r),e.lineTo(g,T)),this._drawHorizontalBorder(e,g,T,l,R)),e.stroke(),c&&(e.lineWidth=h),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:R,table:{defaultBorderColor:h}}=this.options,g=e.width*R,T=e.height*R,f=this._getPagingContinuationTopBorderRanges(r,g),p=a===s.TableBorder.EMPTY,m=a===s.TableBorder.EXTERNAL,C=a===s.TableBorder.INTERNAL;t.save(),a===s.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=d*R,t.strokeStyle=c||h,!p&&!C&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:T,borderExternalWidth:u,isDrawFullBorder:m,skipTopBorderRanges:f});for(let I=0;I<r.length;I++){const L=r[I];for(let E=0;E<L.tdList.length;E++){const O=L.tdList[E];if(O.slashTypes?.length&&this._drawSlash(t,O,n,i),!O.borderTypes?.length&&(p||m))continue;const F=O.width*R,V=O.height*R,D=Math.round(O.x*R+n+F),b=Math.round(O.y*R+i),N=!!O.linkTdPrevId,W=!!O.linkTdNextId;if(t.translate(.5,.5),t.beginPath(),!N&&O.borderTypes?.includes(s.TdBorder.TOP)&&(t.moveTo(D-F,b),t.lineTo(D,b),t.stroke()),O.borderTypes?.includes(s.TdBorder.RIGHT)&&(t.moveTo(D,b),t.lineTo(D,b+V),t.stroke()),O.borderTypes?.includes(s.TdBorder.BOTTOM)&&(t.moveTo(D,b+V),t.lineTo(D-F,b+V),t.stroke()),O.borderTypes?.includes(s.TdBorder.LEFT)&&(t.moveTo(D-F,b),t.lineTo(D-F,b+V),t.stroke()),!p&&!m){if((!C||O.colIndex+O.colspan<l.length)&&(t.moveTo(D,b),t.lineTo(D,b+V),u&&u!==d&&O.colIndex+O.colspan===l.length)){const y=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=y}if(W||!C||O.rowIndex+O.rowspan<r.length){const y=u&&u!==d&&O.rowIndex+O.rowspan===r.length;if(y&&(t.stroke(),t.beginPath()),t.moveTo(D,b+V),t.lineTo(D-F,b+V),y){const M=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=M}}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 R=u.width*r,h=u.height*r,g=Math.round(u.x*r+n),T=Math.round(u.y*r+i);t.fillStyle=u.backgroundColor,t.fillRect(g,T,R,h),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 m=r.tdList[c-1],C=m?m.colIndex+m.colspan:c;for(let I=C;I<e.length;I++)if(this.getRowCountByColIndex(n.slice(0,l),I)===l){u=I;let E=0;for(let O=0;O<I;O++)E+=e[O].width;i=E;break}}else{const m=r.tdList[c-1];m&&(u=m.colIndex+m.colspan)}let R=0;for(let m=0;m<d.colspan;m++)R+=e[m+u].width;let h=0;for(let m=0;m<d.rowspan;m++){const C=n[m+l]||n[l];h+=C.height}const g=r.tdList.length-1===c;let T=a;if(!T&&d.rowspan>1){const m=n.length-1-l;T=d.rowspan-1===m}const f=a&&g;d.isLastRowTd=g,d.isLastColTd=T,d.isLastTd=f,d.x=i;let p=0;for(let m=0;m<l;m++){const C=n[m].tdList;for(let I=0;I<C.length;I++){const L=C[I];if(u>=L.colIndex&&u<L.colIndex+L.colspan){p+=L.height;break}}}d.y=p,d.width=R,d.height=h,d.rowIndex=l,d.colIndex=u,d.trIndex=l,d.tdIndex=c,i+=R,g&&!f&&(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:R,endTdIndex:h,startTrIndex:g,endTrIndex:T}=this.range.getRange();if(!u)return;let f=d[g].tdList[R],p=d[T].tdList[h];(f.x>p.x||f.y>p.y)&&([f,p]=[p,f]);const m=f.colIndex,C=p.colIndex+(p.colspan-1),I=f.rowIndex,L=p.rowIndex+(p.rowspan-1);t.save();for(let E=0;E<d.length;E++){const O=d[E];for(let F=0;F<O.tdList.length;F++){const V=O.tdList[F],D=V.colIndex,b=V.rowIndex;if(D>=m&&D<=C&&b>=I&&b<=L){const N=V.x*l,W=V.y*l,y=V.width*l,M=V.height*l;t.globalAlpha=r,t.fillStyle=a,t.fillRect(N+n,W+i,y,M)}}}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 R=0;R<c.length;R++){const h=c[R];h.height=h.minHeight||l,h.minHeight=h.height}this.computeRowColInfo(t);const d={},u={};for(let R=0;R<c.length;R++){const h=c[R];if(!h.tdList.length){h.height=0;continue}const g=[],T=[];for(let p=0;p<t.colgroup.length;p++){const m=h.tdList.find(C=>C.colIndex===p);if(m){const C=e?e(m):m.rowList,I=C.reduce((E,O)=>E+O.height,0);m.rowList=C;const L=I/n+a;m.mainHeight=L,m.rowspan>1?(u[m.colIndex]=m.id,d[m.id]={td:m,rowSpan:[R,R+m.rowspan-1],preHeight:0,preMinHeight:0,extraHeight:L},T.push(L)):m.height<L?(m.height=L,m.realHeight=L,g.push(L)):g.push(m.height)}else{const C=d[u[p]];C?.rowSpan[1]==R&&g.push(C.extraHeight)}}const f=Math.max(...g.length?g:T);Object.values(d).forEach(p=>{p.rowSpan[0]<=R&&p.rowSpan[1]>=R&&(p.extraHeight-=f,p.preHeight+=f,p.preMinHeight+=h.minHeight)}),h.height=f;for(let p=0;p<t.colgroup.length;p++){const m=h.tdList.find(C=>C.colIndex===p)??this.findPreRowSpanTd(c,R,p);if(m){const C=d[m.id]?.preHeight??0,I=d[m.id]?.preMinHeight??h.minHeight;m.height=f+C,m.realHeight=f+C,m.realMinHeight=I}}}this.computeRowColInfo(t)}}var _e;(function(o){o.ROW="row",o.COL="col"})(_e||(_e={}));class pd{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:R,trList:h}=a,{coordinate:{leftTop:g}}=u,T=this.draw.getHeight(),f=this.draw.getPageGap(),p=this.draw.getPageNo()*(T+f),m=g[0],C=g[1]+p,I=a.trList[n].tdList[i],L=I.rowIndex,E=I.colIndex,O=a.height*c,F=a.width*c,V=document.createElement("div");V.classList.add(`${j}-table-tool__select`),V.style.height=`${O*c}`,V.style.left=`${m}px`,V.style.top=`${C}px`,V.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*c}px, ${-this.TABLE_SELECT_OFFSET*c}px)`,V.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(V),this.toolTableSelectBtn=V;const D=h.map(P=>P.height),b=document.createElement("div");b.classList.add(`${j}-table-tool__row`),b.style.transform=`translateX(-${this.ROW_COL_OFFSET*c}px)`;for(let P=0;P<D.length;P++){const Y=D[P]*c,S=document.createElement("div");S.classList.add(`${j}-table-tool__row__item`),P===L&&S.classList.add("active"),S.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByRowIndex(h,P),v=Q[0],w=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:v.trIndex,tdIndex:v.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,v.tdIndex,w.tdIndex,v.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(b,P)};const U=document.createElement("div");U.classList.add(`${j}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:P,order:_e.ROW})},S.append(U),S.style.height=`${Y}px`,b.append(S)}b.style.left=`${m}px`,b.style.top=`${C}px`,this.container.append(b),this.toolRowContainer=b;const N=document.createElement("div");N.classList.add(`${j}-table-tool__quick__add`),N.style.height=`${O*c}`,N.style.left=`${m}px`,N.style.top=`${C+O}px`,N.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*c}px, ${this.ROW_COL_QUICK_OFFSET*c}px)`,N.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(N),this.toolRowAddBtn=N;const W=R.map(P=>P.width),y=document.createElement("div");y.classList.add(`${j}-table-tool__col`),y.style.transform=`translateY(-${this.ROW_COL_OFFSET*c}px)`;for(let P=0;P<W.length;P++){const Y=W[P]*c,S=document.createElement("div");S.classList.add(`${j}-table-tool__col__item`),P===E&&S.classList.add("active"),S.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByColIndex(h,P),v=Q[0],w=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:v.trIndex,tdIndex:v.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,v.tdIndex,w.tdIndex,v.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(y,P)};const U=document.createElement("div");U.classList.add(`${j}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:P,order:_e.COL})},S.append(U),S.style.width=`${Y}px`,y.append(S)}y.style.left=`${m}px`,y.style.top=`${C}px`,this.container.append(y),this.toolColContainer=y;const M=document.createElement("div");M.classList.add(`${j}-table-tool__quick__add`),M.style.height=`${O*c}`,M.style.left=`${m+F}px`,M.style.top=`${C}px`,M.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*c}px, -${this.ROW_COL_QUICK_POSITION*c}px)`,M.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(M),this.toolColAddBtn=M;const X=document.createElement("div");X.classList.add(`${j}-table-tool__border`),X.style.height=`${O}px`,X.style.width=`${F}px`,X.style.left=`${m}px`,X.style.top=`${C}px`;for(let P=0;P<h.length;P++){const Y=h[P];for(let S=0;S<Y.tdList.length;S++){const U=Y.tdList[S],Q=document.createElement("div");Q.classList.add(`${j}-table-tool__border__row`),Q.style.width=`${U.width*c}px`,Q.style.height=`${this.BORDER_VALUE}px`,Q.style.top=`${(U.y+U.height)*c-this.BORDER_VALUE/2}px`,Q.style.left=`${U.x*c}px`,Q.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.rowIndex+U.rowspan-1,order:_e.ROW})},X.appendChild(Q);const v=document.createElement("div");if(v.classList.add(`${j}-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+U.width)*c-this.BORDER_VALUE/2}px`,v.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.colIndex+U.colspan-1,order:_e.COL})},X.appendChild(v),d&&U.colIndex===0){const w=document.createElement("div");w.classList.add(`${j}-table-tool__border__col`),w.style.width=`${this.BORDER_VALUE}px`,w.style.height=`${U.height*c}px`,w.style.top=`${U.y*c}px`,w.style.left=`${U.x*c-this.BORDER_VALUE/2}px`,w.onmousedown=x=>{this._mousedown({evt:x,element:a,index:0,isLeftStartBorder:!0,order:_e.COL})},X.appendChild(w)}}}this.container.append(X),this.toolBorderContainer=X}_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(),R=this.draw.getPageGap(),h=this.draw.getPageNo()*(u+R),g=this.position.getPositionContext(),p=(this.position.getOriginalPositionList()[g.index]?.coordinate?.leftTop?.[0]||0)*a,m=this.draw.getMargins(),C=m[0],I=m[1],L=C,E=d-I;this.mousedownX=e.x,this.mousedownY=e.y;const O=e.target,F=this.canvas.getBoundingClientRect(),V=window.getComputedStyle(O).cursor;document.body.style.cursor=V,this.canvas.style.cursor=V;let D=0,b=0;const N=document.createElement("div");N.classList.add(`${j}-table-anchor__line`),i===_e.ROW?(N.classList.add(`${j}-table-anchor__line__row`),N.style.width=`${d}px`,D=0,b=h+this.mousedownY-F.top):(N.classList.add(`${j}-table-anchor__line__col`),N.style.height=`${u}px`,D=this.mousedownX-F.left,b=h),N.style.left=`${D}px`,N.style.top=`${b}px`,this.container.append(N),this.anchorLine=N;let W=0,y=0;const M=X=>{const P=this._mousemove(X,i,D,b);P&&(W=P.dx,y=P.dy)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",()=>{let X=!1;if(i===_e.ROW){const P=l.trList,Y=P[n]||P[n-1],{defaultTrMinHeight:S}=this.options.table;y<0&&Y.height+y<S&&(y=S-Y.height),y&&(Y.height+=y,Y.minHeight=Y.height,X=!0)}else{const{colgroup:P}=l;if(P&&W)if(c&&r){P[n].width-W/a<=this.MIN_TD_WIDTH&&(W=(P[n].width-this.MIN_TD_WIDTH)*a);const Y=p+(l.translateX||0)*a;Y+W<L&&(W=L-Y),P[n].width-=W/a,l.width-=W/a,l.translateX=(l.translateX||0)+W/a,X=!0}else{const Y=P[n].width;W<0&&Y*a+W<this.MIN_TD_WIDTH*a&&(W=this.MIN_TD_WIDTH*a-Y*a);const S=P[n+1]?.width;if(W>0&&S&&S*a-W<this.MIN_TD_WIDTH*a&&(W=S*a-this.MIN_TD_WIDTH*a),n===P.length-1){const Q=p+(l.translateX||0)*a+l.width*a;Q+W>E&&(W=E-Q)}W&&(P.length-1!==n&&(P[n+1].width-=W/a),P[n].width+=W/a,X=!0)}}X&&this.draw.render({isSetCursor:!1}),N.remove(),document.removeEventListener("mousemove",M),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 Id{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(`${j}-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 Cd{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,R=e.label?.color||a,h=e.label?.borderRadius||c,g=e.label?.padding||d;t.save(),t.font=e.style;const{width:T,height:f,boundingBoxAscent:p}=e.metrics;t.fillStyle=u,this._drawRoundedRect(t,n,i-p,T,f+(g[0]+g[3])*l,h*l),t.fill(),t.fillStyle=R,t.fillText(e.value,n+g[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 Ld{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,pi(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)this.activeInlineEditor?.elementId===e.id&&this._syncInlineEditorPosition(),c==="select"?this._renderSelectControl(t,e,n,i,d):this._renderTextControl(t,e,n,i,d);else{const R=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,R)}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 R=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,R)}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){if(this.draw.getMode()!==s.EditorMode.FORM||t.type!=="customMacro")return!1;const n=this._ensureMacroConfig(t),i=n.type||"text",l=this.activeInlineEditor;if(l&&l.elementId===t.id&&l.type===i)return l.input.focus(),l.input instanceof HTMLInputElement&&l.input.select(),!0;this.clearInlineEditor({isSubmitHistory:!1});const r=document.createElement("div");r.style.position="absolute",r.style.zIndex="1002",r.style.boxSizing="border-box",r.style.display="flex",r.style.alignItems="center";const a=this._getInlineEditorBaseStyle(t);let c;i==="select"?c=this._createSelectEditor(t,r):c=this._createTextEditor(t,r),c.style.boxSizing="border-box",c.style.width="100%",c.style.height="100%",c.style.border="none",c.style.outline="none",c.style.background="transparent",c.style.font=a.font,c.style.color=a.color,c.style.padding=a.padding,c.style.margin="0",r.append(c),r.addEventListener("mousedown",u=>u.stopPropagation()),r.addEventListener("click",u=>u.stopPropagation()),this.draw.getContainer().append(r),this.draw.setOverlayActive(!0);const d=u=>{const R=u.target;R instanceof Node&&r.contains(R)||this.clearInlineEditor()};return document.addEventListener("mousedown",d,!0),this.activeInlineEditor={elementId:t.id,index:e,type:i,wrapper:r,input:c,initialValue:n.value||"",initialCode:n.code,outsideHandler:d},this._syncInlineEditorPosition(),c.focus(),c instanceof HTMLInputElement?c.select():"showPicker"in c&&typeof c.showPicker=="function"?c.showPicker():c.click(),!0}clearInlineEditor(t={}){const e=this.activeInlineEditor;if(!e)return;const{isSubmitHistory:n=!0,isRestore:i=!1}=t;document.removeEventListener("mousedown",e.outsideHandler,!0);const l=this._getInlineEditorElement(e),r=l?.macroConfig,a=e.input.value||"",c=e.input instanceof HTMLSelectElement&&e.input.value||"";if(l&&r&&(i?(r.value=e.initialValue,e.type==="select"&&(r.code=e.initialCode)):e.type==="text"?r.value=a:(r.code=c||void 0,r.value=this._getSelectLabelByCode(r,c))),e.wrapper.remove(),this.activeInlineEditor=null,this.draw.setOverlayActive(!1),l&&!i){const d=this._ensureMacroConfig(l),u=d.value||"",R=d.code;u!==e.initialValue||R!==e.initialCode?this.draw.getCommand().setMacroValue({id:l.id,dictCode:l.dictCode,label:l.label,areaId:l.areaId,value:u,code:R,isSubmitHistory:n}):this.draw.render({isSubmitHistory:!1,isSetCursor:!1})}else this.draw.render({isSubmitHistory:!1,isSetCursor:!1})}_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,R;d?(u="#722ed1",R="#f9f0ff"):c?(u="#52c41a",R="#f6ffed"):a?(u="#fa8c16",R="#fff7e6"):(u="#1677ff",R="#e6f4ff"),t.save(),t.font=e.style;const h=t.measureText(l),g=h.actualBoundingBoxAscent+h.actualBoundingBoxDescent,T=8*r,f=4*r,p=4*r,m=h.width+T*2,C=g+f*2,I=e.metrics,L=n,E=i-I.boundingBoxAscent+(I.boundingBoxAscent+I.boundingBoxDescent-C)/2;t.fillStyle=R,this._drawRoundedRect(t,L,E,m,C,p),t.fill(),t.fillStyle=u,t.textBaseline="middle",t.fillText(l,n+T,E+C/2),t.restore()}_renderTextControl(t,e,n,i,l){const{scale:r,control:a,strikeoutColor:c}=this.options,{placeholderColor:d,bracketColor:u}=a;t.save(),t.font=e.style;const h=`请输入${e.label||""}`,g=l||h,f=t.measureText(g).width;t.fillStyle=u,t.textBaseline="alphabetic",t.fillText("[",n,i);const p=n+t.measureText("[").width;t.fillStyle=l?e.color||"#000000":d,t.fillText(g,p,i);const m=p+f;if(t.fillStyle=u,t.fillText("]",m,i),e.type==="reusableItem"){const C=t.measureText("[").width+f+t.measureText("]").width;if(t.lineWidth=r,this.draw.getMode()===s.EditorMode.PRINT?t.strokeStyle="transparent":t.strokeStyle=c||"red",e.strikeout){const I=i-3*r,L=i+3.5*r;t.beginPath(),t.moveTo(n,I),t.lineTo(n+C,I),t.stroke(),t.beginPath(),t.moveTo(n,L),t.lineTo(n+C,L),t.stroke()}else if(e.underline&&e.textDecoration?.style==="double"){const I=Math.floor(i+2*r)+.5,L=3*r;t.beginPath(),t.moveTo(n,I),t.lineTo(n+C,I),t.stroke(),t.beginPath(),t.moveTo(n,I+L),t.lineTo(n+C,I+L),t.stroke()}}t.restore()}_renderSelectControl(t,e,n,i,l){const{scale:r,control:a}=this.options,{placeholderColor:c,bracketColor:d}=a;t.save(),t.font=e.style;const R=`请选择${e.label||""}`,h=l||R,g=t.measureText(h),T=g.actualBoundingBoxAscent+g.actualBoundingBoxDescent;t.fillStyle=d,t.textBaseline="alphabetic",t.fillText("[",n,i);const f=n+t.measureText("[").width;t.fillStyle=l?e.color||"#000000":c,t.fillText(h,f,i);const p=f+g.width+2*r,m=i-T/2;t.beginPath(),t.moveTo(p,m-2*r),t.lineTo(p+5*r,m-2*r),t.lineTo(p+2.5*r,m+2*r),t.closePath(),t.fillStyle="#666666",t.fill();const C=p+6*r;t.fillStyle=d,t.fillText("]",C,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()}_createTextEditor(t,e){const n=document.createElement("input");return n.type="text",n.value=t.macroConfig?.value||"",n.placeholder=`请输入${t.label||""}`,n.style.minWidth="0",n.style.background="#ffffff",n.addEventListener("input",()=>{const i=this._ensureMacroConfig(t);i.value=n.value}),n.addEventListener("keydown",i=>{i.key==="Enter"?(i.preventDefault(),this.clearInlineEditor()):i.key==="Escape"&&(i.preventDefault(),this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0}))}),n.addEventListener("blur",()=>{this.activeInlineEditor?.input===n&&this.clearInlineEditor()}),e.style.background="#ffffff",e.style.border="1px solid #1677ff",e.style.borderRadius="4px",e.style.boxShadow="0 0 0 2px rgba(22, 119, 255, 0.12)",n}_createSelectEditor(t,e){const n=document.createElement("select"),i=this._ensureMacroConfig(t),l=document.createElement("option");return l.value="",l.textContent=`请选择${t.label||""}`,n.append(l),i.items?.forEach(r=>{const a=document.createElement("option");a.value=r.code,a.textContent=r.value,n.append(a)}),n.value=i.code||i.items?.find(r=>r.value===i.value)?.code||"",n.addEventListener("change",()=>{i.code=n.value||void 0,i.value=this._getSelectLabelByCode(i,n.value),this.clearInlineEditor()}),n.addEventListener("keydown",r=>{r.key==="Escape"?(r.preventDefault(),this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0})):r.key==="Enter"&&(r.preventDefault(),this.clearInlineEditor())}),n.addEventListener("blur",()=>{this.activeInlineEditor?.input===n&&this.clearInlineEditor()}),e.style.background="#ffffff",e.style.border="1px solid #1677ff",e.style.borderRadius="4px",e.style.boxShadow="0 0 0 2px rgba(22, 119, 255, 0.12)",n}_syncInlineEditorPosition(){const t=this.activeInlineEditor;if(!t)return;const e=this._getInlineEditorPosition(t);if(!e){this.clearInlineEditor({isSubmitHistory:!1});return}const n=e.pageNo*(this.draw.getHeight()+this.draw.getPageGap()),[i,l]=e.coordinate.leftTop,r=Math.max(e.lineHeight,e.metrics.height),a=Math.max(e.metrics.width,80*this.options.scale),c=Math.max(0,(e.lineHeight-r)/2);t.wrapper.style.left=`${i}px`,t.wrapper.style.top=`${l+n+c}px`,t.wrapper.style.width=`${a}px`,t.wrapper.style.height=`${r}px`}_getInlineEditorBaseStyle(t){return{font:this.draw.getElementFont(t),color:t.color||"#000000",padding:`0 ${6*this.options.scale}px`}}_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}_getSelectLabelByCode(t,e){return e&&t.items?.find(n=>n.code===e)?.value||""}}class Pd{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=Ci(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*Is[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 Ed{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 Md{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 Od{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 Sd{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,R=r*d,h=e.width*d,g=this.draw.getDefaultBasicRowMarginHeight()*u;t.save(),t.font=`${R}px ${l}`;const T=t.measureText(c),f=(h-T.width)/2;t.setLineDash(a),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,i),t.lineTo(n+f,i),t.moveTo(n+f+T.width,i),t.lineTo(n+h,i),t.stroke(),t.fillText(c,n+f,i+T.actualBoundingBoxAscent-R/2),t.restore()}}class Xd{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:R}=this.options,h=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=i,t.font=`${r*R}px ${l}`;let T=n;const f=new RegExp($n.PAGE_NO);f.test(T)&&(T=Un.formatNumberPlaceholder(T,e+1,f,u));const p=new RegExp($n.PAGE_COUNT);p.test(T)&&(T=Un.formatNumberPlaceholder(T,this.draw.getPageCount(),p,u));const m=t.measureText(T);if(c){const C=this.draw.getPagePixelRatio(),I=document.createElement("canvas"),L=I.getContext("2d"),E=m.width,O=m.actualBoundingBoxAscent+m.actualBoundingBoxDescent,F=Math.sqrt(Math.pow(E,2)+Math.pow(O,2)),V=F+2*d[0]*R,D=F+2*d[1]*R;I.width=V,I.height=D,I.style.width=`${V*C}px`,I.style.height=`${D*C}px`,L.translate(V/2,D/2),L.rotate(-45*Math.PI/180),L.translate(-V/2,-D/2),L.font=`${r*R}px ${l}`,L.fillStyle=a,L.fillText(T,(V-E)/2,(D-O)/2+m.actualBoundingBoxAscent);const b=t.createPattern(I,"repeat");b&&(t.fillStyle=b,t.fillRect(0,0,h,g))}else{const C=h/2,I=g/2;t.fillStyle=a,t.translate(C,I),t.rotate(-45*Math.PI/180),t.fillText(T,-m.width/2,m.actualBoundingBoxAscent-r*R/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 g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=i,g.onload=()=>{this.imageCache.set(i,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const d=this.draw.getWidth(),u=this.draw.getHeight(),R=e*c,h=n*c;if(t.save(),t.globalAlpha=l,r){const g=this.draw.getPagePixelRatio(),T=document.createElement("canvas"),f=T.getContext("2d"),p=Math.sqrt(Math.pow(R,2)+Math.pow(h,2)),m=p+2*a[0]*c,C=p+2*a[1]*c;T.width=m,T.height=C,T.style.width=`${m*g}px`,T.style.height=`${C*g}px`,f.translate(m/2,C/2),f.rotate(-45*Math.PI/180),f.translate(-m/2,-C/2),f.drawImage(this.imageCache.get(i),(m-R)/2,(C-h)/2,R,h);const I=t.createPattern(T,"repeat");I&&(t.fillStyle=I,t.fillRect(0,0,d,u))}else{const g=d/2,T=u/2;t.translate(g,T),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(i),-R/2,-h/2,R,h)}t.restore()}render(t,e){this.options.watermark.type===s.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class Nd{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.isPrintMode(),u=this.draw.getMode(),R=u===s.EditorMode.EDIT||u===s.EditorMode.FORM,h=this.control.getActiveControl()?.getElement(),g=this._getControlType(t,e);let T=!1,f=!1,p=!1,m=!1;c.highlight||(T=!d&&!!n&&!!h&&c.controlId===h.controlId&&!this.control.getIsRangeInPostfix()),T||(f=!d&&!!i&&!!c.control?.disabled),f||(p=!d&&!!l&&!!c.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),p||(m=!d&&!!r&&!!c.controlId&&!this.control.getIsExistValueByElementListIndex(t,e));const C=R&&!!a&&(g===s.ControlType.NUMBER||g===s.ControlType.SELECT||g===s.ControlType.DATE);return(T?n:"")||(f?i:"")||(p?l:"")||(m?r:"")||(C?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.NUMBER||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 T=r.trList;for(let f=0;f<T.length;f++){const p=T[f];for(let m=0;m<p.tdList.length;m++){const C=p.tdList[m],I={tableId:r.id,tableIndex:l-1,trIndex:f,tdIndex:m,tdId:C.id};e(C.value,I)}}}const a=r?.control;if(!a)continue;const c=this.highlightList.findIndex(T=>T.id===r.controlId||a.conceptId&&a.conceptId===T.conceptId);if(!~c)continue;const d=l;let u=l;for(;u<n.length&&n[u].controlId===r.controlId;)u++;l=u;const R=n.slice(d,u).map(T=>T.controlComponent===s.ControlComponent.VALUE?T:{value:K}),h=this.highlightList[c],{ruleList:g}=h;for(let T=0;T<g.length;T++){const f=g[T],p=t.getMatchList(f.keyword,R);this.highlightMatchResult.push(...p.map(m=>({...m,...f,...i,index:m.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:C,trIndex:I,tdIndex:L,index:E}=c;d=r[C]?.trList[I].tdList[L]?.positionList[E]}else d=l[c.index];if(!d)continue;const{coordinate:{leftTop:u,leftBottom:R,rightTop:h},pageNo:g}=d;if(g!==e)continue;t.fillStyle=c.backgroundColor||i,t.globalAlpha=c.alpha||n;const T=u[0],f=u[1],p=h[0]-u[0],m=R[1]-u[1];t.fillRect(T,f,p,m)}t.restore()}}const ar={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)"}},Fd="#ff4d4f",yd=5e3,Di=4;class bd{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})},yd))}getMarks(){return this.marks}render(t,e,n,i,l,r){if(!this.marks.length||this.draw.isPrintMode())return;const a=this._getRegions(e,n,i,l,r);if(a.length){t.save();for(let c=0;c<a.length;c++){const d=a[c],u=this._getStyle(d.mark),R=Math.max(1,this.options.scale),h=d.x-R,g=d.y-R,T=Math.max(1,d.width+R*2),f=Math.max(1,d.height+R*2),p=Math.max(2,this.options.scale*2);if(this.underlineVisible&&u.borderColor&&d.hasUnderline&&(t.lineWidth=p,t.strokeStyle=u.borderColor,t.beginPath(),t.moveTo(d.underlineX,d.underlineY),t.lineTo(d.underlineRight,d.underlineY),t.stroke()),d.drawRequired){this._renderRequiredMark(t,d,h);continue}if(u.borderColor){t.lineWidth=p;const m=Math.min(Math.max(8*this.options.scale,f*.3),f/2),C=h+T,I=g+f;t.beginPath(),d.drawLeft&&(t.moveTo(h+m,g),t.lineTo(h,g),t.lineTo(h,I)),d.drawRight&&(t.moveTo(C-m,I),t.lineTo(C,I),t.lineTo(C,g)),t.stroke()}}t.restore()}}_getRegions(t,e,n,i,l){const r=this._getParentMap(t),a=this.marks.map(R=>this._getTargetControlIds(t,R)),c=a.map(R=>this._getTitleTargets(t,R)),d=[];for(let R=0;R<n.length;R++){const h=n[R],g=new Map;for(let T=0;T<h.elementList.length;T++){const f=h.elementList[T],p=h.startIndex+T,m=e[p];if(!m||l===s.EditorZone.MAIN&&m.pageNo!==i)continue;const C=this._getTargetIdsForElement(f.controlId,a,r);for(let P=0;P<c.length;P++){const Y=c[P].get(p);Y&&Y.forEach(S=>{C.some(U=>U.markIndex===P&&U.controlId===S)||C.push({markIndex:P,controlId:S})})}if(!C.length)continue;const I=m.coordinate.leftTop,L=m.coordinate.rightTop,E=m.coordinate.leftBottom,O=m.coordinate.rightBottom,F=Math.min(I[0],E[0]),V=Math.max(L[0],O[0]),D=Math.min(I[1],L[1]),b=Math.max(E[1],O[1]),N=m.metrics.boundingBoxAscent+m.metrics.boundingBoxDescent,W=D+m.ascent-m.metrics.boundingBoxAscent,y=N>0?W:D,M=N>0?W+N:b,X=this._isButtonElement(f);for(let P=0;P<C.length;P++){const{markIndex:Y,controlId:S}=C[P],U=`${Y}:${S}:${h.startIndex}`,Q=g.get(U),v={x:F,y,right:V,bottom:M};if(Q){const w=this._mergeBounds(Q,v);Q.x=w.x,Q.y=w.y,Q.width=Math.max(1,w.right-w.x),Q.height=Math.max(1,w.bottom-w.y),X||(Q.hasUnderline?(Q.underlineX=Math.min(Q.underlineX,F),Q.underlineY=Math.max(Q.underlineY,M+Di),Q.underlineRight=Math.max(Q.underlineRight,V)):(Q.underlineX=F,Q.underlineY=M+Di,Q.underlineRight=V),Q.hasUnderline=!0)}else g.set(U,{mark:this.marks[Y],targetKey:`${Y}:${S}`,x:F,y,width:Math.max(1,V-F),height:Math.max(1,M-y),baseline:D+m.ascent,font:f.style||this.draw.getElementFont(f,this.options.scale),underlineX:F,underlineY:M+Di,underlineRight:V,hasUnderline:!X,drawLeft:!1,drawRight:!1,drawRequired:!1})}}d.push(...g.values())}const u=new Map;for(let R=0;R<d.length;R++){const h=d[R],g=u.get(h.targetKey)||[];g.push(h),u.set(h.targetKey,g)}return u.forEach(R=>{this._isRequiredMark(R[0].mark)?R[0].drawRequired=!0:(R[0].drawLeft=!0,R[R.length-1].drawRight=!0)}),d}_renderRequiredMark(t,e,n){t.save(),t.font=e.font,t.fillStyle=e.mark.style?.borderColor||Fd,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];i.controlId&&i.originControlId&&e.set(i.controlId,i.originControlId)}return e}_getTitleTargets(t,e){const n=new Map;return e.forEach(i=>{const l=t.findIndex(R=>R.controlId===i);if(l<0)return;const r=t[l].control,a=this._getTitleTextBefore(t,l);if(!a)return;const c=[r?.label,r?.placeholder].filter(Boolean).map(R=>this._normalizeTitleText(R)),d=this._normalizeTitleText(a);if(!c.some(R=>R===d||R.includes(d)||d.includes(R)))return;let u=l-1;for(;u>=0&&this._isTitleValueElement(t[u]);){let R=n.get(u);R||(R=new Set,n.set(u,R)),R.add(i),u--}}),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];!r.controlId||!r.control||(i==="id"&&r.controlId===e.id||i==="conceptId"&&r.control.conceptId===e.conceptId||i==="code"&&r.control.code===e.code)&&n.add(r.controlId)}return n}_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{...ar[t.type?.toLowerCase()||"error"]||ar.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 Dd{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 jn{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&&!Os(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&&!Ce.includes(d.type)||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT?ie(d,["control","controlId",...Re]):Ie(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};re(i,[g],r,{editorOptions:this.options}),c.spliceElementList(i,R+h,0,[g])}return R+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 g=l[u];if(g.controlId!==a.controlId||g.controlComponent===s.ControlComponent.PREFIX||g.controlComponent===s.ControlComponent.PRE_TEXT){c=u;break}u--}let R=r+1;for(;R<l.length;){const g=l[R];if(g.controlId!==a.controlId||g.controlComponent===s.ControlComponent.POSTFIX||g.controlComponent===s.ControlComponent.POST_TEXT){d=R-1;break}R++}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&&Ms(d,a)){this.control.repaintControl({curIndex:l.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const R=r.valueSets;if(!Array.isArray(R)||!R.length)return;const h=this.getText(a);if(!h){if(c){const L=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~L&&(this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],T=g?ie(g,Ne):ie(i[l.startIndex],Re),f=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~f)return;c||this.control.removePlaceholder(f,e);const p=Ie(i[f],Ne),m=f+1,C=yt(h),I=this.control.getDraw();for(let L=0;L<C.length;L++){const E={...T,...p,type:s.ElementType.TEXT,value:C[L],controlComponent:s.ControlComponent.VALUE};(E.color===this.options.control.bracketColor||E.color===this.options.control.placeholderColor)&&(E.color=this.options.defaultColor),re(i,[E],f,{editorOptions:this.options}),I.spliceElementList(i,m+L,0,[E])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:f,endIndex:f}}),!e.range){const L=m+C.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(`${j}-select-control-popup`),i.setAttribute(Ue,s.EditorComponent.POPUP);const l=document.createElement("ul");let r=null;for(let h=0;h<e.length;h++){const g=e[h],T=document.createElement("li");let f=this.getCodes();f.includes(g.code)&&(T.classList.add("active"),r=T),T.onclick=()=>{const p=f.findIndex(m=>m===g.code);t.isMultiSelect?~p?f.splice(p,1):f.push(g.code):~p?f=[]:f=[g.code],this.setSelect(f.join(this.VALUE_DELIMITER))},T.append(document.createTextNode(g.value)),l.append(T)}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&&Xs(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 cr;function st(){return cr.apply(null,arguments)}function Vd(o){cr=o}function ye(o){return o instanceof Array||Object.prototype.toString.call(o)==="[object Array]"}function Ln(o){return o!=null&&Object.prototype.toString.call(o)==="[object Object]"}function Qt(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function Vi(o){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(o).length===0;var t;for(t in o)if(Qt(o,t))return!1;return!0}function me(o){return o===void 0}function $e(o){return typeof o=="number"||Object.prototype.toString.call(o)==="[object Number]"}function qn(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 un(o,t){for(var e in t)Qt(t,e)&&(o[e]=t[e]);return Qt(t,"toString")&&(o.toString=t.toString),Qt(t,"valueOf")&&(o.valueOf=t.valueOf),o}function Ae(o,t,e,n){return wr(o,t,e,n,!0).utc()}function Wd(){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 Mt(o){return o._pf==null&&(o._pf=Wd()),o._pf}var Wi;Array.prototype.some?Wi=Array.prototype.some:Wi=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 Yi(o){var t=null,e=!1,n=o._d&&!isNaN(o._d.getTime());if(n&&(t=Mt(o),e=Wi.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 No(o){var t=Ae(NaN);return o!=null?un(Mt(t),o):Mt(t).userInvalidated=!0,t}var ur=st.momentProperties=[],Ui=!1;function wi(o,t){var e,n,i,l=ur.length;if(me(t._isAMomentObject)||(o._isAMomentObject=t._isAMomentObject),me(t._i)||(o._i=t._i),me(t._f)||(o._f=t._f),me(t._l)||(o._l=t._l),me(t._strict)||(o._strict=t._strict),me(t._tzm)||(o._tzm=t._tzm),me(t._isUTC)||(o._isUTC=t._isUTC),me(t._offset)||(o._offset=t._offset),me(t._pf)||(o._pf=Mt(t)),me(t._locale)||(o._locale=t._locale),l>0)for(e=0;e<l;e++)n=ur[e],i=t[n],me(i)||(o[n]=i);return o}function to(o){wi(this,o),this._d=new Date(o._d!=null?o._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),Ui===!1&&(Ui=!0,st.updateOffset(this),Ui=!1)}function be(o){return o instanceof to||o!=null&&o._isAMomentObject!=null}function Rr(o){st.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+o)}function Me(o,t){var e=!0;return un(function(){if(st.deprecationHandler!=null&&st.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+=`
106
+ `,K),{startIndex:Q,endIndex:v}=T.getRange(),w=T.getRangeAnchorStyle(W,Q);if(!w)return;const x=Q>0?W[Q-1]:null,rt=!!(w.controlId||w.control),k={...!rt&&x?x:w,...b},ot=i.isDesignMode(),it=W[v+1],Wt=dn(W,w.originControlId,i.getMode()),Kt=dn(W,it?.originControlId,i.getMode()),ne=!w.originControlId&&!it?.originControlId&&Fe(w)&&Xo(it)&&!!w.controlId&&!!it.controlId&&w.controlId!==it.controlId,ce=zn(w)&&Si(it)&&!Wt&&!Kt,H=i.getMode()===s.EditorMode.EDIT?ir(W,w,it):void 0,$=!!w.originControlId&&Fe(w)&&it?.controlId===w.originControlId&&!it.originControlId&&it.control?.type===s.ControlType.TEXTFIELD&&Fe(it),_=!!w.originControlId&&Fe(w)&&it?.controlId===w.originControlId&&!it.originControlId&&it.control?.type===s.ControlType.TEXTFIELD&&it.controlComponent===s.ControlComponent.VALUE,ct=!!Wt&&Wt===Kt&&!!w.controlId&&!!it?.controlId&&w.controlId!==it.controlId&&(zn(w)||Si(it))?Wt:null;if(D&&(ne||ce))return;const nt=Xo(it)&&!it?.originControlId,ut=Fe(w)&&!w.originControlId||w.type===s.ElementType.CONTROL&&w.controlComponent===s.ControlComponent.VALUE&&it?.type!==s.ElementType.CONTROL&&!w.originControlId,mt=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],Lt=(Ct,q)=>!!(Ct?.controlId&&Ct.controlId===q?.controlId&&(Ct.originControlId||null)===(q.originControlId||null)),wt=(Ct,q)=>{if(Ct?.control?.type)return Ct.control.type;if(Ct?.controlId){for(let Dt=q;Dt>=0;Dt--){const at=W[Dt];if(!Lt(Ct,at))break;if(at.control?.type)return at.control.type}for(let Dt=q+1;Dt<W.length;Dt++){const at=W[Dt];if(!Lt(Ct,at))break;if(at.control?.type)return at.control.type}}},_t=(Ct,q)=>{const Dt=wt(Ct,q);return!!(Dt&&mt.includes(Dt))},Ot=Ct=>{const q=W[Ct];let Dt=Ct;for(let at=Ct+1;at<W.length&&Lt(q,W[at]);at++)Dt=at;return Dt},Gt=!!(_t(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&!w.originControlId&&Lt(w,it)&&Fe(it)&&!it?.value),Yt=!!(_t(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&w.originControlId&&Lt(w,it)&&Fe(it))?dn(W,w.originControlId,i.getMode()):null,St=or(W,Yt),Pt=nt||ut||Gt,oe=Pt?{...w,type:void 0,control:void 0,controlId:void 0,controlComponent:void 0,originControlId:void 0,color:r.defaultColor,highlight:void 0}:w,Et=Pt||rt?oe:k,Ht=yt(U).map(Ct=>{const q={value:Ct};if(ot||!Et.title?.disabled&&!Et.control?.disabled){const Dt=W[v+1];(!Et.type||Et.type===y||Et.type===M&&Dt?.type===M||Et.type===Y&&Dt?.type===Y||Et.type===X&&Dt?.type===X||Et.type===P&&Dt?.type===P)&&Ra.forEach(at=>{if(at==="groupIds"&&!Dt?.groupIds)return;const kt=Et[at];kt!==void 0&&(q[at]=kt)}),(b||Et.type===S)&&Ne.forEach(at=>{const kt=b?.[at]||Et[at];kt!==void 0&&(q[at]=kt)}),g&&(q.underline=!0)}if(!Pt){const Dt=w.originControlId&&(w.controlComponent===s.ControlComponent.POSTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||w.controlComponent===s.ControlComponent.POST_TEXT);if($||_||H){const B=H||it;q.controlId=B.controlId,q.control=B.control,q.controlComponent=s.ControlComponent.VALUE,delete q.originControlId,Xi(q,B.control,r.defaultColor)}const at=!w.originControlId&&w.controlId&&(w.controlComponent===s.ControlComponent.POSTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX||w.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||w.controlComponent===s.ControlComponent.POST_TEXT)&&it?.controlId&&it.controlId!==w.controlId&&_c(w,it),kt=w.controlId&&w.originControlId&&(w.controlComponent===s.ControlComponent.VALUE||w.controlComponent===s.ControlComponent.PLACEHOLDER);if(!$&&!_&&!H&&Dt&&!q.controlId){const B=dn(W,w.originControlId,i.getMode());if(!B)return q;let et=null;for(let ft=Q;ft>=0;ft--){const lt=W[ft];if(Je(lt,B)&&lt.control){et=lt.control;break}}q.controlId=B,q.controlComponent=s.ControlComponent.VALUE,et&&(q.control=et),Xi(q,et,r.defaultColor)}else if(at&&!q.controlId){if(it?.controlId&&it.controlId!==w.controlId)if(it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX)for(let B=Q;B>=0;B--){const et=W[B];if(et.controlId===w.controlId&&(et.controlComponent===s.ControlComponent.PREFIX||et.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let ft=B-1;ft>=0;ft--){const lt=W[ft];if(lt.controlId&&lt.controlId!==w.controlId&&(lt.controlComponent===s.ControlComponent.PRETEXTFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRE_TEXT)){q.controlId=lt.controlId,q.controlComponent=s.ControlComponent.VALUE,lt.control&&(q.control=lt.control);break}if(lt.controlId&&lt.controlId!==w.controlId&&(lt.controlComponent===s.ControlComponent.POSTFIX||lt.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}else(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX)&&(q.controlId=it.controlId,q.controlComponent=s.ControlComponent.VALUE,it.control&&(q.control=it.control));if(!q.controlId)for(let B=Q;B>=0;B--){const et=W[B];if(et.controlId===w.controlId&&(et.controlComponent===s.ControlComponent.PREFIX||et.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let ft=B-1;ft>=0;ft--){const lt=W[ft];if(lt.controlId&&lt.controlId!==w.controlId&&(lt.controlComponent===s.ControlComponent.PRETEXTFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRE_TEXT)){q.controlId=lt.controlId,q.controlComponent=s.ControlComponent.VALUE,lt.control&&(q.control=lt.control);break}if(lt.controlId&&lt.controlId!==w.controlId&&(lt.controlComponent===s.ControlComponent.POSTFIX||lt.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}}else if(kt&&!q.controlId){const B=w.controlId;let et=w.control;if(!et)for(let ft=Q;ft>=0;ft--){const lt=W[ft];if(lt.controlId===B&&lt.control&&(et=lt.control,lt.controlComponent===s.ControlComponent.PREFIX||lt.controlComponent===s.ControlComponent.PRETEXTFIX))break}q.controlId=B,q.originControlId=w.originControlId,q.controlComponent=s.ControlComponent.VALUE,et&&(q.control=et)}else if(w.controlId){let B=w.control;if(!B)for(let et=Q;et>=0;et--){const ft=W[et];if(Je(ft,w.controlId)&&ft.control){B=ft.control;break}}q.controlId||(q.controlId=w.controlId),B&&!q.control&&(q.control=B),q.controlComponent||(q.controlComponent=s.ControlComponent.VALUE)}else if(!q.controlId&&!q.control&&it?.originControlId&&(it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX)){const B=dn(W,it.originControlId,i.getMode());if(!B)return q;let et=null;for(let ft=v;ft>=0;ft--){const lt=W[ft];if(Je(lt,B)&&lt.control){et=lt.control;break}}q.controlId=B,q.controlComponent=s.ControlComponent.VALUE,et&&(q.control=et)}}if(Ct&&Ct!==K){const Dt=Hc(Ct,r.defaultFont);q.font=Dt}return q});let It;const Xt=a[u],Ft=a[u+1],pe=a[u-1];if(g)It=Q;else{const Ct=B=>{if(Ht?.length)for(let et=0;et<Ht.length;et++)W.splice(B+et,0,Ht[et]);return B+Ht.length-1},q=Q+1,Dt=Gt?Ot(Q)+1:q,at=()=>{let B=null,et,ft=null;const lt=i.getMode()===s.EditorMode.EDIT?ir(a,Xt,Ft):void 0;if(lt?.controlId?(B=lt.controlId,et=lt.control?.type):i.getMode()===s.EditorMode.EDIT&&zn(Xt)&&Ft?.controlId===Xt.originControlId&&!Ft.originControlId&&Ft.control?.type===s.ControlType.TEXTFIELD&&(Ft.controlComponent===s.ControlComponent.VALUE||Fe(Ft))?(B=Xt.originControlId,et=s.ControlType.TEXTFIELD):zn(Xt)?B=dn(a,Xt.originControlId,i.getMode()):Si(Ft)?B=dn(a,Ft.originControlId,i.getMode()):ct?B=ct:Xt?.control?.type===s.ControlType.TEXT&&Xt.controlId&&!Xt.originControlId&&Fe(Xt)&&pe?.originControlId===Xt.controlId&&(B=Xt.controlId,ft={startIndex:u-1,endIndex:u-1}),!B)return null;if(!et)for(let xt=u;xt>=0;xt--){const zt=a[xt];if(Je(zt,B)&&zt.control?.type){et=zt.control.type;break}if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}return et!==s.ControlType.TEXT&&!(i.getMode()===s.EditorMode.EDIT&&et===s.ControlType.TEXTFIELD)?null:{parentControlId:B,activationIndex:(()=>{for(let xt=u+1;xt<a.length;xt++){const zt=a[xt];if(Je(zt,B))return xt;if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}for(let xt=u;xt>=0;xt--){const zt=a[xt];if(Je(zt,B))return xt;if(zt.controlId&&zt.controlId!==B&&zt.originControlId!==B)break}return u})(),boundaryRange:ft}};Q!==v&&(i.removeSplitTdOtherRangeElements(),i.spliceElementList(W,q,v-Q));const kt=at();if(Yt&&St?.control){const B=Ot(Q);Ht.forEach(et=>{Ni(et,Yt,St.control,r.defaultColor)}),re(W,Ht,B,{editorOptions:r}),i.spliceElementList(W,B+1,0,Ht),It=B+Ht.length}else if(kt){const{parentControlId:B,activationIndex:et,boundaryRange:ft}=kt;m(et,et),p();const lt=l.getActiveControl(),de=Ft?.controlId===B&&!Ft?.originControlId&&Ft?.controlComponent===s.ControlComponent.VALUE?u+1:-1,xt=!!(Xt?.originControlId&&zn(Xt)&&de!==-1),zt=ft||(xt?{startIndex:u,endIndex:u}:de!==-1?{startIndex:u,endIndex:de}:{startIndex:Q,endIndex:v});m(zt.startIndex,zt.endIndex),lt&&lt.getElement()?.controlId===B&&(lt.getElement()?.control?.type===s.ControlType.TEXT||lt.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Ht.forEach(xn=>{Ni(xn,B,lt.getElement().control,r.defaultColor)}),It=lt.setValue(Ht,{range:zt,elementList:W}),l.emitControlContentChange(),m(It,It),p()):Pt?It=Ct(Dt):(It=l.setValue(Ht),l.emitControlContentChange())}else if(Pt)It=Ct(Dt);else if(Xt?.originControlId&&(Xt.controlComponent===s.ControlComponent.POSTFIX||Xt.controlComponent===s.ControlComponent.POST_TEXT||Xt.controlComponent===s.ControlComponent.POSTTEXTFIX||Xt.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))if(C?.getElement()?.control?.type===s.ControlType.TEXT&&C.getElement()?.controlId===Xt.controlId&&(C.getElement()?.originControlId||null)===(Xt.originControlId||null))It=l.setValue(Ht),l.emitControlContentChange();else{const et=dn(a,Xt.originControlId,i.getMode());if(!et){It=Ct(q);return}let ft;for(let de=u;de>=0;de--){const xt=a[de];if(Je(xt,et)&&xt.control?.type){ft=xt.control.type;break}if(xt.controlId&&xt.controlId!==et&&xt.originControlId!==et)break}if(ft===s.ControlType.TEXT||i.getMode()===s.EditorMode.EDIT&&ft===s.ControlType.TEXTFIELD){const de=()=>{for(let Pe=u+1;Pe<a.length;Pe++){const We=a[Pe];if(Je(We,et))return Pe;if(We.controlId&&We.controlId!==et&&We.originControlId!==et)break}for(let Pe=u;Pe>=0;Pe--){const We=a[Pe];if(Je(We,et))return Pe;if(We.controlId&&We.controlId!==et&&We.originControlId!==et)break}return u},xt=Ft?.controlId===et&&Ft?.controlComponent===s.ControlComponent.VALUE?u+1:-1,zt=xt!==-1?{startIndex:u,endIndex:xt}:{startIndex:u,endIndex:u},xn=de();m(xn,xn),p();const gn=l.getActiveControl();m(zt.startIndex,zt.endIndex),gn&&gn.getElement()?.controlId===et&&(gn.getElement()?.control?.type===s.ControlType.TEXT||gn.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Ht.forEach(Pe=>{Ni(Pe,et,gn.getElement().control,r.defaultColor)}),It=gn.setValue(Ht,{range:zt,elementList:W}),l.emitControlContentChange(),m(It,It),p()):It=Ct(q)}else It=Ct(q)}else if((Xt?.control?.type===s.ControlType.NUMBER||Ft?.control?.type===s.ControlType.NUMBER)&&C?.getElement()?.control?.type===s.ControlType.NUMBER&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),It=Q}else if((Xt?.control?.type===s.ControlType.SELECT||Ft?.control?.type===s.ControlType.SELECT)&&C?.getElement()?.control?.type===s.ControlType.SELECT&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),It=Q}else if(C?.getElement()?.control?.type===s.ControlType.DATE&&l.getIsRangeWithinControl()){const B=l.getActiveControl();B&&typeof B.awake=="function"&&B.awake(),It=Q}else Xt?.control?.type==="button"||Ft?.control?.type==="button"?It=Q:C&&l.getIsRangeWithinControl()?(It=l.setValue(Ht),l.emitControlContentChange()):(Xt?.type==="control"||Ft?.type==="control")&&!Pt?It=Ct(q):(re(W,Ht,Q,{editorOptions:r}),i.spliceElementList(W,q,0,Ht),It=Q+Ht.length)}if(~It&&!g){const Ct=se()-n,q=se();f(()=>{T.setRange(It,It),i.render({curIndex:It,isSubmitHistory:!g,traceLabel:`input:${e}`})}),ri(r,`input:${e}`,se()-n,[{label:"mutate",duration:Ct},{label:"renderCall",duration:se()-q}],{isComposing:g,textLength:Ht.length,compositionChainDuration:e==="compositionend"&&N!==void 0?Number((se()-N).toFixed(2)):void 0})}g&&(t.compositionInfo={value:U,startIndex:It,endIndex:v,defaultStyle:b,perfStartTime:n})}function Ac(o){o.compositionInfo&&(o.compositionInfo=null)}function Gc(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 kc(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 h=t.getPosition().getPositionList(),g=h[n],T=g.rowNo,f=g.pageNo,p=[];for(let C=0;C<h.length;C++){const I=h[C];if(I.pageNo>f)break;I.pageNo===f&&I.rowNo===T&&p.push(C)}const m=p[0]-1;r=m<0?0:m,a=p[p.length-1]}const c=t.getOptions();await xs(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})}async function xc(o,t){const e=o.getDraw(),{copy:n}=e.getOverride();if(n&&n()?.preventDefault!==!1)return;const i=e.getRange();let l=null;if(i.getRange().isCrossRowCol){const a=i.getRangeTableElement();if(!a)return;const c=e.getTableParticle().getRangeRowCol();if(!c)return;const d={type:s.ElementType.TABLE,value:"",colgroup:[],trList:[]},u=c[0],R=u[0].colIndex,h=u[u.length-1],g=h.colIndex+h.colspan-1;for(let T=R;T<=g;T++)d.colgroup.push(a.colgroup[T]);for(let T=0;T<c.length;T++){const f=c[T],p=a.trList[f[0].rowIndex],m={tdList:[],height:p.height,minHeight:p.minHeight};for(let C=0;C<f.length;C++)m.tdList.push(f[C]);d.trList.push(m)}l=Vt([d])}else l=i.getIsCollapsed()?i.getRangeRowElementList():i.getSelectionElementList();t?.isPlainText&&l?.length&&(l=[{value:In(l,e.getOptions())}]),l?.length&&await xs(l,e.getOptions())}function Bc(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")&&Pi(t,a)}}}function sr(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(h=>!h.type||h.type!==s.ElementType.CONTROL&&Ce.includes(h.type)?h.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,R=-1;for(const{segment:h,index:g,isWordLike:T}of d){const f=g+a;if(T&&r>=f&&r<f+h.length){u=f-1,R=u+h.length;break}}return~u&&~R?{startIndex:u,endIndex:R}:null}function Jc(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=qo.test(n);if(c||l.test(n)){const u=t.getElementList();let R=i-1;for(;R>0;){const g=u[R].value;if(c&&qo.test(g)||!c&&l.test(g))r++,R--;else break}let h=i+1;for(;h<u.length;){const g=u[h].value;if(c&&qo.test(g)||!c&&l.test(g))a++,h++;else break}}const d=i-r-1;return d<0?null:{startIndex:d,endIndex:i+a}}function $c(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});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=sr(o)||Jc(o);r&&(l.setRange(r.startIndex,r.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),l.setRangeStyle())}function zc(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 T=r[d],f=r[d-1];if(T.value===K&&!T.listWrap||T.listId!==f?.listId||T.titleId!==f?.titleId)break;a++,d--}let u=l+1;for(;u<r.length;){const T=r[u],f=r[u+1];if(T.value===K&&!T.listWrap||T.listId!==f?.listId||T.titleId!==f?.titleId)break;c++,u++}const R=t.getRange();let h=l-a-1;if(r[h]?.value!==K&&(h-=1),h<0)return;let g=l+c+1;(r[g]?.value===K||g>r.length-1)&&(g-=1),R.setRange(h,g),t.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}const rr={dblclick:$c,threeClick:zc};function jc(o){o.isComposing=!0}function qc(o,t){const e=se();o.isComposing=!1;const n=o.getDraw(),i=n.getOptions();if(t.data)o.compositionInfo&&(o.compositionInfo.perfStartTime=e),ua?setTimeout(()=>{o.compositionInfo&&Fi(t.data,o,"compositionend")},1):o.compositionInfo&&Fi(t.data,o,"compositionend");else{const r=o.compositionInfo?.cancel;if(Ac(o),!r){const a=n.getRange(),{endIndex:c}=a.getRange();n.render({curIndex:c,isSubmitHistory:!1,traceLabel:"compositionend:empty"})}}n.getCursor().clearAgentDomValue(),ri(i,"compositionend",se()-e,[],{hasData:!!t.data,dataLength:t.data?.length||0})}function td(o){o.compositionInfo&&(o.compositionInfo.cancel=!0)}const yi={compositionstart:jc,compositionend:qc,compositionCancel:td};function ed(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!Cs(o.target,I=>I===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:R,index:h}=d,g=c.getPositionList(),T=u?R:h;~h&&(e.getRange().setRange(T,T),c.setCursorPosition(g[T]));const f=e.getCursor(),{cursor:{dragColor:p,dragWidth:m,dragFloatImageDisabled:C}}=e.getOptions();if(C){const I=t.cacheElementList?.[t.cacheRange.startIndex];if(I?.type===s.ElementType.IMAGE&&(I.imgDisplay===s.ImageDisplay.FLOAT_TOP||I.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM||I.imgDisplay===s.ImageDisplay.SURROUND))return}f.drawCursor({width:m,color:p,isBlink:!1,isFocus:!1})}const nd={dragover:ed};class od{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)),jl(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=sr(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.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()||Oc(t,this)}mousedown(t){this.draw.isInteractionSuspended()||Pc(t,this)}click(){this.draw.isInteractionSuspended()||ca&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){this.draw.isInteractionSuspended()||Ec(t,this)}mouseleave(t){this.draw.isInteractionSuspended()||Mc(t,this)}keydown(t){this.draw.isInteractionSuspended()||Qc(t,this)}dblclick(t){this.draw.isInteractionSuspended()||rr.dblclick(this,t)}threeClick(){this.draw.isInteractionSuspended()||rr.threeClick(this)}input(t,e="input"){this.draw.isInteractionSuspended()||Fi(t,this,e)}async cut(){this.draw.isInteractionSuspended()||await kc(this)}async copy(t){this.draw.isInteractionSuspended()||await xc(this,t)}compositionstart(){this.draw.isInteractionSuspended()||yi.compositionstart(this)}compositionend(t){this.draw.isInteractionSuspended()||yi.compositionend(this,t)}compositionCancel(){this.draw.isInteractionSuspended()||yi.compositionCancel(this)}drop(t){this.draw.isInteractionSuspended()||Bc(t,this)}dragover(t){this.draw.isInteractionSuspended()||nd.dragover(t,this)}}const lr={PAGE_SCALE:"pageScale"};class id{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(lr.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 sd{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 rd{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:R,table:{tdPadding:h}}=this.options;let g=l,T=r,f=c;for(let p=0;p<n.length;p++){const m=n[p];if(!m.isSurround){const L=m.width+(m.offsetX||0);m.rowFlex===s.RowFlex.CENTER?g+=(d-L)/2:m.rowFlex===s.RowFlex.RIGHT&&(g+=d-L)}g+=m.offsetX||0,T+=m.offsetY||0;const C=g,I=T;for(let L=0;L<m.elementList.length;L++){const E=m.elementList[L],O=E.metrics,F=!ue(E)&&(E.imgDisplay!==s.ImageDisplay.INLINE&&E.type===s.ElementType.IMAGE||E.type===s.ElementType.LATEX)?m.ascent-O.height:m.ascent;E.left&&(g+=E.left),E.translateX&&(g+=E.translateX*R);const V={pageNo:i,index:f,value:E.value,rowIndex:a+p,rowNo:p,metrics:O,left:E.left||0,ascent:F,lineHeight:m.height,isFirstLetter:L===0,isLastLetter:L===m.elementList.length-1,coordinate:{leftTop:[g,T],leftBottom:[g,T+m.height],rightTop:[g+O.width,T],rightBottom:[g+O.width,T+m.height]}};if(E.imgDisplay===s.ImageDisplay.SURROUND||E.imgDisplay===s.ImageDisplay.FLOAT_TOP||E.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM){const D=e[e.length-1];D&&(V.metrics=D.metrics,V.coordinate=D.coordinate),E.imgFloatPosition||(E.imgFloatPosition={x:g,y:T,pageNo:i}),this.floatPositionList.push({pageNo:i,element:E,position:V,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:f,zone:u})}if(e.push(V),f++,g+=O.width,E.type===s.ElementType.TABLE&&!ue(E)){const D=E.tdPadding||h,b=D[1]+D[3],N=D[0]+D[2];for(let W=0;W<E.trList.length;W++){const y=E.trList[W];for(let M=0;M<y.tdList.length;M++){const X=y.tdList[M];X.positionList=[];const P=X.rowList,Y=this.computePageRowPosition({positionList:X.positionList,rowList:P,pageNo:i,startRowIndex:0,startIndex:0,startX:(X.x+D[3])*R+C+(E.translateX||0)*R,startY:(X.y+D[0])*R+I,innerWidth:(X.width-b)*R,isTable:!0,index:f-1,tdIndex:M,trIndex:W,zone:u});if(X.verticalAlign===s.VerticalAlign.MIDDLE||X.verticalAlign===s.VerticalAlign.BOTTOM){const S=P.reduce((v,w)=>v+w.height,0),U=(X.height-N)*R-S,Q=X.verticalAlign===s.VerticalAlign.MIDDLE?U/2:U;Math.floor(Q)>0&&X.positionList.forEach(v=>{const{coordinate:{leftTop:w,leftBottom:x,rightBottom:rt,rightTop:A}}=v;w[1]+=Q,x[1]+=Q,rt[1]+=Q,A[1]+=Q})}g=Y.x,T=Y.y}}g=C,T=I}}g=l,T+=m.height}return{x:g,y:T,index:f}}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 R=u[0].startIndex;this.computePageRowPosition({positionList:this.positionList,rowList:u,pageNo:d,startRowIndex:c,startIndex:R,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:[ht(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 f=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_TOP,s.ImageDisplay.SURROUND]});if(f)return f}for(let f=0;f<r.length;f++){const{index:p,pageNo:m,left:C,isFirstLetter:I,coordinate:{leftTop:L,rightTop:E,leftBottom:O}}=r[f];if(u===m){if(m>u)break;if(L[0]-C<=e&&E[0]>=e&&L[1]<=n&&O[1]>=n){let F=f;const V=l[f];if(V.type===s.ElementType.TABLE)for(let b=0;b<V.trList.length;b++){const N=V.trList[b];for(let W=0;W<N.tdList.length;W++){const y=N.tdList[W],M=this.getPositionByXY({x:e,y:n,td:y,pageNo:c,tablePosition:r[f],isTable:!0,elementList:y.value,positionList:y.positionList});if(~M.index){const{index:X,hitLineStartIndex:P}=M,Y=y.value[X];return{index:p,isCheckbox:M.isCheckbox||Y.type===s.ElementType.CHECKBOX||Y.controlComponent===s.ControlComponent.CHECKBOX,isRadio:Y.type===s.ElementType.RADIO||Y.controlComponent===s.ControlComponent.RADIO,isControl:!!Y.controlId,isImage:M.isImage,isLabel:M.isLabel,isMacro:M.isMacro,isDirectHit:M.isDirectHit,isTable:!0,tdIndex:W,trIndex:b,tdValueIndex:X,tdId:y.id,trId:N.id,tableId:V.id,hitLineStartIndex:P}}}}if(V.type===s.ElementType.IMAGE||V.type===s.ElementType.LATEX)return{index:F,isDirectHit:!0,isImage:!0};if(V.type===s.ElementType.MENSTRUAL_HISTORY)return{index:F,isDirectHit:!0};if(V.type===s.ElementType.FETAL_HEART_POSITION)return{index:F,isDirectHit:!0};if(V.type===s.ElementType.TOOTH_POSITION){const{scale:b}=this.options,N=V.width*b;return e>=L[0]&&e<=L[0]+N?{index:F,isDirectHit:!0}:{index:F}}if(V.type===s.ElementType.CHECKBOX||V.controlComponent===s.ControlComponent.CHECKBOX)return{index:F,isDirectHit:!0,isCheckbox:!0};if(V.type===s.ElementType.LABEL)return{index:F,isDirectHit:!0,isLabel:!0};if(V.type===s.ElementType.MACRO||V.type===s.ElementType.CUSTOM_MACRO||V.type===s.ElementType.REUSABLE_ITEM||V.type===s.ElementType.SUB_TEMPLATE)return{index:F,isDirectHit:!0,isMacro:!0};if(V.type===s.ElementType.TAB&&V.listStyle===s.ListStyle.CHECKBOX){let b=F-1;for(;b>0;){const N=l[b];if(N.value===K&&N.listStyle===s.ListStyle.CHECKBOX)break;b--}return{index:b,isDirectHit:!0,isCheckbox:!0}}if(V.type===s.ElementType.RADIO||V.controlComponent===s.ControlComponent.RADIO)return{index:F,isDirectHit:!0,isRadio:!0};let D;if(l[p].value!==K){const b=E[0]-L[0];e<L[0]+b/2&&(F=f-1,I&&(D=f))}return{isDirectHit:!0,hitLineStartIndex:D,index:F,isControl:!!V.controlId}}}}if(!i){const f=this.getFloatPositionByXY({...t,imgDisplays:[s.ImageDisplay.FLOAT_BOTTOM]});if(f)return f}let R=!1,h=-1,g;if(i){const{scale:f}=this.options,{td:p,tablePosition:m}=t;if(p&&m){const{leftTop:C}=m.coordinate,I=p.x*f+C[0],L=p.y*f+C[1],E=p.width*f,O=p.height*f;if(!(I<e&&e<I+E&&L<n&&n<L+O))return{index:h}}}const T=r.filter(f=>f.isLastLetter&&f.pageNo===u);for(let f=0;f<T.length;f++){const{index:p,rowNo:m,coordinate:{leftTop:C,leftBottom:I}}=T[f];if(n>C[1]&&n<=I[1]){const L=r.findIndex(V=>V.pageNo===u&&V.rowNo===m),E=l[L],O=r[L],F=E.listStyle===s.ListStyle.CHECKBOX?this.draw.getMargins()[3]:O.coordinate.leftTop[0];if(e<F)~L?O.value===K?h=L:(h=L-1,g=L):h=p;else{if(E.listStyle===s.ListStyle.CHECKBOX&&e<C[0])return{index:L,isDirectHit:!0,isCheckbox:!0};h=p}R=!0;break}}if(!R){if(this.draw.getIsPagingMode()){const p=this.draw.getHeader(),m=p.getHeight(),C=p.getHeaderTop()+m,I=this.draw.getFooter(),E=this.draw.getHeight()-(I.getFooterBottom()+I.getHeight());if(d){if(n<C)return{index:-1,zone:s.EditorZone.HEADER};if(n>E)return{index:-1,zone:s.EditorZone.FOOTER}}else if(n<=E&&n>=C)return{index:-1,zone:s.EditorZone.MAIN}}const f=this.draw.getMargins();if(n<=f[0])for(let p=0;p<r.length;p++){const m=r[p];if(m.pageNo!==u||m.rowNo!==0)continue;const{leftTop:C,rightTop:I}=m.coordinate;if(e<=f[3]||e>=C[0]&&e<=I[0]||r[p+1]?.rowNo!==0)return{index:m.index}}else{const p=T[T.length-1];if(p){const m=p.rowNo;for(let C=0;C<r.length;C++){const I=r[C];if(I.pageNo!==u||I.rowNo!==m)continue;const{leftTop:L,rightTop:E}=I.coordinate;if(e<=f[3]||e>=L[0]&&e<=E[0]||r[C+1]?.rowNo!==m)return{index:I.index}}}}return{index:T[T.length-1]?.index||r.length-1}}return{hitLineStartIndex:g,index:h,isControl:!!l[h]?.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:R,trIndex:h,tdIndex:g,tdValueIndex:T,zone:f,pageNo:p}=this.floatPositionList[a];if(i===p&&d.type===s.ElementType.IMAGE&&d.imgDisplay&&t.imgDisplays.includes(d.imgDisplay)&&(!f||f===l)){const m=d.imgFloatPosition,C=m.x*r,I=m.y*r,L=d.width*r,E=d.height*r;if(e>=C&&e<=C+L&&n>=I&&n<=I+E)return u?{index:R,isDirectHit:!0,isImage:!0,isTable:u,trIndex:h,tdIndex:g,tdValueIndex:T,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:p,isTable:m,trIndex:C,tdIndex:I,tdValueIndex:L}=e,E=this.draw.getControl(),{newIndex:O}=E.moveCursor({index:p,isTable:m,trIndex:C,tdIndex:I,tdValueIndex:L});m?e.tdValueIndex=O:e.index=O}const{index:n,isCheckbox:i,isRadio:l,isControl:r,isImage:a,isLabel:c,isDirectHit:d,isTable:u,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f}=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:R,tdIndex:h,tdId:g,trId:T,tableId:f}),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&&!Vn(l)&&!l.control?.minWidth)for(let R=0;R<a.length;R++){const h=a[R],g=h.imgFloatPosition;if(g.pageNo!==n)continue;const T={...g,x:g.x*e,y:g.y*e,width:h.width*e,height:h.height*e};if(sa(r,T)){i.isSurround=!0;const f=T.width+T.x-r.x;if(l.left=f,i.width+=f,u+=f,d=T.x+T.width,i.width+l.metrics.width>c){l.left=0,i.width-=u;break}}}return{x:d,rowIncreaseWidth:u}}}class ld{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=yn(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||Ce.includes(e.type)):null}getTextLikeSelectionElementList(){const t=this.getSelectionElementList();return t?t.filter(e=>!e.type||Ce.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 R=l.get(d);R||(R=[],l.set(d,R)),R.includes(u)||R.unshift(u);const h=i[r],g=i[r-1];if(h.value===K&&!h.listWrap||h.listId!==g?.listId||h.titleId!==g?.titleId)break;r--}const a=t===e;if(!a){let d=t+1;for(;d<e;){const{pageNo:u,rowNo:R}=n[d];let h=l.get(u);h||(h=[],l.set(u,h)),h.includes(R)||h.push(R),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:R,rowNo:h}=n[c];let g=l.get(R);g||(g=[],l.set(R,g)),g.includes(h)||g.push(h),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:R}=r[a];if(n===R&&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:R,trIndex:h}=l,g={startIndex:u,endIndex:u};a===Qe.TABLE&&(g.tableId=d,g.startTdIndex=R,g.endTdIndex=R,g.startTrIndex=h,g.endTrIndex=h),n.set(c,g)}}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){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 P=this.draw.getOriginalElementList(),Y=this.position.getPositionContext();r=P[Y.index]}else{const P=~i?i:0,Y=this.draw.getElementList();r=this.getRangeAnchorStyle(Y,P)}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,R=!~a.findIndex(P=>!P.bold),h=!~a.findIndex(P=>!P.italic),g=!~a.findIndex(P=>!P.underline&&!P.control?.underline),T=!~a.findIndex(P=>!P.strikeout),f=r.color||null,p=r.highlight||null,m=r.rowFlex||null,C=r.vertical||null,I=r.rowMargin??this.options.defaultRowMargin,L=r.dashArray||[],E=r.level||null,O=r.listType||null,F=r.listStyle||null,V=g&&r.textDecoration||null,D=!!this.draw.getPainterStyle(),b=this.historyManager.isCanUndo(),N=this.historyManager.isCanRedo(),W=r.groupIds||null,y=r.extension??null,M=r.deletePerson??"",X={type:c,undo:b,redo:N,painter:D,font:d,size:u,bold:R,italic:h,underline:g,strikeout:T,deletePerson:M,color:f,highlight:p,rowFlex:m,vertical:C,rowMargin:I,dashArray:L,level:E,listType:O,listStyle:F,groupIds:W,textDecoration:V,extension:y};this._emitRangeStyle(X)}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 ad{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 R=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_X?Math.ceil(n*r/a):1,h=l.repeat===s.BackgroundRepeat.REPEAT||l.repeat===s.BackgroundRepeat.REPEAT_Y?Math.ceil(i*r/c):1;for(let g=0;g<R;g++){for(let T=0;T<h;T++)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 bi{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 cd extends bi{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 dd{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]],R=[a[3],r-a[2]],h=[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(R[0]-c,R[1]),t.lineTo(...R),t.lineTo(R[0],R[1]+c),t.moveTo(h[0]+c,h[1]),t.lineTo(...h),t.lineTo(h[0],h[1]+c),t.stroke(),t.restore()}}class ud{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 g=0;g<c;g++)e[g].type===s.ElementType.TABLE&&d.push(g);let u=0,R=0;for(;R<c-1;){const g=d.length?d[u]:c,T=e.slice(R,g);T.length&&a.push({index:R,type:Qe.PAGE,elementList:T});const f=e[g];f&&a.push({index:g,type:Qe.TABLE,elementList:[f]}),R=g+1,u++}function h(g,T,f,p){if(!g)return;let m=f.map(O=>!O.type||Ce.includes(O.type)&&O.controlComponent!==s.ControlComponent.CHECKBOX&&O.controlComponent!==s.ControlComponent.RADIO&&!O.hide&&!O.control?.hide&&!O.area?.hide?O.value:K).filter(Boolean).join("");i&&(m=m.toLocaleLowerCase());const C=[],I=n?new RegExp(g):g;let{index:L,length:E}=Ss(m,I);for(;L!==-1&&E!==0;){C.push({index:L,length:E});const O=Ss(m,I,L+E);L=O.index,E=O.length}for(let O=0;O<C.length;O++){const{index:F,length:V}=C[O],D=Tt();for(let b=0;b<V;b++){const N=F+b+(p?.startIndex||0);r.push({type:T,index:N,groupId:D,...p})}}}for(let g=0;g<a.length;g++){const T=a[g];if(T.type===Qe.TABLE){const f=T.elementList[0];for(let p=0;p<f.trList.length;p++){const m=f.trList[p];for(let C=0;C<m.tdList.length;C++){const I=m.tdList[C],L={tableId:f.id,tableIndex:T.index,trIndex:p,tdIndex:C,tdId:I.id};h(l,T.type,I.value,L)}}}else h(l,T.type,T.elementList,{startIndex:T.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===Qe.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===Qe.TABLE){const{tableIndex:L,trIndex:E,tdIndex:O,index:F}=d;u=a[L]?.trList[E].tdList[O]?.positionList[F]}else u=r[d.index];if(!u)continue;const{coordinate:{leftTop:R,leftBottom:h,rightTop:g},pageNo:T}=u;if(T!==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 p=R[0],m=R[1],C=g[0]-R[0],I=h[1]-R[1];t.fillRect(p,m,C,I)}t.restore()}replace(t,e){if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const l=e?.index;if(ii(l)){const f=[];i.forEach(p=>{const m=f[f.length-1];!m||m[0].groupId!==p.groupId?f.push([p]):m.push(p)}),i=f[l]}if(!i?.length)return;const r=this.draw.isDesignMode();let a=0,c=0,d="",u="",R=-1;const h=this.draw.getOriginalElementList();for(let f=0;f<i.length;f++){const p=i[f];if(p.type===Qe.TABLE){const{tableIndex:m,trIndex:C,tdIndex:I,index:L,tdId:E}=p;u&&E!==u&&(c=0),u=E;const O=m+a,F=h[O].trList[C].tdList[I].value,V=L+c,D=F[V];if(!r&&(D?.control?.deletable===!1||D?.title?.deletable===!1))continue;if(t===""){this.draw.spliceElementList(F,V,1),c--,~R||(R=f);continue}if(d===p.groupId){this.draw.spliceElementList(F,V,1),c--;continue}~R||(R=f);for(let b=0;b<t.length;b++){const N=t[b];b===0?D.value=N:(this.draw.spliceElementList(F,V+b,0,[{...D,value:N}]),c++)}}else{const m=p.index+a,C=h[m];if(!r&&(C?.control?.deletable===!1||C?.title?.deletable===!1)||C.type===s.ElementType.CONTROL&&C.controlComponent!==s.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,m,1),a--,~R||(R=f);continue}if(~R||(R=f),d===p.groupId){this.draw.spliceElementList(h,m,1),a--;continue}for(let I=0;I<t.length;I++){const L=t[I];I===0?C.value=L:(this.draw.spliceElementList(h,m+I,0,[{...C,value:L}]),a++)}}d=p.groupId}if(!~R)return;const g=i[R],T=g.index+(t.length-1);if(g.type===Qe.TABLE){const{tableIndex:f,trIndex:p,tdIndex:m,index:C}=g,I=h[f].trList[p].tdList[m].value[C];this.position.setPositionContext({isTable:!0,index:f,trIndex:p,tdIndex:m,tdId:I.tdId,trId:I.trId,tableId:I.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(T,T),this.draw.render({curIndex:T})}}class Rd extends bi{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 Yn;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(Yn||(Yn={}));class hd extends bi{options;constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,l){const r=e+i;switch(t.beginPath(),l){case Yn.DASHED:t.setLineDash([3,1]);break;case Yn.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?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,Yn.DASHED);break;case s.TextDecorationStyle.DOTTED:this._drawLine(t,i,a,r,Yn.DOTTED);break;default:this._drawLine(t,i,a,r);break}t.restore(),this.clearFillInfo()}}class gd{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:_l});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||!Hl.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 Un{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const l=i===s.NumberType.CHINESE?ea(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:R}}=this.options;if(e<R)return;let h=d;const g=new RegExp($n.PAGE_NO);g.test(h)&&(h=Un.formatNumberPlaceholder(h,e+u-R,g,c));const T=new RegExp($n.PAGE_COUNT);T.test(h)&&(h=Un.formatNumberPlaceholder(h,this.draw.getPageCount()-R,T,c));const f=this.draw.getWidth(),p=this.draw.getHeight(),m=this.draw.getPageNumberBottom(),C=p-m;t.save(),t.fillStyle=r,t.font=`${i*n}px ${l}`;let I=0;const L=this.draw.getMargins(),{width:E}=t.measureText(h);a===s.RowFlex.CENTER?I=(f-E)/2:a===s.RowFlex.RIGHT?I=f-E-L[1]:I=L[3],t.fillText(h,I,C),t.restore()}}class Td{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=$l(()=>{const{intersectionPageNo:t,visiblePageNoList:e}=this.getPageVisibleInfo();this.draw.setIntersectionPageNo(t),this.draw.setVisiblePageNoList(e)},150)}class fd{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($t.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove($t.DOWN):e<this.thresholdPoints[2]?this._startMove($t.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove($t.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===$t.DOWN?e.scrollTo(n,i+this.step):t===$t.UP?e.scrollTo(n,i-this.step):t===$t.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 md{draw;range;options;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=ht(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 R=i.tdList.splice(l,1)[0];e[u]?.tdList.splice(d,0,R)}}}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(),h=this.draw.getOriginalElementList()[e].trList;if(!l)return[[h[n].tdList[i]]];let g=h[c].tdList[r],T=h[d].tdList[a];(g.x>T.x||g.y>T.y)&&([g,T]=[T,g]);const f=g.colIndex,p=T.colIndex+(T.colspan-1),m=g.rowIndex,C=T.rowIndex+(T.rowspan-1),I=[];for(let L=0;L<h.length;L++){const E=h[L],O=[];for(let F=0;F<E.tdList.length;F++){const V=E.tdList[F],D=V.colIndex,b=V.rowIndex;D>=f&&D<=p&&b>=m&&b<=C&&O.push(V)}O.length&&I.push(O)}return I.length?I: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,R=this._mergeHorizontalBorderRanges(d,l),h=e.lineWidth;c&&(e.lineWidth=c*u),e.beginPath();const g=Math.round(n),T=Math.round(i);e.translate(.5,.5),a&&!R.length?e.rect(g,T,l,r):(a?(e.moveTo(g,T),e.lineTo(g,T+r),e.lineTo(g+l,T+r),e.lineTo(g+l,T)):(e.moveTo(g,T+r),e.lineTo(g,T)),this._drawHorizontalBorder(e,g,T,l,R)),e.stroke(),c&&(e.lineWidth=h),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:R,table:{defaultBorderColor:h}}=this.options,g=e.width*R,T=e.height*R,f=this._getPagingContinuationTopBorderRanges(r,g),p=a===s.TableBorder.EMPTY,m=a===s.TableBorder.EXTERNAL,C=a===s.TableBorder.INTERNAL;t.save(),a===s.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=d*R,t.strokeStyle=c||h,!p&&!C&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:T,borderExternalWidth:u,isDrawFullBorder:m,skipTopBorderRanges:f});for(let I=0;I<r.length;I++){const L=r[I];for(let E=0;E<L.tdList.length;E++){const O=L.tdList[E];if(O.slashTypes?.length&&this._drawSlash(t,O,n,i),!O.borderTypes?.length&&(p||m))continue;const F=O.width*R,V=O.height*R,D=Math.round(O.x*R+n+F),b=Math.round(O.y*R+i),N=!!O.linkTdPrevId,W=!!O.linkTdNextId;if(t.translate(.5,.5),t.beginPath(),!N&&O.borderTypes?.includes(s.TdBorder.TOP)&&(t.moveTo(D-F,b),t.lineTo(D,b),t.stroke()),O.borderTypes?.includes(s.TdBorder.RIGHT)&&(t.moveTo(D,b),t.lineTo(D,b+V),t.stroke()),O.borderTypes?.includes(s.TdBorder.BOTTOM)&&(t.moveTo(D,b+V),t.lineTo(D-F,b+V),t.stroke()),O.borderTypes?.includes(s.TdBorder.LEFT)&&(t.moveTo(D-F,b),t.lineTo(D-F,b+V),t.stroke()),!p&&!m){if((!C||O.colIndex+O.colspan<l.length)&&(t.moveTo(D,b),t.lineTo(D,b+V),u&&u!==d&&O.colIndex+O.colspan===l.length)){const y=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=y}if(W||!C||O.rowIndex+O.rowspan<r.length){const y=u&&u!==d&&O.rowIndex+O.rowspan===r.length;if(y&&(t.stroke(),t.beginPath()),t.moveTo(D,b+V),t.lineTo(D-F,b+V),y){const M=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=M}}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 R=u.width*r,h=u.height*r,g=Math.round(u.x*r+n),T=Math.round(u.y*r+i);t.fillStyle=u.backgroundColor,t.fillRect(g,T,R,h),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 m=r.tdList[c-1],C=m?m.colIndex+m.colspan:c;for(let I=C;I<e.length;I++)if(this.getRowCountByColIndex(n.slice(0,l),I)===l){u=I;let E=0;for(let O=0;O<I;O++)E+=e[O].width;i=E;break}}else{const m=r.tdList[c-1];m&&(u=m.colIndex+m.colspan)}let R=0;for(let m=0;m<d.colspan;m++)R+=e[m+u].width;let h=0;for(let m=0;m<d.rowspan;m++){const C=n[m+l]||n[l];h+=C.height}const g=r.tdList.length-1===c;let T=a;if(!T&&d.rowspan>1){const m=n.length-1-l;T=d.rowspan-1===m}const f=a&&g;d.isLastRowTd=g,d.isLastColTd=T,d.isLastTd=f,d.x=i;let p=0;for(let m=0;m<l;m++){const C=n[m].tdList;for(let I=0;I<C.length;I++){const L=C[I];if(u>=L.colIndex&&u<L.colIndex+L.colspan){p+=L.height;break}}}d.y=p,d.width=R,d.height=h,d.rowIndex=l,d.colIndex=u,d.trIndex=l,d.tdIndex=c,i+=R,g&&!f&&(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:R,endTdIndex:h,startTrIndex:g,endTrIndex:T}=this.range.getRange();if(!u)return;let f=d[g].tdList[R],p=d[T].tdList[h];(f.x>p.x||f.y>p.y)&&([f,p]=[p,f]);const m=f.colIndex,C=p.colIndex+(p.colspan-1),I=f.rowIndex,L=p.rowIndex+(p.rowspan-1);t.save();for(let E=0;E<d.length;E++){const O=d[E];for(let F=0;F<O.tdList.length;F++){const V=O.tdList[F],D=V.colIndex,b=V.rowIndex;if(D>=m&&D<=C&&b>=I&&b<=L){const N=V.x*l,W=V.y*l,y=V.width*l,M=V.height*l;t.globalAlpha=r,t.fillStyle=a,t.fillRect(N+n,W+i,y,M)}}}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 R=0;R<c.length;R++){const h=c[R];h.height=h.minHeight||l,h.minHeight=h.height}this.computeRowColInfo(t);const d={},u={};for(let R=0;R<c.length;R++){const h=c[R];if(!h.tdList.length){h.height=0;continue}const g=[],T=[];for(let p=0;p<t.colgroup.length;p++){const m=h.tdList.find(C=>C.colIndex===p);if(m){const C=e?e(m):m.rowList,I=C.reduce((E,O)=>E+O.height,0);m.rowList=C;const L=I/n+a;m.mainHeight=L,m.rowspan>1?(u[m.colIndex]=m.id,d[m.id]={td:m,rowSpan:[R,R+m.rowspan-1],preHeight:0,preMinHeight:0,extraHeight:L},T.push(L)):m.height<L?(m.height=L,m.realHeight=L,g.push(L)):g.push(m.height)}else{const C=d[u[p]];C?.rowSpan[1]==R&&g.push(C.extraHeight)}}const f=Math.max(...g.length?g:T);Object.values(d).forEach(p=>{p.rowSpan[0]<=R&&p.rowSpan[1]>=R&&(p.extraHeight-=f,p.preHeight+=f,p.preMinHeight+=h.minHeight)}),h.height=f;for(let p=0;p<t.colgroup.length;p++){const m=h.tdList.find(C=>C.colIndex===p)??this.findPreRowSpanTd(c,R,p);if(m){const C=d[m.id]?.preHeight??0,I=d[m.id]?.preMinHeight??h.minHeight;m.height=f+C,m.realHeight=f+C,m.realMinHeight=I}}}this.computeRowColInfo(t)}}var _e;(function(o){o.ROW="row",o.COL="col"})(_e||(_e={}));class pd{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:R,trList:h}=a,{coordinate:{leftTop:g}}=u,T=this.draw.getHeight(),f=this.draw.getPageGap(),p=this.draw.getPageNo()*(T+f),m=g[0],C=g[1]+p,I=a.trList[n].tdList[i],L=I.rowIndex,E=I.colIndex,O=a.height*c,F=a.width*c,V=document.createElement("div");V.classList.add(`${j}-table-tool__select`),V.style.height=`${O*c}`,V.style.left=`${m}px`,V.style.top=`${C}px`,V.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*c}px, ${-this.TABLE_SELECT_OFFSET*c}px)`,V.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(V),this.toolTableSelectBtn=V;const D=h.map(P=>P.height),b=document.createElement("div");b.classList.add(`${j}-table-tool__row`),b.style.transform=`translateX(-${this.ROW_COL_OFFSET*c}px)`;for(let P=0;P<D.length;P++){const Y=D[P]*c,S=document.createElement("div");S.classList.add(`${j}-table-tool__row__item`),P===L&&S.classList.add("active"),S.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByRowIndex(h,P),v=Q[0],w=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:v.trIndex,tdIndex:v.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,v.tdIndex,w.tdIndex,v.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(b,P)};const U=document.createElement("div");U.classList.add(`${j}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:P,order:_e.ROW})},S.append(U),S.style.height=`${Y}px`,b.append(S)}b.style.left=`${m}px`,b.style.top=`${C}px`,this.container.append(b),this.toolRowContainer=b;const N=document.createElement("div");N.classList.add(`${j}-table-tool__quick__add`),N.style.height=`${O*c}`,N.style.left=`${m}px`,N.style.top=`${C+O}px`,N.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*c}px, ${this.ROW_COL_QUICK_OFFSET*c}px)`,N.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(N),this.toolRowAddBtn=N;const W=R.map(P=>P.width),y=document.createElement("div");y.classList.add(`${j}-table-tool__col`),y.style.transform=`translateY(-${this.ROW_COL_OFFSET*c}px)`;for(let P=0;P<W.length;P++){const Y=W[P]*c,S=document.createElement("div");S.classList.add(`${j}-table-tool__col__item`),P===E&&S.classList.add("active"),S.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByColIndex(h,P),v=Q[0],w=Q[Q.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:v.trIndex,tdIndex:v.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,v.tdIndex,w.tdIndex,v.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(y,P)};const U=document.createElement("div");U.classList.add(`${j}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:P,order:_e.COL})},S.append(U),S.style.width=`${Y}px`,y.append(S)}y.style.left=`${m}px`,y.style.top=`${C}px`,this.container.append(y),this.toolColContainer=y;const M=document.createElement("div");M.classList.add(`${j}-table-tool__quick__add`),M.style.height=`${O*c}`,M.style.left=`${m+F}px`,M.style.top=`${C}px`,M.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*c}px, -${this.ROW_COL_QUICK_POSITION*c}px)`,M.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(M),this.toolColAddBtn=M;const X=document.createElement("div");X.classList.add(`${j}-table-tool__border`),X.style.height=`${O}px`,X.style.width=`${F}px`,X.style.left=`${m}px`,X.style.top=`${C}px`;for(let P=0;P<h.length;P++){const Y=h[P];for(let S=0;S<Y.tdList.length;S++){const U=Y.tdList[S],Q=document.createElement("div");Q.classList.add(`${j}-table-tool__border__row`),Q.style.width=`${U.width*c}px`,Q.style.height=`${this.BORDER_VALUE}px`,Q.style.top=`${(U.y+U.height)*c-this.BORDER_VALUE/2}px`,Q.style.left=`${U.x*c}px`,Q.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.rowIndex+U.rowspan-1,order:_e.ROW})},X.appendChild(Q);const v=document.createElement("div");if(v.classList.add(`${j}-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+U.width)*c-this.BORDER_VALUE/2}px`,v.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.colIndex+U.colspan-1,order:_e.COL})},X.appendChild(v),d&&U.colIndex===0){const w=document.createElement("div");w.classList.add(`${j}-table-tool__border__col`),w.style.width=`${this.BORDER_VALUE}px`,w.style.height=`${U.height*c}px`,w.style.top=`${U.y*c}px`,w.style.left=`${U.x*c-this.BORDER_VALUE/2}px`,w.onmousedown=x=>{this._mousedown({evt:x,element:a,index:0,isLeftStartBorder:!0,order:_e.COL})},X.appendChild(w)}}}this.container.append(X),this.toolBorderContainer=X}_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(),R=this.draw.getPageGap(),h=this.draw.getPageNo()*(u+R),g=this.position.getPositionContext(),p=(this.position.getOriginalPositionList()[g.index]?.coordinate?.leftTop?.[0]||0)*a,m=this.draw.getMargins(),C=m[0],I=m[1],L=C,E=d-I;this.mousedownX=e.x,this.mousedownY=e.y;const O=e.target,F=this.canvas.getBoundingClientRect(),V=window.getComputedStyle(O).cursor;document.body.style.cursor=V,this.canvas.style.cursor=V;let D=0,b=0;const N=document.createElement("div");N.classList.add(`${j}-table-anchor__line`),i===_e.ROW?(N.classList.add(`${j}-table-anchor__line__row`),N.style.width=`${d}px`,D=0,b=h+this.mousedownY-F.top):(N.classList.add(`${j}-table-anchor__line__col`),N.style.height=`${u}px`,D=this.mousedownX-F.left,b=h),N.style.left=`${D}px`,N.style.top=`${b}px`,this.container.append(N),this.anchorLine=N;let W=0,y=0;const M=X=>{const P=this._mousemove(X,i,D,b);P&&(W=P.dx,y=P.dy)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",()=>{let X=!1;if(i===_e.ROW){const P=l.trList,Y=P[n]||P[n-1],{defaultTrMinHeight:S}=this.options.table;y<0&&Y.height+y<S&&(y=S-Y.height),y&&(Y.height+=y,Y.minHeight=Y.height,X=!0)}else{const{colgroup:P}=l;if(P&&W)if(c&&r){P[n].width-W/a<=this.MIN_TD_WIDTH&&(W=(P[n].width-this.MIN_TD_WIDTH)*a);const Y=p+(l.translateX||0)*a;Y+W<L&&(W=L-Y),P[n].width-=W/a,l.width-=W/a,l.translateX=(l.translateX||0)+W/a,X=!0}else{const Y=P[n].width;W<0&&Y*a+W<this.MIN_TD_WIDTH*a&&(W=this.MIN_TD_WIDTH*a-Y*a);const S=P[n+1]?.width;if(W>0&&S&&S*a-W<this.MIN_TD_WIDTH*a&&(W=S*a-this.MIN_TD_WIDTH*a),n===P.length-1){const Q=p+(l.translateX||0)*a+l.width*a;Q+W>E&&(W=E-Q)}W&&(P.length-1!==n&&(P[n+1].width-=W/a),P[n].width+=W/a,X=!0)}}X&&this.draw.render({isSetCursor:!1}),N.remove(),document.removeEventListener("mousemove",M),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 Id{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(`${j}-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 Cd{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,R=e.label?.color||a,h=e.label?.borderRadius||c,g=e.label?.padding||d;t.save(),t.font=e.style;const{width:T,height:f,boundingBoxAscent:p}=e.metrics;t.fillStyle=u,this._drawRoundedRect(t,n,i-p,T,f+(g[0]+g[3])*l,h*l),t.fill(),t.fillStyle=R,t.fillText(e.value,n+g[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 Ld{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,pi(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)this.activeInlineEditor?.elementId===e.id&&this._syncInlineEditorPosition(),c==="select"?this._renderSelectControl(t,e,n,i,d):this._renderTextControl(t,e,n,i,d);else{const R=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,R)}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 R=d||`获取 ${u}`;this._renderPlainText(t,e,n,i,R)}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){if(this.draw.getMode()!==s.EditorMode.FORM||t.type!=="customMacro")return!1;const n=this._ensureMacroConfig(t),i=n.type||"text",l=this.activeInlineEditor;if(l&&l.elementId===t.id&&l.type===i)return l.input.focus(),l.input instanceof HTMLInputElement&&l.input.select(),!0;this.clearInlineEditor({isSubmitHistory:!1});const r=document.createElement("div");r.style.position="absolute",r.style.zIndex="1002",r.style.boxSizing="border-box",r.style.display="flex",r.style.alignItems="center";const a=this._getInlineEditorBaseStyle(t);let c;i==="select"?c=this._createSelectEditor(t,r):c=this._createTextEditor(t,r),c.style.boxSizing="border-box",c.style.width="100%",c.style.height="100%",c.style.border="none",c.style.outline="none",c.style.background="transparent",c.style.font=a.font,c.style.color=a.color,c.style.padding=a.padding,c.style.margin="0",r.append(c),r.addEventListener("mousedown",u=>u.stopPropagation()),r.addEventListener("click",u=>u.stopPropagation()),this.draw.getContainer().append(r),this.draw.setOverlayActive(!0);const d=u=>{const R=u.target;R instanceof Node&&r.contains(R)||this.clearInlineEditor()};return document.addEventListener("mousedown",d,!0),this.activeInlineEditor={elementId:t.id,index:e,type:i,wrapper:r,input:c,initialValue:n.value||"",initialCode:n.code,outsideHandler:d},this._syncInlineEditorPosition(),c.focus(),c instanceof HTMLInputElement?c.select():"showPicker"in c&&typeof c.showPicker=="function"?c.showPicker():c.click(),!0}clearInlineEditor(t={}){const e=this.activeInlineEditor;if(!e)return;const{isSubmitHistory:n=!0,isRestore:i=!1}=t;document.removeEventListener("mousedown",e.outsideHandler,!0);const l=this._getInlineEditorElement(e),r=l?.macroConfig,a=e.input.value||"",c=e.input instanceof HTMLSelectElement&&e.input.value||"";if(l&&r&&(i?(r.value=e.initialValue,e.type==="select"&&(r.code=e.initialCode)):e.type==="text"?r.value=a:(r.code=c||void 0,r.value=this._getSelectLabelByCode(r,c))),e.wrapper.remove(),this.activeInlineEditor=null,this.draw.setOverlayActive(!1),l&&!i){const d=this._ensureMacroConfig(l),u=d.value||"",R=d.code;u!==e.initialValue||R!==e.initialCode?this.draw.getCommand().setMacroValue({id:l.id,dictCode:l.dictCode,label:l.label,areaId:l.areaId,value:u,code:R,isSubmitHistory:n}):this.draw.render({isSubmitHistory:!1,isSetCursor:!1})}else this.draw.render({isSubmitHistory:!1,isSetCursor:!1})}_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,R;d?(u="#722ed1",R="#f9f0ff"):c?(u="#52c41a",R="#f6ffed"):a?(u="#fa8c16",R="#fff7e6"):(u="#1677ff",R="#e6f4ff"),t.save(),t.font=e.style;const h=t.measureText(l),g=h.actualBoundingBoxAscent+h.actualBoundingBoxDescent,T=8*r,f=4*r,p=4*r,m=h.width+T*2,C=g+f*2,I=e.metrics,L=n,E=i-I.boundingBoxAscent+(I.boundingBoxAscent+I.boundingBoxDescent-C)/2;t.fillStyle=R,this._drawRoundedRect(t,L,E,m,C,p),t.fill(),t.fillStyle=u,t.textBaseline="middle",t.fillText(l,n+T,E+C/2),t.restore()}_renderTextControl(t,e,n,i,l){const{scale:r,control:a,strikeoutColor:c}=this.options,{placeholderColor:d,bracketColor:u}=a;t.save(),t.font=e.style;const h=`请输入${e.label||""}`,g=l||h,f=t.measureText(g).width;t.fillStyle=u,t.textBaseline="alphabetic",t.fillText("[",n,i);const p=n+t.measureText("[").width;t.fillStyle=l?e.color||"#000000":d,t.fillText(g,p,i);const m=p+f;if(t.fillStyle=u,t.fillText("]",m,i),e.type==="reusableItem"){const C=t.measureText("[").width+f+t.measureText("]").width;if(t.lineWidth=r,this.draw.getMode()===s.EditorMode.PRINT?t.strokeStyle="transparent":t.strokeStyle=c||"red",e.strikeout){const I=i-3*r,L=i+3.5*r;t.beginPath(),t.moveTo(n,I),t.lineTo(n+C,I),t.stroke(),t.beginPath(),t.moveTo(n,L),t.lineTo(n+C,L),t.stroke()}else if(e.underline&&e.textDecoration?.style==="double"){const I=Math.floor(i+2*r)+.5,L=3*r;t.beginPath(),t.moveTo(n,I),t.lineTo(n+C,I),t.stroke(),t.beginPath(),t.moveTo(n,I+L),t.lineTo(n+C,I+L),t.stroke()}}t.restore()}_renderSelectControl(t,e,n,i,l){const{scale:r,control:a}=this.options,{placeholderColor:c,bracketColor:d}=a;t.save(),t.font=e.style;const R=`请选择${e.label||""}`,h=l||R,g=t.measureText(h),T=g.actualBoundingBoxAscent+g.actualBoundingBoxDescent;t.fillStyle=d,t.textBaseline="alphabetic",t.fillText("[",n,i);const f=n+t.measureText("[").width;t.fillStyle=l?e.color||"#000000":c,t.fillText(h,f,i);const p=f+g.width+2*r,m=i-T/2;t.beginPath(),t.moveTo(p,m-2*r),t.lineTo(p+5*r,m-2*r),t.lineTo(p+2.5*r,m+2*r),t.closePath(),t.fillStyle="#666666",t.fill();const C=p+6*r;t.fillStyle=d,t.fillText("]",C,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()}_createTextEditor(t,e){const n=document.createElement("input");return n.type="text",n.value=t.macroConfig?.value||"",n.placeholder=`请输入${t.label||""}`,n.style.minWidth="0",n.style.background="#ffffff",n.addEventListener("input",()=>{const i=this._ensureMacroConfig(t);i.value=n.value}),n.addEventListener("keydown",i=>{i.key==="Enter"?(i.preventDefault(),this.clearInlineEditor()):i.key==="Escape"&&(i.preventDefault(),this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0}))}),n.addEventListener("blur",()=>{this.activeInlineEditor?.input===n&&this.clearInlineEditor()}),e.style.background="#ffffff",e.style.border="1px solid #1677ff",e.style.borderRadius="4px",e.style.boxShadow="0 0 0 2px rgba(22, 119, 255, 0.12)",n}_createSelectEditor(t,e){const n=document.createElement("select"),i=this._ensureMacroConfig(t),l=document.createElement("option");return l.value="",l.textContent=`请选择${t.label||""}`,n.append(l),i.items?.forEach(r=>{const a=document.createElement("option");a.value=r.code,a.textContent=r.value,n.append(a)}),n.value=i.code||i.items?.find(r=>r.value===i.value)?.code||"",n.addEventListener("change",()=>{i.code=n.value||void 0,i.value=this._getSelectLabelByCode(i,n.value),this.clearInlineEditor()}),n.addEventListener("keydown",r=>{r.key==="Escape"?(r.preventDefault(),this.clearInlineEditor({isSubmitHistory:!1,isRestore:!0})):r.key==="Enter"&&(r.preventDefault(),this.clearInlineEditor())}),n.addEventListener("blur",()=>{this.activeInlineEditor?.input===n&&this.clearInlineEditor()}),e.style.background="#ffffff",e.style.border="1px solid #1677ff",e.style.borderRadius="4px",e.style.boxShadow="0 0 0 2px rgba(22, 119, 255, 0.12)",n}_syncInlineEditorPosition(){const t=this.activeInlineEditor;if(!t)return;const e=this._getInlineEditorPosition(t);if(!e){this.clearInlineEditor({isSubmitHistory:!1});return}const n=e.pageNo*(this.draw.getHeight()+this.draw.getPageGap()),[i,l]=e.coordinate.leftTop,r=Math.max(e.lineHeight,e.metrics.height),a=Math.max(e.metrics.width,80*this.options.scale),c=Math.max(0,(e.lineHeight-r)/2);t.wrapper.style.left=`${i}px`,t.wrapper.style.top=`${l+n+c}px`,t.wrapper.style.width=`${a}px`,t.wrapper.style.height=`${r}px`}_getInlineEditorBaseStyle(t){return{font:this.draw.getElementFont(t),color:t.color||"#000000",padding:`0 ${6*this.options.scale}px`}}_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}_getSelectLabelByCode(t,e){return e&&t.items?.find(n=>n.code===e)?.value||""}}class Pd{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=Ci(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*Is[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 Ed{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 Md{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 Od{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 Sd{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,R=r*d,h=e.width*d,g=this.draw.getDefaultBasicRowMarginHeight()*u;t.save(),t.font=`${R}px ${l}`;const T=t.measureText(c),f=(h-T.width)/2;t.setLineDash(a),t.translate(0,.5+g),t.beginPath(),t.moveTo(n,i),t.lineTo(n+f,i),t.moveTo(n+f+T.width,i),t.lineTo(n+h,i),t.stroke(),t.fillText(c,n+f,i+T.actualBoundingBoxAscent-R/2),t.restore()}}class Xd{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:R}=this.options,h=this.draw.getWidth(),g=this.draw.getHeight();t.save(),t.globalAlpha=i,t.font=`${r*R}px ${l}`;let T=n;const f=new RegExp($n.PAGE_NO);f.test(T)&&(T=Un.formatNumberPlaceholder(T,e+1,f,u));const p=new RegExp($n.PAGE_COUNT);p.test(T)&&(T=Un.formatNumberPlaceholder(T,this.draw.getPageCount(),p,u));const m=t.measureText(T);if(c){const C=this.draw.getPagePixelRatio(),I=document.createElement("canvas"),L=I.getContext("2d"),E=m.width,O=m.actualBoundingBoxAscent+m.actualBoundingBoxDescent,F=Math.sqrt(Math.pow(E,2)+Math.pow(O,2)),V=F+2*d[0]*R,D=F+2*d[1]*R;I.width=V,I.height=D,I.style.width=`${V*C}px`,I.style.height=`${D*C}px`,L.translate(V/2,D/2),L.rotate(-45*Math.PI/180),L.translate(-V/2,-D/2),L.font=`${r*R}px ${l}`,L.fillStyle=a,L.fillText(T,(V-E)/2,(D-O)/2+m.actualBoundingBoxAscent);const b=t.createPattern(I,"repeat");b&&(t.fillStyle=b,t.fillRect(0,0,h,g))}else{const C=h/2,I=g/2;t.fillStyle=a,t.translate(C,I),t.rotate(-45*Math.PI/180),t.fillText(T,-m.width/2,m.actualBoundingBoxAscent-r*R/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 g=new Image;g.setAttribute("crossOrigin","Anonymous"),g.src=i,g.onload=()=>{this.imageCache.set(i,g),this.draw.render({isCompute:!1,isSubmitHistory:!1})};return}const d=this.draw.getWidth(),u=this.draw.getHeight(),R=e*c,h=n*c;if(t.save(),t.globalAlpha=l,r){const g=this.draw.getPagePixelRatio(),T=document.createElement("canvas"),f=T.getContext("2d"),p=Math.sqrt(Math.pow(R,2)+Math.pow(h,2)),m=p+2*a[0]*c,C=p+2*a[1]*c;T.width=m,T.height=C,T.style.width=`${m*g}px`,T.style.height=`${C*g}px`,f.translate(m/2,C/2),f.rotate(-45*Math.PI/180),f.translate(-m/2,-C/2),f.drawImage(this.imageCache.get(i),(m-R)/2,(C-h)/2,R,h);const I=t.createPattern(T,"repeat");I&&(t.fillStyle=I,t.fillRect(0,0,d,u))}else{const g=d/2,T=u/2;t.translate(g,T),t.rotate(-45*Math.PI/180),t.drawImage(this.imageCache.get(i),-R/2,-h/2,R,h)}t.restore()}render(t,e){this.options.watermark.type===s.WatermarkType.IMAGE?this.renderImage(t):this.renderText(t,e)}}class Nd{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.isPrintMode(),u=this.draw.getMode(),R=u===s.EditorMode.EDIT||u===s.EditorMode.FORM,h=this.control.getActiveControl()?.getElement(),g=this._getControlType(t,e);let T=!1,f=!1,p=!1,m=!1;c.highlight||(T=!d&&!!n&&!!h&&c.controlId===h.controlId&&!this.control.getIsRangeInPostfix()),T||(f=!d&&!!i&&!!c.control?.disabled),f||(p=!d&&!!l&&!!c.controlId&&this.control.getIsExistValueByElementListIndex(t,e)),p||(m=!d&&!!r&&!!c.controlId&&!this.control.getIsExistValueByElementListIndex(t,e));const C=R&&!!a&&(g===s.ControlType.NUMBER||g===s.ControlType.SELECT||g===s.ControlType.DATE);return(T?n:"")||(f?i:"")||(p?l:"")||(m?r:"")||(C?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.NUMBER||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 T=r.trList;for(let f=0;f<T.length;f++){const p=T[f];for(let m=0;m<p.tdList.length;m++){const C=p.tdList[m],I={tableId:r.id,tableIndex:l-1,trIndex:f,tdIndex:m,tdId:C.id};e(C.value,I)}}}const a=r?.control;if(!a)continue;const c=this.highlightList.findIndex(T=>T.id===r.controlId||a.conceptId&&a.conceptId===T.conceptId);if(!~c)continue;const d=l;let u=l;for(;u<n.length&&n[u].controlId===r.controlId;)u++;l=u;const R=n.slice(d,u).map(T=>T.controlComponent===s.ControlComponent.VALUE?T:{value:K}),h=this.highlightList[c],{ruleList:g}=h;for(let T=0;T<g.length;T++){const f=g[T],p=t.getMatchList(f.keyword,R);this.highlightMatchResult.push(...p.map(m=>({...m,...f,...i,index:m.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:C,trIndex:I,tdIndex:L,index:E}=c;d=r[C]?.trList[I].tdList[L]?.positionList[E]}else d=l[c.index];if(!d)continue;const{coordinate:{leftTop:u,leftBottom:R,rightTop:h},pageNo:g}=d;if(g!==e)continue;t.fillStyle=c.backgroundColor||i,t.globalAlpha=c.alpha||n;const T=u[0],f=u[1],p=h[0]-u[0],m=R[1]-u[1];t.fillRect(T,f,p,m)}t.restore()}}const ar={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)"}},Fd="#ff4d4f",yd=5e3,Di=4;class bd{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})},yd))}getMarks(){return this.marks}render(t,e,n,i,l,r){if(!this.marks.length||this.draw.isPrintMode())return;const a=this._getRegions(e,n,i,l,r);if(a.length){t.save();for(let c=0;c<a.length;c++){const d=a[c],u=this._getStyle(d.mark),R=Math.max(1,this.options.scale),h=d.x-R,g=d.y-R,T=Math.max(1,d.width+R*2),f=Math.max(1,d.height+R*2),p=Math.max(2,this.options.scale*2);if(this.underlineVisible&&u.borderColor&&d.hasUnderline&&(t.lineWidth=p,t.strokeStyle=u.borderColor,t.beginPath(),t.moveTo(d.underlineX,d.underlineY),t.lineTo(d.underlineRight,d.underlineY),t.stroke()),d.drawRequired){this._renderRequiredMark(t,d,h);continue}if(u.borderColor){t.lineWidth=p;const m=Math.min(Math.max(8*this.options.scale,f*.3),f/2),C=h+T,I=g+f;t.beginPath(),d.drawLeft&&(t.moveTo(h+m,g),t.lineTo(h,g),t.lineTo(h,I)),d.drawRight&&(t.moveTo(C-m,I),t.lineTo(C,I),t.lineTo(C,g)),t.stroke()}}t.restore()}}_getRegions(t,e,n,i,l){const r=this._getParentMap(t),a=this.marks.map(R=>this._getTargetControlIds(t,R)),c=a.map(R=>this._getTitleTargets(t,R)),d=[];for(let R=0;R<n.length;R++){const h=n[R],g=new Map;for(let T=0;T<h.elementList.length;T++){const f=h.elementList[T],p=h.startIndex+T,m=e[p];if(!m||l===s.EditorZone.MAIN&&m.pageNo!==i)continue;const C=this._getTargetIdsForElement(this._getQualityTargetId(f),a,r);for(let P=0;P<c.length;P++){const Y=c[P].get(p);Y&&Y.forEach(S=>{C.some(U=>U.markIndex===P&&U.controlId===S)||C.push({markIndex:P,controlId:S})})}if(!C.length)continue;const I=m.coordinate.leftTop,L=m.coordinate.rightTop,E=m.coordinate.leftBottom,O=m.coordinate.rightBottom,F=Math.min(I[0],E[0]),V=Math.max(L[0],O[0]),D=Math.min(I[1],L[1]),b=Math.max(E[1],O[1]),N=m.metrics.boundingBoxAscent+m.metrics.boundingBoxDescent,W=D+m.ascent-m.metrics.boundingBoxAscent,y=N>0?W:D,M=N>0?W+N:b,X=this._isButtonElement(f);for(let P=0;P<C.length;P++){const{markIndex:Y,controlId:S}=C[P],U=`${Y}:${S}:${h.startIndex}`,Q=g.get(U),v={x:F,y,right:V,bottom:M};if(Q){const w=this._mergeBounds(Q,v);Q.x=w.x,Q.y=w.y,Q.width=Math.max(1,w.right-w.x),Q.height=Math.max(1,w.bottom-w.y),X||(Q.hasUnderline?(Q.underlineX=Math.min(Q.underlineX,F),Q.underlineY=Math.max(Q.underlineY,M+Di),Q.underlineRight=Math.max(Q.underlineRight,V)):(Q.underlineX=F,Q.underlineY=M+Di,Q.underlineRight=V),Q.hasUnderline=!0)}else g.set(U,{mark:this.marks[Y],targetKey:`${Y}:${S}`,x:F,y,width:Math.max(1,V-F),height:Math.max(1,M-y),baseline:D+m.ascent,font:f.style||this.draw.getElementFont(f,this.options.scale),underlineX:F,underlineY:M+Di,underlineRight:V,hasUnderline:!X,drawLeft:!1,drawRight:!1,drawRequired:!1})}}d.push(...g.values())}const u=new Map;for(let R=0;R<d.length;R++){const h=d[R],g=u.get(h.targetKey)||[];g.push(h),u.set(h.targetKey,g)}return u.forEach(R=>{this._isRequiredMark(R[0].mark)?R[0].drawRequired=!0:(R[0].drawLeft=!0,R[R.length-1].drawRight=!0)}),d}_renderRequiredMark(t,e,n){t.save(),t.font=e.font,t.fillStyle=e.mark.style?.borderColor||Fd,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(h=>this._getQualityTargetId(h)===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(h=>this._normalizeTitleText(h)),u=this._normalizeTitleText(c);if(!d.some(h=>h===u||h.includes(u)||u.includes(h)))return;let R=l-1;for(;R>=0&&this._isTitleValueElement(t[R]);){let h=n.get(R);h||(h=new Set,n.set(R,h)),h.add(i),R--}}),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{...ar[t.type?.toLowerCase()||"error"]||ar.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 Dd{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 jn{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&&!Os(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&&!Ce.includes(d.type)||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT?ie(d,["control","controlId",...Re]):Ie(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};re(i,[g],r,{editorOptions:this.options}),c.spliceElementList(i,R+h,0,[g])}return R+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 g=l[u];if(g.controlId!==a.controlId||g.controlComponent===s.ControlComponent.PREFIX||g.controlComponent===s.ControlComponent.PRE_TEXT){c=u;break}u--}let R=r+1;for(;R<l.length;){const g=l[R];if(g.controlId!==a.controlId||g.controlComponent===s.ControlComponent.POSTFIX||g.controlComponent===s.ControlComponent.POST_TEXT){d=R-1;break}R++}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&&Ms(d,a)){this.control.repaintControl({curIndex:l.startIndex,isCompute:!1,isSubmitHistory:!1}),this.destroy();return}const R=r.valueSets;if(!Array.isArray(R)||!R.length)return;const h=this.getText(a);if(!h){if(c){const L=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~L&&(this.control.repaintControl({curIndex:L}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],T=g?ie(g,Ne):ie(i[l.startIndex],Re),f=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~f)return;c||this.control.removePlaceholder(f,e);const p=Ie(i[f],Ne),m=f+1,C=yt(h),I=this.control.getDraw();for(let L=0;L<C.length;L++){const E={...T,...p,type:s.ElementType.TEXT,value:C[L],controlComponent:s.ControlComponent.VALUE};(E.color===this.options.control.bracketColor||E.color===this.options.control.placeholderColor)&&(E.color=this.options.defaultColor),re(i,[E],f,{editorOptions:this.options}),I.spliceElementList(i,m+L,0,[E])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:f,endIndex:f}}),!e.range){const L=m+C.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(`${j}-select-control-popup`),i.setAttribute(Ue,s.EditorComponent.POPUP);const l=document.createElement("ul");let r=null;for(let h=0;h<e.length;h++){const g=e[h],T=document.createElement("li");let f=this.getCodes();f.includes(g.code)&&(T.classList.add("active"),r=T),T.onclick=()=>{const p=f.findIndex(m=>m===g.code);t.isMultiSelect?~p?f.splice(p,1):f.push(g.code):~p?f=[]:f=[g.code],this.setSelect(f.join(this.VALUE_DELIMITER))},T.append(document.createTextNode(g.value)),l.append(T)}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&&Xs(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 cr;function st(){return cr.apply(null,arguments)}function Vd(o){cr=o}function ye(o){return o instanceof Array||Object.prototype.toString.call(o)==="[object Array]"}function Ln(o){return o!=null&&Object.prototype.toString.call(o)==="[object Object]"}function Qt(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function Vi(o){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(o).length===0;var t;for(t in o)if(Qt(o,t))return!1;return!0}function me(o){return o===void 0}function $e(o){return typeof o=="number"||Object.prototype.toString.call(o)==="[object Number]"}function qn(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 un(o,t){for(var e in t)Qt(t,e)&&(o[e]=t[e]);return Qt(t,"toString")&&(o.toString=t.toString),Qt(t,"valueOf")&&(o.valueOf=t.valueOf),o}function Ae(o,t,e,n){return wr(o,t,e,n,!0).utc()}function Wd(){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 Mt(o){return o._pf==null&&(o._pf=Wd()),o._pf}var Wi;Array.prototype.some?Wi=Array.prototype.some:Wi=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 Yi(o){var t=null,e=!1,n=o._d&&!isNaN(o._d.getTime());if(n&&(t=Mt(o),e=Wi.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 No(o){var t=Ae(NaN);return o!=null?un(Mt(t),o):Mt(t).userInvalidated=!0,t}var ur=st.momentProperties=[],Ui=!1;function wi(o,t){var e,n,i,l=ur.length;if(me(t._isAMomentObject)||(o._isAMomentObject=t._isAMomentObject),me(t._i)||(o._i=t._i),me(t._f)||(o._f=t._f),me(t._l)||(o._l=t._l),me(t._strict)||(o._strict=t._strict),me(t._tzm)||(o._tzm=t._tzm),me(t._isUTC)||(o._isUTC=t._isUTC),me(t._offset)||(o._offset=t._offset),me(t._pf)||(o._pf=Mt(t)),me(t._locale)||(o._locale=t._locale),l>0)for(e=0;e<l;e++)n=ur[e],i=t[n],me(i)||(o[n]=i);return o}function to(o){wi(this,o),this._d=new Date(o._d!=null?o._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),Ui===!1&&(Ui=!0,st.updateOffset(this),Ui=!1)}function be(o){return o instanceof to||o!=null&&o._isAMomentObject!=null}function Rr(o){st.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+o)}function Me(o,t){var e=!0;return un(function(){if(st.deprecationHandler!=null&&st.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+=`
107
107
  [`+l+"] ";for(r in arguments[0])Qt(arguments[0],r)&&(i+=r+": "+arguments[0][r]+", ");i=i.slice(0,-2)}else i=arguments[l];n.push(i)}Rr(o+`
108
108
  Arguments: `+Array.prototype.slice.call(n).join("")+`
109
109
  `+new Error().stack),e=!1}return t.apply(this,arguments)},t)}var hr={};function gr(o,t){st.deprecationHandler!=null&&st.deprecationHandler(o,t),hr[o]||(Rr(t),hr[o]=!0)}st.suppressDeprecationWarnings=!1,st.deprecationHandler=null;function Ge(o){return typeof Function<"u"&&o instanceof Function||Object.prototype.toString.call(o)==="[object Function]"}function Yd(o){var t,e;for(e in o)Qt(o,e)&&(t=o[e],Ge(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 Zi(o,t){var e=un({},o),n;for(n in t)Qt(t,n)&&(Ln(o[n])&&Ln(t[n])?(e[n]={},un(e[n],o[n]),un(e[n],t[n])):t[n]!=null?e[n]=t[n]:delete e[n]);for(n in o)Qt(o,n)&&!Qt(t,n)&&Ln(o[n])&&(e[n]=un({},e[n]));return e}function Qi(o){o!=null&&this.set(o)}var vi;Object.keys?vi=Object.keys:vi=function(o){var t,e=[];for(t in o)Qt(o,t)&&e.push(t);return e};var Ud={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function wd(o,t,e){var n=this._calendar[o]||this._calendar.sameElse;return Ge(n)?n.call(t,e):n}function ke(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 Ki=/(\[[^\[]*\])|(\\)?([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,Fo=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,Hi={},wn={};function gt(o,t,e,n){var i=n;typeof n=="string"&&(i=function(){return this[n]()}),o&&(wn[o]=i),t&&(wn[t[0]]=function(){return ke(i.apply(this,arguments),t[1],t[2])}),e&&(wn[e]=function(){return this.localeData().ordinal(i.apply(this,arguments),o)})}function Zd(o){return o.match(/\[[\s\S]/)?o.replace(/^\[|\]$/g,""):o.replace(/\\/g,"")}function Qd(o){var t=o.match(Ki),e,n;for(e=0,n=t.length;e<n;e++)wn[t[e]]?t[e]=wn[t[e]]:t[e]=Zd(t[e]);return function(i){var l="",r;for(r=0;r<n;r++)l+=Ge(t[r])?t[r].call(i,o):t[r];return l}}function yo(o,t){return o.isValid()?(t=Tr(t,o.localeData()),Hi[t]=Hi[t]||Qd(t),Hi[t](o)):o.localeData().invalidDate()}function Tr(o,t){var e=5;function n(i){return t.longDateFormat(i)||i}for(Fo.lastIndex=0;e>=0&&Fo.test(o);)o=o.replace(Fo,n),Fo.lastIndex=0,e-=1;return o}var vd={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 Kd(o){var t=this._longDateFormat[o],e=this._longDateFormat[o.toUpperCase()];return t||!e?t:(this._longDateFormat[o]=e.match(Ki).map(function(n){return n==="MMMM"||n==="MM"||n==="DD"||n==="dddd"?n.slice(1):n}).join(""),this._longDateFormat[o])}var Hd="Invalid date";function _d(){return this._invalidDate}var Ad="%d",Gd=/\d{1,2}/;function kd(o){return this._ordinal.replace("%d",o)}var xd={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 Bd(o,t,e,n){var i=this._relativeTime[e];return Ge(i)?i(o,t,e,n):i.replace(/%d/i,o)}function Jd(o,t){var e=this._relativeTime[o>0?"future":"past"];return Ge(e)?e(t):e.replace(/%s/i,t)}var fr={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 Oe(o){return typeof o=="string"?fr[o]||fr[o.toLowerCase()]:void 0}function _i(o){var t={},e,n;for(n in o)Qt(o,n)&&(e=Oe(n),e&&(t[e]=o[n]));return t}var $d={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 zd(o){var t=[],e;for(e in o)Qt(o,e)&&t.push({unit:e,priority:$d[e]});return t.sort(function(n,i){return n.priority-i.priority}),t}var mr=/\d/,Le=/\d\d/,pr=/\d{3}/,Ai=/\d{4}/,bo=/[+-]?\d{6}/,qt=/\d\d?/,Ir=/\d\d\d\d?/,Cr=/\d\d\d\d\d\d?/,Do=/\d{1,3}/,Gi=/\d{1,4}/,Vo=/[+-]?\d{1,6}/,Zn=/\d+/,Wo=/[+-]?\d+/,jd=/Z|[+-]\d\d:?\d\d/gi,Yo=/Z|[+-]\d\d(?::?\d\d)?/gi,qd=/[+-]?\d+(\.\d{1,3})?/,eo=/[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,Qn=/^[1-9]\d?/,ki=/^([1-9]\d|\d)/,Uo;Uo={};function dt(o,t,e){Uo[o]=Ge(t)?t:function(n,i){return n&&e?e:t}}function tu(o,t){return Qt(Uo,o)?Uo[o](t._strict,t._locale):new RegExp(eu(o))}function eu(o){return ze(o.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,i,l){return e||n||i||l}))}function ze(o){return o.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Se(o){return o<0?Math.ceil(o)||0:Math.floor(o)}function bt(o){var t=+o,e=0;return t!==0&&isFinite(t)&&(e=Se(t)),e}var xi={};function Bt(o,t){var e,n=t,i;for(typeof o=="string"&&(o=[o]),$e(t)&&(n=function(l,r){r[t]=bt(l)}),i=o.length,e=0;e<i;e++)xi[o[e]]=n}function no(o,t){Bt(o,function(e,n,i,l){i._w=i._w||{},t(e,i._w,i,l)})}function nu(o,t,e){t!=null&&Qt(xi,o)&&xi[o](t,e._a,e,o)}function wo(o){return o%4===0&&o%100!==0||o%400===0}var ge=0,je=1,xe=2,ae=3,De=4,qe=5,Pn=6,ou=7,iu=8;gt("Y",0,0,function(){var o=this.year();return o<=9999?ke(o,4):"+"+o}),gt(0,["YY",2],0,function(){return this.year()%100}),gt(0,["YYYY",4],0,"year"),gt(0,["YYYYY",5],0,"year"),gt(0,["YYYYYY",6,!0],0,"year"),dt("Y",Wo),dt("YY",qt,Le),dt("YYYY",Gi,Ai),dt("YYYYY",Vo,bo),dt("YYYYYY",Vo,bo),Bt(["YYYYY","YYYYYY"],ge),Bt("YYYY",function(o,t){t[ge]=o.length===2?st.parseTwoDigitYear(o):bt(o)}),Bt("YY",function(o,t){t[ge]=st.parseTwoDigitYear(o)}),Bt("Y",function(o,t){t[ge]=parseInt(o,10)});function oo(o){return wo(o)?366:365}st.parseTwoDigitYear=function(o){return bt(o)+(bt(o)>68?1900:2e3)};var Lr=vn("FullYear",!0);function su(){return wo(this.year())}function vn(o,t){return function(e){return e!=null?(Pr(this,o,e),st.updateOffset(this,t),this):io(this,o)}}function io(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 Pr(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&&!wo(l)?28:a,i?n.setUTCFullYear(l,r,a):n.setFullYear(l,r,a)}}function ru(o){return o=Oe(o),Ge(this[o])?this[o]():this}function lu(o,t){if(typeof o=="object"){o=_i(o);var e=zd(o),n,i=e.length;for(n=0;n<i;n++)this[e[n].unit](o[e[n].unit])}else if(o=Oe(o),Ge(this[o]))return this[o](t);return this}function au(o,t){return(o%t+t)%t}var le;Array.prototype.indexOf?le=Array.prototype.indexOf:le=function(o){var t;for(t=0;t<this.length;++t)if(this[t]===o)return t;return-1};function Bi(o,t){if(isNaN(o)||isNaN(t))return NaN;var e=au(t,12);return o+=(t-e)/12,e===1?wo(o)?29:28:31-e%7%2}gt("M",["MM",2],"Mo",function(){return this.month()+1}),gt("MMM",0,0,function(o){return this.localeData().monthsShort(this,o)}),gt("MMMM",0,0,function(o){return this.localeData().months(this,o)}),dt("M",qt,Qn),dt("MM",qt,Le),dt("MMM",function(o,t){return t.monthsShortRegex(o)}),dt("MMMM",function(o,t){return t.monthsRegex(o)}),Bt(["M","MM"],function(o,t){t[je]=bt(o)-1}),Bt(["MMM","MMMM"],function(o,t,e,n){var i=e._locale.monthsParse(o,n,e._strict);i!=null?t[je]=i:Mt(e).invalidMonth=o});var cu="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Er="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Mr=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,du=eo,uu=eo;function Ru(o,t){return o?ye(this._months)?this._months[o.month()]:this._months[(this._months.isFormat||Mr).test(t)?"format":"standalone"][o.month()]:ye(this._months)?this._months:this._months.standalone}function hu(o,t){return o?ye(this._monthsShort)?this._monthsShort[o.month()]:this._monthsShort[Mr.test(t)?"format":"standalone"][o.month()]:ye(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function gu(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=Ae([2e3,n]),this._shortMonthsParse[n]=this.monthsShort(l,"").toLocaleLowerCase(),this._longMonthsParse[n]=this.months(l,"").toLocaleLowerCase();return e?t==="MMM"?(i=le.call(this._shortMonthsParse,r),i!==-1?i:null):(i=le.call(this._longMonthsParse,r),i!==-1?i:null):t==="MMM"?(i=le.call(this._shortMonthsParse,r),i!==-1?i:(i=le.call(this._longMonthsParse,r),i!==-1?i:null)):(i=le.call(this._longMonthsParse,r),i!==-1?i:(i=le.call(this._shortMonthsParse,r),i!==-1?i:null))}function Tu(o,t,e){var n,i,l;if(this._monthsParseExact)return gu.call(this,o,t,e);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(i=Ae([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 Or(o,t){if(!o.isValid())return o;if(typeof t=="string"){if(/^\d+$/.test(t))t=bt(t);else if(t=o.localeData().monthsParse(t),!$e(t))return o}var e=t,n=o.date();return n=n<29?n:Math.min(n,Bi(o.year(),e)),o._isUTC?o._d.setUTCMonth(e,n):o._d.setMonth(e,n),o}function Sr(o){return o!=null?(Or(this,o),st.updateOffset(this,!0),this):io(this,"Month")}function fu(){return Bi(this.year(),this.month())}function mu(o){return this._monthsParseExact?(Qt(this,"_monthsRegex")||Xr.call(this),o?this._monthsShortStrictRegex:this._monthsShortRegex):(Qt(this,"_monthsShortRegex")||(this._monthsShortRegex=du),this._monthsShortStrictRegex&&o?this._monthsShortStrictRegex:this._monthsShortRegex)}function pu(o){return this._monthsParseExact?(Qt(this,"_monthsRegex")||Xr.call(this),o?this._monthsStrictRegex:this._monthsRegex):(Qt(this,"_monthsRegex")||(this._monthsRegex=uu),this._monthsStrictRegex&&o?this._monthsStrictRegex:this._monthsRegex)}function Xr(){function o(c,d){return d.length-c.length}var t=[],e=[],n=[],i,l,r,a;for(i=0;i<12;i++)l=Ae([2e3,i]),r=ze(this.monthsShort(l,"")),a=ze(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 Iu(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 so(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 Zo(o,t,e){var n=7+t-e,i=(7+so(o,0,n).getUTCDay()-t)%7;return-i+n-1}function Nr(o,t,e,n,i){var l=(7+e-n)%7,r=Zo(o,n,i),a=1+7*(t-1)+l+r,c,d;return a<=0?(c=o-1,d=oo(c)+a):a>oo(o)?(c=o+1,d=a-oo(o)):(c=o,d=a),{year:c,dayOfYear:d}}function ro(o,t,e){var n=Zo(o.year(),t,e),i=Math.floor((o.dayOfYear()-n-1)/7)+1,l,r;return i<1?(r=o.year()-1,l=i+tn(r,t,e)):i>tn(o.year(),t,e)?(l=i-tn(o.year(),t,e),r=o.year()+1):(r=o.year(),l=i),{week:l,year:r}}function tn(o,t,e){var n=Zo(o,t,e),i=Zo(o+1,t,e);return(oo(o)-n+i)/7}gt("w",["ww",2],"wo","week"),gt("W",["WW",2],"Wo","isoWeek"),dt("w",qt,Qn),dt("ww",qt,Le),dt("W",qt,Qn),dt("WW",qt,Le),no(["w","ww","W","WW"],function(o,t,e,n){t[n.substr(0,1)]=bt(o)});function Cu(o){return ro(o,this._week.dow,this._week.doy).week}var Lu={dow:0,doy:6};function Pu(){return this._week.dow}function Eu(){return this._week.doy}function Mu(o){var t=this.localeData().week(this);return o==null?t:this.add((o-t)*7,"d")}function Ou(o){var t=ro(this,1,4).week;return o==null?t:this.add((o-t)*7,"d")}gt("d",0,"do","day"),gt("dd",0,0,function(o){return this.localeData().weekdaysMin(this,o)}),gt("ddd",0,0,function(o){return this.localeData().weekdaysShort(this,o)}),gt("dddd",0,0,function(o){return this.localeData().weekdays(this,o)}),gt("e",0,0,"weekday"),gt("E",0,0,"isoWeekday"),dt("d",qt),dt("e",qt),dt("E",qt),dt("dd",function(o,t){return t.weekdaysMinRegex(o)}),dt("ddd",function(o,t){return t.weekdaysShortRegex(o)}),dt("dddd",function(o,t){return t.weekdaysRegex(o)}),no(["dd","ddd","dddd"],function(o,t,e,n){var i=e._locale.weekdaysParse(o,n,e._strict);i!=null?t.d=i:Mt(e).invalidWeekday=o}),no(["d","e","E"],function(o,t,e,n){t[n]=bt(o)});function Su(o,t){return typeof o!="string"?o:isNaN(o)?(o=t.weekdaysParse(o),typeof o=="number"?o:null):parseInt(o,10)}function Xu(o,t){return typeof o=="string"?t.weekdaysParse(o)%7||7:isNaN(o)?null:o}function Ji(o,t){return o.slice(t,7).concat(o.slice(0,t))}var Nu="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Fr="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Fu="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),yu=eo,bu=eo,Du=eo;function Vu(o,t){var e=ye(this._weekdays)?this._weekdays:this._weekdays[o&&o!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return o===!0?Ji(e,this._week.dow):o?e[o.day()]:e}function Wu(o){return o===!0?Ji(this._weekdaysShort,this._week.dow):o?this._weekdaysShort[o.day()]:this._weekdaysShort}function Yu(o){return o===!0?Ji(this._weekdaysMin,this._week.dow):o?this._weekdaysMin[o.day()]:this._weekdaysMin}function Uu(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=Ae([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=le.call(this._weekdaysParse,r),i!==-1?i:null):t==="ddd"?(i=le.call(this._shortWeekdaysParse,r),i!==-1?i:null):(i=le.call(this._minWeekdaysParse,r),i!==-1?i:null):t==="dddd"?(i=le.call(this._weekdaysParse,r),i!==-1||(i=le.call(this._shortWeekdaysParse,r),i!==-1)?i:(i=le.call(this._minWeekdaysParse,r),i!==-1?i:null)):t==="ddd"?(i=le.call(this._shortWeekdaysParse,r),i!==-1||(i=le.call(this._weekdaysParse,r),i!==-1)?i:(i=le.call(this._minWeekdaysParse,r),i!==-1?i:null)):(i=le.call(this._minWeekdaysParse,r),i!==-1||(i=le.call(this._weekdaysParse,r),i!==-1)?i:(i=le.call(this._shortWeekdaysParse,r),i!==-1?i:null))}function wu(o,t,e){var n,i,l;if(this._weekdaysParseExact)return Uu.call(this,o,t,e);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(i=Ae([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 Zu(o){if(!this.isValid())return o!=null?this:NaN;var t=io(this,"Day");return o!=null?(o=Su(o,this.localeData()),this.add(o-t,"d")):t}function Qu(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 vu(o){if(!this.isValid())return o!=null?this:NaN;if(o!=null){var t=Xu(o,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function Ku(o){return this._weekdaysParseExact?(Qt(this,"_weekdaysRegex")||$i.call(this),o?this._weekdaysStrictRegex:this._weekdaysRegex):(Qt(this,"_weekdaysRegex")||(this._weekdaysRegex=yu),this._weekdaysStrictRegex&&o?this._weekdaysStrictRegex:this._weekdaysRegex)}function Hu(o){return this._weekdaysParseExact?(Qt(this,"_weekdaysRegex")||$i.call(this),o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(Qt(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=bu),this._weekdaysShortStrictRegex&&o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function _u(o){return this._weekdaysParseExact?(Qt(this,"_weekdaysRegex")||$i.call(this),o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(Qt(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=Du),this._weekdaysMinStrictRegex&&o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function $i(){function o(u,R){return R.length-u.length}var t=[],e=[],n=[],i=[],l,r,a,c,d;for(l=0;l<7;l++)r=Ae([2e3,1]).day(l),a=ze(this.weekdaysMin(r,"")),c=ze(this.weekdaysShort(r,"")),d=ze(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 zi(){return this.hours()%12||12}function Au(){return this.hours()||24}gt("H",["HH",2],0,"hour"),gt("h",["hh",2],0,zi),gt("k",["kk",2],0,Au),gt("hmm",0,0,function(){return""+zi.apply(this)+ke(this.minutes(),2)}),gt("hmmss",0,0,function(){return""+zi.apply(this)+ke(this.minutes(),2)+ke(this.seconds(),2)}),gt("Hmm",0,0,function(){return""+this.hours()+ke(this.minutes(),2)}),gt("Hmmss",0,0,function(){return""+this.hours()+ke(this.minutes(),2)+ke(this.seconds(),2)});function yr(o,t){gt(o,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}yr("a",!0),yr("A",!1);function br(o,t){return t._meridiemParse}dt("a",br),dt("A",br),dt("H",qt,ki),dt("h",qt,Qn),dt("k",qt,Qn),dt("HH",qt,Le),dt("hh",qt,Le),dt("kk",qt,Le),dt("hmm",Ir),dt("hmmss",Cr),dt("Hmm",Ir),dt("Hmmss",Cr),Bt(["H","HH"],ae),Bt(["k","kk"],function(o,t,e){var n=bt(o);t[ae]=n===24?0:n}),Bt(["a","A"],function(o,t,e){e._isPm=e._locale.isPM(o),e._meridiem=o}),Bt(["h","hh"],function(o,t,e){t[ae]=bt(o),Mt(e).bigHour=!0}),Bt("hmm",function(o,t,e){var n=o.length-2;t[ae]=bt(o.substr(0,n)),t[De]=bt(o.substr(n)),Mt(e).bigHour=!0}),Bt("hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[ae]=bt(o.substr(0,n)),t[De]=bt(o.substr(n,2)),t[qe]=bt(o.substr(i)),Mt(e).bigHour=!0}),Bt("Hmm",function(o,t,e){var n=o.length-2;t[ae]=bt(o.substr(0,n)),t[De]=bt(o.substr(n))}),Bt("Hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[ae]=bt(o.substr(0,n)),t[De]=bt(o.substr(n,2)),t[qe]=bt(o.substr(i))});function Gu(o){return(o+"").toLowerCase().charAt(0)==="p"}var ku=/[ap]\.?m?\.?/i,xu=vn("Hours",!0);function Bu(o,t,e){return o>11?e?"pm":"PM":e?"am":"AM"}var Dr={calendar:Ud,longDateFormat:vd,invalidDate:Hd,ordinal:Ad,dayOfMonthOrdinalParse:Gd,relativeTime:xd,months:cu,monthsShort:Er,week:Lu,weekdays:Nu,weekdaysMin:Fu,weekdaysShort:Fr,meridiemParse:ku},ee={},lo={},ao;function Ju(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 Vr(o){return o&&o.toLowerCase().replace("_","-")}function $u(o){for(var t=0,e,n,i,l;t<o.length;){for(l=Vr(o[t]).split("-"),e=l.length,n=Vr(o[t+1]),n=n?n.split("-"):null;e>0;){if(i=Qo(l.slice(0,e).join("-")),i)return i;if(n&&n.length>=e&&Ju(l,n)>=e-1)break;e--}t++}return ao}function zu(o){return!!(o&&o.match("^[^/\\\\]*$"))}function Qo(o){var t=null,e;if(ee[o]===void 0&&typeof module<"u"&&module&&module.exports&&zu(o))try{t=ao._abbr,e=require,e("./locale/"+o),Rn(t)}catch{ee[o]=null}return ee[o]}function Rn(o,t){var e;return o&&(me(t)?e=en(o):e=ji(o,t),e?ao=e:typeof console<"u"&&console.warn&&console.warn("Locale "+o+" not found. Did you forget to load it?")),ao._abbr}function ji(o,t){if(t!==null){var e,n=Dr;if(t.abbr=o,ee[o]!=null)gr("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=ee[o]._config;else if(t.parentLocale!=null)if(ee[t.parentLocale]!=null)n=ee[t.parentLocale]._config;else if(e=Qo(t.parentLocale),e!=null)n=e._config;else return lo[t.parentLocale]||(lo[t.parentLocale]=[]),lo[t.parentLocale].push({name:o,config:t}),null;return ee[o]=new Qi(Zi(n,t)),lo[o]&&lo[o].forEach(function(i){ji(i.name,i.config)}),Rn(o),ee[o]}else return delete ee[o],null}function ju(o,t){if(t!=null){var e,n,i=Dr;ee[o]!=null&&ee[o].parentLocale!=null?ee[o].set(Zi(ee[o]._config,t)):(n=Qo(o),n!=null&&(i=n._config),t=Zi(i,t),n==null&&(t.abbr=o),e=new Qi(t),e.parentLocale=ee[o],ee[o]=e),Rn(o)}else ee[o]!=null&&(ee[o].parentLocale!=null?(ee[o]=ee[o].parentLocale,o===Rn()&&Rn(o)):ee[o]!=null&&delete ee[o]);return ee[o]}function en(o){var t;if(o&&o._locale&&o._locale._abbr&&(o=o._locale._abbr),!o)return ao;if(!ye(o)){if(t=Qo(o),t)return t;o=[o]}return $u(o)}function qu(){return vi(ee)}function qi(o){var t,e=o._a;return e&&Mt(o).overflow===-2&&(t=e[je]<0||e[je]>11?je:e[xe]<1||e[xe]>Bi(e[ge],e[je])?xe:e[ae]<0||e[ae]>24||e[ae]===24&&(e[De]!==0||e[qe]!==0||e[Pn]!==0)?ae:e[De]<0||e[De]>59?De:e[qe]<0||e[qe]>59?qe:e[Pn]<0||e[Pn]>999?Pn:-1,Mt(o)._overflowDayOfYear&&(t<ge||t>xe)&&(t=xe),Mt(o)._overflowWeeks&&t===-1&&(t=ou),Mt(o)._overflowWeekday&&t===-1&&(t=iu),Mt(o).overflow=t),o}var tR=/^\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=/^\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)?)?$/,nR=/Z|[+-]\d\d(?::?\d\d)?/,vo=[["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]],ts=[["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/]],oR=/^\/?Date\((-?\d+)/i,iR=/^(?:(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}))$/,sR={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Wr(o){var t,e,n=o._i,i=tR.exec(n)||eR.exec(n),l,r,a,c,d=vo.length,u=ts.length;if(i){for(Mt(o).iso=!0,t=0,e=d;t<e;t++)if(vo[t][1].exec(i[1])){r=vo[t][0],l=vo[t][2]!==!1;break}if(r==null){o._isValid=!1;return}if(i[3]){for(t=0,e=u;t<e;t++)if(ts[t][1].exec(i[3])){a=(i[2]||" ")+ts[t][0];break}if(a==null){o._isValid=!1;return}}if(!l&&a!=null){o._isValid=!1;return}if(i[4])if(nR.exec(i[4]))c="Z";else{o._isValid=!1;return}o._f=r+(a||"")+(c||""),ns(o)}else o._isValid=!1}function rR(o,t,e,n,i,l){var r=[lR(o),Er.indexOf(t),parseInt(e,10),parseInt(n,10),parseInt(i,10)];return l&&r.push(parseInt(l,10)),r}function lR(o){var t=parseInt(o,10);return t<=49?2e3+t:t<=999?1900+t:t}function aR(o){return o.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function cR(o,t,e){if(o){var n=Fr.indexOf(o),i=new Date(t[0],t[1],t[2]).getDay();if(n!==i)return Mt(e).weekdayMismatch=!0,e._isValid=!1,!1}return!0}function dR(o,t,e){if(o)return sR[o];if(t)return 0;var n=parseInt(e,10),i=n%100,l=(n-i)/100;return l*60+i}function Yr(o){var t=iR.exec(aR(o._i)),e;if(t){if(e=rR(t[4],t[3],t[2],t[5],t[6],t[7]),!cR(t[1],e,o))return;o._a=e,o._tzm=dR(t[8],t[9],t[10]),o._d=so.apply(null,o._a),o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),Mt(o).rfc2822=!0}else o._isValid=!1}function uR(o){var t=oR.exec(o._i);if(t!==null){o._d=new Date(+t[1]);return}if(Wr(o),o._isValid===!1)delete o._isValid;else return;if(Yr(o),o._isValid===!1)delete o._isValid;else return;o._strict?o._isValid=!1:st.createFromInputFallback(o)}st.createFromInputFallback=Me("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 Kn(o,t,e){return o??t??e}function RR(o){var t=new Date(st.now());return o._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function es(o){var t,e,n=[],i,l,r;if(!o._d){for(i=RR(o),o._w&&o._a[xe]==null&&o._a[je]==null&&hR(o),o._dayOfYear!=null&&(r=Kn(o._a[ge],i[ge]),(o._dayOfYear>oo(r)||o._dayOfYear===0)&&(Mt(o)._overflowDayOfYear=!0),e=so(r,0,o._dayOfYear),o._a[je]=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[ae]===24&&o._a[De]===0&&o._a[qe]===0&&o._a[Pn]===0&&(o._nextDay=!0,o._a[ae]=0),o._d=(o._useUTC?so:Iu).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[ae]=24),o._w&&typeof o._w.d<"u"&&o._w.d!==l&&(Mt(o).weekdayMismatch=!0)}}function hR(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=Kn(t.GG,o._a[ge],ro(te(),1,4).year),n=Kn(t.W,1),i=Kn(t.E,1),(i<1||i>7)&&(c=!0)):(l=o._locale._week.dow,r=o._locale._week.doy,d=ro(te(),l,r),e=Kn(t.gg,o._a[ge],d.year),n=Kn(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>tn(e,l,r)?Mt(o)._overflowWeeks=!0:c!=null?Mt(o)._overflowWeekday=!0:(a=Nr(e,n,i,l,r),o._a[ge]=a.year,o._dayOfYear=a.dayOfYear)}st.ISO_8601=function(){},st.RFC_2822=function(){};function ns(o){if(o._f===st.ISO_8601){Wr(o);return}if(o._f===st.RFC_2822){Yr(o);return}o._a=[],Mt(o).empty=!0;var t=""+o._i,e,n,i,l,r,a=t.length,c=0,d,u;for(i=Tr(o._f,o._locale).match(Ki)||[],u=i.length,e=0;e<u;e++)l=i[e],n=(t.match(tu(l,o))||[])[0],n&&(r=t.substr(0,t.indexOf(n)),r.length>0&&Mt(o).unusedInput.push(r),t=t.slice(t.indexOf(n)+n.length),c+=n.length),wn[l]?(n?Mt(o).empty=!1:Mt(o).unusedTokens.push(l),nu(l,n,o)):o._strict&&!n&&Mt(o).unusedTokens.push(l);Mt(o).charsLeftOver=a-c,t.length>0&&Mt(o).unusedInput.push(t),o._a[ae]<=12&&Mt(o).bigHour===!0&&o._a[ae]>0&&(Mt(o).bigHour=void 0),Mt(o).parsedDateParts=o._a.slice(0),Mt(o).meridiem=o._meridiem,o._a[ae]=gR(o._locale,o._a[ae],o._meridiem),d=Mt(o).era,d!==null&&(o._a[ge]=o._locale.erasConvertYear(d,o._a[ge])),es(o),qi(o)}function gR(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 TR(o){var t,e,n,i,l,r,a=!1,c=o._f.length;if(c===0){Mt(o).invalidFormat=!0,o._d=new Date(NaN);return}for(i=0;i<c;i++)l=0,r=!1,t=wi({},o),o._useUTC!=null&&(t._useUTC=o._useUTC),t._f=o._f[i],ns(t),Yi(t)&&(r=!0),l+=Mt(t).charsLeftOver,l+=Mt(t).unusedTokens.length*10,Mt(t).score=l,a?l<n&&(n=l,e=t):(n==null||l<n||r)&&(n=l,e=t,r&&(a=!0));un(o,e||t)}function fR(o){if(!o._d){var t=_i(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)}),es(o)}}function mR(o){var t=new to(qi(Ur(o)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function Ur(o){var t=o._i,e=o._f;return o._locale=o._locale||en(o._l),t===null||e===void 0&&t===""?No({nullInput:!0}):(typeof t=="string"&&(o._i=t=o._locale.preparse(t)),be(t)?new to(qi(t)):(qn(t)?o._d=t:ye(e)?TR(o):e?ns(o):pR(o),Yi(o)||(o._d=null),o))}function pR(o){var t=o._i;me(t)?o._d=new Date(st.now()):qn(t)?o._d=new Date(t.valueOf()):typeof t=="string"?uR(o):ye(t)?(o._a=dr(t.slice(0),function(e){return parseInt(e,10)}),es(o)):Ln(t)?fR(o):$e(t)?o._d=new Date(t):st.createFromInputFallback(o)}function wr(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),(Ln(o)&&Vi(o)||ye(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,mR(l)}function te(o,t,e,n){return wr(o,t,e,n,!1)}var IR=Me("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=te.apply(null,arguments);return this.isValid()&&o.isValid()?o<this?this:o:No()}),CR=Me("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var o=te.apply(null,arguments);return this.isValid()&&o.isValid()?o>this?this:o:No()});function Zr(o,t){var e,n;if(t.length===1&&ye(t[0])&&(t=t[0]),!t.length)return te();for(e=t[0],n=1;n<t.length;++n)(!t[n].isValid()||t[n][o](e))&&(e=t[n]);return e}function LR(){var o=[].slice.call(arguments,0);return Zr("isBefore",o)}function PR(){var o=[].slice.call(arguments,0);return Zr("isAfter",o)}var ER=function(){return Date.now?Date.now():+new Date},co=["year","quarter","month","week","day","hour","minute","second","millisecond"];function MR(o){var t,e=!1,n,i=co.length;for(t in o)if(Qt(o,t)&&!(le.call(co,t)!==-1&&(o[t]==null||!isNaN(o[t]))))return!1;for(n=0;n<i;++n)if(o[co[n]]){if(e)return!1;parseFloat(o[co[n]])!==bt(o[co[n]])&&(e=!0)}return!0}function OR(){return this._isValid}function SR(){return Ve(NaN)}function Ko(o){var t=_i(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=MR(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=en(),this._bubble()}function Ho(o){return o instanceof Ko}function os(o){return o<0?Math.round(-1*o)*-1:Math.round(o)}function XR(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++)bt(o[r])!==bt(t[r])&&l++;return l+i}function Qr(o,t){gt(o,0,0,function(){var e=this.utcOffset(),n="+";return e<0&&(e=-e,n="-"),n+ke(~~(e/60),2)+t+ke(~~e%60,2)})}Qr("Z",":"),Qr("ZZ",""),dt("Z",Yo),dt("ZZ",Yo),Bt(["Z","ZZ"],function(o,t,e){e._useUTC=!0,e._tzm=is(Yo,o)});var NR=/([\+\-]|\d\d)/gi;function is(o,t){var e=(t||"").match(o),n,i,l;return e===null?null:(n=e[e.length-1]||[],i=(n+"").match(NR)||["-",0,0],l=+(i[1]*60)+bt(i[2]),l===0?0:i[0]==="+"?l:-l)}function ss(o,t){var e,n;return t._isUTC?(e=t.clone(),n=(be(o)||qn(o)?o.valueOf():te(o).valueOf())-e.valueOf(),e._d.setTime(e._d.valueOf()+n),st.updateOffset(e,!1),e):te(o).local()}function rs(o){return-Math.round(o._d.getTimezoneOffset())}st.updateOffset=function(){};function FR(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=is(Yo,o),o===null)return this}else Math.abs(o)<16&&!e&&(o=o*60);return!this._isUTC&&t&&(i=rs(this)),this._offset=o,this._isUTC=!0,i!=null&&this.add(i,"m"),n!==o&&(!t||this._changeInProgress?_r(this,Ve(o-n,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,st.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?n:rs(this)}function yR(o,t){return o!=null?(typeof o!="string"&&(o=-o),this.utcOffset(o,t),this):-this.utcOffset()}function bR(o){return this.utcOffset(0,o)}function DR(o){return this._isUTC&&(this.utcOffset(0,o),this._isUTC=!1,o&&this.subtract(rs(this),"m")),this}function VR(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var o=is(jd,this._i);o!=null?this.utcOffset(o):this.utcOffset(0,!0)}return this}function WR(o){return this.isValid()?(o=o?te(o).utcOffset():0,(this.utcOffset()-o)%60===0):!1}function YR(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function UR(){if(!me(this._isDSTShifted))return this._isDSTShifted;var o={},t;return wi(o,this),o=Ur(o),o._a?(t=o._isUTC?Ae(o._a):te(o._a),this._isDSTShifted=this.isValid()&&XR(o._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function wR(){return this.isValid()?!this._isUTC:!1}function ZR(){return this.isValid()?this._isUTC:!1}function vr(){return this.isValid()?this._isUTC&&this._offset===0:!1}var QR=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,vR=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Ve(o,t){var e=o,n=null,i,l,r;return Ho(o)?e={ms:o._milliseconds,d:o._days,M:o._months}:$e(o)||!isNaN(+o)?(e={},t?e[t]=+o:e.milliseconds=+o):(n=QR.exec(o))?(i=n[1]==="-"?-1:1,e={y:0,d:bt(n[xe])*i,h:bt(n[ae])*i,m:bt(n[De])*i,s:bt(n[qe])*i,ms:bt(os(n[Pn]*1e3))*i}):(n=vR.exec(o))?(i=n[1]==="-"?-1:1,e={y:En(n[2],i),M:En(n[3],i),w:En(n[4],i),d:En(n[5],i),h:En(n[6],i),m:En(n[7],i),s:En(n[8],i)}):e==null?e={}:typeof e=="object"&&("from"in e||"to"in e)&&(r=KR(te(e.from),te(e.to)),e={},e.ms=r.milliseconds,e.M=r.months),l=new Ko(e),Ho(o)&&Qt(o,"_locale")&&(l._locale=o._locale),Ho(o)&&Qt(o,"_isValid")&&(l._isValid=o._isValid),l}Ve.fn=Ko.prototype,Ve.invalid=SR;function En(o,t){var e=o&&parseFloat(o.replace(",","."));return(isNaN(e)?0:e)*t}function Kr(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 KR(o,t){var e;return o.isValid()&&t.isValid()?(t=ss(t,o),o.isBefore(t)?e=Kr(o,t):(e=Kr(t,o),e.milliseconds=-e.milliseconds,e.months=-e.months),e):{milliseconds:0,months:0}}function Hr(o,t){return function(e,n){var i,l;return n!==null&&!isNaN(+n)&&(gr(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=Ve(e,n),_r(this,i,o),this}}function _r(o,t,e,n){var i=t._milliseconds,l=os(t._days),r=os(t._months);o.isValid()&&(n=n??!0,r&&Or(o,io(o,"Month")+r*e),l&&Pr(o,"Date",io(o,"Date")+l*e),i&&o._d.setTime(o._d.valueOf()+i*e),n&&st.updateOffset(o,l||r))}var HR=Hr(1,"add"),_R=Hr(-1,"subtract");function Ar(o){return typeof o=="string"||o instanceof String}function AR(o){return be(o)||qn(o)||Ar(o)||$e(o)||kR(o)||GR(o)||o===null||o===void 0}function GR(o){var t=Ln(o)&&!Vi(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||Qt(o,l);return t&&e}function kR(o){var t=ye(o),e=!1;return t&&(e=o.filter(function(n){return!$e(n)&&Ar(o)}).length===0),t&&e}function xR(o){var t=Ln(o)&&!Vi(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||Qt(o,l);return t&&e}function BR(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 JR(o,t){arguments.length===1&&(arguments[0]?AR(arguments[0])?(o=arguments[0],t=void 0):xR(arguments[0])&&(t=arguments[0],o=void 0):(o=void 0,t=void 0));var e=o||te(),n=ss(e,this).startOf("day"),i=st.calendarFormat(this,n)||"sameElse",l=t&&(Ge(t[i])?t[i].call(this,e):t[i]);return this.format(l||this.localeData().calendar(i,this,te(e)))}function $R(){return new to(this)}function zR(o,t){var e=be(o)?o:te(o);return this.isValid()&&e.isValid()?(t=Oe(t)||"millisecond",t==="millisecond"?this.valueOf()>e.valueOf():e.valueOf()<this.clone().startOf(t).valueOf()):!1}function jR(o,t){var e=be(o)?o:te(o);return this.isValid()&&e.isValid()?(t=Oe(t)||"millisecond",t==="millisecond"?this.valueOf()<e.valueOf():this.clone().endOf(t).valueOf()<e.valueOf()):!1}function qR(o,t,e,n){var i=be(o)?o:te(o),l=be(t)?t:te(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 th(o,t){var e=be(o)?o:te(o),n;return this.isValid()&&e.isValid()?(t=Oe(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 eh(o,t){return this.isSame(o,t)||this.isAfter(o,t)}function nh(o,t){return this.isSame(o,t)||this.isBefore(o,t)}function oh(o,t,e){var n,i,l;if(!this.isValid())return NaN;if(n=ss(o,this),!n.isValid())return NaN;switch(i=(n.utcOffset()-this.utcOffset())*6e4,t=Oe(t),t){case"year":l=_o(this,n)/12;break;case"month":l=_o(this,n);break;case"quarter":l=_o(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:Se(l)}function _o(o,t){if(o.date()<t.date())return-_o(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}st.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",st.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function ih(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function sh(o){if(!this.isValid())return null;var t=o!==!0,e=t?this.clone().utc():this;return e.year()<0||e.year()>9999?yo(e,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):Ge(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",yo(e,"Z")):yo(e,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function rh(){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 lh(o){o||(o=this.isUtc()?st.defaultFormatUtc:st.defaultFormat);var t=yo(this,o);return this.localeData().postformat(t)}function ah(o,t){return this.isValid()&&(be(o)&&o.isValid()||te(o).isValid())?Ve({to:this,from:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function ch(o){return this.from(te(),o)}function dh(o,t){return this.isValid()&&(be(o)&&o.isValid()||te(o).isValid())?Ve({from:this,to:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function uh(o){return this.to(te(),o)}function Gr(o){var t;return o===void 0?this._locale._abbr:(t=en(o),t!=null&&(this._locale=t),this)}var kr=Me("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 xr(){return this._locale}var Ao=1e3,Hn=60*Ao,Go=60*Hn,Br=(365*400+97)*24*Go;function _n(o,t){return(o%t+t)%t}function Jr(o,t,e){return o<100&&o>=0?new Date(o+400,t,e)-Br:new Date(o,t,e).valueOf()}function $r(o,t,e){return o<100&&o>=0?Date.UTC(o+400,t,e)-Br:Date.UTC(o,t,e)}function Rh(o){var t,e;if(o=Oe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?$r:Jr,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-=_n(t+(this._isUTC?0:this.utcOffset()*Hn),Go);break;case"minute":t=this._d.valueOf(),t-=_n(t,Hn);break;case"second":t=this._d.valueOf(),t-=_n(t,Ao);break}return this._d.setTime(t),st.updateOffset(this,!0),this}function hh(o){var t,e;if(o=Oe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?$r:Jr,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+=Go-_n(t+(this._isUTC?0:this.utcOffset()*Hn),Go)-1;break;case"minute":t=this._d.valueOf(),t+=Hn-_n(t,Hn)-1;break;case"second":t=this._d.valueOf(),t+=Ao-_n(t,Ao)-1;break}return this._d.setTime(t),st.updateOffset(this,!0),this}function gh(){return this._d.valueOf()-(this._offset||0)*6e4}function Th(){return Math.floor(this.valueOf()/1e3)}function fh(){return new Date(this.valueOf())}function mh(){var o=this;return[o.year(),o.month(),o.date(),o.hour(),o.minute(),o.second(),o.millisecond()]}function ph(){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 Ih(){return this.isValid()?this.toISOString():null}function Ch(){return Yi(this)}function Lh(){return un({},Mt(this))}function Ph(){return Mt(this).overflow}function Eh(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}gt("N",0,0,"eraAbbr"),gt("NN",0,0,"eraAbbr"),gt("NNN",0,0,"eraAbbr"),gt("NNNN",0,0,"eraName"),gt("NNNNN",0,0,"eraNarrow"),gt("y",["y",1],"yo","eraYear"),gt("y",["yy",2],0,"eraYear"),gt("y",["yyy",3],0,"eraYear"),gt("y",["yyyy",4],0,"eraYear"),dt("N",ls),dt("NN",ls),dt("NNN",ls),dt("NNNN",Wh),dt("NNNNN",Yh),Bt(["N","NN","NNN","NNNN","NNNNN"],function(o,t,e,n){var i=e._locale.erasParse(o,n,e._strict);i?Mt(e).era=i:Mt(e).invalidEra=o}),dt("y",Zn),dt("yy",Zn),dt("yyy",Zn),dt("yyyy",Zn),dt("yo",Uh),Bt(["y","yy","yyy","yyyy"],ge),Bt(["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 Mh(o,t){var e,n,i,l=this._eras||en("en")._eras;for(e=0,n=l.length;e<n;++e)switch(typeof l[e].since==="string"&&(i=st(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=st(l[e].until).startOf("day").valueOf(),l[e].until=i.valueOf();break}return l}function Oh(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 Sh(o,t){var e=o.since<=o.until?1:-1;return t===void 0?st(o.since).year():st(o.since).year()+(t-o.offset)*e}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].name;return""}function Nh(){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 Fh(){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 yh(){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()-st(i[o].since).year())*e+i[o].offset;return this.year()}function bh(o){return Qt(this,"_erasNameRegex")||as.call(this),o?this._erasNameRegex:this._erasRegex}function Dh(o){return Qt(this,"_erasAbbrRegex")||as.call(this),o?this._erasAbbrRegex:this._erasRegex}function Vh(o){return Qt(this,"_erasNarrowRegex")||as.call(this),o?this._erasNarrowRegex:this._erasRegex}function ls(o,t){return t.erasAbbrRegex(o)}function Wh(o,t){return t.erasNameRegex(o)}function Yh(o,t){return t.erasNarrowRegex(o)}function Uh(o,t){return t._eraYearOrdinalRegex||Zn}function as(){var o=[],t=[],e=[],n=[],i,l,r,a,c,d=this.eras();for(i=0,l=d.length;i<l;++i)r=ze(d[i].name),a=ze(d[i].abbr),c=ze(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")}gt(0,["gg",2],0,function(){return this.weekYear()%100}),gt(0,["GG",2],0,function(){return this.isoWeekYear()%100});function ko(o,t){gt(0,[o,o.length],0,t)}ko("gggg","weekYear"),ko("ggggg","weekYear"),ko("GGGG","isoWeekYear"),ko("GGGGG","isoWeekYear"),dt("G",Wo),dt("g",Wo),dt("GG",qt,Le),dt("gg",qt,Le),dt("GGGG",Gi,Ai),dt("gggg",Gi,Ai),dt("GGGGG",Vo,bo),dt("ggggg",Vo,bo),no(["gggg","ggggg","GGGG","GGGGG"],function(o,t,e,n){t[n.substr(0,2)]=bt(o)}),no(["gg","GG"],function(o,t,e,n){t[n]=st.parseTwoDigitYear(o)});function wh(o){return zr.call(this,o,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function Zh(o){return zr.call(this,o,this.isoWeek(),this.isoWeekday(),1,4)}function Qh(){return tn(this.year(),1,4)}function vh(){return tn(this.isoWeekYear(),1,4)}function Kh(){var o=this.localeData()._week;return tn(this.year(),o.dow,o.doy)}function Hh(){var o=this.localeData()._week;return tn(this.weekYear(),o.dow,o.doy)}function zr(o,t,e,n,i){var l;return o==null?ro(this,n,i).year:(l=tn(o,n,i),t>l&&(t=l),_h.call(this,o,t,e,n,i))}function _h(o,t,e,n,i){var l=Nr(o,t,e,n,i),r=so(l.year,0,l.dayOfYear);return this.year(r.getUTCFullYear()),this.month(r.getUTCMonth()),this.date(r.getUTCDate()),this}gt("Q",0,"Qo","quarter"),dt("Q",mr),Bt("Q",function(o,t){t[je]=(bt(o)-1)*3});function Ah(o){return o==null?Math.ceil((this.month()+1)/3):this.month((o-1)*3+this.month()%3)}gt("D",["DD",2],"Do","date"),dt("D",qt,Qn),dt("DD",qt,Le),dt("Do",function(o,t){return o?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Bt(["D","DD"],xe),Bt("Do",function(o,t){t[xe]=bt(o.match(qt)[0])});var jr=vn("Date",!0);gt("DDD",["DDDD",3],"DDDo","dayOfYear"),dt("DDD",Do),dt("DDDD",pr),Bt(["DDD","DDDD"],function(o,t,e){e._dayOfYear=bt(o)});function Gh(o){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return o==null?t:this.add(o-t,"d")}gt("m",["mm",2],0,"minute"),dt("m",qt,ki),dt("mm",qt,Le),Bt(["m","mm"],De);var kh=vn("Minutes",!1);gt("s",["ss",2],0,"second"),dt("s",qt,ki),dt("ss",qt,Le),Bt(["s","ss"],qe);var xh=vn("Seconds",!1);gt("S",0,0,function(){return~~(this.millisecond()/100)}),gt(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),gt(0,["SSS",3],0,"millisecond"),gt(0,["SSSS",4],0,function(){return this.millisecond()*10}),gt(0,["SSSSS",5],0,function(){return this.millisecond()*100}),gt(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),gt(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),gt(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),gt(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),dt("S",Do,mr),dt("SS",Do,Le),dt("SSS",Do,pr);var hn,qr;for(hn="SSSS";hn.length<=9;hn+="S")dt(hn,Zn);function Bh(o,t){t[Pn]=bt(("0."+o)*1e3)}for(hn="S";hn.length<=9;hn+="S")Bt(hn,Bh);qr=vn("Milliseconds",!1),gt("z",0,0,"zoneAbbr"),gt("zz",0,0,"zoneName");function Jh(){return this._isUTC?"UTC":""}function $h(){return this._isUTC?"Coordinated Universal Time":""}var J=to.prototype;J.add=HR,J.calendar=JR,J.clone=$R,J.diff=oh,J.endOf=hh,J.format=lh,J.from=ah,J.fromNow=ch,J.to=dh,J.toNow=uh,J.get=ru,J.invalidAt=Ph,J.isAfter=zR,J.isBefore=jR,J.isBetween=qR,J.isSame=th,J.isSameOrAfter=eh,J.isSameOrBefore=nh,J.isValid=Ch,J.lang=kr,J.locale=Gr,J.localeData=xr,J.max=CR,J.min=IR,J.parsingFlags=Lh,J.set=lu,J.startOf=Rh,J.subtract=_R,J.toArray=mh,J.toObject=ph,J.toDate=fh,J.toISOString=sh,J.inspect=rh,typeof Symbol<"u"&&Symbol.for!=null&&(J[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),J.toJSON=Ih,J.toString=ih,J.unix=Th,J.valueOf=gh,J.creationData=Eh,J.eraName=Xh,J.eraNarrow=Nh,J.eraAbbr=Fh,J.eraYear=yh,J.year=Lr,J.isLeapYear=su,J.weekYear=wh,J.isoWeekYear=Zh,J.quarter=J.quarters=Ah,J.month=Sr,J.daysInMonth=fu,J.week=J.weeks=Mu,J.isoWeek=J.isoWeeks=Ou,J.weeksInYear=Kh,J.weeksInWeekYear=Hh,J.isoWeeksInYear=Qh,J.isoWeeksInISOWeekYear=vh,J.date=jr,J.day=J.days=Zu,J.weekday=Qu,J.isoWeekday=vu,J.dayOfYear=Gh,J.hour=J.hours=xu,J.minute=J.minutes=kh,J.second=J.seconds=xh,J.millisecond=J.milliseconds=qr,J.utcOffset=FR,J.utc=bR,J.local=DR,J.parseZone=VR,J.hasAlignedHourOffset=WR,J.isDST=YR,J.isLocal=wR,J.isUtcOffset=ZR,J.isUtc=vr,J.isUTC=vr,J.zoneAbbr=Jh,J.zoneName=$h,J.dates=Me("dates accessor is deprecated. Use date instead.",jr),J.months=Me("months accessor is deprecated. Use month instead",Sr),J.years=Me("years accessor is deprecated. Use year instead",Lr),J.zone=Me("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",yR),J.isDSTShifted=Me("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",UR);function zh(o){return te(o*1e3)}function jh(){return te.apply(null,arguments).parseZone()}function tl(o){return o}var vt=Qi.prototype;vt.calendar=wd,vt.longDateFormat=Kd,vt.invalidDate=_d,vt.ordinal=kd,vt.preparse=tl,vt.postformat=tl,vt.relativeTime=Bd,vt.pastFuture=Jd,vt.set=Yd,vt.eras=Mh,vt.erasParse=Oh,vt.erasConvertYear=Sh,vt.erasAbbrRegex=Dh,vt.erasNameRegex=bh,vt.erasNarrowRegex=Vh,vt.months=Ru,vt.monthsShort=hu,vt.monthsParse=Tu,vt.monthsRegex=pu,vt.monthsShortRegex=mu,vt.week=Cu,vt.firstDayOfYear=Eu,vt.firstDayOfWeek=Pu,vt.weekdays=Vu,vt.weekdaysMin=Yu,vt.weekdaysShort=Wu,vt.weekdaysParse=wu,vt.weekdaysRegex=Ku,vt.weekdaysShortRegex=Hu,vt.weekdaysMinRegex=_u,vt.isPM=Gu,vt.meridiem=Bu;function xo(o,t,e,n){var i=en(),l=Ae().set(n,t);return i[e](l,o)}function el(o,t,e){if($e(o)&&(t=o,o=void 0),o=o||"",t!=null)return xo(o,t,e,"month");var n,i=[];for(n=0;n<12;n++)i[n]=xo(o,n,e,"month");return i}function cs(o,t,e,n){typeof o=="boolean"?($e(t)&&(e=t,t=void 0),t=t||""):(t=o,e=t,o=!1,$e(t)&&(e=t,t=void 0),t=t||"");var i=en(),l=o?i._week.dow:0,r,a=[];if(e!=null)return xo(t,(e+l)%7,n,"day");for(r=0;r<7;r++)a[r]=xo(t,(r+l)%7,n,"day");return a}function qh(o,t){return el(o,t,"months")}function tg(o,t){return el(o,t,"monthsShort")}function eg(o,t,e){return cs(o,t,e,"weekdays")}function ng(o,t,e){return cs(o,t,e,"weekdaysShort")}function og(o,t,e){return cs(o,t,e,"weekdaysMin")}Rn("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=bt(o%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return o+e}}),st.lang=Me("moment.lang is deprecated. Use moment.locale instead.",Rn),st.langData=Me("moment.langData is deprecated. Use moment.localeData instead.",en);var nn=Math.abs;function ig(){var o=this._data;return this._milliseconds=nn(this._milliseconds),this._days=nn(this._days),this._months=nn(this._months),o.milliseconds=nn(o.milliseconds),o.seconds=nn(o.seconds),o.minutes=nn(o.minutes),o.hours=nn(o.hours),o.months=nn(o.months),o.years=nn(o.years),this}function nl(o,t,e,n){var i=Ve(t,e);return o._milliseconds+=n*i._milliseconds,o._days+=n*i._days,o._months+=n*i._months,o._bubble()}function sg(o,t){return nl(this,o,t,1)}function rg(o,t){return nl(this,o,t,-1)}function ol(o){return o<0?Math.floor(o):Math.ceil(o)}function lg(){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+=ol(ds(e)+t)*864e5,t=0,e=0),n.milliseconds=o%1e3,i=Se(o/1e3),n.seconds=i%60,l=Se(i/60),n.minutes=l%60,r=Se(l/60),n.hours=r%24,t+=Se(r/24),c=Se(il(t)),e+=c,t-=ol(ds(c)),a=Se(e/12),e%=12,n.days=t,n.months=e,n.years=a,this}function il(o){return o*4800/146097}function ds(o){return o*146097/4800}function ag(o){if(!this.isValid())return NaN;var t,e,n=this._milliseconds;if(o=Oe(o),o==="month"||o==="quarter"||o==="year")switch(t=this._days+n/864e5,e=this._months+il(t),o){case"month":return e;case"quarter":return e/3;case"year":return e/12}else switch(t=this._days+Math.round(ds(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 on(o){return function(){return this.as(o)}}var sl=on("ms"),cg=on("s"),dg=on("m"),ug=on("h"),Rg=on("d"),hg=on("w"),gg=on("M"),Tg=on("Q"),fg=on("y"),mg=sl;function pg(){return Ve(this)}function Ig(o){return o=Oe(o),this.isValid()?this[o+"s"]():NaN}function Mn(o){return function(){return this.isValid()?this._data[o]:NaN}}var Cg=Mn("milliseconds"),Lg=Mn("seconds"),Pg=Mn("minutes"),Eg=Mn("hours"),Mg=Mn("days"),Og=Mn("months"),Sg=Mn("years");function Xg(){return Se(this.days()/7)}var sn=Math.round,An={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Ng(o,t,e,n,i){return i.relativeTime(t||1,!!e,o,n)}function Fg(o,t,e,n){var i=Ve(o).abs(),l=sn(i.as("s")),r=sn(i.as("m")),a=sn(i.as("h")),c=sn(i.as("d")),d=sn(i.as("M")),u=sn(i.as("w")),R=sn(i.as("y")),h=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&&(h=h||u<=1&&["w"]||u<e.w&&["ww",u]),h=h||d<=1&&["M"]||d<e.M&&["MM",d]||R<=1&&["y"]||["yy",R],h[2]=t,h[3]=+o>0,h[4]=n,Ng.apply(null,h)}function yg(o){return o===void 0?sn:typeof o=="function"?(sn=o,!0):!1}function bg(o,t){return An[o]===void 0?!1:t===void 0?An[o]:(An[o]=t,o==="s"&&(An.ss=t-1),!0)}function Dg(o,t){if(!this.isValid())return this.localeData().invalidDate();var e=!1,n=An,i,l;return typeof o=="object"&&(t=o,o=!1),typeof o=="boolean"&&(e=o),typeof t=="object"&&(n=Object.assign({},An,t),t.s!=null&&t.ss==null&&(n.ss=t.s-1)),i=this.localeData(),l=Fg(this,!e,n,i),e&&(l=i.pastFuture(+this,l)),i.postformat(l)}var us=Math.abs;function Gn(o){return(o>0)-(o<0)||+o}function Bo(){if(!this.isValid())return this.localeData().invalidDate();var o=us(this._milliseconds)/1e3,t=us(this._days),e=us(this._months),n,i,l,r,a=this.asSeconds(),c,d,u,R;return a?(n=Se(o/60),i=Se(n/60),o%=60,n%=60,l=Se(e/12),e%=12,r=o?o.toFixed(3).replace(/\.?0+$/,""):"",c=a<0?"-":"",d=Gn(this._months)!==Gn(a)?"-":"",u=Gn(this._days)!==Gn(a)?"-":"",R=Gn(this._milliseconds)!==Gn(a)?"-":"",c+"P"+(l?d+l+"Y":"")+(e?d+e+"M":"")+(t?u+t+"D":"")+(i||n||o?"T":"")+(i?R+i+"H":"")+(n?R+n+"M":"")+(o?R+r+"S":"")):"P0D"}var Ut=Ko.prototype;Ut.isValid=OR,Ut.abs=ig,Ut.add=sg,Ut.subtract=rg,Ut.as=ag,Ut.asMilliseconds=sl,Ut.asSeconds=cg,Ut.asMinutes=dg,Ut.asHours=ug,Ut.asDays=Rg,Ut.asWeeks=hg,Ut.asMonths=gg,Ut.asQuarters=Tg,Ut.asYears=fg,Ut.valueOf=mg,Ut._bubble=lg,Ut.clone=pg,Ut.get=Ig,Ut.milliseconds=Cg,Ut.seconds=Lg,Ut.minutes=Pg,Ut.hours=Eg,Ut.days=Mg,Ut.weeks=Xg,Ut.months=Og,Ut.years=Sg,Ut.humanize=Dg,Ut.toISOString=Bo,Ut.toString=Bo,Ut.toJSON=Bo,Ut.locale=Gr,Ut.localeData=xr,Ut.toIsoString=Me("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",Bo),Ut.lang=kr,gt("X",0,0,"unix"),gt("x",0,0,"valueOf"),dt("x",Wo),dt("X",qd),Bt("X",function(o,t,e){e._d=new Date(parseFloat(o)*1e3)}),Bt("x",function(o,t,e){e._d=new Date(bt(o))});st.version="2.30.1",Vd(te),st.fn=J,st.min=LR,st.max=PR,st.now=ER,st.utc=Ae,st.unix=zh,st.months=qh,st.isDate=qn,st.locale=Rn,st.invalid=No,st.duration=Ve,st.isMoment=be,st.weekdays=eg,st.parseZone=jh,st.localeData=en,st.isDuration=Ho,st.monthsShort=tg,st.weekdaysMin=og,st.defineLocale=ji,st.updateLocale=ju,st.locales=qu,st.weekdaysShort=ng,st.normalizeUnits=Oe,st.relativeTimeRounding=yg,st.relativeTimeThreshold=bg,st.calendarFormat=BR,st.prototype=J,st.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 Rs{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 f=i.getTdById(c.linkTdPrevId);if(f){d=f.value,u=d.length-1,c=f;continue}}if(u<0)break;const T=d[u];if(T.controlId!==r.controlId||T.controlComponent===s.ControlComponent.PREFIX||T.controlComponent===s.ControlComponent.PRE_TEXT)break;T.controlComponent===s.ControlComponent.VALUE&&a.unshift(T),u--}c=l;let R=e,h=n+1;for(;;){if(h>=R.length&&c?.linkTdNextId){const f=i.getTdById(c.linkTdNextId);if(f){R=f.value,h=0,c=f;continue}}const T=R[h];if(!T||T.controlId!==r.controlId||T.controlComponent===s.ControlComponent.POSTFIX||T.controlComponent===s.ControlComponent.POST_TEXT)break;T.controlComponent===s.ControlComponent.VALUE&&a.push(T),h++}return a.filter(T=>T.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,R=this.element.originControlId||(this.element.controlId===r?.controlId?r?.originControlId:void 0),h=this.element.control||r.control;const g=!!(r?.controlId&&r.controlId!==this.element.controlId&&!r.originControlId&&r.control?.type===s.ControlType.TEXTFIELD);d?(u=r.originControlId,R=void 0,h=a.control):g&&(u=r.controlId,R=void 0,h=r.control);const T=!!u&&r?.controlId!==u&&this._findNearestTextAncestorId(l,r?.originControlId)===u;!T&&!d&&!g&&(this.control.mergeControl(e),this.control.shrinkBoundary(e));const{startIndex:f,endIndex:p}=i,m=this.control.getDraw();f!==p?m.spliceElementList(l,f+1,p-f,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):T||d||g?this._removePlaceholdersByControl(l,u,R||null):this.control.removePlaceholder(f,{elementList:l});const C=l[f];T||d||g?this._removePlaceholdersByControl(l,u,R||null):this._removeControlPlaceholders(l,f);const I=C.type&&!Ce.includes(C.type)||C.controlComponent===s.ControlComponent.PREFIX||C.controlComponent===s.ControlComponent.PRE_TEXT?ie(C,["control","controlId","originControlId",...Re]):Ie(C,["type"]),L=T||d||g,E=b=>{Re.forEach(N=>{delete b[N];const W=h?.[N];W!==void 0&&(b[N]=W)}),delete b.underline,delete b.textDecoration,h?.type===s.ControlType.TEXT&&b.color?.toLowerCase()==="#87d068"?b.color=this.options.defaultColor:b.color||(b.color=this.options.defaultColor)};L&&E(I),I.controlId=u,h&&(I.control=h),R?I.originControlId=R:delete I.originControlId;const O=this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.inputTraceEnabled,F=i.startIndex+1,V=[],D=b=>{const N=V.length?V:l,W=V.length?V.length-1:d?i.startIndex+1:i.startIndex;re(N,[b],W,{editorOptions:this.options}),V.push(b)};for(let b=0;b<t.length;b++){const N=t[b];if(N.type===s.ElementType.CONTROL&&N.control){const W=N,y=W.controlId||Tt(),M=W.control?.value||[],X=W.control?.type===s.ControlType.TEXTFIELD,Y={...Ie(I,["underline","textDecoration"]),controlId:y,type:s.ElementType.CONTROL,control:W.control,originControlId:u},S=X?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,U=X?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,Q=X?W.control?.preTextFix||this.options.control.preTextFix:W.control?.prefix||this.options.control.prefix;for(let w=0;w<Q.length;w++){const x={...Y,value:Q[w],controlComponent:S};D(x)}for(let w=0;w<M.length;w++){const x=M[w],rt={...Y,...x,controlComponent:s.ControlComponent.VALUE};(rt.color===this.options.control.bracketColor||rt.color===this.options.control.placeholderColor)&&(rt.color=this.options.defaultColor),D(rt)}if(M.length===0){const w=W.control?.placeholder||"";for(let x=0;x<w.length;x++){const rt={...Y,value:w[x],controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};D(rt)}}const v=X?W.control?.postTextFix||this.options.control.postTextFix:W.control?.postfix||this.options.control.postfix;for(let w=0;w<v.length;w++){const x={...Y,value:v[w],controlComponent:U};D(x)}}else if(N.type||N.value){(C.controlComponent===s.ControlComponent.PRE_TEXT||C.controlComponent===s.ControlComponent.POST_TEXT||C.controlComponent===s.ControlComponent.PREFIX||C.controlComponent===s.ControlComponent.POSTFIX)&&(I.color=this.options.defaultColor);const y=Ie(N,["control","controlId","controlComponent","originControlId"]),M={...I,...y,controlComponent:s.ControlComponent.VALUE};L&&E(M),(M.color===this.options.control.bracketColor||M.color===this.options.control.placeholderColor||M.color===this.options.control.textFixColor)&&(M.color=this.options.defaultColor),M.strikeout&&delete M.strikeout,O&&(M.textDecoration={style:s.TextDecorationStyle.DOUBLE},M.underline=!0),D(M)}}return V.length&&m.spliceElementList(l,F,0,V),i.startIndex+V.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,R=this.element.originControlId||r.originControlId||null,h=P=>{if(!P)return null;const Y=new Set;let S=P,U=null;for(;S&&!Y.has(S);){Y.add(S);let Q;for(let v=0;v<e.length;v++){const w=e[v];if(w.controlId===S&&w.control?.type&&(Q=w,w.controlComponent===s.ControlComponent.PREFIX||w.controlComponent===s.ControlComponent.PRE_TEXT||w.controlComponent===s.ControlComponent.PRETEXTFIX||w.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!Q)break;(Q.control?.type===s.ControlType.TEXT||this.options.mode===s.EditorMode.EDIT&&Q.control?.type===s.ControlType.TEXTFIELD)&&(U=S),S=Q.originControlId||null}return U},g=h(R),T=!!g,f=r.controlId===u&&(r.originControlId||null)===R,p=r.controlComponent===s.ControlComponent.VALUE,m=P=>{for(let Y=i-1;Y>=0;Y--){const S=e[Y];if(S.controlId===P&&!S.originControlId){if(S.controlComponent===s.ControlComponent.VALUE||S.controlComponent===s.ControlComponent.PLACEHOLDER)return Y;if(S.controlComponent===s.ControlComponent.PREFIX||S.controlComponent===s.ControlComponent.PRE_TEXT||S.controlComponent===s.ControlComponent.PRETEXTFIX||S.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)break}if(S.controlId&&S.controlId!==P&&S.originControlId!==P)break}return-1},C=(P,Y)=>{for(let S=P;S>=0;S--){const U=e[S];if(U.controlId===Y&&!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 S;if(U.controlId&&U.controlId!==Y&&U.originControlId!==Y)break}for(let S=P+1;S<e.length;S++){const U=e[S];if(U.controlId===Y&&!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 S;if(U.controlId&&U.controlId!==Y&&U.originControlId!==Y)break}return P},L=T&&f&&(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),E=e[l+1],O=!!E?.originControlId&&!!E?.controlId&&E.originControlId!==E.controlId&&(E.controlComponent===s.ControlComponent.PREFIX||E.controlComponent===s.ControlComponent.PRE_TEXT||E.controlComponent===s.ControlComponent.PRETEXTFIX||E.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||E.controlComponent===s.ControlComponent.PLACEHOLDER||E.controlComponent===s.ControlComponent.TEXTFIXLABEL),F=!!E?.originControlId&&!!E?.controlId&&E.originControlId!==E.controlId&&(E.controlComponent===s.ControlComponent.PREFIX||E.controlComponent===s.ControlComponent.PRE_TEXT||E.controlComponent===s.ControlComponent.PRETEXTFIX||E.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||E.controlComponent===s.ControlComponent.POSTFIX||E.controlComponent===s.ControlComponent.POST_TEXT||E.controlComponent===s.ControlComponent.POSTTEXTFIX||E.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||E.controlComponent===s.ControlComponent.PLACEHOLDER||E.controlComponent===s.ControlComponent.TEXTFIXLABEL),V=P=>this.options.mode===s.EditorMode.FORM?i:this.control.removeControl(P),D=r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId&&!!E?.originControlId&&!!u&&h(E.originControlId)===u,b=P=>!!P&&P.controlId===r.controlId&&(P.originControlId||null)===(r.originControlId||null),N=P=>P?.controlComponent===s.ControlComponent.POSTFIX||P?.controlComponent===s.ControlComponent.POST_TEXT||P?.controlComponent===s.ControlComponent.POSTTEXTFIX||P?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT,W=()=>{const P=r.controlId,Y=r.originControlId||null;return c.spliceElementList(e,i,1),e.some(U=>U.controlId===P&&(U.originControlId||null)===Y&&U.controlComponent===s.ControlComponent.VALUE)||this.control.addPlaceholder(i-1),Math.max(i-1,0)},y=r.controlComponent===s.ControlComponent.VALUE&&!!r.originControlId&&b(E)&&N(E),M=!!u&&!this.control.getIsExistValueByElementListIndex(e,i),X=()=>{if(r.controlComponent!==s.ControlComponent.VALUE)return null;let P=i;for(let U=i;U>=0;U--){const Q=e[U];if(!(Q.controlId===r.controlId&&(Q.originControlId||null)===(r.originControlId||null))||Q.controlComponent!==s.ControlComponent.VALUE)break;if(!Q.strikeout){P=U;break}}const Y=e[P];if(!Y||Y.strikeout)return null;Y.strikeout=!0,Y.deletePerson="SWJ",Y.deleteTime=st(new Date).format("YYYY-MM-DD HH:mm:ss");let S=Math.max(P-1,0);for(let U=P-1;U>=0;U--){const Q=e[U];if(!(Q.controlId===Y.controlId&&(Q.originControlId||null)===(Y.originControlId||null))){S=U;break}if(Q.controlComponent!==s.ControlComponent.VALUE){S=U;break}if(!Q.strikeout){S=U;break}S=Math.max(U-1,0)}return this.draws.render({curIndex:S,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),queueMicrotask(()=>{this.ranges.setRange(S,S),this.draws.setCursor(S)}),S};if(t.key===s.KeyMap.Backspace){if(i===l&&M&&(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&&g&&!f&&(r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)){const Y=m(g);return Y>=0?Y:i}if(i===l&&L&&!(d&&r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId))return V(i);if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!T||p)){if(i===l&&r.controlComponent===s.ControlComponent.VALUE){const Y=X();if(Y!==null)return Y}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 Y=e[i+1];return(Y?.controlComponent===s.ControlComponent.POSTFIX||Y?.controlComponent===s.ControlComponent.POST_TEXT||Y?.controlComponent===s.ControlComponent.POSTTEXTFIX||Y?.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 Y=e[i-1],S=e[i+1];return!r.originControlId&&Y?.controlId===r.controlId&&Y?.originControlId===r.originControlId&&Y?.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):N(S)?S.originControlId?y?W():D?(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),C(Math.max(i-1,0),r.controlId)):V(i):(c.spliceElementList(e,i,1),this.control.addPlaceholder(i-1),C(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:C(Math.max(i-1,0),r.controlId))}}}else if(t.key===s.KeyMap.Delete){if(i===l&&M&&(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&&(O||F)){if(D){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 V(l+1)}const P=e[l+1],Y=!!r.originControlId;if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!Y||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:P?.controlComponent===s.ControlComponent.POSTFIX||P?.controlComponent===s.ControlComponent.POST_TEXT||P?.controlComponent===s.ControlComponent.POSTTEXTFIX||P?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?P.originControlId?D?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):V(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?D?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):V(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=st(new Date).format("YYYY-MM-DD HH:mm:ss"),d=h=>{queueMicrotask(()=>{this.ranges.setRange(h,h),this.draws.setCursor(h),this.options.mode===s.EditorMode.FORM&&console.log("[text-sync-trace-cursor]",{index:h,range:this.ranges.getRange(),cursorIndex:this.position.getCursorPosition()?.index})})},u=h=>{const g=this.control.getElementList(),T=g[h],f=T?.controlId,p=T?.originControlId||null;let m=-1;for(let C=h-1;C>=0;C--){const I=g[C];if(I.controlId===f&&(I.originControlId||null)===p&&I.controlComponent===s.ControlComponent.VALUE)return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:C,reason:"prev-value"}),C;if(p){if(I.controlId&&I.controlId!==f&&I.originControlId!==p)break}else{if(I.controlId===f&&(I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRE_TEXT||I.controlComponent===s.ControlComponent.PRETEXTFIX||I.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){m=C;break}if(I.controlId&&I.controlId!==f&&!I.originControlId)break;if(I.originControlId===f&&(I.controlComponent===s.ControlComponent.POSTFIX||I.controlComponent===s.ControlComponent.POST_TEXT||I.controlComponent===s.ControlComponent.POSTTEXTFIX||I.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:C,reason:"nested-postfix"}),C}}if(m>=0){const C=m+1,I=g[C];return I?.controlId===f&&(I.controlComponent===s.ControlComponent.PLACEHOLDER||I.controlComponent===s.ControlComponent.VALUE)?(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:C,reason:"prefix-next-editable"}),C):(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:m,reason:"prefix"}),m)}return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:h,reason:"self"}),h},R=h=>{const g=this.control.getElementList(),T=g[h];if(!T?.controlId||T.controlComponent===s.ControlComponent.VALUE&&(T.metrics?.width??0)>0)return h;for(let f=h+1;f<g.length;f++){const p=g[f];if(p.controlId!==T.controlId||(p.originControlId||null)!==(T.originControlId||null))break;if(p.controlComponent===s.ControlComponent.VALUE&&(p.metrics?.width??0)>0)return f}for(let f=h-1;f>=0;f--){const p=g[f];if(p.controlId!==T.controlId||(p.originControlId||null)!==(T.originControlId||null))break;if(p.controlComponent===s.ControlComponent.VALUE&&(p.metrics?.width??0)>0)return f}return h};if(r?.length){if(!this.element.strikeout){const h=r.findIndex(g=>!g.strikeout);return r.forEach(g=>{g.deletePerson="SWJ",g.deleteTime=c,g.strikeout=!!~h}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),this.control.getRange().endIndex??null}}else{const h=R(a.index),g=this.control.getElementList()[h],T=this.control.getElementList();if(this.options.mode===s.EditorMode.FORM&&console.log("[text-strikeout]",{cursorIndex:a.index,targetIndex:h,targetValue:g?.value,targetComponent:g?.controlComponent,targetControlId:g?.controlId,targetOriginControlId:g?.originControlId||null}),!this.control.getElementList()[h].strikeout&&g?.metrics.width>0){this.control.getElementList()[h].strikeout=!0,this.control.getElementList()[h].deletePerson="SWJ",this.control.getElementList()[h].deleteTime=c;const f=u(h);return this.options.mode===s.EditorMode.FORM&&console.log("[text-strikeout:after]",{targetIndex:h,newIndex:f}),this.ranges.setRange(f,f),this.draws.render({curIndex:f,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),d(f),f??null}else if(n>=0&&n<T.length&&T[n]?.metrics?.width!==void 0&&T[n].metrics.width<=0&&!T[n]?.strikeout){T.splice(n,1);const f=n-1;return this.ranges.setRange(f,f),this.draws.render({curIndex:f,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1}),this.ranges.setDefaultStyle({strikeout:!1}),d(f),f??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 rl{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(`${j}-date-container`),t.setAttribute(Ue,s.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${j}-date-wrap`);const n=document.createElement("div");n.classList.add(`${j}-date-title`);const i=document.createElement("span");i.classList.add(`${j}-date-title__pre-year`),i.innerText="<<";const l=document.createElement("span");l.classList.add(`${j}-date-title__pre-month`),l.innerText="<";const r=document.createElement("span");r.classList.add(`${j}-date-title__now`);const a=document.createElement("span");a.classList.add(`${j}-date-title__next-month`),a.innerText=">";const c=document.createElement("span");c.classList.add(`${j}-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(`${j}-date-week`);const{weeks:{sun:u,mon:R,tue:h,wed:g,thu:T,fri:f,sat:p}}=this.lang;[u,R,h,g,T,f,p].forEach(W=>{const y=document.createElement("span");y.innerText=`${W}`,d.append(y)});const C=document.createElement("div");C.classList.add(`${j}-date-day`),e.append(n),e.append(d),e.append(C);const I=document.createElement("ul");I.classList.add(`${j}-time-wrap`);let L,E,O;[this.lang.hour,this.lang.minute,this.lang.second].forEach((W,y)=>{const M=document.createElement("li"),X=document.createElement("span");X.innerText=W,M.append(X);const P=document.createElement("ol"),Y=y===0,S=y===1,U=Y?24:60;for(let Q=0;Q<U;Q++){const v=document.createElement("li");v.innerText=`${String(Q).padStart(2,"0")}`,v.setAttribute("data-id",`${Q}`),P.append(v)}Y?L=P:S?E=P:O=P,M.append(P),I.append(M)});const V=document.createElement("div");V.classList.add(`${j}-date-menu`);const D=document.createElement("button");D.classList.add(`${j}-date-menu__time`),D.innerText=this.lang.timeSelect;const b=document.createElement("button");b.classList.add(`${j}-date-menu__now`),b.innerText=this.lang.now;const N=document.createElement("button");return N.classList.add(`${j}-date-menu__submit`),N.innerText=this.lang.confirm,V.append(D),V.append(b),V.append(N),t.append(e),t.append(I),t.append(V),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:d,timeWrap:I,title:{preYear:i,preMonth:l,now:r,nextMonth:a,nextYear:c},day:C,time:{hour:L,minute:E,second:O},menu:{time:D,now:b,submit:N}}}_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((h,g)=>{const T=h;T.innerText=c[g]});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 R=this.dom.time.second.previousElementSibling;R.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 R=new Date(c,d,0).getDate();let h=new Date(c,d-1,1).getDay();h===0&&(h=7);const g=new Date(c,d-1,0).getDate();this.dom.day.innerHTML="";const T=g-h+1;for(let p=T;p<=g;p++){const m=document.createElement("div");m.classList.add("disable"),m.innerText=`${p}`,m.onclick=()=>{const C=d-2;this.now=new Date(c,C,p),this._setDatePick(c,C,p)},this.dom.day.append(m)}for(let p=1;p<=R;p++){const m=document.createElement("div");e===c&&n===d&&i===p&&m.classList.add("active"),this.pickDate&&l===c&&r===d&&a===p&&m.classList.add("select"),m.innerText=`${p}`,m.onclick=C=>{const I=d-1;this.now=new Date(c,I,p),this._setDatePick(c,I,p),C.stopPropagation()},this.dom.day.append(m)}const f=42-h-R;for(let p=1;p<=f;p++){const m=document.createElement("div");m.classList.add("disable"),m.innerText=`${p}`,m.onclick=()=>{this.now=new Date(c,d,p),this._setDatePick(c,d,p)},this.dom.day.append(m)}}_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(R=>R.classList.remove("active"))}),[[l,e],[r,n],[a,i]].forEach(([u,R])=>{const h=u.querySelector(`[data-id='${R}']`);h.classList.add("active"),t&&Xs(u,h)})}_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(),R=t.getMilliseconds().toString(),h={"y+":i,"Y+":i,"M+":l,"d+":r,"D+":r,"h+":c.toString(),"H+":a.toString(),"m+":d,"s+":u,"S+":R};for(const g in h){const T=new RegExp("("+g+")").exec(e),f=g;T&&(n=n.replace(T[1],T[1].length===1?h[f]:h[f].padStart(T[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 uo{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&&!Ce.includes(d.type)||d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRE_TEXT?ie(d,["control","controlId",...Re]):Ie(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};re(i,[g],r,{editorOptions:this.options}),c.spliceElementList(i,R+h,0,[g])}return R+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?ie(r,Ne):ie(i[l.startIndex],Re),c=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~c)return;const d=Ie(i[c],Ne),u=c+1,R=this.control.getDraw();for(let h=0;h<t.length;h++){const g={...a,...d,type:s.ElementType.TEXT,value:t[h],controlComponent:s.ControlComponent.VALUE};(g.color===this.options.control.bracketColor||g.color===this.options.control.placeholderColor)&&(g.color=this.options.defaultColor),re(i,[g],c,{editorOptions:this.options}),R.spliceElementList(i,u+h,0,[g])}if(!e.range){const h=u+t.length-1;this.control.repaintControl({curIndex:h}),this.control.emitControlContentChange({context:e}),this.destroy()}}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i,endIndex: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 rl(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 Ro extends Rs{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(L=>!lc(L)||Bl.test(L.value)))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange();this.control.shrinkBoundary(e);const r=ht(t),{startIndex:a,endIndex:c}=l,d=i[a];let u=null;for(let L=a;L>=0;L--)if(i[L].controlComponent===s.ControlComponent.PREFIX){u=i[L];break}const R=u?.control||this.element.control;if(this.control.getIsExistValueByElementListIndex(i,a)){let L=a;for(;L>0;){const O=i[L];if(O.controlId!==d.controlId||O.controlComponent===s.ControlComponent.PREFIX||O.controlComponent===s.ControlComponent.PRE_TEXT)break;r.unshift(O),L--}let E=c+1;for(;E<i.length;){const O=i[E];if(O.controlId!==d.controlId||O.controlComponent===s.ControlComponent.POSTFIX||O.controlComponent===s.ControlComponent.POST_TEXT)break;r.push(O),E++}}const h=Ks(r);if(Number.isNaN(Number(h))||!Number.isFinite(Number(h)))return-1;const g=R?.numberExclusiveOptions,T=g?.maxLength??null,f=g?.decimalPlaces??null,p=h.replace(/[.-]/g,"").length;if(T!=null&&p>T||f!=null&&(h.split(".")[1]||"").length>f)return-1;const m=Number(h),C=g?.minValue,I=g?.maxValue;return C!=null&&m<C||I!=null&&m>I?-1: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,R=a?.maxLength,h=t.trim(),g=h.replace(/[.-]/g,"").length,T=Number(h);if(u!=null&&g<u||R!=null&&g>R||c!=null&&T<c||d!=null&&T>d)return!1;let f=i;for(let F=i;F>=0;F--)if(e[F].controlComponent===s.ControlComponent.PREFIX){f=F;break}let p=f+1;for(let F=f+1;F<e.length;F++)if(e[F].controlComponent===s.ControlComponent.POSTFIX){p=F;break}const m=this.options.mode===s.EditorMode.FORM,C=m&&this.options.modeRule.form.inputTraceEnabled,I=m&&this.options.modeRule.form.deleteTraceEnabled,L=st(new Date).format("YYYY-MM-DD HH:mm:ss");if(I)for(let F=f+1;F<p;F++){const V=e[F];V.controlComponent===s.ControlComponent.VALUE&&!V.strikeout&&V.value&&(V.strikeout=!0,V.deletePerson="SYSTEM",V.deleteTime=L),V.controlComponent===s.ControlComponent.PLACEHOLDER&&(this.control.getDraw().spliceElementList(e,F,1),p--,F--)}else{const F=f+1,V=p-F;V>0&&this.control.getDraw().spliceElementList(e,F,V),p=f+1}p=f+1;for(let F=f+1;F<e.length;F++)if(e[F].controlComponent===s.ControlComponent.POSTFIX){p=F;break}const E=[];for(let F=0;F<h.length;F++){const V={type:s.ElementType.TEXT,value:h[F],controlComponent:s.ControlComponent.VALUE,controlId:e[f].controlId,originControlId:e[f].originControlId,control:e[f].control};C&&(V.textDecoration={style:s.TextDecorationStyle.DOUBLE},V.underline=!0),E.push(V)}for(let F=0;F<E.length;F++)this.control.getDraw().spliceElementList(e,p+F,0,[E[F]]);const O=p+E.length-1;return this.control.getDraw().getRange().setRange(O,O),this.control.emitControlContentChange(),this.control.repaintControl({curIndex:O}),!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 T=n;T>=0;T--)if(t[T].controlComponent===s.ControlComponent.PREFIX){l=t[T];break}const r=l?.control||this.element.control,c=this.getValue().filter(T=>!T.strikeout),d=c.length>0?Ks(c):"",u=r?.numberExclusiveOptions,R=u?.minValue,h=u?.maxValue,g=u?.decimalPlaces;this.inputPopup=new Vg({control:this.control,currentValue:d,minValue:R,maxValue:h,decimalPlaces:g,onConfirm:T=>{if(!T||T.trim()==="")return this._clearNumberValue(),!0;const f=Number(T);return Number.isNaN(f)||!Number.isFinite(f)?!1:this._setNumberValue(T)},onTab:T=>{this.destroy(),setTimeout(()=>{this.control.initNextControl({direction:T})})},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();if(t.key==="Backspace")return r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?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?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 t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey?(t.preventDefault(),this.awake(),null):l}destroy(){this.inputPopup&&(this.inputPopup.destroy(),this.inputPopup=null),this.isPopup=!1}}class Vg{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(`${j}-number-input-modal`),c.setAttribute(Ue,s.EditorComponent.POPUP);const d=I=>{if(I.type==="mouseup"){const L=this.options.control.getDraw().getCanvasEvent();L.setIsAllowDrag(!1),L.setIsAllowSelection(!1)}I.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(`${j}-number-input-modal__content`);const R=document.createElement("div");if(R.classList.add(`${j}-number-input-modal__title`),R.textContent="请输入数值",u.appendChild(R),e!==void 0||n!==void 0){const I=document.createElement("div");I.classList.add(`${j}-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}位小数`),I.textContent=L,u.appendChild(I)}const h=document.createElement("input");h.classList.add(`${j}-number-input-modal__input`),h.type="number",h.value=t,h.placeholder="请输入数值",e!==void 0&&(h.min=String(e)),n!==void 0&&(h.max=String(n)),i!=null&&(h.step=(1/Math.pow(10,i)).toString()),setTimeout(()=>{h.focus(),h.select()},100),u.appendChild(h);const g=document.createElement("div");g.classList.add(`${j}-number-input-modal__error`),g.style.display="none",u.appendChild(g);const T=document.createElement("div");T.classList.add(`${j}-number-input-modal__buttons`);const f=document.createElement("button");f.classList.add(`${j}-number-input-modal__cancel`),f.textContent="取消",f.onclick=()=>{a()},T.appendChild(f);const p=document.createElement("button");p.classList.add(`${j}-number-input-modal__confirm`),p.textContent="确定";const m=()=>{const I=h.value.trim();if(!I)return l("");const L=parseFloat(I);return Number.isNaN(L)||!Number.isFinite(L)?(g.textContent="请输入有效的数值",g.style.display="block",!1):i!=null&&(I.split(".")[1]||"").length>i?(g.textContent=`小数位数不能超过${i}位`,g.style.display="block",!1):e!==void 0&&L<e?(g.textContent=`数值不能小于 ${e}`,g.style.display="block",!1):n!==void 0&&L>n?(g.textContent=`数值不能大于 ${n}`,g.style.display="block",!1):(g.style.display="none",l(I))};p.onclick=()=>{m()&&a()},T.appendChild(p),u.appendChild(T),c.appendChild(u),h.onkeydown=I=>{I.key==="Enter"?p.click():I.key==="Tab"?(I.preventDefault(),m()&&(a(),r(I.shiftKey?$t.UP:$t.DOWN))):I.key==="Escape"&&a()},this.options.control.getContainer().appendChild(c),this.popupDom=c}destroy(){this.popupDom&&(this.popupDom.remove(),this.popupDom=null)}}class Wg{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(Ue,s.EditorComponent.COMPONENT),document.body.append(l);const r=document.createElement("div");r.classList.add("dialog-container"),r.setAttribute(Ue,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 R=document.createElement("div");R.classList.add("dialog-option");for(let f=0;f<this.data.length;f++){const p=this.data[f],m=document.createElement("div");if(m.classList.add("dialog-option__item"),p.visible===!1&&(m.style.display="none"),p.label){const C=document.createElement("span");C.append(document.createTextNode(p.label)),m.append(C),p.required&&C.classList.add("dialog-option__item--require")}if(p.type==="radio"){const C=document.createElement("div");C.classList.add("dialog-radio-group"),p.horizontal&&C.classList.add("dialog-radio-group--horizontal"),p.options?.forEach(I=>{const L=document.createElement("label");L.classList.add("dialog-radio-item");const E=document.createElement("input");E.type="radio",E.name=p.name,E.value=I.value,I.value===(p.value||"")&&(E.checked=!0);const O=document.createElement("span");O.textContent=I.label,L.append(E),L.append(O),C.append(L),E.addEventListener("change",()=>{this._updateFieldVisibility()}),this.inputList.push(E)}),m.append(C)}else if(p.type==="select"){const C=document.createElement("select"),I=p.value||"";p.options?.forEach(L=>{const E=document.createElement("option");E.value=L.value,E.label=L.label,L.value===I&&(E.selected=!0),C.append(E)}),C.name=p.name,C.value=I,C.addEventListener("change",()=>{this._updateFieldVisibility()}),p.width&&(C.style.width=`${p.width}px`),m.append(C),this.inputList.push(C)}else if(p.type==="textarea"){const C=document.createElement("textarea");C.name=p.name,C.value=p.value||"",C.placeholder=p.placeholder||"",p.width&&(C.style.width=`${p.width}px`),p.height&&(C.style.height=`${p.height}px`),m.append(C),this.inputList.push(C)}else{const C=document.createElement("input");C.type=p.type,C.name=p.name,C.value=p.value||"",C.placeholder=p.placeholder||"",p.width&&(C.style.width=`${p.width}px`),p.height&&(C.style.height=`${p.height}px`),m.append(C),this.inputList.push(C)}R.append(m),this.optionItemContainers.push(m)}a.append(R);const h=document.createElement("div");h.classList.add("dialog-menu");const g=document.createElement("button");g.classList.add("dialog-menu__cancel"),g.append(document.createTextNode("取消")),g.type="button",g.onclick=()=>{n&&n(),this._dispose()},h.append(g);const T=document.createElement("button");T.append(document.createTextNode("确定")),T.type="submit",T.onclick=()=>{if(i){const f=new Set,p=[];for(const m of this.inputList)if(!f.has(m.name))if(m instanceof HTMLInputElement&&m.type==="radio"){const C=this.inputList.find(I=>I.name===m.name&&I instanceof HTMLInputElement&&I.checked);C&&(p.push({name:m.name,value:C.value}),f.add(m.name))}else p.push({name:m.name,value:m.value}),f.add(m.name);i(p)}this._dispose()},h.append(T),a.append(h),document.body.append(r),this.container=r,this.mask=l,this._updateFieldVisibility()}_dispose(){this.mask?.remove(),this.container?.remove()}}class On{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(){return[]}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&this.control.getIsDisabledControl(e))return-1;const{elementList:i,range:l}=this.control.mergeControl(e),r=this.control.getDraw(),{startIndex:a}=l,d=i[a].controlId;let u=a;for(let m=a;m>=0;m--){const C=i[m];if(C.controlId!==d)break;if(C.controlComponent===s.ControlComponent.PREFIX){u=m;break}}let R=a;for(let m=a;m<i.length;m++){const C=i[m];if(C.controlId!==d){R=m;break}if(C.controlComponent===s.ControlComponent.POSTFIX){R=m;break}}const h=u+1,g=R-1;g>=h&&r.spliceElementList(i,h,g-h+1);const T=i[u],f=ie(T,["control","controlId",...Re]),p=u+1;for(let m=0;m<t.length;m++){const C={...f,...t[m],controlComponent:s.ControlComponent.VALUE};C.color="#fff",C.highlight="#1677FF",re(i,[C],u,{editorOptions:this.options}),r.spliceElementList(i,p+m,0,[C])}return p+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}keydown(t){if(this.control.getIsDisabledControl())return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{endIndex:i}=n,l=e[i];return!!l?.originControlId&&!!l?.controlId&&l.originControlId!==l.controlId&&l.control?.type===s.ControlType.BUTTON&&!l.control?.buttonText&&(t.key===s.KeyMap.Backspace||t.key===s.KeyMap.Delete)?this.control.removeControl(i):l?.controlComponent==="value"&&l.control?.type==="button"&&l.control?.buttonText?t.key===s.KeyMap.Backspace||t.key===s.KeyMap.Delete?(l.controlId&&this.removeByValue(e,l.controlId),i):null:(t.key===s.KeyMap.Backspace&&l?.controlComponent==="value"&&l.control?.type==="button"&&!l.control?.buttonText,null)}removeByValue(t,e){return On.isDeleting=!0,new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text")&&t[c].controlId===e&&t.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),setTimeout(()=>{On.isDeleting=!1},300),n(!0)})}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()||On.isDeleting||!this.control.getPosition())return;const e=this.draw.getElementList(),{startIndex:n}=this.control.getRange();if(e[n]?.controlId!==this.element?.controlId)return;const i=this.control.getDraw().getPosition().getPositionContext();if(!i.isDirectHit||i.index!==n||e[i.index]?.controlId!==this.element?.controlId)return;const l=e[n]?.controlId,r=e[n]?.control;if(!(l?.endsWith("_text")||r?.buttonText)){if(this.options.mode=="form"){const a=e[n].controlId;if(!a)return;const c=e.filter(d=>d.controlId==a);c[0].control.buttonText||this.showInputModal(c)}else if(this.options.mode=="edit"){const a=e[n].controlId,c=e.filter(d=>d.controlId==a);this.showEditModal(c)}}}showInputModal(t){if(this.inputModal){this.closeInputModal();return}this.isPopup=!0,this.inputModal=document.createElement("div"),this.inputModal.classList.add(`${j}-button-input-modal`),this.inputModal.setAttribute(Ue,s.EditorComponent.POPUP);const e=d=>{if(d.type==="mouseup"){const u=this.control.getDraw().getCanvasEvent();u.setIsAllowDrag(!1),u.setIsAllowSelection(!1)}d.stopPropagation()};this.inputModal.addEventListener("mousedown",e),this.inputModal.addEventListener("mouseup",e),this.inputModal.addEventListener("click",e),this.inputModal.addEventListener("keydown",e),this.inputModal.addEventListener("input",e),this.inputModal.oncontextmenu=d=>{d.preventDefault(),d.stopPropagation()};const n=document.createElement("div");n.classList.add(`${j}-button-input-modal__content`),n.oncontextmenu=d=>{d.preventDefault(),d.stopPropagation()};const i=document.createElement("div");i.classList.add(`${j}-button-input-modal__title`),i.innerText="请输入按钮展开文字(用逗号分隔)";const l=document.createElement("textarea");l.classList.add(`${j}-button-input-modal__textarea`),l.placeholder="例如:选项1,选项2,选项3",l.rows=5;const r=document.createElement("div");r.classList.add(`${j}-button-input-modal__buttons`);const a=document.createElement("button");a.classList.add(`${j}-button-input-modal__cancel`),a.innerText="取消",a.onclick=()=>this.closeInputModal();const c=document.createElement("button");c.classList.add(`${j}-button-input-modal__confirm`),c.innerText="确认",c.onclick=()=>{const d=l.value.trim();if(d){const u=d.split(/[,,]/).map((R,h)=>({value:R.trim(),code:String(h+1)})).filter(R=>R.value);if(u.length>0&&t[0]?.controlId){const R={controlId:t[0].controlId,element:[{...t[0],newButtonValue:u}]};this.draw.getCommand().executeButton(R)}}this.closeInputModal()},r.appendChild(a),r.appendChild(c),n.appendChild(i),n.appendChild(l),n.appendChild(r),this.inputModal.appendChild(n),this.draw.getContainer().appendChild(this.inputModal),setTimeout(()=>l.focus(),100),this.inputModal.onclick=d=>{d.target===this.inputModal&&this.closeInputModal()}}closeInputModal(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}showEditModal(t){const e=t[0]?.control||{},n=e.buttonLabel||e.label||"按钮",i=e.code||"";this.isPopup=!0,new Wg({title:"修改按钮属性",data:[{type:"text",label:"按钮标签",name:"buttonLabel",required:!0,placeholder:"请输入按钮标签",value:n},{type:"text",label:"按钮代码",name:"code",placeholder:"请输入按钮代码",value:i}],onClose:()=>{this.isPopup=!1},onCancel:()=>{this.isPopup=!1},onConfirm:l=>{const r=l.find(h=>h.name==="buttonLabel")?.value?.trim()||"按钮",a=l.find(h=>h.name==="code")?.value?.trim()||"",c=this.control.getElementList(),d=t[0]?.controlId;if(d)for(let h=0;h<c.length;h++){const g=c[h];g.controlId===d&&g.control&&(g.control.buttonLabel=r,g.control.label=r,g.control.code=a)}const u=[];for(let h=0;h<r.length;h++)u.push({value:r[h],controlComponent:s.ControlComponent.VALUE});const R=this.setValue(u);R!==-1&&this.control.repaintControl({curIndex:R}),this.isPopup=!1}})}destroy(){this.inputModal&&this.closeInputModal(),this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}}class ll{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;if(r.controlComponent===s.ControlComponent.PRETEXTFIX||r.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){let T=n+1;for(;T<e.length;){const f=e[T];if(f.controlId!==r.controlId||f.controlComponent!==s.ControlComponent.PRETEXTFIX&&f.controlComponent!==s.ControlComponent.PRETEXTFIX_TEXT){n=T-1;break}T++}}let d=e,u=n;for(;;){if(u<0&&c?.linkTdPrevId){const f=i.getTdById(c.linkTdPrevId);if(f){d=f.value,u=d.length-1,c=f;continue}}if(u<0)break;const T=d[u];if(T.controlId!==r.controlId||T.controlComponent===s.ControlComponent.PRETEXTFIX||T.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||T.controlComponent===s.ControlComponent.TEXTFIXLABEL)break;T.controlComponent===s.ControlComponent.VALUE&&a.unshift(T),u--}c=l;let R=e,h=n+1;for(;;){if(h>=R.length&&c?.linkTdNextId){const f=i.getTdById(c.linkTdNextId);if(f){R=f.value,h=0,c=f;continue}}const T=R[h];if(!T||T.controlId!==r.controlId||T.controlComponent===s.ControlComponent.POSTTEXTFIX||T.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||T.controlComponent===s.ControlComponent.TEXTFIXLABEL)break;T.controlComponent===s.ControlComponent.VALUE&&a.push(T),h++}return a.filter(T=>T.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(this.options.mode===s.EditorMode.FORM||!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,[],{isIgnoreDeletedRule:n.isIgnoreDeletedRule}):this.control.removePlaceholder(r,{elementList:i});const d=i[r],u=i[r+1];let R=d.originControlId||d.controlId,h=d.originControlId&&(d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===s.ControlComponent.POST_TEXT);if(!h&&d.controlId&&(d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===s.ControlComponent.POST_TEXT)&&u?.controlId&&u.controlId!==d.controlId)if(u.controlComponent===s.ControlComponent.PREFIX||u.controlComponent===s.ControlComponent.PRETEXTFIX)for(let m=r;m>=0;m--){const C=i[m];if(C.controlId===d.controlId&&(C.controlComponent===s.ControlComponent.PREFIX||C.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let I=m-1;I>=0;I--){const L=i[I];if(L.controlId&&L.controlId!==d.controlId&&(L.controlComponent===s.ControlComponent.PRETEXTFIX||L.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||L.controlComponent===s.ControlComponent.PREFIX||L.controlComponent===s.ControlComponent.PRE_TEXT)){R=L.controlId,h=!0;break}if(L.controlId&&L.controlId!==d.controlId&&(L.controlComponent===s.ControlComponent.POSTFIX||L.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}else(u.controlComponent===s.ControlComponent.POSTFIX||u.controlComponent===s.ControlComponent.POSTTEXTFIX)&&(R=u.controlId,h=!0);if(!h&&d.controlId&&(d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===s.ControlComponent.POST_TEXT))for(let m=r;m>=0;m--){const C=i[m];if(C.controlId===d.controlId&&(C.controlComponent===s.ControlComponent.PREFIX||C.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let I=m-1;I>=0;I--){const L=i[I];if(L.controlId&&L.controlId!==d.controlId&&(L.controlComponent===s.ControlComponent.PRETEXTFIX||L.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||L.controlComponent===s.ControlComponent.PREFIX||L.controlComponent===s.ControlComponent.PRE_TEXT)){R=L.controlId,h=!0;break}if(L.controlId&&L.controlId!==d.controlId&&(L.controlComponent===s.ControlComponent.POSTFIX||L.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}const g=d.type&&!Ce.includes(d.type)||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT?ie(d,["control","controlId",...Re]):Ie(d,["type"]);h&&(g.controlId=R,delete g.originControlId);const T=l.startIndex+1,f=[],p=m=>{const C=f.length?f:i,I=f.length?f.length-1:l.startIndex;re(C,[m],I,{editorOptions:this.options}),f.push(m)};for(let m=0;m<t.length;m++){const C=t[m];if(C.type===s.ElementType.CONTROL&&C.control){const I=C,L=I.controlId||Tt(),E=I.control?.value||[],O=I.control?.type===s.ControlType.TEXTFIELD,F={...g,controlId:L,type:s.ElementType.CONTROL,control:I.control,originControlId:R},V=O?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,D=O?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,b=O?I.control?.preTextFix||this.options.control.preTextFix:I.control?.prefix||this.options.control.prefix;for(let W=0;W<b.length;W++){const y={...F,value:b[W],controlComponent:V};p(y)}for(let W=0;W<E.length;W++){const y=E[W],M={...F,...y,controlComponent:s.ControlComponent.VALUE,type:y.type};(M.color===this.options.control.textFixColor||M.color===this.options.control.placeholderColor)&&(M.color=this.options.defaultColor),p(M)}if(E.length===0){const W=I.control?.placeholder||"";for(let y=0;y<W.length;y++){const M={...F,value:W[y],controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};p(M)}}const N=O?I.control?.postTextFix||this.options.control.postTextFix:I.control?.postfix||this.options.control.postfix;for(let W=0;W<N.length;W++){const y={...F,value:N[W],controlComponent:D};p(y)}}else if(C.type||C.value){g.color=this.options.defaultColor;const I={...g,...C,controlComponent:s.ControlComponent.VALUE};h&&(I.color=this.element.control?.color??this.options.defaultColor,this.element.control?.highlight?I.highlight=this.element.control.highlight:delete I.highlight),(I.color===this.options.control.textFixColor||I.color===this.options.control.placeholderColor)&&(I.color=this.options.defaultColor),p(I)}}return f.length&&c.spliceElementList(i,T,0,f),l.startIndex+f.length}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(),i=n.startIndex,l=n.endIndex;if(t.key===s.KeyMap.Backspace&&i===l&&i>0){const p=e[i-1],m=p?.controlComponent===s.ControlComponent.POSTFIX||p?.controlComponent===s.ControlComponent.POSTTEXTFIX,C=p?.controlComponent===s.ControlComponent.PLACEHOLDER,I=!!p?.controlId,E=this.draws.getPosition().getPositionList(),O=E[i],F=E[i-1],V=O&&F&&O.rowIndex===F.rowIndex;if((m||C)&&I&&V)return this.control.removeControl(i-1)}this.control.shrinkBoundary();const{startIndex:r,endIndex:a}=n,c=e[r],d=this.control.getDraw(),u=e[a+1],R=!!c?.originControlId&&!!c?.controlId&&c.originControlId!==c.controlId,h=R&&(c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRE_TEXT||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.POSTFIX||c.controlComponent===s.ControlComponent.POST_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PLACEHOLDER||c.controlComponent===s.ControlComponent.TEXTFIXLABEL),g=R&&c.control?.type===s.ControlType.BUTTON&&c.controlComponent===s.ControlComponent.VALUE,T=!!u?.originControlId&&!!u?.controlId&&u.originControlId!==u.controlId&&(u.controlComponent===s.ControlComponent.PREFIX||u.controlComponent===s.ControlComponent.PRE_TEXT||u.controlComponent===s.ControlComponent.PRETEXTFIX||u.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||u.controlComponent===s.ControlComponent.PLACEHOLDER||u.controlComponent===s.ControlComponent.TEXTFIXLABEL),f=!!u?.originControlId&&!!u?.controlId&&u.originControlId!==u.controlId&&u.control?.type===s.ControlType.BUTTON;if(t.key===s.KeyMap.Backspace){if(r===a&&(g||h&&c.controlComponent!==s.ControlComponent.POSTFIX&&c.controlComponent!==s.ControlComponent.POST_TEXT&&c.controlComponent!==s.ControlComponent.POSTTEXTFIX&&c.controlComponent!==s.ControlComponent.POSTTEXTFIX_TEXT))return this.control.removeControl(r);if(this.options.mode===s.EditorMode.FORM)this.strikeout();else{if(r!==a)return e.slice(r,a+1).some(C=>C.controlComponent===s.ControlComponent.POSTTEXTFIX||C.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)?r:(d.spliceElementList(e,r+1,a-r),this.getValue().length||this.control.addPlaceholder(r),r===0&&e[0].type===s.ElementType.SPLIT_TAG?d.fixPosition(!0)??r:r);{const p=e[r-1];return p?.controlId===c.controlId&&p?.originControlId===c.originControlId&&p?.controlComponent===s.ControlComponent.VALUE&&(c.controlComponent===s.ControlComponent.POSTFIX||c.controlComponent===s.ControlComponent.POST_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)?(d.spliceElementList(e,r-1,1),this.getValue().length||this.control.addPlaceholder(r-2),r-2):c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===s.ControlComponent.TEXTFIXLABEL||c.controlComponent===s.ControlComponent.PLACEHOLDER?r:(d.spliceElementList(e,r,1),this.getValue().length||this.control.addPlaceholder(r-1),r===1&&e[0].type===s.ElementType.SPLIT_TAG||r===0?d.fixPosition(!0)??r-1:r-1)}}}else if(t.key===s.KeyMap.Delete){if(r===a&&(h||g))return this.control.removeControl(r);if(r===a&&(T||f))return this.control.removeControl(a+1);if(this.options.mode===s.EditorMode.FORM)this.strikeout();else return r!==a?(d.spliceElementList(e,r+1,a-r),this.getValue().length||this.control.addPlaceholder(r),r===0&&e[0].type===s.ElementType.SPLIT_TAG?d.fixPosition(!0)??r:r):(u||d.getTd()?.linkTdNextId&&c.controlId&&this.removeNextControlElement(c.controlId),u&&((c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&(u.controlComponent===s.ControlComponent.PLACEHOLDER||u.controlComponent===s.ControlComponent.TEXTFIXLABEL)||u.controlComponent===s.ControlComponent.POSTTEXTFIX||u.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PLACEHOLDER||c.controlComponent===s.ControlComponent.TEXTFIXLABEL)?r:(d.spliceElementList(e,r+1,1),this.getValue().length||this.control.addPlaceholder(r),r===0&&e[0].type===s.ElementType.SPLIT_TAG?d.fixPosition(!0)??r:r))}return a}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}strikeout(t,e={},n={}){const{isIgnoreDisabledRule:i=!1}=t||{};if(!i&&(this.draws.isReadonly()||this.draws.isDisabled()))return;const r=this.ranges.getSelectionElementList(),a=this.position.getCursorPosition(),c=st(new Date).format("YYYY-MM-DD HH:mm:ss");if(r?.length){if(!this.element.strikeout){const d=r.findIndex(u=>!u.strikeout);r.forEach(u=>{u.deletePerson="SWJ",u.deleteTime=c,u.strikeout=!!~d}),this.draws.render({isSetCursor:!0,isCompute:!1,isDel:!0,isSubmitHistory:!1}),setTimeout(()=>{this.strikeoute()},100)}}else{const d=this.control.getElementList()[a.index];if(!this.control.getElementList()[a.index].strikeout&&d?.metrics.width>0){this.control.getElementList()[a.index].strikeout=!0,this.control.getElementList()[a.index].deletePerson="SWJ",this.control.getElementList()[a.index].deleteTime=c;const u=--a.index;setTimeout(()=>{this.strikeoute()},100),setTimeout(()=>{const h=u;this.draws.render({curIndex:h,isSetCursor:!0}),a.index=u,this.position.setCursorPosition(a),this.ranges.setRange(u,u)},100)}else{const{elementList:u,range:R}=this.control.mergeControl(n),h=R.startIndex;if(h>=0&&h<u.length&&u[h]?.metrics?.width!==void 0&&u[h].metrics.width<=0&&!u[h]?.strikeout){this.draws.spliceElementList(u,R.startIndex,1,[],{isIgnoreDeletedRule:e.isIgnoreDeletedRule});const g=!0,T=R.startIndex-1;this.draws.render({curIndex:T,isSetCursor:g}),a.index=T,delete a.value,this.position.setCursorPosition(a),this.ranges.setRange(T,T)}}}}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})}}}const Yg={indent:"        ",divider:"────────────────"};class al{draw;element;control;options;isPopup;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1}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),r=this.control.getDraw(),{startIndex:a}=l,d=i[a].controlId;let u=a;for(let m=a;m>=0;m--){const C=i[m];if(C.controlId!==d)break;if(C.controlComponent===s.ControlComponent.PREFIX){u=m;break}}let R=a;for(let m=a;m<i.length;m++){const C=i[m];if(C.controlId!==d){R=m;break}if(C.controlComponent===s.ControlComponent.POSTFIX){R=m;break}}const h=u+1,g=R-1;g>=h&&r.spliceElementList(i,h,g-h+1);const T=i[u],f=ie(T,["control","controlId",...Re]),p=u+1;for(let m=0;m<t.length;m++){const C={...f,...t[m],value:t[m].value===`