ht-emr 0.7.30 → 0.7.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="canvas-editor-style",e.appendChild(document.createTextNode(`.ce-select-control-popup{max-width:160px;min-width:69px;max-height:225px;position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;overflow-y:auto}.ce-select-control-popup ul{list-style:none;padding:3px 0;margin:0;box-sizing:border-box}.ce-select-control-popup ul li{font-size:13px;padding:0 20px;position:relative;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#666;height:36px;line-height:36px;box-sizing:border-box;cursor:pointer}.ce-select-control-popup ul li:hover{background-color:#eef2fd}.ce-select-control-popup ul li.active{color:var(--COLOR-HOVER, #5175f4);font-weight:700}.ce-calculator{position:absolute;z-index:1;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;box-shadow:0 2px 12px #0000001a;box-sizing:border-box;margin:5px 0;padding:8px;width:200px}.ce-calculator-display{width:100%;height:40px;line-height:40px;text-align:right;padding:0 10px;margin-bottom:8px;border:1px solid #e4e7ed;border-radius:4px;background-color:#f5f7fa;font-size:16px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis}.ce-calculator-buttons{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ce-calculator-button{width:100%;height:36px;border:1px solid #e4e7ed;border-radius:4px;background-color:#fff;font-size:14px;cursor:pointer;transition:all .2s;box-sizing:border-box}.ce-calculator-button:hover{background-color:#eef2fd;border-color:#c6d1ff}.ce-calculator-button:active{background-color:#e1e8ff}.ce-calculator-button.operator{background-color:#f5f7fa}.ce-calculator-button.operator:hover{background-color:#eef2fd}.ce-calculator-button.equal{background-color:var(--COLOR-HOVER, #5175f4);color:#fff;border-color:var(--COLOR-HOVER, #5175f4)}.ce-calculator-button.equal:hover{background-color:var(--COLOR-HOVER, #6a84ff);border-color:var(--COLOR-HOVER, #6a84ff)}.ce-calculator-button.utility{background-color:#f0f2f5}.ce-calculator-button.utility:hover{background-color:#e6e8eb}.ce-date-container{display:none;width:300px;overflow:hidden;left:0;right:0;position:absolute;z-index:1;color:#606266;background:#fff;border-radius:4px;padding:10px;-webkit-user-select:none;user-select:none;border:1px solid #e4e7ed;box-shadow:0 2px 12px #0000001a}.ce-date-container.active{display:block}.ce-date-wrap{display:none}.ce-date-wrap.active{display:block}.ce-date-title{display:flex;justify-content:center;align-items:center;text-align:center;color:#606266;font-size:16px}.ce-date-title>span{display:inline-block}.ce-date-title>span:not(.ce-date-title__now){font-family:cursive;cursor:pointer}.ce-date-title>span:not(.ce-date-title__now):hover{color:#5175f4}.ce-date-title .ce-date-title__pre-year,.ce-date-title .ce-date-title__pre-month{width:15%}.ce-date-title .ce-date-title__now{width:40%}.ce-date-title .ce-date-title__next-year,.ce-date-title .ce-date-title__next-month{width:15%}.ce-date-week{width:100%;display:flex;justify-content:center;margin-top:15px;padding-bottom:5px;border-bottom:1px solid #e4e7ed}.ce-date-week>span{list-style:none;width:calc(100%/7);text-align:center;color:#606266;font-size:14px}.ce-date-day{width:100%;display:flex;flex-wrap:wrap;align-items:center;margin-top:5px}.ce-date-day>div{width:calc(100%/7);height:40px;text-align:center;color:#606266;font-size:14px;cursor:pointer;line-height:40px;border-radius:4px}.ce-date-day>div:hover{color:#5175f4;opacity:.8}.ce-date-day>div.active{color:#5175f4;font-weight:700}.ce-date-day>div.disable{color:#c0c4cc}.ce-date-day>div.select{color:#fff;background-color:#5175f4}.ce-time-wrap{display:none;padding:10px;height:286px}.ce-time-wrap ::-webkit-scrollbar{width:0}.ce-time-wrap.active{display:flex}.ce-time-wrap li{list-style:none}.ce-time-wrap>li{width:33.3%;height:100%;text-align:center}.ce-time-wrap>li>span{transform:translateY(-5px);display:inline-block}.ce-time-wrap>li>ol{height:calc(100% - 20px);overflow-y:auto;border:1px solid #e2e2e2;position:relative}.ce-time-wrap>li:first-child>ol{border-right:0}.ce-time-wrap>li:last-child>ol{border-left:0}.ce-time-wrap>li>ol>li{line-height:30px;cursor:pointer;transition:all .3s}.ce-time-wrap>li>ol>li:hover{background-color:#eaeaea}.ce-time-wrap>li>ol>li.active{color:#fff;background:#5175f4}.ce-date-menu{width:100%;height:28px;display:flex;justify-content:flex-end;align-items:center;padding-top:10px;position:relative;border-top:1px solid #e4e7ed}.ce-date-menu button{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#fff;border:1px solid #dcdfe6;color:#606266;appearance:none;text-align:center;box-sizing:border-box;outline:none;transition:.1s;font-weight:500;-webkit-user-select:none;user-select:none;padding:7px 15px;font-size:12px;border-radius:3px;margin:0 0 0 10px}.ce-date-menu button:hover{color:#5175f4;border-color:#5175f4}.ce-date-menu button.ce-date-menu__time{border:1px solid transparent;position:absolute;left:0;margin-left:0}.ce-date-menu button.ce-date-menu__time:hover{color:#5175f4}.ce-block-item{position:absolute;z-index:0;background-color:#fff;border:1px solid rgb(235 236 240)}.ce-block-item .ce-resizer-selection{width:100%;height:100%}.ce-block-item .ce-resizer-mask{position:absolute;inset:0;z-index:1;background-color:transparent}.ce-table-tool__row{position:absolute;width:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed}.ce-table-tool__row .ce-table-tool__row__item{width:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__row .ce-table-tool__row__item:after{content:"";position:absolute;bottom:0;left:2px;width:8px;height:1px;background-color:#c0c6cf}.ce-table-tool__row .ce-table-tool__row__item:hover{background-color:#dadce0}.ce-table-tool__row .ce-table-tool__row__item:last-child:after{display:none}.ce-table-tool__quick__add{width:16px;height:16px;position:absolute;border-radius:50%;background-color:#e2e6ed;cursor:pointer}.ce-table-tool__quick__add:after{content:"+";color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%,-55%)}.ce-table-tool__select{width:16px;height:18px;position:absolute;border-radius:3px;cursor:pointer}.ce-table-tool__select:hover{background-color:#e2e6ed}.ce-table-tool__select:after{content:":::";color:#aaaaab;position:absolute;top:50%;left:50%;transform:translate(-75%,-50%) rotate(-90deg)}.ce-table-tool__col{position:absolute;height:12px;border-radius:6.5px;overflow:hidden;background-color:#e2e6ed;display:flex}.ce-table-tool__col .ce-table-tool__col__item{height:100%;position:relative;cursor:pointer;transition:all .3s}.ce-table-tool__col .ce-table-tool__col__item:after{content:"";position:absolute;top:2px;left:-1px;width:1px;height:8px;z-index:1;background-color:#c0c6cf}.ce-table-tool__col .ce-table-tool__col__item:hover{background-color:#dadce0}.ce-table-tool__col .ce-table-tool__col__item:first-child:after{display:none}.ce-table-tool__row .ce-table-tool__row__item.active,.ce-table-tool__col .ce-table-tool__col__item.active{background-color:#c4d7fa}.ce-table-tool__col .ce-table-tool__anchor{right:-5px;width:10px;height:12px;z-index:9;position:absolute;cursor:col-resize}.ce-table-tool__row .ce-table-tool__anchor{bottom:-5px;left:0;width:12px;height:10px;z-index:9;position:absolute;cursor:row-resize}.ce-table-anchor__line{z-index:9;position:absolute;border:1px dotted #000000}.ce-table-tool__border{position:absolute;z-index:1;background:transparent;pointer-events:none}.ce-table-tool__border__row{position:absolute;cursor:row-resize;pointer-events:auto}.ce-table-tool__border__col{position:absolute;cursor:col-resize;pointer-events:auto}.ce-resizer-selection{position:absolute;border:1px solid;pointer-events:none}.ce-resizer-selection .resizer-handle{position:absolute;z-index:9;width:10px;height:10px;box-shadow:0 1px 4px #0000004d;border-radius:5px;border:2px solid #ffffff;box-sizing:border-box;pointer-events:initial}.ce-resizer-selection .handle-0{cursor:nw-resize}.ce-resizer-selection .handle-1{cursor:n-resize}.ce-resizer-selection .handle-2{cursor:ne-resize}.ce-resizer-selection .handle-3{cursor:e-resize}.ce-resizer-selection .handle-4{cursor:se-resize}.ce-resizer-selection .handle-5{cursor:s-resize}.ce-resizer-selection .handle-6{cursor:sw-resize}.ce-resizer-selection .handle-7{cursor:w-resize}.ce-resizer-size-view{display:flex;align-items:center;height:20px;white-space:nowrap;position:absolute;z-index:9;top:-30px;left:0;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px}.ce-resizer-size-view span{color:#fff;font-size:12px}.ce-resizer-image{position:absolute;opacity:.5}.ce-image-previewer{position:fixed;left:0;top:0;z-index:1000;width:100%;height:100%;overflow:hidden;background:#f2f4f7;display:flex;align-items:center;justify-content:center;animation:previewerAnimation .3s}@keyframes previewerAnimation{0%{opacity:.1}to{opacity:1}}.ce-image-previewer .image-close{width:24px;height:24px;display:inline-block;position:absolute;right:50px;top:30px;z-index:99;cursor:pointer;background:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M23.97%207l1.415%201.414-7.779%207.778%207.779%207.779-1.414%201.414-7.779-7.779-7.778%207.779L7%2023.97l7.778-7.779L7%208.414%208.414%207l7.778%207.778L23.971%207z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e") no-repeat;background-size:100% 100%;transition:all .3s;border-radius:50%}.ce-image-previewer .image-close:hover{background-color:#e2e6ed}.ce-image-previewer .ce-image-container{position:relative}.ce-image-previewer .ce-image-container img{cursor:move;position:relative}.ce-image-previewer .ce-image-menu{height:50px;position:absolute;bottom:50px;z-index:99;display:flex;align-items:center;justify-content:center}.ce-image-previewer .ce-image-menu i{width:32px;height:32px;margin:0 8px;cursor:pointer;display:inline-block;background-repeat:no-repeat;background-size:100% 100%;transition:all .3s;border-radius:50%}.ce-image-previewer .ce-image-menu i:hover{background-color:#e2e6ed}.ce-image-previewer .ce-image-menu i.zoom-in{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%2014v-4h2v4h4v2h-4v4h-2v-4h-4v-2h4zm8.749%2010.163A11.952%2011.952%200%200115%2027C8.373%2027%203%2021.627%203%2015S8.373%203%2015%203s12%205.373%2012%2012c0%202.954-1.067%205.658-2.837%207.749l4.908%204.908-1.414%201.414-4.908-4.908zM15%2025c5.523%200%2010-4.477%2010-10S20.523%205%2015%205%205%209.477%205%2015s4.477%2010%2010%2010z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.zoom-out{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M22.749%2024.163A11.952%2011.952%200%200115%2027C8.373%2027%203%2021.627%203%2015S8.373%203%2015%203s12%205.373%2012%2012c0%202.954-1.067%205.658-2.837%207.749l4.908%204.908-1.414%201.414-4.908-4.908zM15%2025c5.523%200%2010-4.477%2010-10S20.523%205%2015%205%205%209.477%205%2015s4.477%2010%2010%2010zm-5-11h10v2H10v-2z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.rotate{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M16%204c6.627%200%2012%205.373%2012%2012a11.97%2011.97%200%2001-4%208.944V23h-.86A9.968%209.968%200%200026%2016c0-5.523-4.477-10-10-10S6%2010.477%206%2016c0%205.185%203.947%209.449%209%209.95v2.009C8.84%2027.451%204%2022.291%204%2016%204%209.373%209.373%204%2016%204z'%20fill-rule='nonzero'/%3e%3cpath%20d='M19.879%2027.328l1.767-6.717%204.95%204.95z'/%3e%3c/g%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.original-size{background-image:url("data:image/svg+xml,%3csvg%20width='32'%20height='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%204h24v24H4V4zm2%202v20h20V6H6zm4%205h2v10h-2V11zm5%202h2v2h-2v-2zm0%204h2v2h-2v-2zm5-6h2v10h-2V11z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.image-download{background-image:url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4.5%2015v3.5h15V15H21v5H3v-5h1.5zm8.232-11.226v9.196l4.05-4.05%201.06%201.06-5.834%205.834-5.833-5.833%201.06-1.06%203.998%203.996V3.774h1.5z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu .image-navigate{display:flex;align-items:center;justify-content:center}.ce-image-previewer .ce-image-menu i.image-pre{background-image:url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.5%204.063L6.875%2010l5.625%205.938'%20stroke='%233D4757'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu i.image-next{background-image:url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.5%204.063L13.125%2010%207.5%2015.938'%20stroke='%233D4757'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e")}.ce-image-previewer .ce-image-menu .image-count{color:#000;font-size:20px}.ce-image-previewer .ce-image-menu i.disabled{cursor:not-allowed;opacity:.5}.ce-contextmenu-container{z-index:9;position:fixed;display:none;padding:4px;overflow-x:hidden;overflow-y:auto;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px}.ce-contextmenu-content{display:flex;flex-direction:column}.ce-contextmenu-content .ce-contextmenu-sub-item:after{position:absolute;content:"";width:16px;height:16px;right:12px;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M0%200h16v16H0z'/%3e%3cg%20fill='%23767C85'%3e%3cpath%20d='M7%2012.243l-.707-.707%204.243-4.243.707.707z'/%3e%3cpath%20d='M6.293%204.464L7%203.757%2011.243%208l-.707.707z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-content .ce-contextmenu-item{min-width:140px;padding:0 32px 0 16px;height:30px;display:flex;align-items:center;white-space:nowrap;box-sizing:border-box;cursor:pointer}.ce-contextmenu-content .ce-contextmenu-item.hover{background:#1937580a}.ce-contextmenu-content .ce-contextmenu-item span{max-width:300px;font-size:12px;color:#3d4757;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.ce-contextmenu-content .ce-contextmenu-item span.ce-shortcut{color:#767c85;height:30px;flex:1;text-align:right;line-height:30px;margin-left:20px}.ce-contextmenu-content .ce-contextmenu-item i{width:16px;height:16px;vertical-align:middle;display:inline-block;background-repeat:no-repeat;background-size:100% 100%;flex-shrink:0;margin-right:8px}.ce-contextmenu-divider{background-color:#e2e6ed;margin:4px 16px;height:1px}.ce-contextmenu-print{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M12%204h-1V2H5v2H4V2a1%201%200%20011-1h6a1%201%200%20011%201v2zm0%205v4a1%201%200%2001-1%201H5a1%201%200%2001-1-1V9h1v4h6V9h1z'/%3e%3cpath%20d='M12%2012v-1h2V5H2v6h2v1H2a1%201%200%2001-1-1V5a1%201%200%20011-1h12a1%201%200%20011%201v6a1%201%200%2001-1%201h-2z'/%3e%3cpath%20d='M3%208h10v1H3zm8-2h2v1h-2z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-image{background-image:url("data:image/svg+xml,%3csvg%20version='1.1'%20id='图层_1'%20xmlns='http://www.w3.org/2000/svg'%20x='0'%20y='0'%20viewBox='0%200%2016%2016'%20xml:space='preserve'%3e%3cstyle%3e.st0{fill:%233d4757}%3c/style%3e%3cg%20id='_x30_0-公共_x2F_02工具栏_x2F_插入图片-16px-'%3e%3cg%20id='Group-19'%20transform='translate(1%201)'%3e%3cpath%20id='Combined-Shape'%20class='st0'%20d='M1%200h12c.6%200%201%20.4%201%201v11c0%20.6-.4%201-1%201H1c-.6%200-1-.4-1-1V1c0-.6.4-1%201-1zm0%201v11h12V1H1z'/%3e%3ccircle%20id='椭圆形'%20class='st0'%20cx='10'%20cy='4'%20r='1'/%3e%3cpath%20id='Path'%20class='st0'%20d='M8.5%2011.2l-4-4.1L1%2010.7V9.2c1.7-1.6%202.7-2.5%203-2.8.4-.5.7-.4%201%200L8.5%2010%2011%207.3c.4-.5.6-.5%201-.1l2%202.8v1.5l-2.5-3.4-3%203.1z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-image-change{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cg%20transform='translate(2%204)'%20fill='%233D4757'%3e%3ccircle%20fill-rule='nonzero'%20cx='3'%20cy='1'%20r='1'/%3e%3cpath%20d='M7.473%208.223L3.47%204.107%200%207.667v-1.5C1.715%204.6%202.707%203.664%202.975%203.358c.402-.457.651-.39%201.042%200L7.473%207%209.96%204.349c.414-.462.62-.462%201.011-.071L13%207.06v1.5l-2.51-3.41-3.017%203.072z'/%3e%3c/g%3e%3cpath%20d='M6%201.5H1.5v12h13v-4V13a.5.5%200%2001-.5.5H2a.5.5%200%2001-.5-.5V2a.5.5%200%2001.5-.5h4zm8.5%208V6l-.5.5h1l-.5-.5v3.5zM6%201.5h4L9.5%201v1l.5-.5H6z'%20stroke='%233D4757'/%3e%3cpath%20d='M13.085%201.316l-3.814%204a1%201%200%20001.458%201.368l3.815-4a1%201%200%2010-1.459-1.368z'%20fill='%233D4757'%20fill-rule='nonzero'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-row-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%233D4757'%20d='M8.5%205.5h6v4h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M4%207v1h2V7zm-3%20.5L4%205v5zM1%201h12v1H1zm0%2012h12v1H1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-top-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M8%205H7v3h1zm-.5-3L10%205H5z'/%3e%3crect%20stroke='%233D4757'%20x='1.5'%20y='10.5'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-bottom-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M7%2011h1V8H7zm.5%203L5%2011h5z'/%3e%3crect%20stroke='%233D4757'%20x='1.5'%20y='2.5'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-left-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M11%207v1h3V7zm-3%20.5L11%205v5z'/%3e%3crect%20stroke='%233D4757'%20transform='rotate(90%204%207.5)'%20x='-2'%20y='6'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-insert-right-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20fill='%233D4757'%20d='M5%208V7H2v1zm3-.5L5%2010V5z'/%3e%3crect%20stroke='%233D4757'%20transform='rotate(90%2012%207.5)'%20x='6'%20y='6'%20width='12'%20height='3'%20rx='1'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-row-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M8.5%206.5h6v2h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M2%2012h11v1H2zM2%202h11v1H2zm.63%203L7%209.35l-.635.65L2%205.63z'/%3e%3cpath%20fill='%233D4757'%20d='M2%209.363L6.355%205%207%205.707%202.695%2010z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-row{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M8.5%205.5h6v4h-6z'/%3e%3cpath%20fill='%233D4757'%20d='M1%2013h12v1H1zM1%201h12v1H1zm0%204h1v1H1zm1%201h1v1H2zm1%201h1v1H3zm1-1h1v1H4zm1-1h1v1H5zM4%208h1v1H4zM2%208h1v1H2zm3%201h1v1H5zM1%209h1v1H1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-col{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20stroke='%23929AA8'%20d='M5.5%207.5v-6h4v6z'/%3e%3cpath%20fill='%233D4757'%20d='M13%2015V3h1v12zM1%2015V3h1v12zm4%200v-1h1v1zm1-1v-1h1v1zm1-1v-1h1v1zm-1-1v-1h1v1zm-1-1v-1h1v1zm3%201v-1h1v1zm0%202v-1h1v1zm1-3v-1h1v1zm0%204v-1h1v1z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-delete-table{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M14%2013h-1v-3H2v3H1v-3a1%201%200%20011-1h11a1%201%200%20011%201v3z'%20fill-rule='nonzero'/%3e%3cpath%20d='M5.625%202L10%206.375%209.375%207%205%202.625z'/%3e%3cpath%20d='M5%206.375L9.375%202l.625.625L5.625%207z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-merge-cell{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M6%201v1H2v11h4v1H2a1%201%200%2001-1-1V2a1%201%200%20011-1h4zm3%200h4a1%201%200%20011%201v11a1%201%200%2001-1%201H9v-1h4V2H9V1z'/%3e%3cpath%20fill-rule='nonzero'%20d='M6%201h1v4H6zm2%200h1v4H8z'/%3e%3cpath%20d='M8%207.5L10%206v3zm-1%200L5%206v3z'/%3e%3cpath%20d='M9%207h3v1H9zM3%207h3v1H3z'/%3e%3cpath%20fill-rule='nonzero'%20d='M8%2010h1v4H8zm-2%200h1v4H6z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-merge-cancel-cell{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20fill='%233D4757'%20fill-rule='evenodd'%3e%3cpath%20d='M6%201v1H2v11h4v1H2a1%201%200%2001-1-1V2a1%201%200%20011-1h4zm3%200h4a1%201%200%20011%201v11a1%201%200%2001-1%201H9v-1h4V2H9V1z'/%3e%3cpath%20fill-rule='nonzero'%20d='M6%201h1v4H6zm2%200h1v4H8z'/%3e%3cpath%20d='M3%207.5L5%206v3zm9%200L10%206v3z'/%3e%3cpath%20d='M4%207h3v1H4zm4%200h3v1H8z'/%3e%3cpath%20fill-rule='nonzero'%20d='M8%2010h1v4H8zm-2%200h1v4H6z'/%3e%3c/g%3e%3c/svg%3e")}.ce-contextmenu-vertical-align{background-image:url("data:image/svg+xml,%3csvg%20height='16'%20viewBox='0%200%2016%2016'%20width='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%2013h12v1H2zm0-3h8v1H2zm0-3h12v1H2zm0-6h12v1H2zm0%203h8v1H2z'%20fill='%233d4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-top{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8%208H7v6h1zm-.5-3L10%208H5zM2%203h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-middle{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8%2012H7v3h1zm-.5-3l2.5%203H5zM7%203h1V0H7zm.5%203L5%203h5zM2%207h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-vertical-align-bottom{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%209h1V3H7zm.5%203L5%209h5zM2%2013h11v1H2z'%20fill='%233D4757'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.ce-contextmenu-border-all{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%233D4757'/%3e%3cpath%20fill='%233D4757'%20d='M3%208h11v1H3z'/%3e%3cpath%20fill='%233D4757'%20d='M9%203v11H8V3z'/%3e%3c/svg%3e")}.ce-contextmenu-border-empty{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13%203h-1V2h1a1%201%200%20011%201v1h-1V3zm-3-1v1H8.5v2h-1V3H6V2h4zM4%202v1H3v1H2V3a1%201%200%20011-1h1zM2%206h1v1.5h2v1H3V10H2V6zm0%206h1v1h1v1H3a1%201%200%2001-1-1v-1zm4%202v-1h1.5v-2h1v2H10v1H6zm6%200v-1h1v-1h1v1a1%201%200%2001-1%201h-1zm2-4h-1V8.5h-2v-1h2V6h1v4zM8.5%207.5v-1h-1v1h-1v1h1v1h1v-1h1v-1h-1z'%20fill='%23AAACB0'/%3e%3c/svg%3e")}.ce-contextmenu-border-dash{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13%203h-1V2h1a1%201%200%20011%201v1h-1V3zm-3-1v1H8.5v2h-1V3H6V2h4zM4%202v1H3v1H2V3a1%201%200%20011-1h1zM2%206h1v1.5h2v1H3V10H2V6zm0%206h1v1h1v1H3a1%201%200%2001-1-1v-1zm4%202v-1h1.5v-2h1v2H10v1H6zm6%200v-1h1v-1h1v1a1%201%200%2001-1%201h-1zm2-4h-1V8.5h-2v-1h2V6h1v4zM8.5%207.5v-1h-1v1h-1v1h1v1h1v-1h1v-1h-1z'%20fill='%23000000'/%3e%3c/svg%3e")}.ce-contextmenu-border-external{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%233D4757'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9%205V3H8v2h1zm0%209v-2H8v2h1zM5%208H3v1h2V8zm9%200h-2v1h2V8zM9%207v1h1v1H9v1H8V9H7V8h1V7h1z'%20fill='%23AAACB0'/%3e%3c/svg%3e")}.ce-contextmenu-border-internal{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9%205V3H8v2h1zm0%209v-2H8v2h1zM5%208H3v1h2V8zm9%200h-2v1h2V8zM9%207v1h1v1H9v1H8V9H7V8h1V7h1z'%20fill='%233D4757'/%3e%3c/svg%3e")}.ce-contextmenu-border-td{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20d='M8.5%202.5%20v6%20h-6'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-top{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M2.5%203%20h12'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-left{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M3%203%20v11'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-bottom{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M2.5%2014%20h12'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-right{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'/%3e%3cpath%20stroke='%233D4757'%20stroke-width='2'%20d='M14%203%20v11'/%3e%3c/svg%3e")}.ce-contextmenu-border-td-forward{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'%20/%3e%3cpath%20stroke='%233D4757'%20d='M14%203%20l-11%2011'%20/%3e%3c/svg%3e")}.ce-contextmenu-border-td-back{background-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.5%203a.5.5%200%2001.5-.5h11a.5.5%200%2001.5.5v11a.5.5%200%2001-.5.5H3a.5.5%200%2001-.5-.5V3z'%20stroke='%23AAACB0'%20/%3e%3cpath%20stroke='%233D4757'%20d='M3%203%20l11%2011'%20/%3e%3c/svg%3e")}.ce-hyperlink-popup{background:#fff;box-shadow:0 2px 12px #626b8433;border-radius:2px;color:#3d4757;padding:12px 16px;position:absolute;z-index:1;text-align:center;display:none}.ce-hyperlink-popup a{min-width:100px;max-width:300px;font-size:12px;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;color:#00f}.ce-zone-indicator>div{padding:3px 6px;color:#000;font-size:12px;background:#dae7fc;position:absolute;transform-origin:0 0}.ce-zone-indicator-border__top,.ce-zone-indicator-border__bottom,.ce-zone-indicator-border__left,.ce-zone-indicator-border__right{display:block;position:absolute;z-index:0}.ce-zone-indicator-border__top{border-top:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__bottom{border-top:2px dashed rgb(238,238,238);width:100%}.ce-zone-indicator-border__left{border-left:2px dashed rgb(238,238,238)}.ce-zone-indicator-border__right{border-right:2px dashed rgb(238,238,238)}.ce-zone-tip{display:none;align-items:center;height:30px;white-space:nowrap;position:fixed;opacity:.9;background-color:#000;padding:0 5px;border-radius:4px;z-index:9;transition:all .3s;outline:none;-webkit-user-select:none;user-select:none;pointer-events:none;transform:translate(10px,10px)}.ce-zone-tip.show{display:flex}.ce-zone-tip span{color:#fff;font-size:12px}.ce-inputarea{min-width:60px!important;min-height:0;margin:0;padding:0;left:0;top:0;letter-spacing:0;font-size:12px;position:absolute;z-index:-1;outline:none;resize:none;border:none;overflow:hidden;color:transparent;-webkit-user-select:none;user-select:none;caret-color:transparent;background-color:transparent;white-space:pre}.ce-cursor{width:1px;height:20px;left:0;right:0;position:absolute;outline:none;background-color:#000;pointer-events:none}.ce-cursor.ce-cursor--animation{animation-duration:1s;animation-iteration-count:infinite;animation-name:cursorAnimation}@keyframes cursorAnimation{0%{opacity:1}13%{opacity:0}50%{opacity:0}63%{opacity:1}to{opacity:1}}.ce-float-image{position:absolute;opacity:.5;pointer-events:none}.ce-button-input-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;justify-content:center;align-items:center;z-index:2000}.ce-button-input-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:320px;max-width:480px;box-shadow:0 4px 20px #00000026}.ce-button-input-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.ce-button-input-modal__textarea{width:100%;min-height:100px;padding:10px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;line-height:1.5;resize:vertical;outline:none;box-sizing:border-box;font-family:inherit}.ce-button-input-modal__textarea:focus{border-color:#5175f4}.ce-button-input-modal__textarea::placeholder{color:#c0c4cc}.ce-button-input-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-button-input-modal__cancel,.ce-button-input-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-button-input-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-button-input-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-button-input-modal__confirm:hover{background:#409eff;border-color:#409eff}.ce-button-edit-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;justify-content:center;align-items:center;z-index:1000}.ce-button-edit-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:320px;max-width:480px;box-shadow:0 4px 20px #00000026}.ce-button-edit-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:16px}.ce-button-edit-modal__form{display:flex;flex-direction:column;gap:12px}.ce-button-edit-modal__field{display:flex;align-items:center;gap:8px}.ce-button-edit-modal__field label{min-width:80px;font-size:13px;color:#606266}.ce-button-edit-modal__field input{flex:1;padding:8px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;outline:none;box-sizing:border-box}.ce-button-edit-modal__field input:focus{border-color:#5175f4}.ce-button-edit-modal__field input::placeholder{color:#c0c4cc}.ce-button-edit-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-button-edit-modal__cancel,.ce-button-edit-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-button-edit-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-button-edit-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-button-edit-modal__confirm:hover{background:#409eff;border-color:#409eff}.ce-number-input-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;justify-content:center;align-items:center;z-index:2000}.ce-number-input-modal__content{background:#fff;border-radius:8px;padding:20px;min-width:300px;max-width:400px;box-shadow:0 4px 20px #00000026}.ce-number-input-modal__title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.ce-number-input-modal__hint{font-size:12px;color:#909399;margin-bottom:12px}.ce-number-input-modal__input{width:100%;padding:10px 12px;border:1px solid #dcdfe6;border-radius:4px;font-size:13px;outline:none;box-sizing:border-box}.ce-number-input-modal__input:focus{border-color:#5175f4}.ce-number-input-modal__input::placeholder{color:#c0c4cc}.ce-number-input-modal__error{font-size:12px;color:#f56c6c;margin-top:8px}.ce-number-input-modal__buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.ce-number-input-modal__cancel,.ce-number-input-modal__confirm{padding:8px 16px;font-size:13px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.ce-number-input-modal__cancel:hover{color:#5175f4;border-color:#5175f4}.ce-number-input-modal__confirm{background:#5175f4;border-color:#5175f4;color:#fff}.ce-number-input-modal__confirm:hover{background:#409eff;border-color:#409eff}.tooth-position-edit-modal,.tooth-position-create-modal{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1000}.tooth-position-modal__container{position:relative;top:auto;left:auto;transform:none;background:#fff;border-radius:8px;box-shadow:0 4px 12px #00000026;min-width:400px;max-width:90vw;max-height:calc(100vh - 48px);display:flex;flex-direction:column;pointer-events:auto}.tooth-position-modal__header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #e8e8e8}.tooth-position-modal__header span{font-size:16px;font-weight:500;color:#333}.tooth-position-modal__close{font-size:20px;cursor:pointer;color:#999;line-height:1}.tooth-position-modal__close:hover{color:#333}.tooth-position-modal__content{padding:20px;max-height:60vh;overflow-y:auto}.tooth-section{margin-bottom:20px}.tooth-section:last-child{margin-bottom:0}.tooth-section-title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px;padding-left:8px;border-left:3px solid #1890ff}.tooth-row{display:flex;align-items:center;margin-bottom:8px}.tooth-row:last-child{margin-bottom:0}.tooth-row-label{width:30px;font-size:13px;color:#666}.tooth-buttons{display:flex;gap:8px;flex-wrap:wrap}.letter-buttons{margin-left:30px}.tooth-checkbox{display:flex;align-items:center;cursor:pointer}.tooth-checkbox input{display:none}.tooth-checkbox span{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid #d9d9d9;border-radius:4px;background:#f5f5f5;font-size:14px;color:#333;transition:all .2s}.tooth-checkbox input:checked+span{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-checkbox:hover span{border-color:#1890ff}.tooth-position-modal__footer{display:flex;justify-content:flex-end;gap:10px;padding:16px 20px;border-top:1px solid #e8e8e8}.tooth-position-modal__footer .btn-cancel,.tooth-position-modal__footer .btn-confirm{padding:8px 20px;font-size:14px;border-radius:4px;cursor:pointer;border:1px solid #dcdfe6;background:#fff;color:#606266;transition:all .2s}.tooth-position-modal__footer .btn-cancel:hover{color:#1890ff;border-color:#1890ff}.tooth-position-modal__footer .btn-confirm{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-position-modal__footer .btn-confirm:hover{background:#40a9ff;border-color:#40a9ff}.tooth-grid-container{display:flex;flex-direction:column;align-items:center;padding:15px 20px;background:#fafafa;border-radius:8px;margin-bottom:15px;position:relative}.tooth-quick-buttons{display:flex;gap:6px;margin-bottom:16px}.tooth-quick-buttons-left{display:flex;flex-direction:column;gap:6px;flex:1}.tooth-quick-buttons-row{display:flex;gap:6px}.tooth-quick-btn{padding:6px 12px;font-size:12px;border:1px solid #d9d9d9;border-radius:4px;cursor:pointer;background:#fff;color:#333;transition:all .2s;white-space:nowrap}.tooth-quick-btn:hover{border-color:#1890ff;color:#1890ff}.tooth-quick-btn.selected{background:#0ff;border-color:#0ff;color:#fff}.tooth-quick-btn--clear{background:#ff6b6b;border-color:#ff6b6b;color:#fff}.tooth-quick-btn--clear:hover{background:#ff5252;border-color:#ff5252;color:#fff}.tooth-grid-container:before{content:"";position:absolute;left:50%;top:20px;bottom:20px;width:2px;background:#000;transform:translate(-50%);z-index:1}.tooth-grid-container:after{content:"";position:absolute;left:20px;right:20px;top:50%;height:2px;background:#000;transform:translateY(-50%);z-index:1}.tooth-grid-letter-row,.tooth-grid-number-row{display:flex;align-items:center;justify-content:center;position:relative;z-index:2}.tooth-grid-half{display:flex;align-items:center;justify-content:center;gap:4px}.tooth-grid-half.left{justify-content:flex-end;padding-right:15px}.tooth-grid-half.right{justify-content:flex-start;padding-left:15px}.tooth-grid-divider-v,.tooth-grid-divider-h{display:none}.tooth-grid-number-item{width:34px;height:32px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:500;color:#333;cursor:pointer;background:#fff;transition:all .2s;box-sizing:border-box;border:1px solid #d9d9d9;border-radius:12px}.upper-number-row .tooth-grid-number-item{border-top:none;border-radius:0 0 12px 12px}.lower-number-row .tooth-grid-number-item{border-bottom:none;border-radius:12px 12px 0 0}.tooth-grid-number-item[data-value="1"],.tooth-grid-number-item[data-value="2"],.tooth-grid-number-item[data-value="3"]{border-radius:50px}.upper-number-row .tooth-grid-number-item[data-value="1"],.upper-number-row .tooth-grid-number-item[data-value="2"],.upper-number-row .tooth-grid-number-item[data-value="3"]{border-top:none!important;border-radius:0 0 50px 50px!important}.lower-number-row .tooth-grid-number-item[data-value="1"],.lower-number-row .tooth-grid-number-item[data-value="2"],.lower-number-row .tooth-grid-number-item[data-value="3"]{border-bottom:none!important;border-radius:50px 50px 0 0!important}.tooth-grid-number-item:hover{border-color:#1890ff;color:#1890ff}.tooth-grid-number-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-grid-letter-item{width:34px;height:32px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px solid #d9d9d9;transition:all .2s;box-sizing:border-box;border-radius:12px}.upper-letter-row .tooth-grid-letter-item{border-top:none;border-radius:0 0 12px 12px}.lower-letter-row .tooth-grid-letter-item{border-bottom:none;border-radius:12px 12px 0 0}.tooth-grid-letter-item[data-value=A],.tooth-grid-letter-item[data-value=B],.tooth-grid-letter-item[data-value=C]{border-radius:50px}.upper-letter-row .tooth-grid-letter-item[data-value=A],.upper-letter-row .tooth-grid-letter-item[data-value=B],.upper-letter-row .tooth-grid-letter-item[data-value=C]{border-top:none!important;border-radius:0 0 50px 50px!important}.lower-letter-row .tooth-grid-letter-item[data-value=A],.lower-letter-row .tooth-grid-letter-item[data-value=B],.lower-letter-row .tooth-grid-letter-item[data-value=C]{border-bottom:none!important;border-radius:50px 50px 0 0!important}.tooth-grid-letter-item:hover{border-color:#1890ff;color:#1890ff}.tooth-grid-letter-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.tooth-grid-letter-row.hidden,.tooth-grid-number-row.hidden{display:none}.tooth-grid-letter-row{margin-bottom:8px}.tooth-grid-number-row.upper-number-row{margin-bottom:15px}.tooth-grid-number-row.lower-number-row{margin-top:15px}.tooth-grid-letter-row.lower-letter-row{margin-top:8px}.tooth-preview-section{padding-top:10px;border-top:1px solid #e8e8e8}.tooth-preview-title{font-size:14px;font-weight:500;color:#333;margin-bottom:12px}.tooth-preview-wrapper{display:flex;gap:15px}.tooth-preview-container{display:flex;justify-content:center;align-items:center;padding:10px;background:#fafafa;border-radius:8px;flex:1;min-height:60px}.tooth-preview-grid{display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;gap:0;width:100%;min-height:70px;position:relative}.tooth-preview-grid:before{content:"";position:absolute;left:50%;top:0;bottom:0;width:1px;background:#000;transform:translate(-50%)}.tooth-preview-grid:after{content:"";position:absolute;top:50%;left:0;right:0;height:1px;background:#000;transform:translateY(-50%)}.tooth-preview-quadrant{display:flex;align-items:center;padding:5px 10px;font-size:12px;flex-wrap:wrap;gap:4px;justify-content:center}.tooth-preview-upper-left{justify-content:flex-end}.tooth-preview-upper-right{justify-content:flex-start}.tooth-preview-lower-left{justify-content:flex-end}.tooth-preview-lower-right{justify-content:flex-start}.tooth-preview-tooth{position:relative;display:inline;margin:0 4px}.tooth-preview-tooth-value{font-size:12px}.tooth-preview-tooth-value--deciduous{font-size:10px}.tooth-preview-tooth-bracket{font-size:12px}.tooth-preview-supernumerary{font-size:9px;vertical-align:super;margin:0 1px}.tooth-preview-surface{font-size:9px;vertical-align:super;margin-left:1px}.tooth-extra-panel{width:100px;display:flex;flex-direction:column;gap:10px}.tooth-surface-panel{background:#fafafa;border-radius:8px;padding:10px 20px}.tooth-surface-title{font-size:12px;font-weight:500;color:#333;margin-bottom:8px;text-align:center}.tooth-surface-grid{display:flex;flex-direction:column;gap:4px;align-items:center}.tooth-surface-row{display:flex;gap:4px;justify-content:center}.tooth-surface-item{width:30px;height:30px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px dashed #d9d9d9;border-radius:5px;transition:all .2s;box-sizing:border-box}.tooth-surface-item--indent{margin-left:17px}.tooth-surface-item:hover{border-color:#1890ff;color:#1890ff}.tooth-surface-item.selected{background:#1890ff;border-color:#1890ff;border-style:solid;color:#fff}.tooth-supernumerary-panel{background:#fafafa;border-radius:8px;padding:10px 20px}.tooth-supernumerary-title{font-size:12px;font-weight:500;color:#333;margin-bottom:4px;text-align:center}.tooth-supernumerary-hint{font-size:10px;color:#999;font-weight:400}.tooth-supernumerary-grid{display:flex;gap:8px;justify-content:center;margin-top:8px}.tooth-supernumerary-item{width:30px;height:35px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;color:#333;cursor:pointer;background:#fff;border:1px solid #d9d9d9;border-bottom:none;border-radius:50px;transition:all .2s;box-sizing:border-box}.tooth-supernumerary-item:hover{border-color:#1890ff;color:#1890ff}.tooth-supernumerary-item.selected{background:#1890ff;border-color:#1890ff;color:#fff}.ce-button-input-modal,.ce-button-edit-modal,.ce-number-input-modal,.tooth-position-edit-modal,.tooth-position-create-modal{inset:0;display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box;overflow:auto;background:transparent;pointer-events:none}.ce-button-input-modal__content,.ce-button-edit-modal__content,.ce-number-input-modal__content,.tooth-position-modal__container{pointer-events:auto}.ce-button-input-modal__content,.ce-button-edit-modal__content,.ce-number-input-modal__content{max-height:calc(100vh - 48px);overflow:auto}.tooth-position-modal__mask{display:none}.tooth-position-modal__container{position:relative;top:auto;left:auto;transform:none;display:flex;flex-direction:column;max-height:calc(100vh - 48px)}.ant-modal-mask{display:none!important}.ant-modal-wrap{position:fixed!important;inset:0!important;display:flex!important;align-items:center!important;justify-content:center!important;padding:24px!important;box-sizing:border-box!important;overflow:auto!important;pointer-events:none!important}.ant-modal{top:auto!important;margin:0!important;padding-bottom:0!important;max-width:calc(100vw - 48px)!important;max-height:calc(100vh - 48px)!important;pointer-events:auto!important}.ant-modal-content{max-height:calc(100vh - 48px)!important;overflow:auto!important}.dialog-mask{display:none}.dialog-container{position:fixed;inset:0;overflow:auto;z-index:999;margin:0;padding:24px;box-sizing:border-box;display:flex;justify-content:center;align-items:center;pointer-events:none}.dialog{position:relative;padding:0 30px 30px;background:#fff;box-shadow:0 2px 12px #38383833;border:1px solid #e2e6ed;border-radius:2px;max-height:calc(100vh - 48px);overflow:auto;pointer-events:auto}.dialog-title{position:relative;border-bottom:1px solid #e2e6ed;margin-bottom:30px;height:60px;display:flex;align-items:center;justify-content:space-between}.dialog-title i{width:16px;height:16px;cursor:pointer;display:inline-block;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.9%208.192l4.242%204.243-.707.707L8.192%208.9%203.95%2013.142l-.707-.707%204.242-4.243L3.243%203.95l.707-.707%204.242%204.242%204.243-4.242.707.707L8.9%208.192z'%20fill='%236A6A6A'%20fill-rule='evenodd'/%3e%3c/svg%3e")}.dialog-option__item{margin-bottom:18px;display:flex;align-items:center;justify-content:space-between}.dialog-option__item span{margin-right:12px;font-size:14px;color:#3d4757;position:relative}.dialog-option__item input,.dialog-option__item textarea,.dialog-option__item select{width:276px;height:30px;border-radius:2px;border:1px solid #d3d3d3;min-height:30px;padding:5px;box-sizing:border-box;outline:none;appearance:none;-webkit-user-select:none;user-select:none;font-family:inherit}.dialog-option__item input:focus,.dialog-option__item textarea:focus{border-color:#4991f2}.dialog-option__item--require:before{content:"*";color:#f56c6c;margin-right:4px;position:absolute;left:-8px}.dialog-menu{display:flex;align-items:center;justify-content:flex-end}.dialog-menu button{position:relative;display:inline-block;border:1px solid #e2e6ed;border-radius:2px;background:#fff;line-height:22px;padding:0 16px;white-space:nowrap;cursor:pointer}.dialog-menu button:hover{background:#1937580a}.dialog-menu__cancel{margin-right:16px}.dialog-menu button[type=submit]{color:#fff;background:#4991f2;border-color:#4991f2}.dialog-menu button[type=submit]:hover{background:#5b9cf3;border-color:#5b9cf3}.dialog-radio-group{display:flex;flex-direction:column;gap:8px}.dialog-radio-group--horizontal{flex-direction:row;gap:16px}.dialog-radio-item{display:flex;align-items:center;cursor:pointer;font-size:14px;color:#3d4757}.dialog-radio-item input[type=radio]{width:16px;height:16px;margin:0 6px 0 0;cursor:pointer;appearance:auto}.dialog-radio-item span{margin:0}`)),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- (function(s,fn){typeof exports=="object"&&typeof module<"u"?fn(exports):typeof define=="function"&&define.amd?define(["exports"],fn):(s=typeof globalThis<"u"?globalThis:s||self,fn(s["canvas-editor"]={}))})(this,(function(s){"use strict";const fn="0.7.30";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="​",Ps=`
2
+ (function(s,fn){typeof exports=="object"&&typeof module<"u"?fn(exports):typeof define=="function"&&define.amd?define(["exports"],fn):(s=typeof globalThis<"u"?globalThis:s||self,fn(s["canvas-editor"]={}))})(this,(function(s){"use strict";const fn="0.7.31";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="​",Ps=`
3
3
  `,oi=" ",Es="&nbsp;",zl=["·","、",":",":",",",",",".","。",";",";","?","?","!","!"],Ms={[s.MaxHeightRatio.HALF]:1/2,[s.MaxHeightRatio.ONE_THIRD]:1/3,[s.MaxHeightRatio.QUARTER]:1/4},ii={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:"ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΛλΜμΝνΞξΟοΠπΡρΣσςΤτΥυΦφΧχΨψΩω"},jl="中";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 si=/[0-9.]/,ql=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,ta=/[#*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,ea=new RegExp(`${ta.source}|${ql.source}`,"g"),na=/[、,。?!;:……「」“”‘’*()【】〔〕〖〗〘〙〚〛《》———﹝﹞–—\\/·.,!?;:`~<>()[\]{}'"|]/,ri=new RegExp(`^[${K}
4
4
  ]`),oa=/[^0-9\+\-\.eE,]/,ia=/\s/;function sa(o,t){let e;return function(...n){e&&window.clearTimeout(e),e=window.setTimeout(()=>{o.apply(this,n)},t)}}function ra(o,t){let e=0,n;return function(...i){const l=Date.now();l-e>=t?(window.clearTimeout(n),o.apply(this,i),e=l):(window.clearTimeout(n),n=window.setTimeout(()=>{o.apply(this,i),e=l},t))}}function li(o,t){if(!o||typeof o!="object")return o;let e={};return Array.isArray(o)?e=o.map(n=>li(n,t)):Object.keys(o).forEach(n=>{t.includes(n)||(e[n]=li(o[n],t))}),e}function ct(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=>ct(e)):Object.keys(o).forEach(e=>{t[e]=ct(o[e])}),t}function ai(o){return o&&o.nodeType===1&&o.tagName.toLowerCase()==="body"}function Os(o,t,e){if(o&&!ai(o))for(o=o;o;){if(!t||t(o)||ai(o))return t&&!t(o)&&ai(o)?null:o;o=o.parentNode}return null}function ft(){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(ea))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 Ss(o,t){const e=document.createElement("a");e.href=o,e.download=t,e.click()}function la(o,t){aa(3,o,t)}function aa(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 fo(o){return Object.prototype.toString.call(o)==="[object Object]"}function ci(o){return Array.isArray(o)}function di(o){return Object.prototype.toString.call(o)==="[object Number]"}function ca(o){return Object.prototype.toString.call(o)==="[object String]"}function Xs(o,t){if(fo(o)&&fo(t)){const e=t;for(const[n,i]of Object.entries(o))e[n]?e[n]=Xs(i,e[n]):e[n]=i}else ci(o)&&ci(t)&&t.push(...o);return t}function ui(o){if(typeof queueMicrotask=="function"){queueMicrotask(()=>{o()});return}if(typeof Promise<"u"){Promise.resolve().then(()=>{o()});return}setTimeout(()=>{o()},0)}function da(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 Ns(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 $t(o,t){const e={};for(const n in o)t.includes(n)&&(e[n]=o[n]);return e}function pe(o,t){const e={};for(const n in o)t.includes(n)||(e[n]=o[n]);return e}function ua(o){const e=new TextEncoder().encode(o),n=Array.from(e,l=>String.fromCharCode(l));return window.btoa(n.join(""))}function Ra(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 Fs(o,t){return o.length!==t.length?!1:!o.some(e=>!t.includes(e))}function ha(o,t){if(!fo(o)||!fo(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 ga(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 ys(o){return o==null}function mo(o){return o.replace(/\r\n|\r/g,`
5
5
  `)}function bs(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 Ds(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 re(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function Ta(o,t){return o.performance.enabled&&t>=o.performance.threshold}function Ri(o,t,e,n=[],i){if(!Ta(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 fa=12,ma={width:1,color:"#000000",dragWidth:2,dragColor:"#0000FF",dragFloatImageDisabled:!1},Be="editor-component",rt="ce",zn=`${rt}-clipboard`,po={print:{imagePreviewerDisabled:!1,backgroundDisabled:!1},compare:{imagePreviewerDisabled:!1,backgroundDisabled:!1},readonly:{imagePreviewerDisabled:!1},form:{controlDeletableDisabled:!1,inputTraceEnabled:!0,deleteTraceEnabled:!0}};var Jt;(function(o){o.UP="top",o.DOWN="down",o.LEFT="left",o.RIGHT="right"})(Jt||(Jt={}));const mn=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),pa=typeof navigator<"u"&&/iPad|iPhone/.test(navigator.userAgent),Ca=/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),Ia=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 Xe=["bold","color","highlight","font","size","italic","underline","strikeout","textDecoration","deletePerson","newElEditPerson","deleteTime","newElEditTime"],ue=["rowFlex","rowMargin"],La=["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"],Pa=["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"],Ea=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],pn=["tdId","trId","tableId"],hi=["level","titleId","title"],Nn=["listId","listType","listStyle"],gi=["control","controlId","controlComponent"],Re=["font","size","bold","highlight","italic","strikeout","deletePerson","newElEditPerson","deleteTime","color","newElEditTime"],cn=["areaId","area"],Ti=[...pn,...hi,...Nn,...cn],Ce=[s.ElementType.TEXT,s.ElementType.HYPERLINK,s.ElementType.SUBSCRIPT,s.ElementType.SUPERSCRIPT,s.ElementType.CONTROL,s.ElementType.DATE],Ma=[s.ElementType.IMAGE,s.ElementType.LATEX],Oa=[s.ElementType.BLOCK,s.ElementType.PAGE_BREAK,s.ElementType.SEPARATOR,s.ElementType.TABLE],Sa=["HR","TABLE","UL","OL"],Xa=[s.ElementType.TITLE,s.ElementType.LIST];class Fn{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||Fn.sandbox),n.setAttribute("allow",[e?.allow||Fn.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 Vs{draw;options;imageCache;container;floatImageContainer;floatImage;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer(),this.imageCache=new Map,this.floatImageContainer=null,this.floatImage=null}getOriginalMainImageList(){const t=[],e=n=>{for(const i of n)if(i.type===s.ElementType.TABLE){const l=i.trList;for(let r=0;r<l.length;r++){const a=l[r];for(let c=0;c<a.tdList.length;c++){const d=a.tdList[c];e(d.value)}}}else i.type===s.ElementType.IMAGE&&t.push(i)};return e(this.draw.getOriginalMainElementList()),t}_countImagesBeforeTarget(t,e){let n=0;for(const i of t){if(i===e)break;if(i.type===s.ElementType.TABLE){const l=i.trList;for(const r of l)for(const a of r.tdList)n+=this._countImagesBeforeTarget(a.value,e)}else i.type===s.ElementType.IMAGE&&n++}return n}createFloatImage(t){const{scale:e}=this.options;let n=this.floatImageContainer,i=this.floatImage;n||(n=document.createElement("div"),n.classList.add(`${rt}-float-image`),this.container.append(n),this.floatImageContainer=n),i||(i=document.createElement("img"),n.append(i),this.floatImage=i),n.style.display="none",i.style.width=`${t.width*e}px`,i.style.height=`${t.height*e}px`;const l=this.draw.getHeight(),r=this.draw.getPageGap(),a=this.draw.getPageNo()*(l+r),c=t.imgFloatPosition;n.style.left=`${c.x*e}px`,n.style.top=`${a+c.y*e}px`,i.src=t.value}dragFloatImage(t,e){if(!this.floatImageContainer)return;this.floatImageContainer.style.display="block";const n=parseFloat(this.floatImageContainer.style.left)+t,i=parseFloat(this.floatImageContainer.style.top)+e;this.floatImageContainer.style.left=`${n}px`,this.floatImageContainer.style.top=`${i}px`}destroyFloatImage(){this.floatImageContainer&&(this.floatImageContainer.style.display="none")}addImageObserver(t){this.draw.getImageObserver().add(t)}getFallbackImage(t,e){const i=(t-Math.ceil(t/8)*8)/2,l=(e-Math.ceil(e/8)*8)/2,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${e}" viewBox="0 0 ${t} ${e}">
@@ -58,36 +58,36 @@ trailer
58
58
  >>startxref
59
59
 
60
60
  %%EOF
61
- `,c+d}boxes(t){t||(t={});const[e,n,i,l]=this.resolveScale(t),r=[];for(let a=0;a<this._tree.chld.length;a++){const{x:c,y:d,w:u,h:R}=this._tree.chld[a].bbox;r.push({x:e+c*i,y:n+d*l,w:u*i,h:R*l})}return r}box(t){t||(t={});const[e,n,i,l]=this.resolveScale(t);return{x:e+this._tree.bbox.x*i,y:n+this._tree.bbox.y*l,w:this._tree.bbox.w*i,h:this._tree.bbox.h*l}}}class Us extends Vs{static convertLaTextToSVG(t){return new Ua(t).svg({SCALE_X:10,SCALE_Y:10,MARGIN_X:0,MARGIN_Y:0})}render(t,e,n,i){const{scale:l}=this.options,r=e.width*l,a=e.height*l;if(this.imageCache.has(e.value)){const c=this.imageCache.get(e.value);t.drawImage(c,n,i,r,a)}else{const c=new Promise((d,u)=>{const R=new Image;R.src=e.laTexSVG,R.onload=()=>{t.drawImage(R,n,i,r,a),this.imageCache.set(e.value,R),d(e)},R.onerror=h=>{u(h)}});this.addImageObserver(c)}}}s.ListType=void 0,(function(o){o.UL="ul",o.OL="ol"})(s.ListType||(s.ListType={}));var Cn;(function(o){o.DISC="disc",o.CIRCLE="circle",o.SQUARE="square",o.CHECKBOX="checkbox"})(Cn||(Cn={}));var ws;(function(o){o.DECIMAL="decimal"})(ws||(ws={})),s.ListStyle=void 0,(function(o){o.DISC="disc",o.CIRCLE="circle",o.SQUARE="square",o.DECIMAL="decimal",o.CHECKBOX="checkbox"})(s.ListStyle||(s.ListStyle={}));const wa={inheritStyle:!1},pi={[Cn.DISC]:"•",[Cn.CIRCLE]:"◦",[Cn.SQUARE]:"▫︎",[Cn.CHECKBOX]:"☑️"},Za={[s.ListType.OL]:"ol",[s.ListType.UL]:"ul"},va={[s.ListStyle.DISC]:"disc",[s.ListStyle.CIRCLE]:"circle",[s.ListStyle.SQUARE]:"square",[s.ListStyle.DECIMAL]:"decimal",[s.ListStyle.CHECKBOX]:"checkbox"};s.TitleLevel=void 0,(function(o){o.FIRST="first",o.SECOND="second",o.THIRD="third",o.FOURTH="fourth",o.FIFTH="fifth",o.SIXTH="sixth"})(s.TitleLevel||(s.TitleLevel={}));const Qa={defaultFirstSize:26,defaultSecondSize:24,defaultThirdSize:22,defaultFourthSize:20,defaultFifthSize:18,defaultSixthSize:16},Zs={[s.TitleLevel.FIRST]:"defaultFirstSize",[s.TitleLevel.SECOND]:"defaultSecondSize",[s.TitleLevel.THIRD]:"defaultThirdSize",[s.TitleLevel.FOURTH]:"defaultFourthSize",[s.TitleLevel.FIFTH]:"defaultFifthSize",[s.TitleLevel.SIXTH]:"defaultSixthSize"},Ci={[s.TitleLevel.FIRST]:1,[s.TitleLevel.SECOND]:2,[s.TitleLevel.THIRD]:3,[s.TitleLevel.FOURTH]:4,[s.TitleLevel.FIFTH]:5,[s.TitleLevel.SIXTH]:6},Ka={H1:s.TitleLevel.FIRST,H2:s.TitleLevel.SECOND,H3:s.TitleLevel.THIRD,H4:s.TitleLevel.FOURTH,H5:s.TitleLevel.FIFTH,H6:s.TitleLevel.SIXTH};s.BlockType=void 0,(function(o){o.IFRAME="iframe",o.VIDEO="video"})(s.BlockType||(s.BlockType={})),s.ControlType=void 0,(function(o){o.TEXT="text",o.SELECT="select",o.CHECKBOX="checkbox",o.RADIO="radio",o.DATE="date",o.NUMBER="number",o.TEXTFIELD="TextField",o.BUTTON="button",o.MENSTRUAL_HISTORY="menstrualHistory"})(s.ControlType||(s.ControlType={})),s.ControlComponent=void 0,(function(o){o.PREFIX="prefix",o.POSTFIX="postfix",o.PRE_TEXT="preText",o.PRETEXTFIX="preTextFix",o.PRETEXTFIX_TEXT="preTextFixText",o.POSTTEXTFIX="postTextFix",o.POSTTEXTFIX_TEXT="postTextFixText",o.POST_TEXT="postText",o.PLACEHOLDER="placeholder",o.TEXTFIXLABEL="textFixLabel",o.VALUE="value",o.DELETEPERSON="deletePerson",o.CHECKBOX="checkbox",o.RADIO="radio",o.UNDERLINE="underline"})(s.ControlComponent||(s.ControlComponent={})),s.ControlIndentation=void 0,(function(o){o.ROW_START="rowStart",o.VALUE_START="valueStart"})(s.ControlIndentation||(s.ControlIndentation={})),s.ControlState=void 0,(function(o){o.ACTIVE="active",o.INACTIVE="inactive"})(s.ControlState||(s.ControlState={}));var vs;(function(o){o.NUMBER="number",o.OPERATOR="operator",o.UTILITY="utility",o.EQUAL="equal"})(vs||(vs={})),s.EditorComponent=void 0,(function(o){o.COMPONENT="component",o.MENU="menu",o.MAIN="main",o.FOOTER="footer",o.CONTEXTMENU="contextmenu",o.POPUP="popup",o.CATALOG="catalog",o.COMMENT="comment"})(s.EditorComponent||(s.EditorComponent={}));var we;(function(o){o.PAGE="page",o.TABLE="table"})(we||(we={})),s.EditorMode=void 0,(function(o){o.EDIT="edit",o.CLEAN="clean",o.READONLY="readonly",o.FORM="form",o.PRINT="print",o.COMPARE="compare",o.DESIGN="design",o.GRAFFITI="graffiti"})(s.EditorMode||(s.EditorMode={})),s.EditorZone=void 0,(function(o){o.HEADER="header",o.MAIN="main",o.FOOTER="footer"})(s.EditorZone||(s.EditorZone={})),s.PageMode=void 0,(function(o){o.PAGING="paging",o.CONTINUITY="continuity"})(s.PageMode||(s.PageMode={})),s.PaperDirection=void 0,(function(o){o.VERTICAL="vertical",o.HORIZONTAL="horizontal"})(s.PaperDirection||(s.PaperDirection={})),s.WordBreak=void 0,(function(o){o.BREAK_ALL="break-all",o.BREAK_WORD="break-word"})(s.WordBreak||(s.WordBreak={})),s.RenderMode=void 0,(function(o){o.SPEED="speed",o.COMPATIBILITY="compatibility"})(s.RenderMode||(s.RenderMode={})),s.TableBorder=void 0,(function(o){o.ALL="all",o.EMPTY="empty",o.EXTERNAL="external",o.INTERNAL="internal",o.DASH="dash"})(s.TableBorder||(s.TableBorder={})),s.TdBorder=void 0,(function(o){o.TOP="top",o.RIGHT="right",o.BOTTOM="bottom",o.LEFT="left"})(s.TdBorder||(s.TdBorder={})),s.TdSlash=void 0,(function(o){o.FORWARD="forward",o.BACK="back"})(s.TdSlash||(s.TdSlash={})),s.BackgroundSize=void 0,(function(o){o.CONTAIN="contain",o.COVER="cover"})(s.BackgroundSize||(s.BackgroundSize={})),s.BackgroundRepeat=void 0,(function(o){o.REPEAT="repeat",o.NO_REPEAT="no-repeat",o.REPEAT_X="repeat-x",o.REPEAT_Y="repeat-y"})(s.BackgroundRepeat||(s.BackgroundRepeat={}));const Ha={color:"#FFFFFF",image:"",size:s.BackgroundSize.COVER,repeat:s.BackgroundRepeat.NO_REPEAT,applyPageNumbers:[]};s.VerticalAlign=void 0,(function(o){o.TOP="top",o.MIDDLE="middle",o.BOTTOM="bottom"})(s.VerticalAlign||(s.VerticalAlign={}));const _a={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#ffffff",verticalAlign:s.VerticalAlign.BOTTOM},Aa={placeholderColor:"#9c9b9b",bracketColor:"#2284FE",textFixColor:"blue",prefix:"[",postfix:"]",preTextFix:"{",postTextFix:"}",textFixLabel:"",preTextFixText:"",postTextFixText:"",borderWidth:1,borderColor:"#000000",activeBackgroundColor:"",disabledBackgroundColor:"",existValueBackgroundColor:"",noValueBackgroundColor:"",inlineControlBackgroundColor:"#BFF7D7"},ka={bottom:30,inactiveAlpha:1,maxHeightRadio:s.MaxHeightRatio.HALF,disabled:!1,editable:!0},Ga={opacity:.1,backgroundColor:"#E99D00",activeOpacity:.5,activeBackgroundColor:"#E99D00",disabled:!1,deletable:!0},xa={top:30,inactiveAlpha:1,maxHeightRadio:s.MaxHeightRatio.HALF,disabled:!1,editable:!0},Ba={defaultColor:"#1976d2",defaultBackgroundColor:"#e3f2fd",defaultBorderRadius:4,defaultPadding:[4,4,4,4]},Ja={color:"#666666",font:"Microsoft YaHei",size:12,top:5},$a={disabled:!0,color:"#CCCCCC",lineWidth:1.5},za={font:"Microsoft YaHei",fontSize:12,lineDash:[3,1]},jn={PAGE_NO:"{pageNo}",PAGE_COUNT:"{pageCount}"},ja={bottom:60,size:12,font:"Microsoft YaHei",color:"#000000",rowFlex:s.RowFlex.CENTER,format:jn.PAGE_NO,numberType:s.NumberType.ARABIC,disabled:!1,startPageNo:1,fromPageNo:0,maxPageNo:null},Qs={data:"",color:"#DCDFE6",opacity:1,size:16,font:"Microsoft YaHei"},qa={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#000000",verticalAlign:s.VerticalAlign.BOTTOM},tc={lineWidth:1,strokeStyle:"#000000"},ec={tdPadding:[5,5,5,5],defaultTrMinHeight:24,defaultColMinWidth:40,defaultBorderColor:"#000000",overflow:!0};s.WatermarkType=void 0,(function(o){o.TEXT="text",o.IMAGE="image"})(s.WatermarkType||(s.WatermarkType={}));const Ii={data:"",type:s.WatermarkType.TEXT,width:0,height:0,color:"#AEB5C0",opacity:.3,size:200,font:"Microsoft YaHei",repeat:!1,gap:[10,10],numberType:s.NumberType.ARABIC},nc={tipDisabled:!0};s.LineNumberType=void 0,(function(o){o.PAGE="page",o.CONTINUITY="continuity"})(s.LineNumberType||(s.LineNumberType={}));const oc={size:12,font:"Microsoft YaHei",color:"#000000",disabled:!0,right:20,type:s.LineNumberType.CONTINUITY},ic={color:"#000000",lineWidth:1,padding:[0,5,0,5],disabled:!0},sc={top:0,left:5},rc={defaultLineColor:"#000000",defaultLineWidth:2},lc={disabled:!0,color:"#CCCCCC",radius:1};function Lo(o={}){const t={...ec,...o.table},e={...xa,...o.header},n={...ka,...o.footer},i={...ja,...o.pageNumber},l={...Ii,...o.watermark},r={...Aa,...o.control},a={..._a,...o.checkbox},c={...qa,...o.radio},d={...ma,...o.cursor},u={...Qa,...o.title},R={...Qs,...o.placeholder},h={...Ga,...o.group},g={...za,...o.pageBreak},T={...nc,...o.zone},f={...Ha,...o.background},p={...$a,...o.lineBreak},C={...lc,...o.whiteSpace},I={...tc,...o.separator},m={...oc,...o.lineNumber},P={...ic,...o.pageBorder},E={...sc,...o.badge},M={...rc,...o.graffiti},F={...Ba,...o.label},y={...Ja,...o.imgCaption},Y={...wa,...o.list},D={print:{...po.print,...o.modeRule?.print},compare:{...po.compare,...o.modeRule?.compare},readonly:{...po.readonly,...o.modeRule?.readonly},form:{...po.form,...o.modeRule?.form}};return{mode:s.EditorMode.EDIT,locale:"zhCN",defaultType:"TEXT",defaultColor:"#000000",defaultFont:"SimSun",defaultSize:16,minSize:5,maxSize:72,defaultRowMargin:1,defaultBasicRowMarginHeight:8,defaultTabWidth:32,width:794,height:1123,scale:1,pageGap:20,underlineColor:"#000000",strikeoutColor:"#FF0000",rangeAlpha:.6,rangeColor:"#AECBFA",rangeMinWidth:5,searchMatchAlpha:.6,searchMatchColor:"#FFFF00",searchNavigateMatchColor:"#AAD280",highlightAlpha:.6,highlightMarginHeight:8,resizerColor:"#4182D9",resizerSize:5,marginIndicatorSize:35,marginIndicatorColor:"#BABABA",margins:[75.591,56.693,56.693,56.693],pageMode:s.PageMode.PAGING,renderMode:s.RenderMode.SPEED,defaultHyperlinkColor:"#0000FF",paperDirection:s.PaperDirection.VERTICAL,inactiveAlpha:.6,historyMaxRecordCount:100,wordBreak:s.WordBreak.BREAK_WORD,printPixelRatio:3,maskMargin:[0,0,0,0],letterClass:[ii.ENGLISH,ii.NUMBER],contextMenuDisableKeys:[],shortcutDisableKeys:[],scrollContainerSelector:"",pageOuterSelectionDisable:!1,...o,table:t,header:e,footer:n,pageNumber:i,watermark:l,control:r,checkbox:a,radio:c,cursor:d,title:u,placeholder:R,group:h,pageBreak:g,zone:T,background:f,lineBreak:p,whiteSpace:C,separator:I,lineNumber:m,pageBorder:P,badge:E,modeRule:D,graffiti:M,label:F,imgCaption:y,list:Y,performance:{enabled:!1,threshold:16,...o.performance}}}const Ks=new Map,ac=[s.ControlType.NUMBER,s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.CHECKBOX,s.ControlType.RADIO];function Ze(o,t){return o&&ac.includes(o)?[""]:yt(t)}function cc(o){return Ks.get(o)}function Po(o,t){Ks.set(o,t)}function Li(o){const t=[];for(let e=0;e<o.length;e++){const n=o[e],i=yt(n.value);for(let l=0;l<i.length;l++)t.push({...n,value:i[l]})}return t}const Hs=new Set([s.ControlComponent.PREFIX,s.ControlComponent.POSTFIX,s.ControlComponent.PRE_TEXT,s.ControlComponent.POST_TEXT,s.ControlComponent.PRETEXTFIX,s.ControlComponent.PRETEXTFIX_TEXT,s.ControlComponent.POSTTEXTFIX,s.ControlComponent.POSTTEXTFIX_TEXT,s.ControlComponent.PLACEHOLDER,s.ControlComponent.TEXTFIXLABEL,s.ControlComponent.CHECKBOX,s.ControlComponent.RADIO,s.ControlComponent.UNDERLINE]),dc=["请选择","双击获取日期","格式化日期时间"];function uc(o){return(o||[]).map(t=>t.value===K?`
62
- `:t.value||"").join("")}function _s(o){return uc(o.value)}function As(o){return o.placeholder||o.buttonLabel||o.label||""}function bn(){return{color:"#1677FF",highlight:void 0}}function Eo(o){return{color:o,highlight:void 0}}function ks(o){return o===s.EditorMode.READONLY}function Rc(o){const t=[];return o.filter(Boolean).forEach(e=>{t.push(e,`获取${e}`,`获取 ${e}`,`请选择${e}`,`请选择 ${e}`,`请输入${e}`,`请输入 ${e}`)}),t}function ve(o,t=[]){if(!o)return"";const e=o.replace(new RegExp(`${K}`,"g"),`
63
- `),n=e.trim();return n?[...dc,...Rc(t)].includes(n)?"":e:""}function Pi(o,t){const e=ve(o,[t?.label||""]);if(!e)return[];const n=t?$t(t,[...ue,"font","size","bold","italic","underline","strikeout","rowFlex","rowMargin","textDecoration","deletePerson","newElEditPerson","deleteTime","newElEditTime","color"]):{};return yt(e).map(i=>({...n,type:s.ElementType.TEXT,value:i===`
64
- `?K:i}))}function Mo(o){const t=(o.code||"").split(",").map(n=>n.trim()).filter(Boolean);if(!t.length||!o.valueSets?.length)return"";const e=o.multiSelectDelimiter||",";return t.map(n=>o.valueSets?.find(i=>i.code===n)?.value).filter(n=>!!n).join(e)}function Gs(o){return o.type===s.ElementType.REUSABLE_ITEM?ve(o.reusableItemConfig?.value||"",[o.label||""]):o.type===s.ElementType.CUSTOM_MACRO?ve(o.macroConfig?.value||o.value||"",[o.label||""]):o.type===s.ElementType.MACRO?ve(o.value||"",[o.label||""]):""}function hc(o){const t=o.control;if(!t)return[];const e=[t.placeholder||"",t.label||""];if(t.type===s.ControlType.CHECKBOX||t.type===s.ControlType.RADIO){const r=ve(Mo(t),e);if(r)return Pi(r,o)}const i=Dn(t.value||[]);return ve(So(i),e)?i:t.type===s.ControlType.SELECT?Pi(ve(Mo(t),e),o):[]}function gc(o){if(!o)return"";const t=[o.placeholder||"",o.label||""];if(o.type===s.ControlType.CHECKBOX||o.type===s.ControlType.RADIO){const i=ve(Mo(o),t);if(i)return i}const n=ve(So(o.value||[]),t);return n||(o.type===s.ControlType.SELECT?ve(Mo(o),t):"")}function Oo(o){return ae(o)||o.controlComponent&&Hs.has(o.controlComponent)?"":o.type===s.ElementType.CONTROL?gc(o.control):o.type===s.ElementType.MACRO||o.type===s.ElementType.CUSTOM_MACRO||o.type===s.ElementType.REUSABLE_ITEM?Gs(o):o.type===s.ElementType.TABLE?o.trList?.map(t=>t.tdList.map(e=>So(e.value||[])).join(" ")).join(`
61
+ `,c+d}boxes(t){t||(t={});const[e,n,i,l]=this.resolveScale(t),r=[];for(let a=0;a<this._tree.chld.length;a++){const{x:c,y:d,w:u,h:R}=this._tree.chld[a].bbox;r.push({x:e+c*i,y:n+d*l,w:u*i,h:R*l})}return r}box(t){t||(t={});const[e,n,i,l]=this.resolveScale(t);return{x:e+this._tree.bbox.x*i,y:n+this._tree.bbox.y*l,w:this._tree.bbox.w*i,h:this._tree.bbox.h*l}}}class Us extends Vs{static convertLaTextToSVG(t){return new Ua(t).svg({SCALE_X:10,SCALE_Y:10,MARGIN_X:0,MARGIN_Y:0})}render(t,e,n,i){const{scale:l}=this.options,r=e.width*l,a=e.height*l;if(this.imageCache.has(e.value)){const c=this.imageCache.get(e.value);t.drawImage(c,n,i,r,a)}else{const c=new Promise((d,u)=>{const R=new Image;R.src=e.laTexSVG,R.onload=()=>{t.drawImage(R,n,i,r,a),this.imageCache.set(e.value,R),d(e)},R.onerror=h=>{u(h)}});this.addImageObserver(c)}}}s.ListType=void 0,(function(o){o.UL="ul",o.OL="ol"})(s.ListType||(s.ListType={}));var Cn;(function(o){o.DISC="disc",o.CIRCLE="circle",o.SQUARE="square",o.CHECKBOX="checkbox"})(Cn||(Cn={}));var ws;(function(o){o.DECIMAL="decimal"})(ws||(ws={})),s.ListStyle=void 0,(function(o){o.DISC="disc",o.CIRCLE="circle",o.SQUARE="square",o.DECIMAL="decimal",o.CHECKBOX="checkbox"})(s.ListStyle||(s.ListStyle={}));const wa={inheritStyle:!1},pi={[Cn.DISC]:"•",[Cn.CIRCLE]:"◦",[Cn.SQUARE]:"▫︎",[Cn.CHECKBOX]:"☑️"},Za={[s.ListType.OL]:"ol",[s.ListType.UL]:"ul"},Qa={[s.ListStyle.DISC]:"disc",[s.ListStyle.CIRCLE]:"circle",[s.ListStyle.SQUARE]:"square",[s.ListStyle.DECIMAL]:"decimal",[s.ListStyle.CHECKBOX]:"checkbox"};s.TitleLevel=void 0,(function(o){o.FIRST="first",o.SECOND="second",o.THIRD="third",o.FOURTH="fourth",o.FIFTH="fifth",o.SIXTH="sixth"})(s.TitleLevel||(s.TitleLevel={}));const va={defaultFirstSize:26,defaultSecondSize:24,defaultThirdSize:22,defaultFourthSize:20,defaultFifthSize:18,defaultSixthSize:16},Zs={[s.TitleLevel.FIRST]:"defaultFirstSize",[s.TitleLevel.SECOND]:"defaultSecondSize",[s.TitleLevel.THIRD]:"defaultThirdSize",[s.TitleLevel.FOURTH]:"defaultFourthSize",[s.TitleLevel.FIFTH]:"defaultFifthSize",[s.TitleLevel.SIXTH]:"defaultSixthSize"},Ci={[s.TitleLevel.FIRST]:1,[s.TitleLevel.SECOND]:2,[s.TitleLevel.THIRD]:3,[s.TitleLevel.FOURTH]:4,[s.TitleLevel.FIFTH]:5,[s.TitleLevel.SIXTH]:6},Ka={H1:s.TitleLevel.FIRST,H2:s.TitleLevel.SECOND,H3:s.TitleLevel.THIRD,H4:s.TitleLevel.FOURTH,H5:s.TitleLevel.FIFTH,H6:s.TitleLevel.SIXTH};s.BlockType=void 0,(function(o){o.IFRAME="iframe",o.VIDEO="video"})(s.BlockType||(s.BlockType={})),s.ControlType=void 0,(function(o){o.TEXT="text",o.SELECT="select",o.CHECKBOX="checkbox",o.RADIO="radio",o.DATE="date",o.NUMBER="number",o.TEXTFIELD="TextField",o.BUTTON="button",o.MENSTRUAL_HISTORY="menstrualHistory"})(s.ControlType||(s.ControlType={})),s.ControlComponent=void 0,(function(o){o.PREFIX="prefix",o.POSTFIX="postfix",o.PRE_TEXT="preText",o.PRETEXTFIX="preTextFix",o.PRETEXTFIX_TEXT="preTextFixText",o.POSTTEXTFIX="postTextFix",o.POSTTEXTFIX_TEXT="postTextFixText",o.POST_TEXT="postText",o.PLACEHOLDER="placeholder",o.TEXTFIXLABEL="textFixLabel",o.VALUE="value",o.DELETEPERSON="deletePerson",o.CHECKBOX="checkbox",o.RADIO="radio",o.UNDERLINE="underline"})(s.ControlComponent||(s.ControlComponent={})),s.ControlIndentation=void 0,(function(o){o.ROW_START="rowStart",o.VALUE_START="valueStart"})(s.ControlIndentation||(s.ControlIndentation={})),s.ControlState=void 0,(function(o){o.ACTIVE="active",o.INACTIVE="inactive"})(s.ControlState||(s.ControlState={}));var Qs;(function(o){o.NUMBER="number",o.OPERATOR="operator",o.UTILITY="utility",o.EQUAL="equal"})(Qs||(Qs={})),s.EditorComponent=void 0,(function(o){o.COMPONENT="component",o.MENU="menu",o.MAIN="main",o.FOOTER="footer",o.CONTEXTMENU="contextmenu",o.POPUP="popup",o.CATALOG="catalog",o.COMMENT="comment"})(s.EditorComponent||(s.EditorComponent={}));var we;(function(o){o.PAGE="page",o.TABLE="table"})(we||(we={})),s.EditorMode=void 0,(function(o){o.EDIT="edit",o.CLEAN="clean",o.READONLY="readonly",o.FORM="form",o.PRINT="print",o.COMPARE="compare",o.DESIGN="design",o.GRAFFITI="graffiti"})(s.EditorMode||(s.EditorMode={})),s.EditorZone=void 0,(function(o){o.HEADER="header",o.MAIN="main",o.FOOTER="footer"})(s.EditorZone||(s.EditorZone={})),s.PageMode=void 0,(function(o){o.PAGING="paging",o.CONTINUITY="continuity"})(s.PageMode||(s.PageMode={})),s.PaperDirection=void 0,(function(o){o.VERTICAL="vertical",o.HORIZONTAL="horizontal"})(s.PaperDirection||(s.PaperDirection={})),s.WordBreak=void 0,(function(o){o.BREAK_ALL="break-all",o.BREAK_WORD="break-word"})(s.WordBreak||(s.WordBreak={})),s.RenderMode=void 0,(function(o){o.SPEED="speed",o.COMPATIBILITY="compatibility"})(s.RenderMode||(s.RenderMode={})),s.TableBorder=void 0,(function(o){o.ALL="all",o.EMPTY="empty",o.EXTERNAL="external",o.INTERNAL="internal",o.DASH="dash"})(s.TableBorder||(s.TableBorder={})),s.TdBorder=void 0,(function(o){o.TOP="top",o.RIGHT="right",o.BOTTOM="bottom",o.LEFT="left"})(s.TdBorder||(s.TdBorder={})),s.TdSlash=void 0,(function(o){o.FORWARD="forward",o.BACK="back"})(s.TdSlash||(s.TdSlash={})),s.BackgroundSize=void 0,(function(o){o.CONTAIN="contain",o.COVER="cover"})(s.BackgroundSize||(s.BackgroundSize={})),s.BackgroundRepeat=void 0,(function(o){o.REPEAT="repeat",o.NO_REPEAT="no-repeat",o.REPEAT_X="repeat-x",o.REPEAT_Y="repeat-y"})(s.BackgroundRepeat||(s.BackgroundRepeat={}));const Ha={color:"#FFFFFF",image:"",size:s.BackgroundSize.COVER,repeat:s.BackgroundRepeat.NO_REPEAT,applyPageNumbers:[]};s.VerticalAlign=void 0,(function(o){o.TOP="top",o.MIDDLE="middle",o.BOTTOM="bottom"})(s.VerticalAlign||(s.VerticalAlign={}));const _a={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#ffffff",verticalAlign:s.VerticalAlign.BOTTOM},Aa={placeholderColor:"#9c9b9b",bracketColor:"#2284FE",textFixColor:"blue",prefix:"[",postfix:"]",preTextFix:"{",postTextFix:"}",textFixLabel:"",preTextFixText:"",postTextFixText:"",borderWidth:1,borderColor:"#000000",activeBackgroundColor:"",disabledBackgroundColor:"",existValueBackgroundColor:"",noValueBackgroundColor:"",inlineControlBackgroundColor:"#BFF7D7"},ka={bottom:30,inactiveAlpha:1,maxHeightRadio:s.MaxHeightRatio.HALF,disabled:!1,editable:!0},Ga={opacity:.1,backgroundColor:"#E99D00",activeOpacity:.5,activeBackgroundColor:"#E99D00",disabled:!1,deletable:!0},xa={top:30,inactiveAlpha:1,maxHeightRadio:s.MaxHeightRatio.HALF,disabled:!1,editable:!0},Ba={defaultColor:"#1976d2",defaultBackgroundColor:"#e3f2fd",defaultBorderRadius:4,defaultPadding:[4,4,4,4]},Ja={color:"#666666",font:"Microsoft YaHei",size:12,top:5},$a={disabled:!0,color:"#CCCCCC",lineWidth:1.5},za={font:"Microsoft YaHei",fontSize:12,lineDash:[3,1]},jn={PAGE_NO:"{pageNo}",PAGE_COUNT:"{pageCount}"},ja={bottom:60,size:12,font:"Microsoft YaHei",color:"#000000",rowFlex:s.RowFlex.CENTER,format:jn.PAGE_NO,numberType:s.NumberType.ARABIC,disabled:!1,startPageNo:1,fromPageNo:0,maxPageNo:null},vs={data:"",color:"#DCDFE6",opacity:1,size:16,font:"Microsoft YaHei"},qa={width:14,height:14,gap:5,lineWidth:1,fillStyle:"#5175f4",strokeStyle:"#000000",verticalAlign:s.VerticalAlign.BOTTOM},tc={lineWidth:1,strokeStyle:"#000000"},ec={tdPadding:[5,5,5,5],defaultTrMinHeight:24,defaultColMinWidth:40,defaultBorderColor:"#000000",overflow:!0};s.WatermarkType=void 0,(function(o){o.TEXT="text",o.IMAGE="image"})(s.WatermarkType||(s.WatermarkType={}));const Ii={data:"",type:s.WatermarkType.TEXT,width:0,height:0,color:"#AEB5C0",opacity:.3,size:200,font:"Microsoft YaHei",repeat:!1,gap:[10,10],numberType:s.NumberType.ARABIC},nc={tipDisabled:!0};s.LineNumberType=void 0,(function(o){o.PAGE="page",o.CONTINUITY="continuity"})(s.LineNumberType||(s.LineNumberType={}));const oc={size:12,font:"Microsoft YaHei",color:"#000000",disabled:!0,right:20,type:s.LineNumberType.CONTINUITY},ic={color:"#000000",lineWidth:1,padding:[0,5,0,5],disabled:!0},sc={top:0,left:5},rc={defaultLineColor:"#000000",defaultLineWidth:2},lc={disabled:!0,color:"#CCCCCC",radius:1};function Lo(o={}){const t={...ec,...o.table},e={...xa,...o.header},n={...ka,...o.footer},i={...ja,...o.pageNumber},l={...Ii,...o.watermark},r={...Aa,...o.control},a={..._a,...o.checkbox},c={...qa,...o.radio},d={...ma,...o.cursor},u={...va,...o.title},R={...vs,...o.placeholder},h={...Ga,...o.group},g={...za,...o.pageBreak},T={...nc,...o.zone},f={...Ha,...o.background},p={...$a,...o.lineBreak},C={...lc,...o.whiteSpace},I={...tc,...o.separator},m={...oc,...o.lineNumber},P={...ic,...o.pageBorder},E={...sc,...o.badge},M={...rc,...o.graffiti},F={...Ba,...o.label},y={...Ja,...o.imgCaption},Y={...wa,...o.list},D={print:{...po.print,...o.modeRule?.print},compare:{...po.compare,...o.modeRule?.compare},readonly:{...po.readonly,...o.modeRule?.readonly},form:{...po.form,...o.modeRule?.form}};return{mode:s.EditorMode.EDIT,locale:"zhCN",defaultType:"TEXT",defaultColor:"#000000",defaultFont:"SimSun",defaultSize:16,minSize:5,maxSize:72,defaultRowMargin:1,defaultBasicRowMarginHeight:8,defaultTabWidth:32,width:794,height:1123,scale:1,pageGap:20,underlineColor:"#000000",strikeoutColor:"#FF0000",rangeAlpha:.6,rangeColor:"#AECBFA",rangeMinWidth:5,searchMatchAlpha:.6,searchMatchColor:"#FFFF00",searchNavigateMatchColor:"#AAD280",highlightAlpha:.6,highlightMarginHeight:8,resizerColor:"#4182D9",resizerSize:5,marginIndicatorSize:35,marginIndicatorColor:"#BABABA",margins:[75.591,56.693,56.693,56.693],pageMode:s.PageMode.PAGING,renderMode:s.RenderMode.SPEED,defaultHyperlinkColor:"#0000FF",paperDirection:s.PaperDirection.VERTICAL,inactiveAlpha:.6,historyMaxRecordCount:100,wordBreak:s.WordBreak.BREAK_WORD,printPixelRatio:3,maskMargin:[0,0,0,0],letterClass:[ii.ENGLISH,ii.NUMBER],contextMenuDisableKeys:[],shortcutDisableKeys:[],scrollContainerSelector:"",pageOuterSelectionDisable:!1,...o,table:t,header:e,footer:n,pageNumber:i,watermark:l,control:r,checkbox:a,radio:c,cursor:d,title:u,placeholder:R,group:h,pageBreak:g,zone:T,background:f,lineBreak:p,whiteSpace:C,separator:I,lineNumber:m,pageBorder:P,badge:E,modeRule:D,graffiti:M,label:F,imgCaption:y,list:Y,performance:{enabled:!1,threshold:16,...o.performance}}}const Ks=new Map,ac=[s.ControlType.NUMBER,s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.CHECKBOX,s.ControlType.RADIO];function Ze(o,t){return o&&ac.includes(o)?[""]:yt(t)}function cc(o){return Ks.get(o)}function Po(o,t){Ks.set(o,t)}function Li(o){const t=[];for(let e=0;e<o.length;e++){const n=o[e],i=yt(n.value);for(let l=0;l<i.length;l++)t.push({...n,value:i[l]})}return t}const Hs=new Set([s.ControlComponent.PREFIX,s.ControlComponent.POSTFIX,s.ControlComponent.PRE_TEXT,s.ControlComponent.POST_TEXT,s.ControlComponent.PRETEXTFIX,s.ControlComponent.PRETEXTFIX_TEXT,s.ControlComponent.POSTTEXTFIX,s.ControlComponent.POSTTEXTFIX_TEXT,s.ControlComponent.PLACEHOLDER,s.ControlComponent.TEXTFIXLABEL,s.ControlComponent.CHECKBOX,s.ControlComponent.RADIO,s.ControlComponent.UNDERLINE]),dc=["请选择","双击获取日期","格式化日期时间"];function uc(o){return(o||[]).map(t=>t.value===K?`
62
+ `:t.value||"").join("")}function _s(o){return uc(o.value)}function As(o){return o.placeholder||o.buttonLabel||o.label||""}function bn(){return{color:"#1677FF",highlight:void 0}}function Eo(o){return{color:o,highlight:void 0}}function ks(o){return o===s.EditorMode.READONLY}function Rc(o){const t=[];return o.filter(Boolean).forEach(e=>{t.push(e,`获取${e}`,`获取 ${e}`,`请选择${e}`,`请选择 ${e}`,`请输入${e}`,`请输入 ${e}`)}),t}function Qe(o,t=[]){if(!o)return"";const e=o.replace(new RegExp(`${K}`,"g"),`
63
+ `),n=e.trim();return n?[...dc,...Rc(t)].includes(n)?"":e:""}function Pi(o,t){const e=Qe(o,[t?.label||""]);if(!e)return[];const n=t?$t(t,[...ue,"font","size","bold","italic","underline","strikeout","rowFlex","rowMargin","textDecoration","deletePerson","newElEditPerson","deleteTime","newElEditTime","color"]):{};return yt(e).map(i=>({...n,type:s.ElementType.TEXT,value:i===`
64
+ `?K:i}))}function Mo(o){const t=(o.code||"").split(",").map(n=>n.trim()).filter(Boolean);if(!t.length||!o.valueSets?.length)return"";const e=o.multiSelectDelimiter||",";return t.map(n=>o.valueSets?.find(i=>i.code===n)?.value).filter(n=>!!n).join(e)}function Gs(o){return o.type===s.ElementType.REUSABLE_ITEM?Qe(o.reusableItemConfig?.value||"",[o.label||""]):o.type===s.ElementType.CUSTOM_MACRO?Qe(o.macroConfig?.value||o.value||"",[o.label||""]):o.type===s.ElementType.MACRO?Qe(o.value||"",[o.label||""]):""}function hc(o){const t=o.control;if(!t)return[];const e=[t.placeholder||"",t.label||""];if(t.type===s.ControlType.CHECKBOX||t.type===s.ControlType.RADIO){const r=Qe(Mo(t),e);if(r)return Pi(r,o)}const i=Dn(t.value||[]);return Qe(So(i),e)?i:t.type===s.ControlType.SELECT?Pi(Qe(Mo(t),e),o):[]}function gc(o){if(!o)return"";const t=[o.placeholder||"",o.label||""];if(o.type===s.ControlType.CHECKBOX||o.type===s.ControlType.RADIO){const i=Qe(Mo(o),t);if(i)return i}const n=Qe(So(o.value||[]),t);return n||(o.type===s.ControlType.SELECT?Qe(Mo(o),t):"")}function Oo(o){return ae(o)||o.controlComponent&&Hs.has(o.controlComponent)?"":o.type===s.ElementType.CONTROL?gc(o.control):o.type===s.ElementType.MACRO||o.type===s.ElementType.CUSTOM_MACRO||o.type===s.ElementType.REUSABLE_ITEM?Gs(o):o.type===s.ElementType.TABLE?o.trList?.map(t=>t.tdList.map(e=>So(e.value||[])).join(" ")).join(`
65
65
  `)||"":o.type===s.ElementType.TAB?" ":o.valueList?.length?So(o.valueList):o.value||""}function So(o){return o.map(t=>Oo(t)).join("")}function Tc(o){const t=o.menstrualData;if(!t)return"~";const{periodMin:e,periodMax:n,menarcheAge:i,isMenopause:l,menopauseAge:r,lastPeriod:a,cycleMin:c,cycleMax:d}=t,u=e||n?`${e||""}~${n||""}`:"~",R=c||d?`${c||""}~${d||""}`:"~",h=[i?`${i}岁`:"",l?r?`${r}岁`:"":a||""].filter(Boolean);return[u,...h,R].filter(Boolean).join(" ")}function xs(o){return(o||"").replace(new RegExp(`${K}`,"g"),`
66
66
  `)}function Ei(o){let t="";for(let e=0;e<o.length;e++){const n=o[e];if(!ae(n))if(n.type===s.ElementType.TABLE){t&&!t.endsWith(`
67
67
  `)&&(t+=`
68
68
  `);const i=n.trList||[];for(let l=0;l<i.length;l++){const r=i[l];for(let a=0;a<r.tdList.length;a++){const c=r.tdList[a],d=Ei(c.value||[]),u=a===0,R=r.tdList.length-1===a;t+=`${u?"":" "}${d}${R?`
69
69
  `:""}`}}}else n.type===s.ElementType.TAB?t+=" ":n.type===s.ElementType.CHECKBOX?t+=n.checkbox?.value?"☑":"□":n.type===s.ElementType.RADIO?t+=n.radio?.value?"☉":"○":n.type===s.ElementType.MENSTRUAL_HISTORY?t+=Tc(n):n.type===s.ElementType.MACRO||n.type===s.ElementType.CUSTOM_MACRO||n.type===s.ElementType.REUSABLE_ITEM?t+=xs(Oo(n)):n.valueList?.length?t+=Ei(n.valueList):t+=xs(n.value)}return t}function Dn(o=[]){const t=[];return o.forEach(e=>{if(ae(e)||e.controlComponent&&Hs.has(e.controlComponent))return;if(e.type===s.ElementType.TABLE){const i=ct(e);i.trList?.forEach(l=>{l.tdList.forEach(r=>{r.value=Dn(r.value||[])})}),t.push(i);return}if(e.type===s.ElementType.CONTROL&&e.control){t.push(...hc(e));return}if(e.type===s.ElementType.MACRO||e.type===s.ElementType.CUSTOM_MACRO||e.type===s.ElementType.REUSABLE_ITEM){t.push(...Pi(Gs(e),e));return}if(e.valueList?.length){const i=ct(e);i.valueList=Dn(e.valueList),t.push(i);return}const n=ct(e);delete n.control,delete n.controlId,delete n.originControlId,delete n.controlComponent,n.type===s.ElementType.CONTROL&&(n.type=s.ElementType.TEXT),(n.value===`
70
70
  `||n.value===`\r
71
- `)&&(n.value=K),t.push(n)}),t}function jt(o,t){const{isHandleFirstElement:e=!0,isForceCompensation:n=!1,editorOptions:i}=t,l=o[0];(n||e&&l?.type!==s.ElementType.LIST&&(l?.type&&l.type!==s.ElementType.TEXT||!ri.test(l?.value)))&&o.unshift({value:K});let r=0;for(;r<o.length;){let a=o[r];if(a.type===s.ElementType.TITLE){o.splice(r,1);const c=a.valueList||[];if(jt(c,{...t,isHandleFirstElement:!1,isForceCompensation:!1}),c.length){const d=a.titleId||ft(),u=i.title;for(let R=0;R<c.length;R++){const h=c[R];h.title=a.title,a.level&&(h.titleId=d,h.level=a.level),Xo(h)&&(h.size||(h.size=u[Zs[h.level]]),h.bold===void 0&&(h.bold=!0)),o.splice(r,0,h),r++}}r--}else if(a.type===s.ElementType.LIST){o.splice(r,1);const c=a.valueList||[];if(jt(c,{...t,isHandleFirstElement:!0,isForceCompensation:!1}),c.length){const d=ft();for(let u=0;u<c.length;u++){const R=c[u];R.listId=d,R.listType=a.listType,R.listStyle=a.listStyle,o.splice(r,0,R),r++}}r--}else if(a.type===s.ElementType.AREA){o.splice(r,1);const c=a?.valueList||[];if(jt(c,{...t,isHandleFirstElement:!0,isForceCompensation:!0}),c.length){const d=ft();for(let u=0;u<c.length;u++){const R=c[u];if(R.areaId=a.areaId||d,R.area=a.area,R.areaIndex=u,R.type===s.ElementType.TABLE){const h=R.trList;for(let g=0;g<h.length;g++){const T=h[g];for(let f=0;f<T.tdList.length;f++){const C=T.tdList[f].value;for(let I=0;I<C.length;I++){const m=C[I];m.areaId=a.areaId||d,m.area=a.area}}}}o.splice(r,0,R),r++}}r--}else if(a.type===s.ElementType.TABLE){const c=a.id||ft();if(a.id=c,a.trList){const{defaultTrMinHeight:d}=i.table;for(let u=0;u<a.trList.length;u++){const R=a.trList[u],h=R.id||ft();R.id=h,(!R.minHeight||R.minHeight<d)&&(R.minHeight=d),R.height<R.minHeight&&(R.height=R.minHeight);for(let g=0;g<R.tdList.length;g++){const T=R.tdList[g],f=T.id||ft();T.id=f,jt(T.value,{...t,isHandleFirstElement:!0,isForceCompensation:!0}),!T.value[0].size&&T.value[1]?.size&&Xo(T.value[1])&&(T.value[0].size=T.value[1].size);for(let p=0;p<T.value.length;p++){const C=T.value[p];C.tdId=f,C.trId=h,C.tableId=c}}}}}else if(a.type===s.ElementType.HYPERLINK){o.splice(r,1);const c=Li(a.valueList||[]);if(c.length){const d=ft();for(let u=0;u<c.length;u++){const R=c[u];R.type=a.type,R.url=a.url,R.hyperlinkId=d,o.splice(r,0,R),r++}}r--}else if(a.type===s.ElementType.DATE){o.splice(r,1);const c=Li(a.valueList||[]);if(c.length){const d=ft();for(let u=0;u<c.length;u++){const R=c[u];R.type=a.type,R.dateFormat=a.dateFormat,R.dateId=d,o.splice(r,0,R),r++}}r--}else if(a.type===s.ElementType.CONTROL){if(!a.control){r++;continue}if(a.control.type=="TextField"){const{preTextFix:c,postTextFix:d,preTextFixText:u,postTextFixText:R,value:h,placeholder:g,code:T,type:f,valueSets:p}=a.control,C=f,{editorOptions:{control:I,checkbox:m,radio:P}}=t,E=a.controlId||ft();o.splice(r,1);const M=$t(a,[...Ti,...ue]),F=$t(a.control,Re),y={...F,color:i.control.textFixColor,fontWeight:"blod"},Y={...F,color:void 0},D=yt(c||I.preTextFix);for(let b=0;b<D.length;b++){const V=D[b];o.splice(r,0,{...M,...y,controlId:E,value:V,type:a.type,control:a.control,controlComponent:s.ControlComponent.PRETEXTFIX}),r++}if(u){const b=yt(u);for(let V=0;V<b.length;V++){const X=b[V];o.splice(r,0,{...M,...F,controlId:E,value:X,type:a.type,control:a.control,controlComponent:s.ControlComponent.PRETEXTFIX_TEXT}),r++}}if(h&&h.length||C===s.ControlType.CHECKBOX||C===s.ControlType.RADIO||C===s.ControlType.SELECT&&T&&(!h||!h.length)){let b=h?ct(h):[];if(C===s.ControlType.CHECKBOX){const V=T?T.split(","):[];if(Array.isArray(p)&&p.length){const X=b.reduce((L,W)=>L.concat(W.value.split("").map(S=>({...W,value:S}))),[]);let N=0;for(let L=0;L<p.length;L++){const W=p[L];o.splice(r,0,{...M,...F,controlId:E,value:"",type:a.type,control:a.control,controlComponent:s.ControlComponent.CHECKBOX,checkbox:{code:W.code,value:V.includes(W.code)}}),r++;const S=yt(W.value);for(let U=0;U<S.length;U++){const v=S[U],Q=U===S.length-1;o.splice(r,0,{...M,...Y,...X[N],controlId:E,value:v===`
72
- `?K:v,letterSpacing:Q?m.gap:0,control:a.control,controlComponent:s.ControlComponent.VALUE}),N++,r++}}}}else if(C===s.ControlType.RADIO){if(Array.isArray(p)&&p.length){const V=b.reduce((N,L)=>N.concat(L.value.split("").map(W=>({...L,value:W}))),[]);let X=0;for(let N=0;N<p.length;N++){const L=p[N];o.splice(r,0,{...M,...F,controlId:E,value:"",type:a.type,control:a.control,controlComponent:s.ControlComponent.RADIO,radio:{code:L.code,value:T===L.code}}),r++;const W=yt(L.value);for(let S=0;S<W.length;S++){const U=W[S],v=S===W.length-1;o.splice(r,0,{...M,...Y,...V[X],controlId:E,value:U===`
73
- `?K:U,letterSpacing:v?P.gap:0,control:a.control,controlComponent:s.ControlComponent.VALUE}),X++,r++}}}}else{if((!h||!h.length)&&Array.isArray(p)&&p.length){const V=T?T.split(",").map(X=>X.trim()).filter(X=>X):[];if(V.length>1){const X=[];for(const N of V){const L=p.find(W=>W.code===N);L&&X.push({value:L.value})}X.length>0&&(b=X)}else if(V.length===1){const X=p.find(N=>N.code===V[0]);X&&(b=[{value:X.value}])}}for(let V=0;V<b.length;V++){const X=b[V];if(X.type===s.ElementType.CONTROL&&X.control){const N=X,L=N.controlId||ft(),W=N.control?.value||[],S=N.control?.placeholder||"",U=N.control?.type,v=U===s.ControlType.TEXTFIELD,Q=U===s.ControlType.TEXT,w=U===s.ControlType.CHECKBOX,q=U===s.ControlType.RADIO,G=U===s.ControlType.BUTTON,H=v?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,z=v?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,_={...M,controlId:L,type:s.ElementType.CONTROL,control:N.control},dt=v?i.control.textFixColor:Q?"#87d068":G?bn().color:i.control.bracketColor,Ct=G?bn().highlight:void 0,Kt=v?N.control?.preTextFix||I.preTextFix:N.control?.prefix||I.prefix,ge=Ze(U,Kt);for(let lt=0;lt<ge.length;lt++)o.splice(r,0,{..._,color:dt,highlight:Ct,originControlId:E,value:ge[lt],controlComponent:H}),r++;if(G){const lt=_s(N.control);if(lt){const $=yt(lt),j=Eo(i.defaultColor);for(let tt=0;tt<$.length;tt++){const x=$[tt];o.splice(r,0,{..._,...j,originControlId:E,value:x===`
71
+ `)&&(n.value=K),t.push(n)}),t}function jt(o,t){const{isHandleFirstElement:e=!0,isForceCompensation:n=!1,editorOptions:i}=t,l=o[0];(n||e&&l?.type!==s.ElementType.LIST&&(l?.type&&l.type!==s.ElementType.TEXT||!ri.test(l?.value)))&&o.unshift({value:K});let r=0;for(;r<o.length;){let a=o[r];if(a.type===s.ElementType.TITLE){o.splice(r,1);const c=a.valueList||[];if(jt(c,{...t,isHandleFirstElement:!1,isForceCompensation:!1}),c.length){const d=a.titleId||ft(),u=i.title;for(let R=0;R<c.length;R++){const h=c[R];h.title=a.title,a.level&&(h.titleId=d,h.level=a.level),Xo(h)&&(h.size||(h.size=u[Zs[h.level]]),h.bold===void 0&&(h.bold=!0)),o.splice(r,0,h),r++}}r--}else if(a.type===s.ElementType.LIST){o.splice(r,1);const c=a.valueList||[];if(jt(c,{...t,isHandleFirstElement:!0,isForceCompensation:!1}),c.length){const d=ft();for(let u=0;u<c.length;u++){const R=c[u];R.listId=d,R.listType=a.listType,R.listStyle=a.listStyle,o.splice(r,0,R),r++}}r--}else if(a.type===s.ElementType.AREA){o.splice(r,1);const c=a?.valueList||[];if(jt(c,{...t,isHandleFirstElement:!0,isForceCompensation:!0}),c.length){const d=ft();for(let u=0;u<c.length;u++){const R=c[u];if(R.areaId=a.areaId||d,R.area=a.area,R.areaIndex=u,R.type===s.ElementType.TABLE){const h=R.trList;for(let g=0;g<h.length;g++){const T=h[g];for(let f=0;f<T.tdList.length;f++){const C=T.tdList[f].value;for(let I=0;I<C.length;I++){const m=C[I];m.areaId=a.areaId||d,m.area=a.area}}}}o.splice(r,0,R),r++}}r--}else if(a.type===s.ElementType.TABLE){const c=a.id||ft();if(a.id=c,a.trList){const{defaultTrMinHeight:d}=i.table;for(let u=0;u<a.trList.length;u++){const R=a.trList[u],h=R.id||ft();R.id=h,(!R.minHeight||R.minHeight<d)&&(R.minHeight=d),R.height<R.minHeight&&(R.height=R.minHeight);for(let g=0;g<R.tdList.length;g++){const T=R.tdList[g],f=T.id||ft();T.id=f,jt(T.value,{...t,isHandleFirstElement:!0,isForceCompensation:!0}),!T.value[0].size&&T.value[1]?.size&&Xo(T.value[1])&&(T.value[0].size=T.value[1].size);for(let p=0;p<T.value.length;p++){const C=T.value[p];C.tdId=f,C.trId=h,C.tableId=c}}}}}else if(a.type===s.ElementType.HYPERLINK){o.splice(r,1);const c=Li(a.valueList||[]);if(c.length){const d=ft();for(let u=0;u<c.length;u++){const R=c[u];R.type=a.type,R.url=a.url,R.hyperlinkId=d,o.splice(r,0,R),r++}}r--}else if(a.type===s.ElementType.DATE){o.splice(r,1);const c=Li(a.valueList||[]);if(c.length){const d=ft();for(let u=0;u<c.length;u++){const R=c[u];R.type=a.type,R.dateFormat=a.dateFormat,R.dateId=d,o.splice(r,0,R),r++}}r--}else if(a.type===s.ElementType.CONTROL){if(!a.control){r++;continue}if(a.control.type=="TextField"){const{preTextFix:c,postTextFix:d,preTextFixText:u,postTextFixText:R,value:h,placeholder:g,code:T,type:f,valueSets:p}=a.control,C=f,{editorOptions:{control:I,checkbox:m,radio:P}}=t,E=a.controlId||ft();o.splice(r,1);const M=$t(a,[...Ti,...ue]),F=$t(a.control,Re),y={...F,color:i.control.textFixColor,fontWeight:"blod"},Y={...F,color:void 0},D=yt(c||I.preTextFix);for(let b=0;b<D.length;b++){const V=D[b];o.splice(r,0,{...M,...y,controlId:E,value:V,type:a.type,control:a.control,controlComponent:s.ControlComponent.PRETEXTFIX}),r++}if(u){const b=yt(u);for(let V=0;V<b.length;V++){const X=b[V];o.splice(r,0,{...M,...F,controlId:E,value:X,type:a.type,control:a.control,controlComponent:s.ControlComponent.PRETEXTFIX_TEXT}),r++}}if(h&&h.length||C===s.ControlType.CHECKBOX||C===s.ControlType.RADIO||C===s.ControlType.SELECT&&T&&(!h||!h.length)){let b=h?ct(h):[];if(C===s.ControlType.CHECKBOX){const V=T?T.split(","):[];if(Array.isArray(p)&&p.length){const X=b.reduce((L,W)=>L.concat(W.value.split("").map(S=>({...W,value:S}))),[]);let N=0;for(let L=0;L<p.length;L++){const W=p[L];o.splice(r,0,{...M,...F,controlId:E,value:"",type:a.type,control:a.control,controlComponent:s.ControlComponent.CHECKBOX,checkbox:{code:W.code,value:V.includes(W.code)}}),r++;const S=yt(W.value);for(let U=0;U<S.length;U++){const Q=S[U],v=U===S.length-1;o.splice(r,0,{...M,...Y,...X[N],controlId:E,value:Q===`
72
+ `?K:Q,letterSpacing:v?m.gap:0,control:a.control,controlComponent:s.ControlComponent.VALUE}),N++,r++}}}}else if(C===s.ControlType.RADIO){if(Array.isArray(p)&&p.length){const V=b.reduce((N,L)=>N.concat(L.value.split("").map(W=>({...L,value:W}))),[]);let X=0;for(let N=0;N<p.length;N++){const L=p[N];o.splice(r,0,{...M,...F,controlId:E,value:"",type:a.type,control:a.control,controlComponent:s.ControlComponent.RADIO,radio:{code:L.code,value:T===L.code}}),r++;const W=yt(L.value);for(let S=0;S<W.length;S++){const U=W[S],Q=S===W.length-1;o.splice(r,0,{...M,...Y,...V[X],controlId:E,value:U===`
73
+ `?K:U,letterSpacing:Q?P.gap:0,control:a.control,controlComponent:s.ControlComponent.VALUE}),X++,r++}}}}else{if((!h||!h.length)&&Array.isArray(p)&&p.length){const V=T?T.split(",").map(X=>X.trim()).filter(X=>X):[];if(V.length>1){const X=[];for(const N of V){const L=p.find(W=>W.code===N);L&&X.push({value:L.value})}X.length>0&&(b=X)}else if(V.length===1){const X=p.find(N=>N.code===V[0]);X&&(b=[{value:X.value}])}}for(let V=0;V<b.length;V++){const X=b[V];if(X.type===s.ElementType.CONTROL&&X.control){const N=X,L=N.controlId||ft(),W=N.control?.value||[],S=N.control?.placeholder||"",U=N.control?.type,Q=U===s.ControlType.TEXTFIELD,v=U===s.ControlType.TEXT,w=U===s.ControlType.CHECKBOX,q=U===s.ControlType.RADIO,G=U===s.ControlType.BUTTON,H=Q?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,z=Q?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,_={...M,controlId:L,type:s.ElementType.CONTROL,control:N.control},dt=Q?i.control.textFixColor:v?"#87d068":G?bn().color:i.control.bracketColor,Ct=G?bn().highlight:void 0,Kt=Q?N.control?.preTextFix||I.preTextFix:N.control?.prefix||I.prefix,ge=Ze(U,Kt);for(let lt=0;lt<ge.length;lt++)o.splice(r,0,{..._,color:dt,highlight:Ct,originControlId:E,value:ge[lt],controlComponent:H}),r++;if(G){const lt=_s(N.control);if(lt){const $=yt(lt),j=Eo(i.defaultColor);for(let tt=0;tt<$.length;tt++){const x=$[tt];o.splice(r,0,{..._,...j,originControlId:E,value:x===`
74
74
  `?K:x,controlComponent:s.ControlComponent.VALUE}),r++}}else{const $=As(N.control),j=yt($);for(let tt=0;tt<j.length;tt++){const x=j[tt];o.splice(r,0,{..._,color:i.control.placeholderColor,originControlId:E,value:x===`
75
75
  `?K:x,controlComponent:s.ControlComponent.PLACEHOLDER}),r++}}}else if(w){const lt=N.control?.valueSets||[],$=N.control?.code||"",j=$?$.split(","):[];for(let tt=0;tt<lt.length;tt++){const x=lt[tt];o.splice(r,0,{..._,originControlId:E,value:"",controlComponent:s.ControlComponent.CHECKBOX,checkbox:{code:x.code,value:j.includes(x.code)}}),r++;const Rt=yt(x.value||"");for(let ht=0;ht<Rt.length;ht++){const mt=Rt[ht],Pt=ht===Rt.length-1;o.splice(r,0,{..._,...Y,originControlId:E,value:mt===`
76
76
  `?K:mt,letterSpacing:Pt?m.gap:0,controlComponent:s.ControlComponent.VALUE}),r++}}}else if(q){const lt=N.control?.valueSets||[],$=N.control?.code||"";for(let j=0;j<lt.length;j++){const tt=lt[j];o.splice(r,0,{..._,originControlId:E,value:"",controlComponent:s.ControlComponent.RADIO,radio:{code:tt.code,value:$===tt.code}}),r++;const x=yt(tt.value||"");for(let Rt=0;Rt<x.length;Rt++){const ht=x[Rt],mt=Rt===x.length-1;o.splice(r,0,{..._,...Y,originControlId:E,value:ht===`
77
- `?K:ht,letterSpacing:mt?P.gap:0,controlComponent:s.ControlComponent.VALUE}),r++}}}else if(W.length>0)for(let lt=0;lt<W.length;lt++){const $=W[lt];if($.type===s.ElementType.CONTROL&&$.control){const j=$,tt=j.controlId||ft(),x=j.control?.value||[],Rt=j.control?.type,ht=Rt===s.ControlType.TEXTFIELD,mt=Rt===s.ControlType.TEXT,Pt={..._,controlId:tt,control:j.control},vt=ht?i.control.textFixColor:mt?"#87d068":i.control.bracketColor,Lt=ht?j.control?.preTextFix||I.preTextFix:j.control?.prefix||I.prefix,At=Ze(Rt,Lt);for(let Yt=0;Yt<At.length;Yt++)o.splice(r,0,{...Pt,color:vt,originControlId:L,value:At[Yt],controlComponent:ht?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX}),r++;for(let Yt=0;Yt<x.length;Yt++){const Xt=x[Yt];if(Xt.type===s.ElementType.MENSTRUAL_HISTORY||Xt.type===s.ElementType.FETAL_HEART_POSITION||Xt.type===s.ElementType.TOOTH_POSITION||Xt.type===s.ElementType.MACRO||Xt.type===s.ElementType.CUSTOM_MACRO||Xt.type===s.ElementType.REUSABLE_ITEM||Xt.type===s.ElementType.LIST||Xt.type===s.ElementType.SPECIAL_SYMBOLS){const Ft=Xt.id||ft();Xt.id||(Xt.id=Ft);const Et=j.control?.value?.find(Mt=>Mt.id===Ft||Mt.type===Xt.type&&Mt.value===Xt.value);Et&&Po(Ft,Et),o.splice(r,0,{...Pt,...Xt,id:Ft,originControlId:L,controlComponent:s.ControlComponent.VALUE,type:Xt.type})}else o.splice(r,0,{...Pt,...Y,...Xt,originControlId:L,value:Xt.value===`
78
- `?K:Xt.value,controlComponent:s.ControlComponent.VALUE});r++}if(x.length===0){const Yt=j.control?.placeholder||"";if(Yt){const Xt=yt(Yt);for(let bt=0;bt<Xt.length;bt++)o.splice(r,0,{...Pt,color:i.control.placeholderColor,originControlId:L,value:Xt[bt],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}}const ee=ht?j.control?.postTextFix||I.postTextFix:j.control?.postfix||I.postfix,ne=Ze(Rt,ee);for(let Yt=0;Yt<ne.length;Yt++)o.splice(r,0,{...Pt,color:vt,originControlId:L,value:ne[Yt],controlComponent:ht?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX}),r++}else{if($.type===s.ElementType.MENSTRUAL_HISTORY||$.type===s.ElementType.FETAL_HEART_POSITION||$.type===s.ElementType.TOOTH_POSITION||$.type===s.ElementType.MACRO||$.type===s.ElementType.CUSTOM_MACRO||$.type===s.ElementType.REUSABLE_ITEM||$.type===s.ElementType.LIST||$.type===s.ElementType.SPECIAL_SYMBOLS){const tt=$.id||ft();$.id||($.id=tt);const x=N.control?.value?.find(Rt=>Rt.id===tt||Rt.type===$.type&&Rt.value===$.value);x&&Po(tt,x),o.splice(r,0,{..._,...$,id:tt,originControlId:E,controlComponent:s.ControlComponent.VALUE,type:$.type})}else o.splice(r,0,{..._,...Y,...$,originControlId:E,value:$.value===`
79
- `?K:$.value,controlComponent:s.ControlComponent.VALUE});r++}}else if(S){const lt=yt(S);for(let $=0;$<lt.length;$++)o.splice(r,0,{..._,color:i.control.placeholderColor,originControlId:E,value:lt[$],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}else if((U===s.ControlType.SELECT||U===s.ControlType.DATE||U===s.ControlType.NUMBER)&&!N.control?.code&&S){const $=yt(S);for(let j=0;j<$.length;j++)o.splice(r,0,{..._,color:i.control.placeholderColor,originControlId:E,value:$[j],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}const se=v?N.control?.postTextFix||I.postTextFix:N.control?.postfix||I.postfix,J=Ze(U,se);for(let lt=0;lt<J.length;lt++)o.splice(r,0,{..._,color:dt,highlight:Ct,originControlId:E,value:J[lt],controlComponent:z}),r++}else if(X.type===s.ElementType.MENSTRUAL_HISTORY||X.type===s.ElementType.FETAL_HEART_POSITION||X.type===s.ElementType.TOOTH_POSITION||X.type===s.ElementType.MACRO||X.type===s.ElementType.CUSTOM_MACRO||X.type===s.ElementType.REUSABLE_ITEM||X.type===s.ElementType.LIST||X.type===s.ElementType.SPECIAL_SYMBOLS){const N=X.id||ft();X.id||(X.id=N);const L=h?.find(W=>W.id===N||W.type===X.type&&W.value===X.value);L&&Po(N,L),o.splice(r,0,{...M,...X,id:N,controlId:E,control:a.control,controlComponent:s.ControlComponent.VALUE,type:X.type}),r++}else{const N=yt(X.value||"");for(let L=0;L<N.length;L++){const W=N[L];o.splice(r,0,{...M,...Y,...C===s.ControlType.BUTTON?Eo(i.defaultColor):{},...X,controlId:E,value:W===`
77
+ `?K:ht,letterSpacing:mt?P.gap:0,controlComponent:s.ControlComponent.VALUE}),r++}}}else if(W.length>0)for(let lt=0;lt<W.length;lt++){const $=W[lt];if($.type===s.ElementType.CONTROL&&$.control){const j=$,tt=j.controlId||ft(),x=j.control?.value||[],Rt=j.control?.type,ht=Rt===s.ControlType.TEXTFIELD,mt=Rt===s.ControlType.TEXT,Pt={..._,controlId:tt,control:j.control},Qt=ht?i.control.textFixColor:mt?"#87d068":i.control.bracketColor,Lt=ht?j.control?.preTextFix||I.preTextFix:j.control?.prefix||I.prefix,At=Ze(Rt,Lt);for(let Yt=0;Yt<At.length;Yt++)o.splice(r,0,{...Pt,color:Qt,originControlId:L,value:At[Yt],controlComponent:ht?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX}),r++;for(let Yt=0;Yt<x.length;Yt++){const Xt=x[Yt];if(Xt.type===s.ElementType.MENSTRUAL_HISTORY||Xt.type===s.ElementType.FETAL_HEART_POSITION||Xt.type===s.ElementType.TOOTH_POSITION||Xt.type===s.ElementType.MACRO||Xt.type===s.ElementType.CUSTOM_MACRO||Xt.type===s.ElementType.REUSABLE_ITEM||Xt.type===s.ElementType.LIST||Xt.type===s.ElementType.SPECIAL_SYMBOLS){const Ft=Xt.id||ft();Xt.id||(Xt.id=Ft);const Et=j.control?.value?.find(Mt=>Mt.id===Ft||Mt.type===Xt.type&&Mt.value===Xt.value);Et&&Po(Ft,Et),o.splice(r,0,{...Pt,...Xt,id:Ft,originControlId:L,controlComponent:s.ControlComponent.VALUE,type:Xt.type})}else o.splice(r,0,{...Pt,...Y,...Xt,originControlId:L,value:Xt.value===`
78
+ `?K:Xt.value,controlComponent:s.ControlComponent.VALUE});r++}if(x.length===0){const Yt=j.control?.placeholder||"";if(Yt){const Xt=yt(Yt);for(let bt=0;bt<Xt.length;bt++)o.splice(r,0,{...Pt,color:i.control.placeholderColor,originControlId:L,value:Xt[bt],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}}const ee=ht?j.control?.postTextFix||I.postTextFix:j.control?.postfix||I.postfix,ne=Ze(Rt,ee);for(let Yt=0;Yt<ne.length;Yt++)o.splice(r,0,{...Pt,color:Qt,originControlId:L,value:ne[Yt],controlComponent:ht?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX}),r++}else{if($.type===s.ElementType.MENSTRUAL_HISTORY||$.type===s.ElementType.FETAL_HEART_POSITION||$.type===s.ElementType.TOOTH_POSITION||$.type===s.ElementType.MACRO||$.type===s.ElementType.CUSTOM_MACRO||$.type===s.ElementType.REUSABLE_ITEM||$.type===s.ElementType.LIST||$.type===s.ElementType.SPECIAL_SYMBOLS){const tt=$.id||ft();$.id||($.id=tt);const x=N.control?.value?.find(Rt=>Rt.id===tt||Rt.type===$.type&&Rt.value===$.value);x&&Po(tt,x),o.splice(r,0,{..._,...$,id:tt,originControlId:E,controlComponent:s.ControlComponent.VALUE,type:$.type})}else o.splice(r,0,{..._,...Y,...$,originControlId:E,value:$.value===`
79
+ `?K:$.value,controlComponent:s.ControlComponent.VALUE});r++}}else if(S){const lt=yt(S);for(let $=0;$<lt.length;$++)o.splice(r,0,{..._,color:i.control.placeholderColor,originControlId:E,value:lt[$],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}else if((U===s.ControlType.SELECT||U===s.ControlType.DATE||U===s.ControlType.NUMBER)&&!N.control?.code&&S){const $=yt(S);for(let j=0;j<$.length;j++)o.splice(r,0,{..._,color:i.control.placeholderColor,originControlId:E,value:$[j],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}const se=Q?N.control?.postTextFix||I.postTextFix:N.control?.postfix||I.postfix,J=Ze(U,se);for(let lt=0;lt<J.length;lt++)o.splice(r,0,{..._,color:dt,highlight:Ct,originControlId:E,value:J[lt],controlComponent:z}),r++}else if(X.type===s.ElementType.MENSTRUAL_HISTORY||X.type===s.ElementType.FETAL_HEART_POSITION||X.type===s.ElementType.TOOTH_POSITION||X.type===s.ElementType.MACRO||X.type===s.ElementType.CUSTOM_MACRO||X.type===s.ElementType.REUSABLE_ITEM||X.type===s.ElementType.LIST||X.type===s.ElementType.SPECIAL_SYMBOLS){const N=X.id||ft();X.id||(X.id=N);const L=h?.find(W=>W.id===N||W.type===X.type&&W.value===X.value);L&&Po(N,L),o.splice(r,0,{...M,...X,id:N,controlId:E,control:a.control,controlComponent:s.ControlComponent.VALUE,type:X.type}),r++}else{const N=yt(X.value||"");for(let L=0;L<N.length;L++){const W=N[L];o.splice(r,0,{...M,...Y,...C===s.ControlType.BUTTON?Eo(i.defaultColor):{},...X,controlId:E,value:W===`
80
80
  `?K:W,type:C===s.ControlType.BUTTON?s.ElementType.CONTROL:X.type||s.ElementType.TEXT,control:a.control,controlComponent:s.ControlComponent.VALUE}),r++}}}}}else if(g){const b={...F,color:i.control.placeholderColor},V=yt(g);for(let X=0;X<V.length;X++){const N=V[X];o.splice(r,0,{...M,...b,controlId:E,value:N===`
81
81
  `?K:N,type:a.type,control:a.control,controlComponent:s.ControlComponent.PLACEHOLDER}),r++}}if(R){const b=yt(R);for(let V=0;V<b.length;V++){const X=b[V];o.splice(r,0,{...M,...F,controlId:E,value:X,type:a.type,control:a.control,controlComponent:s.ControlComponent.POSTTEXTFIX_TEXT}),r++}}const O=yt(d||I.postTextFix);for(let b=0;b<O.length;b++){const V=O[b];o.splice(r,0,{...M,...y,controlId:E,value:V,type:a.type,control:a.control,controlComponent:s.ControlComponent.POSTTEXTFIX}),r++}r--}else{const{prefix:c,postfix:d,preText:u,postText:R,value:h,placeholder:g,label:T,buttonLabel:f,code:p,type:C,valueSets:I}=a.control,{editorOptions:{control:m,checkbox:P,radio:E}}=t,M=a.controlId||ft();o.splice(r,1);const F=$t(a,[...Ti,...ue]),y=$t(a.control,Re),Y={...y,color:C===s.ControlType.TEXT?"#87d068":C===s.ControlType.BUTTON?bn().color:i.control.bracketColor,highlight:C===s.ControlType.BUTTON?bn().highlight:void 0},D={...y,color:void 0},O=C===s.ControlType.BUTTON?g||f||T||"":g,b=Ze(C,c||m.prefix);for(let X=0;X<b.length;X++){const N=b[X];o.splice(r,0,{...F,...Y,controlId:M,value:N===`
82
- `?K:N,type:a.type,control:a.control,controlComponent:s.ControlComponent.PREFIX}),r++}if(u){const X=yt(u);for(let N=0;N<X.length;N++){const L=X[N];o.splice(r,0,{...F,...y,controlId:M,value:L,type:a.type,control:a.control,controlComponent:s.ControlComponent.PRE_TEXT}),r++}}if(h&&h.length||C===s.ControlType.CHECKBOX||C===s.ControlType.RADIO||C===s.ControlType.SELECT&&p&&(!h||!h.length)){let X=h?ct(h):[];if(C===s.ControlType.CHECKBOX){const N=p?p.split(","):[];if(Array.isArray(I)&&I.length){const L=X.reduce((S,U)=>S.concat(U.value.split("").map(v=>({...U,value:v}))),[]);let W=0;for(let S=0;S<I.length;S++){const U=I[S];o.splice(r,0,{...F,...y,controlId:M,value:"",type:a.type,control:a.control,controlComponent:s.ControlComponent.CHECKBOX,checkbox:{code:U.code,value:N.includes(U.code)}}),r++;const v=yt(U.value);for(let Q=0;Q<v.length;Q++){const w=v[Q],q=Q===v.length-1;o.splice(r,0,{...F,...D,...L[W],controlId:M,value:w===`
83
- `?K:w,letterSpacing:q?P.gap:0,control:a.control,controlComponent:s.ControlComponent.VALUE}),W++,r++}}}}else if(C===s.ControlType.RADIO){if(Array.isArray(I)&&I.length){const N=X.reduce((W,S)=>W.concat(S.value.split("").map(U=>({...S,value:U}))),[]);let L=0;for(let W=0;W<I.length;W++){const S=I[W];o.splice(r,0,{...F,...y,controlId:M,value:"",type:a.type,control:a.control,controlComponent:s.ControlComponent.RADIO,radio:{code:S.code,value:p===S.code}}),r++;const U=yt(S.value);for(let v=0;v<U.length;v++){const Q=U[v],w=v===U.length-1;o.splice(r,0,{...F,...D,...N[L],controlId:M,value:Q===`
84
- `?K:Q,letterSpacing:w?E.gap:0,control:a.control,controlComponent:s.ControlComponent.VALUE}),L++,r++}}}}else{if((!h||!h.length)&&Array.isArray(I)&&I.length){const N=p?p.split(","):[];if(N.length>1){const L=[];for(const W of N){const S=I.find(U=>U.code===W.trim());S&&L.push({value:S.value})}L.length>0&&(X=L)}else{const L=I.find(W=>W.code===p);L&&(X=[{value:L.value}])}}for(let N=0;N<X.length;N++){const L=X[N];if(L.type===s.ElementType.CONTROL&&L.control){const W=L,S=W.controlId||ft(),U=W.control?.value||[],v=W.control?.placeholder||"",Q=W.control?.type,w=Q===s.ControlType.TEXTFIELD,q=Q===s.ControlType.TEXT,G=Q===s.ControlType.CHECKBOX,H=Q===s.ControlType.RADIO,z=Q===s.ControlType.BUTTON,_=w?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,dt=w?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,Ct={...F,controlId:S,type:s.ElementType.CONTROL,control:W.control},Kt=w?i.control.textFixColor:q?"#87d068":z?bn().color:i.control.bracketColor,ge=z?bn().highlight:void 0,se=w?W.control?.preTextFix||m.preTextFix:W.control?.prefix||m.prefix,J=Ze(Q,se);for(let j=0;j<J.length;j++)o.splice(r,0,{...Ct,color:Kt,highlight:ge,originControlId:M,value:J[j],controlComponent:_}),r++;if(z){const j=_s(W.control);if(j){const tt=yt(j),x=Eo(i.defaultColor);for(let Rt=0;Rt<tt.length;Rt++){const ht=tt[Rt];o.splice(r,0,{...Ct,...x,originControlId:M,value:ht===`
82
+ `?K:N,type:a.type,control:a.control,controlComponent:s.ControlComponent.PREFIX}),r++}if(u){const X=yt(u);for(let N=0;N<X.length;N++){const L=X[N];o.splice(r,0,{...F,...y,controlId:M,value:L,type:a.type,control:a.control,controlComponent:s.ControlComponent.PRE_TEXT}),r++}}if(h&&h.length||C===s.ControlType.CHECKBOX||C===s.ControlType.RADIO||C===s.ControlType.SELECT&&p&&(!h||!h.length)){let X=h?ct(h):[];if(C===s.ControlType.CHECKBOX){const N=p?p.split(","):[];if(Array.isArray(I)&&I.length){const L=X.reduce((S,U)=>S.concat(U.value.split("").map(Q=>({...U,value:Q}))),[]);let W=0;for(let S=0;S<I.length;S++){const U=I[S];o.splice(r,0,{...F,...y,controlId:M,value:"",type:a.type,control:a.control,controlComponent:s.ControlComponent.CHECKBOX,checkbox:{code:U.code,value:N.includes(U.code)}}),r++;const Q=yt(U.value);for(let v=0;v<Q.length;v++){const w=Q[v],q=v===Q.length-1;o.splice(r,0,{...F,...D,...L[W],controlId:M,value:w===`
83
+ `?K:w,letterSpacing:q?P.gap:0,control:a.control,controlComponent:s.ControlComponent.VALUE}),W++,r++}}}}else if(C===s.ControlType.RADIO){if(Array.isArray(I)&&I.length){const N=X.reduce((W,S)=>W.concat(S.value.split("").map(U=>({...S,value:U}))),[]);let L=0;for(let W=0;W<I.length;W++){const S=I[W];o.splice(r,0,{...F,...y,controlId:M,value:"",type:a.type,control:a.control,controlComponent:s.ControlComponent.RADIO,radio:{code:S.code,value:p===S.code}}),r++;const U=yt(S.value);for(let Q=0;Q<U.length;Q++){const v=U[Q],w=Q===U.length-1;o.splice(r,0,{...F,...D,...N[L],controlId:M,value:v===`
84
+ `?K:v,letterSpacing:w?E.gap:0,control:a.control,controlComponent:s.ControlComponent.VALUE}),L++,r++}}}}else{if((!h||!h.length)&&Array.isArray(I)&&I.length){const N=p?p.split(","):[];if(N.length>1){const L=[];for(const W of N){const S=I.find(U=>U.code===W.trim());S&&L.push({value:S.value})}L.length>0&&(X=L)}else{const L=I.find(W=>W.code===p);L&&(X=[{value:L.value}])}}for(let N=0;N<X.length;N++){const L=X[N];if(L.type===s.ElementType.CONTROL&&L.control){const W=L,S=W.controlId||ft(),U=W.control?.value||[],Q=W.control?.placeholder||"",v=W.control?.type,w=v===s.ControlType.TEXTFIELD,q=v===s.ControlType.TEXT,G=v===s.ControlType.CHECKBOX,H=v===s.ControlType.RADIO,z=v===s.ControlType.BUTTON,_=w?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,dt=w?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,Ct={...F,controlId:S,type:s.ElementType.CONTROL,control:W.control},Kt=w?i.control.textFixColor:q?"#87d068":z?bn().color:i.control.bracketColor,ge=z?bn().highlight:void 0,se=w?W.control?.preTextFix||m.preTextFix:W.control?.prefix||m.prefix,J=Ze(v,se);for(let j=0;j<J.length;j++)o.splice(r,0,{...Ct,color:Kt,highlight:ge,originControlId:M,value:J[j],controlComponent:_}),r++;if(z){const j=_s(W.control);if(j){const tt=yt(j),x=Eo(i.defaultColor);for(let Rt=0;Rt<tt.length;Rt++){const ht=tt[Rt];o.splice(r,0,{...Ct,...x,originControlId:M,value:ht===`
85
85
  `?K:ht,controlComponent:s.ControlComponent.VALUE}),r++}}else{const tt=As(W.control),x=yt(tt);for(let Rt=0;Rt<x.length;Rt++){const ht=x[Rt];o.splice(r,0,{...Ct,color:i.control.placeholderColor,originControlId:M,value:ht===`
86
- `?K:ht,controlComponent:s.ControlComponent.PLACEHOLDER}),r++}}}else if(G){const j=W.control?.valueSets||[],tt=W.control?.code||"",x=tt?tt.split(","):[];for(let Rt=0;Rt<j.length;Rt++){const ht=j[Rt];o.splice(r,0,{...Ct,...y,originControlId:M,value:"",controlComponent:s.ControlComponent.CHECKBOX,checkbox:{code:ht.code,value:x.includes(ht.code)}}),r++;const mt=yt(ht.value||"");for(let Pt=0;Pt<mt.length;Pt++){const vt=mt[Pt],Lt=Pt===mt.length-1;o.splice(r,0,{...Ct,...D,originControlId:M,value:vt===`
87
- `?K:vt,letterSpacing:Lt?P.gap:0,controlComponent:s.ControlComponent.VALUE}),r++}}}else if(H){const j=W.control?.valueSets||[],tt=W.control?.code||"";for(let x=0;x<j.length;x++){const Rt=j[x];o.splice(r,0,{...Ct,...y,originControlId:M,value:"",controlComponent:s.ControlComponent.RADIO,radio:{code:Rt.code,value:tt===Rt.code}}),r++;const ht=yt(Rt.value||"");for(let mt=0;mt<ht.length;mt++){const Pt=ht[mt],vt=mt===ht.length-1;o.splice(r,0,{...Ct,...D,originControlId:M,value:Pt===`
88
- `?K:Pt,letterSpacing:vt?E.gap:0,controlComponent:s.ControlComponent.VALUE}),r++}}}else if(U.length>0)for(let j=0;j<U.length;j++){const tt=U[j];if(tt.type===s.ElementType.CONTROL&&tt.control){const x=tt,Rt=x.controlId||ft(),ht=x.control?.value||[],mt=x.control?.type,Pt=mt===s.ControlType.TEXTFIELD,vt=mt===s.ControlType.TEXT,Lt={...Ct,controlId:Rt,control:x.control},At=Pt?i.control.textFixColor:vt?"#87d068":i.control.bracketColor,ee=Pt?x.control?.preTextFix||m.preTextFix:x.control?.prefix||m.prefix,ne=Ze(mt,ee);for(let bt=0;bt<ne.length;bt++)o.splice(r,0,{...Lt,color:At,originControlId:S,value:ne[bt],controlComponent:Pt?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX}),r++;for(let bt=0;bt<ht.length;bt++){const Ft=ht[bt];o.splice(r,0,{...Lt,...D,...Ft,originControlId:S,value:Ft.value===`
86
+ `?K:ht,controlComponent:s.ControlComponent.PLACEHOLDER}),r++}}}else if(G){const j=W.control?.valueSets||[],tt=W.control?.code||"",x=tt?tt.split(","):[];for(let Rt=0;Rt<j.length;Rt++){const ht=j[Rt];o.splice(r,0,{...Ct,...y,originControlId:M,value:"",controlComponent:s.ControlComponent.CHECKBOX,checkbox:{code:ht.code,value:x.includes(ht.code)}}),r++;const mt=yt(ht.value||"");for(let Pt=0;Pt<mt.length;Pt++){const Qt=mt[Pt],Lt=Pt===mt.length-1;o.splice(r,0,{...Ct,...D,originControlId:M,value:Qt===`
87
+ `?K:Qt,letterSpacing:Lt?P.gap:0,controlComponent:s.ControlComponent.VALUE}),r++}}}else if(H){const j=W.control?.valueSets||[],tt=W.control?.code||"";for(let x=0;x<j.length;x++){const Rt=j[x];o.splice(r,0,{...Ct,...y,originControlId:M,value:"",controlComponent:s.ControlComponent.RADIO,radio:{code:Rt.code,value:tt===Rt.code}}),r++;const ht=yt(Rt.value||"");for(let mt=0;mt<ht.length;mt++){const Pt=ht[mt],Qt=mt===ht.length-1;o.splice(r,0,{...Ct,...D,originControlId:M,value:Pt===`
88
+ `?K:Pt,letterSpacing:Qt?E.gap:0,controlComponent:s.ControlComponent.VALUE}),r++}}}else if(U.length>0)for(let j=0;j<U.length;j++){const tt=U[j];if(tt.type===s.ElementType.CONTROL&&tt.control){const x=tt,Rt=x.controlId||ft(),ht=x.control?.value||[],mt=x.control?.type,Pt=mt===s.ControlType.TEXTFIELD,Qt=mt===s.ControlType.TEXT,Lt={...Ct,controlId:Rt,control:x.control},At=Pt?i.control.textFixColor:Qt?"#87d068":i.control.bracketColor,ee=Pt?x.control?.preTextFix||m.preTextFix:x.control?.prefix||m.prefix,ne=Ze(mt,ee);for(let bt=0;bt<ne.length;bt++)o.splice(r,0,{...Lt,color:At,originControlId:S,value:ne[bt],controlComponent:Pt?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX}),r++;for(let bt=0;bt<ht.length;bt++){const Ft=ht[bt];o.splice(r,0,{...Lt,...D,...Ft,originControlId:S,value:Ft.value===`
89
89
  `?K:Ft.value,controlComponent:s.ControlComponent.VALUE}),r++}if(ht.length===0){const bt=x.control?.placeholder||"";if(bt){const Ft=yt(bt);for(let Et=0;Et<Ft.length;Et++)o.splice(r,0,{...Lt,color:i.control.placeholderColor,originControlId:S,value:Ft[Et],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}}const Yt=Pt?x.control?.postTextFix||m.postTextFix:x.control?.postfix||m.postfix,Xt=Ze(mt,Yt);for(let bt=0;bt<Xt.length;bt++)o.splice(r,0,{...Lt,color:At,originControlId:S,value:Xt[bt],controlComponent:Pt?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX}),r++}else o.splice(r,0,{...Ct,...D,...tt,originControlId:M,value:tt.value===`
90
- `?K:tt.value,controlComponent:s.ControlComponent.VALUE}),r++}else if(v){const j=yt(v);for(let tt=0;tt<j.length;tt++)o.splice(r,0,{...Ct,color:i.control.placeholderColor,originControlId:M,value:j[tt],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}else if((Q===s.ControlType.SELECT||Q===s.ControlType.DATE||Q===s.ControlType.NUMBER)&&!W.control?.code&&v){const tt=yt(v);for(let x=0;x<tt.length;x++)o.splice(r,0,{...Ct,color:i.control.placeholderColor,originControlId:M,value:tt[x],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}const lt=w?W.control?.postTextFix||m.postTextFix:W.control?.postfix||m.postfix,$=Ze(Q,lt);for(let j=0;j<$.length;j++)o.splice(r,0,{...Ct,color:Kt,highlight:ge,originControlId:M,value:$[j],controlComponent:dt}),r++}else if(L.type===s.ElementType.MENSTRUAL_HISTORY||L.type===s.ElementType.FETAL_HEART_POSITION||L.type===s.ElementType.TOOTH_POSITION||L.type===s.ElementType.MACRO||L.type===s.ElementType.CUSTOM_MACRO||L.type===s.ElementType.REUSABLE_ITEM||L.type===s.ElementType.LIST||L.type===s.ElementType.SPECIAL_SYMBOLS){const W=L.id||ft();L.id||(L.id=W);const S=a.control?.value;if(S){const U=S.find(v=>v.id===W||v.type===L.type&&v.value===L.value);U&&Po(W,U)}o.splice(r,0,{...F,...L,id:W,controlId:M,control:a.control,controlComponent:s.ControlComponent.VALUE,type:L.type}),r++}else{const W=yt(L.value||"");for(let S=0;S<W.length;S++){const U=W[S];o.splice(r,0,{...F,...D,...C===s.ControlType.BUTTON?Eo(i.defaultColor):{},...L,controlId:M,value:U===`
90
+ `?K:tt.value,controlComponent:s.ControlComponent.VALUE}),r++}else if(Q){const j=yt(Q);for(let tt=0;tt<j.length;tt++)o.splice(r,0,{...Ct,color:i.control.placeholderColor,originControlId:M,value:j[tt],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}else if((v===s.ControlType.SELECT||v===s.ControlType.DATE||v===s.ControlType.NUMBER)&&!W.control?.code&&Q){const tt=yt(Q);for(let x=0;x<tt.length;x++)o.splice(r,0,{...Ct,color:i.control.placeholderColor,originControlId:M,value:tt[x],controlComponent:s.ControlComponent.PLACEHOLDER}),r++}const lt=w?W.control?.postTextFix||m.postTextFix:W.control?.postfix||m.postfix,$=Ze(v,lt);for(let j=0;j<$.length;j++)o.splice(r,0,{...Ct,color:Kt,highlight:ge,originControlId:M,value:$[j],controlComponent:dt}),r++}else if(L.type===s.ElementType.MENSTRUAL_HISTORY||L.type===s.ElementType.FETAL_HEART_POSITION||L.type===s.ElementType.TOOTH_POSITION||L.type===s.ElementType.MACRO||L.type===s.ElementType.CUSTOM_MACRO||L.type===s.ElementType.REUSABLE_ITEM||L.type===s.ElementType.LIST||L.type===s.ElementType.SPECIAL_SYMBOLS){const W=L.id||ft();L.id||(L.id=W);const S=a.control?.value;if(S){const U=S.find(Q=>Q.id===W||Q.type===L.type&&Q.value===L.value);U&&Po(W,U)}o.splice(r,0,{...F,...L,id:W,controlId:M,control:a.control,controlComponent:s.ControlComponent.VALUE,type:L.type}),r++}else{const W=yt(L.value||"");for(let S=0;S<W.length;S++){const U=W[S];o.splice(r,0,{...F,...D,...C===s.ControlType.BUTTON?Eo(i.defaultColor):{},...L,controlId:M,value:U===`
91
91
  `?K:U,type:C===s.ControlType.BUTTON?s.ElementType.CONTROL:L.type||s.ElementType.TEXT,control:a.control,controlComponent:s.ControlComponent.VALUE}),r++}}}}}else if(O){const X={...y,color:i.control.placeholderColor},N=yt(O);for(let L=0;L<N.length;L++){const W=N[L];o.splice(r,0,{...F,...X,controlId:M,value:W===`
92
92
  `?K:W,type:a.type,control:a.control,controlComponent:s.ControlComponent.PLACEHOLDER}),r++}}if(R){const X=yt(R);for(let N=0;N<X.length;N++){const L=X[N];o.splice(r,0,{...F,...y,controlId:M,value:L,type:a.type,control:a.control,controlComponent:s.ControlComponent.POST_TEXT}),r++}}const V=Ze(C,d||m.postfix);for(let X=0;X<V.length;X++){const N=V[X];o.splice(r,0,{...F,...Y,controlId:M,value:N===`
93
93
  `?K:N,type:a.type,control:a.control,controlComponent:s.ControlComponent.POSTFIX}),r++}r--}}else if((!a.type||Ce.includes(a.type))&&a.type!==s.ElementType.SPECIAL_SYMBOLS&&a.value?.length>1){o.splice(r,1);const c=yt(a.value);for(let d=0;d<c.length;d++)o.splice(r+d,0,{...a,value:c[d]});a=o[r]}if((a.value===`
@@ -96,7 +96,7 @@ trailer
96
96
  `:o?.value};return o&&n.forEach(l=>{const r=o[l];r!==void 0&&(i[l]=r)}),i}function wt(o,t={}){const{extraPickAttrs:e,isClassifyArea:n=!1,isClone:i=!0,editorOptions:l}=t,r=(i?ct(o):o).filter(d=>d.type!==s.ElementType.SPLIT_TAG),a=[];let c=0;for(;c<r.length;){let d=r[c];if(c===0&&d.value===K&&!d.listId&&(!d.type||d.type===s.ElementType.TEXT)){c++;continue}if(d.areaId){const R=d.areaId,h=d.area,g=[];for(;c<r.length;){const f=r[c];if(R!==f.areaId){c--;break}delete f.area,delete f.areaId,g.push(f),c++}const T=wt(g,t);if(n){const f={type:s.ElementType.AREA,value:"",areaId:R,area:h};f.valueList=T,d=f}else{a.splice(c,0,...T);continue}}else if(d.titleId&&d.level){const R=d.titleId;if(R){const h=d.level,g={type:s.ElementType.TITLE,title:d.title,titleId:R,value:"",level:h},T=[];for(;c<r.length;){const f=r[c];if(R!==f.titleId){c--;break}delete f.level,delete f.title,T.push(f),c++}g.valueList=wt(T,t),d=g}}else if(d.listId&&d.listType){const R=d.listId;if(R){const h=d.listType,g=d.listStyle,T=d?.label,f={type:s.ElementType.LIST,value:"",label:T||"",listId:R,listType:h,listStyle:g},p=[];for(;c<r.length;){const C=r[c];if(R!==C.listId){c--;break}delete C.listType,delete C.listStyle,p.push(C),c++}f.valueList=wt(p,t),d=f}}else if(d.type===s.ElementType.TABLE){if(d.pagingId){let R=c+1,h=0;for(;R<r.length;){const g=r[R];if(g.pagingId===d.pagingId){d.height+=g.height;const T=g.trList.filter(f=>!f.pagingRepeat).filter(f=>(f.tdList=f.tdList.filter(p=>{if(p.originalId){for(let C=0;C<d.trList.length;C++){const m=d.trList[C].tdList.find(({id:P})=>P===p.originalId);if(m){p.value[0]?.type===s.ElementType.SPLIT_TAG&&p.value.splice(0,1),m.value.push(...p.value),m.rowspan=m.originalRowspan??m.rowspan;break}}return!1}return!0}),!f.originalId));d.trList.push(...T),d.trList?.forEach(f=>f.minHeight=f.originalMinHeight??f.minHeight),R++,h++}else break}c+=h}if(d.trList)for(let R=0;R<d.trList.length;R++){const h=d.trList[R];delete h.id;for(let g=0;g<h.tdList.length;g++){const T=h.tdList[g],f={colspan:T.colspan,rowspan:T.rowspan,value:wt(T.value,{...t,isClassifyArea:!1})};Ea.forEach(p=>{const C=T[p];C!==void 0&&(f[p]=C)}),h.tdList[g]=f}}}else if(d.type===s.ElementType.HYPERLINK){const R=d.hyperlinkId;if(R){const h={type:s.ElementType.HYPERLINK,value:"",url:d.url},g=[];for(;c<r.length;){const T=r[c];if(R!==T.hyperlinkId){c--;break}delete T.type,delete T.url,g.push(T),c++}h.valueList=wt(g,t),d=h}}else if(d.type===s.ElementType.DATE){const R=d.dateId;if(R){const h={type:s.ElementType.DATE,value:"",dateFormat:d.dateFormat},g=[];for(;c<r.length;){const T=r[c];if(R!==T.dateId){c--;break}delete T.type,delete T.dateFormat,g.push(T),c++}h.valueList=wt(g,t),d=h}}else if(d.type!==s.ElementType.BUTTON){if(d.controlId){const R=d.controlId;if(!(d.controlComponent===s.ControlComponent.PREFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX||d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&d.controlComponent===s.ControlComponent.VALUE){if(d.type===s.ElementType.MENSTRUAL_HISTORY||d.type===s.ElementType.FETAL_HEART_POSITION||d.type===s.ElementType.TOOTH_POSITION||d.type===s.ElementType.MACRO||d.type===s.ElementType.CUSTOM_MACRO||d.type===s.ElementType.REUSABLE_ITEM||d.type===s.ElementType.LIST||d.type===s.ElementType.SPECIAL_SYMBOLS){let p=!1;for(let C=c-1;C>=0;C--){const I=r[C],m=I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRETEXTFIX||I.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT;if(I.controlId===R&&m){p=!0;break}if(I.controlId!==R)break}if(!p){const C=ct(d);delete C.controlId,delete C.control,delete C.controlComponent,delete C.originControlId,a.push(C),c++;continue}}c++;continue}if(d.controlComponent===s.ControlComponent.PLACEHOLDER||d.controlComponent===s.ControlComponent.POSTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX||d.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||d.controlComponent===s.ControlComponent.POST_TEXT||d.controlComponent===s.ControlComponent.PRE_TEXT||d.controlComponent===s.ControlComponent.CHECKBOX||d.controlComponent===s.ControlComponent.RADIO){c++;continue}const g=(f,p,C,I)=>{if(I===s.ControlType.CHECKBOX||I===s.ControlType.RADIO){let P=-1;for(let E=f;E<r.length&&r[E].controlId===p;E++)P=E;return P}const m=C?[s.ControlComponent.POSTTEXTFIX,s.ControlComponent.POSTTEXTFIX_TEXT]:[s.ControlComponent.POSTFIX];for(let P=f;P<r.length;P++){const E=r[P];if(E.controlId===p&&m.includes(E.controlComponent))return P}return-1},T=(f,p,C)=>{const I=[];let m=f;for(;m<=p;){const P=r[m];if(P.controlId&&P.controlId!==C&&P.control){const Y=P.control?.type,D=Y===s.ControlType.TEXTFIELD,O=D?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,b=P.controlComponent===O,V=Y===s.ControlType.CHECKBOX||Y===s.ControlType.RADIO;if(b||V&&(P.controlComponent===s.ControlComponent.CHECKBOX||P.controlComponent===s.ControlComponent.RADIO)){const X=g(m+1,P.controlId,D,Y);if(X!==-1){const N=r.slice(m,X+1).map(W=>{const S=ct(W);return delete S.originControlId,S}),L=wt(N,t);L.length>0&&I.push(L[0]),m=X+1;continue}}}if(!(P.controlId===C&&(P.controlComponent===s.ControlComponent.VALUE||!P.controlComponent)&&(!P.originControlId||P.originControlId===C)||P.originControlId===C&&P.controlComponent===s.ControlComponent.VALUE||P.controlId===C&&(P.controlComponent===s.ControlComponent.CHECKBOX||P.controlComponent===s.ControlComponent.RADIO)&&!P.originControlId)){m++;continue}if(P.type===s.ElementType.MENSTRUAL_HISTORY||P.type===s.ElementType.FETAL_HEART_POSITION||P.type===s.ElementType.TOOTH_POSITION||P.type===s.ElementType.MACRO||P.type===s.ElementType.CUSTOM_MACRO||P.type===s.ElementType.REUSABLE_ITEM||P.type===s.ElementType.LIST||P.type===s.ElementType.SPECIAL_SYMBOLS){const Y=ct(P);delete Y.controlId,delete Y.control,delete Y.controlComponent,delete Y.originControlId,I.push(Y),m++;continue}if(P.controlComponent===s.ControlComponent.CHECKBOX||P.controlComponent===s.ControlComponent.RADIO){I.push(ct(P)),m++;continue}const F=d.control?.type;if(F===s.ControlType.CHECKBOX||F===s.ControlType.RADIO){let Y=m-1,D=!1;for(;Y>=f-1;){const O=r[Y];if(O.controlId===C&&!O.originControlId)if(O.controlComponent===s.ControlComponent.CHECKBOX){D=O.checkbox?.value===!0;break}else if(O.controlComponent===s.ControlComponent.RADIO){D=O.radio?.value===!0;break}else if(O.controlComponent===s.ControlComponent.VALUE){Y--;continue}else break;Y--}if(D){const O={value:P.value||""},b=[...ue,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"];for(const V of b){const X=P[V];if(X!==void 0){if(V==="color"&&l){const N=l.control?.bracketColor,L=l.control?.placeholderColor;if(X===N||X===L)continue}O[V]=X}}I.push(O)}}else{const Y={value:P.value||""},D=[...ue,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"];for(const O of D){const b=P[O];if(b!==void 0){if(O==="color"&&l){const V=l.control?.bracketColor,X=l.control?.placeholderColor;if(b===V||b===X)continue}Y[O]=b}}I.push(Y)}m++}return I};if(d.controlComponent===s.ControlComponent.PREFIX){const f=d.control?.type===s.ControlType.TEXTFIELD,p=g(c+1,R,f);if(p!==-1){const C=T(c+1,p-1,R),I=$t(d,Re),P=d.control?.type===s.ControlType.BUTTON&&!d.control?.buttonText?C.length?C:null:C,E={...d.control,...I,value:P},M={...$t(d,ue),type:s.ElementType.CONTROL,value:"",control:E,controlId:R};d=dn(M,{extraPickAttrs:e}),c=p}}if(d.controlComponent===s.ControlComponent.PRETEXTFIX){const f=g(c+1,R,!0);if(f!==-1){const p=T(c+1,f-1,R),C=$t(d,Re),I={...d.control,...C,value:p},m={...$t(d,ue),type:s.ElementType.CONTROL,value:"",control:I,controlId:R};d=dn(m,{extraPickAttrs:e}),c=f}}if(d.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){const f=g(c+1,R,!0);if(f!==-1){const p=T(c+1,f-1,R),C=$t(d,Re),I={...d.control,...C,value:p},m={...$t(d,ue),type:s.ElementType.CONTROL,value:"",control:I,controlId:R};d=dn(m,{extraPickAttrs:e}),c=f}}}}const u=dn(d,{extraPickAttrs:e});if(!d.type||d.type===s.ElementType.TEXT||d.type===s.ElementType.SUBSCRIPT||d.type===s.ElementType.SUPERSCRIPT)for(;c<r.length;){const R=r[c+1];if(c++,R&&fc(u,dn(R,{extraPickAttrs:e}))){const h=R.value===K?`
97
97
  `:R.value;u.value+=h}else break}else c++;a.push(u)}return a}function Bs(o){switch(window.getComputedStyle(o).textAlign){case"left":case"start":return s.RowFlex.LEFT;case"center":return s.RowFlex.CENTER;case"right":case"end":return s.RowFlex.RIGHT;case"justify":return s.RowFlex.ALIGNMENT;case"justify-all":return s.RowFlex.JUSTIFY;default:return s.RowFlex.LEFT}}function Js(o){return o===s.RowFlex.ALIGNMENT?"justify":o}function mc(o){switch(o){case s.RowFlex.LEFT:return"flex-start";case s.RowFlex.CENTER:return"center";case s.RowFlex.RIGHT:return"flex-end";case s.RowFlex.ALIGNMENT:case s.RowFlex.JUSTIFY:return"space-between";default:return"flex-start"}}function Xo(o){return!o.type||Ce.includes(o.type)}function pc(o){return!o.type||o.type===s.ElementType.TEXT}function $s(o){return o.filter(t=>Xo(t)).map(t=>t.value).join("").replace(new RegExp(K,"g"),"")}function Vn(o,t){const e=o[t];if(!e)return null;const n=o[t+1];return!e.listId&&e.value===K&&n&&n.value!==K&&e.areaId===n.areaId?n:e}function oe(o,t,e,n){let i=Vn(o,e);if(!i)return;const{isBreakWhenWrap:l=!1,editorOptions:r,ignoreContextKeys:a=[]}=n||{},{mode:c}=r||{};c!==s.EditorMode.DESIGN&&i.title?.disabled&&(i=pe(i,hi));let d=!1;for(let u=0;u<t.length;u++){const R=t[u];if(l&&!i.listId&&ri.test(R.value)&&(d=!0),d||!i.listId&&R.type===s.ElementType.LIST){const g=[...pn,...ue,...cn];Ns(g,a),an(g,i,R),R.valueList?.forEach(T=>{an(g,i,T)});continue}R.valueList?.length&&oe(o,R.valueList,e,n);const h=[...Ti];Un(R)||h.push(...ue),Ns(h,a),an(h,i,R)}}function Cc(o,t){let e="span";o.type===s.ElementType.SUPERSCRIPT?e="sup":o.type===s.ElementType.SUBSCRIPT&&(e="sub");const n=document.createElement(e);return n.style.fontFamily=o.font||t.defaultFont,o.rowFlex&&(n.style.textAlign=Js(o.rowFlex)),o.color&&(n.style.color=o.color),o.bold&&(n.style.fontWeight="600"),o.italic&&(n.style.fontStyle="italic"),n.style.fontSize=`${o.size||t.defaultSize}px`,o.highlight&&(n.style.backgroundColor=o.highlight),o.underline&&(n.style.textDecoration="underline",n.style.textDecorationStyle=o.textDecoration?.style||"solid"),o.strikeout&&(n.style.textDecoration+=" line-through"),o.type&&n.setAttribute("data-type",o.type),o.rowMargin&&(n.style.lineHeight=(o.rowMargin??t.defaultRowMargin).toString()),n.innerText=o.value.replace(new RegExp(`${K}`,"g"),`
98
98
  `),n}function zs(o){let t=0;const e=new Map;for(let n=0;n<o.length;n++){const i=o[n];if(n===0){if(i.checkbox)continue;i.value=i.value.replace(ri,"")}if(i.listWrap){const l=e.get(t)||[];l.push(i),e.set(t,l)}else{const l=i.value.split(`
99
- `);for(let r=0;r<l.length;r++){r>0&&(t+=1);const a=l[r],c=e.get(t)||[];c.push({...i,value:a}),e.set(t,c)}}}return e}function Ic(o){const t=[];if(!o.length)return t;let e=o[0]?.rowFlex||null;t.push({rowFlex:e,data:[o[0]]});for(let n=1;n<o.length;n++){const i=o[n],l=i.rowFlex||null;e===l&&!Un(i)&&!Un(o[n-1])?t[t.length-1].data.push(i):(t.push({rowFlex:l,data:[i]}),e=l)}for(let n=0;n<t.length;n++){const i=t[n];i.data=wt(i.data)}return t}function Wn(o,t){const e=Lo(t),n=ks(e.mode)?Dn(wt(o,{editorOptions:e})):o;function i(a){const c=document.createElement("div");for(let d=0;d<a.length;d++){const u=a[d];if(u.type===s.ElementType.TABLE){const R=document.createElement("table");R.setAttribute("cellSpacing","0"),R.setAttribute("cellpadding","0"),R.setAttribute("border","0");const h="1px solid #000000";!u.borderType||u.borderType===s.TableBorder.ALL?(R.style.borderTop=h,R.style.borderLeft=h):u.borderType===s.TableBorder.EXTERNAL&&(R.style.border=h),R.style.width=`${u.width}px`;const g=document.createElement("colgroup");for(let f=0;f<u.colgroup.length;f++){const p=u.colgroup[f],C=document.createElement("col");C.setAttribute("width",`${p.width}`),g.append(C)}R.append(g);const T=u.trList;for(let f=0;f<T.length;f++){const p=document.createElement("tr"),C=T[f];p.style.height=`${C.height}px`;for(let I=0;I<C.tdList.length;I++){const m=document.createElement("td");(!u.borderType||u.borderType===s.TableBorder.ALL)&&(m.style.borderBottom=m.style.borderRight="1px solid");const P=C.tdList[I];m.colSpan=P.colspan,m.rowSpan=P.rowspan,m.style.verticalAlign=P.verticalAlign||"top",P.borderTypes?.includes(s.TdBorder.TOP)&&(m.style.borderTop=h),P.borderTypes?.includes(s.TdBorder.RIGHT)&&(m.style.borderRight=h),P.borderTypes?.includes(s.TdBorder.BOTTOM)&&(m.style.borderBottom=h),P.borderTypes?.includes(s.TdBorder.LEFT)&&(m.style.borderLeft=h);const E=Wn(P.value,t);m.innerHTML=E.innerHTML,P.backgroundColor&&(m.style.backgroundColor=P.backgroundColor),p.append(m)}R.append(p)}c.append(R)}else if(u.type===s.ElementType.HYPERLINK){const R=document.createElement("a");R.innerText=u.valueList.map(h=>h.value).join(""),u.url&&(R.href=u.url),c.append(R)}else if(u.type===s.ElementType.TITLE){const R=document.createElement(`h${Ci[u.level]}`),h=i(u.valueList);R.innerHTML=h.innerHTML,c.append(R)}else if(u.type===s.ElementType.LIST){const R=document.createElement(Za[u.listType]);u.listStyle&&(R.style.listStyleType=va[u.listStyle]);const h=wt(u.valueList);zs(h).forEach(T=>{const f=document.createElement("li"),p=i(T);f.innerHTML=p.innerHTML,R.append(f)}),c.append(R)}else if(u.type===s.ElementType.IMAGE){const R=document.createElement("img");u.value&&(R.src=u.value,R.width=u.width,R.height=u.height),c.append(R)}else if(u.type===s.ElementType.BLOCK){if(u.block?.type===s.BlockType.VIDEO){const R=u.block.videoBlock?.src;if(R){const h=document.createElement("video");h.style.display="block",h.controls=!0,h.src=R,h.width=u.width||t?.width||window.innerWidth,h.height=u.height,c.append(h)}}else if(u.block?.type===s.BlockType.IFRAME){const{src:R,srcdoc:h,sandbox:g,allow:T}=u.block.iframeBlock||{};if(R||h){const f=document.createElement("iframe");f.sandbox.add(...g||Fn.sandbox),f.setAttribute("allow",[T||Fn.allow].join(" ")),f.style.display="block",f.style.border="none",R?f.src=R:h&&(f.srcdoc=h),f.width=`${u.width||t?.width||window.innerWidth}`,f.height=`${u.height}`,c.append(f)}}}else if(u.type===s.ElementType.SEPARATOR){const R=document.createElement("hr");u.dashArray?.length&&R.setAttribute("data-dash-array",u.dashArray.join(",")),c.append(R)}else if(u.type===s.ElementType.CHECKBOX){const R=document.createElement("input");R.type="checkbox",u.checkbox?.value&&R.setAttribute("checked","true"),c.append(R)}else if(u.type===s.ElementType.RADIO){const R=document.createElement("input");R.type="radio",u.radio?.value&&R.setAttribute("checked","true"),c.append(R)}else if(u.type===s.ElementType.TAB){const R=document.createElement("span");R.innerHTML=`${Es}${Es}`,c.append(R)}else if(u.type===s.ElementType.CONTROL){const R=document.createElement("span"),h=i(u.control?.value||[]);R.innerHTML=h.innerHTML,c.append(R)}else if(u.type===s.ElementType.PAGE_BREAK){const R=document.createElement("div");R.style.breakAfter="page",c.append(R)}else if(!u.type||u.type===s.ElementType.LATEX||Ce.includes(u.type)){let R="";if(u.type===s.ElementType.DATE?R=u.valueList?.map(g=>g.value).join("")||"":R=u.value,!R)continue;const h=Cc(u,e);a[d-1]?.type===s.ElementType.TITLE&&(R=R.replace(/^\n/,"")),h.innerText=R.replace(new RegExp(`${K}`,"g"),`
99
+ `);for(let r=0;r<l.length;r++){r>0&&(t+=1);const a=l[r],c=e.get(t)||[];c.push({...i,value:a}),e.set(t,c)}}}return e}function Ic(o){const t=[];if(!o.length)return t;let e=o[0]?.rowFlex||null;t.push({rowFlex:e,data:[o[0]]});for(let n=1;n<o.length;n++){const i=o[n],l=i.rowFlex||null;e===l&&!Un(i)&&!Un(o[n-1])?t[t.length-1].data.push(i):(t.push({rowFlex:l,data:[i]}),e=l)}for(let n=0;n<t.length;n++){const i=t[n];i.data=wt(i.data)}return t}function Wn(o,t){const e=Lo(t),n=ks(e.mode)?Dn(wt(o,{editorOptions:e})):o;function i(a){const c=document.createElement("div");for(let d=0;d<a.length;d++){const u=a[d];if(u.type===s.ElementType.TABLE){const R=document.createElement("table");R.setAttribute("cellSpacing","0"),R.setAttribute("cellpadding","0"),R.setAttribute("border","0");const h="1px solid #000000";!u.borderType||u.borderType===s.TableBorder.ALL?(R.style.borderTop=h,R.style.borderLeft=h):u.borderType===s.TableBorder.EXTERNAL&&(R.style.border=h),R.style.width=`${u.width}px`;const g=document.createElement("colgroup");for(let f=0;f<u.colgroup.length;f++){const p=u.colgroup[f],C=document.createElement("col");C.setAttribute("width",`${p.width}`),g.append(C)}R.append(g);const T=u.trList;for(let f=0;f<T.length;f++){const p=document.createElement("tr"),C=T[f];p.style.height=`${C.height}px`;for(let I=0;I<C.tdList.length;I++){const m=document.createElement("td");(!u.borderType||u.borderType===s.TableBorder.ALL)&&(m.style.borderBottom=m.style.borderRight="1px solid");const P=C.tdList[I];m.colSpan=P.colspan,m.rowSpan=P.rowspan,m.style.verticalAlign=P.verticalAlign||"top",P.borderTypes?.includes(s.TdBorder.TOP)&&(m.style.borderTop=h),P.borderTypes?.includes(s.TdBorder.RIGHT)&&(m.style.borderRight=h),P.borderTypes?.includes(s.TdBorder.BOTTOM)&&(m.style.borderBottom=h),P.borderTypes?.includes(s.TdBorder.LEFT)&&(m.style.borderLeft=h);const E=Wn(P.value,t);m.innerHTML=E.innerHTML,P.backgroundColor&&(m.style.backgroundColor=P.backgroundColor),p.append(m)}R.append(p)}c.append(R)}else if(u.type===s.ElementType.HYPERLINK){const R=document.createElement("a");R.innerText=u.valueList.map(h=>h.value).join(""),u.url&&(R.href=u.url),c.append(R)}else if(u.type===s.ElementType.TITLE){const R=document.createElement(`h${Ci[u.level]}`),h=i(u.valueList);R.innerHTML=h.innerHTML,c.append(R)}else if(u.type===s.ElementType.LIST){const R=document.createElement(Za[u.listType]);u.listStyle&&(R.style.listStyleType=Qa[u.listStyle]);const h=wt(u.valueList);zs(h).forEach(T=>{const f=document.createElement("li"),p=i(T);f.innerHTML=p.innerHTML,R.append(f)}),c.append(R)}else if(u.type===s.ElementType.IMAGE){const R=document.createElement("img");u.value&&(R.src=u.value,R.width=u.width,R.height=u.height),c.append(R)}else if(u.type===s.ElementType.BLOCK){if(u.block?.type===s.BlockType.VIDEO){const R=u.block.videoBlock?.src;if(R){const h=document.createElement("video");h.style.display="block",h.controls=!0,h.src=R,h.width=u.width||t?.width||window.innerWidth,h.height=u.height,c.append(h)}}else if(u.block?.type===s.BlockType.IFRAME){const{src:R,srcdoc:h,sandbox:g,allow:T}=u.block.iframeBlock||{};if(R||h){const f=document.createElement("iframe");f.sandbox.add(...g||Fn.sandbox),f.setAttribute("allow",[T||Fn.allow].join(" ")),f.style.display="block",f.style.border="none",R?f.src=R:h&&(f.srcdoc=h),f.width=`${u.width||t?.width||window.innerWidth}`,f.height=`${u.height}`,c.append(f)}}}else if(u.type===s.ElementType.SEPARATOR){const R=document.createElement("hr");u.dashArray?.length&&R.setAttribute("data-dash-array",u.dashArray.join(",")),c.append(R)}else if(u.type===s.ElementType.CHECKBOX){const R=document.createElement("input");R.type="checkbox",u.checkbox?.value&&R.setAttribute("checked","true"),c.append(R)}else if(u.type===s.ElementType.RADIO){const R=document.createElement("input");R.type="radio",u.radio?.value&&R.setAttribute("checked","true"),c.append(R)}else if(u.type===s.ElementType.TAB){const R=document.createElement("span");R.innerHTML=`${Es}${Es}`,c.append(R)}else if(u.type===s.ElementType.CONTROL){const R=document.createElement("span"),h=i(u.control?.value||[]);R.innerHTML=h.innerHTML,c.append(R)}else if(u.type===s.ElementType.PAGE_BREAK){const R=document.createElement("div");R.style.breakAfter="page",c.append(R)}else if(!u.type||u.type===s.ElementType.LATEX||Ce.includes(u.type)){let R="";if(u.type===s.ElementType.DATE?R=u.valueList?.map(g=>g.value).join("")||"":R=u.value,!R)continue;const h=Cc(u,e);a[d-1]?.type===s.ElementType.TITLE&&(R=R.replace(/^\n/,"")),h.innerText=R.replace(new RegExp(`${K}`,"g"),`
100
100
  `),c.append(h)}}return c}const l=document.createElement("div"),r=Ic(n);for(let a=0;a<r.length;a++){const c=r[a],d=!c.rowFlex||c.rowFlex===s.RowFlex.LEFT,u=document.createElement("div");if(!d){const R=c.data[0];Un(R)?(u.style.display="flex",u.style.justifyContent=mc(R.rowFlex)):(u.style.textAlign=Js(c.rowFlex),c.rowFlex==="justify"&&(u.style.textAlignLast="justify"))}u.innerHTML=i(c.data).innerHTML,d?u.childNodes.forEach(R=>{l.append(R.cloneNode(!0))}):l.append(u)}return l}function Lc(o){if(!o||o.nodeType!==3)return null;const t=o.parentNode,e=t.nodeName==="FONT"?t.parentNode:t,n=Bs(e),i=o.textContent,l=window.getComputedStyle(e);if(!i||e.nodeName==="STYLE")return null;const r={value:i,color:l.color,bold:Number(l.fontWeight)>500,italic:l.fontStyle.includes("italic"),size:Math.floor(parseFloat(l.fontSize))};return e.nodeName==="SUB"||l.verticalAlign==="sub"?r.type=s.ElementType.SUBSCRIPT:(e.nodeName==="SUP"||l.verticalAlign==="super")&&(r.type=s.ElementType.SUPERSCRIPT),n!==s.RowFlex.LEFT&&(r.rowFlex=n),l.backgroundColor!=="rgba(0, 0, 0, 0)"&&(r.highlight=l.backgroundColor),l.textDecorationLine.includes("underline")&&(r.underline=!0),l.textDecorationLine.includes("line-through")&&(r.strikeout=!0),r}function Yn(o,t){const e=[];function n(c){if(c.nodeType===3){const d=Lc(c);d&&e.push(d)}else if(c.nodeType===1){const d=c.childNodes;for(let u=0;u<d.length;u++){const R=d[u];if(R.nodeName==="BR")e.push({value:`
101
101
  `});else if(R.nodeName==="A"){const h=R,g=h.innerText;g&&e.push({type:s.ElementType.HYPERLINK,value:"",valueList:[{value:g}],url:h.href})}else if(/H[1-6]/.test(R.nodeName)){const g=Yn(Pc(R,"div").outerHTML,t);e.push({value:"",type:s.ElementType.TITLE,level:Ka[R.nodeName],valueList:g}),R.nextSibling&&!Sa.includes(R.nextSibling.nodeName)&&e.push({value:`
102
102
  `})}else if(R.nodeName==="UL"||R.nodeName==="OL"){const h=R,g={value:"",type:s.ElementType.LIST,valueList:[]};R.nodeName==="OL"?g.listType=s.ListType.OL:(g.listType=s.ListType.UL,g.listStyle=h.style.listStyleType),h.querySelectorAll("li").forEach(T=>{const f=Yn(T.innerHTML,t);f.forEach(p=>{p.value===`
@@ -111,11 +111,11 @@ ${R||`${g+1}.`}${i(h)}${T?`
111
111
  `:""}`})}else if(c.type===s.ElementType.CHECKBOX)r+=c.checkbox?.value?"☑":"□";else if(c.type===s.ElementType.RADIO)r+=c.radio?.value?"☉":"○";else if(!c.type||c.type===s.ElementType.LATEX||Ce.includes(c.type)){let d="";if(c.type===s.ElementType.CONTROL){const u=c.control.value?.[0]?.value||"";d=u?`${c.control?.preText||""}${u}${c.control?.postText||""}`:""}else c.type===s.ElementType.DATE?d=c.valueList?.map(u=>u.value).join("")||"":d=c.value;r+=d.replace(new RegExp(`${K}`,"g"),`
112
112
  `)}}return r}return i(n)}function Mi(o){return li(o,["metrics","style"])}function Un(o){return!!o?.type&&(Oa.includes(o.type)||o.imgDisplay===s.ImageDisplay.INLINE)}function Pc(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 Oi(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 Ec(o,t){for(let e=o.length-1;e>=0;e--)o[e].imgFloatPosition?.pageNo===t&&o.splice(e,1)}function ae(o){return o?!!(o.hide||o.control?.hide||o.area?.hide):!0}function wn(o,t,e=s.LocationPosition.BEFORE){if(!ae(o[t]))return t;let n=t;if(e===s.LocationPosition.BEFORE)for(n=t-1;n>0;){if(!ae(o[n]))return n;n--}else for(n=t+1;n<o.length;){if(!ae(o[n]))return n;n++}return n}const js=`${zn}-control`;function qs(o){localStorage.setItem(zn,JSON.stringify({text:o.text,elementList:o.elementList}))}function tr(){const o=localStorage.getItem(zn);return o?JSON.parse(o):null}function er(){localStorage.removeItem(zn)}function Mc(o){localStorage.setItem(js,JSON.stringify(o))}function nr(){const o=localStorage.getItem(js);return o?JSON.parse(o):null}function Oc(){return!!nr()?.element}async function Sc(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=`
113
113
  `,l.append(c),a.selectNodeContents(l),r?.removeAllRanges(),r?.addRange(a),document.execCommand("copy"),l.remove()}qs({text:o,elementList:e})}async function Xc(o){if(!o)return;const t=[{value:o}],e=()=>{const n=document.createElement("textarea");n.value=o,n.style.position="fixed",n.style.opacity="0",document.body.append(n),n.select(),document.execCommand("copy"),n.remove()};if(window.navigator.clipboard?.writeText)try{await window.navigator.clipboard.writeText(o)}catch{e()}else e();qs({text:o,elementList:t})}async function or(o,t){const e=Wn(o,t);document.body.append(e);const n=e.innerText;e.remove();const i=e.innerHTML;!n&&!i&&!o.length||await Sc(n,i,wt(o))}function Nc(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 Si(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(Xa.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===`
114
- `||(t.splice(a,0,u),a++)}a--}a++}}oe(l,t,i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function ir(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=Yn(t,{innerWidth:e.getOriginalInnerWidth()});Si(o,n)}function Xi(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&&oe(l,[d],i,{editorOptions:e.getOptions()}),e.insertElementList([d])}}}function Fc(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(!Nc(n)){const r=n.getData("text"),a=tr();if(a&&mo(r)===mo(a.text)){Si(o,a.elementList);return}}er();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=>{ir(o,c)});break}}else if(a.kind==="file"&&a.type.includes("image")){const c=a.getAsFile();c&&Xi(o,c)}}}async function yc(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=tr();if(l&&mo(i)===mo(l.text)){Si(o,l.elementList);return}if(er(),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&&ir(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);Xi(o,u)}}}class bc{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(`${rt}-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||(Fc(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 Dc{ANIMATION_CLASS=`${rt}-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(`${rt}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new bc(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(Ca&&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:C}=e,P=(this.draw.getZone().isMainActive()?C:this.draw.getPageNo())*(R+h),E=fa*n,M=Math.min(g.height/4,E),F=g.height+M*2,y=this.cursorAgent.getAgentCursorDom();d&&setTimeout(()=>{this.focus()});const Y=g.boundingBoxDescent<0?0:g.boundingBoxDescent,D=T[1]+p+Y-(F-M)+P,O=u?T[0]:f[0];if(y.style.left=`${O}px`,y.style.top=`${D+F-E}px`,!a){this.recoveryCursor();return}const b=this.cursorDom.style.top,V=this.draw.isReadonly();this.cursorDom.style.width=`${r*n}px`,this.cursorDom.style.backgroundColor=l,this.cursorDom.style.left=`${O}px`,this.cursorDom.style.top=`${D}px`,this.cursorDom.style.display=V?"none":"block",this.cursorDom.style.height=`${F}px`,c?this._setBlinkTimeout():this._clearBlinkTimeout(),ui(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(b)>D?Jt.UP:Jt.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=Ra(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:C,bottom:I}=a.getBoundingClientRect();c.left=f,c.right=p,c.top=C,c.bottom=I}const u=i*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,R=n===Jt.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 Ln;(function(o){o[o.LEFT=0]="LEFT",o[o.CENTER=1]="CENTER",o[o.RIGHT=2]="RIGHT"})(Ln||(Ln={}));function Qe(o){return mn?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 No{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 Ni extends No{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 sr(o){const t=o.getDraw(),e=t.getPosition(),n=t.getRange();o.isAllowDrag=!0,o.cacheRange=ct(n.getRange()),o.cacheElementList=t.getElementList(),o.cachePositionList=e.getPositionList(),o.cachePositionContext=e.getPositionContext()}function rr(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 No&&l.setSelect(i)}}function lr(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 Ni&&l.setSelect(i)}}function Vc(o,t){const e=t.getDraw();let n=e.isReadonly();const i=e.isSelectionDisabled(),l=e.getRange(),r=e.getPosition(),a=l.getRange();if(o.button===Ln.RIGHT&&(a.isCrossRowCol||!l.getIsCollapsed()))return;const d=o.target.dataset.index;if(d&&e.setPageNo(Number(d)),!t.isAllowDrag&&!n&&a.startIndex!==a.endIndex&&l.getIsPointInRange(o.offsetX,o.offsetY,e.getPageNo())){sr(t);return}t.isAllowSelection=!i;const u=ct(r.getPositionContext()),R=r.getPositionByXY({x:o.offsetX,y:o.offsetY}),h=r.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!h)return;const{index:g,isDirectHit:T,isCheckbox:f,isRadio:p,isControl:C,isImage:I,isLabel:m,isMacro:P,isTable:E,tdValueIndex:M,hitLineStartIndex:F}=h;t.mouseDownStartPosition={...h,index:E?M:g,originalIndex:g,x:o.offsetX,y:o.offsetY};const y=e.getElementList(),Y=r.getPositionList(),D=E?M:g;let O;E?O=e.getTd().value[M]:O=y[D];const b=E&&e.getTd()?.value||y,V=E&&e.getTd()?.positionList||Y,X=!!(T&&I),N=!!(T&&f),L=!!(T&&p),W=!!(T&&m),S=!!(T&&P),U=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),v=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)),w=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)),q=Z=>{if(!Z)return null;const A=new Set;let et=Z,gt=null;for(;et&&!A.has(et);){A.add(et);let It;for(let Bt=0;Bt<y.length;Bt++){const Qt=y[Bt];if(Qt.controlId===et&&Qt.control?.type&&(It=Qt,Qt.controlComponent===s.ControlComponent.PREFIX||Qt.controlComponent===s.ControlComponent.PRE_TEXT||Qt.controlComponent===s.ControlComponent.PRETEXTFIX||Qt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!It)break;It.control?.type===s.ControlType.TEXT&&(gt=et),et=It.originControlId||null}return gt},G=e.getMode()===s.EditorMode.FORM,H=G&&O?.control?.type===s.ControlType.TEXT,z=G&&!H?e.getControl().getActiveTextControlLimit():null;let _=D;const dt=(Z,A)=>!!Z&&!!A&&Z.controlId===A,Ct=(Z,A,et)=>{if(et){for(let gt=A;gt>=0;gt--){const It=Z[gt];if(dt(It,et)&&!It.originControlId&&It.control?.type)return It.control.type;if(It.controlId&&It.controlId!==et&&It.originControlId!==et)break}for(let gt=A+1;gt<Z.length;gt++){const It=Z[gt];if(dt(It,et)&&!It.originControlId&&It.control?.type)return It.control.type;if(It.controlId&&It.controlId!==et&&It.originControlId!==et)break}}},Kt=(Z,A)=>!!(G&&Z?.controlId&&!Z.originControlId&&Ct(b,A,Z.controlId)===s.ControlType.TEXTFIELD),ge=(Z,A)=>!!(G&&Z?.controlId&&!Z.originControlId&&Ct(b,A,Z.controlId)===s.ControlType.TEXT),se=V[D],J=b[D-1],lt=b[D+1],$=6,j=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],tt=(Z,A)=>!!(Z?.controlId&&Z.controlId===A?.controlId&&(Z.originControlId||null)===(A.originControlId||null)),x=(Z,A)=>{if(Z?.control?.type)return Z.control.type;if(Z?.controlId){for(let et=A;et>=0;et--){const gt=b[et];if(!tt(Z,gt))break;if(gt.control?.type)return gt.control.type}for(let et=A+1;et<b.length;et++){const gt=b[et];if(!tt(Z,gt))break;if(gt.control?.type)return gt.control.type}}},Rt=(Z,A)=>{const et=x(Z,A);return!!(et&&j.includes(et))},ht=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)),Pt=(Z,A)=>{if(!Z?.controlId)return-1;for(let et=A;et>=0;et--){const gt=b[et];if(!tt(Z,gt))break;if(gt.controlComponent===s.ControlComponent.VALUE)return et}for(let et=A+1;et<b.length;et++){const gt=b[et];if(!tt(Z,gt))break;if(gt.controlComponent===s.ControlComponent.VALUE)return et}return-1},vt=(Z,A)=>{if(!Z)return!1;if(Z.controlComponent===s.ControlComponent.VALUE||Z.controlComponent===s.ControlComponent.PLACEHOLDER)return!0;const et=x(Z,A),gt=et===s.ControlType.SELECT||et===s.ControlType.DATE,It=Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||Z.controlComponent===s.ControlComponent.TEXTFIXLABEL;return!!(gt&&It&&Z.value&&Pt(Z,A)===-1)},Lt=Z=>{const A=V[Z];if(!A)return!1;const{coordinate:{leftTop:et,rightTop:gt,leftBottom:It}}=A;return o.offsetX>=et[0]&&o.offsetX<gt[0]&&o.offsetY>=et[1]&&o.offsetY<=It[1]},At=(Z,A)=>{if(e.getMode()!==s.EditorMode.EDIT||!Z?.originControlId||Z.controlComponent!==s.ControlComponent.VALUE||x(Z,A)!==s.ControlType.BUTTON||Z.control?.buttonText||Ct(b,A,Z.originControlId)!==s.ControlType.TEXTFIELD||!Lt(A))return!1;let et=-1;for(let Xn=A;Xn<b.length;Xn++){const ln=b[Xn];if(!tt(Z,ln))break;const xe=V[Xn];ln.controlComponent===s.ControlComponent.VALUE&&xe&&xe.coordinate.rightTop[0]>xe.coordinate.leftTop[0]&&(et=Xn)}if(et===-1)return!1;const gt=V[et],{coordinate:{leftTop:It,rightTop:Bt,leftBottom:Qt}}=gt;return o.offsetX>=It[0]-2&&o.offsetX<=Bt[0]&&o.offsetY>=It[1]&&o.offsetY<=Qt[1]},ee=(Z,A)=>!(!T||!Rt(Z,A)||!Lt(A)||At(Z,A)||!vt(Z,A)||ht(Z)||mt(Z)&&!Z?.value),ne=()=>[R.isTable?R.tdValueIndex:R.index,D,D+1,D-1,D+2,D-2].filter((A,et,gt)=>typeof A=="number"&&A>=0&&A<b.length&&gt.indexOf(A)===et),Yt=()=>{if(!T)return null;for(const Z of ne()){const A=b[Z];if(ee(A,Z))return{element:A,index:Z}}return null},Xt=()=>{if(!T)return-1;for(const Z of ne())if(At(b[Z],Z))return Z;return-1},bt=Z=>{const A=b[Z];let et=Z;for(let gt=Z+1;gt<b.length&&tt(A,b[gt]);gt++)et=gt;return et},Ft=ne().some(Z=>Rt(b[Z],Z)),Et=Yt(),Mt=Xt(),St=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),Vt=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),me=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),Ot=(Z,A)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&St(Z)&&A?.controlId===Z.originControlId&&!A.originControlId&&A.control?.type===s.ControlType.TEXTFIELD&&St(A)),nt=(Z,A)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&St(Z)&&A?.controlId===Z.originControlId&&!A.originControlId&&A.control?.type===s.ControlType.TEXTFIELD&&A.controlComponent===s.ControlComponent.VALUE),Ut=(Z,A,et)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&et?.originControlId===Z.originControlId&&Z.controlId&&et.controlId&&Z.controlId!==et.controlId&&Vt(Z)&&me(et)&&Ct(b,A,Z.originControlId)===s.ControlType.TEXTFIELD),at=Ot(O,lt),Gt=nt(O,lt),k=Ut(O,D,lt),ot=Ut(J,D-1,O),pt=!!(e.getMode()===s.EditorMode.EDIT&&C&&T&&St(O)&&!at&&!Gt&&!k&&J?.controlId===O.controlId&&(J.originControlId||null)===(O.originControlId||null)&&(J.controlComponent===s.ControlComponent.VALUE||J.controlComponent===s.ControlComponent.PLACEHOLDER)),it=(Z,A,et)=>!!(G&&Q(Z)&&Ct(b,A,Z?.originControlId)===et&&(et===s.ControlType.TEXTFIELD?Kt(b[A+1],A+1):ge(b[A+1],A+1))),de=(Z,A,et)=>!!(G&&w(Z)&&Ct(b,A,Z?.originControlId)===et&&(et===s.ControlType.TEXTFIELD?Kt(b[A-1],A-1):ge(b[A-1],A-1))),kt=it(O,D,s.ControlType.TEXTFIELD),zt=!!(G&&se&&Kt(O,D)&&it(J,D-1,s.ControlType.TEXTFIELD)&&o.offsetX<=se.coordinate.leftTop[0]+$),$n=!!(G&&se&&Kt(O,D)&&de(lt,D+1,s.ControlType.TEXTFIELD)&&o.offsetX>=se.coordinate.rightTop[0]-$),Tn=!!(G&&se&&kt&&o.offsetX>se.coordinate.rightTop[0]),Le=!!(G&&se&&w(O)&&Ct(b,D,O.originControlId)===s.ControlType.TEXTFIELD&&Kt(J,D-1)&&o.offsetX<se.coordinate.leftTop[0]),Ve=Kt(O,D)||kt||zt||$n||Tn||Le,qf=it(O,D,s.ControlType.TEXT),vl=Z=>{const A=b[Z],et=Y[Z];if(!et||!ge(A,Z))return-1;const gt=b[Z-1];return!it(gt,Z-1,s.ControlType.TEXT)||o.offsetX>et.coordinate.leftTop[0]+$?-1:Z-1},Is=vl(D),Ql=vl(D-1),Kl=Is!==-1||Ql!==-1,Hl=!!(G&&se&&w(O)&&Ct(b,D,O.originControlId)===s.ControlType.TEXT&&ge(J,D-1)&&o.offsetX<se.coordinate.leftTop[0]),tm=!!(G&&se&&ge(O,D)&&de(lt,D+1,s.ControlType.TEXT)&&o.offsetX>=se.coordinate.rightTop[0]-$),em=qf||Kl||Hl||tm;at||Gt||k?_=D:ot||pt?_=Math.max(D-1,0):Kl?_=Is!==-1?Is:Ql:Hl&&(_=Math.max(D-1,0)),Et?(_=Et.index,r.setPositionContext({...r.getPositionContext(),index:Et.index,isControl:!0,isDirectHit:!0})):Mt!==-1?_=bt(Mt):Rt(O,D)&&se&&!Lt(D)&&o.offsetX>se.coordinate.rightTop[0]&&(_=bt(D));let _l=!1;if(G&&z?.parentControlId&&O?.controlId===z.parentControlId&&!O?.originControlId)for(let Z=D;Z>=0;Z--){const A=y[Z];if(dt(A,z.parentControlId)){A.control?.type===s.ControlType.TEXTFIELD&&(_l=!0);break}if(A.controlId!==z.parentControlId)break}const Al=!!(z&&(!O?.controlId||O.controlId===z.controlId&&(O.originControlId||null)===z.originControlId||z.parentControlId&&O.controlId===z.parentControlId&&!O.originControlId&&_l));if(G&&!H&&(O?.controlId||O?.originControlId)){let Z;const A=O.originControlId||O.controlId;for(let et=D;et>=0;et--){const gt=y[et];if(dt(gt,A)&&gt.control?.type){Z=gt.control.type;break}if(gt.controlId!==O.controlId&&gt.controlId!==A)break}if(Z!==s.ControlType.TEXT){if(Z===s.ControlType.TEXTFIELD){const et=O.controlComponent;if(!v(O)){if(!(O.controlComponent===s.ControlComponent.VALUE&&U(O))){if(et===s.ControlComponent.PRETEXTFIX||et===s.ControlComponent.PRETEXTFIX_TEXT||et===s.ControlComponent.POSTTEXTFIX||et===s.ControlComponent.POSTTEXTFIX_TEXT||et===s.ControlComponent.TEXTFIXLABEL||et===s.ControlComponent.PREFIX||et===s.ControlComponent.POSTFIX||et===s.ControlComponent.PRE_TEXT||et===s.ControlComponent.POST_TEXT||et===s.ControlComponent.PLACEHOLDER)for(let gt=D+1;gt<y.length;gt++){const It=y[gt];if(It.controlId!==A&&It.originControlId!==A)break;if(It.controlComponent===s.ControlComponent.VALUE&&!U(It)){_=gt;break}if(It.controlComponent===s.ControlComponent.POSTTEXTFIX||It.controlComponent===s.ControlComponent.POSTFIX){for(let Bt=D-1;Bt>=0;Bt--){const Qt=y[Bt];if(Qt.controlId!==A&&Qt.originControlId!==A)break;if(Qt.controlComponent===s.ControlComponent.VALUE&&!U(Qt)){_=Bt;break}}break}}else if(et===s.ControlComponent.VALUE&&D>0){const gt=y[D-1];if(gt&&(gt.controlId===A||gt.originControlId===A)&&gt.controlComponent===s.ControlComponent.VALUE&&U(gt)){let It=!1;for(let Bt=D-2;Bt>=0;Bt--){const Qt=y[Bt];if(Qt.controlId!==A&&Qt.originControlId!==A||Qt.controlComponent!==s.ControlComponent.VALUE&&!Qt.originControlId&&Qt.controlId===A)break;if(!U(Qt)){_=Bt+1,It=!0;break}}if(!It)for(let Bt=D;Bt<y.length;Bt++){const Qt=y[Bt];if(Qt.controlId!==A&&Qt.originControlId!==A||(Qt.controlComponent===s.ControlComponent.POSTTEXTFIX||Qt.controlComponent===s.ControlComponent.POSTFIX)&&!Qt.originControlId&&Qt.controlId===A)break;if(!U(Qt)){_=Bt,It=!0;break}}}}}}}}}if(G&&O?.control?.type===s.ControlType.TEXT&&O?.originControlId&&O.controlComponent===s.ControlComponent.PLACEHOLDER&&q(O.originControlId)&&(_=D),~g&&Ve&&!Et)t.isAllowSelection=!1,e.getControl().destroyControl({isEmitEvent:!1}),e.render({isCompute:!1,isSubmitHistory:!1,isSetCursor:!1});else if(~g&&!i){Al&&(_=Math.min(Math.max(_,z.startIndex),z.endIndex));let Z=_,A=_;if(o.shiftKey){const{startIndex:It}=l.getRange();~It&&r.getPositionContext().tdId===u.tdId&&(D>It?Z=It:A=It)}Al&&(Z=Math.min(Math.max(Z,z.startIndex),z.endIndex),A=Math.min(Math.max(A,z.startIndex),z.endIndex),_=Math.min(Math.max(_,z.startIndex),z.endIndex));const et=e.getControl(),gt=!!Et;et.setPopupAwakeDisabled(o.button===Ln.RIGHT||em&&!gt||Ft&&!gt);try{l.setRange(Z,A)}finally{et.setPopupAwakeDisabled(!1)}if(r.setCursorPosition(Y[_]),n=e.isReadonly(),N&&!n)rr(O,e);else if(L&&!n)lr(O,e);else if(!n&&O.controlComponent===s.ControlComponent.VALUE&&(O.control?.type===s.ControlType.CHECKBOX||O.control?.type===s.ControlType.RADIO)){let It=D;for(;It>0;){const Bt=y[It];if(Bt.controlComponent===s.ControlComponent.CHECKBOX){rr(Bt,e);break}else if(Bt.controlComponent===s.ControlComponent.RADIO){lr(Bt,e);break}It--}}else{const Bt=!!(!!(Et&&x(Et.element,Et.index)===s.ControlType.BUTTON&&!Et.element.control?.buttonText)&&Et?.element.control?.editable===!1);let Qt=!1;if(G&&O?.controlId&&O?.controlComponent===s.ControlComponent.VALUE&&!O.originControlId){let xe=!1;for(let Pe=D;Pe>=0;Pe--){const We=y[Pe];if(We.controlId!==O.controlId){if(We.originControlId===O.controlId){xe=!0;continue}break}if(We.control?.type===s.ControlType.TEXTFIELD){if(xe)break;Qt=!0;break}}if(!xe&&!Qt)for(let Pe=D+1;Pe<y.length;Pe++){const We=y[Pe];if(We.controlId!==O.controlId){if(We.originControlId===O.controlId){xe=!0;continue}break}}xe&&(Qt=!1)}const ni=Qt&&U(O),Xn=S&&!ni?_+1:void 0;e.render({curIndex:S&&!ni?Xn:_,isCompute:!1,isSubmitHistory:!1,isSetCursor:!X&&!N&&!L&&!(Bt&&G)&&!ni});const ln=y[_];if(!n&&gt&&ln?.controlId&&o.button===Ln.LEFT){const Pe=e.getControl().getActiveControl(),We=Pe?.getElement()?.control?.type;Pe&&(We===s.ControlType.NUMBER||We===s.ControlType.SELECT||We===s.ControlType.DATE||We===s.ControlType.BUTTON)&&Pe.getElement()?.controlId===ln.controlId&&ln.controlComponent!==s.ControlComponent.POSTFIX&&ln.controlComponent!==s.ControlComponent.POSTTEXTFIX&&ln.controlComponent!==s.ControlComponent.POSTTEXTFIX_TEXT&&ln.controlComponent!==s.ControlComponent.POST_TEXT&&typeof Pe.awake=="function"&&Pe.awake(o)}}F&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:F})}const Ge=e.getEventBus();if(W&&Ge.isSubscribe("labelMousedown")&&Ge.emit("labelMousedown",{evt:o,element:O}),S&&(O.type===s.ElementType.MACRO||O.type===s.ElementType.CUSTOM_MACRO||O.type===s.ElementType.REUSABLE_ITEM)){const Z=e.getMode();if(Z===s.EditorMode.EDIT&&O.type===s.ElementType.CUSTOM_MACRO)Ge.isSubscribe("macroClick")&&Ge.emit("macroClick",{evt:o,element:O});else if(Z===s.EditorMode.FORM){let A=!1;O.type===s.ElementType.CUSTOM_MACRO&&o.button===Ln.LEFT&&!n&&(A=e.getMacroParticle().activateInlineEditor(O,D)),!A&&Ge.isSubscribe("macroValueChange")&&Ge.emit("macroValueChange",{evt:o,element:O})}}o.button===Ln.LEFT&&S&&O.type===s.ElementType.SUB_TEMPLATE&&e.getMode()===s.EditorMode.FORM&&Ge.isSubscribe("subTemplateClick")&&Ge.emit("subTemplateClick",{evt:o,element:O});const kl=e.getPreviewer();if(kl.clearResizer(),X){if(!e.isPrintLikeMode()){const Z={dragDisable:n||!O.controlId&&e.getMode()===s.EditorMode.FORM};O.type===s.ElementType.LATEX&&(Z.mime="svg",Z.srcKey="laTexSVG"),kl.drawResizer(O,Y[D],Z),e.getCursor().drawCursor({isShow:!1}),sr(t),(O.imgDisplay===s.ImageDisplay.SURROUND||O.imgDisplay===s.ImageDisplay.FLOAT_TOP||O.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(O)}Ge.isSubscribe("imageMousedown")&&Ge.emit("imageMousedown",{evt:o,element:O})}const Gl=e.getTableTool();Gl.dispose(),E&&!n&&e.getMode()!==s.EditorMode.FORM&&Gl.render();const Ls=e.getHyperlinkParticle();Ls.clearHyperlinkPopup(),O.type===s.ElementType.HYPERLINK&&(Qe(o)?Ls.openHyperlink(O):Ls.drawHyperlinkPopup(O,Y[D]));const xl=e.getDateParticle();xl.clearDatePicker(),O.type===s.ElementType.DATE&&!n&&xl.renderDatePicker(O,Y[D]);const Bl=e.getMenstrualHistoryParticle();Bl.clearMenstrualHistoryEditor(),O.type===s.ElementType.MENSTRUAL_HISTORY&&T&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&Bl.renderMenstrualHistoryEditor(O,Y[D]);const Jl=e.getFetalHeartPositionParticle();Jl.clearFetalHeartPositionEditor(),O.type===s.ElementType.FETAL_HEART_POSITION&&T&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&Jl.renderFetalHeartPositionEditor(O,Y[D]);const $l=e.getToothPositionParticle();$l.clearToothPositionEditor(),O.type===s.ElementType.TOOTH_POSITION&&T&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&$l.renderToothPositionEditor(O,Y[D])}function Fo(o){const t=ft();return Reflect.set(o,"dragId",t),t}function yo(o,t){return t.findIndex(e=>e.dragId===o)}function ar(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 Wc(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 H=!1,z=!1;if(h){const _=c[T];if(_.type===s.ElementType.IMAGE||_.type===s.ElementType.LATEX){if(ar(_,o,t),_.imgDisplay===s.ImageDisplay.SURROUND||_.imgDisplay===s.ImageDisplay.FLOAT_TOP||_.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(_),H=!0;else{const dt=d[T];e.getPreviewer().drawResizer(_,dt)}z=_.imgDisplay===s.ImageDisplay.SURROUND}}r.replaceRange({...a}),e.render({isCompute:z,isSubmitHistory:H,isSetCursor:!1});return}const f=c.slice(g+1,T+1),p=f.find(H=>H.controlId);if(p){const H=c[g+1],z=c[T];if(!((!H.controlId||H.controlComponent===s.ControlComponent.PREFIX)&&(!z.controlId||z.controlComponent===s.ControlComponent.POSTFIX)||H.controlId===z.controlId&&H.controlComponent===s.ControlComponent.PREFIX&&z.controlComponent===s.ControlComponent.POSTFIX||H.control?.type===s.ControlType.TEXT&&H.controlComponent===s.ControlComponent.VALUE&&z.control?.type===s.ControlType.TEXT&&z.controlComponent===s.ControlComponent.VALUE)){e.render({curIndex:R.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const C=e.getControl(),I=e.getElementList(),m=!p||!!I[R.startIndex].controlId||!C.getIsElementListContainFullControl(f),P=e.getOptions(),E=f.map(H=>{if(!H.type||H.type===s.ElementType.TEXT){const z={value:H.value},_=Xe;return m||_.push(...gi),_.forEach(dt=>{const Ct=H[dt];Ct!==void 0&&(z[dt]=Ct)}),z}else{let z=ct(H);return m&&(z=pe(z,gi)),jt([z],{isHandleFirstElement:!1,editorOptions:P}),z}});oe(I,E,R.startIndex,{editorOptions:e.getOptions()});const M=c[g],F=d[g],y=Fo(c[g]),Y=Fo(c[T]),D=E.length;let O=R.startIndex,b=O+D;const V=C.getActiveControl();if(V&&c[O].controlComponent!==s.ControlComponent.POSTFIX?(b=V.setValue(E),O=b-D):e.spliceElementList(I,O+1,0,E),!~b){e.render({isSetCursor:!1});return}const X=Fo(I[O]),N=Fo(I[b]),L=yo(y,c),W=yo(Y,c),S=c[W];if(S.controlId&&S.controlComponent!==s.ControlComponent.POSTFIX)r.replaceRange({...a,startIndex:L,endIndex:W}),C.getActiveControl()?.cut();else{let H=!0;if(u?.isTable){const{tableId:z,trIndex:_,tdIndex:dt}=u;H=!e.getOriginalElementList().some(Kt=>Kt.id===z&&Kt?.trList?.[_]?.tdList?.[dt]?.deletable===!1)}H&&e.spliceElementList(c,L+1,W-L)}const U=I[R.startIndex],v=i[R.startIndex];let Q=l.index;Q&&(U.tableId&&!M.tableId?F.index<Q&&(Q-=D):!U.tableId&&M.tableId&&v.index<Q&&(Q+=D),n.setPositionContext({...l,index:Q}));const w=yo(X,I),q=yo(N,I);r.setRange(h?q:w,q,R.tableId,R.startTdIndex,R.endTdIndex,R.startTrIndex,R.endTrIndex),e.clearSideEffect();let G=null;if(h){const z=e.getElementList()[q];(z.type===s.ElementType.IMAGE||z.type===s.ElementType.LATEX)&&(ar(z,o,t),G=z)}if(e.render({isSetCursor:!1}),V?C.emitControlContentChange():M.controlId&&C.emitControlContentChange({context:{range:a,elementList:c},controlElement:M}),G)if(G.imgDisplay===s.ImageDisplay.SURROUND||G.imgDisplay===s.ImageDisplay.FLOAT_TOP||G.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(G);else{const z=n.getPositionList()[q];e.getPreviewer().drawResizer(G,z)}}else t.isAllowDrag&&t.cacheRange?.startIndex!==t.cacheRange?.endIndex&&t.mousedown(o)}function Yc(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 Uc(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 N=c.isTable?e.getTdByPosition({...c,isTable:!0,index:c.index}):null,L=c.isTable&&N?.value||e.getElementList(),W=c.isTable&&N?.positionList||a.getPositionList(),S=c.isTable?c.tdValueIndex:c.index,U=e.getMode(),v=U===s.EditorMode.EDIT||U===s.EditorMode.FORM,Q=[S,S+1,S-1,S+2,S-2].filter((H,z,_)=>H>=0&&H<L.length&&_.indexOf(H)===z),w=H=>{const z=W[H];if(!z)return!1;const{coordinate:{leftTop:_,rightTop:dt,leftBottom:Ct}}=z;return dt[0]>_[0]&&o.offsetX>=_[0]&&o.offsetX<dt[0]&&o.offsetY>=_[1]&&o.offsetY<=Ct[1]},q=v&&Q.some(H=>{const _=L[H]?.control?.type;return _!==s.ControlType.NUMBER&&_!==s.ControlType.SELECT&&_!==s.ControlType.DATE?!1:w(H)}),G=Q.some(H=>{const z=L[H];return!!(z?.control?.type===s.ControlType.BUTTON&&!z.control.buttonText&&(z.controlComponent===s.ControlComponent.VALUE||z.controlComponent===s.ControlComponent.PLACEHOLDER)&&w(H))});r&&(q||G)?r.style.cursor="pointer":r&&(r.style.cursor="text")}else r&&(r.style.cursor="text");if(t.isAllowDrag){if(e.isContentReadonly()){t.setIsAllowDrag(!1);return}const N=o.offsetX,L=o.offsetY,{startIndex:W,endIndex:S}=t.cacheRange,U=t.cachePositionList;for(let Q=W+1;Q<=S;Q++){const{coordinate:{leftTop:w,rightBottom:q}}=U[Q];if(N>=w[0]&&N<=q[0]&&L>=w[1]&&L<=q[1])return}const v=t.cacheRange?.startIndex;if(v){const Q=t.cacheElementList[v];Q?.type===s.ElementType.IMAGE&&(Q.imgDisplay===s.ImageDisplay.SURROUND||Q.imgDisplay===s.ImageDisplay.FLOAT_TOP||Q.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:C,tableId:I,trId:m,tdId:P}=h;let E=T?f:g;if(h.isControl&&e.getMode()!==s.EditorMode.READONLY){const{newIndex:N}=n.moveCursor({index:g,isTable:T,trIndex:C,tdIndex:p,tdValueIndex:f});E=N}const{index:M,isTable:F,tdIndex:y,tdId:Y,trIndex:D,tableId:O}=t.mouseDownStartPosition,b=E,V=e.getRange();let X;if(P!==Y&&P&&Y){const N=e.getTdByPosition({...t.mouseDownStartPosition,isTable:!!t.mouseDownStartPosition.tableId,index:t.mouseDownStartPosition.originalIndex??t.mouseDownStartPosition.index}),L=e.getTdByPosition({...h,isTable:!!h.tableId,index:h.index});if(e.isSplitTd(N,L)){const W=(N.valueStartIndex??0)+M,S=(L.valueStartIndex??0)+f;X=[{index:W,element:N.value[M],originalId:N.originalId,isCurrent:!1,length:N.value.length,startIndex:N.valueStartIndex??0},{index:S,element:L.value[f],originalId:L.originalId,isCurrent:!0,length:L.value.length,startIndex:L.valueStartIndex??0}]}}if(T&&F&&P!==Y&&!X)V.setRange(b,b,I,y,p,D,C),R.setPositionContext({isTable:!!T,index:g,trIndex:C,tdIndex:p,tdId:P,trId:m,tableId:I});else{let N=~b?b:0;if((F||T)&&O!==I&&!X)return;R.setPositionContext({isTable:!!T,index:g,trIndex:C,tdIndex:p,tdId:P,trId:m,tableId:I});let L=M,W,S;if(X)[{element:W},{element:S}]=X;else{const Q=e.getElementList();W=Q[L+1],S=Q[N]}if(L===N||W?.controlComponent===s.ControlComponent.PLACEHOLDER&&S?.controlComponent===s.ControlComponent.PLACEHOLDER&&W.controlId===S.controlId)return;if(L>N&&([L,N]=[N,L]),e.getMode()===s.EditorMode.FORM){const w=n.getActiveControl()?.getElement()?.control?.type===s.ControlType.TEXT?null:n.getActiveTextControlLimit();w&&(L=Math.min(Math.max(L,w.startIndex),w.endIndex),N=Math.min(Math.max(N,w.startIndex),w.endIndex));const q=e.getElementList(),G=q[L],H=q[N];if(G?.control?.type===s.ControlType.TEXTFIELD||H?.control?.type===s.ControlType.TEXTFIELD){const z=G?.controlId||H?.controlId;if(z){let _=-1,dt=-1;for(let Ct=L;Ct>=0;Ct--){const Kt=q[Ct];if(Kt.controlId!==z)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){_=Ct+1;break}}for(let Ct=N;Ct<q.length;Ct++){const Kt=q[Ct];if(Kt.controlId!==z)break;if(Kt.controlComponent===s.ControlComponent.POSTTEXTFIX||Kt.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||Kt.controlComponent===s.ControlComponent.POSTFIX||Kt.controlComponent===s.ControlComponent.POST_TEXT){dt=Ct-1;break}}_!==-1&&L<_&&(L=_),dt!==-1&&N>dt&&(N=dt)}}}let v;if(X){const[Q,w]=X.sort((q,G)=>q.index-G.index);v={originalId:X[0].originalId??X[1].originalId,startIndex:Q.index,endIndex:w.index},Q.isCurrent?(L=Q.index,N=Q.length-1):(L=0,N=v.endIndex-w.startIndex)}V.setRange(L,N,void 0,void 0,void 0,void 0,void 0,v)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function bo(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 Fi(o,t){return!!o&&!!t&&o.controlId===t}function wc(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 cr(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 Zc(o){const t=o.getDraw(),e=t.getRange(),n=e.getRange(),i=t.getElementList(),l=i[n.startIndex];if(!ae(l))return;let r=n.startIndex;for(;r>0;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE&&a.subTemplateExpanded){const u=cr(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||!ae(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 vc(o,t,e){if(e.originControlId){const n=bo(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=bo(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=bo(o,n.controlId);if(i)return{isInParent:!0,parentControlId:i}}return{isInParent:!1}}}return{isInParent:!1}}function Qc(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&Zc(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 V=wc(d,l-1);if(V){const X=cr(d,V.labelIndex,e);e.getGlobalEvent().setCanvasEventAbility(),n.setRange(X,X),e.render({curIndex:X});return}}const f=e.getPosition().getPositionList(),p=f[l],C=f[l-1],I=p&&C&&p.rowIndex===C.rowIndex,m=R?.controlComponent===s.ControlComponent.PREFIX||R?.controlComponent===s.ControlComponent.PRETEXTFIX||R?.controlComponent===s.ControlComponent.PRE_TEXT||R?.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT,P=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,M=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,y=h?.control?.type===s.ControlType.TEXT&&(h.controlComponent===s.ControlComponent.PREFIX||h.controlComponent===s.ControlComponent.PRE_TEXT),Y=F&&R?.controlId===h?.controlId&&R?.originControlId===h?.originControlId&&R?.controlComponent===s.ControlComponent.VALUE,D=!!h&&!h.controlId&&!h.control;if(M&&m&&E&&I)return;const{isInParent:O,parentControlId:b}=vc(d,l,R);if(P&&E&&I&&O&&!(h?.controlId===b&&!h?.originControlId&&(h?.controlComponent===s.ControlComponent.VALUE||h?.controlComponent===s.ControlComponent.PLACEHOLDER))){if(R.originControlId&&b)for(let X=l;X<d.length;X++){const N=d[X];if(Fi(N,b)){if(N.controlComponent===s.ControlComponent.VALUE){n.setRange(X,X),e.render({curIndex:X,isSubmitHistory:!1});return}if(N.controlComponent===s.ControlComponent.POSTFIX||N.controlComponent===s.ControlComponent.POSTTEXTFIX||N.controlComponent===s.ControlComponent.POST_TEXT)return}N.controlId!==b&&N.originControlId}return}if(P&&E&&I&&!O&&!(D&&!M&&!F)){if(y)return;if(g)return;{const V=l-1;c=i.removeControl(V),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(V,V),e.render({curIndex:V,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}}if(F&&h?.originControlId&&O&&b&&I){for(let V=l+1;V<d.length;V++){const X=d[V];if(Fi(X,b)){if(X.controlComponent===s.ControlComponent.VALUE||X.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(V,V),e.render({curIndex:V,isSubmitHistory:!1});return}break}if(X.controlId&&X.controlId!==b&&X.originControlId!==b)break}for(let V=l-1;V>=0;V--){const X=d[V];if(Fi(X,b)){if(X.controlComponent===s.ControlComponent.VALUE||X.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(V,V),e.render({curIndex:V,isSubmitHistory:!1});return}break}if(X.controlId&&X.controlId!==b&&X.originControlId!==b)break}return}if(e.getMode()===s.EditorMode.FORM&&F&&h?.originControlId&&I){const V=bo(d,h.originControlId);if(!V)return;for(let X=l-1;X>=0;X--){const N=d[X];if(N.controlId===V&&!N.originControlId){if(N.controlComponent===s.ControlComponent.VALUE||N.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(X,X),e.render({curIndex:X,isSubmitHistory:!1});return}if(N.controlComponent===s.ControlComponent.PREFIX||N.controlComponent===s.ControlComponent.PRE_TEXT||N.controlComponent===s.ControlComponent.PRETEXTFIX||N.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)return}if(N.controlId&&N.controlId!==V&&N.originControlId!==V)break}return}if(F&&h?.controlId&&I&&!Y){const V=l;c=i.removeControl(V),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(V,V),e.render({curIndex:V,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 I=T[h];if(I.value===K){I.listId&&e.getListParticle().unsetList(),o.preventDefault();return}}const f=T[l];if(g&&f.rowFlex&&f.value===K){const I=n.getRangeRowElementList();if(I){const m=T[l-1];I.forEach(P=>{P.rowFlex=m?.rowFlex})}}const p=f.value===K?T[l-1]:f,C=T[r+1];if(p?.titleId&&C?.titleId&&p.level===C.level&&p.titleId!==C.titleId){const I=p.titleId,m=C.titleId;let P=r+1;for(;P<T.length&&T[P]?.titleId===m;)T[P].titleId=I,P++}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 dr(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 Kc(o){const t=o.getDraw(),n=t.getRange().getRange(),i=t.getElementList(),l=i[n.startIndex+1];if(!ae(l))return;const r=n.startIndex+1;for(;r<i.length;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE&&a.subTemplateExpanded){dr(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||!ae(d))break}}function Hc(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()&&Kc(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=dr(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 C=e.getTd();if(C?.linkTdNextId){const I=e.getTdById(C.linkTdNextId);I&&(p=!1,e.spliceElementList(I.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 _c(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),oe(a,[u],i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),o.shiftKey&&d.areaId&&d.areaId!==a[l+1]?.areaId&&(u=pe(u,cn)),!(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 C=[...ue],I=p.controlComponent===s.ControlComponent.POSTFIX||p.controlComponent===s.ControlComponent.POSTTEXTFIX||p.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||p.controlComponent===s.ControlComponent.POST_TEXT,m=p.control?.type===s.ControlType.BUTTON&&!p.control?.buttonText;!I&&!m&&C.push(...Xe),C.forEach(P=>{const E=p[P];E!==void 0&&(u[P]=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 C=l;for(;C+1<a.length&&a[C+1]?.controlId===p;)C++;e.spliceElementList(a,C+1,0,[u]),g=C+1}else if(h&&R.getIsRangeWithinControl())g=R.setValue([u]),R.emitControlContentChange();else{const C=e.getPosition().getCursorPosition();if(!C)return;const{index:I}=C;if(r){if(e.spliceElementList(a,I+1,0,[u]),d.titleId&&a[I+2]?.titleId===d.titleId){const m=ft();let P=I+2;for(;P<a.length&&a[P]?.titleId===d.titleId;)a[P].titleId=m,P++}}else e.spliceElementList(a,i+1,l-i,[u]);g=I+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),o.preventDefault()}function ur(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 Ac(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,C=T&&!p?g.getActiveTextControlLimit():null,I=h[a],m=I?.controlComponent===s.ControlComponent.PREFIX||I?.controlComponent===s.ControlComponent.PRETEXTFIX||I?.controlComponent===s.ControlComponent.PRE_TEXT;let P=!1;if(m&&I?.originControlId){const O=I.originControlId;for(let b=a-1;b>=0;b--){const V=h[b];if(V.controlId===O&&!V.originControlId){P=!0;break}if(V.controlId&&V.controlId!==O&&V.originControlId!==O)break}}if(T&&!p&&g.getActiveControl()&&m&&!C&&!P){g.initNextControl({direction:Jt.UP});return}let E=1;if(Qe(o)){const O=e.getLetterReg(),b=o.shiftKey&&!R&&d===l?.index?u:d;if(O.test(h[b]?.value)){let V=b-1;for(;V>0;){const X=h[V];if(!O.test(X.value))break;E++,V--}}}if(T&&!p){const O=h[d],b=O?.controlId;if(b&&O?.controlComponent===s.ControlComponent.VALUE){let V=!1;for(let X=d;X>=0;X--){const N=h[X];if(N.controlId!==b)break;if(N.control?.type===s.ControlType.TEXTFIELD){V=!0;break}}if(V){if(O.controlComponent===s.ControlComponent.VALUE&&ur(O))return;const X=d-E;if(X>=0){const N=h[X];if(N&&N.controlId===b&&N.controlComponent===s.ControlComponent.VALUE&&ur(N))return}}}}const M=C?Math.max(d-E,C.startIndex):d-E;let F=M,y=M;if(o.shiftKey&&l&&(d!==u?d===l.index?(F=d,y=u-E):(F=M,y=u):y=u),!o.shiftKey){const O=h[d];if(O.type===s.ElementType.TABLE){const b=O.trList,V=b.length-1,X=b[V],N=X.tdList.length-1,L=X.tdList[N];i.setPositionContext({isTable:!0,index:d,trIndex:V,tdIndex:N,tdId:L.id,trId:X.id,tableId:O.id}),F=L.value.length-1,y=F}else if(O.tableId&&d===0){const V=e.getOriginalElementList()[r.index],X=e.getTd();if(X?.linkTdPrevId){const N=e.getTdById(X.linkTdPrevId);N&&(i.setPositionContext({...r,isTable:!0,index:N.tableIndex,trIndex:N.trIndex,tdId:N.id,trId:N.trId,tableId:N.tableId}),F=N.value.length-1,y=F)}else{const N=V.trList;t:for(let L=0;L<N.length;L++){const W=N[L];if(W.id!==O.trId)continue;const S=W.tdList;for(let U=0;U<S.length;U++)if(S[U].id===O.tdId){if(L===0&&U===0)i.setPositionContext({isTable:!1}),F=r.index-1,y=F,e.getTableTool().dispose();else{let Q=L,w=U-1;w<0&&(Q=L-1,w=N[Q].tdList.length-1);const q=N[Q],G=q.tdList[w];i.setPositionContext({isTable:!0,index:r.index,trIndex:Q,tdIndex:w,tdId:G.id,trId:q.id,tableId:O.tableId}),F=G.value.length-1,y=F}break t}}}}}if(!~F||!~y)return;const Y=e.getElementList();F=wn(Y,F),y=wn(Y,y),c.setRange(F,y);const D=F===y;e.updateTableTool(),e.render({curIndex:D?F:void 0,isSetCursor:D,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function Rr(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 kc(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,C=f&&p===s.ControlType.TEXT,I=f&&!C?T.getActiveTextControlLimit():null,m=g[r],P=m?.controlComponent===s.ControlComponent.POSTFIX||m?.controlComponent===s.ControlComponent.POSTTEXTFIX||m?.controlComponent===s.ControlComponent.POST_TEXT;let E=!1;if(P&&m?.originControlId){const V=m.originControlId;for(let X=r+1;X<g.length;X++){const N=g[X];if(N.controlId===V&&!N.originControlId){E=!0;break}if(N.controlId&&N.controlId!==V&&N.originControlId!==V)break}}if(f&&!C&&T.getActiveControl()&&P&&!I&&!E){T.initNextControl({direction:Jt.DOWN});return}let M=1;if(Qe(o)){const V=e.getLetterReg(),X=o.shiftKey&&!h&&u===l?.index?R:u;if(V.test(g[X+1]?.value)){let N=X+2;for(;N<g.length;){const L=g[N];if(!V.test(L.value))break;M++,N++}}}if(f&&!C){const V=g[R],X=V?.controlId;if(X&&V?.controlComponent===s.ControlComponent.VALUE){let N=!1;for(let L=R;L>=0;L--){const W=g[L];if(W.controlId!==X)break;if(W.control?.type===s.ControlType.TEXTFIELD){N=!0;break}}if(N){if(V.controlComponent===s.ControlComponent.VALUE&&Rr(V))return;const L=R+M;if(L<g.length){const W=g[L];if(W&&W.controlId===X&&W.controlComponent===s.ControlComponent.VALUE&&Rr(W))return}}}}const F=I?Math.min(R+M,I.endIndex):R+M;let y=F,Y=F;if(o.shiftKey&&l&&(u!==R?u===l.index?(y=u,Y=F):(y=u+M,Y=R):y=u),!o.shiftKey){const V=g[R],X=g[R+1];if(X?.type===s.ElementType.TABLE){const L=X.trList[0],W=L.tdList[0];i.setPositionContext({isTable:!0,index:R+1,trIndex:0,tdIndex:0,tdId:W.id,trId:L.id,tableId:X.id}),y=0,Y=0}else if(V.tableId&&!X){const N=e.getTd(),L=N?.linkTdNextId?e.getTdById(N.linkTdNextId):void 0;if(L?.value.length)i.setPositionContext({...c,isTable:!0,index:L.tableIndex,trIndex:L.trIndex,tdId:L.id,trId:L.trId,tableId:L.tableId}),y=0,Y=y;else{const S=e.getOriginalElementList()[c.index].trList;t:for(let U=0;U<S.length;U++){const v=S[U];if(v.id!==V.trId)continue;const Q=v.tdList;for(let w=0;w<Q.length;w++)if(Q[w].id===V.tdId){if(U===S.length-1&&w===Q.length-1)i.setPositionContext({isTable:!1}),y=c.index,Y=y,g=e.getElementList(),e.getTableTool().dispose();else{let G=U,H=w+1;H>Q.length-1&&(G=U+1,H=0);const z=S[G],_=z.tdList[H];i.setPositionContext({isTable:!0,index:c.index,trIndex:G,tdIndex:H,tdId:_.id,trId:z.id,tableId:V.tableId}),y=0,Y=y}break t}}}}}const D=g.length-1;if(y>D||Y>D)return;const O=e.getElementList();y=wn(O,y,s.LocationPosition.AFTER),Y=wn(O,Y,s.LocationPosition.AFTER),d.setRange(y,Y);const b=y===Y;e.updateTableTool(),e.render({curIndex:b?y:void 0,isSetCursor:b,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function Gc(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?Jt.UP:Jt.DOWN});else if(T&&l.getIsRangeWithinControl())o.preventDefault(),l.initNextControl({direction:o.shiftKey?Jt.UP:Jt.DOWN});else{o.preventDefault();const f=r.getRangeAnchorStyle(a,d),C={...f?$t(f,Xe):null,type:s.ElementType.TAB,value:""};oe(a,[C],c,{editorOptions:e.getOptions()}),e.insertElementList([C])}}function yi(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 xc(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:C,tableId:I}=g;if(u){const m=e.getOriginalElementList();if(p===0)if(m[f].originalId){const E=f-1,M=m[E];for(let F=M.trList.length-1;F>=0;F--){const y=M.trList[F].tdList.find(Y=>Y.tdIndex===C);if(y?.value.length){i.setPositionContext({isTable:!0,tableId:M.id,index:E,trIndex:F,tdIndex:C}),R=y.value.length-1,h=y.value.length-1;break}}}else i.setPositionContext({isTable:!1}),R=f-1,h=R,e.getTableTool().dispose();else{let P=-1,E=-1;const M=m[f].trList,F=M[p].tdList[C].colIndex;t:for(let D=p-1;D>=0;D--){const b=M[D].tdList;for(let V=0;V<b.length;V++){const X=b[V];if(X.colIndex===F||X.colIndex+X.colspan-1>=F&&X.colIndex<=F){P=D,E=V;break t}}}if(!~P||!~E)return;const y=M[P],Y=y.tdList[E];i.setPositionContext({isTable:!0,index:f,trIndex:P,tdIndex:E,tdId:Y.id,trId:y.id,tableId:I}),R=Y.value.length-1,h=R}}else{const m=e.getOriginalElementList(),P=m[f],E=P.trList;if(p===E.length-1){const M=f+1,F=m[M];if(F&&[P.id,P.originalId].includes(F.originalId)){for(let Y=C;Y>=0;Y--)if(F.trList[0].tdList[Y].value.length){i.setPositionContext({isTable:!0,index:M,tableId:F.id,trIndex:0,tdIndex:Y}),R=0,h=0;break}}else i.setPositionContext({isTable:!1}),R=f,h=R,e.getTableTool().dispose()}else{let M=-1,F=-1;const y=E[p].tdList[C].colIndex;t:for(let O=p+1;O<E.length;O++){const V=E[O].tdList;for(let X=0;X<V.length;X++){const N=V[X];if(N.colIndex===y||N.colIndex+N.colspan-1>=y&&N.colIndex<=y){M=O,F=X;break t}}}if(!~M||!~F)return;const Y=E[M],D=Y.tdList[F];i.setPositionContext({isTable:!0,index:f,trIndex:M,tdIndex:F,tdId:D.id,trId:Y.id,tableId:I}),R=D.value.length-1,h=R}}}else{let f=l;o.shiftKey&&(a===l.index?f=d[c]:f=d[a]);const{index:p,rowNo:C,rowIndex:I,coordinate:{rightTop:[m]}}=f;if(u&&I===0||!u&&I===e.getRowCount()-1)return;const P=yi({positionList:d,index:p,rowNo:C,isUp:u,cursorX:m});if(P<0)return;R=P,h=P,o.shiftKey&&(a!==c?a===l.index?R=a:h=c:u?h=c:R=a);const M=e.getElementList()[P];if(M.type===s.ElementType.TABLE){const{scale:F}=e.getOptions(),y=e.getMargins(),Y=M.trList;let D=-1,O=-1,b=-1;if(u)t:for(let V=Y.length-1;V>=0;V--){const N=Y[V].tdList;for(let L=0;L<N.length;L++){const W=N[L],S=W.x*F+y[3],U=W.width*F;if(m>=S&&m<=S+U){const v=W.positionList,Q=v[v.length-1],w=yi({positionList:v,index:Q.index+1,rowNo:Q.rowNo-1,isUp:u,cursorX:m})||Q.index;D=V,O=L,b=w;break t}}}else t:for(let V=0;V<Y.length;V++){const N=Y[V].tdList;for(let L=0;L<N.length;L++){const W=N[L],S=W.x*F+y[3],U=W.width*F;if(m>=S&&m<=S+U){const v=W.positionList,Q=yi({positionList:v,index:-1,rowNo:-1,isUp:u,cursorX:m})||0;D=V,O=L,b=Q;break t}}}if(~D&&~O&&~b){const V=Y[D],X=V.tdList[O];i.setPositionContext({isTable:!0,index:P,trIndex:D,tdIndex:O,tdId:X.id,trId:V.id,tableId:M.id}),R=b,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?Jt.UP:Jt.DOWN}),e.updateTableTool())}function Bc(o){return o.key.length===1&&!o.ctrlKey&&!o.metaKey&&!o.altKey}function Jc(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=C=>!!C?.controlId&&C.controlId===R.controlId&&(C.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 $c(o,t){if(t.isComposing)return;const e=t.getDraw();if(o.key===s.KeyMap.Backspace)Qc(o,t);else if(o.key===s.KeyMap.Delete)Hc(o,t);else if(o.key===s.KeyMap.Enter)_c(o,t);else if(o.key===s.KeyMap.Left)Ac(o,t);else if(o.key===s.KeyMap.Right)kc(o,t);else if(o.key===s.KeyMap.Up||o.key===s.KeyMap.Down)xc(o,t);else if(Qe(o)&&o.key.toLocaleLowerCase()===s.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return;e.getHistoryManager().undo(),o.preventDefault()}else if(Qe(o)&&o.key.toLocaleLowerCase()===s.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return;e.getHistoryManager().redo(),o.preventDefault()}else if(Qe(o)&&o.key.toLocaleLowerCase()===s.KeyMap.C)t.copy(),o.preventDefault();else if(Qe(o)&&o.key.toLocaleLowerCase()===s.KeyMap.X)t.cut(),o.preventDefault();else if(Qe(o)&&o.key.toLocaleLowerCase()===s.KeyMap.A)t.selectAll(),o.preventDefault();else if(Qe(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?Gc(o,t):Bc(o)&&Jc(o,t)}function zc(o){return/[\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]/.test(o)}function jc(o){return/[a-zA-Z]/.test(o)}function qc(o,t){return zc(o)?t:jc(o)?"Times New Roman":t}function Do(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 Ne(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 bi(o){return!!o?.originControlId&&Do(o)}function qn(o){return!!o?.originControlId&&Ne(o)}function td(o,t){return!o||!t?!1:!!o.originControlId&&!!t.originControlId&&o.originControlId===t.originControlId&&o.controlId!==t.controlId}function un(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 hr(o,t){if(t)return o.find(e=>e.controlId===t&&!e.originControlId&&!!e.control?.type)}function gr(o,t,e){if(!t?.originControlId||e?.originControlId!==t.originControlId||!t.controlId||!e.controlId||t.controlId===e.controlId||!Ne(t)||!Do(e))return;const n=hr(o,t.originControlId);if(n?.control?.type===s.ControlType.TEXTFIELD)return n}function Di(o,t,e){Xe.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 Vi(o,t,e,n){o.controlId=t,o.control=e,o.controlComponent=s.ControlComponent.VALUE,delete o.originControlId,Di(o,e,n)}function Wi(o,t,e="input"){const n=re(),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=Ot=>{l.setPopupAwakeDisabled(!0);try{return Ot()}finally{l.setPopupAwakeDisabled(!1)}},p=()=>{f(()=>l.initControl())},C=(Ot,nt)=>{f(()=>{T.setRange(Ot,nt)})};let I=l.getActiveControl();const m=i.getElementList()[T.getRange().endIndex],P=m?.control?.type===s.ControlType.TEXT&&!!m?.originControlId&&(m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRE_TEXT||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POST_TEXT||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||m.controlComponent===s.ControlComponent.PLACEHOLDER);if(!I&&(l.getIsRangeWithinControl()||P)&&(p(),I=l.getActiveControl()),I){const Ot=I.getElement(),nt=i.getElementList()[T.getRange().endIndex],Ut=Ot?.controlId===nt?.controlId&&(Ot?.originControlId||null)===(nt?.originControlId||null),at=!!nt&&nt.controlComponent===s.ControlComponent.VALUE&&!!nt.controlId&&!nt.originControlId&&T.getRange().endIndex>0&&i.getElementList()[T.getRange().endIndex-1]?.originControlId===nt.controlId;(!Ut||at)&&(p(),I=l.getActiveControl())}const{endIndex:E}=T.getRange(),M=i.getElementList(),F=M[E],y=M[E+1];if(F?.type===s.ElementType.SUB_TEMPLATE&&y?.type===s.ElementType.SUB_TEMPLATE)return;const Y=i.getMode()===s.EditorMode.FORM;if(Y){const Ot=T.getRange();if(!(i.getElementList()[Ot.endIndex]?.control?.type===s.ControlType.TEXT)){const at=l.getActiveTextControlLimit();if(!I||!l.getIsRangeWithinControl()&&!l.getIsRangeInPostfix())return;if(at){const pt=T.getRange();if(pt.startIndex<at.startIndex||pt.endIndex>at.endIndex){const it=Math.min(Math.max(pt.endIndex,at.startIndex),at.endIndex);f(()=>{T.setRange(it,it),i.render({curIndex:it,isSubmitHistory:!1})});return}}const{endIndex:Gt}=T.getRange(),k=i.getElementList(),ot=k[Gt];if(!ot?.originControlId){if(ot?.controlId&&ot?.controlComponent===s.ControlComponent.VALUE){let pt=!1;for(let it=Gt;it>=0;it--){const de=k[it];if(de.controlId!==ot.controlId||de.originControlId)break;if(de.control?.type===s.ControlType.TEXTFIELD){pt=!0;break}}if(pt)return}}}}const D=T.getDefaultStyle()||t.compositionInfo?.defaultStyle||null,O=t.compositionInfo?.perfStartTime,b=nd(t,i.getElementList());g||i.getCursor().clearAgentDomValue();const{TEXT:V,HYPERLINK:X,SUBSCRIPT:N,SUPERSCRIPT:L,DATE:W,TAB:S}=s.ElementType,U=o.replaceAll(`
115
- `,K),{startIndex:v,endIndex:Q}=T.getRange(),w=T.getRangeAnchorStyle(b,v);if(!w)return;const q=v>0?b[v-1]:null,G=!!(w.controlId||w.control),z={...!G&&q?q:w,...D},_=i.isDesignMode(),dt=b[Q+1],Ct=un(b,w.originControlId,i.getMode()),Kt=un(b,dt?.originControlId,i.getMode()),ge=!w.originControlId&&!dt?.originControlId&&Ne(w)&&Do(dt)&&!!w.controlId&&!!dt.controlId&&w.controlId!==dt.controlId,se=qn(w)&&bi(dt)&&!Ct&&!Kt,J=i.getMode()===s.EditorMode.EDIT?gr(b,w,dt):void 0,lt=!!w.originControlId&&Ne(w)&&dt?.controlId===w.originControlId&&!dt.originControlId&&dt.control?.type===s.ControlType.TEXTFIELD&&Ne(dt),$=!!w.originControlId&&Ne(w)&&dt?.controlId===w.originControlId&&!dt.originControlId&&dt.control?.type===s.ControlType.TEXTFIELD&&dt.controlComponent===s.ControlComponent.VALUE,tt=!!Ct&&Ct===Kt&&!!w.controlId&&!!dt?.controlId&&w.controlId!==dt.controlId&&(qn(w)||bi(dt))?Ct:null;if(Y&&(ge||se))return;const x=Do(dt)&&!dt?.originControlId,Rt=Ne(w)&&!w.originControlId||w.type===s.ElementType.CONTROL&&w.controlComponent===s.ControlComponent.VALUE&&dt?.type!==s.ElementType.CONTROL&&!w.originControlId,ht=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],mt=(Ot,nt)=>!!(Ot?.controlId&&Ot.controlId===nt?.controlId&&(Ot.originControlId||null)===(nt.originControlId||null)),Pt=(Ot,nt)=>{if(Ot?.control?.type)return Ot.control.type;if(Ot?.controlId){for(let Ut=nt;Ut>=0;Ut--){const at=b[Ut];if(!mt(Ot,at))break;if(at.control?.type)return at.control.type}for(let Ut=nt+1;Ut<b.length;Ut++){const at=b[Ut];if(!mt(Ot,at))break;if(at.control?.type)return at.control.type}}},vt=(Ot,nt)=>{const Ut=Pt(Ot,nt);return!!(Ut&&ht.includes(Ut))},Lt=Ot=>{const nt=b[Ot];let Ut=Ot;for(let at=Ot+1;at<b.length&&mt(nt,b[at]);at++)Ut=at;return Ut},At=!!(vt(w,v)&&w.controlComponent===s.ControlComponent.VALUE&&!w.originControlId&&mt(w,dt)&&Ne(dt)&&!dt?.value),ne=!!(vt(w,v)&&w.controlComponent===s.ControlComponent.VALUE&&w.originControlId&&mt(w,dt)&&Ne(dt))?un(b,w.originControlId,i.getMode()):null,Yt=hr(b,ne),Xt=x||Rt||At,bt=Xt?{...w,type:void 0,control:void 0,controlId:void 0,controlComponent:void 0,originControlId:void 0,color:r.defaultColor,highlight:void 0}:w,Ft=Xt||G?bt:z,Et=yt(U).map(Ot=>{const nt={value:Ot};if(_||!Ft.title?.disabled&&!Ft.control?.disabled){const Ut=b[Q+1];(!Ft.type||Ft.type===V||Ft.type===X&&Ut?.type===X||Ft.type===W&&Ut?.type===W||Ft.type===N&&Ut?.type===N||Ft.type===L&&Ut?.type===L)&&La.forEach(at=>{if(at==="groupIds"&&!Ut?.groupIds)return;const Gt=Ft[at];Gt!==void 0&&(nt[at]=Gt)}),(D||Ft.type===S)&&Xe.forEach(at=>{const Gt=D?.[at]||Ft[at];Gt!==void 0&&(nt[at]=Gt)}),g&&(nt.underline=!0)}if(!Xt){const Ut=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(lt||$||J){const k=J||dt;nt.controlId=k.controlId,nt.control=k.control,nt.controlComponent=s.ControlComponent.VALUE,delete nt.originControlId,Di(nt,k.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)&&dt?.controlId&&dt.controlId!==w.controlId&&td(w,dt),Gt=w.controlId&&w.originControlId&&(w.controlComponent===s.ControlComponent.VALUE||w.controlComponent===s.ControlComponent.PLACEHOLDER);if(!lt&&!$&&!J&&Ut&&!nt.controlId){const k=un(b,w.originControlId,i.getMode());if(!k)return nt;let ot=null;for(let pt=v;pt>=0;pt--){const it=b[pt];if(Je(it,k)&&it.control){ot=it.control;break}}nt.controlId=k,nt.controlComponent=s.ControlComponent.VALUE,ot&&(nt.control=ot),Di(nt,ot,r.defaultColor)}else if(at&&!nt.controlId){if(dt?.controlId&&dt.controlId!==w.controlId)if(dt.controlComponent===s.ControlComponent.PREFIX||dt.controlComponent===s.ControlComponent.PRETEXTFIX)for(let k=v;k>=0;k--){const ot=b[k];if(ot.controlId===w.controlId&&(ot.controlComponent===s.ControlComponent.PREFIX||ot.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let pt=k-1;pt>=0;pt--){const it=b[pt];if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.PRETEXTFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRE_TEXT)){nt.controlId=it.controlId,nt.controlComponent=s.ControlComponent.VALUE,it.control&&(nt.control=it.control);break}if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}else(dt.controlComponent===s.ControlComponent.POSTFIX||dt.controlComponent===s.ControlComponent.POSTTEXTFIX)&&(nt.controlId=dt.controlId,nt.controlComponent=s.ControlComponent.VALUE,dt.control&&(nt.control=dt.control));if(!nt.controlId)for(let k=v;k>=0;k--){const ot=b[k];if(ot.controlId===w.controlId&&(ot.controlComponent===s.ControlComponent.PREFIX||ot.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let pt=k-1;pt>=0;pt--){const it=b[pt];if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.PRETEXTFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRE_TEXT)){nt.controlId=it.controlId,nt.controlComponent=s.ControlComponent.VALUE,it.control&&(nt.control=it.control);break}if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}}else if(Gt&&!nt.controlId){const k=w.controlId;let ot=w.control;if(!ot)for(let pt=v;pt>=0;pt--){const it=b[pt];if(it.controlId===k&&it.control&&(ot=it.control,it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX))break}nt.controlId=k,nt.originControlId=w.originControlId,nt.controlComponent=s.ControlComponent.VALUE,ot&&(nt.control=ot)}else if(w.controlId){let k=w.control;if(!k)for(let ot=v;ot>=0;ot--){const pt=b[ot];if(Je(pt,w.controlId)&&pt.control){k=pt.control;break}}nt.controlId||(nt.controlId=w.controlId),k&&!nt.control&&(nt.control=k),nt.controlComponent||(nt.controlComponent=s.ControlComponent.VALUE)}else if(!nt.controlId&&!nt.control&&dt?.originControlId&&(dt.controlComponent===s.ControlComponent.PREFIX||dt.controlComponent===s.ControlComponent.PRETEXTFIX)){const k=un(b,dt.originControlId,i.getMode());if(!k)return nt;let ot=null;for(let pt=Q;pt>=0;pt--){const it=b[pt];if(Je(it,k)&&it.control){ot=it.control;break}}nt.controlId=k,nt.controlComponent=s.ControlComponent.VALUE,ot&&(nt.control=ot)}}if(Ot&&Ot!==K){const Ut=qc(Ot,r.defaultFont);nt.font=Ut}return nt});let Mt;const St=a[u],Vt=a[u+1],me=a[u-1];if(g)Mt=v;else{const Ot=k=>{if(Et?.length)for(let ot=0;ot<Et.length;ot++)b.splice(k+ot,0,Et[ot]);return k+Et.length-1},nt=v+1,Ut=At?Lt(v)+1:nt,at=()=>{let k=null,ot,pt=null;const it=i.getMode()===s.EditorMode.EDIT?gr(a,St,Vt):void 0;if(it?.controlId?(k=it.controlId,ot=it.control?.type):i.getMode()===s.EditorMode.EDIT&&qn(St)&&Vt?.controlId===St.originControlId&&!Vt.originControlId&&Vt.control?.type===s.ControlType.TEXTFIELD&&(Vt.controlComponent===s.ControlComponent.VALUE||Ne(Vt))?(k=St.originControlId,ot=s.ControlType.TEXTFIELD):qn(St)?k=un(a,St.originControlId,i.getMode()):bi(Vt)?k=un(a,Vt.originControlId,i.getMode()):tt?k=tt:St?.control?.type===s.ControlType.TEXT&&St.controlId&&!St.originControlId&&Ne(St)&&me?.originControlId===St.controlId&&(k=St.controlId,pt={startIndex:u-1,endIndex:u-1}),!k)return null;if(!ot)for(let kt=u;kt>=0;kt--){const zt=a[kt];if(Je(zt,k)&&zt.control?.type){ot=zt.control.type;break}if(zt.controlId&&zt.controlId!==k&&zt.originControlId!==k)break}return ot!==s.ControlType.TEXT&&!(i.getMode()===s.EditorMode.EDIT&&ot===s.ControlType.TEXTFIELD)?null:{parentControlId:k,activationIndex:(()=>{for(let kt=u+1;kt<a.length;kt++){const zt=a[kt];if(Je(zt,k))return kt;if(zt.controlId&&zt.controlId!==k&&zt.originControlId!==k)break}for(let kt=u;kt>=0;kt--){const zt=a[kt];if(Je(zt,k))return kt;if(zt.controlId&&zt.controlId!==k&&zt.originControlId!==k)break}return u})(),boundaryRange:pt}};v!==Q&&(i.removeSplitTdOtherRangeElements(),i.spliceElementList(b,nt,Q-v));const Gt=at();if(ne&&Yt?.control){const k=Lt(v);Et.forEach(ot=>{Vi(ot,ne,Yt.control,r.defaultColor)}),oe(b,Et,k,{editorOptions:r}),i.spliceElementList(b,k+1,0,Et),Mt=k+Et.length}else if(Gt){const{parentControlId:k,activationIndex:ot,boundaryRange:pt}=Gt;C(ot,ot),p();const it=l.getActiveControl(),de=Vt?.controlId===k&&!Vt?.originControlId&&Vt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,kt=!!(St?.originControlId&&qn(St)&&de!==-1),zt=pt||(kt?{startIndex:u,endIndex:u}:de!==-1?{startIndex:u,endIndex:de}:{startIndex:v,endIndex:Q});C(zt.startIndex,zt.endIndex),it&&it.getElement()?.controlId===k&&(it.getElement()?.control?.type===s.ControlType.TEXT||it.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Et.forEach($n=>{Vi($n,k,it.getElement().control,r.defaultColor)}),Mt=it.setValue(Et,{range:zt,elementList:b}),l.emitControlContentChange(),C(Mt,Mt),p()):Xt?Mt=Ot(Ut):(Mt=l.setValue(Et),l.emitControlContentChange())}else if(Xt)Mt=Ot(Ut);else if(St?.originControlId&&(St.controlComponent===s.ControlComponent.POSTFIX||St.controlComponent===s.ControlComponent.POST_TEXT||St.controlComponent===s.ControlComponent.POSTTEXTFIX||St.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))if(I?.getElement()?.control?.type===s.ControlType.TEXT&&I.getElement()?.controlId===St.controlId&&(I.getElement()?.originControlId||null)===(St.originControlId||null))Mt=l.setValue(Et),l.emitControlContentChange();else{const ot=un(a,St.originControlId,i.getMode());if(!ot){Mt=Ot(nt);return}let pt;for(let de=u;de>=0;de--){const kt=a[de];if(Je(kt,ot)&&kt.control?.type){pt=kt.control.type;break}if(kt.controlId&&kt.controlId!==ot&&kt.originControlId!==ot)break}if(pt===s.ControlType.TEXT||i.getMode()===s.EditorMode.EDIT&&pt===s.ControlType.TEXTFIELD){const de=()=>{for(let Le=u+1;Le<a.length;Le++){const Ve=a[Le];if(Je(Ve,ot))return Le;if(Ve.controlId&&Ve.controlId!==ot&&Ve.originControlId!==ot)break}for(let Le=u;Le>=0;Le--){const Ve=a[Le];if(Je(Ve,ot))return Le;if(Ve.controlId&&Ve.controlId!==ot&&Ve.originControlId!==ot)break}return u},kt=Vt?.controlId===ot&&Vt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,zt=kt!==-1?{startIndex:u,endIndex:kt}:{startIndex:u,endIndex:u},$n=de();C($n,$n),p();const Tn=l.getActiveControl();C(zt.startIndex,zt.endIndex),Tn&&Tn.getElement()?.controlId===ot&&(Tn.getElement()?.control?.type===s.ControlType.TEXT||Tn.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Et.forEach(Le=>{Vi(Le,ot,Tn.getElement().control,r.defaultColor)}),Mt=Tn.setValue(Et,{range:zt,elementList:b}),l.emitControlContentChange(),C(Mt,Mt),p()):Mt=Ot(nt)}else Mt=Ot(nt)}else if((St?.control?.type===s.ControlType.NUMBER||Vt?.control?.type===s.ControlType.NUMBER)&&I?.getElement()?.control?.type===s.ControlType.NUMBER&&l.getIsRangeWithinControl()){const k=l.getActiveControl();k&&typeof k.awake=="function"&&k.awake(),Mt=v}else if((St?.control?.type===s.ControlType.SELECT||Vt?.control?.type===s.ControlType.SELECT)&&I?.getElement()?.control?.type===s.ControlType.SELECT&&l.getIsRangeWithinControl()){const k=l.getActiveControl();k&&typeof k.awake=="function"&&k.awake(),Mt=v}else if(I?.getElement()?.control?.type===s.ControlType.DATE&&l.getIsRangeWithinControl()){const k=l.getActiveControl();k&&typeof k.awake=="function"&&k.awake(),Mt=v}else St?.control?.type===s.ControlType.BUTTON||Vt?.control?.type===s.ControlType.BUTTON?I?.getElement()?.control?.type===s.ControlType.BUTTON&&I.getElement()?.control?.editable!==!1&&l.getIsRangeWithinControl()?(Mt=l.setValue(Et),l.emitControlContentChange()):Mt=v:I&&l.getIsRangeWithinControl()?(Mt=l.setValue(Et),l.emitControlContentChange()):(St?.type==="control"||Vt?.type==="control")&&!Xt?Mt=Ot(nt):(oe(b,Et,v,{editorOptions:r}),i.spliceElementList(b,nt,0,Et),Mt=v+Et.length)}if(~Mt&&!g){const Ot=re()-n,nt=re();f(()=>{T.setRange(Mt,Mt),i.render({curIndex:Mt,isSubmitHistory:!g,traceLabel:`input:${e}`})}),Ri(r,`input:${e}`,re()-n,[{label:"mutate",duration:Ot},{label:"renderCall",duration:re()-nt}],{isComposing:g,textLength:Et.length,compositionChainDuration:e==="compositionend"&&O!==void 0?Number((re()-O).toFixed(2)):void 0})}g&&(t.compositionInfo={value:U,startIndex:Mt,endIndex:Q,defaultStyle:D,perfStartTime:n})}function ed(o){o.compositionInfo&&(o.compositionInfo=null)}function nd(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 od(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 I=0;I<h.length;I++){const m=h[I];if(m.pageNo>f)break;m.pageNo===f&&m.rowNo===T&&p.push(I)}const C=p[0]-1;r=C<0?0:C,a=p[p.length-1]}const c=t.getOptions();await or(l.slice(r+1,a+1),c);const d=t.getControl();let u;d.getActiveControl()&&d.getIsRangeWithinControl()?(u=d.cut(),d.emitControlContentChange()):(t.spliceElementList(l,r+1,a-r),u=r),e.setRange(u,u),t.render({curIndex:u})}function id(o){return o.replace(/^(?:\r\n|\r|\n)+|(?:\r\n|\r|\n)+$/g,"")}async function sd(o,t){const e=o.getDraw(),n=e.getMode()===s.EditorMode.COMPARE,i=n||t?.isPlainText,{copy:l}=e.getOverride();if(l&&l()?.preventDefault!==!1)return;const r=e.getRange();let a=null;if(r.getRange().isCrossRowCol){const d=r.getRangeTableElement();if(!d)return;const u=e.getTableParticle().getRangeRowCol();if(!u)return;const R={type:s.ElementType.TABLE,value:"",colgroup:[],trList:[]},h=u[0],g=h[0].colIndex,T=h[h.length-1],f=T.colIndex+T.colspan-1;for(let p=g;p<=f;p++)R.colgroup.push(d.colgroup[p]);for(let p=0;p<u.length;p++){const C=u[p],I=d.trList[C[0].rowIndex],m={tdList:[],height:I.height,minHeight:I.minHeight};for(let P=0;P<C.length;P++)m.tdList.push(C[P]);R.trList.push(m)}a=n?[R]:wt([R])}else a=r.getIsCollapsed()?r.getRangeRowElementList():r.getSelectionElementList();if(i&&a?.length){const d=In(a,e.getOptions());await Xc(n?id(d):d);return}a?.length&&await or(a,e.getOptions())}function rd(o,t){const e=t.getDraw(),{drop:n}=e.getOverride();if(n&&n(o)?.preventDefault!==!1)return;o.preventDefault();const i=o.dataTransfer?.getData("text");if(i)t.input(i);else{const l=o.dataTransfer?.files;if(!l)return;for(let r=0;r<l.length;r++){const a=l[r];a.type.startsWith("image")&&Xi(t,a)}}}function Tr(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 ld(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=si.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&&si.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&&si.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 ad(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(e.getMode()===s.EditorMode.FORM){const a=i.isTable&&e.getTd()?.value||e.getElementList(),c=i.isTable?i.tdValueIndex:i.index,d=a[c],u=cd(a,d),R=e.getEventBus();if(i.isDirectHit&&u?.controlId&&u.control?.type===s.ControlType.BUTTON&&!u.control.buttonText&&R.isSubscribe("buttonChange")){const h=a.filter(g=>g.controlId===u.controlId&&(g.originControlId||null)===(u.originControlId||null));R.emit("buttonChange",{evt:t,element:ct(u),elementList:ct(h),controlId:u.controlId,control:ct(u.control)});return}}if(i.isImage&&i.isDirectHit){const a=e.getElementList(),c=e.getEventBus(),d=a[i.index];if(c.isSubscribe("imageDblclick")&&c.emit("imageDblclick",{evt:t,element:d}),d.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&e.getMode()===s.EditorMode.EDIT&&!~i.index&&i.zone){e.getZone().setZone(i.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((i.isCheckbox||i.isRadio)&&i.isDirectHit)return;const l=e.getRange(),r=Tr(o)||ld(o);r&&(l.setRange(r.startIndex,r.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),l.setRangeStyle())}function cd(o,t){if(!t?.controlId)return null;const e=t.originControlId||null,n=l=>!!(l&&l.controlId===t.controlId&&(l.originControlId||null)===e);if(t.control?.type===s.ControlType.BUTTON)return t;const i=o.indexOf(t);for(let l=i;l>=0;l--){const r=o[l];if(!n(r))break;if(r.control?.type===s.ControlType.BUTTON)return r}for(let l=i+1;l<o.length;l++){const r=o[l];if(!n(r))break;if(r.control?.type===s.ControlType.BUTTON)return r}return null}function dd(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 fr={dblclick:ad,threeClick:dd};function ud(o){o.isComposing=!0}function Rd(o,t){const e=re();o.isComposing=!1;const n=o.getDraw(),i=n.getOptions();if(t.data)o.compositionInfo&&(o.compositionInfo.perfStartTime=e),Ia?setTimeout(()=>{o.compositionInfo&&Wi(t.data,o,"compositionend")},1):o.compositionInfo&&Wi(t.data,o,"compositionend");else{const r=o.compositionInfo?.cancel;if(ed(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",re()-e,[],{hasData:!!t.data,dataLength:t.data?.length||0})}function hd(o){o.compositionInfo&&(o.compositionInfo.cancel=!0)}const Yi={compositionstart:ud,compositionend:Rd,compositionCancel:hd};function gd(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!Os(o.target,m=>m===i))return;const a=o.target.dataset.index;a&&e.setPageNo(Number(a));const c=e.getPosition(),d=c.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!d)return;const{isTable:u,tdValueIndex: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:C,dragFloatImageDisabled:I}}=e.getOptions();if(I){const m=t.cacheElementList?.[t.cacheRange.startIndex];if(m?.type===s.ElementType.IMAGE&&(m.imgDisplay===s.ImageDisplay.FLOAT_TOP||m.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM||m.imgDisplay===s.ImageDisplay.SURROUND))return}f.drawCursor({width:C,color:p,isBlink:!1,isFocus:!1})}const Td={dragover:gd};class fd{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)),la(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=Tr(this);r&&(n=this.draw.getElementList().slice(r.startIndex+1,r.endIndex+1))}if(!n)return;const i=Object.keys(t);n.forEach(r=>{i.forEach(a=>{const c=a;Reflect.set(r,c,t[c])})}),this.draw.render({isSetCursor:!1});const l=this.draw.getPainterOptions();(!l||!l.isDblclick)&&this.clearPainterStyle()}selectAll(){if(!this.draw.isSelectionDisabled())if(this.position.getPositionContext().isTable)this.draw.getTableOperate().tableSelectAll();else{const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}}mousemove(t){this.draw.isInteractionSuspended()||Uc(t,this)}mousedown(t){this.draw.isInteractionSuspended()||Vc(t,this)}click(){this.draw.isInteractionSuspended()||pa&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){this.draw.isInteractionSuspended()||Wc(t,this)}mouseleave(t){this.draw.isInteractionSuspended()||Yc(t,this)}keydown(t){this.draw.isInteractionSuspended()||$c(t,this)}dblclick(t){this.draw.isInteractionSuspended()||fr.dblclick(this,t)}threeClick(){this.draw.isInteractionSuspended()||fr.threeClick(this)}input(t,e="input"){this.draw.isInteractionSuspended()||Wi(t,this,e)}async cut(){this.draw.isInteractionSuspended()||await od(this)}async copy(t){this.draw.isInteractionSuspended()||await sd(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()||rd(t,this)}dragover(t){this.draw.isInteractionSuspended()||Td.dragover(t,this)}}const mr={PAGE_SCALE:"pageScale"};class md{draw;options;cursor;canvasEvent;range;previewer;tableTool;hyperlinkParticle;control;dateParticle;imageParticle;dprMediaQueryList;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.canvasEvent=e,this.cursor=null,this.range=t.getRange(),this.previewer=t.getPreviewer(),this.tableTool=t.getTableTool(),this.hyperlinkParticle=t.getHyperlinkParticle(),this.dateParticle=t.getDateParticle(),this.imageParticle=t.getImageParticle(),this.control=t.getControl(),this.dprMediaQueryList=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)}register(){this.cursor=this.draw.getCursor(),this.addEvent()}addEvent(){window.addEventListener("blur",this.clearSideEffect),document.addEventListener("mousedown",this.clearSideEffect),document.addEventListener("mouseup",this.setCanvasEventAbility),document.addEventListener("wheel",this.setPageScale,{passive:!1}),document.addEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.addEventListener("change",this._handleDprChange)}removeEvent(){window.removeEventListener("blur",this.clearSideEffect),document.removeEventListener("mousedown",this.clearSideEffect),document.removeEventListener("mouseup",this.setCanvasEventAbility),document.removeEventListener("wheel",this.setPageScale),document.removeEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.removeEventListener("change",this._handleDprChange)}clearSideEffect=t=>{if(!this.cursor)return;if(this.draw.isInteractionSuspended()){this.resetSideEffect();return}const e=t?.composedPath?.()[0]||t.target;if(this.draw.isTargetInsideEditor(e)){this.watchCursorActive();return}this.resetSideEffect()};resetSideEffect=()=>{this.cursor&&(this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker(),this.imageParticle.destroyFloatImage())};setCanvasEventAbility=()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)};watchCursorActive(){this.range.getIsCollapsed()&&setTimeout(()=>{this.cursor?.getAgentIsActive()||this.cursor?.drawCursor({isFocus:!1,isBlink:!1})})}setPageScale=t=>{if(this.draw.isInteractionSuspended()||!this.draw.isTargetInsideEditor(t.target)||this.options.shortcutDisableKeys.includes(mr.PAGE_SCALE)||!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const n=e*10+1;n<=30&&this.draw.setPageScale(n/10)}else{const n=e*10-1;n>=5&&this.draw.setPageScale(n/10)}};_handleVisibilityChange=()=>{if(document.visibilityState==="visible"){const t=this.range.getRange(),e=!!~t.startIndex&&!!~t.endIndex&&t.startIndex===t.endIndex;this.range.replaceRange(t),this.draw.render({isSetCursor:e,isCompute:!1,isSubmitHistory:!1,curIndex:t.startIndex})}};_handleDprChange=()=>{this.draw.setPageDevicePixel()}}class pd{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 Cd{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 C=n[p];if(!C.isSurround){const P=C.width+(C.offsetX||0);C.rowFlex===s.RowFlex.CENTER?g+=(d-P)/2:C.rowFlex===s.RowFlex.RIGHT&&(g+=d-P)}g+=C.offsetX||0,T+=C.offsetY||0;const I=g,m=T;for(let P=0;P<C.elementList.length;P++){const E=C.elementList[P],M=E.metrics,F=!ae(E)&&(E.imgDisplay!==s.ImageDisplay.INLINE&&E.type===s.ElementType.IMAGE||E.type===s.ElementType.LATEX)?C.ascent-M.height:C.ascent;E.left&&(g+=E.left),E.translateX&&(g+=E.translateX*R);const y={pageNo:i,index:f,value:E.value,rowIndex:a+p,rowNo:p,metrics:M,left:E.left||0,ascent:F,lineHeight:C.height,isFirstLetter:P===0,isLastLetter:P===C.elementList.length-1,coordinate:{leftTop:[g,T],leftBottom:[g,T+C.height],rightTop:[g+M.width,T],rightBottom:[g+M.width,T+C.height]}};if(E.imgDisplay===s.ImageDisplay.SURROUND||E.imgDisplay===s.ImageDisplay.FLOAT_TOP||E.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM){const Y=e[e.length-1];Y&&(y.metrics=Y.metrics,y.coordinate=Y.coordinate),E.imgFloatPosition||(E.imgFloatPosition={x:g,y:T,pageNo:i}),this.floatPositionList.push({pageNo:i,element:E,position:y,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:f,zone:u})}if(e.push(y),f++,g+=M.width,E.type===s.ElementType.TABLE&&!ae(E)){const Y=E.tdPadding||h,D=Y[1]+Y[3],O=Y[0]+Y[2];for(let b=0;b<E.trList.length;b++){const V=E.trList[b];for(let X=0;X<V.tdList.length;X++){const N=V.tdList[X];N.positionList=[];const L=N.rowList,W=this.computePageRowPosition({positionList:N.positionList,rowList:L,pageNo:i,startRowIndex:0,startIndex:0,startX:(N.x+Y[3])*R+I+(E.translateX||0)*R,startY:(N.y+Y[0])*R+m,innerWidth:(N.width-D)*R,isTable:!0,index:f-1,tdIndex:X,trIndex:b,zone:u});if(N.verticalAlign===s.VerticalAlign.MIDDLE||N.verticalAlign===s.VerticalAlign.BOTTOM){const S=L.reduce((Q,w)=>Q+w.height,0),U=(N.height-O)*R-S,v=N.verticalAlign===s.VerticalAlign.MIDDLE?U/2:U;Math.floor(v)>0&&N.positionList.forEach(Q=>{const{coordinate:{leftTop:w,leftBottom:q,rightBottom:G,rightTop:H}}=Q;w[1]+=v,q[1]+=v,G[1]+=v,H[1]+=v})}g=W.x,T=W.y}}g=I,T=m}}g=l,T+=C.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:[ct(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:C,left:I,isFirstLetter:m,coordinate:{leftTop:P,rightTop:E,leftBottom:M}}=r[f];if(u===C){if(C>u)break;if(P[0]-I<=e&&E[0]>=e&&P[1]<=n&&M[1]>=n){let F=f;const y=l[f];if(y.type===s.ElementType.TABLE)for(let D=0;D<y.trList.length;D++){const O=y.trList[D];for(let b=0;b<O.tdList.length;b++){const V=O.tdList[b],X=this.getPositionByXY({x:e,y:n,td:V,pageNo:c,tablePosition:r[f],isTable:!0,elementList:V.value,positionList:V.positionList});if(~X.index){const{index:N,hitLineStartIndex:L}=X,W=V.value[N];return{index:p,isCheckbox:X.isCheckbox||W.type===s.ElementType.CHECKBOX||W.controlComponent===s.ControlComponent.CHECKBOX,isRadio:W.type===s.ElementType.RADIO||W.controlComponent===s.ControlComponent.RADIO,isControl:!!W.controlId,isImage:X.isImage,isLabel:X.isLabel,isMacro:X.isMacro,isDirectHit:X.isDirectHit,isTable:!0,tdIndex:b,trIndex:D,tdValueIndex:N,tdId:V.id,trId:O.id,tableId:y.id,hitLineStartIndex:L}}}}if(y.type===s.ElementType.IMAGE||y.type===s.ElementType.LATEX)return{index:F,isDirectHit:!0,isImage:!0};if(y.type===s.ElementType.MENSTRUAL_HISTORY)return{index:F,isDirectHit:!0};if(y.type===s.ElementType.FETAL_HEART_POSITION)return{index:F,isDirectHit:!0};if(y.type===s.ElementType.TOOTH_POSITION){const{scale:D}=this.options,O=y.width*D;return e>=P[0]&&e<=P[0]+O?{index:F,isDirectHit:!0}:{index:F}}if(y.type===s.ElementType.CHECKBOX||y.controlComponent===s.ControlComponent.CHECKBOX)return{index:F,isDirectHit:!0,isCheckbox:!0};if(y.type===s.ElementType.LABEL)return{index:F,isDirectHit:!0,isLabel:!0};if(y.type===s.ElementType.MACRO||y.type===s.ElementType.CUSTOM_MACRO||y.type===s.ElementType.REUSABLE_ITEM||y.type===s.ElementType.SUB_TEMPLATE)return{index:F,isDirectHit:!0,isMacro:!0};if(y.type===s.ElementType.TAB&&y.listStyle===s.ListStyle.CHECKBOX){let D=F-1;for(;D>0;){const O=l[D];if(O.value===K&&O.listStyle===s.ListStyle.CHECKBOX)break;D--}return{index:D,isDirectHit:!0,isCheckbox:!0}}if(y.type===s.ElementType.RADIO||y.controlComponent===s.ControlComponent.RADIO)return{index:F,isDirectHit:!0,isRadio:!0};let Y;if(l[p].value!==K){const D=E[0]-P[0];e<P[0]+D/2&&(F=f-1,m&&(Y=f))}return{isDirectHit:!0,hitLineStartIndex:Y,index:F,isControl:!!y.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:C}=t;if(p&&C){const{leftTop:I}=C.coordinate,m=p.x*f+I[0],P=p.y*f+I[1],E=p.width*f,M=p.height*f;if(!(m<e&&e<m+E&&P<n&&n<P+M))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:C,coordinate:{leftTop:I,leftBottom:m}}=T[f];if(n>I[1]&&n<=m[1]){const P=r.findIndex(y=>y.pageNo===u&&y.rowNo===C),E=l[P],M=r[P],F=E.listStyle===s.ListStyle.CHECKBOX?this.draw.getMargins()[3]:M.coordinate.leftTop[0];if(e<F)~P?M.value===K?h=P:(h=P-1,g=P):h=p;else{if(E.listStyle===s.ListStyle.CHECKBOX&&e<I[0])return{index:P,isDirectHit:!0,isCheckbox:!0};h=p}R=!0;break}}if(!R){if(this.draw.getIsPagingMode()){const p=this.draw.getHeader(),C=p.getHeight(),I=p.getHeaderTop()+C,m=this.draw.getFooter(),E=this.draw.getHeight()-(m.getFooterBottom()+m.getHeight());if(d){if(n<I)return{index:-1,zone:s.EditorZone.HEADER};if(n>E)return{index:-1,zone:s.EditorZone.FOOTER}}else if(n<=E&&n>=I)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 C=r[p];if(C.pageNo!==u||C.rowNo!==0)continue;const{leftTop:I,rightTop:m}=C.coordinate;if(e<=f[3]||e>=I[0]&&e<=m[0]||r[p+1]?.rowNo!==0)return{index:C.index}}else{const p=T[T.length-1];if(p){const C=p.rowNo;for(let I=0;I<r.length;I++){const m=r[I];if(m.pageNo!==u||m.rowNo!==C)continue;const{leftTop:P,rightTop:E}=m.coordinate;if(e<=f[3]||e>=P[0]&&e<=E[0]||r[I+1]?.rowNo!==C)return{index:m.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 C=d.imgFloatPosition,I=C.x*r,m=C.y*r,P=d.width*r,E=d.height*r;if(e>=I&&e<=I+P&&n>=m&&n<=m+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:C,trIndex:I,tdIndex:m,tdValueIndex:P}=e,E=this.draw.getControl(),{newIndex:M}=E.moveCursor({index:p,isTable:C,trIndex:I,tdIndex:m,tdValueIndex:P});C?e.tdValueIndex=M:e.index=M}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&&!Un(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(ga(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 Id{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=Vn(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===we.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&&!this.draw.isContentReadonly()){u.initControl();return}u.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}shrinkRange(){const{startIndex:t,endIndex:e}=this.range;t===e||!~t&&!~e||this.replaceRange({...this.range,startIndex:e})}setRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:i,isCrossRowCol:l}=this.range;if(!~n&&!~i)return;let r;if(l){const L=this.draw.getOriginalElementList(),W=this.position.getPositionContext();r=L[W.index]}else{const L=~i?i:0,W=this.draw.getElementList();r=this.getRangeAnchorStyle(W,L)}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(L=>!L.bold),h=!~a.findIndex(L=>!L.italic),g=!~a.findIndex(L=>!L.underline&&!L.control?.underline),T=!~a.findIndex(L=>!L.strikeout),f=r.color||null,p=r.highlight||null,C=r.rowFlex||null,I=r.vertical||null,m=r.rowMargin??this.options.defaultRowMargin,P=r.dashArray||[],E=r.level||null,M=r.listType||null,F=r.listStyle||null,y=g&&r.textDecoration||null,Y=!!this.draw.getPainterStyle(),D=this.historyManager.isCanUndo(),O=this.historyManager.isCanRedo(),b=r.groupIds||null,V=r.extension??null,X=r.deletePerson??"",N={type:c,undo:D,redo:O,painter:Y,font:d,size:u,bold:R,italic:h,underline:g,strikeout:T,deletePerson:X,color:f,highlight:p,rowFlex:C,vertical:I,rowMargin:m,dashArray:P,level:E,listType:M,listStyle:F,groupIds:b,textDecoration:y,extension:V};this._emitRangeStyle(N)}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 Ld{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 Ui{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 Pd extends Ui{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 Ed{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 Md{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:we.PAGE,elementList:T});const f=e[g];f&&a.push({index:g,type:we.TABLE,elementList:[f]}),R=g+1,u++}function h(g,T,f,p){if(!g)return;let C=f.map(M=>!M.type||Ce.includes(M.type)&&M.controlComponent!==s.ControlComponent.CHECKBOX&&M.controlComponent!==s.ControlComponent.RADIO&&!M.hide&&!M.control?.hide&&!M.area?.hide?M.value:K).filter(Boolean).join("");i&&(C=C.toLocaleLowerCase());const I=[],m=n?new RegExp(g):g;let{index:P,length:E}=bs(C,m);for(;P!==-1&&E!==0;){I.push({index:P,length:E});const M=bs(C,m,P+E);P=M.index,E=M.length}for(let M=0;M<I.length;M++){const{index:F,length:y}=I[M],Y=ft();for(let D=0;D<y;D++){const O=F+D+(p?.startIndex||0);r.push({type:T,index:O,groupId:Y,...p})}}}for(let g=0;g<a.length;g++){const T=a[g];if(T.type===we.TABLE){const f=T.elementList[0];for(let p=0;p<f.trList.length;p++){const C=f.trList[p];for(let I=0;I<C.tdList.length;I++){const m=C.tdList[I],P={tableId:f.id,tableIndex:T.index,trIndex:p,tdIndex:I,tdId:m.id};h(l,T.type,m.value,P)}}}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===we.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===we.TABLE){const{tableIndex:P,trIndex:E,tdIndex:M,index:F}=d;u=a[P]?.trList[E].tdList[M]?.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 P=this.searchMatchList[c-1];(!P||P.groupId!==d.groupId)&&this.searchNavigateScrollIntoView(u)}else t.fillStyle=i;const p=R[0],C=R[1],I=g[0]-R[0],m=h[1]-R[1];t.fillRect(p,C,I,m)}t.restore()}replace(t,e){if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const l=e?.index;if(di(l)){const f=[];i.forEach(p=>{const C=f[f.length-1];!C||C[0].groupId!==p.groupId?f.push([p]):C.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===we.TABLE){const{tableIndex:C,trIndex:I,tdIndex:m,index:P,tdId:E}=p;u&&E!==u&&(c=0),u=E;const M=C+a,F=h[M].trList[I].tdList[m].value,y=P+c,Y=F[y];if(!r&&(Y?.control?.deletable===!1||Y?.title?.deletable===!1))continue;if(t===""){this.draw.spliceElementList(F,y,1),c--,~R||(R=f);continue}if(d===p.groupId){this.draw.spliceElementList(F,y,1),c--;continue}~R||(R=f);for(let D=0;D<t.length;D++){const O=t[D];D===0?Y.value=O:(this.draw.spliceElementList(F,y+D,0,[{...Y,value:O}]),c++)}}else{const C=p.index+a,I=h[C];if(!r&&(I?.control?.deletable===!1||I?.title?.deletable===!1)||I.type===s.ElementType.CONTROL&&I.controlComponent!==s.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,C,1),a--,~R||(R=f);continue}if(~R||(R=f),d===p.groupId){this.draw.spliceElementList(h,C,1),a--;continue}for(let m=0;m<t.length;m++){const P=t[m];m===0?I.value=P:(this.draw.spliceElementList(h,C+m,0,[{...I,value:P}]),a++)}}d=p.groupId}if(!~R)return;const g=i[R],T=g.index+(t.length-1);if(g.type===we.TABLE){const{tableIndex:f,trIndex:p,tdIndex:C,index:I}=g,m=h[f].trList[p].tdList[C].value[I];this.position.setPositionContext({isTable:!0,index:f,trIndex:p,tdIndex:C,tdId:m.tdId,trId:m.trId,tableId:m.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(T,T),this.draw.render({curIndex:T})}}class Od extends Ui{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 Zn;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(Zn||(Zn={}));class Sd extends Ui{options;constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,l){const r=e+i;switch(t.beginPath(),l){case Zn.DASHED:t.setLineDash([3,1]);break;case Zn.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(r,n),t.stroke()}_drawDouble(t,e,n,i){const r=e+i,a=n+3*this.options.scale;this.options.mode===s.EditorMode.PRINT||this.options.mode===s.EditorMode.COMPARE?t.strokeStyle="transparent":t.strokeStyle="red",t.beginPath(),t.moveTo(e,n),t.lineTo(r,n),t.stroke(),t.beginPath(),t.moveTo(e,a),t.lineTo(r,a),t.stroke()}_drawWave(t,e,n,i){const{scale:l}=this.options,r=1.2*l,a=1/l,c=n+2*r;t.beginPath();for(let d=0;d<i;d++){const u=r*Math.sin(a*d);t.lineTo(e+d,c+u)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:i,y:l,width:r}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const a=Math.floor(l+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case s.TextDecorationStyle.WAVY:this._drawWave(t,i,a,r);break;case s.TextDecorationStyle.DOUBLE:this._drawDouble(t,i,a,r);break;case s.TextDecorationStyle.DASHED:this._drawLine(t,i,a,r,Zn.DASHED);break;case s.TextDecorationStyle.DOTTED:this._drawLine(t,i,a,r,Zn.DOTTED);break;default:this._drawLine(t,i,a,r);break}t.restore(),this.clearFillInfo()}}class Xd{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:jl});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||!zl.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 vn{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const l=i===s.NumberType.CHINESE?da(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(jn.PAGE_NO);g.test(h)&&(h=vn.formatNumberPlaceholder(h,e+u-R,g,c));const T=new RegExp(jn.PAGE_COUNT);T.test(h)&&(h=vn.formatNumberPlaceholder(h,this.draw.getPageCount()-R,T,c));const f=this.draw.getWidth(),p=this.draw.getHeight(),C=this.draw.getPageNumberBottom(),I=p-C;t.save(),t.fillStyle=r,t.font=`${i*n}px ${l}`;let m=0;const P=this.draw.getMargins(),{width:E}=t.measureText(h);a===s.RowFlex.CENTER?m=(f-E)/2:a===s.RowFlex.RIGHT?m=f-E-P[1]:m=P[3],t.fillText(h,m,I),t.restore()}}class Nd{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=sa(()=>{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(Jt.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove(Jt.DOWN):e<this.thresholdPoints[2]?this._startMove(Jt.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(Jt.RIGHT):this._stopMove()};_move(t){const e=this.selectionContainer instanceof Document?window:this.selectionContainer,n=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,i=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Jt.DOWN?e.scrollTo(n,i+this.step):t===Jt.UP?e.scrollTo(n,i-this.step):t===Jt.LEFT?e.scrollTo(n-this.step,i):e.scrollTo(n+this.step,i),this.requestAnimationFrameId=window.requestAnimationFrame(this._move.bind(this,t))}_startMove(t){this.isMoving||(this.isMoving=!0,this._move(t))}_stopMove(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=null,this.isMoving=!1)}}class yd{draw;range;options;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=ct(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),C=g.rowIndex,I=T.rowIndex+(T.rowspan-1),m=[];for(let P=0;P<h.length;P++){const E=h[P],M=[];for(let F=0;F<E.tdList.length;F++){const y=E.tdList[F],Y=y.colIndex,D=y.rowIndex;Y>=f&&Y<=p&&D>=C&&D<=I&&M.push(y)}M.length&&m.push(M)}return m.length?m:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:i,width:l,height:r,isDrawFullBorder:a,borderExternalWidth:c,skipTopBorderRanges:d=[]}=t,{scale:u}=this.options,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,C=a===s.TableBorder.EXTERNAL,I=a===s.TableBorder.INTERNAL;t.save(),a===s.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=d*R,t.strokeStyle=c||h,!p&&!I&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:T,borderExternalWidth:u,isDrawFullBorder:C,skipTopBorderRanges:f});for(let m=0;m<r.length;m++){const P=r[m];for(let E=0;E<P.tdList.length;E++){const M=P.tdList[E];if(M.slashTypes?.length&&this._drawSlash(t,M,n,i),!M.borderTypes?.length&&(p||C))continue;const F=M.width*R,y=M.height*R,Y=Math.round(M.x*R+n+F),D=Math.round(M.y*R+i),O=!!M.linkTdPrevId,b=!!M.linkTdNextId;if(t.translate(.5,.5),t.beginPath(),!O&&M.borderTypes?.includes(s.TdBorder.TOP)&&(t.moveTo(Y-F,D),t.lineTo(Y,D),t.stroke()),M.borderTypes?.includes(s.TdBorder.RIGHT)&&(t.moveTo(Y,D),t.lineTo(Y,D+y),t.stroke()),M.borderTypes?.includes(s.TdBorder.BOTTOM)&&(t.moveTo(Y,D+y),t.lineTo(Y-F,D+y),t.stroke()),M.borderTypes?.includes(s.TdBorder.LEFT)&&(t.moveTo(Y-F,D),t.lineTo(Y-F,D+y),t.stroke()),!p&&!C){if((!I||M.colIndex+M.colspan<l.length)&&(t.moveTo(Y,D),t.lineTo(Y,D+y),u&&u!==d&&M.colIndex+M.colspan===l.length)){const V=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=V}if(b||!I||M.rowIndex+M.rowspan<r.length){const V=u&&u!==d&&M.rowIndex+M.rowspan===r.length;if(V&&(t.stroke(),t.beginPath()),t.moveTo(Y,D+y),t.lineTo(Y-F,D+y),V){const X=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=X}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,i){const{trList:l}=e;if(!l)return;const{scale:r}=this.options;for(let a=0;a<l.length;a++){const c=l[a];for(let d=0;d<c.tdList.length;d++){const u=c.tdList[d];if(!u.backgroundColor)continue;t.save();const 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 C=r.tdList[c-1],I=C?C.colIndex+C.colspan:c;for(let m=I;m<e.length;m++)if(this.getRowCountByColIndex(n.slice(0,l),m)===l){u=m;let E=0;for(let M=0;M<m;M++)E+=e[M].width;i=E;break}}else{const C=r.tdList[c-1];C&&(u=C.colIndex+C.colspan)}let R=0;for(let C=0;C<d.colspan;C++)R+=e[C+u].width;let h=0;for(let C=0;C<d.rowspan;C++){const I=n[C+l]||n[l];h+=I.height}const g=r.tdList.length-1===c;let T=a;if(!T&&d.rowspan>1){const C=n.length-1-l;T=d.rowspan-1===C}const f=a&&g;d.isLastRowTd=g,d.isLastColTd=T,d.isLastTd=f,d.x=i;let p=0;for(let C=0;C<l;C++){const I=n[C].tdList;for(let m=0;m<I.length;m++){const P=I[m];if(u>=P.colIndex&&u<P.colIndex+P.colspan){p+=P.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 C=f.colIndex,I=p.colIndex+(p.colspan-1),m=f.rowIndex,P=p.rowIndex+(p.rowspan-1);t.save();for(let E=0;E<d.length;E++){const M=d[E];for(let F=0;F<M.tdList.length;F++){const y=M.tdList[F],Y=y.colIndex,D=y.rowIndex;if(Y>=C&&Y<=I&&D>=m&&D<=P){const O=y.x*l,b=y.y*l,V=y.width*l,X=y.height*l;t.globalAlpha=r,t.fillStyle=a,t.fillRect(O+n,b+i,V,X)}}}t.restore()}render(t,e,n,i){this._drawBackgroundColor(t,e,n,i),this._drawBorder(t,e,n,i)}findPreRowSpanTd(t,e,n){for(let i=e;i>=0;i--){const l=t[i].tdList.find(r=>r.colIndex===n);if(l)return l}}computeTrHeight(t,e){const{scale:n,table:{tdPadding:i,defaultTrMinHeight:l}}=this.options,r=t.tdPadding||i,a=r[0]+r[2],c=t.trList;for(let 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 C=h.tdList.find(I=>I.colIndex===p);if(C){const I=e?e(C):C.rowList,m=I.reduce((E,M)=>E+M.height,0);C.rowList=I;const P=m/n+a;C.mainHeight=P,C.rowspan>1?(u[C.colIndex]=C.id,d[C.id]={td:C,rowSpan:[R,R+C.rowspan-1],preHeight:0,preMinHeight:0,extraHeight:P},T.push(P)):C.height<P?(C.height=P,C.realHeight=P,g.push(P)):g.push(C.height)}else{const I=d[u[p]];I?.rowSpan[1]==R&&g.push(I.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 C=h.tdList.find(I=>I.colIndex===p)??this.findPreRowSpanTd(c,R,p);if(C){const I=d[C.id]?.preHeight??0,m=d[C.id]?.preMinHeight??h.minHeight;C.height=f+I,C.realHeight=f+I,C.realMinHeight=m}}}this.computeRowColInfo(t)}}var Ke;(function(o){o.ROW="row",o.COL="col"})(Ke||(Ke={}));class bd{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),C=g[0],I=g[1]+p,m=a.trList[n].tdList[i],P=m.rowIndex,E=m.colIndex,M=a.height*c,F=a.width*c,y=document.createElement("div");y.classList.add(`${rt}-table-tool__select`),y.style.height=`${M*c}`,y.style.left=`${C}px`,y.style.top=`${I}px`,y.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*c}px, ${-this.TABLE_SELECT_OFFSET*c}px)`,y.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(y),this.toolTableSelectBtn=y;const Y=h.map(L=>L.height),D=document.createElement("div");D.classList.add(`${rt}-table-tool__row`),D.style.transform=`translateX(-${this.ROW_COL_OFFSET*c}px)`;for(let L=0;L<Y.length;L++){const W=Y[L]*c,S=document.createElement("div");S.classList.add(`${rt}-table-tool__row__item`),L===P&&S.classList.add("active"),S.onclick=()=>{const v=this.draw.getTableParticle().getTdListByRowIndex(h,L),Q=v[0],w=v[v.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:Q.trIndex,tdIndex:Q.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,Q.tdIndex,w.tdIndex,Q.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(D,L)};const U=document.createElement("div");U.classList.add(`${rt}-table-tool__anchor`),U.onmousedown=v=>{this._mousedown({evt:v,element:a,index:L,order:Ke.ROW})},S.append(U),S.style.height=`${W}px`,D.append(S)}D.style.left=`${C}px`,D.style.top=`${I}px`,this.container.append(D),this.toolRowContainer=D;const O=document.createElement("div");O.classList.add(`${rt}-table-tool__quick__add`),O.style.height=`${M*c}`,O.style.left=`${C}px`,O.style.top=`${I+M}px`,O.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*c}px, ${this.ROW_COL_QUICK_OFFSET*c}px)`,O.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(O),this.toolRowAddBtn=O;const b=R.map(L=>L.width),V=document.createElement("div");V.classList.add(`${rt}-table-tool__col`),V.style.transform=`translateY(-${this.ROW_COL_OFFSET*c}px)`;for(let L=0;L<b.length;L++){const W=b[L]*c,S=document.createElement("div");S.classList.add(`${rt}-table-tool__col__item`),L===E&&S.classList.add("active"),S.onclick=()=>{const v=this.draw.getTableParticle().getTdListByColIndex(h,L),Q=v[0],w=v[v.length-1];this.position.setPositionContext({index:e,isTable:!0,trIndex:Q.trIndex,tdIndex:Q.tdIndex,tableId:a.id}),this.range.setRange(0,0,a.id,Q.tdIndex,w.tdIndex,Q.trIndex,w.trIndex),this.draw.render({curIndex:0,isCompute:!1,isSubmitHistory:!1}),this._setAnchorActive(V,L)};const U=document.createElement("div");U.classList.add(`${rt}-table-tool__anchor`),U.onmousedown=v=>{this._mousedown({evt:v,element:a,index:L,order:Ke.COL})},S.append(U),S.style.width=`${W}px`,V.append(S)}V.style.left=`${C}px`,V.style.top=`${I}px`,this.container.append(V),this.toolColContainer=V;const X=document.createElement("div");X.classList.add(`${rt}-table-tool__quick__add`),X.style.height=`${M*c}`,X.style.left=`${C+F}px`,X.style.top=`${I}px`,X.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*c}px, -${this.ROW_COL_QUICK_POSITION*c}px)`,X.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(X),this.toolColAddBtn=X;const N=document.createElement("div");N.classList.add(`${rt}-table-tool__border`),N.style.height=`${M}px`,N.style.width=`${F}px`,N.style.left=`${C}px`,N.style.top=`${I}px`;for(let L=0;L<h.length;L++){const W=h[L];for(let S=0;S<W.tdList.length;S++){const U=W.tdList[S],v=document.createElement("div");v.classList.add(`${rt}-table-tool__border__row`),v.style.width=`${U.width*c}px`,v.style.height=`${this.BORDER_VALUE}px`,v.style.top=`${(U.y+U.height)*c-this.BORDER_VALUE/2}px`,v.style.left=`${U.x*c}px`,v.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.rowIndex+U.rowspan-1,order:Ke.ROW})},N.appendChild(v);const Q=document.createElement("div");if(Q.classList.add(`${rt}-table-tool__border__col`),Q.style.width=`${this.BORDER_VALUE}px`,Q.style.height=`${U.height*c}px`,Q.style.top=`${U.y*c}px`,Q.style.left=`${(U.x+U.width)*c-this.BORDER_VALUE/2}px`,Q.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.colIndex+U.colspan-1,order:Ke.COL})},N.appendChild(Q),d&&U.colIndex===0){const w=document.createElement("div");w.classList.add(`${rt}-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=q=>{this._mousedown({evt:q,element:a,index:0,isLeftStartBorder:!0,order:Ke.COL})},N.appendChild(w)}}}this.container.append(N),this.toolBorderContainer=N}_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,C=this.draw.getMargins(),I=C[0],m=C[1],P=I,E=d-m;this.mousedownX=e.x,this.mousedownY=e.y;const M=e.target,F=this.canvas.getBoundingClientRect(),y=window.getComputedStyle(M).cursor;document.body.style.cursor=y,this.canvas.style.cursor=y;let Y=0,D=0;const O=document.createElement("div");O.classList.add(`${rt}-table-anchor__line`),i===Ke.ROW?(O.classList.add(`${rt}-table-anchor__line__row`),O.style.width=`${d}px`,Y=0,D=h+this.mousedownY-F.top):(O.classList.add(`${rt}-table-anchor__line__col`),O.style.height=`${u}px`,Y=this.mousedownX-F.left,D=h),O.style.left=`${Y}px`,O.style.top=`${D}px`,this.container.append(O),this.anchorLine=O;let b=0,V=0;const X=N=>{const L=this._mousemove(N,i,Y,D);L&&(b=L.dx,V=L.dy)};document.addEventListener("mousemove",X),document.addEventListener("mouseup",()=>{let N=!1;if(i===Ke.ROW){const L=l.trList,W=L[n]||L[n-1],{defaultTrMinHeight:S}=this.options.table;V<0&&W.height+V<S&&(V=S-W.height),V&&(W.height+=V,W.minHeight=W.height,N=!0)}else{const{colgroup:L}=l;if(L&&b)if(c&&r){L[n].width-b/a<=this.MIN_TD_WIDTH&&(b=(L[n].width-this.MIN_TD_WIDTH)*a);const W=p+(l.translateX||0)*a;W+b<P&&(b=P-W),L[n].width-=b/a,l.width-=b/a,l.translateX=(l.translateX||0)+b/a,N=!0}else{const W=L[n].width;b<0&&W*a+b<this.MIN_TD_WIDTH*a&&(b=this.MIN_TD_WIDTH*a-W*a);const S=L[n+1]?.width;if(b>0&&S&&S*a-b<this.MIN_TD_WIDTH*a&&(b=S*a-this.MIN_TD_WIDTH*a),n===L.length-1){const v=p+(l.translateX||0)*a+l.width*a;v+b>E&&(b=E-v)}b&&(L.length-1!==n&&(L[n+1].width-=b/a),L[n].width+=b/a,N=!0)}}N&&this.draw.render({isSetCursor:!1}),O.remove(),document.removeEventListener("mousemove",X),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,i){if(!this.anchorLine)return null;const l=t.x-this.mousedownX,r=t.y-this.mousedownY;return e===Ke.ROW?this.anchorLine.style.top=`${i+r}px`:this.anchorLine.style.left=`${n+l}px`,t.preventDefault(),{dx:l,dy:r}}}class Dd{draw;options;container;hyperlinkPopupContainer;hyperlinkDom;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:n}=this._createHyperlinkPopupDom();this.hyperlinkDom=n,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${rt}-hyperlink-popup`);const e=document.createElement("a");return e.target="_blank",e.rel="noopener",t.append(e),this.container.append(t),{hyperlinkPopupContainer:t,hyperlinkDom:e}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[n,i]},lineHeight:l}=e,r=this.draw.getHeight(),a=this.draw.getPageGap(),c=this.draw.getPageNo()*(r+a);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${i+c+l}px`;const d=t.url||"#";this.hyperlinkDom.href=d,this.hyperlinkDom.title=d,this.hyperlinkDom.innerText=d}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,i){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),t.fillText(e.value,n,i),t.restore()}}class Vd{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:l,label:{defaultBackgroundColor:r,defaultColor:a,defaultBorderRadius:c,defaultPadding:d}}=this.options,u=e.label?.backgroundColor||r,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 Wd{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,Oo(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,C=h.width+T*2,I=g+f*2,m=e.metrics,P=n,E=i-m.boundingBoxAscent+(m.boundingBoxAscent+m.boundingBoxDescent-I)/2;t.fillStyle=R,this._drawRoundedRect(t,P,E,C,I,p),t.fill(),t.fillStyle=u,t.textBaseline="middle",t.fillText(l,n+T,E+I/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 C=p+f;if(t.fillStyle=u,t.fillText("]",C,i),e.type==="reusableItem"){const I=t.measureText("[").width+f+t.measureText("]").width;if(t.lineWidth=r,this.draw.isPrintLikeMode()?t.strokeStyle="transparent":t.strokeStyle=c||"red",e.strikeout){const m=i-3*r,P=i+3.5*r;t.beginPath(),t.moveTo(n,m),t.lineTo(n+I,m),t.stroke(),t.beginPath(),t.moveTo(n,P),t.lineTo(n+I,P),t.stroke()}else if(e.underline&&e.textDecoration?.style==="double"){const m=Math.floor(i+2*r)+.5,P=3*r;t.beginPath(),t.moveTo(n,m),t.lineTo(n+I,m),t.stroke(),t.beginPath(),t.moveTo(n,m+P),t.lineTo(n+I,m+P),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,C=i-T/2;t.beginPath(),t.moveTo(p,C-2*r),t.lineTo(p+5*r,C-2*r),t.lineTo(p+2.5*r,C+2*r),t.closePath(),t.fillStyle="#666666",t.fill();const I=p+6*r;t.fillStyle=d,t.fillText("]",I,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 Yd{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=Oi(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*Ms[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 Ud{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 wd{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 Zd{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 vd{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 Qd{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(jn.PAGE_NO);f.test(T)&&(T=vn.formatNumberPlaceholder(T,e+1,f,u));const p=new RegExp(jn.PAGE_COUNT);p.test(T)&&(T=vn.formatNumberPlaceholder(T,this.draw.getPageCount(),p,u));const C=t.measureText(T);if(c){const I=this.draw.getPagePixelRatio(),m=document.createElement("canvas"),P=m.getContext("2d"),E=C.width,M=C.actualBoundingBoxAscent+C.actualBoundingBoxDescent,F=Math.sqrt(Math.pow(E,2)+Math.pow(M,2)),y=F+2*d[0]*R,Y=F+2*d[1]*R;m.width=y,m.height=Y,m.style.width=`${y*I}px`,m.style.height=`${Y*I}px`,P.translate(y/2,Y/2),P.rotate(-45*Math.PI/180),P.translate(-y/2,-Y/2),P.font=`${r*R}px ${l}`,P.fillStyle=a,P.fillText(T,(y-E)/2,(Y-M)/2+C.actualBoundingBoxAscent);const D=t.createPattern(m,"repeat");D&&(t.fillStyle=D,t.fillRect(0,0,h,g))}else{const I=h/2,m=g/2;t.fillStyle=a,t.translate(I,m),t.rotate(-45*Math.PI/180),t.fillText(T,-C.width/2,C.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)),C=p+2*a[0]*c,I=p+2*a[1]*c;T.width=C,T.height=I,T.style.width=`${C*g}px`,T.style.height=`${I*g}px`,f.translate(C/2,I/2),f.rotate(-45*Math.PI/180),f.translate(-C/2,-I/2),f.drawImage(this.imageCache.get(i),(C-R)/2,(I-h)/2,R,h);const m=t.createPattern(T,"repeat");m&&(t.fillStyle=m,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 Kd{draw;control;options;highlightList;highlightMatchResult;constructor(t){this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){const{control:{activeBackgroundColor:n,disabledBackgroundColor:i,existValueBackgroundColor:l,noValueBackgroundColor:r,inlineControlBackgroundColor:a}}=this.options,c=t[e],d=this.draw.isPrintLikeMode(),u=this.draw.getMode(),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,C=!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||(C=!d&&!!r&&!!c.controlId&&!this.control.getIsExistValueByElementListIndex(t,e));const I=R&&!!a&&(g===s.ControlType.NUMBER||g===s.ControlType.SELECT||g===s.ControlType.DATE);return(T?n:"")||(f?i:"")||(p?l:"")||(C?r:"")||(I?a:"")}getIsInlineControlBackground(t,e){const n=this.draw.getMode(),i=this._getControlType(t,e);return!!((n===s.EditorMode.EDIT||n===s.EditorMode.FORM)&&this.options.control.inlineControlBackgroundColor&&(i===s.ControlType.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 C=0;C<p.tdList.length;C++){const I=p.tdList[C],m={tableId:r.id,tableIndex:l-1,trIndex:f,tdIndex:C,tdId:I.id};e(I.value,m)}}}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(C=>({...C,...f,...i,index:C.index+d})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){if(!this.highlightMatchResult?.length)return;const{searchMatchAlpha:n,searchMatchColor:i}=this.options,l=this.draw.getPosition().getOriginalPositionList(),r=this.draw.getOriginalElementList();t.save();for(let a=0;a<this.highlightMatchResult.length;a++){const c=this.highlightMatchResult[a];let d=null;if(c.tableId){const{tableIndex:I,trIndex:m,tdIndex:P,index:E}=c;d=r[I]?.trList[m].tdList[P]?.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],C=R[1]-u[1];t.fillRect(T,f,p,C)}t.restore()}}const pr={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)"}},Hd="#ff4d4f",_d=5e3,wi=4;class Ad{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})},_d))}getMarks(){return this.marks}render(t,e,n,i,l,r,a){if(!this.marks.length||this.draw.isPrintLikeMode())return;const c=this._getRegions(e,n,i,l,r,a);if(c.length){t.save();for(let d=0;d<c.length;d++){const u=c[d],R=this._getStyle(u.mark),h=Math.max(1,this.options.scale),g=u.x-h,T=u.y-h,f=Math.max(1,u.width+h*2),p=Math.max(1,u.height+h*2),C=Math.max(2,this.options.scale*2);if(this.underlineVisible&&R.borderColor&&u.hasUnderline&&(t.lineWidth=C,t.strokeStyle=R.borderColor,t.beginPath(),t.moveTo(u.underlineX,u.underlineY),t.lineTo(u.underlineRight,u.underlineY),t.stroke()),u.drawRequired){this._renderRequiredMark(t,u,g);continue}if(R.borderColor){t.lineWidth=C;const I=Math.min(Math.max(8*this.options.scale,p*.3),p/2),m=g+f,P=T+p;t.beginPath(),u.drawLeft&&(t.moveTo(g+I,T),t.lineTo(g,T),t.lineTo(g,P)),u.drawRight&&(t.moveTo(m-I,P),t.lineTo(m,P),t.lineTo(m,T)),t.stroke()}}t.restore()}}_getRegions(t,e,n,i,l,r){const a=this._getParentMap(t),c=this.marks.map(h=>this._getTargetControlIds(t,h)),d=c.map(h=>this._getTitleTargets(t,h)),u=[];for(let h=0;h<n.length;h++){const g=n[h],T=new Map,f=e[g.startIndex],p=f?Math.min(f.coordinate.leftTop[0],f.coordinate.leftBottom[0])-(g.offsetX||0):0,C=f?p+(r||this.draw.getInnerWidth()):0;for(let I=0;I<g.elementList.length;I++){const m=g.elementList[I],P=g.startIndex+I,E=e[P];if(!E||l===s.EditorZone.MAIN&&E.pageNo!==i)continue;const M=this._getTargetIdsForElement(this._getQualityTargetId(m),c,a);for(let Q=0;Q<d.length;Q++){const w=d[Q].get(P);w&&w.forEach(q=>{M.some(G=>G.markIndex===Q&&G.controlId===q)||M.push({markIndex:Q,controlId:q})})}if(!M.length)continue;const F=E.coordinate.leftTop,y=E.coordinate.rightTop,Y=E.coordinate.leftBottom,D=E.coordinate.rightBottom,O=Math.min(F[0],Y[0]),b=Math.max(y[0],D[0]),V=Math.min(F[1],y[1]),X=Math.max(Y[1],D[1]),N=E.metrics.boundingBoxAscent+E.metrics.boundingBoxDescent,L=V+E.ascent-E.metrics.boundingBoxAscent,W=N>0?L:V,S=N>0?L+N:X,U=this._isButtonElement(m),v=f?Math.max(O,Math.min(b,C)):b;for(let Q=0;Q<M.length;Q++){const{markIndex:w,controlId:q}=M[Q],G=`${w}:${q}:${g.startIndex}`,H=T.get(G),z={x:O,y:W,right:b,bottom:S};if(H){const _=this._mergeBounds(H,z);H.x=_.x,H.y=_.y,H.width=Math.max(1,_.right-_.x),H.height=Math.max(1,_.bottom-_.y),U||(H.hasUnderline?(H.underlineX=Math.min(H.underlineX,O),H.underlineY=Math.max(H.underlineY,S+wi),H.underlineRight=Math.max(H.underlineRight,v)):(H.underlineX=O,H.underlineY=S+wi,H.underlineRight=v),H.hasUnderline=!0)}else T.set(G,{mark:this.marks[w],targetKey:`${w}:${q}`,x:O,y:W,width:Math.max(1,b-O),height:Math.max(1,S-W),baseline:V+E.ascent,font:m.style||this.draw.getElementFont(m,this.options.scale),underlineX:O,underlineY:S+wi,underlineRight:v,hasUnderline:!U,drawLeft:!1,drawRight:!1,drawRequired:!1})}}u.push(...T.values())}const R=new Map;for(let h=0;h<u.length;h++){const g=u[h],T=R.get(g.targetKey)||[];T.push(g),R.set(g.targetKey,T)}return R.forEach(h=>{this._isRequiredMark(h[0].mark)?h[0].drawRequired=!0:(h[0].drawLeft=!0,h[h.length-1].drawRight=!0)}),u}_renderRequiredMark(t,e,n){t.save(),t.font=e.font,t.fillStyle=e.mark.style?.borderColor||Hd,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{...pr[t.type?.toLowerCase()||"error"]||pr.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 kd{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 to{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&&!ys(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?$t(d,["control","controlId",...Re]):pe(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};oe(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&&Fs(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 P=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~P&&(this.control.repaintControl({curIndex:P}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],T=g?$t(g,Xe):$t(i[l.startIndex],Re),f=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~f)return;c||this.control.removePlaceholder(f,e);const p=pe(i[f],Xe),C=f+1,I=yt(h),m=this.control.getDraw();for(let P=0;P<I.length;P++){const E={...T,...p,type:s.ElementType.TEXT,value:I[P],controlComponent:s.ControlComponent.VALUE};(E.color===this.options.control.bracketColor||E.color===this.options.control.placeholderColor)&&(E.color=this.options.defaultColor),oe(i,[E],f,{editorOptions:this.options}),m.spliceElementList(i,C+P,0,[E])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:f,endIndex:f}}),!e.range){const P=C+I.length-1;this.control.repaintControl({curIndex:P}),this.control.emitControlContentChange({context:e}),u||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const n=this.control.getPosition();if(!n)return;const i=document.createElement("div");i.classList.add(`${rt}-select-control-popup`),i.setAttribute(Be,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(C=>C===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&&Ds(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 Gd(o){Cr=o}function Fe(o){return o instanceof Array||Object.prototype.toString.call(o)==="[object Array]"}function Pn(o){return o!=null&&Object.prototype.toString.call(o)==="[object Object]"}function Ht(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function Zi(o){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(o).length===0;var t;for(t in o)if(Ht(o,t))return!1;return!0}function fe(o){return o===void 0}function $e(o){return typeof o=="number"||Object.prototype.toString.call(o)==="[object Number]"}function eo(o){return o instanceof Date||Object.prototype.toString.call(o)==="[object Date]"}function Ir(o,t){var e=[],n,i=o.length;for(n=0;n<i;++n)e.push(t(o[n],n));return e}function Rn(o,t){for(var e in t)Ht(t,e)&&(o[e]=t[e]);return Ht(t,"toString")&&(o.toString=t.toString),Ht(t,"valueOf")&&(o.valueOf=t.valueOf),o}function He(o,t,e,n){return xr(o,t,e,n,!0).utc()}function xd(){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 Nt(o){return o._pf==null&&(o._pf=xd()),o._pf}var vi;Array.prototype.some?vi=Array.prototype.some:vi=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 Qi(o){var t=null,e=!1,n=o._d&&!isNaN(o._d.getTime());if(n&&(t=Nt(o),e=vi.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 Vo(o){var t=He(NaN);return o!=null?Rn(Nt(t),o):Nt(t).userInvalidated=!0,t}var Lr=st.momentProperties=[],Ki=!1;function Hi(o,t){var e,n,i,l=Lr.length;if(fe(t._isAMomentObject)||(o._isAMomentObject=t._isAMomentObject),fe(t._i)||(o._i=t._i),fe(t._f)||(o._f=t._f),fe(t._l)||(o._l=t._l),fe(t._strict)||(o._strict=t._strict),fe(t._tzm)||(o._tzm=t._tzm),fe(t._isUTC)||(o._isUTC=t._isUTC),fe(t._offset)||(o._offset=t._offset),fe(t._pf)||(o._pf=Nt(t)),fe(t._locale)||(o._locale=t._locale),l>0)for(e=0;e<l;e++)n=Lr[e],i=t[n],fe(i)||(o[n]=i);return o}function no(o){Hi(this,o),this._d=new Date(o._d!=null?o._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),Ki===!1&&(Ki=!0,st.updateOffset(this),Ki=!1)}function ye(o){return o instanceof no||o!=null&&o._isAMomentObject!=null}function Pr(o){st.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+o)}function Me(o,t){var e=!0;return Rn(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+=`
114
+ `||(t.splice(a,0,u),a++)}a--}a++}}oe(l,t,i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()})}e.insertElementList(t)}function ir(o,t){const e=o.getDraw();if(e.isReadonly()||e.isDisabled())return;const n=Yn(t,{innerWidth:e.getOriginalInnerWidth()});Si(o,n)}function Xi(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&&oe(l,[d],i,{editorOptions:e.getOptions()}),e.insertElementList([d])}}}function Fc(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(!Nc(n)){const r=n.getData("text"),a=tr();if(a&&mo(r)===mo(a.text)){Si(o,a.elementList);return}}er();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=>{ir(o,c)});break}}else if(a.kind==="file"&&a.type.includes("image")){const c=a.getAsFile();c&&Xi(o,c)}}}async function yc(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=tr();if(l&&mo(i)===mo(l.text)){Si(o,l.elementList);return}if(er(),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&&ir(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);Xi(o,u)}}}class bc{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(`${rt}-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||(Fc(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 Dc{ANIMATION_CLASS=`${rt}-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(`${rt}-cursor`),this.container.append(this.cursorDom),this.cursorAgent=new bc(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(Ca&&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:C}=e,P=(this.draw.getZone().isMainActive()?C:this.draw.getPageNo())*(R+h),E=fa*n,M=Math.min(g.height/4,E),F=g.height+M*2,y=this.cursorAgent.getAgentCursorDom();d&&setTimeout(()=>{this.focus()});const Y=g.boundingBoxDescent<0?0:g.boundingBoxDescent,D=T[1]+p+Y-(F-M)+P,O=u?T[0]:f[0];if(y.style.left=`${O}px`,y.style.top=`${D+F-E}px`,!a){this.recoveryCursor();return}const b=this.cursorDom.style.top,V=this.draw.isReadonly();this.cursorDom.style.width=`${r*n}px`,this.cursorDom.style.backgroundColor=l,this.cursorDom.style.left=`${O}px`,this.cursorDom.style.top=`${D}px`,this.cursorDom.style.display=V?"none":"block",this.cursorDom.style.height=`${F}px`,c?this._setBlinkTimeout():this._clearBlinkTimeout(),ui(()=>{this.moveCursorToVisible({cursorPosition:e,direction:parseInt(b)>D?Jt.UP:Jt.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=Ra(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:C,bottom:I}=a.getBoundingClientRect();c.left=f,c.right=p,c.top=C,c.bottom=I}const u=i*(this.draw.getHeight()+this.draw.getPageGap())+this.container.getBoundingClientRect().top,R=n===Jt.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 Ln;(function(o){o[o.LEFT=0]="LEFT",o[o.CENTER=1]="CENTER",o[o.RIGHT=2]="RIGHT"})(Ln||(Ln={}));function ve(o){return mn?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 No{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 Ni extends No{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 sr(o){const t=o.getDraw(),e=t.getPosition(),n=t.getRange();o.isAllowDrag=!0,o.cacheRange=ct(n.getRange()),o.cacheElementList=t.getElementList(),o.cachePositionList=e.getPositionList(),o.cachePositionContext=e.getPositionContext()}function rr(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 No&&l.setSelect(i)}}function lr(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 Ni&&l.setSelect(i)}}function Vc(o,t){const e=t.getDraw();let n=e.isReadonly();const i=e.isSelectionDisabled(),l=e.getRange(),r=e.getPosition(),a=l.getRange();if(o.button===Ln.RIGHT&&(a.isCrossRowCol||!l.getIsCollapsed()))return;const d=o.target.dataset.index;if(d&&e.setPageNo(Number(d)),!t.isAllowDrag&&!n&&a.startIndex!==a.endIndex&&l.getIsPointInRange(o.offsetX,o.offsetY,e.getPageNo())){sr(t);return}t.isAllowSelection=!i;const u=ct(r.getPositionContext()),R=r.getPositionByXY({x:o.offsetX,y:o.offsetY}),h=r.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!h)return;const{index:g,isDirectHit:T,isCheckbox:f,isRadio:p,isControl:C,isImage:I,isLabel:m,isMacro:P,isTable:E,tdValueIndex:M,hitLineStartIndex:F}=h;t.mouseDownStartPosition={...h,index:E?M:g,originalIndex:g,x:o.offsetX,y:o.offsetY};const y=e.getElementList(),Y=r.getPositionList(),D=E?M:g;let O;E?O=e.getTd().value[M]:O=y[D];const b=E&&e.getTd()?.value||y,V=E&&e.getTd()?.positionList||Y,X=!!(T&&I),N=!!(T&&f),L=!!(T&&p),W=!!(T&&m),S=!!(T&&P),U=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),Q=Z=>Z&&!!Z.originControlId&&!!Z.controlId,v=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)),w=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)),q=Z=>{if(!Z)return null;const A=new Set;let et=Z,gt=null;for(;et&&!A.has(et);){A.add(et);let It;for(let Bt=0;Bt<y.length;Bt++){const vt=y[Bt];if(vt.controlId===et&&vt.control?.type&&(It=vt,vt.controlComponent===s.ControlComponent.PREFIX||vt.controlComponent===s.ControlComponent.PRE_TEXT||vt.controlComponent===s.ControlComponent.PRETEXTFIX||vt.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))break}if(!It)break;It.control?.type===s.ControlType.TEXT&&(gt=et),et=It.originControlId||null}return gt},G=e.getMode()===s.EditorMode.FORM,H=G&&O?.control?.type===s.ControlType.TEXT,z=G&&!H?e.getControl().getActiveTextControlLimit():null;let _=D;const dt=(Z,A)=>!!Z&&!!A&&Z.controlId===A,Ct=(Z,A,et)=>{if(et){for(let gt=A;gt>=0;gt--){const It=Z[gt];if(dt(It,et)&&!It.originControlId&&It.control?.type)return It.control.type;if(It.controlId&&It.controlId!==et&&It.originControlId!==et)break}for(let gt=A+1;gt<Z.length;gt++){const It=Z[gt];if(dt(It,et)&&!It.originControlId&&It.control?.type)return It.control.type;if(It.controlId&&It.controlId!==et&&It.originControlId!==et)break}}},Kt=(Z,A)=>!!(G&&Z?.controlId&&!Z.originControlId&&Ct(b,A,Z.controlId)===s.ControlType.TEXTFIELD),ge=(Z,A)=>!!(G&&Z?.controlId&&!Z.originControlId&&Ct(b,A,Z.controlId)===s.ControlType.TEXT),se=V[D],J=b[D-1],lt=b[D+1],$=6,j=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],tt=(Z,A)=>!!(Z?.controlId&&Z.controlId===A?.controlId&&(Z.originControlId||null)===(A.originControlId||null)),x=(Z,A)=>{if(Z?.control?.type)return Z.control.type;if(Z?.controlId){for(let et=A;et>=0;et--){const gt=b[et];if(!tt(Z,gt))break;if(gt.control?.type)return gt.control.type}for(let et=A+1;et<b.length;et++){const gt=b[et];if(!tt(Z,gt))break;if(gt.control?.type)return gt.control.type}}},Rt=(Z,A)=>{const et=x(Z,A);return!!(et&&j.includes(et))},ht=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)),Pt=(Z,A)=>{if(!Z?.controlId)return-1;for(let et=A;et>=0;et--){const gt=b[et];if(!tt(Z,gt))break;if(gt.controlComponent===s.ControlComponent.VALUE)return et}for(let et=A+1;et<b.length;et++){const gt=b[et];if(!tt(Z,gt))break;if(gt.controlComponent===s.ControlComponent.VALUE)return et}return-1},Qt=(Z,A)=>{if(!Z)return!1;if(Z.controlComponent===s.ControlComponent.VALUE||Z.controlComponent===s.ControlComponent.PLACEHOLDER)return!0;const et=x(Z,A),gt=et===s.ControlType.SELECT||et===s.ControlType.DATE,It=Z.controlComponent===s.ControlComponent.PRE_TEXT||Z.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||Z.controlComponent===s.ControlComponent.TEXTFIXLABEL;return!!(gt&&It&&Z.value&&Pt(Z,A)===-1)},Lt=Z=>{const A=V[Z];if(!A)return!1;const{coordinate:{leftTop:et,rightTop:gt,leftBottom:It}}=A;return o.offsetX>=et[0]&&o.offsetX<gt[0]&&o.offsetY>=et[1]&&o.offsetY<=It[1]},At=(Z,A)=>{if(e.getMode()!==s.EditorMode.EDIT||!Z?.originControlId||Z.controlComponent!==s.ControlComponent.VALUE||x(Z,A)!==s.ControlType.BUTTON||Z.control?.buttonText||Ct(b,A,Z.originControlId)!==s.ControlType.TEXTFIELD||!Lt(A))return!1;let et=-1;for(let Xn=A;Xn<b.length;Xn++){const ln=b[Xn];if(!tt(Z,ln))break;const xe=V[Xn];ln.controlComponent===s.ControlComponent.VALUE&&xe&&xe.coordinate.rightTop[0]>xe.coordinate.leftTop[0]&&(et=Xn)}if(et===-1)return!1;const gt=V[et],{coordinate:{leftTop:It,rightTop:Bt,leftBottom:vt}}=gt;return o.offsetX>=It[0]-2&&o.offsetX<=Bt[0]&&o.offsetY>=It[1]&&o.offsetY<=vt[1]},ee=(Z,A)=>!(!T||!Rt(Z,A)||!Lt(A)||At(Z,A)||!Qt(Z,A)||ht(Z)||mt(Z)&&!Z?.value),ne=()=>[R.isTable?R.tdValueIndex:R.index,D,D+1,D-1,D+2,D-2].filter((A,et,gt)=>typeof A=="number"&&A>=0&&A<b.length&&gt.indexOf(A)===et),Yt=()=>{if(!T)return null;for(const Z of ne()){const A=b[Z];if(ee(A,Z))return{element:A,index:Z}}return null},Xt=()=>{if(!T)return-1;for(const Z of ne())if(At(b[Z],Z))return Z;return-1},bt=Z=>{const A=b[Z];let et=Z;for(let gt=Z+1;gt<b.length&&tt(A,b[gt]);gt++)et=gt;return et},Ft=ne().some(Z=>Rt(b[Z],Z)),Et=Yt(),Mt=Xt(),St=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),Vt=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),me=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),Ot=(Z,A)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&St(Z)&&A?.controlId===Z.originControlId&&!A.originControlId&&A.control?.type===s.ControlType.TEXTFIELD&&St(A)),nt=(Z,A)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&St(Z)&&A?.controlId===Z.originControlId&&!A.originControlId&&A.control?.type===s.ControlType.TEXTFIELD&&A.controlComponent===s.ControlComponent.VALUE),Ut=(Z,A,et)=>!!(e.getMode()===s.EditorMode.EDIT&&Z?.originControlId&&et?.originControlId===Z.originControlId&&Z.controlId&&et.controlId&&Z.controlId!==et.controlId&&Vt(Z)&&me(et)&&Ct(b,A,Z.originControlId)===s.ControlType.TEXTFIELD),at=Ot(O,lt),Gt=nt(O,lt),k=Ut(O,D,lt),ot=Ut(J,D-1,O),pt=!!(e.getMode()===s.EditorMode.EDIT&&C&&T&&St(O)&&!at&&!Gt&&!k&&J?.controlId===O.controlId&&(J.originControlId||null)===(O.originControlId||null)&&(J.controlComponent===s.ControlComponent.VALUE||J.controlComponent===s.ControlComponent.PLACEHOLDER)),it=(Z,A,et)=>!!(G&&v(Z)&&Ct(b,A,Z?.originControlId)===et&&(et===s.ControlType.TEXTFIELD?Kt(b[A+1],A+1):ge(b[A+1],A+1))),de=(Z,A,et)=>!!(G&&w(Z)&&Ct(b,A,Z?.originControlId)===et&&(et===s.ControlType.TEXTFIELD?Kt(b[A-1],A-1):ge(b[A-1],A-1))),kt=it(O,D,s.ControlType.TEXTFIELD),zt=!!(G&&se&&Kt(O,D)&&it(J,D-1,s.ControlType.TEXTFIELD)&&o.offsetX<=se.coordinate.leftTop[0]+$),$n=!!(G&&se&&Kt(O,D)&&de(lt,D+1,s.ControlType.TEXTFIELD)&&o.offsetX>=se.coordinate.rightTop[0]-$),Tn=!!(G&&se&&kt&&o.offsetX>se.coordinate.rightTop[0]),Le=!!(G&&se&&w(O)&&Ct(b,D,O.originControlId)===s.ControlType.TEXTFIELD&&Kt(J,D-1)&&o.offsetX<se.coordinate.leftTop[0]),Ve=Kt(O,D)||kt||zt||$n||Tn||Le,qf=it(O,D,s.ControlType.TEXT),Ql=Z=>{const A=b[Z],et=Y[Z];if(!et||!ge(A,Z))return-1;const gt=b[Z-1];return!it(gt,Z-1,s.ControlType.TEXT)||o.offsetX>et.coordinate.leftTop[0]+$?-1:Z-1},Is=Ql(D),vl=Ql(D-1),Kl=Is!==-1||vl!==-1,Hl=!!(G&&se&&w(O)&&Ct(b,D,O.originControlId)===s.ControlType.TEXT&&ge(J,D-1)&&o.offsetX<se.coordinate.leftTop[0]),tm=!!(G&&se&&ge(O,D)&&de(lt,D+1,s.ControlType.TEXT)&&o.offsetX>=se.coordinate.rightTop[0]-$),em=qf||Kl||Hl||tm;at||Gt||k?_=D:ot||pt?_=Math.max(D-1,0):Kl?_=Is!==-1?Is:vl:Hl&&(_=Math.max(D-1,0)),Et?(_=Et.index,r.setPositionContext({...r.getPositionContext(),index:Et.index,isControl:!0,isDirectHit:!0})):Mt!==-1?_=bt(Mt):Rt(O,D)&&se&&!Lt(D)&&o.offsetX>se.coordinate.rightTop[0]&&(_=bt(D));let _l=!1;if(G&&z?.parentControlId&&O?.controlId===z.parentControlId&&!O?.originControlId)for(let Z=D;Z>=0;Z--){const A=y[Z];if(dt(A,z.parentControlId)){A.control?.type===s.ControlType.TEXTFIELD&&(_l=!0);break}if(A.controlId!==z.parentControlId)break}const Al=!!(z&&(!O?.controlId||O.controlId===z.controlId&&(O.originControlId||null)===z.originControlId||z.parentControlId&&O.controlId===z.parentControlId&&!O.originControlId&&_l));if(G&&!H&&(O?.controlId||O?.originControlId)){let Z;const A=O.originControlId||O.controlId;for(let et=D;et>=0;et--){const gt=y[et];if(dt(gt,A)&&gt.control?.type){Z=gt.control.type;break}if(gt.controlId!==O.controlId&&gt.controlId!==A)break}if(Z!==s.ControlType.TEXT){if(Z===s.ControlType.TEXTFIELD){const et=O.controlComponent;if(!Q(O)){if(!(O.controlComponent===s.ControlComponent.VALUE&&U(O))){if(et===s.ControlComponent.PRETEXTFIX||et===s.ControlComponent.PRETEXTFIX_TEXT||et===s.ControlComponent.POSTTEXTFIX||et===s.ControlComponent.POSTTEXTFIX_TEXT||et===s.ControlComponent.TEXTFIXLABEL||et===s.ControlComponent.PREFIX||et===s.ControlComponent.POSTFIX||et===s.ControlComponent.PRE_TEXT||et===s.ControlComponent.POST_TEXT||et===s.ControlComponent.PLACEHOLDER)for(let gt=D+1;gt<y.length;gt++){const It=y[gt];if(It.controlId!==A&&It.originControlId!==A)break;if(It.controlComponent===s.ControlComponent.VALUE&&!U(It)){_=gt;break}if(It.controlComponent===s.ControlComponent.POSTTEXTFIX||It.controlComponent===s.ControlComponent.POSTFIX){for(let Bt=D-1;Bt>=0;Bt--){const vt=y[Bt];if(vt.controlId!==A&&vt.originControlId!==A)break;if(vt.controlComponent===s.ControlComponent.VALUE&&!U(vt)){_=Bt;break}}break}}else if(et===s.ControlComponent.VALUE&&D>0){const gt=y[D-1];if(gt&&(gt.controlId===A||gt.originControlId===A)&&gt.controlComponent===s.ControlComponent.VALUE&&U(gt)){let It=!1;for(let Bt=D-2;Bt>=0;Bt--){const vt=y[Bt];if(vt.controlId!==A&&vt.originControlId!==A||vt.controlComponent!==s.ControlComponent.VALUE&&!vt.originControlId&&vt.controlId===A)break;if(!U(vt)){_=Bt+1,It=!0;break}}if(!It)for(let Bt=D;Bt<y.length;Bt++){const vt=y[Bt];if(vt.controlId!==A&&vt.originControlId!==A||(vt.controlComponent===s.ControlComponent.POSTTEXTFIX||vt.controlComponent===s.ControlComponent.POSTFIX)&&!vt.originControlId&&vt.controlId===A)break;if(!U(vt)){_=Bt,It=!0;break}}}}}}}}}if(G&&O?.control?.type===s.ControlType.TEXT&&O?.originControlId&&O.controlComponent===s.ControlComponent.PLACEHOLDER&&q(O.originControlId)&&(_=D),~g&&Ve&&!Et)t.isAllowSelection=!1,e.getControl().destroyControl({isEmitEvent:!1}),e.render({isCompute:!1,isSubmitHistory:!1,isSetCursor:!1});else if(~g&&!i){Al&&(_=Math.min(Math.max(_,z.startIndex),z.endIndex));let Z=_,A=_;if(o.shiftKey){const{startIndex:It}=l.getRange();~It&&r.getPositionContext().tdId===u.tdId&&(D>It?Z=It:A=It)}Al&&(Z=Math.min(Math.max(Z,z.startIndex),z.endIndex),A=Math.min(Math.max(A,z.startIndex),z.endIndex),_=Math.min(Math.max(_,z.startIndex),z.endIndex));const et=e.getControl(),gt=!!Et;et.setPopupAwakeDisabled(o.button===Ln.RIGHT||em&&!gt||Ft&&!gt);try{l.setRange(Z,A)}finally{et.setPopupAwakeDisabled(!1)}if(r.setCursorPosition(Y[_]),n=e.isReadonly(),N&&!n)rr(O,e);else if(L&&!n)lr(O,e);else if(!n&&O.controlComponent===s.ControlComponent.VALUE&&(O.control?.type===s.ControlType.CHECKBOX||O.control?.type===s.ControlType.RADIO)){let It=D;for(;It>0;){const Bt=y[It];if(Bt.controlComponent===s.ControlComponent.CHECKBOX){rr(Bt,e);break}else if(Bt.controlComponent===s.ControlComponent.RADIO){lr(Bt,e);break}It--}}else{const Bt=!!(!!(Et&&x(Et.element,Et.index)===s.ControlType.BUTTON&&!Et.element.control?.buttonText)&&Et?.element.control?.editable===!1);let vt=!1;if(G&&O?.controlId&&O?.controlComponent===s.ControlComponent.VALUE&&!O.originControlId){let xe=!1;for(let Pe=D;Pe>=0;Pe--){const We=y[Pe];if(We.controlId!==O.controlId){if(We.originControlId===O.controlId){xe=!0;continue}break}if(We.control?.type===s.ControlType.TEXTFIELD){if(xe)break;vt=!0;break}}if(!xe&&!vt)for(let Pe=D+1;Pe<y.length;Pe++){const We=y[Pe];if(We.controlId!==O.controlId){if(We.originControlId===O.controlId){xe=!0;continue}break}}xe&&(vt=!1)}const ni=vt&&U(O),Xn=S&&!ni?_+1:void 0;e.render({curIndex:S&&!ni?Xn:_,isCompute:!1,isSubmitHistory:!1,isSetCursor:!X&&!N&&!L&&!(Bt&&G)&&!ni});const ln=y[_];if(!n&&gt&&ln?.controlId&&o.button===Ln.LEFT){const Pe=e.getControl().getActiveControl(),We=Pe?.getElement()?.control?.type;Pe&&(We===s.ControlType.NUMBER||We===s.ControlType.SELECT||We===s.ControlType.DATE||We===s.ControlType.BUTTON)&&Pe.getElement()?.controlId===ln.controlId&&ln.controlComponent!==s.ControlComponent.POSTFIX&&ln.controlComponent!==s.ControlComponent.POSTTEXTFIX&&ln.controlComponent!==s.ControlComponent.POSTTEXTFIX_TEXT&&ln.controlComponent!==s.ControlComponent.POST_TEXT&&typeof Pe.awake=="function"&&Pe.awake(o)}}F&&t.getDraw().getCursor().drawCursor({hitLineStartIndex:F})}const Ge=e.getEventBus();if(W&&Ge.isSubscribe("labelMousedown")&&Ge.emit("labelMousedown",{evt:o,element:O}),S&&(O.type===s.ElementType.MACRO||O.type===s.ElementType.CUSTOM_MACRO||O.type===s.ElementType.REUSABLE_ITEM)){const Z=e.getMode();if(Z===s.EditorMode.EDIT&&O.type===s.ElementType.CUSTOM_MACRO)Ge.isSubscribe("macroClick")&&Ge.emit("macroClick",{evt:o,element:O});else if(Z===s.EditorMode.FORM){let A=!1;O.type===s.ElementType.CUSTOM_MACRO&&o.button===Ln.LEFT&&!n&&(A=e.getMacroParticle().activateInlineEditor(O,D)),!A&&Ge.isSubscribe("macroValueChange")&&Ge.emit("macroValueChange",{evt:o,element:O})}}o.button===Ln.LEFT&&S&&O.type===s.ElementType.SUB_TEMPLATE&&e.getMode()===s.EditorMode.FORM&&Ge.isSubscribe("subTemplateClick")&&Ge.emit("subTemplateClick",{evt:o,element:O});const kl=e.getPreviewer();if(kl.clearResizer(),X){if(!e.isPrintLikeMode()){const Z={dragDisable:n||!O.controlId&&e.getMode()===s.EditorMode.FORM};O.type===s.ElementType.LATEX&&(Z.mime="svg",Z.srcKey="laTexSVG"),kl.drawResizer(O,Y[D],Z),e.getCursor().drawCursor({isShow:!1}),sr(t),(O.imgDisplay===s.ImageDisplay.SURROUND||O.imgDisplay===s.ImageDisplay.FLOAT_TOP||O.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)&&e.getImageParticle().createFloatImage(O)}Ge.isSubscribe("imageMousedown")&&Ge.emit("imageMousedown",{evt:o,element:O})}const Gl=e.getTableTool();Gl.dispose(),E&&!n&&e.getMode()!==s.EditorMode.FORM&&Gl.render();const Ls=e.getHyperlinkParticle();Ls.clearHyperlinkPopup(),O.type===s.ElementType.HYPERLINK&&(ve(o)?Ls.openHyperlink(O):Ls.drawHyperlinkPopup(O,Y[D]));const xl=e.getDateParticle();xl.clearDatePicker(),O.type===s.ElementType.DATE&&!n&&xl.renderDatePicker(O,Y[D]);const Bl=e.getMenstrualHistoryParticle();Bl.clearMenstrualHistoryEditor(),O.type===s.ElementType.MENSTRUAL_HISTORY&&T&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&Bl.renderMenstrualHistoryEditor(O,Y[D]);const Jl=e.getFetalHeartPositionParticle();Jl.clearFetalHeartPositionEditor(),O.type===s.ElementType.FETAL_HEART_POSITION&&T&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&Jl.renderFetalHeartPositionEditor(O,Y[D]);const $l=e.getToothPositionParticle();$l.clearToothPositionEditor(),O.type===s.ElementType.TOOTH_POSITION&&T&&(e.getMode()===s.EditorMode.FORM||e.getMode()===s.EditorMode.EDIT)&&$l.renderToothPositionEditor(O,Y[D])}function Fo(o){const t=ft();return Reflect.set(o,"dragId",t),t}function yo(o,t){return t.findIndex(e=>e.dragId===o)}function ar(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 Wc(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 H=!1,z=!1;if(h){const _=c[T];if(_.type===s.ElementType.IMAGE||_.type===s.ElementType.LATEX){if(ar(_,o,t),_.imgDisplay===s.ImageDisplay.SURROUND||_.imgDisplay===s.ImageDisplay.FLOAT_TOP||_.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(_),H=!0;else{const dt=d[T];e.getPreviewer().drawResizer(_,dt)}z=_.imgDisplay===s.ImageDisplay.SURROUND}}r.replaceRange({...a}),e.render({isCompute:z,isSubmitHistory:H,isSetCursor:!1});return}const f=c.slice(g+1,T+1),p=f.find(H=>H.controlId);if(p){const H=c[g+1],z=c[T];if(!((!H.controlId||H.controlComponent===s.ControlComponent.PREFIX)&&(!z.controlId||z.controlComponent===s.ControlComponent.POSTFIX)||H.controlId===z.controlId&&H.controlComponent===s.ControlComponent.PREFIX&&z.controlComponent===s.ControlComponent.POSTFIX||H.control?.type===s.ControlType.TEXT&&H.controlComponent===s.ControlComponent.VALUE&&z.control?.type===s.ControlType.TEXT&&z.controlComponent===s.ControlComponent.VALUE)){e.render({curIndex:R.startIndex,isCompute:!1,isSubmitHistory:!1});return}}const C=e.getControl(),I=e.getElementList(),m=!p||!!I[R.startIndex].controlId||!C.getIsElementListContainFullControl(f),P=e.getOptions(),E=f.map(H=>{if(!H.type||H.type===s.ElementType.TEXT){const z={value:H.value},_=Xe;return m||_.push(...gi),_.forEach(dt=>{const Ct=H[dt];Ct!==void 0&&(z[dt]=Ct)}),z}else{let z=ct(H);return m&&(z=pe(z,gi)),jt([z],{isHandleFirstElement:!1,editorOptions:P}),z}});oe(I,E,R.startIndex,{editorOptions:e.getOptions()});const M=c[g],F=d[g],y=Fo(c[g]),Y=Fo(c[T]),D=E.length;let O=R.startIndex,b=O+D;const V=C.getActiveControl();if(V&&c[O].controlComponent!==s.ControlComponent.POSTFIX?(b=V.setValue(E),O=b-D):e.spliceElementList(I,O+1,0,E),!~b){e.render({isSetCursor:!1});return}const X=Fo(I[O]),N=Fo(I[b]),L=yo(y,c),W=yo(Y,c),S=c[W];if(S.controlId&&S.controlComponent!==s.ControlComponent.POSTFIX)r.replaceRange({...a,startIndex:L,endIndex:W}),C.getActiveControl()?.cut();else{let H=!0;if(u?.isTable){const{tableId:z,trIndex:_,tdIndex:dt}=u;H=!e.getOriginalElementList().some(Kt=>Kt.id===z&&Kt?.trList?.[_]?.tdList?.[dt]?.deletable===!1)}H&&e.spliceElementList(c,L+1,W-L)}const U=I[R.startIndex],Q=i[R.startIndex];let v=l.index;v&&(U.tableId&&!M.tableId?F.index<v&&(v-=D):!U.tableId&&M.tableId&&Q.index<v&&(v+=D),n.setPositionContext({...l,index:v}));const w=yo(X,I),q=yo(N,I);r.setRange(h?q:w,q,R.tableId,R.startTdIndex,R.endTdIndex,R.startTrIndex,R.endTrIndex),e.clearSideEffect();let G=null;if(h){const z=e.getElementList()[q];(z.type===s.ElementType.IMAGE||z.type===s.ElementType.LATEX)&&(ar(z,o,t),G=z)}if(e.render({isSetCursor:!1}),V?C.emitControlContentChange():M.controlId&&C.emitControlContentChange({context:{range:a,elementList:c},controlElement:M}),G)if(G.imgDisplay===s.ImageDisplay.SURROUND||G.imgDisplay===s.ImageDisplay.FLOAT_TOP||G.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)e.getPreviewer().drawResizer(G);else{const z=n.getPositionList()[q];e.getPreviewer().drawResizer(G,z)}}else t.isAllowDrag&&t.cacheRange?.startIndex!==t.cacheRange?.endIndex&&t.mousedown(o)}function Yc(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 Uc(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 N=c.isTable?e.getTdByPosition({...c,isTable:!0,index:c.index}):null,L=c.isTable&&N?.value||e.getElementList(),W=c.isTable&&N?.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((H,z,_)=>H>=0&&H<L.length&&_.indexOf(H)===z),w=H=>{const z=W[H];if(!z)return!1;const{coordinate:{leftTop:_,rightTop:dt,leftBottom:Ct}}=z;return dt[0]>_[0]&&o.offsetX>=_[0]&&o.offsetX<dt[0]&&o.offsetY>=_[1]&&o.offsetY<=Ct[1]},q=Q&&v.some(H=>{const _=L[H]?.control?.type;return _!==s.ControlType.NUMBER&&_!==s.ControlType.SELECT&&_!==s.ControlType.DATE?!1:w(H)}),G=v.some(H=>{const z=L[H];return!!(z?.control?.type===s.ControlType.BUTTON&&!z.control.buttonText&&(z.controlComponent===s.ControlComponent.VALUE||z.controlComponent===s.ControlComponent.PLACEHOLDER)&&w(H))});r&&(q||G)?r.style.cursor="pointer":r&&(r.style.cursor="text")}else r&&(r.style.cursor="text");if(t.isAllowDrag){if(e.isContentReadonly()){t.setIsAllowDrag(!1);return}const N=o.offsetX,L=o.offsetY,{startIndex:W,endIndex:S}=t.cacheRange,U=t.cachePositionList;for(let v=W+1;v<=S;v++){const{coordinate:{leftTop:w,rightBottom:q}}=U[v];if(N>=w[0]&&N<=q[0]&&L>=w[1]&&L<=q[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:C,tableId:I,trId:m,tdId:P}=h;let E=T?f:g;if(h.isControl&&e.getMode()!==s.EditorMode.READONLY){const{newIndex:N}=n.moveCursor({index:g,isTable:T,trIndex:C,tdIndex:p,tdValueIndex:f});E=N}const{index:M,isTable:F,tdIndex:y,tdId:Y,trIndex:D,tableId:O}=t.mouseDownStartPosition,b=E,V=e.getRange();let X;if(P!==Y&&P&&Y){const N=e.getTdByPosition({...t.mouseDownStartPosition,isTable:!!t.mouseDownStartPosition.tableId,index:t.mouseDownStartPosition.originalIndex??t.mouseDownStartPosition.index}),L=e.getTdByPosition({...h,isTable:!!h.tableId,index:h.index});if(e.isSplitTd(N,L)){const W=(N.valueStartIndex??0)+M,S=(L.valueStartIndex??0)+f;X=[{index:W,element:N.value[M],originalId:N.originalId,isCurrent:!1,length:N.value.length,startIndex:N.valueStartIndex??0},{index:S,element:L.value[f],originalId:L.originalId,isCurrent:!0,length:L.value.length,startIndex:L.valueStartIndex??0}]}}if(T&&F&&P!==Y&&!X)V.setRange(b,b,I,y,p,D,C),R.setPositionContext({isTable:!!T,index:g,trIndex:C,tdIndex:p,tdId:P,trId:m,tableId:I});else{let N=~b?b:0;if((F||T)&&O!==I&&!X)return;R.setPositionContext({isTable:!!T,index:g,trIndex:C,tdIndex:p,tdId:P,trId:m,tableId:I});let L=M,W,S;if(X)[{element:W},{element:S}]=X;else{const v=e.getElementList();W=v[L+1],S=v[N]}if(L===N||W?.controlComponent===s.ControlComponent.PLACEHOLDER&&S?.controlComponent===s.ControlComponent.PLACEHOLDER&&W.controlId===S.controlId)return;if(L>N&&([L,N]=[N,L]),e.getMode()===s.EditorMode.FORM){const w=n.getActiveControl()?.getElement()?.control?.type===s.ControlType.TEXT?null:n.getActiveTextControlLimit();w&&(L=Math.min(Math.max(L,w.startIndex),w.endIndex),N=Math.min(Math.max(N,w.startIndex),w.endIndex));const q=e.getElementList(),G=q[L],H=q[N];if(G?.control?.type===s.ControlType.TEXTFIELD||H?.control?.type===s.ControlType.TEXTFIELD){const z=G?.controlId||H?.controlId;if(z){let _=-1,dt=-1;for(let Ct=L;Ct>=0;Ct--){const Kt=q[Ct];if(Kt.controlId!==z)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){_=Ct+1;break}}for(let Ct=N;Ct<q.length;Ct++){const Kt=q[Ct];if(Kt.controlId!==z)break;if(Kt.controlComponent===s.ControlComponent.POSTTEXTFIX||Kt.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||Kt.controlComponent===s.ControlComponent.POSTFIX||Kt.controlComponent===s.ControlComponent.POST_TEXT){dt=Ct-1;break}}_!==-1&&L<_&&(L=_),dt!==-1&&N>dt&&(N=dt)}}}let Q;if(X){const[v,w]=X.sort((q,G)=>q.index-G.index);Q={originalId:X[0].originalId??X[1].originalId,startIndex:v.index,endIndex:w.index},v.isCurrent?(L=v.index,N=v.length-1):(L=0,N=Q.endIndex-w.startIndex)}V.setRange(L,N,void 0,void 0,void 0,void 0,void 0,Q)}e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}function bo(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 Fi(o,t){return!!o&&!!t&&o.controlId===t}function wc(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 cr(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 Zc(o){const t=o.getDraw(),e=t.getRange(),n=e.getRange(),i=t.getElementList(),l=i[n.startIndex];if(!ae(l))return;let r=n.startIndex;for(;r>0;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE&&a.subTemplateExpanded){const u=cr(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||!ae(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 Qc(o,t,e){if(e.originControlId){const n=bo(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=bo(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=bo(o,n.controlId);if(i)return{isInParent:!0,parentControlId:i}}return{isInParent:!1}}}return{isInParent:!1}}function vc(o,t){const e=t.getDraw();if(e.isReadonly())return;const n=e.getRange();if(!n.getIsCanInput())return;n.getIsCollapsed()&&Zc(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 V=wc(d,l-1);if(V){const X=cr(d,V.labelIndex,e);e.getGlobalEvent().setCanvasEventAbility(),n.setRange(X,X),e.render({curIndex:X});return}}const f=e.getPosition().getPositionList(),p=f[l],C=f[l-1],I=p&&C&&p.rowIndex===C.rowIndex,m=R?.controlComponent===s.ControlComponent.PREFIX||R?.controlComponent===s.ControlComponent.PRETEXTFIX||R?.controlComponent===s.ControlComponent.PRE_TEXT||R?.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT,P=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,M=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,y=h?.control?.type===s.ControlType.TEXT&&(h.controlComponent===s.ControlComponent.PREFIX||h.controlComponent===s.ControlComponent.PRE_TEXT),Y=F&&R?.controlId===h?.controlId&&R?.originControlId===h?.originControlId&&R?.controlComponent===s.ControlComponent.VALUE,D=!!h&&!h.controlId&&!h.control;if(M&&m&&E&&I)return;const{isInParent:O,parentControlId:b}=Qc(d,l,R);if(P&&E&&I&&O&&!(h?.controlId===b&&!h?.originControlId&&(h?.controlComponent===s.ControlComponent.VALUE||h?.controlComponent===s.ControlComponent.PLACEHOLDER))){if(R.originControlId&&b)for(let X=l;X<d.length;X++){const N=d[X];if(Fi(N,b)){if(N.controlComponent===s.ControlComponent.VALUE){n.setRange(X,X),e.render({curIndex:X,isSubmitHistory:!1});return}if(N.controlComponent===s.ControlComponent.POSTFIX||N.controlComponent===s.ControlComponent.POSTTEXTFIX||N.controlComponent===s.ControlComponent.POST_TEXT)return}N.controlId!==b&&N.originControlId}return}if(P&&E&&I&&!O&&!(D&&!M&&!F)){if(y)return;if(g)return;{const V=l-1;c=i.removeControl(V),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(V,V),e.render({curIndex:V,isSubmitHistory:!1})):(n.setRange(c,c),e.render({curIndex:c}));return}}if(F&&h?.originControlId&&O&&b&&I){for(let V=l+1;V<d.length;V++){const X=d[V];if(Fi(X,b)){if(X.controlComponent===s.ControlComponent.VALUE||X.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(V,V),e.render({curIndex:V,isSubmitHistory:!1});return}break}if(X.controlId&&X.controlId!==b&&X.originControlId!==b)break}for(let V=l-1;V>=0;V--){const X=d[V];if(Fi(X,b)){if(X.controlComponent===s.ControlComponent.VALUE||X.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(V,V),e.render({curIndex:V,isSubmitHistory:!1});return}break}if(X.controlId&&X.controlId!==b&&X.originControlId!==b)break}return}if(e.getMode()===s.EditorMode.FORM&&F&&h?.originControlId&&I){const V=bo(d,h.originControlId);if(!V)return;for(let X=l-1;X>=0;X--){const N=d[X];if(N.controlId===V&&!N.originControlId){if(N.controlComponent===s.ControlComponent.VALUE||N.controlComponent===s.ControlComponent.PLACEHOLDER){n.setRange(X,X),e.render({curIndex:X,isSubmitHistory:!1});return}if(N.controlComponent===s.ControlComponent.PREFIX||N.controlComponent===s.ControlComponent.PRE_TEXT||N.controlComponent===s.ControlComponent.PRETEXTFIX||N.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)return}if(N.controlId&&N.controlId!==V&&N.originControlId!==V)break}return}if(F&&h?.controlId&&I&&!Y){const V=l;c=i.removeControl(V),e.getGlobalEvent().setCanvasEventAbility(),c===null?(n.setRange(V,V),e.render({curIndex:V,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 I=T[h];if(I.value===K){I.listId&&e.getListParticle().unsetList(),o.preventDefault();return}}const f=T[l];if(g&&f.rowFlex&&f.value===K){const I=n.getRangeRowElementList();if(I){const m=T[l-1];I.forEach(P=>{P.rowFlex=m?.rowFlex})}}const p=f.value===K?T[l-1]:f,C=T[r+1];if(p?.titleId&&C?.titleId&&p.level===C.level&&p.titleId!==C.titleId){const I=p.titleId,m=C.titleId;let P=r+1;for(;P<T.length&&T[P]?.titleId===m;)T[P].titleId=I,P++}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 dr(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 Kc(o){const t=o.getDraw(),n=t.getRange().getRange(),i=t.getElementList(),l=i[n.startIndex+1];if(!ae(l))return;const r=n.startIndex+1;for(;r<i.length;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE&&a.subTemplateExpanded){dr(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||!ae(d))break}}function Hc(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()&&Kc(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=dr(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 C=e.getTd();if(C?.linkTdNextId){const I=e.getTdById(C.linkTdNextId);I&&(p=!1,e.spliceElementList(I.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 _c(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),oe(a,[u],i,{isBreakWhenWrap:!0,editorOptions:e.getOptions()}),o.shiftKey&&d.areaId&&d.areaId!==a[l+1]?.areaId&&(u=pe(u,cn)),!(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 C=[...ue],I=p.controlComponent===s.ControlComponent.POSTFIX||p.controlComponent===s.ControlComponent.POSTTEXTFIX||p.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||p.controlComponent===s.ControlComponent.POST_TEXT,m=p.control?.type===s.ControlType.BUTTON&&!p.control?.buttonText;!I&&!m&&C.push(...Xe),C.forEach(P=>{const E=p[P];E!==void 0&&(u[P]=E)})}}const R=e.getControl(),h=R.getActiveControl();let g;const T=h?.getElement();if(T?.control?.type===s.ControlType.BUTTON&&!T.control?.buttonText)g=h.setValue([u]),~g&&R.emitControlContentChange();else if(h&&R.getIsRangeWithinControl())g=R.setValue([u]),R.emitControlContentChange();else{const C=e.getPosition().getCursorPosition();if(!C)return;const{index:I}=C;if(r){if(e.spliceElementList(a,I+1,0,[u]),d.titleId&&a[I+2]?.titleId===d.titleId){const m=ft();let P=I+2;for(;P<a.length&&a[P]?.titleId===d.titleId;)a[P].titleId=m,P++}}else e.spliceElementList(a,i+1,l-i,[u]);g=I+1}~g&&(n.setRange(g,g),e.render({curIndex:g})),o.preventDefault()}function ur(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 Ac(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,C=T&&!p?g.getActiveTextControlLimit():null,I=h[a],m=I?.controlComponent===s.ControlComponent.PREFIX||I?.controlComponent===s.ControlComponent.PRETEXTFIX||I?.controlComponent===s.ControlComponent.PRE_TEXT;let P=!1;if(m&&I?.originControlId){const O=I.originControlId;for(let b=a-1;b>=0;b--){const V=h[b];if(V.controlId===O&&!V.originControlId){P=!0;break}if(V.controlId&&V.controlId!==O&&V.originControlId!==O)break}}if(T&&!p&&g.getActiveControl()&&m&&!C&&!P){g.initNextControl({direction:Jt.UP});return}let E=1;if(ve(o)){const O=e.getLetterReg(),b=o.shiftKey&&!R&&d===l?.index?u:d;if(O.test(h[b]?.value)){let V=b-1;for(;V>0;){const X=h[V];if(!O.test(X.value))break;E++,V--}}}if(T&&!p){const O=h[d],b=O?.controlId;if(b&&O?.controlComponent===s.ControlComponent.VALUE){let V=!1;for(let X=d;X>=0;X--){const N=h[X];if(N.controlId!==b)break;if(N.control?.type===s.ControlType.TEXTFIELD){V=!0;break}}if(V){if(O.controlComponent===s.ControlComponent.VALUE&&ur(O))return;const X=d-E;if(X>=0){const N=h[X];if(N&&N.controlId===b&&N.controlComponent===s.ControlComponent.VALUE&&ur(N))return}}}}const M=C?Math.max(d-E,C.startIndex):d-E;let F=M,y=M;if(o.shiftKey&&l&&(d!==u?d===l.index?(F=d,y=u-E):(F=M,y=u):y=u),!o.shiftKey){const O=h[d];if(O.type===s.ElementType.TABLE){const b=O.trList,V=b.length-1,X=b[V],N=X.tdList.length-1,L=X.tdList[N];i.setPositionContext({isTable:!0,index:d,trIndex:V,tdIndex:N,tdId:L.id,trId:X.id,tableId:O.id}),F=L.value.length-1,y=F}else if(O.tableId&&d===0){const V=e.getOriginalElementList()[r.index],X=e.getTd();if(X?.linkTdPrevId){const N=e.getTdById(X.linkTdPrevId);N&&(i.setPositionContext({...r,isTable:!0,index:N.tableIndex,trIndex:N.trIndex,tdId:N.id,trId:N.trId,tableId:N.tableId}),F=N.value.length-1,y=F)}else{const N=V.trList;t:for(let L=0;L<N.length;L++){const W=N[L];if(W.id!==O.trId)continue;const S=W.tdList;for(let U=0;U<S.length;U++)if(S[U].id===O.tdId){if(L===0&&U===0)i.setPositionContext({isTable:!1}),F=r.index-1,y=F,e.getTableTool().dispose();else{let v=L,w=U-1;w<0&&(v=L-1,w=N[v].tdList.length-1);const q=N[v],G=q.tdList[w];i.setPositionContext({isTable:!0,index:r.index,trIndex:v,tdIndex:w,tdId:G.id,trId:q.id,tableId:O.tableId}),F=G.value.length-1,y=F}break t}}}}}if(!~F||!~y)return;const Y=e.getElementList();F=wn(Y,F),y=wn(Y,y),c.setRange(F,y);const D=F===y;e.updateTableTool(),e.render({curIndex:D?F:void 0,isSetCursor:D,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function Rr(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 kc(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,C=f&&p===s.ControlType.TEXT,I=f&&!C?T.getActiveTextControlLimit():null,m=g[r],P=m?.controlComponent===s.ControlComponent.POSTFIX||m?.controlComponent===s.ControlComponent.POSTTEXTFIX||m?.controlComponent===s.ControlComponent.POST_TEXT;let E=!1;if(P&&m?.originControlId){const V=m.originControlId;for(let X=r+1;X<g.length;X++){const N=g[X];if(N.controlId===V&&!N.originControlId){E=!0;break}if(N.controlId&&N.controlId!==V&&N.originControlId!==V)break}}if(f&&!C&&T.getActiveControl()&&P&&!I&&!E){T.initNextControl({direction:Jt.DOWN});return}let M=1;if(ve(o)){const V=e.getLetterReg(),X=o.shiftKey&&!h&&u===l?.index?R:u;if(V.test(g[X+1]?.value)){let N=X+2;for(;N<g.length;){const L=g[N];if(!V.test(L.value))break;M++,N++}}}if(f&&!C){const V=g[R],X=V?.controlId;if(X&&V?.controlComponent===s.ControlComponent.VALUE){let N=!1;for(let L=R;L>=0;L--){const W=g[L];if(W.controlId!==X)break;if(W.control?.type===s.ControlType.TEXTFIELD){N=!0;break}}if(N){if(V.controlComponent===s.ControlComponent.VALUE&&Rr(V))return;const L=R+M;if(L<g.length){const W=g[L];if(W&&W.controlId===X&&W.controlComponent===s.ControlComponent.VALUE&&Rr(W))return}}}}const F=I?Math.min(R+M,I.endIndex):R+M;let y=F,Y=F;if(o.shiftKey&&l&&(u!==R?u===l.index?(y=u,Y=F):(y=u+M,Y=R):y=u),!o.shiftKey){const V=g[R],X=g[R+1];if(X?.type===s.ElementType.TABLE){const L=X.trList[0],W=L.tdList[0];i.setPositionContext({isTable:!0,index:R+1,trIndex:0,tdIndex:0,tdId:W.id,trId:L.id,tableId:X.id}),y=0,Y=0}else if(V.tableId&&!X){const N=e.getTd(),L=N?.linkTdNextId?e.getTdById(N.linkTdNextId):void 0;if(L?.value.length)i.setPositionContext({...c,isTable:!0,index:L.tableIndex,trIndex:L.trIndex,tdId:L.id,trId:L.trId,tableId:L.tableId}),y=0,Y=y;else{const S=e.getOriginalElementList()[c.index].trList;t:for(let U=0;U<S.length;U++){const Q=S[U];if(Q.id!==V.trId)continue;const v=Q.tdList;for(let w=0;w<v.length;w++)if(v[w].id===V.tdId){if(U===S.length-1&&w===v.length-1)i.setPositionContext({isTable:!1}),y=c.index,Y=y,g=e.getElementList(),e.getTableTool().dispose();else{let G=U,H=w+1;H>v.length-1&&(G=U+1,H=0);const z=S[G],_=z.tdList[H];i.setPositionContext({isTable:!0,index:c.index,trIndex:G,tdIndex:H,tdId:_.id,trId:z.id,tableId:V.tableId}),y=0,Y=y}break t}}}}}const D=g.length-1;if(y>D||Y>D)return;const O=e.getElementList();y=wn(O,y,s.LocationPosition.AFTER),Y=wn(O,Y,s.LocationPosition.AFTER),d.setRange(y,Y);const b=y===Y;e.updateTableTool(),e.render({curIndex:b?y:void 0,isSetCursor:b,isSubmitHistory:!1,isCompute:!1}),o.preventDefault()}function Gc(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?Jt.UP:Jt.DOWN});else if(T&&l.getIsRangeWithinControl())o.preventDefault(),l.initNextControl({direction:o.shiftKey?Jt.UP:Jt.DOWN});else{o.preventDefault();const f=r.getRangeAnchorStyle(a,d),C={...f?$t(f,Xe):null,type:s.ElementType.TAB,value:""};oe(a,[C],c,{editorOptions:e.getOptions()}),e.insertElementList([C])}}function yi(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 xc(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:C,tableId:I}=g;if(u){const m=e.getOriginalElementList();if(p===0)if(m[f].originalId){const E=f-1,M=m[E];for(let F=M.trList.length-1;F>=0;F--){const y=M.trList[F].tdList.find(Y=>Y.tdIndex===C);if(y?.value.length){i.setPositionContext({isTable:!0,tableId:M.id,index:E,trIndex:F,tdIndex:C}),R=y.value.length-1,h=y.value.length-1;break}}}else i.setPositionContext({isTable:!1}),R=f-1,h=R,e.getTableTool().dispose();else{let P=-1,E=-1;const M=m[f].trList,F=M[p].tdList[C].colIndex;t:for(let D=p-1;D>=0;D--){const b=M[D].tdList;for(let V=0;V<b.length;V++){const X=b[V];if(X.colIndex===F||X.colIndex+X.colspan-1>=F&&X.colIndex<=F){P=D,E=V;break t}}}if(!~P||!~E)return;const y=M[P],Y=y.tdList[E];i.setPositionContext({isTable:!0,index:f,trIndex:P,tdIndex:E,tdId:Y.id,trId:y.id,tableId:I}),R=Y.value.length-1,h=R}}else{const m=e.getOriginalElementList(),P=m[f],E=P.trList;if(p===E.length-1){const M=f+1,F=m[M];if(F&&[P.id,P.originalId].includes(F.originalId)){for(let Y=C;Y>=0;Y--)if(F.trList[0].tdList[Y].value.length){i.setPositionContext({isTable:!0,index:M,tableId:F.id,trIndex:0,tdIndex:Y}),R=0,h=0;break}}else i.setPositionContext({isTable:!1}),R=f,h=R,e.getTableTool().dispose()}else{let M=-1,F=-1;const y=E[p].tdList[C].colIndex;t:for(let O=p+1;O<E.length;O++){const V=E[O].tdList;for(let X=0;X<V.length;X++){const N=V[X];if(N.colIndex===y||N.colIndex+N.colspan-1>=y&&N.colIndex<=y){M=O,F=X;break t}}}if(!~M||!~F)return;const Y=E[M],D=Y.tdList[F];i.setPositionContext({isTable:!0,index:f,trIndex:M,tdIndex:F,tdId:D.id,trId:Y.id,tableId:I}),R=D.value.length-1,h=R}}}else{let f=l;o.shiftKey&&(a===l.index?f=d[c]:f=d[a]);const{index:p,rowNo:C,rowIndex:I,coordinate:{rightTop:[m]}}=f;if(u&&I===0||!u&&I===e.getRowCount()-1)return;const P=yi({positionList:d,index:p,rowNo:C,isUp:u,cursorX:m});if(P<0)return;R=P,h=P,o.shiftKey&&(a!==c?a===l.index?R=a:h=c:u?h=c:R=a);const M=e.getElementList()[P];if(M.type===s.ElementType.TABLE){const{scale:F}=e.getOptions(),y=e.getMargins(),Y=M.trList;let D=-1,O=-1,b=-1;if(u)t:for(let V=Y.length-1;V>=0;V--){const N=Y[V].tdList;for(let L=0;L<N.length;L++){const W=N[L],S=W.x*F+y[3],U=W.width*F;if(m>=S&&m<=S+U){const Q=W.positionList,v=Q[Q.length-1],w=yi({positionList:Q,index:v.index+1,rowNo:v.rowNo-1,isUp:u,cursorX:m})||v.index;D=V,O=L,b=w;break t}}}else t:for(let V=0;V<Y.length;V++){const N=Y[V].tdList;for(let L=0;L<N.length;L++){const W=N[L],S=W.x*F+y[3],U=W.width*F;if(m>=S&&m<=S+U){const Q=W.positionList,v=yi({positionList:Q,index:-1,rowNo:-1,isUp:u,cursorX:m})||0;D=V,O=L,b=v;break t}}}if(~D&&~O&&~b){const V=Y[D],X=V.tdList[O];i.setPositionContext({isTable:!0,index:P,trIndex:D,tdIndex:O,tdId:X.id,trId:V.id,tableId:M.id}),R=b,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?Jt.UP:Jt.DOWN}),e.updateTableTool())}function Bc(o){return o.key.length===1&&!o.ctrlKey&&!o.metaKey&&!o.altKey}function Jc(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=C=>!!C?.controlId&&C.controlId===R.controlId&&(C.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 $c(o,t){if(t.isComposing)return;const e=t.getDraw();if(o.key===s.KeyMap.Backspace)vc(o,t);else if(o.key===s.KeyMap.Delete)Hc(o,t);else if(o.key===s.KeyMap.Enter)_c(o,t);else if(o.key===s.KeyMap.Left)Ac(o,t);else if(o.key===s.KeyMap.Right)kc(o,t);else if(o.key===s.KeyMap.Up||o.key===s.KeyMap.Down)xc(o,t);else if(ve(o)&&o.key.toLocaleLowerCase()===s.KeyMap.Z){if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return;e.getHistoryManager().undo(),o.preventDefault()}else if(ve(o)&&o.key.toLocaleLowerCase()===s.KeyMap.Y){if(e.isReadonly()&&e.getMode()!==s.EditorMode.FORM)return;e.getHistoryManager().redo(),o.preventDefault()}else if(ve(o)&&o.key.toLocaleLowerCase()===s.KeyMap.C)t.copy(),o.preventDefault();else if(ve(o)&&o.key.toLocaleLowerCase()===s.KeyMap.X)t.cut(),o.preventDefault();else if(ve(o)&&o.key.toLocaleLowerCase()===s.KeyMap.A)t.selectAll(),o.preventDefault();else if(ve(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?Gc(o,t):Bc(o)&&Jc(o,t)}function zc(o){return/[\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]/.test(o)}function jc(o){return/[a-zA-Z]/.test(o)}function qc(o,t){return zc(o)?t:jc(o)?"Times New Roman":t}function Do(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 Ne(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 bi(o){return!!o?.originControlId&&Do(o)}function qn(o){return!!o?.originControlId&&Ne(o)}function td(o,t){return!o||!t?!1:!!o.originControlId&&!!t.originControlId&&o.originControlId===t.originControlId&&o.controlId!==t.controlId}function un(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 hr(o,t){if(t)return o.find(e=>e.controlId===t&&!e.originControlId&&!!e.control?.type)}function gr(o,t,e){if(!t?.originControlId||e?.originControlId!==t.originControlId||!t.controlId||!e.controlId||t.controlId===e.controlId||!Ne(t)||!Do(e))return;const n=hr(o,t.originControlId);if(n?.control?.type===s.ControlType.TEXTFIELD)return n}function Di(o,t,e){Xe.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 Vi(o,t,e,n){o.controlId=t,o.control=e,o.controlComponent=s.ControlComponent.VALUE,delete o.originControlId,Di(o,e,n)}function Wi(o,t,e="input"){const n=re(),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=Ot=>{l.setPopupAwakeDisabled(!0);try{return Ot()}finally{l.setPopupAwakeDisabled(!1)}},p=()=>{f(()=>l.initControl())},C=(Ot,nt)=>{f(()=>{T.setRange(Ot,nt)})};let I=l.getActiveControl();const m=i.getElementList()[T.getRange().endIndex],P=m?.control?.type===s.ControlType.TEXT&&!!m?.originControlId&&(m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRE_TEXT||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POST_TEXT||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||m.controlComponent===s.ControlComponent.PLACEHOLDER);if(!I&&(l.getIsRangeWithinControl()||P)&&(p(),I=l.getActiveControl()),I){const Ot=I.getElement(),nt=i.getElementList()[T.getRange().endIndex],Ut=Ot?.controlId===nt?.controlId&&(Ot?.originControlId||null)===(nt?.originControlId||null),at=!!nt&&nt.controlComponent===s.ControlComponent.VALUE&&!!nt.controlId&&!nt.originControlId&&T.getRange().endIndex>0&&i.getElementList()[T.getRange().endIndex-1]?.originControlId===nt.controlId;(!Ut||at)&&(p(),I=l.getActiveControl())}const{endIndex:E}=T.getRange(),M=i.getElementList(),F=M[E],y=M[E+1];if(F?.type===s.ElementType.SUB_TEMPLATE&&y?.type===s.ElementType.SUB_TEMPLATE)return;const Y=i.getMode()===s.EditorMode.FORM;if(Y){const Ot=T.getRange();if(!(i.getElementList()[Ot.endIndex]?.control?.type===s.ControlType.TEXT)){const at=l.getActiveTextControlLimit();if(!I||!l.getIsRangeWithinControl()&&!l.getIsRangeInPostfix())return;if(at){const pt=T.getRange();if(pt.startIndex<at.startIndex||pt.endIndex>at.endIndex){const it=Math.min(Math.max(pt.endIndex,at.startIndex),at.endIndex);f(()=>{T.setRange(it,it),i.render({curIndex:it,isSubmitHistory:!1})});return}}const{endIndex:Gt}=T.getRange(),k=i.getElementList(),ot=k[Gt];if(!ot?.originControlId){if(ot?.controlId&&ot?.controlComponent===s.ControlComponent.VALUE){let pt=!1;for(let it=Gt;it>=0;it--){const de=k[it];if(de.controlId!==ot.controlId||de.originControlId)break;if(de.control?.type===s.ControlType.TEXTFIELD){pt=!0;break}}if(pt)return}}}}const D=T.getDefaultStyle()||t.compositionInfo?.defaultStyle||null,O=t.compositionInfo?.perfStartTime,b=nd(t,i.getElementList());g||i.getCursor().clearAgentDomValue();const{TEXT:V,HYPERLINK:X,SUBSCRIPT:N,SUPERSCRIPT:L,DATE:W,TAB:S}=s.ElementType,U=o.replaceAll(`
115
+ `,K),{startIndex:Q,endIndex:v}=T.getRange(),w=T.getRangeAnchorStyle(b,Q);if(!w)return;const q=Q>0?b[Q-1]:null,G=!!(w.controlId||w.control),z={...!G&&q?q:w,...D},_=i.isDesignMode(),dt=b[v+1],Ct=un(b,w.originControlId,i.getMode()),Kt=un(b,dt?.originControlId,i.getMode()),ge=!w.originControlId&&!dt?.originControlId&&Ne(w)&&Do(dt)&&!!w.controlId&&!!dt.controlId&&w.controlId!==dt.controlId,se=qn(w)&&bi(dt)&&!Ct&&!Kt,J=i.getMode()===s.EditorMode.EDIT?gr(b,w,dt):void 0,lt=!!w.originControlId&&Ne(w)&&dt?.controlId===w.originControlId&&!dt.originControlId&&dt.control?.type===s.ControlType.TEXTFIELD&&Ne(dt),$=!!w.originControlId&&Ne(w)&&dt?.controlId===w.originControlId&&!dt.originControlId&&dt.control?.type===s.ControlType.TEXTFIELD&&dt.controlComponent===s.ControlComponent.VALUE,tt=!!Ct&&Ct===Kt&&!!w.controlId&&!!dt?.controlId&&w.controlId!==dt.controlId&&(qn(w)||bi(dt))?Ct:null;if(Y&&(ge||se))return;const x=Do(dt)&&!dt?.originControlId,Rt=Ne(w)&&!w.originControlId||w.type===s.ElementType.CONTROL&&w.controlComponent===s.ControlComponent.VALUE&&dt?.type!==s.ElementType.CONTROL&&!w.originControlId,ht=[s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.NUMBER,s.ControlType.BUTTON],mt=(Ot,nt)=>!!(Ot?.controlId&&Ot.controlId===nt?.controlId&&(Ot.originControlId||null)===(nt.originControlId||null)),Pt=(Ot,nt)=>{if(Ot?.control?.type)return Ot.control.type;if(Ot?.controlId){for(let Ut=nt;Ut>=0;Ut--){const at=b[Ut];if(!mt(Ot,at))break;if(at.control?.type)return at.control.type}for(let Ut=nt+1;Ut<b.length;Ut++){const at=b[Ut];if(!mt(Ot,at))break;if(at.control?.type)return at.control.type}}},Qt=(Ot,nt)=>{const Ut=Pt(Ot,nt);return!!(Ut&&ht.includes(Ut))},Lt=Ot=>{const nt=b[Ot];let Ut=Ot;for(let at=Ot+1;at<b.length&&mt(nt,b[at]);at++)Ut=at;return Ut},At=!!(Qt(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&!w.originControlId&&mt(w,dt)&&Ne(dt)&&!dt?.value),ne=!!(Qt(w,Q)&&w.controlComponent===s.ControlComponent.VALUE&&w.originControlId&&mt(w,dt)&&Ne(dt))?un(b,w.originControlId,i.getMode()):null,Yt=hr(b,ne),Xt=x||Rt||At,bt=Xt?{...w,type:void 0,control:void 0,controlId:void 0,controlComponent:void 0,originControlId:void 0,color:r.defaultColor,highlight:void 0}:w,Ft=Xt||G?bt:z,Et=yt(U).map(Ot=>{const nt={value:Ot};if(_||!Ft.title?.disabled&&!Ft.control?.disabled){const Ut=b[v+1];(!Ft.type||Ft.type===V||Ft.type===X&&Ut?.type===X||Ft.type===W&&Ut?.type===W||Ft.type===N&&Ut?.type===N||Ft.type===L&&Ut?.type===L)&&La.forEach(at=>{if(at==="groupIds"&&!Ut?.groupIds)return;const Gt=Ft[at];Gt!==void 0&&(nt[at]=Gt)}),(D||Ft.type===S)&&Xe.forEach(at=>{const Gt=D?.[at]||Ft[at];Gt!==void 0&&(nt[at]=Gt)}),g&&(nt.underline=!0)}if(!Xt){const Ut=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(lt||$||J){const k=J||dt;nt.controlId=k.controlId,nt.control=k.control,nt.controlComponent=s.ControlComponent.VALUE,delete nt.originControlId,Di(nt,k.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)&&dt?.controlId&&dt.controlId!==w.controlId&&td(w,dt),Gt=w.controlId&&w.originControlId&&(w.controlComponent===s.ControlComponent.VALUE||w.controlComponent===s.ControlComponent.PLACEHOLDER);if(!lt&&!$&&!J&&Ut&&!nt.controlId){const k=un(b,w.originControlId,i.getMode());if(!k)return nt;let ot=null;for(let pt=Q;pt>=0;pt--){const it=b[pt];if(Je(it,k)&&it.control){ot=it.control;break}}nt.controlId=k,nt.controlComponent=s.ControlComponent.VALUE,ot&&(nt.control=ot),Di(nt,ot,r.defaultColor)}else if(at&&!nt.controlId){if(dt?.controlId&&dt.controlId!==w.controlId)if(dt.controlComponent===s.ControlComponent.PREFIX||dt.controlComponent===s.ControlComponent.PRETEXTFIX)for(let k=Q;k>=0;k--){const ot=b[k];if(ot.controlId===w.controlId&&(ot.controlComponent===s.ControlComponent.PREFIX||ot.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let pt=k-1;pt>=0;pt--){const it=b[pt];if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.PRETEXTFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRE_TEXT)){nt.controlId=it.controlId,nt.controlComponent=s.ControlComponent.VALUE,it.control&&(nt.control=it.control);break}if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}else(dt.controlComponent===s.ControlComponent.POSTFIX||dt.controlComponent===s.ControlComponent.POSTTEXTFIX)&&(nt.controlId=dt.controlId,nt.controlComponent=s.ControlComponent.VALUE,dt.control&&(nt.control=dt.control));if(!nt.controlId)for(let k=Q;k>=0;k--){const ot=b[k];if(ot.controlId===w.controlId&&(ot.controlComponent===s.ControlComponent.PREFIX||ot.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let pt=k-1;pt>=0;pt--){const it=b[pt];if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.PRETEXTFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRE_TEXT)){nt.controlId=it.controlId,nt.controlComponent=s.ControlComponent.VALUE,it.control&&(nt.control=it.control);break}if(it.controlId&&it.controlId!==w.controlId&&(it.controlComponent===s.ControlComponent.POSTFIX||it.controlComponent===s.ControlComponent.POSTTEXTFIX))break}break}}}else if(Gt&&!nt.controlId){const k=w.controlId;let ot=w.control;if(!ot)for(let pt=Q;pt>=0;pt--){const it=b[pt];if(it.controlId===k&&it.control&&(ot=it.control,it.controlComponent===s.ControlComponent.PREFIX||it.controlComponent===s.ControlComponent.PRETEXTFIX))break}nt.controlId=k,nt.originControlId=w.originControlId,nt.controlComponent=s.ControlComponent.VALUE,ot&&(nt.control=ot)}else if(w.controlId){let k=w.control;if(!k)for(let ot=Q;ot>=0;ot--){const pt=b[ot];if(Je(pt,w.controlId)&&pt.control){k=pt.control;break}}nt.controlId||(nt.controlId=w.controlId),k&&!nt.control&&(nt.control=k),nt.controlComponent||(nt.controlComponent=s.ControlComponent.VALUE)}else if(!nt.controlId&&!nt.control&&dt?.originControlId&&(dt.controlComponent===s.ControlComponent.PREFIX||dt.controlComponent===s.ControlComponent.PRETEXTFIX)){const k=un(b,dt.originControlId,i.getMode());if(!k)return nt;let ot=null;for(let pt=v;pt>=0;pt--){const it=b[pt];if(Je(it,k)&&it.control){ot=it.control;break}}nt.controlId=k,nt.controlComponent=s.ControlComponent.VALUE,ot&&(nt.control=ot)}}if(Ot&&Ot!==K){const Ut=qc(Ot,r.defaultFont);nt.font=Ut}return nt});let Mt;const St=a[u],Vt=a[u+1],me=a[u-1];if(g)Mt=Q;else{const Ot=k=>{if(Et?.length)for(let ot=0;ot<Et.length;ot++)b.splice(k+ot,0,Et[ot]);return k+Et.length-1},nt=Q+1,Ut=At?Lt(Q)+1:nt,at=()=>{let k=null,ot,pt=null;const it=i.getMode()===s.EditorMode.EDIT?gr(a,St,Vt):void 0;if(it?.controlId?(k=it.controlId,ot=it.control?.type):i.getMode()===s.EditorMode.EDIT&&qn(St)&&Vt?.controlId===St.originControlId&&!Vt.originControlId&&Vt.control?.type===s.ControlType.TEXTFIELD&&(Vt.controlComponent===s.ControlComponent.VALUE||Ne(Vt))?(k=St.originControlId,ot=s.ControlType.TEXTFIELD):qn(St)?k=un(a,St.originControlId,i.getMode()):bi(Vt)?k=un(a,Vt.originControlId,i.getMode()):tt?k=tt:St?.control?.type===s.ControlType.TEXT&&St.controlId&&!St.originControlId&&Ne(St)&&me?.originControlId===St.controlId&&(k=St.controlId,pt={startIndex:u-1,endIndex:u-1}),!k)return null;if(!ot)for(let kt=u;kt>=0;kt--){const zt=a[kt];if(Je(zt,k)&&zt.control?.type){ot=zt.control.type;break}if(zt.controlId&&zt.controlId!==k&&zt.originControlId!==k)break}return ot!==s.ControlType.TEXT&&!(i.getMode()===s.EditorMode.EDIT&&ot===s.ControlType.TEXTFIELD)?null:{parentControlId:k,activationIndex:(()=>{for(let kt=u+1;kt<a.length;kt++){const zt=a[kt];if(Je(zt,k))return kt;if(zt.controlId&&zt.controlId!==k&&zt.originControlId!==k)break}for(let kt=u;kt>=0;kt--){const zt=a[kt];if(Je(zt,k))return kt;if(zt.controlId&&zt.controlId!==k&&zt.originControlId!==k)break}return u})(),boundaryRange:pt}};Q!==v&&(i.removeSplitTdOtherRangeElements(),i.spliceElementList(b,nt,v-Q));const Gt=at();if(ne&&Yt?.control){const k=Lt(Q);Et.forEach(ot=>{Vi(ot,ne,Yt.control,r.defaultColor)}),oe(b,Et,k,{editorOptions:r}),i.spliceElementList(b,k+1,0,Et),Mt=k+Et.length}else if(Gt){const{parentControlId:k,activationIndex:ot,boundaryRange:pt}=Gt;C(ot,ot),p();const it=l.getActiveControl(),de=Vt?.controlId===k&&!Vt?.originControlId&&Vt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,kt=!!(St?.originControlId&&qn(St)&&de!==-1),zt=pt||(kt?{startIndex:u,endIndex:u}:de!==-1?{startIndex:u,endIndex:de}:{startIndex:Q,endIndex:v});C(zt.startIndex,zt.endIndex),it&&it.getElement()?.controlId===k&&(it.getElement()?.control?.type===s.ControlType.TEXT||it.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Et.forEach($n=>{Vi($n,k,it.getElement().control,r.defaultColor)}),Mt=it.setValue(Et,{range:zt,elementList:b}),l.emitControlContentChange(),C(Mt,Mt),p()):Xt?Mt=Ot(Ut):(Mt=l.setValue(Et),l.emitControlContentChange())}else if(Xt)Mt=Ot(Ut);else if(St?.originControlId&&(St.controlComponent===s.ControlComponent.POSTFIX||St.controlComponent===s.ControlComponent.POST_TEXT||St.controlComponent===s.ControlComponent.POSTTEXTFIX||St.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))if(I?.getElement()?.control?.type===s.ControlType.TEXT&&I.getElement()?.controlId===St.controlId&&(I.getElement()?.originControlId||null)===(St.originControlId||null))Mt=l.setValue(Et),l.emitControlContentChange();else{const ot=un(a,St.originControlId,i.getMode());if(!ot){Mt=Ot(nt);return}let pt;for(let de=u;de>=0;de--){const kt=a[de];if(Je(kt,ot)&&kt.control?.type){pt=kt.control.type;break}if(kt.controlId&&kt.controlId!==ot&&kt.originControlId!==ot)break}if(pt===s.ControlType.TEXT||i.getMode()===s.EditorMode.EDIT&&pt===s.ControlType.TEXTFIELD){const de=()=>{for(let Le=u+1;Le<a.length;Le++){const Ve=a[Le];if(Je(Ve,ot))return Le;if(Ve.controlId&&Ve.controlId!==ot&&Ve.originControlId!==ot)break}for(let Le=u;Le>=0;Le--){const Ve=a[Le];if(Je(Ve,ot))return Le;if(Ve.controlId&&Ve.controlId!==ot&&Ve.originControlId!==ot)break}return u},kt=Vt?.controlId===ot&&Vt?.controlComponent===s.ControlComponent.VALUE?u+1:-1,zt=kt!==-1?{startIndex:u,endIndex:kt}:{startIndex:u,endIndex:u},$n=de();C($n,$n),p();const Tn=l.getActiveControl();C(zt.startIndex,zt.endIndex),Tn&&Tn.getElement()?.controlId===ot&&(Tn.getElement()?.control?.type===s.ControlType.TEXT||Tn.getElement()?.control?.type===s.ControlType.TEXTFIELD)?(Et.forEach(Le=>{Vi(Le,ot,Tn.getElement().control,r.defaultColor)}),Mt=Tn.setValue(Et,{range:zt,elementList:b}),l.emitControlContentChange(),C(Mt,Mt),p()):Mt=Ot(nt)}else Mt=Ot(nt)}else if((St?.control?.type===s.ControlType.NUMBER||Vt?.control?.type===s.ControlType.NUMBER)&&I?.getElement()?.control?.type===s.ControlType.NUMBER&&l.getIsRangeWithinControl()){const k=l.getActiveControl();k&&typeof k.awake=="function"&&k.awake(),Mt=Q}else if((St?.control?.type===s.ControlType.SELECT||Vt?.control?.type===s.ControlType.SELECT)&&I?.getElement()?.control?.type===s.ControlType.SELECT&&l.getIsRangeWithinControl()){const k=l.getActiveControl();k&&typeof k.awake=="function"&&k.awake(),Mt=Q}else if(I?.getElement()?.control?.type===s.ControlType.DATE&&l.getIsRangeWithinControl()){const k=l.getActiveControl();k&&typeof k.awake=="function"&&k.awake(),Mt=Q}else St?.control?.type===s.ControlType.BUTTON||Vt?.control?.type===s.ControlType.BUTTON?I?.getElement()?.control?.type===s.ControlType.BUTTON&&I.getElement()?.control?.editable!==!1&&l.getIsRangeWithinControl()?(Mt=l.setValue(Et),l.emitControlContentChange()):Mt=Q:I&&l.getIsRangeWithinControl()?(Mt=l.setValue(Et),l.emitControlContentChange()):(St?.type==="control"||Vt?.type==="control")&&!Xt?Mt=Ot(nt):(oe(b,Et,Q,{editorOptions:r}),i.spliceElementList(b,nt,0,Et),Mt=Q+Et.length)}if(~Mt&&!g){const Ot=re()-n,nt=re();f(()=>{T.setRange(Mt,Mt),i.render({curIndex:Mt,isSubmitHistory:!g,traceLabel:`input:${e}`})}),Ri(r,`input:${e}`,re()-n,[{label:"mutate",duration:Ot},{label:"renderCall",duration:re()-nt}],{isComposing:g,textLength:Et.length,compositionChainDuration:e==="compositionend"&&O!==void 0?Number((re()-O).toFixed(2)):void 0})}g&&(t.compositionInfo={value:U,startIndex:Mt,endIndex:v,defaultStyle:D,perfStartTime:n})}function ed(o){o.compositionInfo&&(o.compositionInfo=null)}function nd(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 od(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 I=0;I<h.length;I++){const m=h[I];if(m.pageNo>f)break;m.pageNo===f&&m.rowNo===T&&p.push(I)}const C=p[0]-1;r=C<0?0:C,a=p[p.length-1]}const c=t.getOptions();await or(l.slice(r+1,a+1),c);const d=t.getControl();let u;d.getActiveControl()&&d.getIsRangeWithinControl()?(u=d.cut(),d.emitControlContentChange()):(t.spliceElementList(l,r+1,a-r),u=r),e.setRange(u,u),t.render({curIndex:u})}function id(o){return o.replace(/^(?:\r\n|\r|\n)+|(?:\r\n|\r|\n)+$/g,"")}async function sd(o,t){const e=o.getDraw(),n=e.getMode()===s.EditorMode.COMPARE,i=n||t?.isPlainText,{copy:l}=e.getOverride();if(l&&l()?.preventDefault!==!1)return;const r=e.getRange();let a=null;if(r.getRange().isCrossRowCol){const d=r.getRangeTableElement();if(!d)return;const u=e.getTableParticle().getRangeRowCol();if(!u)return;const R={type:s.ElementType.TABLE,value:"",colgroup:[],trList:[]},h=u[0],g=h[0].colIndex,T=h[h.length-1],f=T.colIndex+T.colspan-1;for(let p=g;p<=f;p++)R.colgroup.push(d.colgroup[p]);for(let p=0;p<u.length;p++){const C=u[p],I=d.trList[C[0].rowIndex],m={tdList:[],height:I.height,minHeight:I.minHeight};for(let P=0;P<C.length;P++)m.tdList.push(C[P]);R.trList.push(m)}a=n?[R]:wt([R])}else a=r.getIsCollapsed()?r.getRangeRowElementList():r.getSelectionElementList();if(i&&a?.length){const d=In(a,e.getOptions());await Xc(n?id(d):d);return}a?.length&&await or(a,e.getOptions())}function rd(o,t){const e=t.getDraw(),{drop:n}=e.getOverride();if(n&&n(o)?.preventDefault!==!1)return;o.preventDefault();const i=o.dataTransfer?.getData("text");if(i)t.input(i);else{const l=o.dataTransfer?.files;if(!l)return;for(let r=0;r<l.length;r++){const a=l[r];a.type.startsWith("image")&&Xi(t,a)}}}function Tr(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 ld(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=si.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&&si.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&&si.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 ad(o,t){const e=o.getDraw(),n=e.getPosition(),i=n.getPositionByXY({x:t.offsetX,y:t.offsetY});if(e.getMode()===s.EditorMode.FORM){const a=i.isTable&&e.getTd()?.value||e.getElementList(),c=i.isTable?i.tdValueIndex:i.index,d=a[c],u=cd(a,d),R=e.getEventBus();if(i.isDirectHit&&u?.controlId&&u.control?.type===s.ControlType.BUTTON&&!u.control.buttonText&&R.isSubscribe("buttonChange")){const h=a.filter(g=>g.controlId===u.controlId&&(g.originControlId||null)===(u.originControlId||null));R.emit("buttonChange",{evt:t,element:ct(u),elementList:ct(h),controlId:u.controlId,control:ct(u.control)});return}}if(i.isImage&&i.isDirectHit){const a=e.getElementList(),c=e.getEventBus(),d=a[i.index];if(c.isSubscribe("imageDblclick")&&c.emit("imageDblclick",{evt:t,element:d}),d.imgPreviewDisabled)return;e.getPreviewer().render();return}if(e.getIsPagingMode()&&e.getMode()===s.EditorMode.EDIT&&!~i.index&&i.zone){e.getZone().setZone(i.zone),e.clearSideEffect(),n.setPositionContext({isTable:!1});return}if((i.isCheckbox||i.isRadio)&&i.isDirectHit)return;const l=e.getRange(),r=Tr(o)||ld(o);r&&(l.setRange(r.startIndex,r.endIndex),e.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),l.setRangeStyle())}function cd(o,t){if(!t?.controlId)return null;const e=t.originControlId||null,n=l=>!!(l&&l.controlId===t.controlId&&(l.originControlId||null)===e);if(t.control?.type===s.ControlType.BUTTON)return t;const i=o.indexOf(t);for(let l=i;l>=0;l--){const r=o[l];if(!n(r))break;if(r.control?.type===s.ControlType.BUTTON)return r}for(let l=i+1;l<o.length;l++){const r=o[l];if(!n(r))break;if(r.control?.type===s.ControlType.BUTTON)return r}return null}function dd(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 fr={dblclick:ad,threeClick:dd};function ud(o){o.isComposing=!0}function Rd(o,t){const e=re();o.isComposing=!1;const n=o.getDraw(),i=n.getOptions();if(t.data)o.compositionInfo&&(o.compositionInfo.perfStartTime=e),Ia?setTimeout(()=>{o.compositionInfo&&Wi(t.data,o,"compositionend")},1):o.compositionInfo&&Wi(t.data,o,"compositionend");else{const r=o.compositionInfo?.cancel;if(ed(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",re()-e,[],{hasData:!!t.data,dataLength:t.data?.length||0})}function hd(o){o.compositionInfo&&(o.compositionInfo.cancel=!0)}const Yi={compositionstart:ud,compositionend:Rd,compositionCancel:hd};function gd(o,t){const e=t.getDraw();if(e.isReadonly())return;o.preventDefault();const i=e.getPageContainer();if(!Os(o.target,m=>m===i))return;const a=o.target.dataset.index;a&&e.setPageNo(Number(a));const c=e.getPosition(),d=c.adjustPositionContext({x:o.offsetX,y:o.offsetY});if(!d)return;const{isTable:u,tdValueIndex: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:C,dragFloatImageDisabled:I}}=e.getOptions();if(I){const m=t.cacheElementList?.[t.cacheRange.startIndex];if(m?.type===s.ElementType.IMAGE&&(m.imgDisplay===s.ImageDisplay.FLOAT_TOP||m.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM||m.imgDisplay===s.ImageDisplay.SURROUND))return}f.drawCursor({width:C,color:p,isBlink:!1,isFocus:!1})}const Td={dragover:gd};class fd{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)),la(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=Tr(this);r&&(n=this.draw.getElementList().slice(r.startIndex+1,r.endIndex+1))}if(!n)return;const i=Object.keys(t);n.forEach(r=>{i.forEach(a=>{const c=a;Reflect.set(r,c,t[c])})}),this.draw.render({isSetCursor:!1});const l=this.draw.getPainterOptions();(!l||!l.isDblclick)&&this.clearPainterStyle()}selectAll(){if(!this.draw.isSelectionDisabled())if(this.position.getPositionContext().isTable)this.draw.getTableOperate().tableSelectAll();else{const t=this.position.getPositionList();this.range.setRange(0,t.length-1),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1})}}mousemove(t){this.draw.isInteractionSuspended()||Uc(t,this)}mousedown(t){this.draw.isInteractionSuspended()||Vc(t,this)}click(){this.draw.isInteractionSuspended()||pa&&!this.draw.isReadonly()&&this.draw.getCursor().getAgentDom().focus()}mouseup(t){this.draw.isInteractionSuspended()||Wc(t,this)}mouseleave(t){this.draw.isInteractionSuspended()||Yc(t,this)}keydown(t){this.draw.isInteractionSuspended()||$c(t,this)}dblclick(t){this.draw.isInteractionSuspended()||fr.dblclick(this,t)}threeClick(){this.draw.isInteractionSuspended()||fr.threeClick(this)}input(t,e="input"){this.draw.isInteractionSuspended()||Wi(t,this,e)}async cut(){this.draw.isInteractionSuspended()||await od(this)}async copy(t){this.draw.isInteractionSuspended()||await sd(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()||rd(t,this)}dragover(t){this.draw.isInteractionSuspended()||Td.dragover(t,this)}}const mr={PAGE_SCALE:"pageScale"};class md{draw;options;cursor;canvasEvent;range;previewer;tableTool;hyperlinkParticle;control;dateParticle;imageParticle;dprMediaQueryList;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.canvasEvent=e,this.cursor=null,this.range=t.getRange(),this.previewer=t.getPreviewer(),this.tableTool=t.getTableTool(),this.hyperlinkParticle=t.getHyperlinkParticle(),this.dateParticle=t.getDateParticle(),this.imageParticle=t.getImageParticle(),this.control=t.getControl(),this.dprMediaQueryList=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)}register(){this.cursor=this.draw.getCursor(),this.addEvent()}addEvent(){window.addEventListener("blur",this.clearSideEffect),document.addEventListener("mousedown",this.clearSideEffect),document.addEventListener("mouseup",this.setCanvasEventAbility),document.addEventListener("wheel",this.setPageScale,{passive:!1}),document.addEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.addEventListener("change",this._handleDprChange)}removeEvent(){window.removeEventListener("blur",this.clearSideEffect),document.removeEventListener("mousedown",this.clearSideEffect),document.removeEventListener("mouseup",this.setCanvasEventAbility),document.removeEventListener("wheel",this.setPageScale),document.removeEventListener("visibilitychange",this._handleVisibilityChange),this.dprMediaQueryList.removeEventListener("change",this._handleDprChange)}clearSideEffect=t=>{if(!this.cursor)return;if(this.draw.isInteractionSuspended()){this.resetSideEffect();return}const e=t?.composedPath?.()[0]||t.target;if(this.draw.isTargetInsideEditor(e)){this.watchCursorActive();return}this.resetSideEffect()};resetSideEffect=()=>{this.cursor&&(this.cursor.recoveryCursor(),this.range.recoveryRangeStyle(),this.previewer.clearResizer(),this.tableTool.dispose(),this.hyperlinkParticle.clearHyperlinkPopup(),this.control.destroyControl(),this.dateParticle.clearDatePicker(),this.imageParticle.destroyFloatImage())};setCanvasEventAbility=()=>{this.canvasEvent.setIsAllowDrag(!1),this.canvasEvent.setIsAllowSelection(!1)};watchCursorActive(){this.range.getIsCollapsed()&&setTimeout(()=>{this.cursor?.getAgentIsActive()||this.cursor?.drawCursor({isFocus:!1,isBlink:!1})})}setPageScale=t=>{if(this.draw.isInteractionSuspended()||!this.draw.isTargetInsideEditor(t.target)||this.options.shortcutDisableKeys.includes(mr.PAGE_SCALE)||!t.ctrlKey)return;t.preventDefault();const{scale:e}=this.options;if(t.deltaY<0){const n=e*10+1;n<=30&&this.draw.setPageScale(n/10)}else{const n=e*10-1;n>=5&&this.draw.setPageScale(n/10)}};_handleVisibilityChange=()=>{if(document.visibilityState==="visible"){const t=this.range.getRange(),e=!!~t.startIndex&&!!~t.endIndex&&t.startIndex===t.endIndex;this.range.replaceRange(t),this.draw.render({isSetCursor:e,isCompute:!1,isSubmitHistory:!1,curIndex:t.startIndex})}};_handleDprChange=()=>{this.draw.setPageDevicePixel()}}class pd{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 Cd{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 C=n[p];if(!C.isSurround){const P=C.width+(C.offsetX||0);C.rowFlex===s.RowFlex.CENTER?g+=(d-P)/2:C.rowFlex===s.RowFlex.RIGHT&&(g+=d-P)}g+=C.offsetX||0,T+=C.offsetY||0;const I=g,m=T;for(let P=0;P<C.elementList.length;P++){const E=C.elementList[P],M=E.metrics,F=!ae(E)&&(E.imgDisplay!==s.ImageDisplay.INLINE&&E.type===s.ElementType.IMAGE||E.type===s.ElementType.LATEX)?C.ascent-M.height:C.ascent;E.left&&(g+=E.left),E.translateX&&(g+=E.translateX*R);const y={pageNo:i,index:f,value:E.value,rowIndex:a+p,rowNo:p,metrics:M,left:E.left||0,ascent:F,lineHeight:C.height,isFirstLetter:P===0,isLastLetter:P===C.elementList.length-1,coordinate:{leftTop:[g,T],leftBottom:[g,T+C.height],rightTop:[g+M.width,T],rightBottom:[g+M.width,T+C.height]}};if(E.imgDisplay===s.ImageDisplay.SURROUND||E.imgDisplay===s.ImageDisplay.FLOAT_TOP||E.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM){const Y=e[e.length-1];Y&&(y.metrics=Y.metrics,y.coordinate=Y.coordinate),E.imgFloatPosition||(E.imgFloatPosition={x:g,y:T,pageNo:i}),this.floatPositionList.push({pageNo:i,element:E,position:y,isTable:t.isTable,index:t.index,tdIndex:t.tdIndex,trIndex:t.trIndex,tdValueIndex:f,zone:u})}if(e.push(y),f++,g+=M.width,E.type===s.ElementType.TABLE&&!ae(E)){const Y=E.tdPadding||h,D=Y[1]+Y[3],O=Y[0]+Y[2];for(let b=0;b<E.trList.length;b++){const V=E.trList[b];for(let X=0;X<V.tdList.length;X++){const N=V.tdList[X];N.positionList=[];const L=N.rowList,W=this.computePageRowPosition({positionList:N.positionList,rowList:L,pageNo:i,startRowIndex:0,startIndex:0,startX:(N.x+Y[3])*R+I+(E.translateX||0)*R,startY:(N.y+Y[0])*R+m,innerWidth:(N.width-D)*R,isTable:!0,index:f-1,tdIndex:X,trIndex:b,zone:u});if(N.verticalAlign===s.VerticalAlign.MIDDLE||N.verticalAlign===s.VerticalAlign.BOTTOM){const S=L.reduce((v,w)=>v+w.height,0),U=(N.height-O)*R-S,Q=N.verticalAlign===s.VerticalAlign.MIDDLE?U/2:U;Math.floor(Q)>0&&N.positionList.forEach(v=>{const{coordinate:{leftTop:w,leftBottom:q,rightBottom:G,rightTop:H}}=v;w[1]+=Q,q[1]+=Q,G[1]+=Q,H[1]+=Q})}g=W.x,T=W.y}}g=I,T=m}}g=l,T+=C.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:[ct(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:C,left:I,isFirstLetter:m,coordinate:{leftTop:P,rightTop:E,leftBottom:M}}=r[f];if(u===C){if(C>u)break;if(P[0]-I<=e&&E[0]>=e&&P[1]<=n&&M[1]>=n){let F=f;const y=l[f];if(y.type===s.ElementType.TABLE)for(let D=0;D<y.trList.length;D++){const O=y.trList[D];for(let b=0;b<O.tdList.length;b++){const V=O.tdList[b],X=this.getPositionByXY({x:e,y:n,td:V,pageNo:c,tablePosition:r[f],isTable:!0,elementList:V.value,positionList:V.positionList});if(~X.index){const{index:N,hitLineStartIndex:L}=X,W=V.value[N];return{index:p,isCheckbox:X.isCheckbox||W.type===s.ElementType.CHECKBOX||W.controlComponent===s.ControlComponent.CHECKBOX,isRadio:W.type===s.ElementType.RADIO||W.controlComponent===s.ControlComponent.RADIO,isControl:!!W.controlId,isImage:X.isImage,isLabel:X.isLabel,isMacro:X.isMacro,isDirectHit:X.isDirectHit,isTable:!0,tdIndex:b,trIndex:D,tdValueIndex:N,tdId:V.id,trId:O.id,tableId:y.id,hitLineStartIndex:L}}}}if(y.type===s.ElementType.IMAGE||y.type===s.ElementType.LATEX)return{index:F,isDirectHit:!0,isImage:!0};if(y.type===s.ElementType.MENSTRUAL_HISTORY)return{index:F,isDirectHit:!0};if(y.type===s.ElementType.FETAL_HEART_POSITION)return{index:F,isDirectHit:!0};if(y.type===s.ElementType.TOOTH_POSITION){const{scale:D}=this.options,O=y.width*D;return e>=P[0]&&e<=P[0]+O?{index:F,isDirectHit:!0}:{index:F}}if(y.type===s.ElementType.CHECKBOX||y.controlComponent===s.ControlComponent.CHECKBOX)return{index:F,isDirectHit:!0,isCheckbox:!0};if(y.type===s.ElementType.LABEL)return{index:F,isDirectHit:!0,isLabel:!0};if(y.type===s.ElementType.MACRO||y.type===s.ElementType.CUSTOM_MACRO||y.type===s.ElementType.REUSABLE_ITEM||y.type===s.ElementType.SUB_TEMPLATE)return{index:F,isDirectHit:!0,isMacro:!0};if(y.type===s.ElementType.TAB&&y.listStyle===s.ListStyle.CHECKBOX){let D=F-1;for(;D>0;){const O=l[D];if(O.value===K&&O.listStyle===s.ListStyle.CHECKBOX)break;D--}return{index:D,isDirectHit:!0,isCheckbox:!0}}if(y.type===s.ElementType.RADIO||y.controlComponent===s.ControlComponent.RADIO)return{index:F,isDirectHit:!0,isRadio:!0};let Y;if(l[p].value!==K){const D=E[0]-P[0];e<P[0]+D/2&&(F=f-1,m&&(Y=f))}return{isDirectHit:!0,hitLineStartIndex:Y,index:F,isControl:!!y.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:C}=t;if(p&&C){const{leftTop:I}=C.coordinate,m=p.x*f+I[0],P=p.y*f+I[1],E=p.width*f,M=p.height*f;if(!(m<e&&e<m+E&&P<n&&n<P+M))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:C,coordinate:{leftTop:I,leftBottom:m}}=T[f];if(n>I[1]&&n<=m[1]){const P=r.findIndex(y=>y.pageNo===u&&y.rowNo===C),E=l[P],M=r[P],F=E.listStyle===s.ListStyle.CHECKBOX?this.draw.getMargins()[3]:M.coordinate.leftTop[0];if(e<F)~P?M.value===K?h=P:(h=P-1,g=P):h=p;else{if(E.listStyle===s.ListStyle.CHECKBOX&&e<I[0])return{index:P,isDirectHit:!0,isCheckbox:!0};h=p}R=!0;break}}if(!R){if(this.draw.getIsPagingMode()){const p=this.draw.getHeader(),C=p.getHeight(),I=p.getHeaderTop()+C,m=this.draw.getFooter(),E=this.draw.getHeight()-(m.getFooterBottom()+m.getHeight());if(d){if(n<I)return{index:-1,zone:s.EditorZone.HEADER};if(n>E)return{index:-1,zone:s.EditorZone.FOOTER}}else if(n<=E&&n>=I)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 C=r[p];if(C.pageNo!==u||C.rowNo!==0)continue;const{leftTop:I,rightTop:m}=C.coordinate;if(e<=f[3]||e>=I[0]&&e<=m[0]||r[p+1]?.rowNo!==0)return{index:C.index}}else{const p=T[T.length-1];if(p){const C=p.rowNo;for(let I=0;I<r.length;I++){const m=r[I];if(m.pageNo!==u||m.rowNo!==C)continue;const{leftTop:P,rightTop:E}=m.coordinate;if(e<=f[3]||e>=P[0]&&e<=E[0]||r[I+1]?.rowNo!==C)return{index:m.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 C=d.imgFloatPosition,I=C.x*r,m=C.y*r,P=d.width*r,E=d.height*r;if(e>=I&&e<=I+P&&n>=m&&n<=m+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:C,trIndex:I,tdIndex:m,tdValueIndex:P}=e,E=this.draw.getControl(),{newIndex:M}=E.moveCursor({index:p,isTable:C,trIndex:I,tdIndex:m,tdValueIndex:P});C?e.tdValueIndex=M:e.index=M}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&&!Un(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(ga(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 Id{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=Vn(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===we.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&&!this.draw.isContentReadonly()){u.initControl();return}u.destroyControl()}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}shrinkRange(){const{startIndex:t,endIndex:e}=this.range;t===e||!~t&&!~e||this.replaceRange({...this.range,startIndex:e})}setRangeStyle(){const t=this.listener.rangeStyleChange,e=this.eventBus.isSubscribe("rangeStyleChange");if(!t&&!e)return;const{startIndex:n,endIndex:i,isCrossRowCol:l}=this.range;if(!~n&&!~i)return;let r;if(l){const L=this.draw.getOriginalElementList(),W=this.position.getPositionContext();r=L[W.index]}else{const L=~i?i:0,W=this.draw.getElementList();r=this.getRangeAnchorStyle(W,L)}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(L=>!L.bold),h=!~a.findIndex(L=>!L.italic),g=!~a.findIndex(L=>!L.underline&&!L.control?.underline),T=!~a.findIndex(L=>!L.strikeout),f=r.color||null,p=r.highlight||null,C=r.rowFlex||null,I=r.vertical||null,m=r.rowMargin??this.options.defaultRowMargin,P=r.dashArray||[],E=r.level||null,M=r.listType||null,F=r.listStyle||null,y=g&&r.textDecoration||null,Y=!!this.draw.getPainterStyle(),D=this.historyManager.isCanUndo(),O=this.historyManager.isCanRedo(),b=r.groupIds||null,V=r.extension??null,X=r.deletePerson??"",N={type:c,undo:D,redo:O,painter:Y,font:d,size:u,bold:R,italic:h,underline:g,strikeout:T,deletePerson:X,color:f,highlight:p,rowFlex:C,vertical:I,rowMargin:m,dashArray:P,level:E,listType:M,listStyle:F,groupIds:b,textDecoration:y,extension:V};this._emitRangeStyle(N)}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 Ld{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 Ui{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 Pd extends Ui{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 Ed{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 Md{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:we.PAGE,elementList:T});const f=e[g];f&&a.push({index:g,type:we.TABLE,elementList:[f]}),R=g+1,u++}function h(g,T,f,p){if(!g)return;let C=f.map(M=>!M.type||Ce.includes(M.type)&&M.controlComponent!==s.ControlComponent.CHECKBOX&&M.controlComponent!==s.ControlComponent.RADIO&&!M.hide&&!M.control?.hide&&!M.area?.hide?M.value:K).filter(Boolean).join("");i&&(C=C.toLocaleLowerCase());const I=[],m=n?new RegExp(g):g;let{index:P,length:E}=bs(C,m);for(;P!==-1&&E!==0;){I.push({index:P,length:E});const M=bs(C,m,P+E);P=M.index,E=M.length}for(let M=0;M<I.length;M++){const{index:F,length:y}=I[M],Y=ft();for(let D=0;D<y;D++){const O=F+D+(p?.startIndex||0);r.push({type:T,index:O,groupId:Y,...p})}}}for(let g=0;g<a.length;g++){const T=a[g];if(T.type===we.TABLE){const f=T.elementList[0];for(let p=0;p<f.trList.length;p++){const C=f.trList[p];for(let I=0;I<C.tdList.length;I++){const m=C.tdList[I],P={tableId:f.id,tableIndex:T.index,trIndex:p,tdIndex:I,tdId:m.id};h(l,T.type,m.value,P)}}}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===we.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===we.TABLE){const{tableIndex:P,trIndex:E,tdIndex:M,index:F}=d;u=a[P]?.trList[E].tdList[M]?.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 P=this.searchMatchList[c-1];(!P||P.groupId!==d.groupId)&&this.searchNavigateScrollIntoView(u)}else t.fillStyle=i;const p=R[0],C=R[1],I=g[0]-R[0],m=h[1]-R[1];t.fillRect(p,C,I,m)}t.restore()}replace(t,e){if(this.draw.isReadonly()||t==null)return;let i=this.getSearchMatchList();const l=e?.index;if(di(l)){const f=[];i.forEach(p=>{const C=f[f.length-1];!C||C[0].groupId!==p.groupId?f.push([p]):C.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===we.TABLE){const{tableIndex:C,trIndex:I,tdIndex:m,index:P,tdId:E}=p;u&&E!==u&&(c=0),u=E;const M=C+a,F=h[M].trList[I].tdList[m].value,y=P+c,Y=F[y];if(!r&&(Y?.control?.deletable===!1||Y?.title?.deletable===!1))continue;if(t===""){this.draw.spliceElementList(F,y,1),c--,~R||(R=f);continue}if(d===p.groupId){this.draw.spliceElementList(F,y,1),c--;continue}~R||(R=f);for(let D=0;D<t.length;D++){const O=t[D];D===0?Y.value=O:(this.draw.spliceElementList(F,y+D,0,[{...Y,value:O}]),c++)}}else{const C=p.index+a,I=h[C];if(!r&&(I?.control?.deletable===!1||I?.title?.deletable===!1)||I.type===s.ElementType.CONTROL&&I.controlComponent!==s.ControlComponent.VALUE)continue;if(t===""){this.draw.spliceElementList(h,C,1),a--,~R||(R=f);continue}if(~R||(R=f),d===p.groupId){this.draw.spliceElementList(h,C,1),a--;continue}for(let m=0;m<t.length;m++){const P=t[m];m===0?I.value=P:(this.draw.spliceElementList(h,C+m,0,[{...I,value:P}]),a++)}}d=p.groupId}if(!~R)return;const g=i[R],T=g.index+(t.length-1);if(g.type===we.TABLE){const{tableIndex:f,trIndex:p,tdIndex:C,index:I}=g,m=h[f].trList[p].tdList[C].value[I];this.position.setPositionContext({isTable:!0,index:f,trIndex:p,tdIndex:C,tdId:m.tdId,trId:m.trId,tableId:m.tableId})}else this.position.setPositionContext({isTable:!1});this.draw.getRange().setRange(T,T),this.draw.render({curIndex:T})}}class Od extends Ui{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 Zn;(function(o){o.SOLID="solid",o.DASHED="dashed",o.DOTTED="dotted"})(Zn||(Zn={}));class Sd extends Ui{options;constructor(t){super(),this.options=t.getOptions()}_drawLine(t,e,n,i,l){const r=e+i;switch(t.beginPath(),l){case Zn.DASHED:t.setLineDash([3,1]);break;case Zn.DOTTED:t.setLineDash([1,1]);break}t.moveTo(e,n),t.lineTo(r,n),t.stroke()}_drawDouble(t,e,n,i){const r=e+i,a=n+3*this.options.scale;this.options.mode===s.EditorMode.PRINT||this.options.mode===s.EditorMode.COMPARE?t.strokeStyle="transparent":t.strokeStyle="red",t.beginPath(),t.moveTo(e,n),t.lineTo(r,n),t.stroke(),t.beginPath(),t.moveTo(e,a),t.lineTo(r,a),t.stroke()}_drawWave(t,e,n,i){const{scale:l}=this.options,r=1.2*l,a=1/l,c=n+2*r;t.beginPath();for(let d=0;d<i;d++){const u=r*Math.sin(a*d);t.lineTo(e+d,c+u)}t.stroke()}render(t){if(!this.fillRect.width)return;const{underlineColor:e,scale:n}=this.options,{x:i,y:l,width:r}=this.fillRect;t.save(),t.strokeStyle=this.fillColor||e,t.lineWidth=n;const a=Math.floor(l+2*t.lineWidth)+.5;switch(this.fillDecorationStyle){case s.TextDecorationStyle.WAVY:this._drawWave(t,i,a,r);break;case s.TextDecorationStyle.DOUBLE:this._drawDouble(t,i,a,r);break;case s.TextDecorationStyle.DASHED:this._drawLine(t,i,a,r,Zn.DASHED);break;case s.TextDecorationStyle.DOTTED:this._drawLine(t,i,a,r,Zn.DOTTED);break;default:this._drawLine(t,i,a,r);break}t.restore(),this.clearFillInfo()}}class Xd{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:jl});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||!zl.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 Qn{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}static formatNumberPlaceholder(t,e,n,i){const l=i===s.NumberType.CHINESE?da(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(jn.PAGE_NO);g.test(h)&&(h=Qn.formatNumberPlaceholder(h,e+u-R,g,c));const T=new RegExp(jn.PAGE_COUNT);T.test(h)&&(h=Qn.formatNumberPlaceholder(h,this.draw.getPageCount()-R,T,c));const f=this.draw.getWidth(),p=this.draw.getHeight(),C=this.draw.getPageNumberBottom(),I=p-C;t.save(),t.fillStyle=r,t.font=`${i*n}px ${l}`;let m=0;const P=this.draw.getMargins(),{width:E}=t.measureText(h);a===s.RowFlex.CENTER?m=(f-E)/2:a===s.RowFlex.RIGHT?m=f-E-P[1]:m=P[3],t.fillText(h,m,I),t.restore()}}class Nd{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=sa(()=>{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(Jt.UP):this.clientHeight-n<=this.thresholdPoints[1]?this._startMove(Jt.DOWN):e<this.thresholdPoints[2]?this._startMove(Jt.LEFT):this.clientWidth-e<this.thresholdPoints[3]?this._startMove(Jt.RIGHT):this._stopMove()};_move(t){const e=this.selectionContainer instanceof Document?window:this.selectionContainer,n=this.selectionContainer instanceof Document?window.scrollX:e.scrollLeft,i=this.selectionContainer instanceof Document?window.scrollY:e.scrollTop;t===Jt.DOWN?e.scrollTo(n,i+this.step):t===Jt.UP?e.scrollTo(n,i-this.step):t===Jt.LEFT?e.scrollTo(n-this.step,i):e.scrollTo(n+this.step,i),this.requestAnimationFrameId=window.requestAnimationFrame(this._move.bind(this,t))}_startMove(t){this.isMoving||(this.isMoving=!0,this._move(t))}_stopMove(){this.requestAnimationFrameId&&(window.cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=null,this.isMoving=!1)}}class yd{draw;range;options;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}getTrListGroupByCol(t){const e=ct(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),C=g.rowIndex,I=T.rowIndex+(T.rowspan-1),m=[];for(let P=0;P<h.length;P++){const E=h[P],M=[];for(let F=0;F<E.tdList.length;F++){const y=E.tdList[F],Y=y.colIndex,D=y.rowIndex;Y>=f&&Y<=p&&D>=C&&D<=I&&M.push(y)}M.length&&m.push(M)}return m.length?m:null}_drawOuterBorder(t){const{ctx:e,startX:n,startY:i,width:l,height:r,isDrawFullBorder:a,borderExternalWidth:c,skipTopBorderRanges:d=[]}=t,{scale:u}=this.options,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,C=a===s.TableBorder.EXTERNAL,I=a===s.TableBorder.INTERNAL;t.save(),a===s.TableBorder.DASH&&t.setLineDash([3,3]),t.lineWidth=d*R,t.strokeStyle=c||h,!p&&!I&&this._drawOuterBorder({ctx:t,startX:n,startY:i,width:g,height:T,borderExternalWidth:u,isDrawFullBorder:C,skipTopBorderRanges:f});for(let m=0;m<r.length;m++){const P=r[m];for(let E=0;E<P.tdList.length;E++){const M=P.tdList[E];if(M.slashTypes?.length&&this._drawSlash(t,M,n,i),!M.borderTypes?.length&&(p||C))continue;const F=M.width*R,y=M.height*R,Y=Math.round(M.x*R+n+F),D=Math.round(M.y*R+i),O=!!M.linkTdPrevId,b=!!M.linkTdNextId;if(t.translate(.5,.5),t.beginPath(),!O&&M.borderTypes?.includes(s.TdBorder.TOP)&&(t.moveTo(Y-F,D),t.lineTo(Y,D),t.stroke()),M.borderTypes?.includes(s.TdBorder.RIGHT)&&(t.moveTo(Y,D),t.lineTo(Y,D+y),t.stroke()),M.borderTypes?.includes(s.TdBorder.BOTTOM)&&(t.moveTo(Y,D+y),t.lineTo(Y-F,D+y),t.stroke()),M.borderTypes?.includes(s.TdBorder.LEFT)&&(t.moveTo(Y-F,D),t.lineTo(Y-F,D+y),t.stroke()),!p&&!C){if((!I||M.colIndex+M.colspan<l.length)&&(t.moveTo(Y,D),t.lineTo(Y,D+y),u&&u!==d&&M.colIndex+M.colspan===l.length)){const V=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=V}if(b||!I||M.rowIndex+M.rowspan<r.length){const V=u&&u!==d&&M.rowIndex+M.rowspan===r.length;if(V&&(t.stroke(),t.beginPath()),t.moveTo(Y,D+y),t.lineTo(Y-F,D+y),V){const X=t.lineWidth;t.lineWidth=u*R,t.stroke(),t.beginPath(),t.lineWidth=X}}t.stroke()}t.translate(-.5,-.5)}}t.restore()}_drawBackgroundColor(t,e,n,i){const{trList:l}=e;if(!l)return;const{scale:r}=this.options;for(let a=0;a<l.length;a++){const c=l[a];for(let d=0;d<c.tdList.length;d++){const u=c.tdList[d];if(!u.backgroundColor)continue;t.save();const 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 C=r.tdList[c-1],I=C?C.colIndex+C.colspan:c;for(let m=I;m<e.length;m++)if(this.getRowCountByColIndex(n.slice(0,l),m)===l){u=m;let E=0;for(let M=0;M<m;M++)E+=e[M].width;i=E;break}}else{const C=r.tdList[c-1];C&&(u=C.colIndex+C.colspan)}let R=0;for(let C=0;C<d.colspan;C++)R+=e[C+u].width;let h=0;for(let C=0;C<d.rowspan;C++){const I=n[C+l]||n[l];h+=I.height}const g=r.tdList.length-1===c;let T=a;if(!T&&d.rowspan>1){const C=n.length-1-l;T=d.rowspan-1===C}const f=a&&g;d.isLastRowTd=g,d.isLastColTd=T,d.isLastTd=f,d.x=i;let p=0;for(let C=0;C<l;C++){const I=n[C].tdList;for(let m=0;m<I.length;m++){const P=I[m];if(u>=P.colIndex&&u<P.colIndex+P.colspan){p+=P.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 C=f.colIndex,I=p.colIndex+(p.colspan-1),m=f.rowIndex,P=p.rowIndex+(p.rowspan-1);t.save();for(let E=0;E<d.length;E++){const M=d[E];for(let F=0;F<M.tdList.length;F++){const y=M.tdList[F],Y=y.colIndex,D=y.rowIndex;if(Y>=C&&Y<=I&&D>=m&&D<=P){const O=y.x*l,b=y.y*l,V=y.width*l,X=y.height*l;t.globalAlpha=r,t.fillStyle=a,t.fillRect(O+n,b+i,V,X)}}}t.restore()}render(t,e,n,i){this._drawBackgroundColor(t,e,n,i),this._drawBorder(t,e,n,i)}findPreRowSpanTd(t,e,n){for(let i=e;i>=0;i--){const l=t[i].tdList.find(r=>r.colIndex===n);if(l)return l}}computeTrHeight(t,e){const{scale:n,table:{tdPadding:i,defaultTrMinHeight:l}}=this.options,r=t.tdPadding||i,a=r[0]+r[2],c=t.trList;for(let 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 C=h.tdList.find(I=>I.colIndex===p);if(C){const I=e?e(C):C.rowList,m=I.reduce((E,M)=>E+M.height,0);C.rowList=I;const P=m/n+a;C.mainHeight=P,C.rowspan>1?(u[C.colIndex]=C.id,d[C.id]={td:C,rowSpan:[R,R+C.rowspan-1],preHeight:0,preMinHeight:0,extraHeight:P},T.push(P)):C.height<P?(C.height=P,C.realHeight=P,g.push(P)):g.push(C.height)}else{const I=d[u[p]];I?.rowSpan[1]==R&&g.push(I.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 C=h.tdList.find(I=>I.colIndex===p)??this.findPreRowSpanTd(c,R,p);if(C){const I=d[C.id]?.preHeight??0,m=d[C.id]?.preMinHeight??h.minHeight;C.height=f+I,C.realHeight=f+I,C.realMinHeight=m}}}this.computeRowColInfo(t)}}var Ke;(function(o){o.ROW="row",o.COL="col"})(Ke||(Ke={}));class bd{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),C=g[0],I=g[1]+p,m=a.trList[n].tdList[i],P=m.rowIndex,E=m.colIndex,M=a.height*c,F=a.width*c,y=document.createElement("div");y.classList.add(`${rt}-table-tool__select`),y.style.height=`${M*c}`,y.style.left=`${C}px`,y.style.top=`${I}px`,y.style.transform=`translate(-${this.TABLE_SELECT_OFFSET*c}px, ${-this.TABLE_SELECT_OFFSET*c}px)`,y.onclick=()=>{this.draw.getTableOperate().tableSelectAll()},this.container.append(y),this.toolTableSelectBtn=y;const Y=h.map(L=>L.height),D=document.createElement("div");D.classList.add(`${rt}-table-tool__row`),D.style.transform=`translateX(-${this.ROW_COL_OFFSET*c}px)`;for(let L=0;L<Y.length;L++){const W=Y[L]*c,S=document.createElement("div");S.classList.add(`${rt}-table-tool__row__item`),L===P&&S.classList.add("active"),S.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByRowIndex(h,L),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(D,L)};const U=document.createElement("div");U.classList.add(`${rt}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:L,order:Ke.ROW})},S.append(U),S.style.height=`${W}px`,D.append(S)}D.style.left=`${C}px`,D.style.top=`${I}px`,this.container.append(D),this.toolRowContainer=D;const O=document.createElement("div");O.classList.add(`${rt}-table-tool__quick__add`),O.style.height=`${M*c}`,O.style.left=`${C}px`,O.style.top=`${I+M}px`,O.style.transform=`translate(-${this.ROW_COL_QUICK_POSITION*c}px, ${this.ROW_COL_QUICK_OFFSET*c}px)`,O.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:h.length-1,tdIndex:0,tableId:a.id}),this.draw.getTableOperate().insertTableBottomRow()},this.container.append(O),this.toolRowAddBtn=O;const b=R.map(L=>L.width),V=document.createElement("div");V.classList.add(`${rt}-table-tool__col`),V.style.transform=`translateY(-${this.ROW_COL_OFFSET*c}px)`;for(let L=0;L<b.length;L++){const W=b[L]*c,S=document.createElement("div");S.classList.add(`${rt}-table-tool__col__item`),L===E&&S.classList.add("active"),S.onclick=()=>{const Q=this.draw.getTableParticle().getTdListByColIndex(h,L),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(V,L)};const U=document.createElement("div");U.classList.add(`${rt}-table-tool__anchor`),U.onmousedown=Q=>{this._mousedown({evt:Q,element:a,index:L,order:Ke.COL})},S.append(U),S.style.width=`${W}px`,V.append(S)}V.style.left=`${C}px`,V.style.top=`${I}px`,this.container.append(V),this.toolColContainer=V;const X=document.createElement("div");X.classList.add(`${rt}-table-tool__quick__add`),X.style.height=`${M*c}`,X.style.left=`${C+F}px`,X.style.top=`${I}px`,X.style.transform=`translate(${this.ROW_COL_QUICK_OFFSET*c}px, -${this.ROW_COL_QUICK_POSITION*c}px)`,X.onclick=()=>{this.position.setPositionContext({index:e,isTable:!0,trIndex:0,tdIndex:h[0].tdList.length-1||0,tableId:a.id}),this.draw.getTableOperate().insertTableRightCol()},this.container.append(X),this.toolColAddBtn=X;const N=document.createElement("div");N.classList.add(`${rt}-table-tool__border`),N.style.height=`${M}px`,N.style.width=`${F}px`,N.style.left=`${C}px`,N.style.top=`${I}px`;for(let L=0;L<h.length;L++){const W=h[L];for(let S=0;S<W.tdList.length;S++){const U=W.tdList[S],Q=document.createElement("div");Q.classList.add(`${rt}-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:Ke.ROW})},N.appendChild(Q);const v=document.createElement("div");if(v.classList.add(`${rt}-table-tool__border__col`),v.style.width=`${this.BORDER_VALUE}px`,v.style.height=`${U.height*c}px`,v.style.top=`${U.y*c}px`,v.style.left=`${(U.x+U.width)*c-this.BORDER_VALUE/2}px`,v.onmousedown=w=>{this._mousedown({evt:w,element:a,index:U.colIndex+U.colspan-1,order:Ke.COL})},N.appendChild(v),d&&U.colIndex===0){const w=document.createElement("div");w.classList.add(`${rt}-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=q=>{this._mousedown({evt:q,element:a,index:0,isLeftStartBorder:!0,order:Ke.COL})},N.appendChild(w)}}}this.container.append(N),this.toolBorderContainer=N}_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,C=this.draw.getMargins(),I=C[0],m=C[1],P=I,E=d-m;this.mousedownX=e.x,this.mousedownY=e.y;const M=e.target,F=this.canvas.getBoundingClientRect(),y=window.getComputedStyle(M).cursor;document.body.style.cursor=y,this.canvas.style.cursor=y;let Y=0,D=0;const O=document.createElement("div");O.classList.add(`${rt}-table-anchor__line`),i===Ke.ROW?(O.classList.add(`${rt}-table-anchor__line__row`),O.style.width=`${d}px`,Y=0,D=h+this.mousedownY-F.top):(O.classList.add(`${rt}-table-anchor__line__col`),O.style.height=`${u}px`,Y=this.mousedownX-F.left,D=h),O.style.left=`${Y}px`,O.style.top=`${D}px`,this.container.append(O),this.anchorLine=O;let b=0,V=0;const X=N=>{const L=this._mousemove(N,i,Y,D);L&&(b=L.dx,V=L.dy)};document.addEventListener("mousemove",X),document.addEventListener("mouseup",()=>{let N=!1;if(i===Ke.ROW){const L=l.trList,W=L[n]||L[n-1],{defaultTrMinHeight:S}=this.options.table;V<0&&W.height+V<S&&(V=S-W.height),V&&(W.height+=V,W.minHeight=W.height,N=!0)}else{const{colgroup:L}=l;if(L&&b)if(c&&r){L[n].width-b/a<=this.MIN_TD_WIDTH&&(b=(L[n].width-this.MIN_TD_WIDTH)*a);const W=p+(l.translateX||0)*a;W+b<P&&(b=P-W),L[n].width-=b/a,l.width-=b/a,l.translateX=(l.translateX||0)+b/a,N=!0}else{const W=L[n].width;b<0&&W*a+b<this.MIN_TD_WIDTH*a&&(b=this.MIN_TD_WIDTH*a-W*a);const S=L[n+1]?.width;if(b>0&&S&&S*a-b<this.MIN_TD_WIDTH*a&&(b=S*a-this.MIN_TD_WIDTH*a),n===L.length-1){const Q=p+(l.translateX||0)*a+l.width*a;Q+b>E&&(b=E-Q)}b&&(L.length-1!==n&&(L[n+1].width-=b/a),L[n].width+=b/a,N=!0)}}N&&this.draw.render({isSetCursor:!1}),O.remove(),document.removeEventListener("mousemove",X),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),e.preventDefault()}_mousemove(t,e,n,i){if(!this.anchorLine)return null;const l=t.x-this.mousedownX,r=t.y-this.mousedownY;return e===Ke.ROW?this.anchorLine.style.top=`${i+r}px`:this.anchorLine.style.left=`${n+l}px`,t.preventDefault(),{dx:l,dy:r}}}class Dd{draw;options;container;hyperlinkPopupContainer;hyperlinkDom;constructor(t){this.draw=t,this.options=t.getOptions(),this.container=t.getContainer();const{hyperlinkPopupContainer:e,hyperlinkDom:n}=this._createHyperlinkPopupDom();this.hyperlinkDom=n,this.hyperlinkPopupContainer=e}_createHyperlinkPopupDom(){const t=document.createElement("div");t.classList.add(`${rt}-hyperlink-popup`);const e=document.createElement("a");return e.target="_blank",e.rel="noopener",t.append(e),this.container.append(t),{hyperlinkPopupContainer:t,hyperlinkDom:e}}drawHyperlinkPopup(t,e){const{coordinate:{leftTop:[n,i]},lineHeight:l}=e,r=this.draw.getHeight(),a=this.draw.getPageGap(),c=this.draw.getPageNo()*(r+a);this.hyperlinkPopupContainer.style.display="block",this.hyperlinkPopupContainer.style.left=`${n}px`,this.hyperlinkPopupContainer.style.top=`${i+c+l}px`;const d=t.url||"#";this.hyperlinkDom.href=d,this.hyperlinkDom.title=d,this.hyperlinkDom.innerText=d}clearHyperlinkPopup(){this.hyperlinkPopupContainer.style.display="none"}openHyperlink(t){const e=window.open(t.url,"_blank");e&&(e.opener=null)}render(t,e,n,i){t.save(),t.font=e.style,e.color||(e.color=this.options.defaultHyperlinkColor),t.fillStyle=e.color,e.underline===void 0&&(e.underline=!0),t.fillText(e.value,n,i),t.restore()}}class Vd{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:l,label:{defaultBackgroundColor:r,defaultColor:a,defaultBorderRadius:c,defaultPadding:d}}=this.options,u=e.label?.backgroundColor||r,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 Wd{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,Oo(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,C=h.width+T*2,I=g+f*2,m=e.metrics,P=n,E=i-m.boundingBoxAscent+(m.boundingBoxAscent+m.boundingBoxDescent-I)/2;t.fillStyle=R,this._drawRoundedRect(t,P,E,C,I,p),t.fill(),t.fillStyle=u,t.textBaseline="middle",t.fillText(l,n+T,E+I/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 C=p+f;if(t.fillStyle=u,t.fillText("]",C,i),e.type==="reusableItem"){const I=t.measureText("[").width+f+t.measureText("]").width;if(t.lineWidth=r,this.draw.isPrintLikeMode()?t.strokeStyle="transparent":t.strokeStyle=c||"red",e.strikeout){const m=i-3*r,P=i+3.5*r;t.beginPath(),t.moveTo(n,m),t.lineTo(n+I,m),t.stroke(),t.beginPath(),t.moveTo(n,P),t.lineTo(n+I,P),t.stroke()}else if(e.underline&&e.textDecoration?.style==="double"){const m=Math.floor(i+2*r)+.5,P=3*r;t.beginPath(),t.moveTo(n,m),t.lineTo(n+I,m),t.stroke(),t.beginPath(),t.moveTo(n,m+P),t.lineTo(n+I,m+P),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,C=i-T/2;t.beginPath(),t.moveTo(p,C-2*r),t.lineTo(p+5*r,C-2*r),t.lineTo(p+2.5*r,C+2*r),t.closePath(),t.fillStyle="#666666",t.fill();const I=p+6*r;t.fillStyle=d,t.fillText("]",I,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 Yd{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=Oi(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*Ms[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 Ud{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 wd{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 Zd{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 Qd{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 vd{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(jn.PAGE_NO);f.test(T)&&(T=Qn.formatNumberPlaceholder(T,e+1,f,u));const p=new RegExp(jn.PAGE_COUNT);p.test(T)&&(T=Qn.formatNumberPlaceholder(T,this.draw.getPageCount(),p,u));const C=t.measureText(T);if(c){const I=this.draw.getPagePixelRatio(),m=document.createElement("canvas"),P=m.getContext("2d"),E=C.width,M=C.actualBoundingBoxAscent+C.actualBoundingBoxDescent,F=Math.sqrt(Math.pow(E,2)+Math.pow(M,2)),y=F+2*d[0]*R,Y=F+2*d[1]*R;m.width=y,m.height=Y,m.style.width=`${y*I}px`,m.style.height=`${Y*I}px`,P.translate(y/2,Y/2),P.rotate(-45*Math.PI/180),P.translate(-y/2,-Y/2),P.font=`${r*R}px ${l}`,P.fillStyle=a,P.fillText(T,(y-E)/2,(Y-M)/2+C.actualBoundingBoxAscent);const D=t.createPattern(m,"repeat");D&&(t.fillStyle=D,t.fillRect(0,0,h,g))}else{const I=h/2,m=g/2;t.fillStyle=a,t.translate(I,m),t.rotate(-45*Math.PI/180),t.fillText(T,-C.width/2,C.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)),C=p+2*a[0]*c,I=p+2*a[1]*c;T.width=C,T.height=I,T.style.width=`${C*g}px`,T.style.height=`${I*g}px`,f.translate(C/2,I/2),f.rotate(-45*Math.PI/180),f.translate(-C/2,-I/2),f.drawImage(this.imageCache.get(i),(C-R)/2,(I-h)/2,R,h);const m=t.createPattern(T,"repeat");m&&(t.fillStyle=m,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 Kd{draw;control;options;highlightList;highlightMatchResult;constructor(t){this.draw=t.getDraw(),this.control=t,this.options=this.draw.getOptions(),this.highlightList=[],this.highlightMatchResult=[]}getControlHighlight(t,e){const{control:{activeBackgroundColor:n,disabledBackgroundColor:i,existValueBackgroundColor:l,noValueBackgroundColor:r,inlineControlBackgroundColor:a}}=this.options,c=t[e],d=this.draw.isPrintLikeMode(),u=this.draw.getMode(),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,C=!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||(C=!d&&!!r&&!!c.controlId&&!this.control.getIsExistValueByElementListIndex(t,e));const I=R&&!!a&&(g===s.ControlType.NUMBER||g===s.ControlType.SELECT||g===s.ControlType.DATE);return(T?n:"")||(f?i:"")||(p?l:"")||(C?r:"")||(I?a:"")}getIsInlineControlBackground(t,e){const n=this.draw.getMode(),i=this._getControlType(t,e);return!!((n===s.EditorMode.EDIT||n===s.EditorMode.FORM)&&this.options.control.inlineControlBackgroundColor&&(i===s.ControlType.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 C=0;C<p.tdList.length;C++){const I=p.tdList[C],m={tableId:r.id,tableIndex:l-1,trIndex:f,tdIndex:C,tdId:I.id};e(I.value,m)}}}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(C=>({...C,...f,...i,index:C.index+d})))}}};this.highlightMatchResult=[],e(this.draw.getOriginalMainElementList())}renderHighlightList(t,e){if(!this.highlightMatchResult?.length)return;const{searchMatchAlpha:n,searchMatchColor:i}=this.options,l=this.draw.getPosition().getOriginalPositionList(),r=this.draw.getOriginalElementList();t.save();for(let a=0;a<this.highlightMatchResult.length;a++){const c=this.highlightMatchResult[a];let d=null;if(c.tableId){const{tableIndex:I,trIndex:m,tdIndex:P,index:E}=c;d=r[I]?.trList[m].tdList[P]?.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],C=R[1]-u[1];t.fillRect(T,f,p,C)}t.restore()}}const pr={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)"}},Hd="#ff4d4f",_d=5e3,wi=4;class Ad{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})},_d))}getMarks(){return this.marks}render(t,e,n,i,l,r,a){if(!this.marks.length||this.draw.isPrintLikeMode())return;const c=this._getRegions(e,n,i,l,r,a);if(c.length){t.save();for(let d=0;d<c.length;d++){const u=c[d],R=this._getStyle(u.mark),h=Math.max(1,this.options.scale),g=u.x-h,T=u.y-h,f=Math.max(1,u.width+h*2),p=Math.max(1,u.height+h*2),C=Math.max(2,this.options.scale*2);if(this.underlineVisible&&R.borderColor&&u.hasUnderline&&(t.lineWidth=C,t.strokeStyle=R.borderColor,t.beginPath(),t.moveTo(u.underlineX,u.underlineY),t.lineTo(u.underlineRight,u.underlineY),t.stroke()),u.drawRequired){this._renderRequiredMark(t,u,g);continue}if(R.borderColor){t.lineWidth=C;const I=Math.min(Math.max(8*this.options.scale,p*.3),p/2),m=g+f,P=T+p;t.beginPath(),u.drawLeft&&(t.moveTo(g+I,T),t.lineTo(g,T),t.lineTo(g,P)),u.drawRight&&(t.moveTo(m-I,P),t.lineTo(m,P),t.lineTo(m,T)),t.stroke()}}t.restore()}}_getRegions(t,e,n,i,l,r){const a=this._getParentMap(t),c=this.marks.map(h=>this._getTargetControlIds(t,h)),d=c.map(h=>this._getTitleTargets(t,h)),u=[];for(let h=0;h<n.length;h++){const g=n[h],T=new Map,f=e[g.startIndex],p=f?Math.min(f.coordinate.leftTop[0],f.coordinate.leftBottom[0])-(g.offsetX||0):0,C=f?p+(r||this.draw.getInnerWidth()):0;for(let I=0;I<g.elementList.length;I++){const m=g.elementList[I],P=g.startIndex+I,E=e[P];if(!E||l===s.EditorZone.MAIN&&E.pageNo!==i)continue;const M=this._getTargetIdsForElement(this._getQualityTargetId(m),c,a);for(let v=0;v<d.length;v++){const w=d[v].get(P);w&&w.forEach(q=>{M.some(G=>G.markIndex===v&&G.controlId===q)||M.push({markIndex:v,controlId:q})})}if(!M.length)continue;const F=E.coordinate.leftTop,y=E.coordinate.rightTop,Y=E.coordinate.leftBottom,D=E.coordinate.rightBottom,O=Math.min(F[0],Y[0]),b=Math.max(y[0],D[0]),V=Math.min(F[1],y[1]),X=Math.max(Y[1],D[1]),N=E.metrics.boundingBoxAscent+E.metrics.boundingBoxDescent,L=V+E.ascent-E.metrics.boundingBoxAscent,W=N>0?L:V,S=N>0?L+N:X,U=this._isButtonElement(m),Q=f?Math.max(O,Math.min(b,C)):b;for(let v=0;v<M.length;v++){const{markIndex:w,controlId:q}=M[v],G=`${w}:${q}:${g.startIndex}`,H=T.get(G),z={x:O,y:W,right:b,bottom:S};if(H){const _=this._mergeBounds(H,z);H.x=_.x,H.y=_.y,H.width=Math.max(1,_.right-_.x),H.height=Math.max(1,_.bottom-_.y),U||(H.hasUnderline?(H.underlineX=Math.min(H.underlineX,O),H.underlineY=Math.max(H.underlineY,S+wi),H.underlineRight=Math.max(H.underlineRight,Q)):(H.underlineX=O,H.underlineY=S+wi,H.underlineRight=Q),H.hasUnderline=!0)}else T.set(G,{mark:this.marks[w],targetKey:`${w}:${q}`,x:O,y:W,width:Math.max(1,b-O),height:Math.max(1,S-W),baseline:V+E.ascent,font:m.style||this.draw.getElementFont(m,this.options.scale),underlineX:O,underlineY:S+wi,underlineRight:Q,hasUnderline:!U,drawLeft:!1,drawRight:!1,drawRequired:!1})}}u.push(...T.values())}const R=new Map;for(let h=0;h<u.length;h++){const g=u[h],T=R.get(g.targetKey)||[];T.push(g),R.set(g.targetKey,T)}return R.forEach(h=>{this._isRequiredMark(h[0].mark)?h[0].drawRequired=!0:(h[0].drawLeft=!0,h[h.length-1].drawRight=!0)}),u}_renderRequiredMark(t,e,n){t.save(),t.font=e.font,t.fillStyle=e.mark.style?.borderColor||Hd,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{...pr[t.type?.toLowerCase()||"error"]||pr.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 kd{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 to{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&&!ys(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?$t(d,["control","controlId",...Re]):pe(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};oe(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&&Fs(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 P=this.clearSelect(e,{isIgnoreDeletedRule:n.isIgnoreDeletedRule});~P&&(this.control.repaintControl({curIndex:P}),this.control.emitControlContentChange({controlValue:[]}))}return}const g=this.getValue(e)[0],T=g?$t(g,Xe):$t(i[l.startIndex],Re),f=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~f)return;c||this.control.removePlaceholder(f,e);const p=pe(i[f],Xe),C=f+1,I=yt(h),m=this.control.getDraw();for(let P=0;P<I.length;P++){const E={...T,...p,type:s.ElementType.TEXT,value:I[P],controlComponent:s.ControlComponent.VALUE};(E.color===this.options.control.bracketColor||E.color===this.options.control.placeholderColor)&&(E.color=this.options.defaultColor),oe(i,[E],f,{editorOptions:this.options}),m.spliceElementList(i,C+P,0,[E])}if(this.control.setControlProperties({code:t},{elementList:i,range:{startIndex:f,endIndex:f}}),!e.range){const P=C+I.length-1;this.control.repaintControl({curIndex:P}),this.control.emitControlContentChange({context:e}),u||this.destroy()}}_createSelectPopupDom(){const t=this.element.control,e=t.valueSets;if(!Array.isArray(e)||!e.length)return;const n=this.control.getPosition();if(!n)return;const i=document.createElement("div");i.classList.add(`${rt}-select-control-popup`),i.setAttribute(Be,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(C=>C===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&&Ds(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 Gd(o){Cr=o}function Fe(o){return o instanceof Array||Object.prototype.toString.call(o)==="[object Array]"}function Pn(o){return o!=null&&Object.prototype.toString.call(o)==="[object Object]"}function Ht(o,t){return Object.prototype.hasOwnProperty.call(o,t)}function Zi(o){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(o).length===0;var t;for(t in o)if(Ht(o,t))return!1;return!0}function fe(o){return o===void 0}function $e(o){return typeof o=="number"||Object.prototype.toString.call(o)==="[object Number]"}function eo(o){return o instanceof Date||Object.prototype.toString.call(o)==="[object Date]"}function Ir(o,t){var e=[],n,i=o.length;for(n=0;n<i;++n)e.push(t(o[n],n));return e}function Rn(o,t){for(var e in t)Ht(t,e)&&(o[e]=t[e]);return Ht(t,"toString")&&(o.toString=t.toString),Ht(t,"valueOf")&&(o.valueOf=t.valueOf),o}function He(o,t,e,n){return xr(o,t,e,n,!0).utc()}function xd(){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 Nt(o){return o._pf==null&&(o._pf=xd()),o._pf}var Qi;Array.prototype.some?Qi=Array.prototype.some:Qi=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 vi(o){var t=null,e=!1,n=o._d&&!isNaN(o._d.getTime());if(n&&(t=Nt(o),e=Qi.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 Vo(o){var t=He(NaN);return o!=null?Rn(Nt(t),o):Nt(t).userInvalidated=!0,t}var Lr=st.momentProperties=[],Ki=!1;function Hi(o,t){var e,n,i,l=Lr.length;if(fe(t._isAMomentObject)||(o._isAMomentObject=t._isAMomentObject),fe(t._i)||(o._i=t._i),fe(t._f)||(o._f=t._f),fe(t._l)||(o._l=t._l),fe(t._strict)||(o._strict=t._strict),fe(t._tzm)||(o._tzm=t._tzm),fe(t._isUTC)||(o._isUTC=t._isUTC),fe(t._offset)||(o._offset=t._offset),fe(t._pf)||(o._pf=Nt(t)),fe(t._locale)||(o._locale=t._locale),l>0)for(e=0;e<l;e++)n=Lr[e],i=t[n],fe(i)||(o[n]=i);return o}function no(o){Hi(this,o),this._d=new Date(o._d!=null?o._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),Ki===!1&&(Ki=!0,st.updateOffset(this),Ki=!1)}function ye(o){return o instanceof no||o!=null&&o._isAMomentObject!=null}function Pr(o){st.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+o)}function Me(o,t){var e=!0;return Rn(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+=`
116
116
  [`+l+"] ";for(r in arguments[0])Ht(arguments[0],r)&&(i+=r+": "+arguments[0][r]+", ");i=i.slice(0,-2)}else i=arguments[l];n.push(i)}Pr(o+`
117
117
  Arguments: `+Array.prototype.slice.call(n).join("")+`
118
- `+new Error().stack),e=!1}return t.apply(this,arguments)},t)}var Er={};function Mr(o,t){st.deprecationHandler!=null&&st.deprecationHandler(o,t),Er[o]||(Pr(t),Er[o]=!0)}st.suppressDeprecationWarnings=!1,st.deprecationHandler=null;function _e(o){return typeof Function<"u"&&o instanceof Function||Object.prototype.toString.call(o)==="[object Function]"}function Bd(o){var t,e;for(e in o)Ht(o,e)&&(t=o[e],_e(t)?this[e]=t:this["_"+e]=t);this._config=o,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function _i(o,t){var e=Rn({},o),n;for(n in t)Ht(t,n)&&(Pn(o[n])&&Pn(t[n])?(e[n]={},Rn(e[n],o[n]),Rn(e[n],t[n])):t[n]!=null?e[n]=t[n]:delete e[n]);for(n in o)Ht(o,n)&&!Ht(t,n)&&Pn(o[n])&&(e[n]=Rn({},e[n]));return e}function Ai(o){o!=null&&this.set(o)}var ki;Object.keys?ki=Object.keys:ki=function(o){var t,e=[];for(t in o)Ht(o,t)&&e.push(t);return e};var Jd={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function $d(o,t,e){var n=this._calendar[o]||this._calendar.sameElse;return _e(n)?n.call(t,e):n}function Ae(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 Gi=/(\[[^\[]*\])|(\\)?([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,Wo=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,xi={},Qn={};function Tt(o,t,e,n){var i=n;typeof n=="string"&&(i=function(){return this[n]()}),o&&(Qn[o]=i),t&&(Qn[t[0]]=function(){return Ae(i.apply(this,arguments),t[1],t[2])}),e&&(Qn[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 jd(o){var t=o.match(Gi),e,n;for(e=0,n=t.length;e<n;e++)Qn[t[e]]?t[e]=Qn[t[e]]:t[e]=zd(t[e]);return function(i){var l="",r;for(r=0;r<n;r++)l+=_e(t[r])?t[r].call(i,o):t[r];return l}}function Yo(o,t){return o.isValid()?(t=Or(t,o.localeData()),xi[t]=xi[t]||jd(t),xi[t](o)):o.localeData().invalidDate()}function Or(o,t){var e=5;function n(i){return t.longDateFormat(i)||i}for(Wo.lastIndex=0;e>=0&&Wo.test(o);)o=o.replace(Wo,n),Wo.lastIndex=0,e-=1;return o}var qd={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 tu(o){var t=this._longDateFormat[o],e=this._longDateFormat[o.toUpperCase()];return t||!e?t:(this._longDateFormat[o]=e.match(Gi).map(function(n){return n==="MMMM"||n==="MM"||n==="DD"||n==="dddd"?n.slice(1):n}).join(""),this._longDateFormat[o])}var eu="Invalid date";function nu(){return this._invalidDate}var ou="%d",iu=/\d{1,2}/;function su(o){return this._ordinal.replace("%d",o)}var ru={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function lu(o,t,e,n){var i=this._relativeTime[e];return _e(i)?i(o,t,e,n):i.replace(/%d/i,o)}function au(o,t){var e=this._relativeTime[o>0?"future":"past"];return _e(e)?e(t):e.replace(/%s/i,t)}var Sr={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"?Sr[o]||Sr[o.toLowerCase()]:void 0}function Bi(o){var t={},e,n;for(n in o)Ht(o,n)&&(e=Oe(n),e&&(t[e]=o[n]));return t}var cu={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 du(o){var t=[],e;for(e in o)Ht(o,e)&&t.push({unit:e,priority:cu[e]});return t.sort(function(n,i){return n.priority-i.priority}),t}var Xr=/\d/,Ie=/\d\d/,Nr=/\d{3}/,Ji=/\d{4}/,Uo=/[+-]?\d{6}/,qt=/\d\d?/,Fr=/\d\d\d\d?/,yr=/\d\d\d\d\d\d?/,wo=/\d{1,3}/,$i=/\d{1,4}/,Zo=/[+-]?\d{1,6}/,Kn=/\d+/,vo=/[+-]?\d+/,uu=/Z|[+-]\d\d:?\d\d/gi,Qo=/Z|[+-]\d\d(?::?\d\d)?/gi,Ru=/[+-]?\d+(\.\d{1,3})?/,oo=/[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,Hn=/^[1-9]\d?/,zi=/^([1-9]\d|\d)/,Ko;Ko={};function ut(o,t,e){Ko[o]=_e(t)?t:function(n,i){return n&&e?e:t}}function hu(o,t){return Ht(Ko,o)?Ko[o](t._strict,t._locale):new RegExp(gu(o))}function gu(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 Wt(o){var t=+o,e=0;return t!==0&&isFinite(t)&&(e=Se(t)),e}var ji={};function xt(o,t){var e,n=t,i;for(typeof o=="string"&&(o=[o]),$e(t)&&(n=function(l,r){r[t]=Wt(l)}),i=o.length,e=0;e<i;e++)ji[o[e]]=n}function io(o,t){xt(o,function(e,n,i,l){i._w=i._w||{},t(e,i._w,i,l)})}function Tu(o,t,e){t!=null&&Ht(ji,o)&&ji[o](t,e._a,e,o)}function Ho(o){return o%4===0&&o%100!==0||o%400===0}var he=0,je=1,ke=2,ce=3,be=4,qe=5,En=6,fu=7,mu=8;Tt("Y",0,0,function(){var o=this.year();return o<=9999?Ae(o,4):"+"+o}),Tt(0,["YY",2],0,function(){return this.year()%100}),Tt(0,["YYYY",4],0,"year"),Tt(0,["YYYYY",5],0,"year"),Tt(0,["YYYYYY",6,!0],0,"year"),ut("Y",vo),ut("YY",qt,Ie),ut("YYYY",$i,Ji),ut("YYYYY",Zo,Uo),ut("YYYYYY",Zo,Uo),xt(["YYYYY","YYYYYY"],he),xt("YYYY",function(o,t){t[he]=o.length===2?st.parseTwoDigitYear(o):Wt(o)}),xt("YY",function(o,t){t[he]=st.parseTwoDigitYear(o)}),xt("Y",function(o,t){t[he]=parseInt(o,10)});function so(o){return Ho(o)?366:365}st.parseTwoDigitYear=function(o){return Wt(o)+(Wt(o)>68?1900:2e3)};var br=_n("FullYear",!0);function pu(){return Ho(this.year())}function _n(o,t){return function(e){return e!=null?(Dr(this,o,e),st.updateOffset(this,t),this):ro(this,o)}}function ro(o,t){if(!o.isValid())return NaN;var e=o._d,n=o._isUTC;switch(t){case"Milliseconds":return n?e.getUTCMilliseconds():e.getMilliseconds();case"Seconds":return n?e.getUTCSeconds():e.getSeconds();case"Minutes":return n?e.getUTCMinutes():e.getMinutes();case"Hours":return n?e.getUTCHours():e.getHours();case"Date":return n?e.getUTCDate():e.getDate();case"Day":return n?e.getUTCDay():e.getDay();case"Month":return n?e.getUTCMonth():e.getMonth();case"FullYear":return n?e.getUTCFullYear():e.getFullYear();default:return NaN}}function Dr(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&&!Ho(l)?28:a,i?n.setUTCFullYear(l,r,a):n.setFullYear(l,r,a)}}function Cu(o){return o=Oe(o),_e(this[o])?this[o]():this}function Iu(o,t){if(typeof o=="object"){o=Bi(o);var e=du(o),n,i=e.length;for(n=0;n<i;n++)this[e[n].unit](o[e[n].unit])}else if(o=Oe(o),_e(this[o]))return this[o](t);return this}function Lu(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 qi(o,t){if(isNaN(o)||isNaN(t))return NaN;var e=Lu(t,12);return o+=(t-e)/12,e===1?Ho(o)?29:28:31-e%7%2}Tt("M",["MM",2],"Mo",function(){return this.month()+1}),Tt("MMM",0,0,function(o){return this.localeData().monthsShort(this,o)}),Tt("MMMM",0,0,function(o){return this.localeData().months(this,o)}),ut("M",qt,Hn),ut("MM",qt,Ie),ut("MMM",function(o,t){return t.monthsShortRegex(o)}),ut("MMMM",function(o,t){return t.monthsRegex(o)}),xt(["M","MM"],function(o,t){t[je]=Wt(o)-1}),xt(["MMM","MMMM"],function(o,t,e,n){var i=e._locale.monthsParse(o,n,e._strict);i!=null?t[je]=i:Nt(e).invalidMonth=o});var Pu="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Vr="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Wr=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Eu=oo,Mu=oo;function Ou(o,t){return o?Fe(this._months)?this._months[o.month()]:this._months[(this._months.isFormat||Wr).test(t)?"format":"standalone"][o.month()]:Fe(this._months)?this._months:this._months.standalone}function Su(o,t){return o?Fe(this._monthsShort)?this._monthsShort[o.month()]:this._monthsShort[Wr.test(t)?"format":"standalone"][o.month()]:Fe(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Xu(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=He([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 Nu(o,t,e){var n,i,l;if(this._monthsParseExact)return Xu.call(this,o,t,e);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(i=He([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 Yr(o,t){if(!o.isValid())return o;if(typeof t=="string"){if(/^\d+$/.test(t))t=Wt(t);else if(t=o.localeData().monthsParse(t),!$e(t))return o}var e=t,n=o.date();return n=n<29?n:Math.min(n,qi(o.year(),e)),o._isUTC?o._d.setUTCMonth(e,n):o._d.setMonth(e,n),o}function Ur(o){return o!=null?(Yr(this,o),st.updateOffset(this,!0),this):ro(this,"Month")}function Fu(){return qi(this.year(),this.month())}function yu(o){return this._monthsParseExact?(Ht(this,"_monthsRegex")||wr.call(this),o?this._monthsShortStrictRegex:this._monthsShortRegex):(Ht(this,"_monthsShortRegex")||(this._monthsShortRegex=Eu),this._monthsShortStrictRegex&&o?this._monthsShortStrictRegex:this._monthsShortRegex)}function bu(o){return this._monthsParseExact?(Ht(this,"_monthsRegex")||wr.call(this),o?this._monthsStrictRegex:this._monthsRegex):(Ht(this,"_monthsRegex")||(this._monthsRegex=Mu),this._monthsStrictRegex&&o?this._monthsStrictRegex:this._monthsRegex)}function wr(){function o(c,d){return d.length-c.length}var t=[],e=[],n=[],i,l,r,a;for(i=0;i<12;i++)l=He([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 Du(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 lo(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 _o(o,t,e){var n=7+t-e,i=(7+lo(o,0,n).getUTCDay()-t)%7;return-i+n-1}function Zr(o,t,e,n,i){var l=(7+e-n)%7,r=_o(o,n,i),a=1+7*(t-1)+l+r,c,d;return a<=0?(c=o-1,d=so(c)+a):a>so(o)?(c=o+1,d=a-so(o)):(c=o,d=a),{year:c,dayOfYear:d}}function ao(o,t,e){var n=_o(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=_o(o,t,e),i=_o(o+1,t,e);return(so(o)-n+i)/7}Tt("w",["ww",2],"wo","week"),Tt("W",["WW",2],"Wo","isoWeek"),ut("w",qt,Hn),ut("ww",qt,Ie),ut("W",qt,Hn),ut("WW",qt,Ie),io(["w","ww","W","WW"],function(o,t,e,n){t[n.substr(0,1)]=Wt(o)});function Vu(o){return ao(o,this._week.dow,this._week.doy).week}var Wu={dow:0,doy:6};function Yu(){return this._week.dow}function Uu(){return this._week.doy}function wu(o){var t=this.localeData().week(this);return o==null?t:this.add((o-t)*7,"d")}function Zu(o){var t=ao(this,1,4).week;return o==null?t:this.add((o-t)*7,"d")}Tt("d",0,"do","day"),Tt("dd",0,0,function(o){return this.localeData().weekdaysMin(this,o)}),Tt("ddd",0,0,function(o){return this.localeData().weekdaysShort(this,o)}),Tt("dddd",0,0,function(o){return this.localeData().weekdays(this,o)}),Tt("e",0,0,"weekday"),Tt("E",0,0,"isoWeekday"),ut("d",qt),ut("e",qt),ut("E",qt),ut("dd",function(o,t){return t.weekdaysMinRegex(o)}),ut("ddd",function(o,t){return t.weekdaysShortRegex(o)}),ut("dddd",function(o,t){return t.weekdaysRegex(o)}),io(["dd","ddd","dddd"],function(o,t,e,n){var i=e._locale.weekdaysParse(o,n,e._strict);i!=null?t.d=i:Nt(e).invalidWeekday=o}),io(["d","e","E"],function(o,t,e,n){t[n]=Wt(o)});function vu(o,t){return typeof o!="string"?o:isNaN(o)?(o=t.weekdaysParse(o),typeof o=="number"?o:null):parseInt(o,10)}function Qu(o,t){return typeof o=="string"?t.weekdaysParse(o)%7||7:isNaN(o)?null:o}function ts(o,t){return o.slice(t,7).concat(o.slice(0,t))}var Ku="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),vr="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Hu="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),_u=oo,Au=oo,ku=oo;function Gu(o,t){var e=Fe(this._weekdays)?this._weekdays:this._weekdays[o&&o!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return o===!0?ts(e,this._week.dow):o?e[o.day()]:e}function xu(o){return o===!0?ts(this._weekdaysShort,this._week.dow):o?this._weekdaysShort[o.day()]:this._weekdaysShort}function Bu(o){return o===!0?ts(this._weekdaysMin,this._week.dow):o?this._weekdaysMin[o.day()]:this._weekdaysMin}function Ju(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=He([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 $u(o,t,e){var n,i,l;if(this._weekdaysParseExact)return Ju.call(this,o,t,e);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(i=He([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=ro(this,"Day");return o!=null?(o=vu(o,this.localeData()),this.add(o-t,"d")):t}function ju(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 qu(o){if(!this.isValid())return o!=null?this:NaN;if(o!=null){var t=Qu(o,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function tR(o){return this._weekdaysParseExact?(Ht(this,"_weekdaysRegex")||es.call(this),o?this._weekdaysStrictRegex:this._weekdaysRegex):(Ht(this,"_weekdaysRegex")||(this._weekdaysRegex=_u),this._weekdaysStrictRegex&&o?this._weekdaysStrictRegex:this._weekdaysRegex)}function eR(o){return this._weekdaysParseExact?(Ht(this,"_weekdaysRegex")||es.call(this),o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(Ht(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=Au),this._weekdaysShortStrictRegex&&o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function nR(o){return this._weekdaysParseExact?(Ht(this,"_weekdaysRegex")||es.call(this),o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(Ht(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=ku),this._weekdaysMinStrictRegex&&o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function es(){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=He([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 ns(){return this.hours()%12||12}function oR(){return this.hours()||24}Tt("H",["HH",2],0,"hour"),Tt("h",["hh",2],0,ns),Tt("k",["kk",2],0,oR),Tt("hmm",0,0,function(){return""+ns.apply(this)+Ae(this.minutes(),2)}),Tt("hmmss",0,0,function(){return""+ns.apply(this)+Ae(this.minutes(),2)+Ae(this.seconds(),2)}),Tt("Hmm",0,0,function(){return""+this.hours()+Ae(this.minutes(),2)}),Tt("Hmmss",0,0,function(){return""+this.hours()+Ae(this.minutes(),2)+Ae(this.seconds(),2)});function Qr(o,t){Tt(o,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}Qr("a",!0),Qr("A",!1);function Kr(o,t){return t._meridiemParse}ut("a",Kr),ut("A",Kr),ut("H",qt,zi),ut("h",qt,Hn),ut("k",qt,Hn),ut("HH",qt,Ie),ut("hh",qt,Ie),ut("kk",qt,Ie),ut("hmm",Fr),ut("hmmss",yr),ut("Hmm",Fr),ut("Hmmss",yr),xt(["H","HH"],ce),xt(["k","kk"],function(o,t,e){var n=Wt(o);t[ce]=n===24?0:n}),xt(["a","A"],function(o,t,e){e._isPm=e._locale.isPM(o),e._meridiem=o}),xt(["h","hh"],function(o,t,e){t[ce]=Wt(o),Nt(e).bigHour=!0}),xt("hmm",function(o,t,e){var n=o.length-2;t[ce]=Wt(o.substr(0,n)),t[be]=Wt(o.substr(n)),Nt(e).bigHour=!0}),xt("hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[ce]=Wt(o.substr(0,n)),t[be]=Wt(o.substr(n,2)),t[qe]=Wt(o.substr(i)),Nt(e).bigHour=!0}),xt("Hmm",function(o,t,e){var n=o.length-2;t[ce]=Wt(o.substr(0,n)),t[be]=Wt(o.substr(n))}),xt("Hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[ce]=Wt(o.substr(0,n)),t[be]=Wt(o.substr(n,2)),t[qe]=Wt(o.substr(i))});function iR(o){return(o+"").toLowerCase().charAt(0)==="p"}var sR=/[ap]\.?m?\.?/i,rR=_n("Hours",!0);function lR(o,t,e){return o>11?e?"pm":"PM":e?"am":"AM"}var Hr={calendar:Jd,longDateFormat:qd,invalidDate:eu,ordinal:ou,dayOfMonthOrdinalParse:iu,relativeTime:ru,months:Pu,monthsShort:Vr,week:Wu,weekdays:Ku,weekdaysMin:Hu,weekdaysShort:vr,meridiemParse:sR},ie={},co={},uo;function aR(o,t){var e,n=Math.min(o.length,t.length);for(e=0;e<n;e+=1)if(o[e]!==t[e])return e;return n}function _r(o){return o&&o.toLowerCase().replace("_","-")}function cR(o){for(var t=0,e,n,i,l;t<o.length;){for(l=_r(o[t]).split("-"),e=l.length,n=_r(o[t+1]),n=n?n.split("-"):null;e>0;){if(i=Ao(l.slice(0,e).join("-")),i)return i;if(n&&n.length>=e&&aR(l,n)>=e-1)break;e--}t++}return uo}function dR(o){return!!(o&&o.match("^[^/\\\\]*$"))}function Ao(o){var t=null,e;if(ie[o]===void 0&&typeof module<"u"&&module&&module.exports&&dR(o))try{t=uo._abbr,e=require,e("./locale/"+o),hn(t)}catch{ie[o]=null}return ie[o]}function hn(o,t){var e;return o&&(fe(t)?e=en(o):e=os(o,t),e?uo=e:typeof console<"u"&&console.warn&&console.warn("Locale "+o+" not found. Did you forget to load it?")),uo._abbr}function os(o,t){if(t!==null){var e,n=Hr;if(t.abbr=o,ie[o]!=null)Mr("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=ie[o]._config;else if(t.parentLocale!=null)if(ie[t.parentLocale]!=null)n=ie[t.parentLocale]._config;else if(e=Ao(t.parentLocale),e!=null)n=e._config;else return co[t.parentLocale]||(co[t.parentLocale]=[]),co[t.parentLocale].push({name:o,config:t}),null;return ie[o]=new Ai(_i(n,t)),co[o]&&co[o].forEach(function(i){os(i.name,i.config)}),hn(o),ie[o]}else return delete ie[o],null}function uR(o,t){if(t!=null){var e,n,i=Hr;ie[o]!=null&&ie[o].parentLocale!=null?ie[o].set(_i(ie[o]._config,t)):(n=Ao(o),n!=null&&(i=n._config),t=_i(i,t),n==null&&(t.abbr=o),e=new Ai(t),e.parentLocale=ie[o],ie[o]=e),hn(o)}else ie[o]!=null&&(ie[o].parentLocale!=null?(ie[o]=ie[o].parentLocale,o===hn()&&hn(o)):ie[o]!=null&&delete ie[o]);return ie[o]}function en(o){var t;if(o&&o._locale&&o._locale._abbr&&(o=o._locale._abbr),!o)return uo;if(!Fe(o)){if(t=Ao(o),t)return t;o=[o]}return cR(o)}function RR(){return ki(ie)}function is(o){var t,e=o._a;return e&&Nt(o).overflow===-2&&(t=e[je]<0||e[je]>11?je:e[ke]<1||e[ke]>qi(e[he],e[je])?ke:e[ce]<0||e[ce]>24||e[ce]===24&&(e[be]!==0||e[qe]!==0||e[En]!==0)?ce:e[be]<0||e[be]>59?be:e[qe]<0||e[qe]>59?qe:e[En]<0||e[En]>999?En:-1,Nt(o)._overflowDayOfYear&&(t<he||t>ke)&&(t=ke),Nt(o)._overflowWeeks&&t===-1&&(t=fu),Nt(o)._overflowWeekday&&t===-1&&(t=mu),Nt(o).overflow=t),o}var hR=/^\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)?)?$/,gR=/^\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)?)?$/,TR=/Z|[+-]\d\d(?::?\d\d)?/,ko=[["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]],ss=[["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/]],fR=/^\/?Date\((-?\d+)/i,mR=/^(?:(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}))$/,pR={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Ar(o){var t,e,n=o._i,i=hR.exec(n)||gR.exec(n),l,r,a,c,d=ko.length,u=ss.length;if(i){for(Nt(o).iso=!0,t=0,e=d;t<e;t++)if(ko[t][1].exec(i[1])){r=ko[t][0],l=ko[t][2]!==!1;break}if(r==null){o._isValid=!1;return}if(i[3]){for(t=0,e=u;t<e;t++)if(ss[t][1].exec(i[3])){a=(i[2]||" ")+ss[t][0];break}if(a==null){o._isValid=!1;return}}if(!l&&a!=null){o._isValid=!1;return}if(i[4])if(TR.exec(i[4]))c="Z";else{o._isValid=!1;return}o._f=r+(a||"")+(c||""),ls(o)}else o._isValid=!1}function CR(o,t,e,n,i,l){var r=[IR(o),Vr.indexOf(t),parseInt(e,10),parseInt(n,10),parseInt(i,10)];return l&&r.push(parseInt(l,10)),r}function IR(o){var t=parseInt(o,10);return t<=49?2e3+t:t<=999?1900+t:t}function LR(o){return o.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function PR(o,t,e){if(o){var n=vr.indexOf(o),i=new Date(t[0],t[1],t[2]).getDay();if(n!==i)return Nt(e).weekdayMismatch=!0,e._isValid=!1,!1}return!0}function ER(o,t,e){if(o)return pR[o];if(t)return 0;var n=parseInt(e,10),i=n%100,l=(n-i)/100;return l*60+i}function kr(o){var t=mR.exec(LR(o._i)),e;if(t){if(e=CR(t[4],t[3],t[2],t[5],t[6],t[7]),!PR(t[1],e,o))return;o._a=e,o._tzm=ER(t[8],t[9],t[10]),o._d=lo.apply(null,o._a),o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),Nt(o).rfc2822=!0}else o._isValid=!1}function MR(o){var t=fR.exec(o._i);if(t!==null){o._d=new Date(+t[1]);return}if(Ar(o),o._isValid===!1)delete o._isValid;else return;if(kr(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 An(o,t,e){return o??t??e}function OR(o){var t=new Date(st.now());return o._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function rs(o){var t,e,n=[],i,l,r;if(!o._d){for(i=OR(o),o._w&&o._a[ke]==null&&o._a[je]==null&&SR(o),o._dayOfYear!=null&&(r=An(o._a[he],i[he]),(o._dayOfYear>so(r)||o._dayOfYear===0)&&(Nt(o)._overflowDayOfYear=!0),e=lo(r,0,o._dayOfYear),o._a[je]=e.getUTCMonth(),o._a[ke]=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[ce]===24&&o._a[be]===0&&o._a[qe]===0&&o._a[En]===0&&(o._nextDay=!0,o._a[ce]=0),o._d=(o._useUTC?lo:Du).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[ce]=24),o._w&&typeof o._w.d<"u"&&o._w.d!==l&&(Nt(o).weekdayMismatch=!0)}}function SR(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=An(t.GG,o._a[he],ao(te(),1,4).year),n=An(t.W,1),i=An(t.E,1),(i<1||i>7)&&(c=!0)):(l=o._locale._week.dow,r=o._locale._week.doy,d=ao(te(),l,r),e=An(t.gg,o._a[he],d.year),n=An(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)?Nt(o)._overflowWeeks=!0:c!=null?Nt(o)._overflowWeekday=!0:(a=Zr(e,n,i,l,r),o._a[he]=a.year,o._dayOfYear=a.dayOfYear)}st.ISO_8601=function(){},st.RFC_2822=function(){};function ls(o){if(o._f===st.ISO_8601){Ar(o);return}if(o._f===st.RFC_2822){kr(o);return}o._a=[],Nt(o).empty=!0;var t=""+o._i,e,n,i,l,r,a=t.length,c=0,d,u;for(i=Or(o._f,o._locale).match(Gi)||[],u=i.length,e=0;e<u;e++)l=i[e],n=(t.match(hu(l,o))||[])[0],n&&(r=t.substr(0,t.indexOf(n)),r.length>0&&Nt(o).unusedInput.push(r),t=t.slice(t.indexOf(n)+n.length),c+=n.length),Qn[l]?(n?Nt(o).empty=!1:Nt(o).unusedTokens.push(l),Tu(l,n,o)):o._strict&&!n&&Nt(o).unusedTokens.push(l);Nt(o).charsLeftOver=a-c,t.length>0&&Nt(o).unusedInput.push(t),o._a[ce]<=12&&Nt(o).bigHour===!0&&o._a[ce]>0&&(Nt(o).bigHour=void 0),Nt(o).parsedDateParts=o._a.slice(0),Nt(o).meridiem=o._meridiem,o._a[ce]=XR(o._locale,o._a[ce],o._meridiem),d=Nt(o).era,d!==null&&(o._a[he]=o._locale.erasConvertYear(d,o._a[he])),rs(o),is(o)}function XR(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 NR(o){var t,e,n,i,l,r,a=!1,c=o._f.length;if(c===0){Nt(o).invalidFormat=!0,o._d=new Date(NaN);return}for(i=0;i<c;i++)l=0,r=!1,t=Hi({},o),o._useUTC!=null&&(t._useUTC=o._useUTC),t._f=o._f[i],ls(t),Qi(t)&&(r=!0),l+=Nt(t).charsLeftOver,l+=Nt(t).unusedTokens.length*10,Nt(t).score=l,a?l<n&&(n=l,e=t):(n==null||l<n||r)&&(n=l,e=t,r&&(a=!0));Rn(o,e||t)}function FR(o){if(!o._d){var t=Bi(o._i),e=t.day===void 0?t.date:t.day;o._a=Ir([t.year,t.month,e,t.hour,t.minute,t.second,t.millisecond],function(n){return n&&parseInt(n,10)}),rs(o)}}function yR(o){var t=new no(is(Gr(o)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function Gr(o){var t=o._i,e=o._f;return o._locale=o._locale||en(o._l),t===null||e===void 0&&t===""?Vo({nullInput:!0}):(typeof t=="string"&&(o._i=t=o._locale.preparse(t)),ye(t)?new no(is(t)):(eo(t)?o._d=t:Fe(e)?NR(o):e?ls(o):bR(o),Qi(o)||(o._d=null),o))}function bR(o){var t=o._i;fe(t)?o._d=new Date(st.now()):eo(t)?o._d=new Date(t.valueOf()):typeof t=="string"?MR(o):Fe(t)?(o._a=Ir(t.slice(0),function(e){return parseInt(e,10)}),rs(o)):Pn(t)?FR(o):$e(t)?o._d=new Date(t):st.createFromInputFallback(o)}function xr(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),(Pn(o)&&Zi(o)||Fe(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,yR(l)}function te(o,t,e,n){return xr(o,t,e,n,!1)}var DR=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:Vo()}),VR=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:Vo()});function Br(o,t){var e,n;if(t.length===1&&Fe(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 WR(){var o=[].slice.call(arguments,0);return Br("isBefore",o)}function YR(){var o=[].slice.call(arguments,0);return Br("isAfter",o)}var UR=function(){return Date.now?Date.now():+new Date},Ro=["year","quarter","month","week","day","hour","minute","second","millisecond"];function wR(o){var t,e=!1,n,i=Ro.length;for(t in o)if(Ht(o,t)&&!(le.call(Ro,t)!==-1&&(o[t]==null||!isNaN(o[t]))))return!1;for(n=0;n<i;++n)if(o[Ro[n]]){if(e)return!1;parseFloat(o[Ro[n]])!==Wt(o[Ro[n]])&&(e=!0)}return!0}function ZR(){return this._isValid}function vR(){return De(NaN)}function Go(o){var t=Bi(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=wR(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 xo(o){return o instanceof Go}function as(o){return o<0?Math.round(-1*o)*-1:Math.round(o)}function QR(o,t,e){var n=Math.min(o.length,t.length),i=Math.abs(o.length-t.length),l=0,r;for(r=0;r<n;r++)Wt(o[r])!==Wt(t[r])&&l++;return l+i}function Jr(o,t){Tt(o,0,0,function(){var e=this.utcOffset(),n="+";return e<0&&(e=-e,n="-"),n+Ae(~~(e/60),2)+t+Ae(~~e%60,2)})}Jr("Z",":"),Jr("ZZ",""),ut("Z",Qo),ut("ZZ",Qo),xt(["Z","ZZ"],function(o,t,e){e._useUTC=!0,e._tzm=cs(Qo,o)});var KR=/([\+\-]|\d\d)/gi;function cs(o,t){var e=(t||"").match(o),n,i,l;return e===null?null:(n=e[e.length-1]||[],i=(n+"").match(KR)||["-",0,0],l=+(i[1]*60)+Wt(i[2]),l===0?0:i[0]==="+"?l:-l)}function ds(o,t){var e,n;return t._isUTC?(e=t.clone(),n=(ye(o)||eo(o)?o.valueOf():te(o).valueOf())-e.valueOf(),e._d.setTime(e._d.valueOf()+n),st.updateOffset(e,!1),e):te(o).local()}function us(o){return-Math.round(o._d.getTimezoneOffset())}st.updateOffset=function(){};function HR(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=cs(Qo,o),o===null)return this}else Math.abs(o)<16&&!e&&(o=o*60);return!this._isUTC&&t&&(i=us(this)),this._offset=o,this._isUTC=!0,i!=null&&this.add(i,"m"),n!==o&&(!t||this._changeInProgress?qr(this,De(o-n,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,st.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?n:us(this)}function _R(o,t){return o!=null?(typeof o!="string"&&(o=-o),this.utcOffset(o,t),this):-this.utcOffset()}function AR(o){return this.utcOffset(0,o)}function kR(o){return this._isUTC&&(this.utcOffset(0,o),this._isUTC=!1,o&&this.subtract(us(this),"m")),this}function GR(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var o=cs(uu,this._i);o!=null?this.utcOffset(o):this.utcOffset(0,!0)}return this}function xR(o){return this.isValid()?(o=o?te(o).utcOffset():0,(this.utcOffset()-o)%60===0):!1}function BR(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function JR(){if(!fe(this._isDSTShifted))return this._isDSTShifted;var o={},t;return Hi(o,this),o=Gr(o),o._a?(t=o._isUTC?He(o._a):te(o._a),this._isDSTShifted=this.isValid()&&QR(o._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function $R(){return this.isValid()?!this._isUTC:!1}function zR(){return this.isValid()?this._isUTC:!1}function $r(){return this.isValid()?this._isUTC&&this._offset===0:!1}var jR=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,qR=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function De(o,t){var e=o,n=null,i,l,r;return xo(o)?e={ms:o._milliseconds,d:o._days,M:o._months}:$e(o)||!isNaN(+o)?(e={},t?e[t]=+o:e.milliseconds=+o):(n=jR.exec(o))?(i=n[1]==="-"?-1:1,e={y:0,d:Wt(n[ke])*i,h:Wt(n[ce])*i,m:Wt(n[be])*i,s:Wt(n[qe])*i,ms:Wt(as(n[En]*1e3))*i}):(n=qR.exec(o))?(i=n[1]==="-"?-1:1,e={y:Mn(n[2],i),M:Mn(n[3],i),w:Mn(n[4],i),d:Mn(n[5],i),h:Mn(n[6],i),m:Mn(n[7],i),s:Mn(n[8],i)}):e==null?e={}:typeof e=="object"&&("from"in e||"to"in e)&&(r=th(te(e.from),te(e.to)),e={},e.ms=r.milliseconds,e.M=r.months),l=new Go(e),xo(o)&&Ht(o,"_locale")&&(l._locale=o._locale),xo(o)&&Ht(o,"_isValid")&&(l._isValid=o._isValid),l}De.fn=Go.prototype,De.invalid=vR;function Mn(o,t){var e=o&&parseFloat(o.replace(",","."));return(isNaN(e)?0:e)*t}function zr(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 th(o,t){var e;return o.isValid()&&t.isValid()?(t=ds(t,o),o.isBefore(t)?e=zr(o,t):(e=zr(t,o),e.milliseconds=-e.milliseconds,e.months=-e.months),e):{milliseconds:0,months:0}}function jr(o,t){return function(e,n){var i,l;return n!==null&&!isNaN(+n)&&(Mr(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=De(e,n),qr(this,i,o),this}}function qr(o,t,e,n){var i=t._milliseconds,l=as(t._days),r=as(t._months);o.isValid()&&(n=n??!0,r&&Yr(o,ro(o,"Month")+r*e),l&&Dr(o,"Date",ro(o,"Date")+l*e),i&&o._d.setTime(o._d.valueOf()+i*e),n&&st.updateOffset(o,l||r))}var eh=jr(1,"add"),nh=jr(-1,"subtract");function tl(o){return typeof o=="string"||o instanceof String}function oh(o){return ye(o)||eo(o)||tl(o)||$e(o)||sh(o)||ih(o)||o===null||o===void 0}function ih(o){var t=Pn(o)&&!Zi(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||Ht(o,l);return t&&e}function sh(o){var t=Fe(o),e=!1;return t&&(e=o.filter(function(n){return!$e(n)&&tl(o)}).length===0),t&&e}function rh(o){var t=Pn(o)&&!Zi(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||Ht(o,l);return t&&e}function lh(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 ah(o,t){arguments.length===1&&(arguments[0]?oh(arguments[0])?(o=arguments[0],t=void 0):rh(arguments[0])&&(t=arguments[0],o=void 0):(o=void 0,t=void 0));var e=o||te(),n=ds(e,this).startOf("day"),i=st.calendarFormat(this,n)||"sameElse",l=t&&(_e(t[i])?t[i].call(this,e):t[i]);return this.format(l||this.localeData().calendar(i,this,te(e)))}function ch(){return new no(this)}function dh(o,t){var e=ye(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 uh(o,t){var e=ye(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 Rh(o,t,e,n){var i=ye(o)?o:te(o),l=ye(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 hh(o,t){var e=ye(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 gh(o,t){return this.isSame(o,t)||this.isAfter(o,t)}function Th(o,t){return this.isSame(o,t)||this.isBefore(o,t)}function fh(o,t,e){var n,i,l;if(!this.isValid())return NaN;if(n=ds(o,this),!n.isValid())return NaN;switch(i=(n.utcOffset()-this.utcOffset())*6e4,t=Oe(t),t){case"year":l=Bo(this,n)/12;break;case"month":l=Bo(this,n);break;case"quarter":l=Bo(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 Bo(o,t){if(o.date()<t.date())return-Bo(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 mh(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function ph(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"):_e(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 Ch(){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 Ih(o){o||(o=this.isUtc()?st.defaultFormatUtc:st.defaultFormat);var t=Yo(this,o);return this.localeData().postformat(t)}function Lh(o,t){return this.isValid()&&(ye(o)&&o.isValid()||te(o).isValid())?De({to:this,from:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Ph(o){return this.from(te(),o)}function Eh(o,t){return this.isValid()&&(ye(o)&&o.isValid()||te(o).isValid())?De({from:this,to:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Mh(o){return this.to(te(),o)}function el(o){var t;return o===void 0?this._locale._abbr:(t=en(o),t!=null&&(this._locale=t),this)}var nl=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 ol(){return this._locale}var Jo=1e3,kn=60*Jo,$o=60*kn,il=(365*400+97)*24*$o;function Gn(o,t){return(o%t+t)%t}function sl(o,t,e){return o<100&&o>=0?new Date(o+400,t,e)-il:new Date(o,t,e).valueOf()}function rl(o,t,e){return o<100&&o>=0?Date.UTC(o+400,t,e)-il:Date.UTC(o,t,e)}function Oh(o){var t,e;if(o=Oe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?rl:sl,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-=Gn(t+(this._isUTC?0:this.utcOffset()*kn),$o);break;case"minute":t=this._d.valueOf(),t-=Gn(t,kn);break;case"second":t=this._d.valueOf(),t-=Gn(t,Jo);break}return this._d.setTime(t),st.updateOffset(this,!0),this}function Sh(o){var t,e;if(o=Oe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?rl:sl,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+=$o-Gn(t+(this._isUTC?0:this.utcOffset()*kn),$o)-1;break;case"minute":t=this._d.valueOf(),t+=kn-Gn(t,kn)-1;break;case"second":t=this._d.valueOf(),t+=Jo-Gn(t,Jo)-1;break}return this._d.setTime(t),st.updateOffset(this,!0),this}function Xh(){return this._d.valueOf()-(this._offset||0)*6e4}function Nh(){return Math.floor(this.valueOf()/1e3)}function Fh(){return new Date(this.valueOf())}function yh(){var o=this;return[o.year(),o.month(),o.date(),o.hour(),o.minute(),o.second(),o.millisecond()]}function bh(){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 Dh(){return this.isValid()?this.toISOString():null}function Vh(){return Qi(this)}function Wh(){return Rn({},Nt(this))}function Yh(){return Nt(this).overflow}function Uh(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}Tt("N",0,0,"eraAbbr"),Tt("NN",0,0,"eraAbbr"),Tt("NNN",0,0,"eraAbbr"),Tt("NNNN",0,0,"eraName"),Tt("NNNNN",0,0,"eraNarrow"),Tt("y",["y",1],"yo","eraYear"),Tt("y",["yy",2],0,"eraYear"),Tt("y",["yyy",3],0,"eraYear"),Tt("y",["yyyy",4],0,"eraYear"),ut("N",Rs),ut("NN",Rs),ut("NNN",Rs),ut("NNNN",xh),ut("NNNNN",Bh),xt(["N","NN","NNN","NNNN","NNNNN"],function(o,t,e,n){var i=e._locale.erasParse(o,n,e._strict);i?Nt(e).era=i:Nt(e).invalidEra=o}),ut("y",Kn),ut("yy",Kn),ut("yyy",Kn),ut("yyyy",Kn),ut("yo",Jh),xt(["y","yy","yyy","yyyy"],he),xt(["yo"],function(o,t,e,n){var i;e._locale._eraYearOrdinalRegex&&(i=o.match(e._locale._eraYearOrdinalRegex)),e._locale.eraYearOrdinalParse?t[he]=e._locale.eraYearOrdinalParse(o,i):t[he]=parseInt(o,10)});function wh(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 Zh(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 vh(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 Qh(){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 Kh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].narrow;return""}function Hh(){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 _h(){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 Ah(o){return Ht(this,"_erasNameRegex")||hs.call(this),o?this._erasNameRegex:this._erasRegex}function kh(o){return Ht(this,"_erasAbbrRegex")||hs.call(this),o?this._erasAbbrRegex:this._erasRegex}function Gh(o){return Ht(this,"_erasNarrowRegex")||hs.call(this),o?this._erasNarrowRegex:this._erasRegex}function Rs(o,t){return t.erasAbbrRegex(o)}function xh(o,t){return t.erasNameRegex(o)}function Bh(o,t){return t.erasNarrowRegex(o)}function Jh(o,t){return t._eraYearOrdinalRegex||Kn}function hs(){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")}Tt(0,["gg",2],0,function(){return this.weekYear()%100}),Tt(0,["GG",2],0,function(){return this.isoWeekYear()%100});function zo(o,t){Tt(0,[o,o.length],0,t)}zo("gggg","weekYear"),zo("ggggg","weekYear"),zo("GGGG","isoWeekYear"),zo("GGGGG","isoWeekYear"),ut("G",vo),ut("g",vo),ut("GG",qt,Ie),ut("gg",qt,Ie),ut("GGGG",$i,Ji),ut("gggg",$i,Ji),ut("GGGGG",Zo,Uo),ut("ggggg",Zo,Uo),io(["gggg","ggggg","GGGG","GGGGG"],function(o,t,e,n){t[n.substr(0,2)]=Wt(o)}),io(["gg","GG"],function(o,t,e,n){t[n]=st.parseTwoDigitYear(o)});function $h(o){return ll.call(this,o,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function zh(o){return ll.call(this,o,this.isoWeek(),this.isoWeekday(),1,4)}function jh(){return tn(this.year(),1,4)}function qh(){return tn(this.isoWeekYear(),1,4)}function tg(){var o=this.localeData()._week;return tn(this.year(),o.dow,o.doy)}function eg(){var o=this.localeData()._week;return tn(this.weekYear(),o.dow,o.doy)}function ll(o,t,e,n,i){var l;return o==null?ao(this,n,i).year:(l=tn(o,n,i),t>l&&(t=l),ng.call(this,o,t,e,n,i))}function ng(o,t,e,n,i){var l=Zr(o,t,e,n,i),r=lo(l.year,0,l.dayOfYear);return this.year(r.getUTCFullYear()),this.month(r.getUTCMonth()),this.date(r.getUTCDate()),this}Tt("Q",0,"Qo","quarter"),ut("Q",Xr),xt("Q",function(o,t){t[je]=(Wt(o)-1)*3});function og(o){return o==null?Math.ceil((this.month()+1)/3):this.month((o-1)*3+this.month()%3)}Tt("D",["DD",2],"Do","date"),ut("D",qt,Hn),ut("DD",qt,Ie),ut("Do",function(o,t){return o?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),xt(["D","DD"],ke),xt("Do",function(o,t){t[ke]=Wt(o.match(qt)[0])});var al=_n("Date",!0);Tt("DDD",["DDDD",3],"DDDo","dayOfYear"),ut("DDD",wo),ut("DDDD",Nr),xt(["DDD","DDDD"],function(o,t,e){e._dayOfYear=Wt(o)});function ig(o){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return o==null?t:this.add(o-t,"d")}Tt("m",["mm",2],0,"minute"),ut("m",qt,zi),ut("mm",qt,Ie),xt(["m","mm"],be);var sg=_n("Minutes",!1);Tt("s",["ss",2],0,"second"),ut("s",qt,zi),ut("ss",qt,Ie),xt(["s","ss"],qe);var rg=_n("Seconds",!1);Tt("S",0,0,function(){return~~(this.millisecond()/100)}),Tt(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),Tt(0,["SSS",3],0,"millisecond"),Tt(0,["SSSS",4],0,function(){return this.millisecond()*10}),Tt(0,["SSSSS",5],0,function(){return this.millisecond()*100}),Tt(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),Tt(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),Tt(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),Tt(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),ut("S",wo,Xr),ut("SS",wo,Ie),ut("SSS",wo,Nr);var gn,cl;for(gn="SSSS";gn.length<=9;gn+="S")ut(gn,Kn);function lg(o,t){t[En]=Wt(("0."+o)*1e3)}for(gn="S";gn.length<=9;gn+="S")xt(gn,lg);cl=_n("Milliseconds",!1),Tt("z",0,0,"zoneAbbr"),Tt("zz",0,0,"zoneName");function ag(){return this._isUTC?"UTC":""}function cg(){return this._isUTC?"Coordinated Universal Time":""}var B=no.prototype;B.add=eh,B.calendar=ah,B.clone=ch,B.diff=fh,B.endOf=Sh,B.format=Ih,B.from=Lh,B.fromNow=Ph,B.to=Eh,B.toNow=Mh,B.get=Cu,B.invalidAt=Yh,B.isAfter=dh,B.isBefore=uh,B.isBetween=Rh,B.isSame=hh,B.isSameOrAfter=gh,B.isSameOrBefore=Th,B.isValid=Vh,B.lang=nl,B.locale=el,B.localeData=ol,B.max=VR,B.min=DR,B.parsingFlags=Wh,B.set=Iu,B.startOf=Oh,B.subtract=nh,B.toArray=yh,B.toObject=bh,B.toDate=Fh,B.toISOString=ph,B.inspect=Ch,typeof Symbol<"u"&&Symbol.for!=null&&(B[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),B.toJSON=Dh,B.toString=mh,B.unix=Nh,B.valueOf=Xh,B.creationData=Uh,B.eraName=Qh,B.eraNarrow=Kh,B.eraAbbr=Hh,B.eraYear=_h,B.year=br,B.isLeapYear=pu,B.weekYear=$h,B.isoWeekYear=zh,B.quarter=B.quarters=og,B.month=Ur,B.daysInMonth=Fu,B.week=B.weeks=wu,B.isoWeek=B.isoWeeks=Zu,B.weeksInYear=tg,B.weeksInWeekYear=eg,B.isoWeeksInYear=jh,B.isoWeeksInISOWeekYear=qh,B.date=al,B.day=B.days=zu,B.weekday=ju,B.isoWeekday=qu,B.dayOfYear=ig,B.hour=B.hours=rR,B.minute=B.minutes=sg,B.second=B.seconds=rg,B.millisecond=B.milliseconds=cl,B.utcOffset=HR,B.utc=AR,B.local=kR,B.parseZone=GR,B.hasAlignedHourOffset=xR,B.isDST=BR,B.isLocal=$R,B.isUtcOffset=zR,B.isUtc=$r,B.isUTC=$r,B.zoneAbbr=ag,B.zoneName=cg,B.dates=Me("dates accessor is deprecated. Use date instead.",al),B.months=Me("months accessor is deprecated. Use month instead",Ur),B.years=Me("years accessor is deprecated. Use year instead",br),B.zone=Me("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",_R),B.isDSTShifted=Me("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",JR);function dg(o){return te(o*1e3)}function ug(){return te.apply(null,arguments).parseZone()}function dl(o){return o}var _t=Ai.prototype;_t.calendar=$d,_t.longDateFormat=tu,_t.invalidDate=nu,_t.ordinal=su,_t.preparse=dl,_t.postformat=dl,_t.relativeTime=lu,_t.pastFuture=au,_t.set=Bd,_t.eras=wh,_t.erasParse=Zh,_t.erasConvertYear=vh,_t.erasAbbrRegex=kh,_t.erasNameRegex=Ah,_t.erasNarrowRegex=Gh,_t.months=Ou,_t.monthsShort=Su,_t.monthsParse=Nu,_t.monthsRegex=bu,_t.monthsShortRegex=yu,_t.week=Vu,_t.firstDayOfYear=Uu,_t.firstDayOfWeek=Yu,_t.weekdays=Gu,_t.weekdaysMin=Bu,_t.weekdaysShort=xu,_t.weekdaysParse=$u,_t.weekdaysRegex=tR,_t.weekdaysShortRegex=eR,_t.weekdaysMinRegex=nR,_t.isPM=iR,_t.meridiem=lR;function jo(o,t,e,n){var i=en(),l=He().set(n,t);return i[e](l,o)}function ul(o,t,e){if($e(o)&&(t=o,o=void 0),o=o||"",t!=null)return jo(o,t,e,"month");var n,i=[];for(n=0;n<12;n++)i[n]=jo(o,n,e,"month");return i}function gs(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 jo(t,(e+l)%7,n,"day");for(r=0;r<7;r++)a[r]=jo(t,(r+l)%7,n,"day");return a}function Rg(o,t){return ul(o,t,"months")}function hg(o,t){return ul(o,t,"monthsShort")}function gg(o,t,e){return gs(o,t,e,"weekdays")}function Tg(o,t,e){return gs(o,t,e,"weekdaysShort")}function fg(o,t,e){return gs(o,t,e,"weekdaysMin")}hn("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(o){var t=o%10,e=Wt(o%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return o+e}}),st.lang=Me("moment.lang is deprecated. Use moment.locale instead.",hn),st.langData=Me("moment.langData is deprecated. Use moment.localeData instead.",en);var nn=Math.abs;function mg(){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 Rl(o,t,e,n){var i=De(t,e);return o._milliseconds+=n*i._milliseconds,o._days+=n*i._days,o._months+=n*i._months,o._bubble()}function pg(o,t){return Rl(this,o,t,1)}function Cg(o,t){return Rl(this,o,t,-1)}function hl(o){return o<0?Math.floor(o):Math.ceil(o)}function Ig(){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+=hl(Ts(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(gl(t)),e+=c,t-=hl(Ts(c)),a=Se(e/12),e%=12,n.days=t,n.months=e,n.years=a,this}function gl(o){return o*4800/146097}function Ts(o){return o*146097/4800}function Lg(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+gl(t),o){case"month":return e;case"quarter":return e/3;case"year":return e/12}else switch(t=this._days+Math.round(Ts(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 Tl=on("ms"),Pg=on("s"),Eg=on("m"),Mg=on("h"),Og=on("d"),Sg=on("w"),Xg=on("M"),Ng=on("Q"),Fg=on("y"),yg=Tl;function bg(){return De(this)}function Dg(o){return o=Oe(o),this.isValid()?this[o+"s"]():NaN}function On(o){return function(){return this.isValid()?this._data[o]:NaN}}var Vg=On("milliseconds"),Wg=On("seconds"),Yg=On("minutes"),Ug=On("hours"),wg=On("days"),Zg=On("months"),vg=On("years");function Qg(){return Se(this.days()/7)}var sn=Math.round,xn={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Kg(o,t,e,n,i){return i.relativeTime(t||1,!!e,o,n)}function Hg(o,t,e,n){var i=De(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,Kg.apply(null,h)}function _g(o){return o===void 0?sn:typeof o=="function"?(sn=o,!0):!1}function Ag(o,t){return xn[o]===void 0?!1:t===void 0?xn[o]:(xn[o]=t,o==="s"&&(xn.ss=t-1),!0)}function kg(o,t){if(!this.isValid())return this.localeData().invalidDate();var e=!1,n=xn,i,l;return typeof o=="object"&&(t=o,o=!1),typeof o=="boolean"&&(e=o),typeof t=="object"&&(n=Object.assign({},xn,t),t.s!=null&&t.ss==null&&(n.ss=t.s-1)),i=this.localeData(),l=Hg(this,!e,n,i),e&&(l=i.pastFuture(+this,l)),i.postformat(l)}var fs=Math.abs;function Bn(o){return(o>0)-(o<0)||+o}function qo(){if(!this.isValid())return this.localeData().invalidDate();var o=fs(this._milliseconds)/1e3,t=fs(this._days),e=fs(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=Bn(this._months)!==Bn(a)?"-":"",u=Bn(this._days)!==Bn(a)?"-":"",R=Bn(this._milliseconds)!==Bn(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 Zt=Go.prototype;Zt.isValid=ZR,Zt.abs=mg,Zt.add=pg,Zt.subtract=Cg,Zt.as=Lg,Zt.asMilliseconds=Tl,Zt.asSeconds=Pg,Zt.asMinutes=Eg,Zt.asHours=Mg,Zt.asDays=Og,Zt.asWeeks=Sg,Zt.asMonths=Xg,Zt.asQuarters=Ng,Zt.asYears=Fg,Zt.valueOf=yg,Zt._bubble=Ig,Zt.clone=bg,Zt.get=Dg,Zt.milliseconds=Vg,Zt.seconds=Wg,Zt.minutes=Yg,Zt.hours=Ug,Zt.days=wg,Zt.weeks=Qg,Zt.months=Zg,Zt.years=vg,Zt.humanize=kg,Zt.toISOString=qo,Zt.toString=qo,Zt.toJSON=qo,Zt.locale=el,Zt.localeData=ol,Zt.toIsoString=Me("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",qo),Zt.lang=nl,Tt("X",0,0,"unix"),Tt("x",0,0,"valueOf"),ut("x",vo),ut("X",Ru),xt("X",function(o,t,e){e._d=new Date(parseFloat(o)*1e3)}),xt("x",function(o,t,e){e._d=new Date(Wt(o))});st.version="2.30.1",Gd(te),st.fn=B,st.min=WR,st.max=YR,st.now=UR,st.utc=He,st.unix=dg,st.months=Rg,st.isDate=eo,st.locale=hn,st.invalid=Vo,st.duration=De,st.isMoment=ye,st.weekdays=gg,st.parseZone=ug,st.localeData=en,st.isDuration=xo,st.monthsShort=hg,st.weekdaysMin=fg,st.defineLocale=os,st.updateLocale=uR,st.locales=RR,st.weekdaysShort=Tg,st.normalizeUnits=Oe,st.relativeTimeRounding=_g,st.relativeTimeThreshold=Ag,st.calendarFormat=lh,st.prototype=B,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 ms{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),l=t?null:i.getTd();n>=e.length&&(n=e.length-1);const r=e[n],a=[];let c=l,d=e,u=n;for(;;){if(u<0&&c?.linkTdPrevId){const 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=D=>!!(D&&(D.controlComponent===s.ControlComponent.POSTFIX||D.controlComponent===s.ControlComponent.POST_TEXT||D.controlComponent===s.ControlComponent.POSTTEXTFIX||D.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,C=this.control.getDraw();f!==p?C.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 I=l[f];T||d||g?this._removePlaceholdersByControl(l,u,R||null):this._removeControlPlaceholders(l,f);const m=I.type&&!Ce.includes(I.type)||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRE_TEXT?$t(I,["control","controlId","originControlId",...Re]):pe(I,["type"]),P=T||d||g,E=D=>{Re.forEach(O=>{delete D[O];const b=h?.[O];b!==void 0&&(D[O]=b)}),delete D.underline,delete D.textDecoration,h?.type===s.ControlType.TEXT&&D.color?.toLowerCase()==="#87d068"?D.color=this.options.defaultColor:D.color||(D.color=this.options.defaultColor)};P&&E(m),m.controlId=u,h&&(m.control=h),R?m.originControlId=R:delete m.originControlId;const M=this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.inputTraceEnabled,F=i.startIndex+1,y=[],Y=D=>{const O=y.length?y:l,b=y.length?y.length-1:d?i.startIndex+1:i.startIndex;oe(O,[D],b,{editorOptions:this.options}),y.push(D)};for(let D=0;D<t.length;D++){const O=t[D];if(O.type===s.ElementType.CONTROL&&O.control){const b=O,V=b.controlId||ft(),X=b.control?.value||[],N=b.control?.type===s.ControlType.TEXTFIELD,W={...pe(m,["underline","textDecoration"]),controlId:V,type:s.ElementType.CONTROL,control:b.control,originControlId:u},S=N?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,U=N?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,v=N?b.control?.preTextFix||this.options.control.preTextFix:b.control?.prefix||this.options.control.prefix;for(let w=0;w<v.length;w++){const q={...W,value:v[w],controlComponent:S};Y(q)}for(let w=0;w<X.length;w++){const q=X[w],G={...W,...q,controlComponent:s.ControlComponent.VALUE};(G.color===this.options.control.bracketColor||G.color===this.options.control.placeholderColor)&&(G.color=this.options.defaultColor),Y(G)}if(X.length===0){const w=b.control?.placeholder||"";for(let q=0;q<w.length;q++){const G={...W,value:w[q],controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};Y(G)}}const Q=N?b.control?.postTextFix||this.options.control.postTextFix:b.control?.postfix||this.options.control.postfix;for(let w=0;w<Q.length;w++){const q={...W,value:Q[w],controlComponent:U};Y(q)}}else if(O.type||O.value){(I.controlComponent===s.ControlComponent.PRE_TEXT||I.controlComponent===s.ControlComponent.POST_TEXT||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.POSTFIX)&&(m.color=this.options.defaultColor);const V=pe(O,["control","controlId","controlComponent","originControlId"]),X={...m,...V,controlComponent:s.ControlComponent.VALUE};P&&E(X),(X.color===this.options.control.bracketColor||X.color===this.options.control.placeholderColor||X.color===this.options.control.textFixColor)&&(X.color=this.options.defaultColor),X.strikeout&&delete X.strikeout,M&&(X.textDecoration={style:s.TextDecorationStyle.DOUBLE},X.underline=!0),Y(X)}}return y.length&&C.spliceElementList(l,F,0,y),i.startIndex+y.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=L=>{if(!L)return null;const W=new Set;let S=L,U=null;for(;S&&!W.has(S);){W.add(S);let v;for(let Q=0;Q<e.length;Q++){const w=e[Q];if(w.controlId===S&&w.control?.type&&(v=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(!v)break;(v.control?.type===s.ControlType.TEXT||this.options.mode===s.EditorMode.EDIT&&v.control?.type===s.ControlType.TEXTFIELD)&&(U=S),S=v.originControlId||null}return U},g=h(R),T=!!g,f=r.controlId===u&&(r.originControlId||null)===R,p=r.controlComponent===s.ControlComponent.VALUE,C=L=>{for(let W=i-1;W>=0;W--){const S=e[W];if(S.controlId===L&&!S.originControlId){if(S.controlComponent===s.ControlComponent.VALUE||S.controlComponent===s.ControlComponent.PLACEHOLDER)return W;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!==L&&S.originControlId!==L)break}return-1},I=(L,W)=>{for(let S=L;S>=0;S--){const U=e[S];if(U.controlId===W&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.PREFIX||U.controlComponent===s.ControlComponent.PRE_TEXT||U.controlComponent===s.ControlComponent.PRETEXTFIX||U.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))return S;if(U.controlId&&U.controlId!==W&&U.originControlId!==W)break}for(let S=L+1;S<e.length;S++){const U=e[S];if(U.controlId===W&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.POSTFIX||U.controlComponent===s.ControlComponent.POST_TEXT||U.controlComponent===s.ControlComponent.POSTTEXTFIX||U.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return S;if(U.controlId&&U.controlId!==W&&U.originControlId!==W)break}return L},P=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],M=!!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),y=L=>this.options.mode===s.EditorMode.FORM?i:this.control.removeControl(L),Y=r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId&&!!E?.originControlId&&!!u&&h(E.originControlId)===u,D=L=>!!L&&L.controlId===r.controlId&&(L.originControlId||null)===(r.originControlId||null),O=L=>L?.controlComponent===s.ControlComponent.POSTFIX||L?.controlComponent===s.ControlComponent.POST_TEXT||L?.controlComponent===s.ControlComponent.POSTTEXTFIX||L?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT,b=()=>{const L=r.controlId,W=r.originControlId||null;return c.spliceElementList(e,i,1),e.some(U=>U.controlId===L&&(U.originControlId||null)===W&&U.controlComponent===s.ControlComponent.VALUE)||this.control.addPlaceholder(i-1),Math.max(i-1,0)},V=r.controlComponent===s.ControlComponent.VALUE&&!!r.originControlId&&D(E)&&O(E),X=!!u&&!this.control.getIsExistValueByElementListIndex(e,i),N=()=>{if(r.controlComponent!==s.ControlComponent.VALUE)return null;let L=i;for(let U=i;U>=0;U--){const v=e[U];if(!(v.controlId===r.controlId&&(v.originControlId||null)===(r.originControlId||null))||v.controlComponent!==s.ControlComponent.VALUE)break;if(!v.strikeout){L=U;break}}const W=e[L];if(!W||W.strikeout)return null;W.strikeout=!0,W.deletePerson="SWJ",W.deleteTime=st(new Date).format("YYYY-MM-DD HH:mm:ss");let S=Math.max(L-1,0);for(let U=L-1;U>=0;U--){const v=e[U];if(!(v.controlId===W.controlId&&(v.originControlId||null)===(W.originControlId||null))){S=U;break}if(v.controlComponent!==s.ControlComponent.VALUE){S=U;break}if(!v.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&&X&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return i;if(d&&i===l&&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 W=C(g);return W>=0?W:i}if(i===l&&P&&!(d&&r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId))return y(i);if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!T||p)){if(i===l&&r.controlComponent===s.ControlComponent.VALUE){const W=N();if(W!==null)return W}return r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?i:this.strikeout()}else{if(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER)return i;if(i!==l){c.spliceElementList(e,i+1,l-i);const W=e[i+1];return(W?.controlComponent===s.ControlComponent.POSTFIX||W?.controlComponent===s.ControlComponent.POST_TEXT||W?.controlComponent===s.ControlComponent.POSTTEXTFIX||W?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(i),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i}else{const W=e[i-1],S=e[i+1];return!r.originControlId&&W?.controlId===r.controlId&&W?.originControlId===r.originControlId&&W?.controlComponent===s.ControlComponent.VALUE&&(r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.options.mode!==s.EditorMode.FORM?(c.spliceElementList(e,i-1,1),this.getValue().length||this.control.addPlaceholder(i-2),i-2):O(S)?S.originControlId?V?b():Y?(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):y(i):(c.spliceElementList(e,i,1),this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):(c.spliceElementList(e,i,1),i===1&&e[0].type===s.ElementType.SPLIT_TAG||i===0?c.fixPosition(!0)??i-1:I(Math.max(i-1,0),r.controlId))}}}else if(t.key===s.KeyMap.Delete){if(i===l&&X&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return l;if(i===l&&(M||F)){if(Y){const U=e[l+1];if(U?.controlComponent===s.ControlComponent.VALUE&&U.controlId===r.controlId&&!U.originControlId)return c.spliceElementList(e,l+1,1),this.getValue().length||this.control.addPlaceholder(i),i}return y(l+1)}const L=e[l+1],W=!!r.originControlId;if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!W||r.controlComponent===s.ControlComponent.VALUE))return a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||a.controlComponent===s.ControlComponent.POSTTEXTFIX||a.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?l:L?.controlComponent===s.ControlComponent.POSTFIX||L?.controlComponent===s.ControlComponent.POST_TEXT||L?.controlComponent===s.ControlComponent.POSTTEXTFIX||L?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?L.originControlId?Y?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):y(i+1):(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):this.strikeout();{const U=e[l+1];return r.controlComponent===s.ControlComponent.PLACEHOLDER?l:U?.controlComponent===s.ControlComponent.POSTFIX||U?.controlComponent===s.ControlComponent.POST_TEXT||U?.controlComponent===s.ControlComponent.POSTTEXTFIX||U?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?U.originControlId?Y?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):y(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 C=-1;for(let I=h-1;I>=0;I--){const m=g[I];if(m.controlId===f&&(m.originControlId||null)===p&&m.controlComponent===s.ControlComponent.VALUE)return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:I,reason:"prev-value"}),I;if(p){if(m.controlId&&m.controlId!==f&&m.originControlId!==p)break}else{if(m.controlId===f&&(m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRE_TEXT||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){C=I;break}if(m.controlId&&m.controlId!==f&&!m.originControlId)break;if(m.originControlId===f&&(m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POST_TEXT||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:I,reason:"nested-postfix"}),I}}if(C>=0){const I=C+1,m=g[I];return m?.controlId===f&&(m.controlComponent===s.ControlComponent.PLACEHOLDER||m.controlComponent===s.ControlComponent.VALUE)?(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:I,reason:"prefix-next-editable"}),I):(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:C,reason:"prefix"}),C)}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 fl{draw;options;now;dom;renderOptions;isDatePicker;pickDate;lang;constructor(t,e={}){this.draw=t,this.options=e,this.lang=this._getLang(),this.now=new Date,this.dom=this._createDom(),this.renderOptions=null,this.isDatePicker=!0,this.pickDate=null,this._bindEvent()}_createDom(){const t=document.createElement("div");t.classList.add(`${rt}-date-container`),t.setAttribute(Be,s.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${rt}-date-wrap`);const n=document.createElement("div");n.classList.add(`${rt}-date-title`);const i=document.createElement("span");i.classList.add(`${rt}-date-title__pre-year`),i.innerText="<<";const l=document.createElement("span");l.classList.add(`${rt}-date-title__pre-month`),l.innerText="<";const r=document.createElement("span");r.classList.add(`${rt}-date-title__now`);const a=document.createElement("span");a.classList.add(`${rt}-date-title__next-month`),a.innerText=">";const c=document.createElement("span");c.classList.add(`${rt}-date-title__next-year`),c.innerText=">>",n.append(i),n.append(l),n.append(r),n.append(a),n.append(c);const d=document.createElement("div");d.classList.add(`${rt}-date-week`);const{weeks:{sun:u,mon:R,tue:h,wed:g,thu:T,fri:f,sat:p}}=this.lang;[u,R,h,g,T,f,p].forEach(b=>{const V=document.createElement("span");V.innerText=`${b}`,d.append(V)});const I=document.createElement("div");I.classList.add(`${rt}-date-day`),e.append(n),e.append(d),e.append(I);const m=document.createElement("ul");m.classList.add(`${rt}-time-wrap`);let P,E,M;[this.lang.hour,this.lang.minute,this.lang.second].forEach((b,V)=>{const X=document.createElement("li"),N=document.createElement("span");N.innerText=b,X.append(N);const L=document.createElement("ol"),W=V===0,S=V===1,U=W?24:60;for(let v=0;v<U;v++){const Q=document.createElement("li");Q.innerText=`${String(v).padStart(2,"0")}`,Q.setAttribute("data-id",`${v}`),L.append(Q)}W?P=L:S?E=L:M=L,X.append(L),m.append(X)});const y=document.createElement("div");y.classList.add(`${rt}-date-menu`);const Y=document.createElement("button");Y.classList.add(`${rt}-date-menu__time`),Y.innerText=this.lang.timeSelect;const D=document.createElement("button");D.classList.add(`${rt}-date-menu__now`),D.innerText=this.lang.now;const O=document.createElement("button");return O.classList.add(`${rt}-date-menu__submit`),O.innerText=this.lang.confirm,y.append(Y),y.append(D),y.append(O),t.append(e),t.append(m),t.append(y),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:d,timeWrap:m,title:{preYear:i,preMonth:l,now:r,nextMonth:a,nextYear:c},day:I,time:{hour:P,minute:E,second:M},menu:{time:Y,now:D,submit:O}}}_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 C=document.createElement("div");C.classList.add("disable"),C.innerText=`${p}`,C.onclick=()=>{const I=d-2;this.now=new Date(c,I,p),this._setDatePick(c,I,p)},this.dom.day.append(C)}for(let p=1;p<=R;p++){const C=document.createElement("div");e===c&&n===d&&i===p&&C.classList.add("active"),this.pickDate&&l===c&&r===d&&a===p&&C.classList.add("select"),C.innerText=`${p}`,C.onclick=I=>{const m=d-1;this.now=new Date(c,m,p),this._setDatePick(c,m,p),I.stopPropagation()},this.dom.day.append(C)}const f=42-h-R;for(let p=1;p<=f;p++){const C=document.createElement("div");C.classList.add("disable"),C.innerText=`${p}`,C.onclick=()=>{this.now=new Date(c,d,p),this._setDatePick(c,d,p)},this.dom.day.append(C)}}_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&&Ds(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 ho{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?$t(d,["control","controlId",...Re]):pe(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};oe(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?$t(r,Xe):$t(i[l.startIndex],Re),c=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~c)return;const d=pe(i[c],Xe),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),oe(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 fl(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 go extends ms{isPopup;inputPopup;constructor(t,e){super(t,e),this.isPopup=!1,this.inputPopup=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(P=>!pc(P)||oa.test(P.value)))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange();this.control.shrinkBoundary(e);const r=ct(t),{startIndex:a,endIndex:c}=l,d=i[a];let u=null;for(let P=a;P>=0;P--)if(i[P].controlComponent===s.ControlComponent.PREFIX){u=i[P];break}const R=u?.control||this.element.control;if(this.control.getIsExistValueByElementListIndex(i,a)){let P=a;for(;P>0;){const M=i[P];if(M.controlId!==d.controlId||M.controlComponent===s.ControlComponent.PREFIX||M.controlComponent===s.ControlComponent.PRE_TEXT)break;r.unshift(M),P--}let E=c+1;for(;E<i.length;){const M=i[E];if(M.controlId!==d.controlId||M.controlComponent===s.ControlComponent.POSTFIX||M.controlComponent===s.ControlComponent.POST_TEXT)break;r.push(M),E++}}const h=$s(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 C=Number(h),I=g?.minValue,m=g?.maxValue;return I!=null&&C<I||m!=null&&C>m?-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 C=this.options.mode===s.EditorMode.FORM,I=C&&this.options.modeRule.form.inputTraceEnabled,m=C&&this.options.modeRule.form.deleteTraceEnabled,P=st(new Date).format("YYYY-MM-DD HH:mm:ss");if(m)for(let F=f+1;F<p;F++){const y=e[F];y.controlComponent===s.ControlComponent.VALUE&&!y.strikeout&&y.value&&(y.strikeout=!0,y.deletePerson="SYSTEM",y.deleteTime=P),y.controlComponent===s.ControlComponent.PLACEHOLDER&&(this.control.getDraw().spliceElementList(e,F,1),p--,F--)}else{const F=f+1,y=p-F;y>0&&this.control.getDraw().spliceElementList(e,F,y),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 y={type:s.ElementType.TEXT,value:h[F],controlComponent:s.ControlComponent.VALUE,controlId:e[f].controlId,originControlId:e[f].originControlId,control:e[f].control};I&&(y.textDecoration={style:s.TextDecorationStyle.DOUBLE},y.underline=!0),E.push(y)}for(let F=0;F<E.length;F++)this.control.getDraw().spliceElementList(e,p+F,0,[E[F]]);const M=p+E.length-1;return this.control.getDraw().getRange().setRange(M,M),this.control.emitControlContentChange(),this.control.repaintControl({curIndex:M}),!0}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e,i=t[n];if(!i||i.controlId!==this.element.controlId)return;let l=null;for(let 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?$s(c):"",u=r?.numberExclusiveOptions,R=u?.minValue,h=u?.maxValue,g=u?.decimalPlaces;this.inputPopup=new Gg({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 Gg{options;popupDom;constructor(t){this.options=t,this.popupDom=null}create(){const{currentValue:t,minValue:e,maxValue:n,decimalPlaces:i,onConfirm:l,onTab:r,onClose:a}=this.options,c=document.createElement("div");c.classList.add(`${rt}-number-input-modal`),c.setAttribute(Be,s.EditorComponent.POPUP);const d=m=>{if(m.type==="mouseup"){const P=this.options.control.getDraw().getCanvasEvent();P.setIsAllowDrag(!1),P.setIsAllowSelection(!1)}m.stopPropagation()};c.addEventListener("mousedown",d),c.addEventListener("mouseup",d),c.addEventListener("click",d),c.addEventListener("keydown",d),c.addEventListener("input",d);const u=document.createElement("div");u.classList.add(`${rt}-number-input-modal__content`);const R=document.createElement("div");if(R.classList.add(`${rt}-number-input-modal__title`),R.textContent="请输入数值",u.appendChild(R),e!==void 0||n!==void 0){const m=document.createElement("div");m.classList.add(`${rt}-number-input-modal__hint`);let P="有效范围:";e!==void 0&&n!==void 0?P+=`${e} ~ ${n}`:e!==void 0?P+=`≥ ${e}`:P+=`≤ ${n}`,i!=null&&(P+=`,保留${i}位小数`),m.textContent=P,u.appendChild(m)}const h=document.createElement("input");h.classList.add(`${rt}-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(`${rt}-number-input-modal__error`),g.style.display="none",u.appendChild(g);const T=document.createElement("div");T.classList.add(`${rt}-number-input-modal__buttons`);const f=document.createElement("button");f.classList.add(`${rt}-number-input-modal__cancel`),f.textContent="取消",f.onclick=()=>{a()},T.appendChild(f);const p=document.createElement("button");p.classList.add(`${rt}-number-input-modal__confirm`),p.textContent="确定";const C=()=>{const m=h.value.trim();if(!m)return l("");const P=parseFloat(m);return Number.isNaN(P)||!Number.isFinite(P)?(g.textContent="请输入有效的数值",g.style.display="block",!1):i!=null&&(m.split(".")[1]||"").length>i?(g.textContent=`小数位数不能超过${i}位`,g.style.display="block",!1):e!==void 0&&P<e?(g.textContent=`数值不能小于 ${e}`,g.style.display="block",!1):n!==void 0&&P>n?(g.textContent=`数值不能大于 ${n}`,g.style.display="block",!1):(g.style.display="none",l(m))};p.onclick=()=>{C()&&a()},T.appendChild(p),u.appendChild(T),c.appendChild(u),h.onkeydown=m=>{m.key==="Enter"?p.click():m.key==="Tab"?(m.preventDefault(),C()&&(a(),r(m.shiftKey?Jt.UP:Jt.DOWN))):m.key==="Escape"&&a()},this.options.control.getContainer().appendChild(c),this.popupDom=c}destroy(){this.popupDom&&(this.popupDom.remove(),this.popupDom=null)}}class xg{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(Be,s.EditorComponent.COMPONENT),document.body.append(l);const r=document.createElement("div");r.classList.add("dialog-container"),r.setAttribute(Be,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],C=document.createElement("div");if(C.classList.add("dialog-option__item"),p.visible===!1&&(C.style.display="none"),p.label){const I=document.createElement("span");I.append(document.createTextNode(p.label)),C.append(I),p.required&&I.classList.add("dialog-option__item--require")}if(p.type==="radio"){const I=document.createElement("div");I.classList.add("dialog-radio-group"),p.horizontal&&I.classList.add("dialog-radio-group--horizontal"),p.options?.forEach(m=>{const P=document.createElement("label");P.classList.add("dialog-radio-item");const E=document.createElement("input");E.type="radio",E.name=p.name,E.value=m.value,m.value===(p.value||"")&&(E.checked=!0);const M=document.createElement("span");M.textContent=m.label,P.append(E),P.append(M),I.append(P),E.addEventListener("change",()=>{this._updateFieldVisibility()}),this.inputList.push(E)}),C.append(I)}else if(p.type==="select"){const I=document.createElement("select"),m=p.value||"";p.options?.forEach(P=>{const E=document.createElement("option");E.value=P.value,E.label=P.label,P.value===m&&(E.selected=!0),I.append(E)}),I.name=p.name,I.value=m,I.addEventListener("change",()=>{this._updateFieldVisibility()}),p.width&&(I.style.width=`${p.width}px`),C.append(I),this.inputList.push(I)}else if(p.type==="textarea"){const I=document.createElement("textarea");I.name=p.name,I.value=p.value||"",I.placeholder=p.placeholder||"",p.width&&(I.style.width=`${p.width}px`),p.height&&(I.style.height=`${p.height}px`),C.append(I),this.inputList.push(I)}else{const I=document.createElement("input");I.type=p.type,I.name=p.name,I.value=p.value||"",I.placeholder=p.placeholder||"",p.width&&(I.style.width=`${p.width}px`),p.height&&(I.style.height=`${p.height}px`),C.append(I),this.inputList.push(I)}R.append(C),this.optionItemContainers.push(C)}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 C of this.inputList)if(!f.has(C.name))if(C instanceof HTMLInputElement&&C.type==="radio"){const I=this.inputList.find(m=>m.name===C.name&&m instanceof HTMLInputElement&&m.checked);I&&(p.push({name:C.name,value:I.value}),f.add(C.name))}else p.push({name:C.name,value:C.value}),f.add(C.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()}}const Bg=[{label:"无",value:""},{label:"诊断信息",value:"outpatient.diagnosis"}];function Jg(o){if(o==="outpatient.diagnosis")return{key:o,label:"诊断信息",writeTarget:"self",writeMode:"replaceOnConfirm"}}class Sn{draw;element;control;isPopup;datePicker;options;range;static isDeleting=!1;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.range=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:l,endIndex:r}=n;for(let a=l;a<=r;a++){const c=e[a];c.controlComponent===s.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&(this.control.getIsDisabledControl(e)||this.element.control?.editable===!1))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),r=this.control.getDraw(),{startIndex:a,endIndex:c}=l,d=i[a],u=this.element.controlId||d.controlId,R=this.element.originControlId||d.originControlId||null;if(!u)return-1;const h=E=>!!E&&E.controlId===u&&(E.originControlId||null)===R;let g=a;for(;g>0&&h(i[g])&&i[g].controlComponent!==s.ControlComponent.PREFIX;)g--;let T=a;for(;T<i.length&&h(i[T])&&i[T].controlComponent!==s.ControlComponent.POSTFIX;)T++;T>=i.length&&(T=a);let f=a+1,p=c-a,C=d.controlComponent===s.ControlComponent.POSTFIX?a:a+1;a===c&&(p=0,d.controlComponent===s.ControlComponent.PREFIX?C=g+1:d.controlComponent===s.ControlComponent.POSTFIX&&(C=T),f=C),p>0&&(r.spliceElementList(i,f,p),C=f);const I=i[Math.max(C-1,g)]||i[g]||d,m=$t(I,["control","controlId","originControlId",...Re]);m.control=this.element.control||d.control,m.controlId=u,R?m.originControlId=R:delete m.originControlId;const P=[];for(let E=0;E<t.length;E++){const M={...m,...t[E],type:s.ElementType.CONTROL,controlComponent:s.ControlComponent.VALUE};M.color=this.options.defaultColor,M.highlight=void 0,oe(i,[M],C+E-1,{editorOptions:this.options}),P.push(M)}return P.length?r.spliceElementList(i,C,0,P):this.control.addPlaceholder(Math.max(C-1,0),e),this.syncControlValue(i,u,R),C+t.length-1}syncControlValue(t,e,n){const i=t.filter(r=>r.controlId===e&&(r.originControlId||null)===n&&r.controlComponent===s.ControlComponent.VALUE).map(r=>{const a={value:r.value||""};return["color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"].forEach(d=>{const u=r[d];u!==void 0&&(a[d]=u)}),a}),l=i.length?i:null;t.forEach(r=>{r.controlId===e&&(r.originControlId||null)===n&&r.control&&(r.control.value=l?ct(l):null)})}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()||this.element.control?.editable===!1)return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{endIndex:i}=n,l=e[i],r=this.element.controlId||l?.controlId,a=this.element.originControlId||l?.originControlId||null,c=R=>!!R&&R.controlId===r&&(R.originControlId||null)===a;if(!!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))return this.control.removeControl(i);if(!r)return null;const u=R=>(this.draw.spliceElementList(e,R,1),this.syncControlValue(e,r,a),e.some(g=>g.controlId===r&&(g.originControlId||null)===a&&g.controlComponent===s.ControlComponent.VALUE)||this.control.addPlaceholder(Math.max(R-1,0)),Math.max(R-1,0));if(t.key===s.KeyMap.Backspace){if(l?.controlComponent===s.ControlComponent.VALUE&&c(l))return u(i);if(l?.controlComponent===s.ControlComponent.POSTFIX&&c(l)){const R=e[i-1];if(R?.controlComponent===s.ControlComponent.VALUE&&c(R))return u(i-1)}return i}if(t.key===s.KeyMap.Delete){const R=e[i+1];return R?.controlComponent===s.ControlComponent.VALUE&&c(R)?u(i+1):l?.controlComponent===s.ControlComponent.VALUE&&c(l)?u(i):i}return null}removeByValue(t,e){return Sn.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(()=>{Sn.isDeleting=!1},300),n(!0)})}cut(){if(this.control.getIsDisabledControl()||this.element.control?.editable===!1)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.syncControlValue(i,this.element.controlId||i[t]?.controlId||"",this.element.originControlId||i[t]?.originControlId||null),this.control.addPlaceholder(t),t}awake(t){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl()||Sn.isDeleting||!this.control.getPosition())return;const n=this.draw.getElementList(),{startIndex:i}=this.control.getRange();if(n[i]?.controlId!==this.element?.controlId)return;const l=this.control.getDraw().getPosition().getPositionContext();if(!l.isDirectHit||l.index!==i||n[l.index]?.controlId!==this.element?.controlId)return;const r=n[i]?.controlId,a=n[i]?.control;if(r?.endsWith("_text")||a?.buttonText)return;const c=n[i].controlId;if(!c)return;const d=n.filter(R=>R.controlId===c),u=d[0];if(u?.control&&this.options.mode!="form"&&this.options.mode=="edit"){const R=this.draw.getEventBus();if(t&&R.isSubscribe("buttonClick")){const h={evt:t,element:ct(u),elementList:ct(d),controlId:c,control:ct(u.control)};R.emit("buttonClick",h)}this.showEditModal(d)}}closeInputModal(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}syncButtonPlaceholderElements(t,e){const n=this.control.getElementList(),i=[];let l=null,r=-1,a=!1;if(n.forEach((u,R)=>{u.controlId!==t||u.control?.type!==s.ControlType.BUTTON||(u.control.placeholder=e,l||=u,u.controlComponent===s.ControlComponent.VALUE&&u.value&&u.value.trim()&&(a=!0),u.controlComponent===s.ControlComponent.PLACEHOLDER&&i.push({element:u,index:R}),r===-1&&u.controlComponent===s.ControlComponent.POSTFIX&&(r=R))}),!l)return;const c=i.length?Math.min(...i.map(u=>u.index)):r;i.length&&i.sort((u,R)=>R.index-u.index).forEach(u=>{n.splice(u.index,1)});const d=yt(e);!d.length||a&&!i.length||c<0||d.forEach((u,R)=>{const h={...$t(l,[...Re,...ue]),value:u===`
118
+ `+new Error().stack),e=!1}return t.apply(this,arguments)},t)}var Er={};function Mr(o,t){st.deprecationHandler!=null&&st.deprecationHandler(o,t),Er[o]||(Pr(t),Er[o]=!0)}st.suppressDeprecationWarnings=!1,st.deprecationHandler=null;function _e(o){return typeof Function<"u"&&o instanceof Function||Object.prototype.toString.call(o)==="[object Function]"}function Bd(o){var t,e;for(e in o)Ht(o,e)&&(t=o[e],_e(t)?this[e]=t:this["_"+e]=t);this._config=o,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function _i(o,t){var e=Rn({},o),n;for(n in t)Ht(t,n)&&(Pn(o[n])&&Pn(t[n])?(e[n]={},Rn(e[n],o[n]),Rn(e[n],t[n])):t[n]!=null?e[n]=t[n]:delete e[n]);for(n in o)Ht(o,n)&&!Ht(t,n)&&Pn(o[n])&&(e[n]=Rn({},e[n]));return e}function Ai(o){o!=null&&this.set(o)}var ki;Object.keys?ki=Object.keys:ki=function(o){var t,e=[];for(t in o)Ht(o,t)&&e.push(t);return e};var Jd={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function $d(o,t,e){var n=this._calendar[o]||this._calendar.sameElse;return _e(n)?n.call(t,e):n}function Ae(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 Gi=/(\[[^\[]*\])|(\\)?([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,Wo=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,xi={},vn={};function Tt(o,t,e,n){var i=n;typeof n=="string"&&(i=function(){return this[n]()}),o&&(vn[o]=i),t&&(vn[t[0]]=function(){return Ae(i.apply(this,arguments),t[1],t[2])}),e&&(vn[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 jd(o){var t=o.match(Gi),e,n;for(e=0,n=t.length;e<n;e++)vn[t[e]]?t[e]=vn[t[e]]:t[e]=zd(t[e]);return function(i){var l="",r;for(r=0;r<n;r++)l+=_e(t[r])?t[r].call(i,o):t[r];return l}}function Yo(o,t){return o.isValid()?(t=Or(t,o.localeData()),xi[t]=xi[t]||jd(t),xi[t](o)):o.localeData().invalidDate()}function Or(o,t){var e=5;function n(i){return t.longDateFormat(i)||i}for(Wo.lastIndex=0;e>=0&&Wo.test(o);)o=o.replace(Wo,n),Wo.lastIndex=0,e-=1;return o}var qd={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 tu(o){var t=this._longDateFormat[o],e=this._longDateFormat[o.toUpperCase()];return t||!e?t:(this._longDateFormat[o]=e.match(Gi).map(function(n){return n==="MMMM"||n==="MM"||n==="DD"||n==="dddd"?n.slice(1):n}).join(""),this._longDateFormat[o])}var eu="Invalid date";function nu(){return this._invalidDate}var ou="%d",iu=/\d{1,2}/;function su(o){return this._ordinal.replace("%d",o)}var ru={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function lu(o,t,e,n){var i=this._relativeTime[e];return _e(i)?i(o,t,e,n):i.replace(/%d/i,o)}function au(o,t){var e=this._relativeTime[o>0?"future":"past"];return _e(e)?e(t):e.replace(/%s/i,t)}var Sr={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"?Sr[o]||Sr[o.toLowerCase()]:void 0}function Bi(o){var t={},e,n;for(n in o)Ht(o,n)&&(e=Oe(n),e&&(t[e]=o[n]));return t}var cu={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 du(o){var t=[],e;for(e in o)Ht(o,e)&&t.push({unit:e,priority:cu[e]});return t.sort(function(n,i){return n.priority-i.priority}),t}var Xr=/\d/,Ie=/\d\d/,Nr=/\d{3}/,Ji=/\d{4}/,Uo=/[+-]?\d{6}/,qt=/\d\d?/,Fr=/\d\d\d\d?/,yr=/\d\d\d\d\d\d?/,wo=/\d{1,3}/,$i=/\d{1,4}/,Zo=/[+-]?\d{1,6}/,Kn=/\d+/,Qo=/[+-]?\d+/,uu=/Z|[+-]\d\d:?\d\d/gi,vo=/Z|[+-]\d\d(?::?\d\d)?/gi,Ru=/[+-]?\d+(\.\d{1,3})?/,oo=/[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,Hn=/^[1-9]\d?/,zi=/^([1-9]\d|\d)/,Ko;Ko={};function ut(o,t,e){Ko[o]=_e(t)?t:function(n,i){return n&&e?e:t}}function hu(o,t){return Ht(Ko,o)?Ko[o](t._strict,t._locale):new RegExp(gu(o))}function gu(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 Wt(o){var t=+o,e=0;return t!==0&&isFinite(t)&&(e=Se(t)),e}var ji={};function xt(o,t){var e,n=t,i;for(typeof o=="string"&&(o=[o]),$e(t)&&(n=function(l,r){r[t]=Wt(l)}),i=o.length,e=0;e<i;e++)ji[o[e]]=n}function io(o,t){xt(o,function(e,n,i,l){i._w=i._w||{},t(e,i._w,i,l)})}function Tu(o,t,e){t!=null&&Ht(ji,o)&&ji[o](t,e._a,e,o)}function Ho(o){return o%4===0&&o%100!==0||o%400===0}var he=0,je=1,ke=2,ce=3,be=4,qe=5,En=6,fu=7,mu=8;Tt("Y",0,0,function(){var o=this.year();return o<=9999?Ae(o,4):"+"+o}),Tt(0,["YY",2],0,function(){return this.year()%100}),Tt(0,["YYYY",4],0,"year"),Tt(0,["YYYYY",5],0,"year"),Tt(0,["YYYYYY",6,!0],0,"year"),ut("Y",Qo),ut("YY",qt,Ie),ut("YYYY",$i,Ji),ut("YYYYY",Zo,Uo),ut("YYYYYY",Zo,Uo),xt(["YYYYY","YYYYYY"],he),xt("YYYY",function(o,t){t[he]=o.length===2?st.parseTwoDigitYear(o):Wt(o)}),xt("YY",function(o,t){t[he]=st.parseTwoDigitYear(o)}),xt("Y",function(o,t){t[he]=parseInt(o,10)});function so(o){return Ho(o)?366:365}st.parseTwoDigitYear=function(o){return Wt(o)+(Wt(o)>68?1900:2e3)};var br=_n("FullYear",!0);function pu(){return Ho(this.year())}function _n(o,t){return function(e){return e!=null?(Dr(this,o,e),st.updateOffset(this,t),this):ro(this,o)}}function ro(o,t){if(!o.isValid())return NaN;var e=o._d,n=o._isUTC;switch(t){case"Milliseconds":return n?e.getUTCMilliseconds():e.getMilliseconds();case"Seconds":return n?e.getUTCSeconds():e.getSeconds();case"Minutes":return n?e.getUTCMinutes():e.getMinutes();case"Hours":return n?e.getUTCHours():e.getHours();case"Date":return n?e.getUTCDate():e.getDate();case"Day":return n?e.getUTCDay():e.getDay();case"Month":return n?e.getUTCMonth():e.getMonth();case"FullYear":return n?e.getUTCFullYear():e.getFullYear();default:return NaN}}function Dr(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&&!Ho(l)?28:a,i?n.setUTCFullYear(l,r,a):n.setFullYear(l,r,a)}}function Cu(o){return o=Oe(o),_e(this[o])?this[o]():this}function Iu(o,t){if(typeof o=="object"){o=Bi(o);var e=du(o),n,i=e.length;for(n=0;n<i;n++)this[e[n].unit](o[e[n].unit])}else if(o=Oe(o),_e(this[o]))return this[o](t);return this}function Lu(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 qi(o,t){if(isNaN(o)||isNaN(t))return NaN;var e=Lu(t,12);return o+=(t-e)/12,e===1?Ho(o)?29:28:31-e%7%2}Tt("M",["MM",2],"Mo",function(){return this.month()+1}),Tt("MMM",0,0,function(o){return this.localeData().monthsShort(this,o)}),Tt("MMMM",0,0,function(o){return this.localeData().months(this,o)}),ut("M",qt,Hn),ut("MM",qt,Ie),ut("MMM",function(o,t){return t.monthsShortRegex(o)}),ut("MMMM",function(o,t){return t.monthsRegex(o)}),xt(["M","MM"],function(o,t){t[je]=Wt(o)-1}),xt(["MMM","MMMM"],function(o,t,e,n){var i=e._locale.monthsParse(o,n,e._strict);i!=null?t[je]=i:Nt(e).invalidMonth=o});var Pu="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Vr="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Wr=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Eu=oo,Mu=oo;function Ou(o,t){return o?Fe(this._months)?this._months[o.month()]:this._months[(this._months.isFormat||Wr).test(t)?"format":"standalone"][o.month()]:Fe(this._months)?this._months:this._months.standalone}function Su(o,t){return o?Fe(this._monthsShort)?this._monthsShort[o.month()]:this._monthsShort[Wr.test(t)?"format":"standalone"][o.month()]:Fe(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Xu(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=He([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 Nu(o,t,e){var n,i,l;if(this._monthsParseExact)return Xu.call(this,o,t,e);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(i=He([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 Yr(o,t){if(!o.isValid())return o;if(typeof t=="string"){if(/^\d+$/.test(t))t=Wt(t);else if(t=o.localeData().monthsParse(t),!$e(t))return o}var e=t,n=o.date();return n=n<29?n:Math.min(n,qi(o.year(),e)),o._isUTC?o._d.setUTCMonth(e,n):o._d.setMonth(e,n),o}function Ur(o){return o!=null?(Yr(this,o),st.updateOffset(this,!0),this):ro(this,"Month")}function Fu(){return qi(this.year(),this.month())}function yu(o){return this._monthsParseExact?(Ht(this,"_monthsRegex")||wr.call(this),o?this._monthsShortStrictRegex:this._monthsShortRegex):(Ht(this,"_monthsShortRegex")||(this._monthsShortRegex=Eu),this._monthsShortStrictRegex&&o?this._monthsShortStrictRegex:this._monthsShortRegex)}function bu(o){return this._monthsParseExact?(Ht(this,"_monthsRegex")||wr.call(this),o?this._monthsStrictRegex:this._monthsRegex):(Ht(this,"_monthsRegex")||(this._monthsRegex=Mu),this._monthsStrictRegex&&o?this._monthsStrictRegex:this._monthsRegex)}function wr(){function o(c,d){return d.length-c.length}var t=[],e=[],n=[],i,l,r,a;for(i=0;i<12;i++)l=He([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 Du(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 lo(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 _o(o,t,e){var n=7+t-e,i=(7+lo(o,0,n).getUTCDay()-t)%7;return-i+n-1}function Zr(o,t,e,n,i){var l=(7+e-n)%7,r=_o(o,n,i),a=1+7*(t-1)+l+r,c,d;return a<=0?(c=o-1,d=so(c)+a):a>so(o)?(c=o+1,d=a-so(o)):(c=o,d=a),{year:c,dayOfYear:d}}function ao(o,t,e){var n=_o(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=_o(o,t,e),i=_o(o+1,t,e);return(so(o)-n+i)/7}Tt("w",["ww",2],"wo","week"),Tt("W",["WW",2],"Wo","isoWeek"),ut("w",qt,Hn),ut("ww",qt,Ie),ut("W",qt,Hn),ut("WW",qt,Ie),io(["w","ww","W","WW"],function(o,t,e,n){t[n.substr(0,1)]=Wt(o)});function Vu(o){return ao(o,this._week.dow,this._week.doy).week}var Wu={dow:0,doy:6};function Yu(){return this._week.dow}function Uu(){return this._week.doy}function wu(o){var t=this.localeData().week(this);return o==null?t:this.add((o-t)*7,"d")}function Zu(o){var t=ao(this,1,4).week;return o==null?t:this.add((o-t)*7,"d")}Tt("d",0,"do","day"),Tt("dd",0,0,function(o){return this.localeData().weekdaysMin(this,o)}),Tt("ddd",0,0,function(o){return this.localeData().weekdaysShort(this,o)}),Tt("dddd",0,0,function(o){return this.localeData().weekdays(this,o)}),Tt("e",0,0,"weekday"),Tt("E",0,0,"isoWeekday"),ut("d",qt),ut("e",qt),ut("E",qt),ut("dd",function(o,t){return t.weekdaysMinRegex(o)}),ut("ddd",function(o,t){return t.weekdaysShortRegex(o)}),ut("dddd",function(o,t){return t.weekdaysRegex(o)}),io(["dd","ddd","dddd"],function(o,t,e,n){var i=e._locale.weekdaysParse(o,n,e._strict);i!=null?t.d=i:Nt(e).invalidWeekday=o}),io(["d","e","E"],function(o,t,e,n){t[n]=Wt(o)});function Qu(o,t){return typeof o!="string"?o:isNaN(o)?(o=t.weekdaysParse(o),typeof o=="number"?o:null):parseInt(o,10)}function vu(o,t){return typeof o=="string"?t.weekdaysParse(o)%7||7:isNaN(o)?null:o}function ts(o,t){return o.slice(t,7).concat(o.slice(0,t))}var Ku="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Qr="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Hu="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),_u=oo,Au=oo,ku=oo;function Gu(o,t){var e=Fe(this._weekdays)?this._weekdays:this._weekdays[o&&o!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return o===!0?ts(e,this._week.dow):o?e[o.day()]:e}function xu(o){return o===!0?ts(this._weekdaysShort,this._week.dow):o?this._weekdaysShort[o.day()]:this._weekdaysShort}function Bu(o){return o===!0?ts(this._weekdaysMin,this._week.dow):o?this._weekdaysMin[o.day()]:this._weekdaysMin}function Ju(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=He([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 $u(o,t,e){var n,i,l;if(this._weekdaysParseExact)return Ju.call(this,o,t,e);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(i=He([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=ro(this,"Day");return o!=null?(o=Qu(o,this.localeData()),this.add(o-t,"d")):t}function ju(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 qu(o){if(!this.isValid())return o!=null?this:NaN;if(o!=null){var t=vu(o,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function tR(o){return this._weekdaysParseExact?(Ht(this,"_weekdaysRegex")||es.call(this),o?this._weekdaysStrictRegex:this._weekdaysRegex):(Ht(this,"_weekdaysRegex")||(this._weekdaysRegex=_u),this._weekdaysStrictRegex&&o?this._weekdaysStrictRegex:this._weekdaysRegex)}function eR(o){return this._weekdaysParseExact?(Ht(this,"_weekdaysRegex")||es.call(this),o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(Ht(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=Au),this._weekdaysShortStrictRegex&&o?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function nR(o){return this._weekdaysParseExact?(Ht(this,"_weekdaysRegex")||es.call(this),o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(Ht(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=ku),this._weekdaysMinStrictRegex&&o?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function es(){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=He([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 ns(){return this.hours()%12||12}function oR(){return this.hours()||24}Tt("H",["HH",2],0,"hour"),Tt("h",["hh",2],0,ns),Tt("k",["kk",2],0,oR),Tt("hmm",0,0,function(){return""+ns.apply(this)+Ae(this.minutes(),2)}),Tt("hmmss",0,0,function(){return""+ns.apply(this)+Ae(this.minutes(),2)+Ae(this.seconds(),2)}),Tt("Hmm",0,0,function(){return""+this.hours()+Ae(this.minutes(),2)}),Tt("Hmmss",0,0,function(){return""+this.hours()+Ae(this.minutes(),2)+Ae(this.seconds(),2)});function vr(o,t){Tt(o,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}vr("a",!0),vr("A",!1);function Kr(o,t){return t._meridiemParse}ut("a",Kr),ut("A",Kr),ut("H",qt,zi),ut("h",qt,Hn),ut("k",qt,Hn),ut("HH",qt,Ie),ut("hh",qt,Ie),ut("kk",qt,Ie),ut("hmm",Fr),ut("hmmss",yr),ut("Hmm",Fr),ut("Hmmss",yr),xt(["H","HH"],ce),xt(["k","kk"],function(o,t,e){var n=Wt(o);t[ce]=n===24?0:n}),xt(["a","A"],function(o,t,e){e._isPm=e._locale.isPM(o),e._meridiem=o}),xt(["h","hh"],function(o,t,e){t[ce]=Wt(o),Nt(e).bigHour=!0}),xt("hmm",function(o,t,e){var n=o.length-2;t[ce]=Wt(o.substr(0,n)),t[be]=Wt(o.substr(n)),Nt(e).bigHour=!0}),xt("hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[ce]=Wt(o.substr(0,n)),t[be]=Wt(o.substr(n,2)),t[qe]=Wt(o.substr(i)),Nt(e).bigHour=!0}),xt("Hmm",function(o,t,e){var n=o.length-2;t[ce]=Wt(o.substr(0,n)),t[be]=Wt(o.substr(n))}),xt("Hmmss",function(o,t,e){var n=o.length-4,i=o.length-2;t[ce]=Wt(o.substr(0,n)),t[be]=Wt(o.substr(n,2)),t[qe]=Wt(o.substr(i))});function iR(o){return(o+"").toLowerCase().charAt(0)==="p"}var sR=/[ap]\.?m?\.?/i,rR=_n("Hours",!0);function lR(o,t,e){return o>11?e?"pm":"PM":e?"am":"AM"}var Hr={calendar:Jd,longDateFormat:qd,invalidDate:eu,ordinal:ou,dayOfMonthOrdinalParse:iu,relativeTime:ru,months:Pu,monthsShort:Vr,week:Wu,weekdays:Ku,weekdaysMin:Hu,weekdaysShort:Qr,meridiemParse:sR},ie={},co={},uo;function aR(o,t){var e,n=Math.min(o.length,t.length);for(e=0;e<n;e+=1)if(o[e]!==t[e])return e;return n}function _r(o){return o&&o.toLowerCase().replace("_","-")}function cR(o){for(var t=0,e,n,i,l;t<o.length;){for(l=_r(o[t]).split("-"),e=l.length,n=_r(o[t+1]),n=n?n.split("-"):null;e>0;){if(i=Ao(l.slice(0,e).join("-")),i)return i;if(n&&n.length>=e&&aR(l,n)>=e-1)break;e--}t++}return uo}function dR(o){return!!(o&&o.match("^[^/\\\\]*$"))}function Ao(o){var t=null,e;if(ie[o]===void 0&&typeof module<"u"&&module&&module.exports&&dR(o))try{t=uo._abbr,e=require,e("./locale/"+o),hn(t)}catch{ie[o]=null}return ie[o]}function hn(o,t){var e;return o&&(fe(t)?e=en(o):e=os(o,t),e?uo=e:typeof console<"u"&&console.warn&&console.warn("Locale "+o+" not found. Did you forget to load it?")),uo._abbr}function os(o,t){if(t!==null){var e,n=Hr;if(t.abbr=o,ie[o]!=null)Mr("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=ie[o]._config;else if(t.parentLocale!=null)if(ie[t.parentLocale]!=null)n=ie[t.parentLocale]._config;else if(e=Ao(t.parentLocale),e!=null)n=e._config;else return co[t.parentLocale]||(co[t.parentLocale]=[]),co[t.parentLocale].push({name:o,config:t}),null;return ie[o]=new Ai(_i(n,t)),co[o]&&co[o].forEach(function(i){os(i.name,i.config)}),hn(o),ie[o]}else return delete ie[o],null}function uR(o,t){if(t!=null){var e,n,i=Hr;ie[o]!=null&&ie[o].parentLocale!=null?ie[o].set(_i(ie[o]._config,t)):(n=Ao(o),n!=null&&(i=n._config),t=_i(i,t),n==null&&(t.abbr=o),e=new Ai(t),e.parentLocale=ie[o],ie[o]=e),hn(o)}else ie[o]!=null&&(ie[o].parentLocale!=null?(ie[o]=ie[o].parentLocale,o===hn()&&hn(o)):ie[o]!=null&&delete ie[o]);return ie[o]}function en(o){var t;if(o&&o._locale&&o._locale._abbr&&(o=o._locale._abbr),!o)return uo;if(!Fe(o)){if(t=Ao(o),t)return t;o=[o]}return cR(o)}function RR(){return ki(ie)}function is(o){var t,e=o._a;return e&&Nt(o).overflow===-2&&(t=e[je]<0||e[je]>11?je:e[ke]<1||e[ke]>qi(e[he],e[je])?ke:e[ce]<0||e[ce]>24||e[ce]===24&&(e[be]!==0||e[qe]!==0||e[En]!==0)?ce:e[be]<0||e[be]>59?be:e[qe]<0||e[qe]>59?qe:e[En]<0||e[En]>999?En:-1,Nt(o)._overflowDayOfYear&&(t<he||t>ke)&&(t=ke),Nt(o)._overflowWeeks&&t===-1&&(t=fu),Nt(o)._overflowWeekday&&t===-1&&(t=mu),Nt(o).overflow=t),o}var hR=/^\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)?)?$/,gR=/^\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)?)?$/,TR=/Z|[+-]\d\d(?::?\d\d)?/,ko=[["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]],ss=[["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/]],fR=/^\/?Date\((-?\d+)/i,mR=/^(?:(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}))$/,pR={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Ar(o){var t,e,n=o._i,i=hR.exec(n)||gR.exec(n),l,r,a,c,d=ko.length,u=ss.length;if(i){for(Nt(o).iso=!0,t=0,e=d;t<e;t++)if(ko[t][1].exec(i[1])){r=ko[t][0],l=ko[t][2]!==!1;break}if(r==null){o._isValid=!1;return}if(i[3]){for(t=0,e=u;t<e;t++)if(ss[t][1].exec(i[3])){a=(i[2]||" ")+ss[t][0];break}if(a==null){o._isValid=!1;return}}if(!l&&a!=null){o._isValid=!1;return}if(i[4])if(TR.exec(i[4]))c="Z";else{o._isValid=!1;return}o._f=r+(a||"")+(c||""),ls(o)}else o._isValid=!1}function CR(o,t,e,n,i,l){var r=[IR(o),Vr.indexOf(t),parseInt(e,10),parseInt(n,10),parseInt(i,10)];return l&&r.push(parseInt(l,10)),r}function IR(o){var t=parseInt(o,10);return t<=49?2e3+t:t<=999?1900+t:t}function LR(o){return o.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function PR(o,t,e){if(o){var n=Qr.indexOf(o),i=new Date(t[0],t[1],t[2]).getDay();if(n!==i)return Nt(e).weekdayMismatch=!0,e._isValid=!1,!1}return!0}function ER(o,t,e){if(o)return pR[o];if(t)return 0;var n=parseInt(e,10),i=n%100,l=(n-i)/100;return l*60+i}function kr(o){var t=mR.exec(LR(o._i)),e;if(t){if(e=CR(t[4],t[3],t[2],t[5],t[6],t[7]),!PR(t[1],e,o))return;o._a=e,o._tzm=ER(t[8],t[9],t[10]),o._d=lo.apply(null,o._a),o._d.setUTCMinutes(o._d.getUTCMinutes()-o._tzm),Nt(o).rfc2822=!0}else o._isValid=!1}function MR(o){var t=fR.exec(o._i);if(t!==null){o._d=new Date(+t[1]);return}if(Ar(o),o._isValid===!1)delete o._isValid;else return;if(kr(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 An(o,t,e){return o??t??e}function OR(o){var t=new Date(st.now());return o._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function rs(o){var t,e,n=[],i,l,r;if(!o._d){for(i=OR(o),o._w&&o._a[ke]==null&&o._a[je]==null&&SR(o),o._dayOfYear!=null&&(r=An(o._a[he],i[he]),(o._dayOfYear>so(r)||o._dayOfYear===0)&&(Nt(o)._overflowDayOfYear=!0),e=lo(r,0,o._dayOfYear),o._a[je]=e.getUTCMonth(),o._a[ke]=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[ce]===24&&o._a[be]===0&&o._a[qe]===0&&o._a[En]===0&&(o._nextDay=!0,o._a[ce]=0),o._d=(o._useUTC?lo:Du).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[ce]=24),o._w&&typeof o._w.d<"u"&&o._w.d!==l&&(Nt(o).weekdayMismatch=!0)}}function SR(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=An(t.GG,o._a[he],ao(te(),1,4).year),n=An(t.W,1),i=An(t.E,1),(i<1||i>7)&&(c=!0)):(l=o._locale._week.dow,r=o._locale._week.doy,d=ao(te(),l,r),e=An(t.gg,o._a[he],d.year),n=An(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)?Nt(o)._overflowWeeks=!0:c!=null?Nt(o)._overflowWeekday=!0:(a=Zr(e,n,i,l,r),o._a[he]=a.year,o._dayOfYear=a.dayOfYear)}st.ISO_8601=function(){},st.RFC_2822=function(){};function ls(o){if(o._f===st.ISO_8601){Ar(o);return}if(o._f===st.RFC_2822){kr(o);return}o._a=[],Nt(o).empty=!0;var t=""+o._i,e,n,i,l,r,a=t.length,c=0,d,u;for(i=Or(o._f,o._locale).match(Gi)||[],u=i.length,e=0;e<u;e++)l=i[e],n=(t.match(hu(l,o))||[])[0],n&&(r=t.substr(0,t.indexOf(n)),r.length>0&&Nt(o).unusedInput.push(r),t=t.slice(t.indexOf(n)+n.length),c+=n.length),vn[l]?(n?Nt(o).empty=!1:Nt(o).unusedTokens.push(l),Tu(l,n,o)):o._strict&&!n&&Nt(o).unusedTokens.push(l);Nt(o).charsLeftOver=a-c,t.length>0&&Nt(o).unusedInput.push(t),o._a[ce]<=12&&Nt(o).bigHour===!0&&o._a[ce]>0&&(Nt(o).bigHour=void 0),Nt(o).parsedDateParts=o._a.slice(0),Nt(o).meridiem=o._meridiem,o._a[ce]=XR(o._locale,o._a[ce],o._meridiem),d=Nt(o).era,d!==null&&(o._a[he]=o._locale.erasConvertYear(d,o._a[he])),rs(o),is(o)}function XR(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 NR(o){var t,e,n,i,l,r,a=!1,c=o._f.length;if(c===0){Nt(o).invalidFormat=!0,o._d=new Date(NaN);return}for(i=0;i<c;i++)l=0,r=!1,t=Hi({},o),o._useUTC!=null&&(t._useUTC=o._useUTC),t._f=o._f[i],ls(t),vi(t)&&(r=!0),l+=Nt(t).charsLeftOver,l+=Nt(t).unusedTokens.length*10,Nt(t).score=l,a?l<n&&(n=l,e=t):(n==null||l<n||r)&&(n=l,e=t,r&&(a=!0));Rn(o,e||t)}function FR(o){if(!o._d){var t=Bi(o._i),e=t.day===void 0?t.date:t.day;o._a=Ir([t.year,t.month,e,t.hour,t.minute,t.second,t.millisecond],function(n){return n&&parseInt(n,10)}),rs(o)}}function yR(o){var t=new no(is(Gr(o)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function Gr(o){var t=o._i,e=o._f;return o._locale=o._locale||en(o._l),t===null||e===void 0&&t===""?Vo({nullInput:!0}):(typeof t=="string"&&(o._i=t=o._locale.preparse(t)),ye(t)?new no(is(t)):(eo(t)?o._d=t:Fe(e)?NR(o):e?ls(o):bR(o),vi(o)||(o._d=null),o))}function bR(o){var t=o._i;fe(t)?o._d=new Date(st.now()):eo(t)?o._d=new Date(t.valueOf()):typeof t=="string"?MR(o):Fe(t)?(o._a=Ir(t.slice(0),function(e){return parseInt(e,10)}),rs(o)):Pn(t)?FR(o):$e(t)?o._d=new Date(t):st.createFromInputFallback(o)}function xr(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),(Pn(o)&&Zi(o)||Fe(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,yR(l)}function te(o,t,e,n){return xr(o,t,e,n,!1)}var DR=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:Vo()}),VR=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:Vo()});function Br(o,t){var e,n;if(t.length===1&&Fe(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 WR(){var o=[].slice.call(arguments,0);return Br("isBefore",o)}function YR(){var o=[].slice.call(arguments,0);return Br("isAfter",o)}var UR=function(){return Date.now?Date.now():+new Date},Ro=["year","quarter","month","week","day","hour","minute","second","millisecond"];function wR(o){var t,e=!1,n,i=Ro.length;for(t in o)if(Ht(o,t)&&!(le.call(Ro,t)!==-1&&(o[t]==null||!isNaN(o[t]))))return!1;for(n=0;n<i;++n)if(o[Ro[n]]){if(e)return!1;parseFloat(o[Ro[n]])!==Wt(o[Ro[n]])&&(e=!0)}return!0}function ZR(){return this._isValid}function QR(){return De(NaN)}function Go(o){var t=Bi(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=wR(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 xo(o){return o instanceof Go}function as(o){return o<0?Math.round(-1*o)*-1:Math.round(o)}function vR(o,t,e){var n=Math.min(o.length,t.length),i=Math.abs(o.length-t.length),l=0,r;for(r=0;r<n;r++)Wt(o[r])!==Wt(t[r])&&l++;return l+i}function Jr(o,t){Tt(o,0,0,function(){var e=this.utcOffset(),n="+";return e<0&&(e=-e,n="-"),n+Ae(~~(e/60),2)+t+Ae(~~e%60,2)})}Jr("Z",":"),Jr("ZZ",""),ut("Z",vo),ut("ZZ",vo),xt(["Z","ZZ"],function(o,t,e){e._useUTC=!0,e._tzm=cs(vo,o)});var KR=/([\+\-]|\d\d)/gi;function cs(o,t){var e=(t||"").match(o),n,i,l;return e===null?null:(n=e[e.length-1]||[],i=(n+"").match(KR)||["-",0,0],l=+(i[1]*60)+Wt(i[2]),l===0?0:i[0]==="+"?l:-l)}function ds(o,t){var e,n;return t._isUTC?(e=t.clone(),n=(ye(o)||eo(o)?o.valueOf():te(o).valueOf())-e.valueOf(),e._d.setTime(e._d.valueOf()+n),st.updateOffset(e,!1),e):te(o).local()}function us(o){return-Math.round(o._d.getTimezoneOffset())}st.updateOffset=function(){};function HR(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=cs(vo,o),o===null)return this}else Math.abs(o)<16&&!e&&(o=o*60);return!this._isUTC&&t&&(i=us(this)),this._offset=o,this._isUTC=!0,i!=null&&this.add(i,"m"),n!==o&&(!t||this._changeInProgress?qr(this,De(o-n,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,st.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?n:us(this)}function _R(o,t){return o!=null?(typeof o!="string"&&(o=-o),this.utcOffset(o,t),this):-this.utcOffset()}function AR(o){return this.utcOffset(0,o)}function kR(o){return this._isUTC&&(this.utcOffset(0,o),this._isUTC=!1,o&&this.subtract(us(this),"m")),this}function GR(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var o=cs(uu,this._i);o!=null?this.utcOffset(o):this.utcOffset(0,!0)}return this}function xR(o){return this.isValid()?(o=o?te(o).utcOffset():0,(this.utcOffset()-o)%60===0):!1}function BR(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function JR(){if(!fe(this._isDSTShifted))return this._isDSTShifted;var o={},t;return Hi(o,this),o=Gr(o),o._a?(t=o._isUTC?He(o._a):te(o._a),this._isDSTShifted=this.isValid()&&vR(o._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function $R(){return this.isValid()?!this._isUTC:!1}function zR(){return this.isValid()?this._isUTC:!1}function $r(){return this.isValid()?this._isUTC&&this._offset===0:!1}var jR=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,qR=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function De(o,t){var e=o,n=null,i,l,r;return xo(o)?e={ms:o._milliseconds,d:o._days,M:o._months}:$e(o)||!isNaN(+o)?(e={},t?e[t]=+o:e.milliseconds=+o):(n=jR.exec(o))?(i=n[1]==="-"?-1:1,e={y:0,d:Wt(n[ke])*i,h:Wt(n[ce])*i,m:Wt(n[be])*i,s:Wt(n[qe])*i,ms:Wt(as(n[En]*1e3))*i}):(n=qR.exec(o))?(i=n[1]==="-"?-1:1,e={y:Mn(n[2],i),M:Mn(n[3],i),w:Mn(n[4],i),d:Mn(n[5],i),h:Mn(n[6],i),m:Mn(n[7],i),s:Mn(n[8],i)}):e==null?e={}:typeof e=="object"&&("from"in e||"to"in e)&&(r=th(te(e.from),te(e.to)),e={},e.ms=r.milliseconds,e.M=r.months),l=new Go(e),xo(o)&&Ht(o,"_locale")&&(l._locale=o._locale),xo(o)&&Ht(o,"_isValid")&&(l._isValid=o._isValid),l}De.fn=Go.prototype,De.invalid=QR;function Mn(o,t){var e=o&&parseFloat(o.replace(",","."));return(isNaN(e)?0:e)*t}function zr(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 th(o,t){var e;return o.isValid()&&t.isValid()?(t=ds(t,o),o.isBefore(t)?e=zr(o,t):(e=zr(t,o),e.milliseconds=-e.milliseconds,e.months=-e.months),e):{milliseconds:0,months:0}}function jr(o,t){return function(e,n){var i,l;return n!==null&&!isNaN(+n)&&(Mr(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=De(e,n),qr(this,i,o),this}}function qr(o,t,e,n){var i=t._milliseconds,l=as(t._days),r=as(t._months);o.isValid()&&(n=n??!0,r&&Yr(o,ro(o,"Month")+r*e),l&&Dr(o,"Date",ro(o,"Date")+l*e),i&&o._d.setTime(o._d.valueOf()+i*e),n&&st.updateOffset(o,l||r))}var eh=jr(1,"add"),nh=jr(-1,"subtract");function tl(o){return typeof o=="string"||o instanceof String}function oh(o){return ye(o)||eo(o)||tl(o)||$e(o)||sh(o)||ih(o)||o===null||o===void 0}function ih(o){var t=Pn(o)&&!Zi(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||Ht(o,l);return t&&e}function sh(o){var t=Fe(o),e=!1;return t&&(e=o.filter(function(n){return!$e(n)&&tl(o)}).length===0),t&&e}function rh(o){var t=Pn(o)&&!Zi(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||Ht(o,l);return t&&e}function lh(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 ah(o,t){arguments.length===1&&(arguments[0]?oh(arguments[0])?(o=arguments[0],t=void 0):rh(arguments[0])&&(t=arguments[0],o=void 0):(o=void 0,t=void 0));var e=o||te(),n=ds(e,this).startOf("day"),i=st.calendarFormat(this,n)||"sameElse",l=t&&(_e(t[i])?t[i].call(this,e):t[i]);return this.format(l||this.localeData().calendar(i,this,te(e)))}function ch(){return new no(this)}function dh(o,t){var e=ye(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 uh(o,t){var e=ye(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 Rh(o,t,e,n){var i=ye(o)?o:te(o),l=ye(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 hh(o,t){var e=ye(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 gh(o,t){return this.isSame(o,t)||this.isAfter(o,t)}function Th(o,t){return this.isSame(o,t)||this.isBefore(o,t)}function fh(o,t,e){var n,i,l;if(!this.isValid())return NaN;if(n=ds(o,this),!n.isValid())return NaN;switch(i=(n.utcOffset()-this.utcOffset())*6e4,t=Oe(t),t){case"year":l=Bo(this,n)/12;break;case"month":l=Bo(this,n);break;case"quarter":l=Bo(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 Bo(o,t){if(o.date()<t.date())return-Bo(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 mh(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function ph(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"):_e(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 Ch(){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 Ih(o){o||(o=this.isUtc()?st.defaultFormatUtc:st.defaultFormat);var t=Yo(this,o);return this.localeData().postformat(t)}function Lh(o,t){return this.isValid()&&(ye(o)&&o.isValid()||te(o).isValid())?De({to:this,from:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Ph(o){return this.from(te(),o)}function Eh(o,t){return this.isValid()&&(ye(o)&&o.isValid()||te(o).isValid())?De({from:this,to:o}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Mh(o){return this.to(te(),o)}function el(o){var t;return o===void 0?this._locale._abbr:(t=en(o),t!=null&&(this._locale=t),this)}var nl=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 ol(){return this._locale}var Jo=1e3,kn=60*Jo,$o=60*kn,il=(365*400+97)*24*$o;function Gn(o,t){return(o%t+t)%t}function sl(o,t,e){return o<100&&o>=0?new Date(o+400,t,e)-il:new Date(o,t,e).valueOf()}function rl(o,t,e){return o<100&&o>=0?Date.UTC(o+400,t,e)-il:Date.UTC(o,t,e)}function Oh(o){var t,e;if(o=Oe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?rl:sl,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-=Gn(t+(this._isUTC?0:this.utcOffset()*kn),$o);break;case"minute":t=this._d.valueOf(),t-=Gn(t,kn);break;case"second":t=this._d.valueOf(),t-=Gn(t,Jo);break}return this._d.setTime(t),st.updateOffset(this,!0),this}function Sh(o){var t,e;if(o=Oe(o),o===void 0||o==="millisecond"||!this.isValid())return this;switch(e=this._isUTC?rl:sl,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+=$o-Gn(t+(this._isUTC?0:this.utcOffset()*kn),$o)-1;break;case"minute":t=this._d.valueOf(),t+=kn-Gn(t,kn)-1;break;case"second":t=this._d.valueOf(),t+=Jo-Gn(t,Jo)-1;break}return this._d.setTime(t),st.updateOffset(this,!0),this}function Xh(){return this._d.valueOf()-(this._offset||0)*6e4}function Nh(){return Math.floor(this.valueOf()/1e3)}function Fh(){return new Date(this.valueOf())}function yh(){var o=this;return[o.year(),o.month(),o.date(),o.hour(),o.minute(),o.second(),o.millisecond()]}function bh(){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 Dh(){return this.isValid()?this.toISOString():null}function Vh(){return vi(this)}function Wh(){return Rn({},Nt(this))}function Yh(){return Nt(this).overflow}function Uh(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}Tt("N",0,0,"eraAbbr"),Tt("NN",0,0,"eraAbbr"),Tt("NNN",0,0,"eraAbbr"),Tt("NNNN",0,0,"eraName"),Tt("NNNNN",0,0,"eraNarrow"),Tt("y",["y",1],"yo","eraYear"),Tt("y",["yy",2],0,"eraYear"),Tt("y",["yyy",3],0,"eraYear"),Tt("y",["yyyy",4],0,"eraYear"),ut("N",Rs),ut("NN",Rs),ut("NNN",Rs),ut("NNNN",xh),ut("NNNNN",Bh),xt(["N","NN","NNN","NNNN","NNNNN"],function(o,t,e,n){var i=e._locale.erasParse(o,n,e._strict);i?Nt(e).era=i:Nt(e).invalidEra=o}),ut("y",Kn),ut("yy",Kn),ut("yyy",Kn),ut("yyyy",Kn),ut("yo",Jh),xt(["y","yy","yyy","yyyy"],he),xt(["yo"],function(o,t,e,n){var i;e._locale._eraYearOrdinalRegex&&(i=o.match(e._locale._eraYearOrdinalRegex)),e._locale.eraYearOrdinalParse?t[he]=e._locale.eraYearOrdinalParse(o,i):t[he]=parseInt(o,10)});function wh(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 Zh(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 Qh(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 vh(){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 Kh(){var o,t,e,n=this.localeData().eras();for(o=0,t=n.length;o<t;++o)if(e=this.clone().startOf("day").valueOf(),n[o].since<=e&&e<=n[o].until||n[o].until<=e&&e<=n[o].since)return n[o].narrow;return""}function Hh(){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 _h(){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 Ah(o){return Ht(this,"_erasNameRegex")||hs.call(this),o?this._erasNameRegex:this._erasRegex}function kh(o){return Ht(this,"_erasAbbrRegex")||hs.call(this),o?this._erasAbbrRegex:this._erasRegex}function Gh(o){return Ht(this,"_erasNarrowRegex")||hs.call(this),o?this._erasNarrowRegex:this._erasRegex}function Rs(o,t){return t.erasAbbrRegex(o)}function xh(o,t){return t.erasNameRegex(o)}function Bh(o,t){return t.erasNarrowRegex(o)}function Jh(o,t){return t._eraYearOrdinalRegex||Kn}function hs(){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")}Tt(0,["gg",2],0,function(){return this.weekYear()%100}),Tt(0,["GG",2],0,function(){return this.isoWeekYear()%100});function zo(o,t){Tt(0,[o,o.length],0,t)}zo("gggg","weekYear"),zo("ggggg","weekYear"),zo("GGGG","isoWeekYear"),zo("GGGGG","isoWeekYear"),ut("G",Qo),ut("g",Qo),ut("GG",qt,Ie),ut("gg",qt,Ie),ut("GGGG",$i,Ji),ut("gggg",$i,Ji),ut("GGGGG",Zo,Uo),ut("ggggg",Zo,Uo),io(["gggg","ggggg","GGGG","GGGGG"],function(o,t,e,n){t[n.substr(0,2)]=Wt(o)}),io(["gg","GG"],function(o,t,e,n){t[n]=st.parseTwoDigitYear(o)});function $h(o){return ll.call(this,o,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function zh(o){return ll.call(this,o,this.isoWeek(),this.isoWeekday(),1,4)}function jh(){return tn(this.year(),1,4)}function qh(){return tn(this.isoWeekYear(),1,4)}function tg(){var o=this.localeData()._week;return tn(this.year(),o.dow,o.doy)}function eg(){var o=this.localeData()._week;return tn(this.weekYear(),o.dow,o.doy)}function ll(o,t,e,n,i){var l;return o==null?ao(this,n,i).year:(l=tn(o,n,i),t>l&&(t=l),ng.call(this,o,t,e,n,i))}function ng(o,t,e,n,i){var l=Zr(o,t,e,n,i),r=lo(l.year,0,l.dayOfYear);return this.year(r.getUTCFullYear()),this.month(r.getUTCMonth()),this.date(r.getUTCDate()),this}Tt("Q",0,"Qo","quarter"),ut("Q",Xr),xt("Q",function(o,t){t[je]=(Wt(o)-1)*3});function og(o){return o==null?Math.ceil((this.month()+1)/3):this.month((o-1)*3+this.month()%3)}Tt("D",["DD",2],"Do","date"),ut("D",qt,Hn),ut("DD",qt,Ie),ut("Do",function(o,t){return o?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),xt(["D","DD"],ke),xt("Do",function(o,t){t[ke]=Wt(o.match(qt)[0])});var al=_n("Date",!0);Tt("DDD",["DDDD",3],"DDDo","dayOfYear"),ut("DDD",wo),ut("DDDD",Nr),xt(["DDD","DDDD"],function(o,t,e){e._dayOfYear=Wt(o)});function ig(o){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return o==null?t:this.add(o-t,"d")}Tt("m",["mm",2],0,"minute"),ut("m",qt,zi),ut("mm",qt,Ie),xt(["m","mm"],be);var sg=_n("Minutes",!1);Tt("s",["ss",2],0,"second"),ut("s",qt,zi),ut("ss",qt,Ie),xt(["s","ss"],qe);var rg=_n("Seconds",!1);Tt("S",0,0,function(){return~~(this.millisecond()/100)}),Tt(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),Tt(0,["SSS",3],0,"millisecond"),Tt(0,["SSSS",4],0,function(){return this.millisecond()*10}),Tt(0,["SSSSS",5],0,function(){return this.millisecond()*100}),Tt(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),Tt(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),Tt(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),Tt(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),ut("S",wo,Xr),ut("SS",wo,Ie),ut("SSS",wo,Nr);var gn,cl;for(gn="SSSS";gn.length<=9;gn+="S")ut(gn,Kn);function lg(o,t){t[En]=Wt(("0."+o)*1e3)}for(gn="S";gn.length<=9;gn+="S")xt(gn,lg);cl=_n("Milliseconds",!1),Tt("z",0,0,"zoneAbbr"),Tt("zz",0,0,"zoneName");function ag(){return this._isUTC?"UTC":""}function cg(){return this._isUTC?"Coordinated Universal Time":""}var B=no.prototype;B.add=eh,B.calendar=ah,B.clone=ch,B.diff=fh,B.endOf=Sh,B.format=Ih,B.from=Lh,B.fromNow=Ph,B.to=Eh,B.toNow=Mh,B.get=Cu,B.invalidAt=Yh,B.isAfter=dh,B.isBefore=uh,B.isBetween=Rh,B.isSame=hh,B.isSameOrAfter=gh,B.isSameOrBefore=Th,B.isValid=Vh,B.lang=nl,B.locale=el,B.localeData=ol,B.max=VR,B.min=DR,B.parsingFlags=Wh,B.set=Iu,B.startOf=Oh,B.subtract=nh,B.toArray=yh,B.toObject=bh,B.toDate=Fh,B.toISOString=ph,B.inspect=Ch,typeof Symbol<"u"&&Symbol.for!=null&&(B[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),B.toJSON=Dh,B.toString=mh,B.unix=Nh,B.valueOf=Xh,B.creationData=Uh,B.eraName=vh,B.eraNarrow=Kh,B.eraAbbr=Hh,B.eraYear=_h,B.year=br,B.isLeapYear=pu,B.weekYear=$h,B.isoWeekYear=zh,B.quarter=B.quarters=og,B.month=Ur,B.daysInMonth=Fu,B.week=B.weeks=wu,B.isoWeek=B.isoWeeks=Zu,B.weeksInYear=tg,B.weeksInWeekYear=eg,B.isoWeeksInYear=jh,B.isoWeeksInISOWeekYear=qh,B.date=al,B.day=B.days=zu,B.weekday=ju,B.isoWeekday=qu,B.dayOfYear=ig,B.hour=B.hours=rR,B.minute=B.minutes=sg,B.second=B.seconds=rg,B.millisecond=B.milliseconds=cl,B.utcOffset=HR,B.utc=AR,B.local=kR,B.parseZone=GR,B.hasAlignedHourOffset=xR,B.isDST=BR,B.isLocal=$R,B.isUtcOffset=zR,B.isUtc=$r,B.isUTC=$r,B.zoneAbbr=ag,B.zoneName=cg,B.dates=Me("dates accessor is deprecated. Use date instead.",al),B.months=Me("months accessor is deprecated. Use month instead",Ur),B.years=Me("years accessor is deprecated. Use year instead",br),B.zone=Me("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",_R),B.isDSTShifted=Me("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",JR);function dg(o){return te(o*1e3)}function ug(){return te.apply(null,arguments).parseZone()}function dl(o){return o}var _t=Ai.prototype;_t.calendar=$d,_t.longDateFormat=tu,_t.invalidDate=nu,_t.ordinal=su,_t.preparse=dl,_t.postformat=dl,_t.relativeTime=lu,_t.pastFuture=au,_t.set=Bd,_t.eras=wh,_t.erasParse=Zh,_t.erasConvertYear=Qh,_t.erasAbbrRegex=kh,_t.erasNameRegex=Ah,_t.erasNarrowRegex=Gh,_t.months=Ou,_t.monthsShort=Su,_t.monthsParse=Nu,_t.monthsRegex=bu,_t.monthsShortRegex=yu,_t.week=Vu,_t.firstDayOfYear=Uu,_t.firstDayOfWeek=Yu,_t.weekdays=Gu,_t.weekdaysMin=Bu,_t.weekdaysShort=xu,_t.weekdaysParse=$u,_t.weekdaysRegex=tR,_t.weekdaysShortRegex=eR,_t.weekdaysMinRegex=nR,_t.isPM=iR,_t.meridiem=lR;function jo(o,t,e,n){var i=en(),l=He().set(n,t);return i[e](l,o)}function ul(o,t,e){if($e(o)&&(t=o,o=void 0),o=o||"",t!=null)return jo(o,t,e,"month");var n,i=[];for(n=0;n<12;n++)i[n]=jo(o,n,e,"month");return i}function gs(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 jo(t,(e+l)%7,n,"day");for(r=0;r<7;r++)a[r]=jo(t,(r+l)%7,n,"day");return a}function Rg(o,t){return ul(o,t,"months")}function hg(o,t){return ul(o,t,"monthsShort")}function gg(o,t,e){return gs(o,t,e,"weekdays")}function Tg(o,t,e){return gs(o,t,e,"weekdaysShort")}function fg(o,t,e){return gs(o,t,e,"weekdaysMin")}hn("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(o){var t=o%10,e=Wt(o%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return o+e}}),st.lang=Me("moment.lang is deprecated. Use moment.locale instead.",hn),st.langData=Me("moment.langData is deprecated. Use moment.localeData instead.",en);var nn=Math.abs;function mg(){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 Rl(o,t,e,n){var i=De(t,e);return o._milliseconds+=n*i._milliseconds,o._days+=n*i._days,o._months+=n*i._months,o._bubble()}function pg(o,t){return Rl(this,o,t,1)}function Cg(o,t){return Rl(this,o,t,-1)}function hl(o){return o<0?Math.floor(o):Math.ceil(o)}function Ig(){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+=hl(Ts(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(gl(t)),e+=c,t-=hl(Ts(c)),a=Se(e/12),e%=12,n.days=t,n.months=e,n.years=a,this}function gl(o){return o*4800/146097}function Ts(o){return o*146097/4800}function Lg(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+gl(t),o){case"month":return e;case"quarter":return e/3;case"year":return e/12}else switch(t=this._days+Math.round(Ts(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 Tl=on("ms"),Pg=on("s"),Eg=on("m"),Mg=on("h"),Og=on("d"),Sg=on("w"),Xg=on("M"),Ng=on("Q"),Fg=on("y"),yg=Tl;function bg(){return De(this)}function Dg(o){return o=Oe(o),this.isValid()?this[o+"s"]():NaN}function On(o){return function(){return this.isValid()?this._data[o]:NaN}}var Vg=On("milliseconds"),Wg=On("seconds"),Yg=On("minutes"),Ug=On("hours"),wg=On("days"),Zg=On("months"),Qg=On("years");function vg(){return Se(this.days()/7)}var sn=Math.round,xn={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Kg(o,t,e,n,i){return i.relativeTime(t||1,!!e,o,n)}function Hg(o,t,e,n){var i=De(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,Kg.apply(null,h)}function _g(o){return o===void 0?sn:typeof o=="function"?(sn=o,!0):!1}function Ag(o,t){return xn[o]===void 0?!1:t===void 0?xn[o]:(xn[o]=t,o==="s"&&(xn.ss=t-1),!0)}function kg(o,t){if(!this.isValid())return this.localeData().invalidDate();var e=!1,n=xn,i,l;return typeof o=="object"&&(t=o,o=!1),typeof o=="boolean"&&(e=o),typeof t=="object"&&(n=Object.assign({},xn,t),t.s!=null&&t.ss==null&&(n.ss=t.s-1)),i=this.localeData(),l=Hg(this,!e,n,i),e&&(l=i.pastFuture(+this,l)),i.postformat(l)}var fs=Math.abs;function Bn(o){return(o>0)-(o<0)||+o}function qo(){if(!this.isValid())return this.localeData().invalidDate();var o=fs(this._milliseconds)/1e3,t=fs(this._days),e=fs(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=Bn(this._months)!==Bn(a)?"-":"",u=Bn(this._days)!==Bn(a)?"-":"",R=Bn(this._milliseconds)!==Bn(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 Zt=Go.prototype;Zt.isValid=ZR,Zt.abs=mg,Zt.add=pg,Zt.subtract=Cg,Zt.as=Lg,Zt.asMilliseconds=Tl,Zt.asSeconds=Pg,Zt.asMinutes=Eg,Zt.asHours=Mg,Zt.asDays=Og,Zt.asWeeks=Sg,Zt.asMonths=Xg,Zt.asQuarters=Ng,Zt.asYears=Fg,Zt.valueOf=yg,Zt._bubble=Ig,Zt.clone=bg,Zt.get=Dg,Zt.milliseconds=Vg,Zt.seconds=Wg,Zt.minutes=Yg,Zt.hours=Ug,Zt.days=wg,Zt.weeks=vg,Zt.months=Zg,Zt.years=Qg,Zt.humanize=kg,Zt.toISOString=qo,Zt.toString=qo,Zt.toJSON=qo,Zt.locale=el,Zt.localeData=ol,Zt.toIsoString=Me("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",qo),Zt.lang=nl,Tt("X",0,0,"unix"),Tt("x",0,0,"valueOf"),ut("x",Qo),ut("X",Ru),xt("X",function(o,t,e){e._d=new Date(parseFloat(o)*1e3)}),xt("x",function(o,t,e){e._d=new Date(Wt(o))});st.version="2.30.1",Gd(te),st.fn=B,st.min=WR,st.max=YR,st.now=UR,st.utc=He,st.unix=dg,st.months=Rg,st.isDate=eo,st.locale=hn,st.invalid=Vo,st.duration=De,st.isMoment=ye,st.weekdays=gg,st.parseZone=ug,st.localeData=en,st.isDuration=xo,st.monthsShort=hg,st.weekdaysMin=fg,st.defineLocale=os,st.updateLocale=uR,st.locales=RR,st.weekdaysShort=Tg,st.normalizeUnits=Oe,st.relativeTimeRounding=_g,st.relativeTimeThreshold=Ag,st.calendarFormat=lh,st.prototype=B,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 ms{draws;ranges;element;control;options;position;constructor(t,e){const n=e.getDraw();this.draws=n,this.position=n.getPosition(),this.ranges=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e}setElement(t){this.element=t}getElement(){return this.element}getValue(t={}){const e=t.elementList||this.control.getElementList();let{startIndex:n}=t.range||this.control.getRange();const i=this.control.getDraw(),l=t?null:i.getTd();n>=e.length&&(n=e.length-1);const r=e[n],a=[];let c=l,d=e,u=n;for(;;){if(u<0&&c?.linkTdPrevId){const 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=D=>!!(D&&(D.controlComponent===s.ControlComponent.POSTFIX||D.controlComponent===s.ControlComponent.POST_TEXT||D.controlComponent===s.ControlComponent.POSTTEXTFIX||D.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,C=this.control.getDraw();f!==p?C.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 I=l[f];T||d||g?this._removePlaceholdersByControl(l,u,R||null):this._removeControlPlaceholders(l,f);const m=I.type&&!Ce.includes(I.type)||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRE_TEXT?$t(I,["control","controlId","originControlId",...Re]):pe(I,["type"]),P=T||d||g,E=D=>{Re.forEach(O=>{delete D[O];const b=h?.[O];b!==void 0&&(D[O]=b)}),delete D.underline,delete D.textDecoration,h?.type===s.ControlType.TEXT&&D.color?.toLowerCase()==="#87d068"?D.color=this.options.defaultColor:D.color||(D.color=this.options.defaultColor)};P&&E(m),m.controlId=u,h&&(m.control=h),R?m.originControlId=R:delete m.originControlId;const M=this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.inputTraceEnabled,F=i.startIndex+1,y=[],Y=D=>{const O=y.length?y:l,b=y.length?y.length-1:d?i.startIndex+1:i.startIndex;oe(O,[D],b,{editorOptions:this.options}),y.push(D)};for(let D=0;D<t.length;D++){const O=t[D];if(O.type===s.ElementType.CONTROL&&O.control){const b=O,V=b.controlId||ft(),X=b.control?.value||[],N=b.control?.type===s.ControlType.TEXTFIELD,W={...pe(m,["underline","textDecoration"]),controlId:V,type:s.ElementType.CONTROL,control:b.control,originControlId:u},S=N?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,U=N?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,Q=N?b.control?.preTextFix||this.options.control.preTextFix:b.control?.prefix||this.options.control.prefix;for(let w=0;w<Q.length;w++){const q={...W,value:Q[w],controlComponent:S};Y(q)}for(let w=0;w<X.length;w++){const q=X[w],G={...W,...q,controlComponent:s.ControlComponent.VALUE};(G.color===this.options.control.bracketColor||G.color===this.options.control.placeholderColor)&&(G.color=this.options.defaultColor),Y(G)}if(X.length===0){const w=b.control?.placeholder||"";for(let q=0;q<w.length;q++){const G={...W,value:w[q],controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};Y(G)}}const v=N?b.control?.postTextFix||this.options.control.postTextFix:b.control?.postfix||this.options.control.postfix;for(let w=0;w<v.length;w++){const q={...W,value:v[w],controlComponent:U};Y(q)}}else if(O.type||O.value){(I.controlComponent===s.ControlComponent.PRE_TEXT||I.controlComponent===s.ControlComponent.POST_TEXT||I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.POSTFIX)&&(m.color=this.options.defaultColor);const V=pe(O,["control","controlId","controlComponent","originControlId"]),X={...m,...V,controlComponent:s.ControlComponent.VALUE};P&&E(X),(X.color===this.options.control.bracketColor||X.color===this.options.control.placeholderColor||X.color===this.options.control.textFixColor)&&(X.color=this.options.defaultColor),X.strikeout&&delete X.strikeout,M&&(X.textDecoration={style:s.TextDecorationStyle.DOUBLE},X.underline=!0),Y(X)}}return y.length&&C.spliceElementList(l,F,0,y),i.startIndex+y.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=L=>{if(!L)return null;const W=new Set;let S=L,U=null;for(;S&&!W.has(S);){W.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,C=L=>{for(let W=i-1;W>=0;W--){const S=e[W];if(S.controlId===L&&!S.originControlId){if(S.controlComponent===s.ControlComponent.VALUE||S.controlComponent===s.ControlComponent.PLACEHOLDER)return W;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!==L&&S.originControlId!==L)break}return-1},I=(L,W)=>{for(let S=L;S>=0;S--){const U=e[S];if(U.controlId===W&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.PREFIX||U.controlComponent===s.ControlComponent.PRE_TEXT||U.controlComponent===s.ControlComponent.PRETEXTFIX||U.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT))return S;if(U.controlId&&U.controlId!==W&&U.originControlId!==W)break}for(let S=L+1;S<e.length;S++){const U=e[S];if(U.controlId===W&&!U.originControlId&&(U.controlComponent===s.ControlComponent.VALUE||U.controlComponent===s.ControlComponent.PLACEHOLDER||U.controlComponent===s.ControlComponent.POSTFIX||U.controlComponent===s.ControlComponent.POST_TEXT||U.controlComponent===s.ControlComponent.POSTTEXTFIX||U.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return S;if(U.controlId&&U.controlId!==W&&U.originControlId!==W)break}return L},P=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],M=!!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),y=L=>this.options.mode===s.EditorMode.FORM?i:this.control.removeControl(L),Y=r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId&&!!E?.originControlId&&!!u&&h(E.originControlId)===u,D=L=>!!L&&L.controlId===r.controlId&&(L.originControlId||null)===(r.originControlId||null),O=L=>L?.controlComponent===s.ControlComponent.POSTFIX||L?.controlComponent===s.ControlComponent.POST_TEXT||L?.controlComponent===s.ControlComponent.POSTTEXTFIX||L?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT,b=()=>{const L=r.controlId,W=r.originControlId||null;return c.spliceElementList(e,i,1),e.some(U=>U.controlId===L&&(U.originControlId||null)===W&&U.controlComponent===s.ControlComponent.VALUE)||this.control.addPlaceholder(i-1),Math.max(i-1,0)},V=r.controlComponent===s.ControlComponent.VALUE&&!!r.originControlId&&D(E)&&O(E),X=!!u&&!this.control.getIsExistValueByElementListIndex(e,i),N=()=>{if(r.controlComponent!==s.ControlComponent.VALUE)return null;let L=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){L=U;break}}const W=e[L];if(!W||W.strikeout)return null;W.strikeout=!0,W.deletePerson="SWJ",W.deleteTime=st(new Date).format("YYYY-MM-DD HH:mm:ss");let S=Math.max(L-1,0);for(let U=L-1;U>=0;U--){const Q=e[U];if(!(Q.controlId===W.controlId&&(Q.originControlId||null)===(W.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&&X&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return i;if(d&&i===l&&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 W=C(g);return W>=0?W:i}if(i===l&&P&&!(d&&r.controlComponent===s.ControlComponent.VALUE&&!r.originControlId))return y(i);if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!T||p)){if(i===l&&r.controlComponent===s.ControlComponent.VALUE){const W=N();if(W!==null)return W}return r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?i:this.strikeout()}else{if(r.controlComponent===s.ControlComponent.PREFIX||r.controlComponent===s.ControlComponent.PRE_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER)return i;if(i!==l){c.spliceElementList(e,i+1,l-i);const W=e[i+1];return(W?.controlComponent===s.ControlComponent.POSTFIX||W?.controlComponent===s.ControlComponent.POST_TEXT||W?.controlComponent===s.ControlComponent.POSTTEXTFIX||W?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.addPlaceholder(i),i===0&&e[0].type===s.ElementType.SPLIT_TAG?c.fixPosition(!0)??i:i}else{const W=e[i-1],S=e[i+1];return!r.originControlId&&W?.controlId===r.controlId&&W?.originControlId===r.originControlId&&W?.controlComponent===s.ControlComponent.VALUE&&(r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.options.mode!==s.EditorMode.FORM?(c.spliceElementList(e,i-1,1),this.getValue().length||this.control.addPlaceholder(i-2),i-2):O(S)?S.originControlId?V?b():Y?(c.spliceElementList(e,i,1),this.getValue().length||this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):y(i):(c.spliceElementList(e,i,1),this.control.addPlaceholder(i-1),I(Math.max(i-1,0),r.controlId)):(c.spliceElementList(e,i,1),i===1&&e[0].type===s.ElementType.SPLIT_TAG||i===0?c.fixPosition(!0)??i-1:I(Math.max(i-1,0),r.controlId))}}}else if(t.key===s.KeyMap.Delete){if(i===l&&X&&(r.controlComponent===s.ControlComponent.PLACEHOLDER||r.controlComponent===s.ControlComponent.POSTFIX||r.controlComponent===s.ControlComponent.POST_TEXT||r.controlComponent===s.ControlComponent.POSTTEXTFIX||r.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return l;if(i===l&&(M||F)){if(Y){const U=e[l+1];if(U?.controlComponent===s.ControlComponent.VALUE&&U.controlId===r.controlId&&!U.originControlId)return c.spliceElementList(e,l+1,1),this.getValue().length||this.control.addPlaceholder(i),i}return y(l+1)}const L=e[l+1],W=!!r.originControlId;if(this.options.mode===s.EditorMode.FORM&&this.options.modeRule.form.deleteTraceEnabled&&(!W||r.controlComponent===s.ControlComponent.VALUE))return a.controlComponent===s.ControlComponent.POSTFIX||a.controlComponent===s.ControlComponent.POST_TEXT||a.controlComponent===s.ControlComponent.POSTTEXTFIX||a.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||r.controlComponent===s.ControlComponent.PLACEHOLDER?l:L?.controlComponent===s.ControlComponent.POSTFIX||L?.controlComponent===s.ControlComponent.POST_TEXT||L?.controlComponent===s.ControlComponent.POSTTEXTFIX||L?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?L.originControlId?Y?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):y(i+1):(c.spliceElementList(e,i+1,1),this.control.addPlaceholder(i),i):this.strikeout();{const U=e[l+1];return r.controlComponent===s.ControlComponent.PLACEHOLDER?l:U?.controlComponent===s.ControlComponent.POSTFIX||U?.controlComponent===s.ControlComponent.POST_TEXT||U?.controlComponent===s.ControlComponent.POSTTEXTFIX||U?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT?U.originControlId?Y?(c.spliceElementList(e,i+1,1),this.getValue().length||this.control.addPlaceholder(i),i):y(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 C=-1;for(let I=h-1;I>=0;I--){const m=g[I];if(m.controlId===f&&(m.originControlId||null)===p&&m.controlComponent===s.ControlComponent.VALUE)return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:I,reason:"prev-value"}),I;if(p){if(m.controlId&&m.controlId!==f&&m.originControlId!==p)break}else{if(m.controlId===f&&(m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRE_TEXT||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){C=I;break}if(m.controlId&&m.controlId!==f&&!m.originControlId)break;if(m.originControlId===f&&(m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POST_TEXT||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))return this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:I,reason:"nested-postfix"}),I}}if(C>=0){const I=C+1,m=g[I];return m?.controlId===f&&(m.controlComponent===s.ControlComponent.PLACEHOLDER||m.controlComponent===s.ControlComponent.VALUE)?(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:I,reason:"prefix-next-editable"}),I):(this.options.mode===s.EditorMode.FORM&&console.log("[text-prev-trace-index]",{from:h,to:C,reason:"prefix"}),C)}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 fl{draw;options;now;dom;renderOptions;isDatePicker;pickDate;lang;constructor(t,e={}){this.draw=t,this.options=e,this.lang=this._getLang(),this.now=new Date,this.dom=this._createDom(),this.renderOptions=null,this.isDatePicker=!0,this.pickDate=null,this._bindEvent()}_createDom(){const t=document.createElement("div");t.classList.add(`${rt}-date-container`),t.setAttribute(Be,s.EditorComponent.POPUP);const e=document.createElement("div");e.classList.add(`${rt}-date-wrap`);const n=document.createElement("div");n.classList.add(`${rt}-date-title`);const i=document.createElement("span");i.classList.add(`${rt}-date-title__pre-year`),i.innerText="<<";const l=document.createElement("span");l.classList.add(`${rt}-date-title__pre-month`),l.innerText="<";const r=document.createElement("span");r.classList.add(`${rt}-date-title__now`);const a=document.createElement("span");a.classList.add(`${rt}-date-title__next-month`),a.innerText=">";const c=document.createElement("span");c.classList.add(`${rt}-date-title__next-year`),c.innerText=">>",n.append(i),n.append(l),n.append(r),n.append(a),n.append(c);const d=document.createElement("div");d.classList.add(`${rt}-date-week`);const{weeks:{sun:u,mon:R,tue:h,wed:g,thu:T,fri:f,sat:p}}=this.lang;[u,R,h,g,T,f,p].forEach(b=>{const V=document.createElement("span");V.innerText=`${b}`,d.append(V)});const I=document.createElement("div");I.classList.add(`${rt}-date-day`),e.append(n),e.append(d),e.append(I);const m=document.createElement("ul");m.classList.add(`${rt}-time-wrap`);let P,E,M;[this.lang.hour,this.lang.minute,this.lang.second].forEach((b,V)=>{const X=document.createElement("li"),N=document.createElement("span");N.innerText=b,X.append(N);const L=document.createElement("ol"),W=V===0,S=V===1,U=W?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}`),L.append(v)}W?P=L:S?E=L:M=L,X.append(L),m.append(X)});const y=document.createElement("div");y.classList.add(`${rt}-date-menu`);const Y=document.createElement("button");Y.classList.add(`${rt}-date-menu__time`),Y.innerText=this.lang.timeSelect;const D=document.createElement("button");D.classList.add(`${rt}-date-menu__now`),D.innerText=this.lang.now;const O=document.createElement("button");return O.classList.add(`${rt}-date-menu__submit`),O.innerText=this.lang.confirm,y.append(Y),y.append(D),y.append(O),t.append(e),t.append(m),t.append(y),this.draw.getContainer().append(t),{container:t,dateWrap:e,datePickerWeek:d,timeWrap:m,title:{preYear:i,preMonth:l,now:r,nextMonth:a,nextYear:c},day:I,time:{hour:P,minute:E,second:M},menu:{time:Y,now:D,submit:O}}}_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 C=document.createElement("div");C.classList.add("disable"),C.innerText=`${p}`,C.onclick=()=>{const I=d-2;this.now=new Date(c,I,p),this._setDatePick(c,I,p)},this.dom.day.append(C)}for(let p=1;p<=R;p++){const C=document.createElement("div");e===c&&n===d&&i===p&&C.classList.add("active"),this.pickDate&&l===c&&r===d&&a===p&&C.classList.add("select"),C.innerText=`${p}`,C.onclick=I=>{const m=d-1;this.now=new Date(c,m,p),this._setDatePick(c,m,p),I.stopPropagation()},this.dom.day.append(C)}const f=42-h-R;for(let p=1;p<=f;p++){const C=document.createElement("div");C.classList.add("disable"),C.innerText=`${p}`,C.onclick=()=>{this.now=new Date(c,d,p),this._setDatePick(c,d,p)},this.dom.day.append(C)}}_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&&Ds(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 ho{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?$t(d,["control","controlId",...Re]):pe(d,["type"]),R=l.startIndex+1;for(let h=0;h<t.length;h++){const g={...u,...t[h],controlComponent:s.ControlComponent.VALUE};oe(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?$t(r,Xe):$t(i[l.startIndex],Re),c=this.clearSelect(e,{isAddPlaceholder:!1,isIgnoreDeletedRule:n.isIgnoreDeletedRule});if(!~c)return;const d=pe(i[c],Xe),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),oe(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 fl(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 go extends ms{isPopup;inputPopup;constructor(t,e){super(t,e),this.isPopup=!1,this.inputPopup=null}getIsPopup(){return this.isPopup}setValue(t,e={},n={}){if(t.some(P=>!pc(P)||oa.test(P.value)))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange();this.control.shrinkBoundary(e);const r=ct(t),{startIndex:a,endIndex:c}=l,d=i[a];let u=null;for(let P=a;P>=0;P--)if(i[P].controlComponent===s.ControlComponent.PREFIX){u=i[P];break}const R=u?.control||this.element.control;if(this.control.getIsExistValueByElementListIndex(i,a)){let P=a;for(;P>0;){const M=i[P];if(M.controlId!==d.controlId||M.controlComponent===s.ControlComponent.PREFIX||M.controlComponent===s.ControlComponent.PRE_TEXT)break;r.unshift(M),P--}let E=c+1;for(;E<i.length;){const M=i[E];if(M.controlId!==d.controlId||M.controlComponent===s.ControlComponent.POSTFIX||M.controlComponent===s.ControlComponent.POST_TEXT)break;r.push(M),E++}}const h=$s(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 C=Number(h),I=g?.minValue,m=g?.maxValue;return I!=null&&C<I||m!=null&&C>m?-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 C=this.options.mode===s.EditorMode.FORM,I=C&&this.options.modeRule.form.inputTraceEnabled,m=C&&this.options.modeRule.form.deleteTraceEnabled,P=st(new Date).format("YYYY-MM-DD HH:mm:ss");if(m)for(let F=f+1;F<p;F++){const y=e[F];y.controlComponent===s.ControlComponent.VALUE&&!y.strikeout&&y.value&&(y.strikeout=!0,y.deletePerson="SYSTEM",y.deleteTime=P),y.controlComponent===s.ControlComponent.PLACEHOLDER&&(this.control.getDraw().spliceElementList(e,F,1),p--,F--)}else{const F=f+1,y=p-F;y>0&&this.control.getDraw().spliceElementList(e,F,y),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 y={type:s.ElementType.TEXT,value:h[F],controlComponent:s.ControlComponent.VALUE,controlId:e[f].controlId,originControlId:e[f].originControlId,control:e[f].control};I&&(y.textDecoration={style:s.TextDecorationStyle.DOUBLE},y.underline=!0),E.push(y)}for(let F=0;F<E.length;F++)this.control.getDraw().spliceElementList(e,p+F,0,[E[F]]);const M=p+E.length-1;return this.control.getDraw().getRange().setRange(M,M),this.control.emitControlContentChange(),this.control.repaintControl({curIndex:M}),!0}awake(){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl())return;const t=this.control.getElementList(),e=this.control.getRange(),{startIndex:n}=e,i=t[n];if(!i||i.controlId!==this.element.controlId)return;let l=null;for(let 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?$s(c):"",u=r?.numberExclusiveOptions,R=u?.minValue,h=u?.maxValue,g=u?.decimalPlaces;this.inputPopup=new Gg({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 Gg{options;popupDom;constructor(t){this.options=t,this.popupDom=null}create(){const{currentValue:t,minValue:e,maxValue:n,decimalPlaces:i,onConfirm:l,onTab:r,onClose:a}=this.options,c=document.createElement("div");c.classList.add(`${rt}-number-input-modal`),c.setAttribute(Be,s.EditorComponent.POPUP);const d=m=>{if(m.type==="mouseup"){const P=this.options.control.getDraw().getCanvasEvent();P.setIsAllowDrag(!1),P.setIsAllowSelection(!1)}m.stopPropagation()};c.addEventListener("mousedown",d),c.addEventListener("mouseup",d),c.addEventListener("click",d),c.addEventListener("keydown",d),c.addEventListener("input",d);const u=document.createElement("div");u.classList.add(`${rt}-number-input-modal__content`);const R=document.createElement("div");if(R.classList.add(`${rt}-number-input-modal__title`),R.textContent="请输入数值",u.appendChild(R),e!==void 0||n!==void 0){const m=document.createElement("div");m.classList.add(`${rt}-number-input-modal__hint`);let P="有效范围:";e!==void 0&&n!==void 0?P+=`${e} ~ ${n}`:e!==void 0?P+=`≥ ${e}`:P+=`≤ ${n}`,i!=null&&(P+=`,保留${i}位小数`),m.textContent=P,u.appendChild(m)}const h=document.createElement("input");h.classList.add(`${rt}-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(`${rt}-number-input-modal__error`),g.style.display="none",u.appendChild(g);const T=document.createElement("div");T.classList.add(`${rt}-number-input-modal__buttons`);const f=document.createElement("button");f.classList.add(`${rt}-number-input-modal__cancel`),f.textContent="取消",f.onclick=()=>{a()},T.appendChild(f);const p=document.createElement("button");p.classList.add(`${rt}-number-input-modal__confirm`),p.textContent="确定";const C=()=>{const m=h.value.trim();if(!m)return l("");const P=parseFloat(m);return Number.isNaN(P)||!Number.isFinite(P)?(g.textContent="请输入有效的数值",g.style.display="block",!1):i!=null&&(m.split(".")[1]||"").length>i?(g.textContent=`小数位数不能超过${i}位`,g.style.display="block",!1):e!==void 0&&P<e?(g.textContent=`数值不能小于 ${e}`,g.style.display="block",!1):n!==void 0&&P>n?(g.textContent=`数值不能大于 ${n}`,g.style.display="block",!1):(g.style.display="none",l(m))};p.onclick=()=>{C()&&a()},T.appendChild(p),u.appendChild(T),c.appendChild(u),h.onkeydown=m=>{m.key==="Enter"?p.click():m.key==="Tab"?(m.preventDefault(),C()&&(a(),r(m.shiftKey?Jt.UP:Jt.DOWN))):m.key==="Escape"&&a()},this.options.control.getContainer().appendChild(c),this.popupDom=c}destroy(){this.popupDom&&(this.popupDom.remove(),this.popupDom=null)}}class xg{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(Be,s.EditorComponent.COMPONENT),document.body.append(l);const r=document.createElement("div");r.classList.add("dialog-container"),r.setAttribute(Be,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],C=document.createElement("div");if(C.classList.add("dialog-option__item"),p.visible===!1&&(C.style.display="none"),p.label){const I=document.createElement("span");I.append(document.createTextNode(p.label)),C.append(I),p.required&&I.classList.add("dialog-option__item--require")}if(p.type==="radio"){const I=document.createElement("div");I.classList.add("dialog-radio-group"),p.horizontal&&I.classList.add("dialog-radio-group--horizontal"),p.options?.forEach(m=>{const P=document.createElement("label");P.classList.add("dialog-radio-item");const E=document.createElement("input");E.type="radio",E.name=p.name,E.value=m.value,m.value===(p.value||"")&&(E.checked=!0);const M=document.createElement("span");M.textContent=m.label,P.append(E),P.append(M),I.append(P),E.addEventListener("change",()=>{this._updateFieldVisibility()}),this.inputList.push(E)}),C.append(I)}else if(p.type==="select"){const I=document.createElement("select"),m=p.value||"";p.options?.forEach(P=>{const E=document.createElement("option");E.value=P.value,E.label=P.label,P.value===m&&(E.selected=!0),I.append(E)}),I.name=p.name,I.value=m,I.addEventListener("change",()=>{this._updateFieldVisibility()}),p.width&&(I.style.width=`${p.width}px`),C.append(I),this.inputList.push(I)}else if(p.type==="textarea"){const I=document.createElement("textarea");I.name=p.name,I.value=p.value||"",I.placeholder=p.placeholder||"",p.width&&(I.style.width=`${p.width}px`),p.height&&(I.style.height=`${p.height}px`),C.append(I),this.inputList.push(I)}else{const I=document.createElement("input");I.type=p.type,I.name=p.name,I.value=p.value||"",I.placeholder=p.placeholder||"",p.width&&(I.style.width=`${p.width}px`),p.height&&(I.style.height=`${p.height}px`),C.append(I),this.inputList.push(I)}R.append(C),this.optionItemContainers.push(C)}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 C of this.inputList)if(!f.has(C.name))if(C instanceof HTMLInputElement&&C.type==="radio"){const I=this.inputList.find(m=>m.name===C.name&&m instanceof HTMLInputElement&&m.checked);I&&(p.push({name:C.name,value:I.value}),f.add(C.name))}else p.push({name:C.name,value:C.value}),f.add(C.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()}}const Bg=[{label:"无",value:""},{label:"诊断信息",value:"outpatient.diagnosis"}];function Jg(o){if(o==="outpatient.diagnosis")return{key:o,label:"诊断信息",writeTarget:"self",writeMode:"replaceOnConfirm"}}class Sn{draw;element;control;isPopup;datePicker;options;range;static isDeleting=!1;inputModal=null;constructor(t,e){const n=e.getDraw();this.draw=n,this.range=n.getRange(),this.options=n.getOptions(),this.element=t,this.control=e,this.isPopup=!1,this.datePicker=null}setElement(t){this.element=t}getElement(){return this.element}getIsPopup(){return this.isPopup}getValue(t={}){const e=t.elementList||this.control.getElementList(),n=this.control.getValueRange(t);if(!n)return[];const i=[],{startIndex:l,endIndex:r}=n;for(let a=l;a<=r;a++){const c=e[a];c.controlComponent===s.ControlComponent.VALUE&&i.push(c)}return i}setValue(t,e={},n={}){if(!n.isIgnoreDisabledRule&&(this.control.getIsDisabledControl(e)||this.element.control?.editable===!1))return-1;const i=e.elementList||this.control.getElementList(),l=e.range||this.control.getRange(),r=this.control.getDraw(),{startIndex:a,endIndex:c}=l,d=i[a],u=this.element.controlId||d.controlId,R=this.element.originControlId||d.originControlId||null;if(!u)return-1;const h=E=>!!E&&E.controlId===u&&(E.originControlId||null)===R;let g=a;for(;g>0&&h(i[g])&&i[g].controlComponent!==s.ControlComponent.PREFIX;)g--;let T=a;for(;T<i.length&&h(i[T])&&i[T].controlComponent!==s.ControlComponent.POSTFIX;)T++;T>=i.length&&(T=a);let f=a+1,p=c-a,C=d.controlComponent===s.ControlComponent.POSTFIX?a:a+1;a===c&&(p=0,d.controlComponent===s.ControlComponent.PREFIX?C=g+1:d.controlComponent===s.ControlComponent.POSTFIX&&(C=T),f=C),p>0&&(r.spliceElementList(i,f,p),C=f);const I=i[Math.max(C-1,g)]||i[g]||d,m=$t(I,["control","controlId","originControlId",...Re]);m.control=this.element.control||d.control,m.controlId=u,R?m.originControlId=R:delete m.originControlId;const P=[];for(let E=0;E<t.length;E++){const M={...m,...t[E],type:s.ElementType.CONTROL,controlComponent:s.ControlComponent.VALUE};M.color=this.options.defaultColor,M.highlight=void 0,oe(i,[M],C+E-1,{editorOptions:this.options}),P.push(M)}return P.length?r.spliceElementList(i,C,0,P):this.control.addPlaceholder(Math.max(C-1,0),e),this.syncControlValue(i,u,R),C+t.length-1}syncControlValue(t,e,n){const i=t.filter(r=>r.controlId===e&&(r.originControlId||null)===n&&r.controlComponent===s.ControlComponent.VALUE).map(r=>{const a={value:r.value||""};return["color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"].forEach(d=>{const u=r[d];u!==void 0&&(a[d]=u)}),a}),l=i.length?i:null;t.forEach(r=>{r.controlId===e&&(r.originControlId||null)===n&&r.control&&(r.control.value=l?ct(l):null)})}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()||this.element.control?.editable===!1)return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{endIndex:i}=n,l=e[i],r=this.element.controlId||l?.controlId,a=this.element.originControlId||l?.originControlId||null,c=R=>!!R&&R.controlId===r&&(R.originControlId||null)===a;if(!!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))return this.control.removeControl(i);if(!r)return null;const u=R=>(this.draw.spliceElementList(e,R,1),this.syncControlValue(e,r,a),e.some(g=>g.controlId===r&&(g.originControlId||null)===a&&g.controlComponent===s.ControlComponent.VALUE)||this.control.addPlaceholder(Math.max(R-1,0)),Math.max(R-1,0));if(t.key===s.KeyMap.Backspace){if(l?.controlComponent===s.ControlComponent.VALUE&&c(l))return u(i);if(l?.controlComponent===s.ControlComponent.POSTFIX&&c(l)){const R=e[i-1];if(R?.controlComponent===s.ControlComponent.VALUE&&c(R))return u(i-1)}return i}if(t.key===s.KeyMap.Delete){const R=e[i+1];return R?.controlComponent===s.ControlComponent.VALUE&&c(R)?u(i+1):l?.controlComponent===s.ControlComponent.VALUE&&c(l)?u(i):i}return null}removeByValue(t,e){return Sn.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(()=>{Sn.isDeleting=!1},300),n(!0)})}cut(){if(this.control.getIsDisabledControl()||this.element.control?.editable===!1)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.syncControlValue(i,this.element.controlId||i[t]?.controlId||"",this.element.originControlId||i[t]?.originControlId||null),this.control.addPlaceholder(t),t}awake(t){if(this.isPopup||this.control.getIsDisabledControl()||!this.control.getIsRangeWithinControl()||Sn.isDeleting||!this.control.getPosition())return;const n=this.draw.getElementList(),{startIndex:i}=this.control.getRange();if(n[i]?.controlId!==this.element?.controlId)return;const l=this.control.getDraw().getPosition().getPositionContext();if(!l.isDirectHit||l.index!==i||n[l.index]?.controlId!==this.element?.controlId)return;const r=n[i]?.controlId,a=n[i]?.control;if(r?.endsWith("_text")||a?.buttonText)return;const c=n[i].controlId;if(!c)return;const d=n.filter(R=>R.controlId===c),u=d[0];if(u?.control&&this.options.mode!="form"&&this.options.mode=="edit"){const R=this.draw.getEventBus();if(t&&R.isSubscribe("buttonClick")){const h={evt:t,element:ct(u),elementList:ct(d),controlId:c,control:ct(u.control)};R.emit("buttonClick",h)}this.showEditModal(d)}}closeInputModal(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}syncButtonPlaceholderElements(t,e){const n=this.control.getElementList(),i=[];let l=null,r=-1,a=!1;if(n.forEach((u,R)=>{u.controlId!==t||u.control?.type!==s.ControlType.BUTTON||(u.control.placeholder=e,l||=u,u.controlComponent===s.ControlComponent.VALUE&&(a=!0),u.controlComponent===s.ControlComponent.PLACEHOLDER&&i.push({element:u,index:R}),r===-1&&u.controlComponent===s.ControlComponent.POSTFIX&&(r=R))}),!l)return;const c=i.length?Math.min(...i.map(u=>u.index)):r;i.length&&i.sort((u,R)=>R.index-u.index).forEach(u=>{n.splice(u.index,1)});const d=yt(e);!d.length||a&&!i.length||c<0||d.forEach((u,R)=>{const h={...$t(l,[...Re,...ue]),value:u===`
119
119
  `?K:u,controlId:t,type:s.ElementType.CONTROL,control:l.control,controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor,hide:a};oe(n,[h],c-1+R,{editorOptions:this.options}),n.splice(c+R,0,h)})}showEditModal(t){const e=t[0]?.control||{},n=e.buttonLabel||e.label||"事件",i=e.code||"",l=e.action?.key||"",r=e.editable!==!1?"true":"false";this.isPopup=!0,new xg({title:"修改事件控件属性",data:[{type:"text",label:"显示文本",name:"buttonLabel",required:!0,placeholder:"请输入显示文本",value:n},{type:"text",label:"事件代码",name:"code",placeholder:"请输入事件代码",value:i},{type:"select",label:"执行事件",name:"actionKey",options:Bg,value:l},{type:"radio",label:"是否可编辑",name:"editable",options:[{label:"是",value:"true"},{label:"否",value:"false"}],value:r,horizontal:!0}],onClose:()=>{this.isPopup=!1},onCancel:()=>{this.isPopup=!1},onConfirm:a=>{const c=a.find(f=>f.name==="buttonLabel")?.value?.trim()||"事件",d=a.find(f=>f.name==="code")?.value?.trim()||"",u=a.find(f=>f.name==="actionKey")?.value||"",R=Jg(u),h=a.find(f=>f.name==="editable")?.value!=="false",g=this.control.getElementList(),T=t[0]?.controlId;if(T){for(let f=0;f<g.length;f++){const p=g[f];p.controlId===T&&p.control&&(p.control.buttonLabel=c,p.control.label=c,p.control.placeholder=c,p.control.code=d,p.control.editable=h,R?p.control.action=R:delete p.control.action)}this.syncButtonPlaceholderElements(T,c)}this.draw.render({curIndex:this.control.getRange().endIndex,isSubmitHistory:!0}),this.isPopup=!1}})}destroy(){this.inputModal&&this.closeInputModal(),this.isPopup&&(this.datePicker?.destroy(),this.isPopup=!1)}}class ml{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 C=r;C>=0;C--){const I=i[C];if(I.controlId===d.controlId&&(I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let m=C-1;m>=0;m--){const P=i[m];if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===s.ControlComponent.PRETEXTFIX||P.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===s.ControlComponent.PREFIX||P.controlComponent===s.ControlComponent.PRE_TEXT)){R=P.controlId,h=!0;break}if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===s.ControlComponent.POSTFIX||P.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 C=r;C>=0;C--){const I=i[C];if(I.controlId===d.controlId&&(I.controlComponent===s.ControlComponent.PREFIX||I.controlComponent===s.ControlComponent.PRETEXTFIX)){for(let m=C-1;m>=0;m--){const P=i[m];if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===s.ControlComponent.PRETEXTFIX||P.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||P.controlComponent===s.ControlComponent.PREFIX||P.controlComponent===s.ControlComponent.PRE_TEXT)){R=P.controlId,h=!0;break}if(P.controlId&&P.controlId!==d.controlId&&(P.controlComponent===s.ControlComponent.POSTFIX||P.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?$t(d,["control","controlId",...Re]):pe(d,["type"]);h&&(g.controlId=R,delete g.originControlId);const T=l.startIndex+1,f=[],p=C=>{const I=f.length?f:i,m=f.length?f.length-1:l.startIndex;oe(I,[C],m,{editorOptions:this.options}),f.push(C)};for(let C=0;C<t.length;C++){const I=t[C];if(I.type===s.ElementType.CONTROL&&I.control){const m=I,P=m.controlId||ft(),E=m.control?.value||[],M=m.control?.type===s.ControlType.TEXTFIELD,F={...g,controlId:P,type:s.ElementType.CONTROL,control:m.control,originControlId:R},y=M?s.ControlComponent.PRETEXTFIX:s.ControlComponent.PREFIX,Y=M?s.ControlComponent.POSTTEXTFIX:s.ControlComponent.POSTFIX,D=M?m.control?.preTextFix||this.options.control.preTextFix:m.control?.prefix||this.options.control.prefix;for(let b=0;b<D.length;b++){const V={...F,value:D[b],controlComponent:y};p(V)}for(let b=0;b<E.length;b++){const V=E[b],X={...F,...V,controlComponent:s.ControlComponent.VALUE,type:V.type};(X.color===this.options.control.textFixColor||X.color===this.options.control.placeholderColor)&&(X.color=this.options.defaultColor),p(X)}if(E.length===0){const b=m.control?.placeholder||"";for(let V=0;V<b.length;V++){const X={...F,value:b[V],controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor};p(X)}}const O=M?m.control?.postTextFix||this.options.control.postTextFix:m.control?.postfix||this.options.control.postfix;for(let b=0;b<O.length;b++){const V={...F,value:O[b],controlComponent:Y};p(V)}}else if(I.type||I.value){g.color=this.options.defaultColor;const m={...g,...I,controlComponent:s.ControlComponent.VALUE};h&&(m.color=this.element.control?.color??this.options.defaultColor,this.element.control?.highlight?m.highlight=this.element.control.highlight:delete m.highlight),(m.color===this.options.control.textFixColor||m.color===this.options.control.placeholderColor)&&(m.color=this.options.defaultColor),p(m)}}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],C=p?.controlComponent===s.ControlComponent.POSTFIX||p?.controlComponent===s.ControlComponent.POSTTEXTFIX,I=p?.controlComponent===s.ControlComponent.PLACEHOLDER,m=!!p?.controlId,E=this.draws.getPosition().getPositionList(),M=E[i],F=E[i-1],y=M&&F&&M.rowIndex===F.rowIndex;if((C||I)&&m&&y)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(I=>I.controlComponent===s.ControlComponent.POSTTEXTFIX||I.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 $g={indent:"        ",divider:"────────────────"};class pl{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 C=a;C>=0;C--){const I=i[C];if(I.controlId!==d)break;if(I.controlComponent===s.ControlComponent.PREFIX){u=C;break}}let R=a;for(let C=a;C<i.length;C++){const I=i[C];if(I.controlId!==d){R=C;break}if(I.controlComponent===s.ControlComponent.POSTFIX){R=C;break}}const h=u+1,g=R-1;g>=h&&r.spliceElementList(i,h,g-h+1);const T=i[u],f=$t(T,["control","controlId",...Re]),p=u+1;for(let C=0;C<t.length;C++){const I={...f,...t[C],value:t[C].value===`
120
120
  `?K:t[C].value,controlComponent:s.ControlComponent.VALUE};(I.color===this.options.control.bracketColor||I.color===this.options.control.placeholderColor)&&(I.color=this.options.defaultColor),oe(i,[I],u,{editorOptions:this.options}),r.spliceElementList(i,p+C,0,[I])}return p+t.length-1}keydown(t){if(this.control.getIsDisabledControl()||this.options.mode===s.EditorMode.FORM)return null;const e=this.control.getElementList(),n=this.control.getRange();this.control.shrinkBoundary();const{startIndex:i}=n,l=e[i];if(t.key===s.KeyMap.Backspace||t.key===s.KeyMap.Delete){const r=l.controlId;let a=i,c=i;for(;a>0&&e[a-1].controlId===r;)a--;for(;c<e.length-1&&e[c+1].controlId===r;)c++;return this.draw.spliceElementList(e,a,c-a+1),a>0?a-1:0}return null}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.options.mode===s.EditorMode.PRINT||this.options.mode===s.EditorMode.COMPARE||this.isPopup||this.control.getIsDisabledControl())return;let t=!1;const e=this.control.getElementList(),n=this.element.controlId;for(let i=0;i<e.length;i++){const l=e[i];l.controlId===n&&l.control&&l.control._justCreated&&(t=!0,delete l.control._justCreated)}t||this.showMenstrualHistoryDialog()}generateDisplayText(t){const{indent:e,divider:n}=$g,{isMenopause:i,periodMin:l,periodMax:r,menarcheAge:a,cycleMin:c,cycleMax:d}=t,u=`${e}月经持续${l}~${r}天`,R=`${e}生理周期持续${c}~${d}天${K}`;let h;return i?h=`初潮年龄${a}岁${n}闭经年龄${t.menopauseAge||"_"}岁`:h=`初潮年龄${a}岁${n}末次日期${t.lastPeriod||"____-__-__"}`,`${K} ${u}
121
121
  ${h}
@@ -319,7 +319,7 @@ ${R} `}textToElements(t){const e=[],n=t.split(`
319
319
  <button class="btn-confirm">确认</button>
320
320
  </div>
321
321
  </div>
322
- `,document.body.appendChild(this.inputModal);const i=this.inputModal.querySelector(".fetal-heart-position-modal__mask"),l=this.inputModal.querySelector(".fetal-heart-position-modal__container"),r=this.inputModal.querySelector(".fetal-heart-position-modal__close"),a=this.inputModal.querySelector(".btn-cancel"),c=this.inputModal.querySelector(".btn-confirm"),d=()=>{this.clearFetalHeartPositionEditor()};l.addEventListener("click",u=>{u.stopPropagation()}),i.addEventListener("click",d),r.addEventListener("click",d),a.addEventListener("click",d),c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation();const R=this.inputModal;if(!R)return;const h={a:R.querySelector("#fh-a")?.checked||!1,b:R.querySelector("#fh-b")?.checked||!1,c:R.querySelector("#fh-c")?.checked||!1,d:R.querySelector("#fh-d")?.checked||!1,e:R.querySelector("#fh-e")?.checked||!1,f:R.querySelector("#fh-f")?.checked||!1};this.clearFetalHeartPositionEditor();const g=this.draw.getElementList(),T=e.index;this.draw.spliceElementList(g,T,1);const f={type:"fetalHeartPosition",value:"",fetalHeartData:h};this.draw.spliceElementList(g,T,0,[f]),this.draw.getControl().destroyControl(),this.draw.getRange().clearRange(),this.draw.render({isSetCursor:!1,isCompute:!0})})}}const rn={fontSize:12,deciduousFontSize:10,smallFontSize:9,totalHeight:60,toothGap:2,halfGap:8,minLineHalfWidth:50,maxLineHalfWidth:85},Ll=["La","B","F","M","I","D","L","P"];class rT{draw;options;inputModal=null;isPopup=!1;finallyAdd=null;toothSurfaceMap={};supernumeraryToothMap={};constructor(t){this.draw=t,this.options=t.getOptions()}computeSize(t){const e=rn,n=this.options.scale,i=t.toothPositionData,r=this.calculateLineHalfWidth(i,n)*2;return{width:Math.min(r,this.draw.getInnerWidth()),height:e.totalHeight*n}}calculateLineHalfWidth(t,e){const{minLineHalfWidth:n,maxLineHalfWidth:i,fontSize:l,deciduousFontSize:r,smallFontSize:a,toothGap:c}=rn,d=(f,p,C)=>{let I=0;const m=(P,E)=>`${P}-${E}`;return p.forEach(P=>{const E=m(C,P),M=t?.toothSurfaceMap?.[E]||[],F=t?.supernumeraryToothMap?.[E];I+=r*e*.6,M.length>0&&(I+=a*e*M.length*.5),F&&(I+=r*e*.4),I+=c*e}),f.forEach(P=>{const E=m(C,P),M=t?.toothSurfaceMap?.[E]||[],F=t?.supernumeraryToothMap?.[E];I+=l*e*.6,M.length>0&&(I+=a*e*M.length*.5),F&&(I+=l*e*.4),I+=c*e}),I},u=Math.max(d(t?.upperLeft||[],t?.upperLeftLetter||[],"upperLeft"),d(t?.lowerLeft||[],t?.lowerLeftLetter||[],"lowerLeft")),R=Math.max(d(t?.upperRight||[],t?.upperRightLetter||[],"upperRight"),d(t?.lowerRight||[],t?.lowerRightLetter||[],"lowerRight")),g=Math.max(u,R)/e+rn.halfGap;return Math.max(n,Math.min(i,g))*e}render(t){const{ctx:e,x:n,y:i,element:l}=t,r=l.toothPositionData,a=this.options.scale;e.save();const c=rn.fontSize*a,d=rn.deciduousFontSize*a,u=rn.smallFontSize*a,R=rn.toothGap*a,h=rn.totalHeight*a,g=rn.halfGap*a,T=2*a,f=(M,F)=>`${M}-${F}`,p=this.calculateLineHalfWidth(r,a),C=p*2,I=n+p,m=i;e.beginPath(),e.rect(I-p,m-h/2,C,h),e.clip(),e.beginPath(),e.strokeStyle=this.options.defaultColor,e.lineWidth=1*a,e.moveTo(I,m-h/2+10*a),e.lineTo(I,m+h/2-10*a),e.stroke(),e.beginPath(),e.moveTo(I-p,m),e.lineTo(I+p,m),e.stroke();const P=(M,F,y,Y,D)=>{const O=f(M,F),b=r?.toothSurfaceMap?.[O]||[],V=Ll.filter(U=>b.includes(U)),X=r?.supernumeraryToothMap?.[O],N=F.toString(),W=typeof F=="string"?d:c;e.font=`${W}px "Microsoft YaHei", sans-serif`,e.textBaseline="middle";let S=y;if(X){e.font=`${W}px "Microsoft YaHei", sans-serif`;const w=e.measureText("(").width,q=e.measureText(N).width;e.font=`${u}px "Microsoft YaHei", sans-serif`;const G=e.measureText("S").width;let H=w+q+w;H+=G+T;let z=0,_="";return V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,_=V.join(","),z=e.measureText(_).width+T/2),D==="right"?(S=y-H,V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText(_,S-z-T/2,Y-W*.4)),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.textAlign="left",e.fillStyle=this.options.defaultColor,e.fillText("(",S,Y),S+=w,e.font=`${u}px "Microsoft YaHei", sans-serif`,X==="Si"&&(e.fillText("S",S,Y-W*.4),S+=G+T),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.fillText(N,S,Y),S+=q,X==="iS"&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText("S",S,Y-W*.4),S+=G),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.fillText(")",S,Y),y-H-z-R):(e.font=`${W}px "Microsoft YaHei", sans-serif`,e.textAlign="left",e.fillStyle=this.options.defaultColor,e.fillText("(",S,Y),S+=w,e.font=`${u}px "Microsoft YaHei", sans-serif`,X==="Si"&&(e.fillText("S",S,Y-W*.4),S+=G+T),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.fillText(N,S,Y),S+=q,X==="iS"&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText("S",S,Y-W*.4),S+=G),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.fillText(")",S,Y),S+=w,V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText(_,S+T/2,Y-W*.4),S+=z),S+R)}else{e.font=`${W}px "Microsoft YaHei", sans-serif`;const U=e.measureText(N).width;let v=0,Q="";return V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,Q=V.join(","),v=e.measureText(Q).width+T/2,e.font=`${W}px "Microsoft YaHei", sans-serif`),D==="right"?(S=y-U,V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText(Q,S-v-T/2,Y-W*.4),e.font=`${W}px "Microsoft YaHei", sans-serif`),e.textAlign="left",e.fillStyle=this.options.defaultColor,e.fillText(N,S,Y),y-U-v-R):(e.textAlign="left",e.fillStyle=this.options.defaultColor,e.fillText(N,S,Y),S+=U,V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText(Q,S+T/2,Y-W*.4),S+=v),S+R)}},E=(M,F,y,Y,D,O)=>{let b=Y;O==="right"?([...F].reverse().forEach(N=>{b=P(y,N,b,D,O)}),[...M].reverse().forEach(N=>{b=P(y,N,b,D,O)})):(F.forEach(V=>{b=P(y,V,b,D,O)}),M.forEach(V=>{b=P(y,V,b,D,O)}))};E(r?.upperLeft||[],r?.upperLeftLetter||[],"upperLeft",I-g,m-h/4,"right"),E(r?.upperRight||[],r?.upperRightLetter||[],"upperRight",I+g,m-h/4,"left"),E(r?.lowerLeft||[],r?.lowerLeftLetter||[],"lowerLeft",I-g,m+h/4,"right"),E(r?.lowerRight||[],r?.lowerRightLetter||[],"lowerRight",I+g,m+h/4,"left"),e.restore()}clearToothPositionEditor(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}renderToothPositionEditor(t,e){if(this.options.mode===s.EditorMode.PRINT||this.options.mode===s.EditorMode.COMPARE)return;(this.isPopup||this.inputModal)&&this.clearToothPositionEditor(),this.isPopup=!0,this.finallyAdd=null,this.toothSurfaceMap={},this.supernumeraryToothMap={};const n=t.toothPositionData;this.inputModal=document.createElement("div"),this.inputModal.className="tooth-position-edit-modal",this.inputModal.setAttribute("editor-component","tooth-position-edit-modal"),this.inputModal.innerHTML=`
322
+ `,document.body.appendChild(this.inputModal);const i=this.inputModal.querySelector(".fetal-heart-position-modal__mask"),l=this.inputModal.querySelector(".fetal-heart-position-modal__container"),r=this.inputModal.querySelector(".fetal-heart-position-modal__close"),a=this.inputModal.querySelector(".btn-cancel"),c=this.inputModal.querySelector(".btn-confirm"),d=()=>{this.clearFetalHeartPositionEditor()};l.addEventListener("click",u=>{u.stopPropagation()}),i.addEventListener("click",d),r.addEventListener("click",d),a.addEventListener("click",d),c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation();const R=this.inputModal;if(!R)return;const h={a:R.querySelector("#fh-a")?.checked||!1,b:R.querySelector("#fh-b")?.checked||!1,c:R.querySelector("#fh-c")?.checked||!1,d:R.querySelector("#fh-d")?.checked||!1,e:R.querySelector("#fh-e")?.checked||!1,f:R.querySelector("#fh-f")?.checked||!1};this.clearFetalHeartPositionEditor();const g=this.draw.getElementList(),T=e.index;this.draw.spliceElementList(g,T,1);const f={type:"fetalHeartPosition",value:"",fetalHeartData:h};this.draw.spliceElementList(g,T,0,[f]),this.draw.getControl().destroyControl(),this.draw.getRange().clearRange(),this.draw.render({isSetCursor:!1,isCompute:!0})})}}const rn={fontSize:12,deciduousFontSize:10,smallFontSize:9,totalHeight:60,toothGap:2,halfGap:8,minLineHalfWidth:50,maxLineHalfWidth:85},Ll=["La","B","F","M","I","D","L","P"];class rT{draw;options;inputModal=null;isPopup=!1;finallyAdd=null;toothSurfaceMap={};supernumeraryToothMap={};constructor(t){this.draw=t,this.options=t.getOptions()}computeSize(t){const e=rn,n=this.options.scale,i=t.toothPositionData,r=this.calculateLineHalfWidth(i,n)*2;return{width:Math.min(r,this.draw.getInnerWidth()),height:e.totalHeight*n}}calculateLineHalfWidth(t,e){const{minLineHalfWidth:n,maxLineHalfWidth:i,fontSize:l,deciduousFontSize:r,smallFontSize:a,toothGap:c}=rn,d=(f,p,C)=>{let I=0;const m=(P,E)=>`${P}-${E}`;return p.forEach(P=>{const E=m(C,P),M=t?.toothSurfaceMap?.[E]||[],F=t?.supernumeraryToothMap?.[E];I+=r*e*.6,M.length>0&&(I+=a*e*M.length*.5),F&&(I+=r*e*.4),I+=c*e}),f.forEach(P=>{const E=m(C,P),M=t?.toothSurfaceMap?.[E]||[],F=t?.supernumeraryToothMap?.[E];I+=l*e*.6,M.length>0&&(I+=a*e*M.length*.5),F&&(I+=l*e*.4),I+=c*e}),I},u=Math.max(d(t?.upperLeft||[],t?.upperLeftLetter||[],"upperLeft"),d(t?.lowerLeft||[],t?.lowerLeftLetter||[],"lowerLeft")),R=Math.max(d(t?.upperRight||[],t?.upperRightLetter||[],"upperRight"),d(t?.lowerRight||[],t?.lowerRightLetter||[],"lowerRight")),g=Math.max(u,R)/e+rn.halfGap;return Math.max(n,Math.min(i,g))*e}render(t){const{ctx:e,x:n,y:i,element:l}=t,r=l.toothPositionData,a=this.options.scale;e.save();const c=rn.fontSize*a,d=rn.deciduousFontSize*a,u=rn.smallFontSize*a,R=rn.toothGap*a,h=rn.totalHeight*a,g=rn.halfGap*a,T=2*a,f=(M,F)=>`${M}-${F}`,p=this.calculateLineHalfWidth(r,a),C=p*2,I=n+p,m=i;e.beginPath(),e.rect(I-p,m-h/2,C,h),e.clip(),e.beginPath(),e.strokeStyle=this.options.defaultColor,e.lineWidth=1*a,e.moveTo(I,m-h/2+10*a),e.lineTo(I,m+h/2-10*a),e.stroke(),e.beginPath(),e.moveTo(I-p,m),e.lineTo(I+p,m),e.stroke();const P=(M,F,y,Y,D)=>{const O=f(M,F),b=r?.toothSurfaceMap?.[O]||[],V=Ll.filter(U=>b.includes(U)),X=r?.supernumeraryToothMap?.[O],N=F.toString(),W=typeof F=="string"?d:c;e.font=`${W}px "Microsoft YaHei", sans-serif`,e.textBaseline="middle";let S=y;if(X){e.font=`${W}px "Microsoft YaHei", sans-serif`;const w=e.measureText("(").width,q=e.measureText(N).width;e.font=`${u}px "Microsoft YaHei", sans-serif`;const G=e.measureText("S").width;let H=w+q+w;H+=G+T;let z=0,_="";return V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,_=V.join(","),z=e.measureText(_).width+T/2),D==="right"?(S=y-H,V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText(_,S-z-T/2,Y-W*.4)),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.textAlign="left",e.fillStyle=this.options.defaultColor,e.fillText("(",S,Y),S+=w,e.font=`${u}px "Microsoft YaHei", sans-serif`,X==="Si"&&(e.fillText("S",S,Y-W*.4),S+=G+T),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.fillText(N,S,Y),S+=q,X==="iS"&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText("S",S,Y-W*.4),S+=G),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.fillText(")",S,Y),y-H-z-R):(e.font=`${W}px "Microsoft YaHei", sans-serif`,e.textAlign="left",e.fillStyle=this.options.defaultColor,e.fillText("(",S,Y),S+=w,e.font=`${u}px "Microsoft YaHei", sans-serif`,X==="Si"&&(e.fillText("S",S,Y-W*.4),S+=G+T),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.fillText(N,S,Y),S+=q,X==="iS"&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText("S",S,Y-W*.4),S+=G),e.font=`${W}px "Microsoft YaHei", sans-serif`,e.fillText(")",S,Y),S+=w,V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText(_,S+T/2,Y-W*.4),S+=z),S+R)}else{e.font=`${W}px "Microsoft YaHei", sans-serif`;const U=e.measureText(N).width;let Q=0,v="";return V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,v=V.join(","),Q=e.measureText(v).width+T/2,e.font=`${W}px "Microsoft YaHei", sans-serif`),D==="right"?(S=y-U,V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText(v,S-Q-T/2,Y-W*.4),e.font=`${W}px "Microsoft YaHei", sans-serif`),e.textAlign="left",e.fillStyle=this.options.defaultColor,e.fillText(N,S,Y),y-U-Q-R):(e.textAlign="left",e.fillStyle=this.options.defaultColor,e.fillText(N,S,Y),S+=U,V.length>0&&(e.font=`${u}px "Microsoft YaHei", sans-serif`,e.fillText(v,S+T/2,Y-W*.4),S+=Q),S+R)}},E=(M,F,y,Y,D,O)=>{let b=Y;O==="right"?([...F].reverse().forEach(N=>{b=P(y,N,b,D,O)}),[...M].reverse().forEach(N=>{b=P(y,N,b,D,O)})):(F.forEach(V=>{b=P(y,V,b,D,O)}),M.forEach(V=>{b=P(y,V,b,D,O)}))};E(r?.upperLeft||[],r?.upperLeftLetter||[],"upperLeft",I-g,m-h/4,"right"),E(r?.upperRight||[],r?.upperRightLetter||[],"upperRight",I+g,m-h/4,"left"),E(r?.lowerLeft||[],r?.lowerLeftLetter||[],"lowerLeft",I-g,m+h/4,"right"),E(r?.lowerRight||[],r?.lowerRightLetter||[],"lowerRight",I+g,m+h/4,"left"),e.restore()}clearToothPositionEditor(){this.inputModal&&(this.inputModal.remove(),this.inputModal=null),this.isPopup=!1}renderToothPositionEditor(t,e){if(this.options.mode===s.EditorMode.PRINT||this.options.mode===s.EditorMode.COMPARE)return;(this.isPopup||this.inputModal)&&this.clearToothPositionEditor(),this.isPopup=!0,this.finallyAdd=null,this.toothSurfaceMap={},this.supernumeraryToothMap={};const n=t.toothPositionData;this.inputModal=document.createElement("div"),this.inputModal.className="tooth-position-edit-modal",this.inputModal.setAttribute("editor-component","tooth-position-edit-modal"),this.inputModal.innerHTML=`
323
323
  <div class="tooth-position-modal__mask"></div>
324
324
  <div class="tooth-position-modal__container">
325
325
  <div class="tooth-position-modal__header">
@@ -520,7 +520,7 @@ ${R} `}textToElements(t){const e=[],n=t.split(`
520
520
  ${m}
521
521
  </span>`},l=(u,R,h)=>{const g=[];return R.forEach(T=>{g.push(i(h,T))}),u.forEach(T=>{g.push(i(h,T))}),g.join(" ")},r=e.querySelector(".tooth-preview-upper-left"),a=e.querySelector(".tooth-preview-upper-right"),c=e.querySelector(".tooth-preview-lower-left"),d=e.querySelector(".tooth-preview-lower-right");r&&(r.innerHTML=l(t?.upperLeft||[],t?.upperLeftLetter||[],"upperLeft")),a&&(a.innerHTML=l(t?.upperRight||[],t?.upperRightLetter||[],"upperRight")),c&&(c.innerHTML=l(t?.lowerLeft||[],t?.lowerLeftLetter||[],"lowerLeft")),d&&(d.innerHTML=l(t?.lowerRight||[],t?.lowerRightLetter||[],"lowerRight"))}bindExtraPanelEvents(){const t=this.inputModal;if(!t)return;t.querySelectorAll(".tooth-surface-item").forEach(i=>{i.addEventListener("click",()=>{if(!this.finallyAdd)return;const l=i.dataset.surface;if(!l)return;const r=`${this.finallyAdd.position}-${this.finallyAdd.value}`;this.toothSurfaceMap[r]||(this.toothSurfaceMap[r]=[]);const a=this.toothSurfaceMap[r],c=a.indexOf(l);c>-1?(a.splice(c,1),i.classList.remove("selected")):(a.push(l),i.classList.add("selected")),this.updatePreview()})}),t.querySelectorAll(".tooth-supernumerary-item").forEach(i=>{i.addEventListener("click",()=>{if(!this.finallyAdd)return;const l=i.dataset.supernumerary;if(!l)return;const r=`${this.finallyAdd.position}-${this.finallyAdd.value}`;this.supernumeraryToothMap[r]===l?(delete this.supernumeraryToothMap[r],i.classList.remove("selected")):(t.querySelectorAll(".tooth-supernumerary-item").forEach(a=>a.classList.remove("selected")),this.supernumeraryToothMap[r]=l,i.classList.add("selected")),this.updatePreview()})}),this.updateExtraPanelSelection()}updateExtraPanelSelection(){const t=this.inputModal;if(!t||!this.finallyAdd)return;const e=`${this.finallyAdd.position}-${this.finallyAdd.value}`,n=this.toothSurfaceMap[e]||[];t.querySelectorAll(".tooth-surface-item").forEach(l=>{const r=l.dataset.surface;n.includes(r||"")?l.classList.add("selected"):l.classList.remove("selected")});const i=this.supernumeraryToothMap[e];t.querySelectorAll(".tooth-supernumerary-item").forEach(l=>{l.dataset.supernumerary===i?l.classList.add("selected"):l.classList.remove("selected")})}}const Pl='(function(){"use strict";function f(i){let s="",n=0;for(;n<i.length;){const t=i[n];if(t.type==="table"){if(t.trList)for(let l=0;l<t.trList.length;l++){const o=t.trList[l];for(let e=0;e<o.tdList.length;e++){const r=o.tdList[e];s+=f(r.value)}}}else if(t.type==="hyperlink"){const l=t.hyperlinkId,o=[];for(;n<i.length;){const e=i[n];if(l!==e.hyperlinkId){n--;break}delete e.type,o.push(e),n++}s+=f(o)}else if(t.controlId){if(!t.control?.hide){const l=t.controlId,o=[];for(;n<i.length;){const e=i[n];if(l!==e.controlId){n--;break}e.controlComponent==="value"&&(delete e.controlId,o.push(e)),n++}s+=f(o)}}else(!t.type||t.type==="text")&&!t.area?.hide&&(s+=t.value);n++}return s}function p(i){const s=[],n=/[0-9]/,t=/[A-Za-z]/,l=/\\s/;let o=!1,e=!1,r="";function a(){r&&(s.push(r),r="")}for(const c of i)t.test(c)?(o||a(),r+=c,o=!0,e=!1):n.test(c)?(e||a(),r+=c,o=!1,e=!0):(a(),o=!1,e=!1,l.test(c)||s.push(c));return a(),s}onmessage=i=>{const s=i.data,t=f(s).replace(new RegExp("^​"),"").replace(new RegExp("​","g"),`\n`),l=p(t);postMessage(l.length)}})();\n',El=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Pl],{type:"text/javascript;charset=utf-8"});function lT(o){let t;try{if(t=El&&(self.URL||self.webkitURL).createObjectURL(El),!t)throw"";const e=new Worker(t,{name:o?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Pl),{name:o?.name})}}const Ml=`(function(){"use strict";const v={first:1,second:2,third:3,fourth:4,fifth:5,sixth:6},E=["text","hyperlink","subscript","superscript","control","date","label"],L="​";function m(c){return!c.type||E.includes(c.type)}function I(c){const{elementList:r,positionList:d}=c,p=[];let u=0;for(;u<r.length;){const t=r[u],l=(e,n,s)=>{const g=e.titleId,a={type:"title",value:"",level:e.level,titleId:g,pageNo:d[u].pageNo},o=[];for(;s<n.length;){const i=n[s];if(g!==i.titleId){s--;break}o.push(i),s++}return a.value=o.filter(i=>m(i)).map(i=>i.value).join("").replace(new RegExp(L,"g"),""),{position:s,titleElement:a}};if(t.titleId){const{position:e,titleElement:n}=l(t,r,u);u=e,p.push(n)}if(t.type==="table"){const e=t.trList;for(let n=0;n<e.length;n++){const s=e[n];for(let g=0;g<s.tdList.length;g++){const a=s.tdList[g].value;if(a.length>1){let o=1;for(;o<a.length;){if(a[o]?.titleId){const{titleElement:i,position:N}=l(a[o],a,o);p.push(i),o=N}o++}}}}}u++}if(!p.length)return null;const f=(t,l)=>{const e=l.subCatalog[l.subCatalog.length-1],n=v[e?.level],s=v[t.level];e&&s>n?f(t,e):l.subCatalog.push({id:t.titleId,name:t.value,level:t.level,pageNo:t.pageNo,subCatalog:[]})},h=[];for(let t=0;t<p.length;t++){const l=p[t],e=h[h.length-1],n=v[e?.level],s=v[l.level];e&&s>n?f(l,e):h.push({id:l.titleId,name:l.value,level:l.level,pageNo:l.pageNo,subCatalog:[]})}return h}onmessage=c=>{const r=c.data,d=I(r);postMessage(d)}})();
522
522
  `,Ol=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ml],{type:"text/javascript;charset=utf-8"});function aT(o){let t;try{if(t=Ol&&(self.URL||self.webkitURL).createObjectURL(Ol),!t)throw"";const e=new Worker(t,{name:o?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Ml),{name:o?.name})}}const Sl=`(function(){"use strict";function u(e){const t=[];for(const s of e){if(s.type==="table"){const o=s.trList;for(let n=0;n<o.length;n++){const c=o[n];for(let r=0;r<c.tdList.length;r++){const i=c.tdList[r];t.push(...u(i.value))}}}if(s.groupIds)for(const o of s.groupIds)t.includes(o)||t.push(o)}return t}onmessage=e=>{const t=e.data,s=u(t);postMessage(s)}})();
523
- `,Xl=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Sl],{type:"text/javascript;charset=utf-8"});function cT(o){let t;try{if(t=Xl&&(self.URL||self.webkitURL).createObjectURL(Xl),!t)throw"";const e=new Worker(t,{name:o?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Sl),{name:o?.name})}}const Nl='(function(){"use strict";var m=(t=>(t.HALF="half",t.ONE_THIRD="one-third",t.QUARTER="quarter",t))(m||{}),M=(t=>(t.ARABIC="arabic",t.CHINESE="chinese",t))(M||{});const K="​";m.HALF+"",1/2,m.ONE_THIRD+"",1/3,m.QUARTER+"",1/4;function b(t){if(typeof structuredClone=="function")return structuredClone(t);if(!t||typeof t!="object")return t;let d={};return Array.isArray(t)?d=t.map(f=>b(f)):Object.keys(t).forEach(f=>{d[f]=b(t[f])}),d}function D(t,d){const f={};for(const S in t)d.includes(S)&&(f[S]=t[S]);return f}function et(t,d){return t.length!==d.length?!1:!t.some(f=>!d.includes(f))}var o=(t=>(t.TEXT="text",t.TEXTFIELD="TextField",t.BUTTON="button",t.IMAGE="image",t.TABLE="table",t.HYPERLINK="hyperlink",t.SUPERSCRIPT="superscript",t.SUBSCRIPT="subscript",t.SEPARATOR="separator",t.PAGE_BREAK="pageBreak",t.CONTROL="control",t.AREA="area",t.CHECKBOX="checkbox",t.RADIO="radio",t.LATEX="latex",t.TAB="tab",t.DATE="date",t.BLOCK="block",t.TITLE="title",t.LIST="list",t.SPLIT_TAG="splitTag",t.LABEL="label",t.MENSTRUAL_HISTORY="menstrualHistory",t.FETAL_HEART_POSITION="fetalHeartPosition",t.TOOTH_POSITION="toothPosition",t.SPECIAL_SYMBOLS="specialSymbols",t.MACRO="macro",t.CUSTOM_MACRO="customMacro",t.REUSABLE_ITEM="reusableItem",t.SUB_TEMPLATE="subTemplate",t))(o||{});const y=["rowFlex","rowMargin"],ot=["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"],nt=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],w=["font","size","bold","highlight","italic","strikeout","deletePerson","newElEditPerson","deleteTime","color","newElEditTime"];o.TEXT,o.HYPERLINK,o.SUBSCRIPT,o.SUPERSCRIPT,o.CONTROL,o.DATE,o.IMAGE,o.LATEX,o.BLOCK,o.PAGE_BREAK,o.SEPARATOR,o.TABLE,o.TITLE,o.LIST;var Y=(t=>(t.UL="ul",t.OL="ol",t))(Y||{}),N=(t=>(t.DISC="disc",t.CIRCLE="circle",t.SQUARE="square",t.CHECKBOX="checkbox",t))(N||{}),_=(t=>(t.DISC="disc",t.CIRCLE="circle",t.SQUARE="square",t.DECIMAL="decimal",t.CHECKBOX="checkbox",t))(_||{});N.DISC+"",N.CIRCLE+"",N.SQUARE+"",N.CHECKBOX+"",Y.OL+"",Y.UL+"",_.DISC+"",_.CIRCLE+"",_.SQUARE+"",_.DECIMAL+"",_.CHECKBOX+"";var p=(t=>(t.FIRST="first",t.SECOND="second",t.THIRD="third",t.FOURTH="fourth",t.FIFTH="fifth",t.SIXTH="sixth",t))(p||{});p.FIRST+"",p.SECOND+"",p.THIRD+"",p.FOURTH+"",p.FIFTH+"",p.SIXTH+"",p.FIRST+"",p.SECOND+"",p.THIRD+"",p.FOURTH+"",p.FIFTH+"",p.SIXTH+"",p.FIRST,p.SECOND,p.THIRD,p.FOURTH,p.FIFTH,p.SIXTH;var L=(t=>(t.TEXT="text",t.SELECT="select",t.CHECKBOX="checkbox",t.RADIO="radio",t.DATE="date",t.NUMBER="number",t.TEXTFIELD="TextField",t.BUTTON="button",t.MENSTRUAL_HISTORY="menstrualHistory",t))(L||{}),n=(t=>(t.PREFIX="prefix",t.POSTFIX="postfix",t.PRE_TEXT="preText",t.PRETEXTFIX="preTextFix",t.PRETEXTFIX_TEXT="preTextFixText",t.POSTTEXTFIX="postTextFix",t.POSTTEXTFIX_TEXT="postTextFixText",t.POST_TEXT="postText",t.PLACEHOLDER="placeholder",t.TEXTFIXLABEL="textFixLabel",t.VALUE="value",t.DELETEPERSON="deletePerson",t.CHECKBOX="checkbox",t.RADIO="radio",t.UNDERLINE="underline",t))(n||{}),q=(t=>(t.LEFT="left",t.CENTER="center",t.RIGHT="right",t.ALIGNMENT="alignment",t.JUSTIFY="justify",t))(q||{}),W=(t=>(t.CONTAIN="contain",t.COVER="cover",t))(W||{}),Z=(t=>(t.REPEAT="repeat",t.NO_REPEAT="no-repeat",t.REPEAT_X="repeat-x",t.REPEAT_Y="repeat-y",t))(Z||{});W.COVER,Z.NO_REPEAT;var z=(t=>(t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom",t))(z||{});z.BOTTOM,m.HALF,m.HALF,q.CENTER,M.ARABIC,z.BOTTOM;var j=(t=>(t.TEXT="text",t.IMAGE="image",t))(j||{});j.TEXT,M.ARABIC;var J=(t=>(t.PAGE="page",t.CONTINUITY="continuity",t))(J||{});J.CONTINUITY,L.NUMBER,L.SELECT,L.DATE,L.CHECKBOX,L.RADIO,n.PREFIX,n.POSTFIX,n.PRE_TEXT,n.POST_TEXT,n.PRETEXTFIX,n.PRETEXTFIX_TEXT,n.POSTTEXTFIX,n.POSTTEXTFIX_TEXT,n.PLACEHOLDER,n.TEXTFIXLABEL,n.CHECKBOX,n.RADIO,n.UNDERLINE;function lt(t,d){const f=Object.keys(t),S=Object.keys(d);if(f.length!==S.length)return!1;for(let X=0;X<f.length;X++){const R=f[X];if(R!=="value"&&!(R==="groupIds"&&Array.isArray(t[R])&&Array.isArray(d[R])&&et(t[R],d[R]))&&t[R]!==d[R])return!1}return!0}function B(t,d={}){const{extraPickAttrs:f}=d,S=[...ot];f&&S.push(...f);const X={value:t?.value===K?`\n`:t?.value};return t&&S.forEach(R=>{const T=t[R];T!==void 0&&(X[R]=T)}),X}function P(t,d={}){const{extraPickAttrs:f,isClassifyArea:S=!1,isClone:X=!0,editorOptions:R}=d,T=(X?b(t):t).filter(e=>e.type!==o.SPLIT_TAG),k=[];let r=0;for(;r<T.length;){let e=T[r];if(r===0&&e.value===K&&!e.listId&&(!e.type||e.type===o.TEXT)){r++;continue}if(e.areaId){const s=e.areaId,O=e.area,E=[];for(;r<T.length;){const i=T[r];if(s!==i.areaId){r--;break}delete i.area,delete i.areaId,E.push(i),r++}const a=P(E,d);if(S){const i={type:o.AREA,value:"",areaId:s,area:O};i.valueList=a,e=i}else{k.splice(r,0,...a);continue}}else if(e.titleId&&e.level){const s=e.titleId;if(s){const O=e.level,E={type:o.TITLE,title:e.title,titleId:s,value:"",level:O},a=[];for(;r<T.length;){const i=T[r];if(s!==i.titleId){r--;break}delete i.level,delete i.title,a.push(i),r++}E.valueList=P(a,d),e=E}}else if(e.listId&&e.listType){const s=e.listId;if(s){const O=e.listType,E=e.listStyle,a=e?.label,i={type:o.LIST,value:"",label:a||"",listId:s,listType:O,listStyle:E},I=[];for(;r<T.length;){const c=T[r];if(s!==c.listId){r--;break}delete c.listType,delete c.listStyle,I.push(c),r++}i.valueList=P(I,d),e=i}}else if(e.type===o.TABLE){if(e.pagingId){let s=r+1,O=0;for(;s<T.length;){const E=T[s];if(E.pagingId===e.pagingId){e.height+=E.height;const a=E.trList.filter(i=>!i.pagingRepeat).filter(i=>(i.tdList=i.tdList.filter(I=>{if(I.originalId){for(let c=0;c<e.trList.length;c++){const u=e.trList[c].tdList.find(({id:l})=>l===I.originalId);if(u){I.value[0]?.type===o.SPLIT_TAG&&I.value.splice(0,1),u.value.push(...I.value),u.rowspan=u.originalRowspan??u.rowspan;break}}return!1}return!0}),!i.originalId));e.trList.push(...a),e.trList?.forEach(i=>i.minHeight=i.originalMinHeight??i.minHeight),s++,O++}else break}r+=O}if(e.trList)for(let s=0;s<e.trList.length;s++){const O=e.trList[s];delete O.id;for(let E=0;E<O.tdList.length;E++){const a=O.tdList[E],i={colspan:a.colspan,rowspan:a.rowspan,value:P(a.value,{...d,isClassifyArea:!1})};nt.forEach(I=>{const c=a[I];c!==void 0&&(i[I]=c)}),O.tdList[E]=i}}}else if(e.type===o.HYPERLINK){const s=e.hyperlinkId;if(s){const O={type:o.HYPERLINK,value:"",url:e.url},E=[];for(;r<T.length;){const a=T[r];if(s!==a.hyperlinkId){r--;break}delete a.type,delete a.url,E.push(a),r++}O.valueList=P(E,d),e=O}}else if(e.type===o.DATE){const s=e.dateId;if(s){const O={type:o.DATE,value:"",dateFormat:e.dateFormat},E=[];for(;r<T.length;){const a=T[r];if(s!==a.dateId){r--;break}delete a.type,delete a.dateFormat,E.push(a),r++}O.valueList=P(E,d),e=O}}else if(e.type!==o.BUTTON){if(e.controlId){const s=e.controlId;if(!(e.controlComponent===n.PREFIX||e.controlComponent===n.PRETEXTFIX||e.controlComponent===n.PRETEXTFIX_TEXT)&&e.controlComponent===n.VALUE){if(e.type===o.MENSTRUAL_HISTORY||e.type===o.FETAL_HEART_POSITION||e.type===o.TOOTH_POSITION||e.type===o.MACRO||e.type===o.CUSTOM_MACRO||e.type===o.REUSABLE_ITEM||e.type===o.LIST||e.type===o.SPECIAL_SYMBOLS){let I=!1;for(let c=r-1;c>=0;c--){const C=T[c],u=C.controlComponent===n.PREFIX||C.controlComponent===n.PRETEXTFIX||C.controlComponent===n.PRETEXTFIX_TEXT;if(C.controlId===s&&u){I=!0;break}if(C.controlId!==s)break}if(!I){const c=b(e);delete c.controlId,delete c.control,delete c.controlComponent,delete c.originControlId,k.push(c),r++;continue}}r++;continue}if(e.controlComponent===n.PLACEHOLDER||e.controlComponent===n.POSTFIX||e.controlComponent===n.POSTTEXTFIX||e.controlComponent===n.POSTTEXTFIX_TEXT||e.controlComponent===n.POST_TEXT||e.controlComponent===n.PRE_TEXT||e.controlComponent===n.CHECKBOX||e.controlComponent===n.RADIO){r++;continue}const E=(i,I,c,C)=>{if(C===L.CHECKBOX||C===L.RADIO){let l=-1;for(let v=i;v<T.length&&T[v].controlId===I;v++)l=v;return l}const u=c?[n.POSTTEXTFIX,n.POSTTEXTFIX_TEXT]:[n.POSTFIX];for(let l=i;l<T.length;l++){const v=T[l];if(v.controlId===I&&u.includes(v.controlComponent))return l}return-1},a=(i,I,c)=>{const C=[];let u=i;for(;u<=I;){const l=T[u];if(l.controlId&&l.controlId!==c&&l.control){const A=l.control?.type,g=A===L.TEXTFIELD,h=g?n.PRETEXTFIX:n.PREFIX,H=l.controlComponent===h,x=A===L.CHECKBOX||A===L.RADIO;if(H||x&&(l.controlComponent===n.CHECKBOX||l.controlComponent===n.RADIO)){const F=E(u+1,l.controlId,g,A);if(F!==-1){const Q=T.slice(u,F+1).map(it=>{const tt=b(it);return delete tt.originControlId,tt}),U=P(Q,d);U.length>0&&C.push(U[0]),u=F+1;continue}}}if(!(l.controlId===c&&(l.controlComponent===n.VALUE||!l.controlComponent)&&(!l.originControlId||l.originControlId===c)||l.originControlId===c&&l.controlComponent===n.VALUE||l.controlId===c&&(l.controlComponent===n.CHECKBOX||l.controlComponent===n.RADIO)&&!l.originControlId)){u++;continue}if(l.type===o.MENSTRUAL_HISTORY||l.type===o.FETAL_HEART_POSITION||l.type===o.TOOTH_POSITION||l.type===o.MACRO||l.type===o.CUSTOM_MACRO||l.type===o.REUSABLE_ITEM||l.type===o.LIST||l.type===o.SPECIAL_SYMBOLS){const A=b(l);delete A.controlId,delete A.control,delete A.controlComponent,delete A.originControlId,C.push(A),u++;continue}if(l.controlComponent===n.CHECKBOX||l.controlComponent===n.RADIO){C.push(b(l)),u++;continue}const $=e.control?.type;if($===L.CHECKBOX||$===L.RADIO){let A=u-1,g=!1;for(;A>=i-1;){const h=T[A];if(h.controlId===c&&!h.originControlId)if(h.controlComponent===n.CHECKBOX){g=h.checkbox?.value===!0;break}else if(h.controlComponent===n.RADIO){g=h.radio?.value===!0;break}else if(h.controlComponent===n.VALUE){A--;continue}else break;A--}if(g){const h={value:l.value||""},H=[...y,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"];for(const x of H){const F=l[x];if(F!==void 0){if(x==="color"&&R){const Q=R.control?.bracketColor,U=R.control?.placeholderColor;if(F===Q||F===U)continue}h[x]=F}}C.push(h)}}else{const A={value:l.value||""},g=[...y,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"];for(const h of g){const H=l[h];if(H!==void 0){if(h==="color"&&R){const x=R.control?.bracketColor,F=R.control?.placeholderColor;if(H===x||H===F)continue}A[h]=H}}C.push(A)}u++}return C};if(e.controlComponent===n.PREFIX){const i=e.control?.type===L.TEXTFIELD,I=E(r+1,s,i);if(I!==-1){const c=a(r+1,I-1,s),C=D(e,w),l=e.control?.type===L.BUTTON&&!e.control?.buttonText?c.length?c:null:c,v={...e.control,...C,value:l},V={...D(e,y),type:o.CONTROL,value:"",control:v,controlId:s};e=B(V,{extraPickAttrs:f}),r=I}}if(e.controlComponent===n.PRETEXTFIX){const i=E(r+1,s,!0);if(i!==-1){const I=a(r+1,i-1,s),c=D(e,w),C={...e.control,...c,value:I},u={...D(e,y),type:o.CONTROL,value:"",control:C,controlId:s};e=B(u,{extraPickAttrs:f}),r=i}}if(e.controlComponent===n.PRETEXTFIX_TEXT){const i=E(r+1,s,!0);if(i!==-1){const I=a(r+1,i-1,s),c=D(e,w),C={...e.control,...c,value:I},u={...D(e,y),type:o.CONTROL,value:"",control:C,controlId:s};e=B(u,{extraPickAttrs:f}),r=i}}}}const G=B(e,{extraPickAttrs:f});if(!e.type||e.type===o.TEXT||e.type===o.SUBSCRIPT||e.type===o.SUPERSCRIPT)for(;r<T.length;){const s=T[r+1];if(r++,s&&lt(G,B(s,{extraPickAttrs:f}))){const O=s.value===K?`\n`:s.value;G.value+=O}else break}else r++;k.push(G)}return k}onmessage=t=>{const d=t.data,{options:f,data:S}=d,{extraPickAttrs:X=[]}=f||{},R={header:P(S.header,{extraPickAttrs:X,isClone:!1}),main:P(S.main,{extraPickAttrs:X,isClassifyArea:!0,isClone:!1}),footer:P(S.footer,{extraPickAttrs:X,isClone:!1})};postMessage(R)}})();\n',Fl=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Nl],{type:"text/javascript;charset=utf-8"});function dT(o){let t;try{if(t=Fl&&(self.URL||self.webkitURL).createObjectURL(Fl),!t)throw"";const e=new Worker(t,{name:o?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Nl),{name:o?.name})}}class uT{draw;wordCountWorker;catalogWorker;groupWorker;valueWorker;constructor(t){this.draw=t,this.wordCountWorker=new lT,this.catalogWorker=new aT,this.groupWorker=new cT,this.valueWorker=new dT}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=i=>{t(i.data)},this.wordCountWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(n)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=l=>{t(l.data)},this.catalogWorker.onerror=l=>{e(l)};const n=this.draw.getOriginalMainElementList(),i=this.draw.getPosition().getOriginalMainPositionList();this.catalogWorker.postMessage({elementList:n,positionList:i})})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=i=>{t(i.data)},this.groupWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(n)})}getValue(t){return new Promise((e,n)=>{this.valueWorker.onmessage=i=>{e({version:fn,data:i.data,options:ct(this.draw.getOptions())})},this.valueWorker.onerror=i=>{n(i)},this.valueWorker.postMessage({data:this.draw.getOriginValue(t),options:t})})}}class RT{container;canvas;draw;options;curElement;curElementSrc;previewerDrawOption;curPosition;eventBus;imageList;curShowElement;imageCount;imagePre;imageNext;resizerSelection;resizerHandleList;resizerImageContainer;resizerImage;resizerSize;width;height;mousedownX;mousedownY;curHandleIndex;previewerContainer;previewerImage;constructor(t){this.container=t.getContainer(),this.canvas=t.getPage(),this.draw=t,this.options=t.getOptions(),this.curElement=null,this.curElementSrc="",this.previewerDrawOption={},this.curPosition=null,this.eventBus=t.getEventBus(),this.imageList=[],this.curShowElement=null,this.imageCount=null,this.imagePre=null,this.imageNext=null;const{resizerSelection:e,resizerHandleList:n,resizerImageContainer:i,resizerImage:l,resizerSize:r}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=n,this.resizerImageContainer=i,this.resizerImage=l,this.resizerSize=r,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.previewerContainer=null,this.previewerImage=null}_getElementPosition(t,e=null){const{scale:n}=this.options;let i=0,l=0;const r=this.draw.getHeight(),a=this.draw.getPageGap(),d=(e?.pageNo??this.draw.getPageNo())*(r+a);if(t.imgFloatPosition)i=t.imgFloatPosition.x*n,l=t.imgFloatPosition.y*n+d;else if(e){const{coordinate:{leftTop:[u,R]},ascent:h}=e;i=u,l=R+d+h}return{x:i,y:l}}_createResizerDom(){const{scale:t}=this.options,e=document.createElement("div");e.classList.add(`${rt}-resizer-selection`),e.style.display="none",e.style.borderColor=this.options.resizerColor,e.style.borderWidth=`${t}px`;const n=[];for(let c=0;c<8;c++){const d=document.createElement("div");d.style.background=this.options.resizerColor,d.classList.add("resizer-handle"),d.classList.add(`handle-${c}`),d.setAttribute("data-index",String(c)),d.onmousedown=this._mousedown.bind(this),e.append(d),n.push(d)}this.container.append(e);const i=document.createElement("div");i.classList.add(`${rt}-resizer-size-view`);const l=document.createElement("span");i.append(l),e.append(i);const r=document.createElement("div");r.classList.add(`${rt}-resizer-image`),r.style.display="none";const a=document.createElement("img");return r.append(a),this.container.append(r),{resizerSelection:e,resizerHandleList:n,resizerImageContainer:r,resizerImage:a,resizerSize:l}}_keydown=()=>{this.resizerSelection.style.display==="block"&&(this.clearResizer(),document.removeEventListener("keydown",this._keydown))};_mousedown(t){if(this.canvas=this.draw.getPage(),!this.curElement)return;const{scale:e}=this.options;this.mousedownX=t.x,this.mousedownY=t.y;const n=t.target;this.curHandleIndex=Number(n.dataset.index);const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,this.canvas.style.cursor=i,this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{x:l,y:r}=this._getElementPosition(this.curElement,this.curPosition);this.resizerImageContainer.style.left=`${l}px`,this.resizerImageContainer.style.top=`${r}px`,this.resizerImage.style.width=`${this.curElement.width*e}px`,this.resizerImage.style.height=`${this.curElement.height*e}px`;const a=this._mousemove.bind(this);document.addEventListener("mousemove",a),document.addEventListener("mouseup",()=>{this.curElement&&!this.previewerDrawOption.dragDisable&&(this.curElement.width=this.width,this.curElement.height=this.height,this.draw.render({isSetCursor:!0,curIndex:this.curPosition?.index})),this.resizerImageContainer.style.display="none",document.removeEventListener("mousemove",a),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.curElement||this.previewerDrawOption.dragDisable)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const d=this.mousedownX-t.x,u=this.mousedownY-t.y;n=Math.cbrt(d**3+u**3),i=this.curElement.height*n/this.curElement.width}break;case 1:i=this.mousedownY-t.y;break;case 2:{const d=t.x-this.mousedownX,u=this.mousedownY-t.y;n=Math.cbrt(d**3+u**3),i=this.curElement.height*n/this.curElement.width}break;case 4:{const d=t.x-this.mousedownX,u=t.y-this.mousedownY;n=Math.cbrt(d**3+u**3),i=this.curElement.height*n/this.curElement.width}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const d=this.mousedownX-t.x,u=t.y-this.mousedownY;n=Math.cbrt(d**3+u**3),i=this.curElement.height*n/this.curElement.width}break;case 7:n=this.mousedownX-t.x;break}const l=this.curElement.width+n/e,r=this.curElement.height+i/e;if(l<=0||r<=0)return;this.width=l,this.height=r;const a=l*e,c=r*e;this.resizerImage.style.width=`${a}px`,this.resizerImage.style.height=`${c}px`,this._updateResizerRect(a,c),this._updateResizerSizeView(a,c),t.preventDefault(),this.eventBus.isSubscribe("imageSizeChange")&&this.eventBus.emit("imageSizeChange",{element:this.curElement})}_drawPreviewer(){const t=document.createElement("div");t.classList.add(`${rt}-image-previewer`);const e=document.createElement("i");e.classList.add("image-close"),e.onclick=()=>{this._clearPreviewer()},t.append(e);const n=document.createElement("div");n.classList.add(`${rt}-image-container`);const i=document.createElement("img");i.src=this.curElementSrc,i.draggable=!1,n.append(i),this.previewerImage=i,t.append(n);let l=0,r=0,a=1,c=0;const d=document.createElement("div");d.classList.add(`${rt}-image-menu`);const u=document.createElement("div");u.classList.add("image-navigate");const R=document.createElement("i");R.classList.add("image-pre"),R.onclick=()=>{const M=this.imageList.findIndex(F=>F.id===this.curShowElement?.id);M<=0||(this.curShowElement=this.imageList[M-1],i.src=this.curShowElement.value,this._updateImageNavigate())},u.append(R),this.imagePre=R;const h=document.createElement("span");h.classList.add("image-count"),this.imageCount=h,u.append(h);const g=document.createElement("i");g.classList.add("image-next"),g.onclick=()=>{const M=this.imageList.findIndex(F=>F.id===this.curShowElement?.id);M>=this.imageList.length-1||(this.curShowElement=this.imageList[M+1],i.src=this.curShowElement.value,this._updateImageNavigate())},this.imageNext=g,u.append(g),d.append(u);const T=document.createElement("i");T.classList.add("zoom-in"),T.onclick=()=>{a+=.1,this._setPreviewerTransform(a,c,l,r)},d.append(T);const f=document.createElement("i");f.onclick=()=>{a-.1<=.1||(a-=.1,this._setPreviewerTransform(a,c,l,r))},f.classList.add("zoom-out"),d.append(f);const p=document.createElement("i");p.classList.add("rotate"),p.onclick=()=>{c+=1,this._setPreviewerTransform(a,c,l,r)},d.append(p);const C=document.createElement("i");C.classList.add("original-size"),C.onclick=()=>{l=0,r=0,a=1,c=0,this._setPreviewerTransform(a,c,l,r)},d.append(C);const I=document.createElement("i");I.classList.add("image-download"),I.onclick=()=>{const{mime:M}=this.previewerDrawOption;Ss(i.src,`${this.curElement?.id}.${M||"png"}`)},d.append(I),t.append(d),this.previewerContainer=t,document.body.append(t);let m=0,P=0,E=!1;i.onmousedown=M=>{E=!0,m=M.x,P=M.y,t.style.cursor="move"},t.onmousemove=M=>{E&&(l+=M.x-m,r+=M.y-P,m=M.x,P=M.y,this._setPreviewerTransform(a,c,l,r))},t.onmouseup=()=>{E=!1,t.style.cursor="auto"},t.onwheel=M=>{if(M.preventDefault(),M.stopPropagation(),M.deltaY<0)a+=.1;else{if(a-.1<=.1)return;a-=.1}this._setPreviewerTransform(a,c,l,r)},this._updateImageNavigate()}_updateImageNavigate(){const t=this.imageList.findIndex(e=>e.id===this.curShowElement?.id);this.imageCount.innerText=`${t+1} / ${this.imageList.length}`,t<=0?this.imagePre.classList.add("disabled"):this.imagePre.classList.remove("disabled"),t>=this.imageList.length-1?this.imageNext.classList.add("disabled"):this.imageNext.classList.remove("disabled")}_setPreviewerTransform(t,e,n,i){this.previewerImage&&(this.previewerImage.style.left=`${n}px`,this.previewerImage.style.top=`${i}px`,this.previewerImage.style.transform=`scale(${t}) rotate(${e*90}deg)`)}_clearPreviewer(){this.previewerContainer?.remove(),this.previewerContainer=null,document.body.style.overflow="auto"}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options,l=this.draw.isReadonly();this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let r=0;r<8;r++){const a=r===0||r===6||r===7?-n:r===1||r===5?t/2:t-n,c=r===0||r===1||r===2?-n:r===3||r===7?e/2-n:e-n;this.resizerHandleList[r].style.transform=`scale(${i})`,this.resizerHandleList[r].style.left=`${a}px`,this.resizerHandleList[r].style.top=`${c}px`,this.resizerHandleList[r].style.display=l?"none":"block"}}_updateResizerSizeView(t,e){this.resizerSize.innerText=`${Math.round(t)} × ${Math.round(e)}`}render(){const t=this.draw.getMode();!this.curElement||this.curElement.imgToolDisabled&&!this.draw.isDesignMode()||t===s.EditorMode.PRINT&&this.options.modeRule[s.EditorMode.PRINT]?.imagePreviewerDisabled||t===s.EditorMode.COMPARE&&this.options.modeRule[s.EditorMode.COMPARE]?.imagePreviewerDisabled||t===s.EditorMode.READONLY&&this.options.modeRule[s.EditorMode.READONLY]?.imagePreviewerDisabled||(this.imageList=this.draw.getImageParticle().getOriginalMainImageList(),this.curShowElement=this.curElement,this._drawPreviewer(),document.body.style.overflow="hidden")}drawResizer(t,e=null,n={}){const i=this.draw.getMode();t.imgToolDisabled&&!this.draw.isDesignMode()||i===s.EditorMode.PRINT&&this.options.modeRule[s.EditorMode.PRINT]?.imagePreviewerDisabled||i===s.EditorMode.COMPARE&&this.options.modeRule[s.EditorMode.COMPARE]?.imagePreviewerDisabled||i===s.EditorMode.READONLY&&this.options.modeRule[s.EditorMode.READONLY]?.imagePreviewerDisabled||(this.previewerDrawOption=n,this.curElementSrc=t[n.srcKey||"value"]||"",this.updateResizer(t,e),document.addEventListener("keydown",this._keydown))}updateResizer(t,e=null){const{scale:n}=this.options,i=t.width*n,l=t.height*n;this._updateResizerSizeView(i,l);const{x:r,y:a}=this._getElementPosition(t,e);this.resizerSelection.style.left=`${r}px`,this.resizerSelection.style.top=`${a}px`,this.resizerSelection.style.borderWidth=`${n}px`,this._updateResizerRect(i,l),this.resizerSelection.style.display="block",this.curElement=t,this.curPosition=e,this.width=i,this.height=l}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}class hT{draw;range;datePicker;options;constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.datePicker=new fl(t,{onSubmit:this._setValue.bind(this)})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[n,i]=e,l=this.draw.getElementList(),r=l[n+1];this.draw.spliceElementList(l,n+1,i-n),this.range.setRange(n,n);const a={type:s.ElementType.DATE,value:"",dateFormat:r.dateFormat,valueList:[{value:t}]};oe(l,[a],n,{editorOptions:this.options}),this.draw.insertElementList([a])}getDateElementRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=this.draw.getElementList(),r=l[n];if(r.type!==s.ElementType.DATE)return null;let a=n;for(;a>=0;){if(l[a].dateId!==r.dateId){t=a;break}a--}let c=n+1;for(;c<l.length;){if(l[c].dateId!==r.dateId){e=c-1;break}c++}return c===l.length&&(e=c-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const n=this.draw.getElementList(),i=this.getDateElementRange(),l=i?n.slice(i[0]+1,i[1]+1).map(r=>r.value).join(""):"";this.datePicker.render({value:l,position:e,dateFormat:t.dateFormat})}}class yl{element;videoCache;constructor(t){this.element=t,this.videoCache=new Map}snapshot(t,e,n){return new Promise((i,l)=>{const r=this.element.block?.videoBlock?.src||"";if(this.videoCache.has(r)){const a=this.videoCache.get(r);t.drawImage(a,e,n,this.element.metrics.width,this.element.metrics.height),i(this.element)}else{const a=document.createElement("video");a.src=r,a.muted=!0,a.crossOrigin="anonymous",a.onloadeddata=()=>{t.drawImage(a,e,n,this.element.metrics.width,this.element.metrics.height),this.videoCache.set(r,a),i(this.element)},a.onerror=c=>{l(c)},a.play().then(()=>{a.pause()})}})}render(t){const e=this.element.block,n=document.createElement("video");n.style.width="100%",n.style.height="100%",n.style.objectFit="contain",n.src=e.videoBlock?.src||"",n.controls=!0,t.append(n)}}class gT{draw;options;element;block;blockContainer;blockItem;blockCache;resizerMask;resizerSelection;resizerHandleList;width;height;mousedownX;mousedownY;curHandleIndex;isAllowResize;constructor(t,e){this.draw=t.getDraw(),this.options=this.draw.getOptions(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null;const{blockItem:n,resizerMask:i,resizerSelection:l,resizerHandleList:r}=this._createBlockItem();this.blockItem=n,this.blockContainer.append(this.blockItem),this.blockCache=new Map,this.resizerMask=i,this.resizerSelection=l,this.resizerHandleList=r,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.isAllowResize=!1}getBlockElement(){return this.element}getBlockWidth(){return this.element.width||this.element.metrics.width}_createBlockItem(){const{scale:t,resizerColor:e}=this.options,n=document.createElement("div");n.classList.add(`${rt}-block-item`);const i=document.createElement("div");i.style.display="none",i.classList.add(`${rt}-resizer-selection`),i.style.borderColor=e,i.style.borderWidth=`${t}px`;const l=[];for(let a=0;a<8;a++){const c=document.createElement("div");c.style.background=e,c.classList.add("resizer-handle"),c.classList.add(`handle-${a}`),c.setAttribute("data-index",String(a)),c.onmousedown=this._mousedown.bind(this),i.append(c),l.push(c)}const r=document.createElement("div");return r.classList.add(`${rt}-resizer-mask`),r.style.display="none",n.append(r),n.onmouseenter=()=>{if(this.draw.isReadonly())return;const{width:c,height:d}=this.element.metrics;this._updateResizerRect(c,d),i.style.display="block"},n.onmouseleave=()=>{this.isAllowResize||(i.style.display="none")},n.append(i),{blockItem:n,resizerMask:r,resizerSelection:i,resizerHandleList:l}}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options;this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let l=0;l<8;l++){const r=l===0||l===6||l===7?-n:l===1||l===5?t/2:t-n,a=l===0||l===1||l===2?-n:l===3||l===7?e/2-n:e-n;this.resizerHandleList[l].style.transform=`scale(${i})`,this.resizerHandleList[l].style.left=`${r}px`,this.resizerHandleList[l].style.top=`${a}px`}}_mousedown(t){const e=this.draw.getPage();this.mousedownX=t.x,this.mousedownY=t.y,this.isAllowResize=!0;const n=t.target;this.curHandleIndex=Number(n.dataset.index),this.resizerMask.style.display="block";const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,e.style.cursor=i;const l=this._mousemove.bind(this);document.addEventListener("mousemove",l),document.addEventListener("mouseup",()=>{this.element.width=Math.min(this.width,this.draw.getInnerWidth()),this.element.height=this.height,this.isAllowResize=!1,this.resizerSelection.style.display="none",this.resizerMask.style.display="none",document.removeEventListener("mousemove",l),document.body.style.cursor="",e.style.cursor="text",this.draw.render()},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.isAllowResize)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const d=this.mousedownX-t.x,u=this.mousedownY-t.y;n=Math.cbrt(d**3+u**3),i=this.element.height*n/this.getBlockWidth()}break;case 1:i=this.mousedownY-t.y;break;case 2:{const d=t.x-this.mousedownX,u=this.mousedownY-t.y;n=Math.cbrt(d**3+u**3),i=this.element.height*n/this.getBlockWidth()}break;case 4:{const d=t.x-this.mousedownX,u=t.y-this.mousedownY;n=Math.cbrt(d**3+u**3),i=this.element.height*n/this.getBlockWidth()}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const d=this.mousedownX-t.x,u=t.y-this.mousedownY;n=Math.cbrt(d**3+u**3),i=this.element.height*n/this.getBlockWidth()}break;case 7:n=this.mousedownX-t.x;break}const l=this.getBlockWidth()+n/e,r=this.element.height+i/e;if(l<=0||r<=0)return;this.width=l,this.height=r;const a=l*e,c=r*e;this._updateResizerRect(a,c),this.blockItem.style.width=`${a}px`,this.blockItem.style.height=`${c}px`,t.preventDefault()}snapshot(t,e,n){if(this.element.block.type===s.BlockType.VIDEO)if(this.blockItem.style.display="none",this.blockCache.has(this.element.id))this.blockCache.get(this.element.id).snapshot(t,e,n);else{this.block=new yl(this.element);const l=this.block.snapshot(t,e,n);this.draw.getImageObserver().add(l),this.blockCache.set(this.element.id,this.block)}}render(){const t=this.element.block;t.type===s.BlockType.IFRAME?(this.block=new Fn(this.element),this.block.render(this.blockItem)):t.type===s.BlockType.VIDEO&&(this.block=new yl(this.element),this.block.render(this.blockItem))}setClientRects(t,e,n){const i=this.draw.getHeight(),l=this.draw.getPageGap(),r=t*(i+l),{metrics:a}=this.element;this.blockItem.style.display="block",this.blockItem.style.width=`${a.width}px`,this.blockItem.style.height=`${a.height}px`,this.blockItem.style.left=`${e}px`,this.blockItem.style.top=`${r+n}px`}remove(){this.blockItem.remove()}}class TT{draw;container;blockContainer;blockMap;constructor(t){this.draw=t,this.container=t.getContainer(),this.blockMap=new Map,this.blockContainer=this._createBlockContainer(),this.container.append(this.blockContainer)}_createBlockContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,n,i,l){const r=n.id;let a=this.blockMap.get(r);a||(a=new gT(this,n),a.render(),this.blockMap.set(r,a)),this.draw.isPrintLikeMode()?a.snapshot(t,i,l):a.setClientRects(e,i,l)}clear(){if(!this.blockMap.size)return;const t=this.draw.getOriginalMainElementList(),e=[];for(let n=0;n<t.length;n++){const i=t[n];i.type===s.ElementType.BLOCK&&e.push(i.id)}this.blockMap.forEach(n=>{const i=n.getBlockElement().id;e.includes(i)||(n.remove(),this.blockMap.delete(i))})}}const Cs={contextmenu:{global:{cut:"剪切",copy:"复制",paste:"粘贴",selectAll:"全选",print:"打印",cancel:"取消"},control:{delete:"删除控件",editAttribute:"修改元素配置",addExpression:"添加表达式",addMenstrualHistory:"月经史",addFetalHeartPosition:"胎心位置"},hyperlink:{delete:"删除链接",cancel:"取消链接",edit:"编辑链接"},image:{change:"更改图片",saveAs:"另存为图片",textWrap:"文字环绕",textWrapType:{embed:"嵌入型",upDown:"上下型环绕",surround:"四周型环绕",floatTop:"浮于文字上方",floatBottom:"衬于文字下方"}},table:{insertRowCol:"插入行列",insertTopRow:"上方插入1行",insertBottomRow:"下方插入1行",insertLeftCol:"左侧插入1列",insertRightCol:"右侧插入1列",deleteRowCol:"删除行列",deleteRow:"删除1行",deleteCol:"删除1列",deleteTable:"删除整个表格",mergeCell:"合并单元格",mergeCancelCell:"取消合并",verticalAlign:"垂直对齐",verticalAlignTop:"顶端对齐",verticalAlignMiddle:"垂直居中",verticalAlignBottom:"底端对齐",border:"表格边框",borderAll:"所有框线",borderEmpty:"无框线",borderDash:"虚框线",borderExternal:"外侧框线",borderInternal:"内侧框线",borderTd:"单元格边框",borderTdTop:"上边框",borderTdRight:"右边框",borderTdBottom:"下边框",borderTdLeft:"左边框",borderTdForward:"正斜线",borderTdBack:"反斜线",tableProperties:"表格属性"}},datePicker:{now:"此刻",confirm:"确定",return:"返回日期",timeSelect:"时间选择",weeks:{sun:"日",mon:"一",tue:"二",wed:"三",thu:"四",fri:"五",sat:"六"},year:"年",month:"月",hour:"时",minute:"分",second:"秒"},frame:{header:"页眉",footer:"页脚"},pageBreak:{displayName:"分页符"},zone:{headerTip:"双击编辑页眉",footerTip:"双击编辑页脚"}},fT={contextmenu:{global:{cut:"Cut",copy:"Copy",paste:"Paste",selectAll:"Select all",print:"Print",cancel:"Cancel"},control:{delete:"Delete control",editAttribute:"Edit element config",addExpression:"Add expression",addMenstrualHistory:"Menstrual History",addFetalHeartPosition:"Fetal Heart Position"},hyperlink:{delete:"Delete hyperlink",cancel:"Cancel hyperlink",edit:"Edit hyperlink"},image:{change:"Change image",saveAs:"Save as image",textWrap:"Text wrap",textWrapType:{embed:"Embed",upDown:"Up down",surround:"Surround",floatTop:"Float above text",floatBottom:"Float below text"}},table:{insertRowCol:"Insert row col",insertTopRow:"Insert top 1 row",insertBottomRow:"Insert bottom 1 row",insertLeftCol:"Insert left 1 col",insertRightCol:"Insert right 1 col",deleteRowCol:"Delete row col",deleteRow:"Delete 1 row",deleteCol:"Delete 1 col",deleteTable:"Delete table",mergeCell:"Merge cell",mergeCancelCell:"Cancel merge cell",verticalAlign:"Vertical align",verticalAlignTop:"Top",verticalAlignMiddle:"Middle",verticalAlignBottom:"Bottom",border:"Table border",borderAll:"All",borderEmpty:"Empty",borderDash:"Dash",borderExternal:"External",borderInternal:"Internal",borderTd:"Table cell border",borderTdTop:"Top",borderTdRight:"Right",borderTdBottom:"Bottom",borderTdLeft:"Left",borderTdForward:"Forward",borderTdBack:"Back",tableProperties:"Table Properties"}},datePicker:{now:"Now",confirm:"Confirm",return:"Return",timeSelect:"Time select",weeks:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},year:" ",month:" ",hour:"Hour",minute:"Minute",second:"Second"},frame:{header:"Header",footer:"Footer"},pageBreak:{displayName:"Page Break"},zone:{headerTip:"Double click to edit header",footerTip:"Double click to edit footer"}};class mT{currentLocale;langMap=new Map([["zhCN",Cs],["en",fT]]);constructor(t){this.currentLocale=t}registerLangMap(t,e){const n=this.langMap.get(t);this.langMap.set(t,Xs(n||Cs,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||Cs}t(t){const e=t.split(".");let n="",i=this.getLang();for(let l=0;l<e.length;l++){const r=e[l],a=Reflect.get(i,r);if(a)n=i=a;else return""}return n}}class pT{promiseList;constructor(){this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class CT{draw;zone;i18n;container;pageContainer;isDisableMouseMove;tipContainer;tipContent;currentMoveZone;constructor(t,e){this.draw=t,this.zone=e,this.i18n=t.getI18n(),this.container=t.getContainer(),this.pageContainer=t.getPageContainer();const{tipContainer:n,tipContent:i}=this._drawZoneTip();this.tipContainer=n,this.tipContent=i,this.isDisableMouseMove=!0,this.currentMoveZone=s.EditorZone.MAIN;const l=[],{header:r,footer:a}=t.getOptions();r.disabled||l.push(s.EditorZone.HEADER),a.disabled||l.push(s.EditorZone.FOOTER),l.length&&this._watchMouseMoveZoneChange(l)}_watchMouseMoveZoneChange(t){this.pageContainer.addEventListener("mousemove",ra(e=>{if(!(this.isDisableMouseMove||!this.draw.getIsPagingMode())){if(this.draw.getMode()!==s.EditorMode.EDIT){this._updateZoneTip(!1);return}if(e.offsetY)if(e.target instanceof HTMLCanvasElement){const n=this.zone.getZoneByY(e.offsetY);if(!t.includes(n)){this._updateZoneTip(!1);return}this.currentMoveZone=n,this._updateZoneTip(this.zone.getZone()===s.EditorZone.MAIN&&(n===s.EditorZone.HEADER||n===s.EditorZone.FOOTER),e.x,e.y)}else this._updateZoneTip(!1)}},250)),this.pageContainer.addEventListener("mouseenter",()=>{this.isDisableMouseMove=!1}),this.pageContainer.addEventListener("mouseleave",()=>{this.isDisableMouseMove=!0,this._updateZoneTip(!1)})}_drawZoneTip(){const t=document.createElement("div");t.classList.add(`${rt}-zone-tip`);const e=document.createElement("span");return t.append(e),this.container.append(t),{tipContainer:t,tipContent:e}}_updateZoneTip(t,e,n){t?(this.tipContainer.classList.add("show"),this.tipContainer.style.left=`${e}px`,this.tipContainer.style.top=`${n}px`,this.tipContent.innerText=this.i18n.t(`zone.${this.currentMoveZone===s.EditorZone.HEADER?"headerTip":"footerTip"}`)):this.tipContainer.classList.remove("show")}}class IT{INDICATOR_PADDING=2;INDICATOR_TITLE_TRANSLATE=[20,5];draw;options;i18n;container;currentZone;indicatorContainer;constructor(t){this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=s.EditorZone.MAIN,this.indicatorContainer=null,this.options.zone.tipDisabled||new CT(t,this)}isHeaderActive(){return this.getZone()===s.EditorZone.HEADER}isMainActive(){return this.getZone()===s.EditorZone.MAIN}isFooterActive(){return this.getZone()===s.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){const{header:e,footer:n}=this.options;!e.editable&&t===s.EditorZone.HEADER||!n.editable&&t===s.EditorZone.FOOTER||this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),ui(()=>{const i=this.draw.getListener();i.zoneChange&&i.zoneChange(t);const l=this.draw.getEventBus();l.isSubscribe("zoneChange")&&l.emit("zoneChange",t)}))}getZoneByY(t){const e=this.draw.getHeader(),n=e.getHeaderTop()+e.getHeight(),i=this.draw.getFooter(),r=this.draw.getHeight()-(i.getFooterBottom()+i.getHeight());return t<n?s.EditorZone.HEADER:t>r?s.EditorZone.FOOTER:s.EditorZone.MAIN}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[n,i]=this.INDICATOR_TITLE_TRANSLATE,l=this.draw.getPageList(),r=this.draw.getMargins(),a=this.draw.getInnerWidth(),c=this.draw.getHeight(),d=this.draw.getPageGap(),u=c+d;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${rt}-zone-indicator`);const R=this.draw.getHeader(),h=this.draw.getFooter(),g=e?R.getHeight():h.getHeight(),T=e?R.getHeaderTop():c-h.getFooterBottom()-g;for(let f=0;f<l.length;f++){const p=u*f+T,C=r[3]-this.INDICATOR_PADDING,I=r[3]+a+this.INDICATOR_PADDING,m=e?p-this.INDICATOR_PADDING:p+g+this.INDICATOR_PADDING,P=e?p+g+this.INDICATOR_PADDING:p-this.INDICATOR_PADDING,E=document.createElement("div");E.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),E.style.top=`${P}px`,E.style.transform=`translate(${n*t}px, ${i*t}px) scale(${t})`,this.indicatorContainer.append(E);const M=document.createElement("span");M.classList.add(`${rt}-zone-indicator-border__top`),M.style.top=`${m}px`,M.style.width=`${a}px`,M.style.marginLeft=`${r[3]}px`,this.indicatorContainer.append(M);const F=document.createElement("span");F.classList.add(`${rt}-zone-indicator-border__left`),F.style.top=`${p}px`,F.style.height=`${g}px`,F.style.left=`${C}px`,this.indicatorContainer.append(F);const y=document.createElement("span");y.classList.add(`${rt}-zone-indicator-border__bottom`),y.style.top=`${P}px`,this.indicatorContainer.append(y);const Y=document.createElement("span");Y.classList.add(`${rt}-zone-indicator-border__right`),Y.style.top=`${p}px`,Y.style.height=`${g}px`,Y.style.left=`${I}px`,this.indicatorContainer.append(Y)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){this.indicatorContainer?.remove(),this.indicatorContainer=null}}class LT{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();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(){const t=this.getFooterBottom(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],l=this.draw.getHeight(),r=this.getHeight(),a=l-t-r;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:a,innerWidth:e,zone:s.EditorZone.FOOTER})}getFooterBottom(){const{footer:{bottom:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{footer:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Ms[t])}getHeight(){if(this.options.footer.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getFooterBottom()+e-t[2];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isFooterActive()?1:this.options.footer.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),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.FOOTER}),t.restore()}}class PT{draw;range;options;UN_COUNT_STYLE_WIDTH=20;MEASURE_BASE_TEXT="0";LIST_GAP=10;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}setList(t,e){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:l}=this.range.getRange();if(!~i&&!~l)return;const r=this.range.getRangeParagraphElementList();if(!r||!r.length)return;if(r.find(R=>R.listType===t&&R.listStyle===e)||!t){this.unsetList();return}const c=ft();r.forEach(R=>{R.listId=c,R.listType=t,R.listStyle=e});const d=i===l,u=d?l:i;this.draw.render({curIndex:u,isSetCursor:d})}unsetList(){if(this.draw.isReadonly())return;const{startIndex:e,endIndex:n}=this.range.getRange();if(!~e&&!~n)return;const i=this.range.getRangeParagraphElementList()?.filter(d=>d.listId);if(!i||!i.length)return;const l=this.draw.getElementList(),r=l[n];if(r.listId){let d=n+1;for(;d<l.length;){const u=l[d];if(u.value===K&&!u.listWrap)break;if(u.listId!==r.listId){this.draw.spliceElementList(l,d,0,[{value:K}]);break}d++}}i.forEach(d=>{delete d.listId,delete d.listType,delete d.listStyle,delete d.listWrap});const a=e===n,c=a?n:e;this.draw.render({curIndex:c,isSetCursor:a})}computeListStyle(t,e){const n=new Map;let i=0,l=e[i]?.listId,r=[];const a=e.length;for(;i<a;){const c=e[i];if(l&&l===c.listId)r.push(c);else if(c.listId&&c.listId!==l){if(r.length){const d=this.getListStyleWidth(t,r);n.set(l,d)}l=c.listId,r=l?[c]:[]}i++}if(r.length){const c=this.getListStyleWidth(t,r);n.set(l,c)}return n}findStyledElement(t){let e=t[0];for(let n=1;n<t.length;n++){const i=t[n];if(i.font||i.size||i.bold||i.italic){e=i;break}}return e}getListFontStyle(t,e){if(this.options.list.inheritStyle){const n=this.findStyledElement(t);return this.draw.getElementFont(n,e)}else{const{defaultFont:n,defaultSize:i}=this.options;return`${i*e}px ${n}`}}getListStyleWidth(t,e){const{scale:n,checkbox:i}=this.options,l=e[0];if(l.listStyle&&l.listStyle!==s.ListStyle.DECIMAL)return l.listStyle===s.ListStyle.CHECKBOX?(i.width+this.LIST_GAP)*n:this.UN_COUNT_STYLE_WIDTH*n;const r=e.reduce((d,u)=>(u.value===K&&(d+=1),d),0);if(!r)return 0;t.save(),t.font=this.getListFontStyle(e,n);const a=`${this.MEASURE_BASE_TEXT.repeat(String(r).length)}${s.KeyMap.PERIOD}`,c=t.measureText(a);return t.restore(),Math.ceil((c.width+this.LIST_GAP)*n)}drawListStyle(t,e,n){const{elementList:i,offsetX:l,listIndex:r,ascent:a}=e,c=i[0];if(c.value!==K||c.listWrap)return;let d=0;const{defaultTabWidth:u,scale:R}=this.options;for(let p=1;p<i.length&&i[p]?.type===s.ElementType.TAB;p++)d+=u*R;const{coordinate:{leftTop:[h,g]}}=n,T=h-l+d,f=g+a;if(c.listStyle===s.ListStyle.CHECKBOX){const{width:p,height:C,gap:I}=this.options.checkbox,m={...c,checkbox:{value:!!c.checkbox?.value},metrics:{...c.metrics,width:(p+I*2)*R,height:C*R}};this.draw.getCheckboxParticle().render({ctx:t,x:T-I*R,y:f,index:0,row:{...e,elementList:[m,...e.elementList]}})}else{let p="";if(c.listType===s.ListType.UL?p=pi[c.listStyle]||pi[Cn.DISC]:p=`${r+1}${s.KeyMap.PERIOD}`,!p)return;t.save(),t.font=this.getListFontStyle(i,R),t.fillText(p,T,f),t.restore()}}}class To{options;static WIDTH=12;static HEIGHT=9;static GAP=3;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:l,lineBreak:{color:r,lineWidth:a}}=this.options;t.save(),t.beginPath();const c=i-To.HEIGHT*l/2,d=n+e.metrics.width;t.translate(d,c),t.scale(l,l),t.strokeStyle=r,t.lineWidth=a,t.lineCap="round",t.lineJoin="round",t.beginPath(),t.moveTo(8,0),t.lineTo(12,0),t.lineTo(12,6),t.lineTo(3,6),t.moveTo(3,6),t.lineTo(6,3),t.moveTo(3,6),t.lineTo(6,9),t.stroke(),t.closePath(),t.restore()}}class bl{draw;position;options;elementList;rowList;positionList;constructor(t){this.draw=t,this.position=t.getPosition(),this.options=t.getOptions(),this.elementList=[],this.rowList=[],this.positionList=[]}_recovery(){this.elementList=[],this.rowList=[],this.positionList=[]}_compute(t){this._computeRowList(),this._computePositionList(t)}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(t){const{lineBreak:e,scale:n}=this.options,i=this.draw.getHeader().getExtraHeight(),l=this.draw.getInnerWidth(),r=this.draw.getMargins();let a=r[3];e.disabled||(a+=(To.WIDTH+To.GAP)*n);const c=t?.startY||r[0]+i;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:a,startY:c,innerWidth:l})}render(t,e){const{placeholder:n=this.options.placeholder}=e||{},{data:i,font:l,size:r,color:a,opacity:c}=n;this._recovery(),this.elementList=[{value:i,font:l,size:r,color:a}],jt(this.elementList,{editorOptions:this.options,isForceCompensation:!0}),this._compute(e);const d=this.draw.getInnerWidth();t.save(),t.globalAlpha=c,this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:this.rowList,pageNo:0,startIndex:0,innerWidth:d,isDrawLineBreak:!1}),t.restore()}}class ET{draw;options;range;fillRectMap;constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==s.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=ft();return t.forEach(n=>{Array.isArray(n.groupIds)||(n.groupIds=[]),n.groupIds.push(e)}),this.draw.render({isSetCursor:!1,isCompute:!1}),e}getElementListByGroupId(t,e){const n=[];for(let i=0;i<t.length;i++){const l=t[i];if(l.type===s.ElementType.TABLE){const r=l.trList;for(let a=0;a<r.length;a++){const c=r[a];for(let d=0;d<c.tdList.length;d++){const u=c.tdList[d],R=this.getElementListByGroupId(u.value,e);if(R.length)return n.push(...R),n}}}if(l?.groupIds?.includes(e)&&(n.push(l),!t[i+1]?.groupIds?.includes(e)))break}return n}deleteGroup(t){if(this.draw.isReadonly())return;const e=this.draw.getOriginalMainElementList(),n=this.getElementListByGroupId(e,t);if(n.length){for(let i=0;i<n.length;i++){const l=n[i],r=l.groupIds,a=r.findIndex(c=>c===t);r.splice(a,1),r.length||delete l.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){for(let n=0;n<t.length;n++){const i=t[n];if(i.type===s.ElementType.TABLE){const r=i.trList;for(let a=0;a<r.length;a++){const c=r[a];for(let d=0;d<c.tdList.length;d++){const u=c.tdList[d],R=this.getContextByGroupId(u.value,e);if(R)return{...R,isTable:!0,index:n,trIndex:a,tdIndex:d,tdId:u.id,trId:c.id,tableId:i.tableId}}}}const l=t[n+1];if(i.groupIds?.includes(e)&&!l?.groupIds?.includes(e))return{isTable:!1,startIndex:n,endIndex:n}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,n,i,l){const r=t.groupIds;if(r)for(const a of r){const c=this.fillRectMap.get(a);c?c.width+=i:this.fillRectMap.set(a,{x:e,y:n,width:i,height:l})}}render(t){if(!this.fillRectMap.size)return;const e=this.range.getRange(),i=this.draw.getElementList()[e.endIndex]?.groupIds,{group:{backgroundColor:l,opacity:r,activeOpacity:a,activeBackgroundColor:c}}=this.options;t.save(),this.fillRectMap.forEach((d,u)=>{const{x:R,y:h,width:g,height:T}=d;i?.includes(u)?(t.globalAlpha=a,t.fillStyle=c):(t.globalAlpha=r,t.fillStyle=l),t.fillRect(R,h,g,T)}),t.restore(),this.clearFillInfo()}}class MT{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:l,whiteSpace:{color:r,radius:a}}=this.options,c=e.metrics;t.save(),t.fillStyle=r,t.beginPath(),t.arc(n+c.width/2,i,a*l,0,Math.PI*2),t.fill(),t.closePath(),t.restore()}}class OT{draw;eventBus;pageContainer;constructor(t){this.draw=t,this.eventBus=this.draw.getEventBus(),this.pageContainer=this.draw.getPageContainer(),this.pageContainer.addEventListener("mousemove",this._mousemove.bind(this)),this.pageContainer.addEventListener("mouseenter",this._mouseenter.bind(this)),this.pageContainer.addEventListener("mouseleave",this._mouseleave.bind(this)),this.pageContainer.addEventListener("mousedown",this._mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this._mouseup.bind(this)),this.pageContainer.addEventListener("click",this._click.bind(this))}_mousemove(t){this.eventBus.isSubscribe("mousemove")&&this.eventBus.emit("mousemove",t)}_mouseenter(t){this.eventBus.isSubscribe("mouseenter")&&this.eventBus.emit("mouseenter",t)}_mouseleave(t){this.eventBus.isSubscribe("mouseleave")&&this.eventBus.emit("mouseleave",t)}_mousedown(t){this.eventBus.isSubscribe("mousedown")&&this.eventBus.emit("mousedown",t)}_mouseup(t){this.eventBus.isSubscribe("mouseup")&&this.eventBus.emit("mouseup",t)}_click(t){this.eventBus.isSubscribe("click")&&this.eventBus.emit("click",t)}}class ST{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:n,lineNumber:{color:i,size:l,font:r,right:a,type:c}}=this.options,d=this.draw.getTextParticle(),u=this.draw.getMargins(),R=this.draw.getPosition().getOriginalMainPositionList(),g=this.draw.getPageRowList()[e];t.save(),t.fillStyle=i,t.font=`${l*n}px ${r}`;for(let T=0;T<g.length;T++){const f=g[T],{coordinate:{leftBottom:p}}=R[f.startIndex],C=c===s.LineNumberType.PAGE?T+1:f.rowIndex+1,I=d.measureText(t,{value:`${C}`}),m=u[3]-(I.width+a)*n,P=p[1]-I.actualBoundingBoxAscent*n;t.fillText(`${C}`,m,P)}t.restore()}}class XT{draw;header;footer;options;constructor(t){this.draw=t,this.header=t.getHeader(),this.footer=t.getFooter(),this.options=t.getOptions()}render(t){const{scale:e,pageBorder:{color:n,lineWidth:i,padding:l}}=this.options;t.save(),t.translate(.5,.5),t.strokeStyle=n,t.lineWidth=i*e;const r=this.draw.getMargins(),a=r[3]-l[3]*e,c=r[0]+this.header.getExtraHeight()-l[0]*e,d=this.draw.getInnerWidth()+(l[1]+l[3])*e,u=this.draw.getHeight()-c-this.footer.getExtraHeight()-r[2]+l[2]*e;t.rect(a,c,d,u),t.stroke(),t.restore()}}function NT(o,t){const{value:e,oldValue:n}=t;n.isTable&&!e.isTable&&o.getTableTool().dispose()}class FT{draw;eventBus;constructor(t){this.draw=t,this.eventBus=t.getEventBus(),this.execute()}execute(){this.eventBus.on("positionContextChange",t=>{NT(this.draw,t)})}}class yT{draw;range;position;tableTool;tableParticle;options;constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.tableTool=t.getTableTool(),this.tableParticle=t.getTableParticle(),this.options=t.getOptions()}insertTable(t,e){const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{defaultTrMinHeight:l}=this.options.table,r=this.draw.getElementList();let a=0;if(r[n]?.listId){const T=this.position.getPositionList(),{rowIndex:f}=T[n];a=this.draw.getRowList()[f]?.offsetX||0}const c=this.draw.getContextInnerWidth()-a,d=[],u=c/e;for(let T=0;T<e;T++)d.push({width:u});const R=[];for(let T=0;T<t;T++){const f=[],p={height:l,tdList:f};for(let C=0;C<e;C++)f.push({colspan:1,rowspan:1,value:[]});R.push(p)}const h={type:s.ElementType.TABLE,value:"",colgroup:d,trList:R};jt([h],{editorOptions:this.options}),oe(r,[h],n,{editorOptions:this.options});const g=n+1;this.draw.spliceElementList(r,g,n===i?0:i-n,[h]),this.range.setRange(g,g),this.draw.render({curIndex:g,isSetCursor:!1})}insertTableTopRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=a[n];if(c.tdList.length<r.colgroup.length){const R=c.tdList[0].rowIndex;for(let h=0;h<n;h++){const g=a[h];for(let T=0;T<g.tdList.length;T++){const f=g.tdList[T];f.rowspan>1&&f.rowIndex+f.rowspan>=R+1&&(f.rowspan+=1)}}}const d=ft(),u={height:c.height,id:d,tdList:[]};for(let R=0;R<c.tdList.length;R++){const h=c.tdList[R],g=ft();u.tdList.push({id:g,rowspan:1,colspan:h.colspan,value:[{value:K,size:16,tableId:i,trId:d,tdId:g}]})}a.splice(n,0,u),this.position.setPositionContext({isTable:!0,index:e,trIndex:n,tdIndex:0,tdId:u.tdList[0].id,trId:u.id,tableId:i}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableBottomRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=a[n],d=a.length-1===n?c:a[n+1];if(d.tdList.length<r.colgroup.length){const h=d.tdList[0].rowIndex;for(let g=0;g<n+1;g++){const T=a[g];for(let f=0;f<T.tdList.length;f++){const p=T.tdList[f];p.rowspan>1&&p.rowIndex+p.rowspan>=h+1&&(p.rowspan+=1)}}}const u=ft(),R={height:d.height,id:u,tdList:[]};for(let h=0;h<d.tdList.length;h++){const g=d.tdList[h],T=ft();R.tdList.push({id:T,rowspan:1,colspan:g.colspan,value:[{value:K,size:16,tableId:i,trId:u,tdId:T}]})}a.splice(n+1,0,R),this.position.setPositionContext({isTable:!0,index:e,trIndex:n+1,tdIndex:0,tdId:R.tdList[0].id,trId:R.id,tableId:r.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}adjustColWidth(t){if(t.type!==s.ElementType.TABLE)return;const{defaultColMinWidth:e}=this.options.table,n=t.colgroup,i=n.reduce((r,a)=>r+a.width,0),l=this.draw.getOriginalInnerWidth();if(i>l){const r=n.filter(c=>c.width>e),a=(i-l)/r.length;for(let c=0;c<n.length;c++){const d=n[c];d.width-a>=e&&(d.width-=a)}}}insertTableLeftCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=n;for(let R=0;R<a.length;R++){const h=a[R],g=ft();h.tdList.splice(c,0,{id:g,rowspan:1,colspan:1,value:[{value:K,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:d}=this.options.table;r.colgroup.splice(c,0,{width:d}),this.adjustColWidth(r),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:c,tdId:a[0].tdList[c].id,trId:a[0].id,tableId:i}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableRightCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=n+1;for(let R=0;R<a.length;R++){const h=a[R],g=ft();h.tdList.splice(c,0,{id:g,rowspan:1,colspan:1,value:[{value:K,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:d}=this.options.table;r.colgroup.splice(c,0,{width:d}),this.adjustColWidth(r),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:c,tdId:a[0].tdList[c].id,trId:a[0].id,tableId:r.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}deleteTableRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tdIndex:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=a[n],d=c.tdList[i].rowIndex;if(a.length<=1&&r.pagingIndex===0){this.deleteTable();return}for(let u=0;u<d;u++){const h=a[u].tdList;for(let g=0;g<h.length;g++){const T=h[g];T.rowIndex+T.rowspan>d&&T.rowspan--}}for(let u=0;u<c.tdList.length;u++){const R=c.tdList[u];if(R.rowspan>1){const h=ft(),g=a[n+1];g.tdList.splice(u,0,{id:h,rowspan:R.rowspan-1,colspan:R.colspan,value:[{value:K,size:16,tableId:r.id,trId:g.id,tdId:h}]})}}a.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.clearRange(),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTableCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,d=a[i].tdList[n].colIndex;if(!a.find(R=>R.tdList.length>1)){this.deleteTable();return}for(let R=0;R<a.length;R++){const h=a[R];for(let g=0;g<h.tdList.length;g++){const T=h.tdList[g];T.colIndex<=d&&T.colIndex+T.colspan>d&&(T.colspan>1?T.colspan--:h.tdList.splice(g,1))}}r.colgroup?.splice(d,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTable(){const t=this.position.getPositionContext();if(!t.isTable)return;const e=this.draw.getOriginalElementList(),n=e[t.index];let i=1,l=t.index;if(n.pagingId){l=t.index-n.pagingIndex;for(let a=l+1;a<e.length&&e[a].pagingId===n.pagingId;a++)i++}e.splice(l,i);const r=l-1;this.position.setPositionContext({isTable:!1,index:r}),this.range.setRange(r,r),this.draw.render({curIndex:r}),this.tableTool.dispose()}mergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{isCrossRowCol:e,startTdIndex:n,endTdIndex:i,startTrIndex:l,endTrIndex:r}=this.range.getRange();if(!e)return;const{index:a}=t,u=this.draw.getOriginalElementList()[a].trList;let R=u[l].tdList[n],h=u[r].tdList[i];(R.x>h.x||R.y>h.y)&&([R,h]=[h,R]);const g=R.colIndex,T=h.colIndex+(h.colspan-1),f=R.rowIndex,p=h.rowIndex+(h.rowspan-1),C=[];for(let V=0;V<u.length;V++){const X=u[V],N=[];for(let L=0;L<X.tdList.length;L++){const W=X.tdList[L],S=W.colIndex,U=W.rowIndex;S>=g&&S<=T&&U>=f&&U<=p&&N.push(W)}N.length&&C.push(N)}if(!C.length)return;const I=C[C.length-1],m=C[0][0],P=I[I.length-1],E=m.x,M=m.y,F=P.x+P.width,y=P.y+P.height;for(let V=0;V<C.length;V++){const X=C[V];for(let N=0;N<X.length;N++){const L=X[N],W=L.x,S=L.y,U=W+L.width,v=S+L.height;if(E>W||M>S||F<U||y<v)return}}const Y=[],D=C[0][0],O=D.value[0];for(let V=0;V<C.length;V++){const X=C[V];for(let N=0;N<X.length;N++){const L=X[N];if(!(V===0&&N===0)){Y.push(L.id);const S=L.value.length>1?0:1;for(let U=S;U<L.value.length;U++){const v=L.value[U];an(pn,O,v),D.value.push(v)}}V===0&&N!==0&&(D.colspan+=L.colspan),V!==0&&D.colIndex===L.colIndex&&(D.rowspan+=L.rowspan)}}for(let V=0;V<u.length;V++){const X=u[V];let N=0;for(;N<X.tdList.length;){const L=X.tdList[N];Y.includes(L.id)&&(X.tdList.splice(N,1),N--),N++}}this.position.setPositionContext({...t,trIndex:D.trIndex,tdIndex:D.tdIndex});const b=D.value.length-1;this.range.setRange(b,b),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=a[i],d=c.tdList[n];if(d.rowspan===1&&d.colspan===1)return;const u=d.colspan;if(d.colspan>1){for(let h=1;h<d.colspan;h++){const g=ft();c.tdList.splice(n+h,0,{id:g,rowspan:1,colspan:1,value:[{value:K,size:16,tableId:r.id,trId:c.id,tdId:g}]})}d.colspan=1}if(d.rowspan>1){for(let h=1;h<d.rowspan;h++){const g=a[i+h];for(let T=0;T<u;T++){const f=ft();g.tdList.splice(d.colIndex,0,{id:f,rowspan:1,colspan:1,value:[{value:K,size:16,tableId:r.id,trId:g.id,tdId:f}]})}}d.rowspan=1}const R=d.value.length-1;this.range.setRange(R,R),this.draw.render(),this.tableTool.render()}splitVerticalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:l}=t,a=this.draw.getOriginalElementList()[n],c=a.trList,d=c[l],u=d.tdList[i];a.colgroup.splice(i+1,0,{width:this.options.table.defaultColMinWidth});for(let R=0;R<c.length;R++){const h=c[R];let g=0;for(;g<h.tdList.length;){const T=h.tdList[g];if(T.rowIndex!==u.rowIndex)T.colIndex<=u.colIndex&&T.colIndex+T.colspan>u.colIndex&&T.colspan++;else if(T.id===u.id){const f=ft();d.tdList.splice(g+u.colspan,0,{id:f,rowspan:u.rowspan,colspan:1,value:[{value:K,size:16,tableId:a.id,trId:h.id,tdId:f}]}),g++}g++}}this.draw.render(),this.tableTool.render()}splitHorizontalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:l}=t,a=this.draw.getOriginalElementList()[n],c=a.trList,u=c[l].tdList[i];let R=-1,h=0;for(;h<c.length;){if(h===R){h++;continue}const g=c[h];let T=0;for(;T<g.tdList.length;){const f=g.tdList[T];if(f.id===u.id){const p=ft(),C=ft();c.splice(h+u.rowspan,0,{id:p,height:this.options.table.defaultTrMinHeight,tdList:[{id:C,rowspan:1,colspan:u.colspan,value:[{value:K,size:16,tableId:a.id,trId:p,tdId:C}]}]}),R=h+u.rowspan}else f.rowIndex>=u.rowIndex&&f.rowIndex<u.rowIndex+u.rowspan&&f.rowIndex+f.rowspan>=u.rowIndex+u.rowspan&&f.rowspan++;T++}h++}this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const l=e[i];for(let r=0;r<l.length;r++){const a=l[r];!a||a.verticalAlign===t||!a.verticalAlign&&t===s.VerticalAlign.TOP||(a.verticalAlign=t)}}const{endIndex:n}=this.range.getRange();this.draw.render({curIndex:n})}tableBorderType(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,l=this.draw.getOriginalElementList()[n];if(!l.borderType&&t===s.TableBorder.ALL||l.borderType===t)return;l.borderType=t;const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableBorderColor(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,l=this.draw.getOriginalElementList()[n];if(!l.borderColor&&t===this.options.table.defaultBorderColor||l.borderColor===t)return;l.borderColor=t;const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r,isCompute:!1})}tableTdBorderType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(r=>!r.borderTypes?.includes(t));n.forEach(r=>{r.borderTypes||(r.borderTypes=[]);const a=r.borderTypes.findIndex(c=>c===t);i?~a||r.borderTypes.push(t):~a&&r.borderTypes.splice(a,1),r.borderTypes.length||delete r.borderTypes});const{endIndex:l}=this.range.getRange();this.draw.render({curIndex:l})}tableTdSlashType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(r=>!r.slashTypes?.includes(t));n.forEach(r=>{r.slashTypes||(r.slashTypes=[]);const a=r.slashTypes.findIndex(c=>c===t);i?~a||r.slashTypes.push(t):~a&&r.slashTypes.splice(a,1),r.slashTypes.length||delete r.slashTypes});const{endIndex:l}=this.range.getRange();this.draw.render({curIndex:l})}tableTdBackgroundColor(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const l=e[i];for(let r=0;r<l.length;r++){const a=l[r];a.backgroundColor=t}}const{endIndex:n}=this.range.getRange();this.range.setRange(n,n),this.draw.render({isCompute:!1})}tableSelectAll(){const t=this.position.getPositionContext(),{index:e,tableId:n,isTable:i}=t;if(!i||!n)return;const{startIndex:l,endIndex:r}=this.range.getRange(),c=this.draw.getOriginalElementList()[e].trList,d=c.length-1,u=c[d].tdList.length-1;this.range.replaceRange({startIndex:l,endIndex:r,tableId:n,startTdIndex:0,endTdIndex:u,startTrIndex:0,endTrIndex:d}),this.draw.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1})}tableProperties(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e}=t,i=this.draw.getOriginalElementList()[e],l=this.draw.getOptions().table.tdPadding,r=i.tdPadding||l,a=document.createElement("div");a.className="table-properties-modal",a.setAttribute("editor-component","table-properties-modal"),a.innerHTML=`
523
+ `,Xl=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Sl],{type:"text/javascript;charset=utf-8"});function cT(o){let t;try{if(t=Xl&&(self.URL||self.webkitURL).createObjectURL(Xl),!t)throw"";const e=new Worker(t,{name:o?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Sl),{name:o?.name})}}const Nl='(function(){"use strict";var m=(t=>(t.HALF="half",t.ONE_THIRD="one-third",t.QUARTER="quarter",t))(m||{}),M=(t=>(t.ARABIC="arabic",t.CHINESE="chinese",t))(M||{});const K="​";m.HALF+"",1/2,m.ONE_THIRD+"",1/3,m.QUARTER+"",1/4;function b(t){if(typeof structuredClone=="function")return structuredClone(t);if(!t||typeof t!="object")return t;let d={};return Array.isArray(t)?d=t.map(f=>b(f)):Object.keys(t).forEach(f=>{d[f]=b(t[f])}),d}function D(t,d){const f={};for(const S in t)d.includes(S)&&(f[S]=t[S]);return f}function et(t,d){return t.length!==d.length?!1:!t.some(f=>!d.includes(f))}var o=(t=>(t.TEXT="text",t.TEXTFIELD="TextField",t.BUTTON="button",t.IMAGE="image",t.TABLE="table",t.HYPERLINK="hyperlink",t.SUPERSCRIPT="superscript",t.SUBSCRIPT="subscript",t.SEPARATOR="separator",t.PAGE_BREAK="pageBreak",t.CONTROL="control",t.AREA="area",t.CHECKBOX="checkbox",t.RADIO="radio",t.LATEX="latex",t.TAB="tab",t.DATE="date",t.BLOCK="block",t.TITLE="title",t.LIST="list",t.SPLIT_TAG="splitTag",t.LABEL="label",t.MENSTRUAL_HISTORY="menstrualHistory",t.FETAL_HEART_POSITION="fetalHeartPosition",t.TOOTH_POSITION="toothPosition",t.SPECIAL_SYMBOLS="specialSymbols",t.MACRO="macro",t.CUSTOM_MACRO="customMacro",t.REUSABLE_ITEM="reusableItem",t.SUB_TEMPLATE="subTemplate",t))(o||{});const y=["rowFlex","rowMargin"],ot=["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"],nt=["conceptId","extension","externalId","verticalAlign","backgroundColor","borderTypes","slashTypes","disabled","deletable"],w=["font","size","bold","highlight","italic","strikeout","deletePerson","newElEditPerson","deleteTime","color","newElEditTime"];o.TEXT,o.HYPERLINK,o.SUBSCRIPT,o.SUPERSCRIPT,o.CONTROL,o.DATE,o.IMAGE,o.LATEX,o.BLOCK,o.PAGE_BREAK,o.SEPARATOR,o.TABLE,o.TITLE,o.LIST;var Y=(t=>(t.UL="ul",t.OL="ol",t))(Y||{}),N=(t=>(t.DISC="disc",t.CIRCLE="circle",t.SQUARE="square",t.CHECKBOX="checkbox",t))(N||{}),_=(t=>(t.DISC="disc",t.CIRCLE="circle",t.SQUARE="square",t.DECIMAL="decimal",t.CHECKBOX="checkbox",t))(_||{});N.DISC+"",N.CIRCLE+"",N.SQUARE+"",N.CHECKBOX+"",Y.OL+"",Y.UL+"",_.DISC+"",_.CIRCLE+"",_.SQUARE+"",_.DECIMAL+"",_.CHECKBOX+"";var p=(t=>(t.FIRST="first",t.SECOND="second",t.THIRD="third",t.FOURTH="fourth",t.FIFTH="fifth",t.SIXTH="sixth",t))(p||{});p.FIRST+"",p.SECOND+"",p.THIRD+"",p.FOURTH+"",p.FIFTH+"",p.SIXTH+"",p.FIRST+"",p.SECOND+"",p.THIRD+"",p.FOURTH+"",p.FIFTH+"",p.SIXTH+"",p.FIRST,p.SECOND,p.THIRD,p.FOURTH,p.FIFTH,p.SIXTH;var L=(t=>(t.TEXT="text",t.SELECT="select",t.CHECKBOX="checkbox",t.RADIO="radio",t.DATE="date",t.NUMBER="number",t.TEXTFIELD="TextField",t.BUTTON="button",t.MENSTRUAL_HISTORY="menstrualHistory",t))(L||{}),n=(t=>(t.PREFIX="prefix",t.POSTFIX="postfix",t.PRE_TEXT="preText",t.PRETEXTFIX="preTextFix",t.PRETEXTFIX_TEXT="preTextFixText",t.POSTTEXTFIX="postTextFix",t.POSTTEXTFIX_TEXT="postTextFixText",t.POST_TEXT="postText",t.PLACEHOLDER="placeholder",t.TEXTFIXLABEL="textFixLabel",t.VALUE="value",t.DELETEPERSON="deletePerson",t.CHECKBOX="checkbox",t.RADIO="radio",t.UNDERLINE="underline",t))(n||{}),q=(t=>(t.LEFT="left",t.CENTER="center",t.RIGHT="right",t.ALIGNMENT="alignment",t.JUSTIFY="justify",t))(q||{}),W=(t=>(t.CONTAIN="contain",t.COVER="cover",t))(W||{}),Z=(t=>(t.REPEAT="repeat",t.NO_REPEAT="no-repeat",t.REPEAT_X="repeat-x",t.REPEAT_Y="repeat-y",t))(Z||{});W.COVER,Z.NO_REPEAT;var z=(t=>(t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom",t))(z||{});z.BOTTOM,m.HALF,m.HALF,q.CENTER,M.ARABIC,z.BOTTOM;var j=(t=>(t.TEXT="text",t.IMAGE="image",t))(j||{});j.TEXT,M.ARABIC;var J=(t=>(t.PAGE="page",t.CONTINUITY="continuity",t))(J||{});J.CONTINUITY,L.NUMBER,L.SELECT,L.DATE,L.CHECKBOX,L.RADIO,n.PREFIX,n.POSTFIX,n.PRE_TEXT,n.POST_TEXT,n.PRETEXTFIX,n.PRETEXTFIX_TEXT,n.POSTTEXTFIX,n.POSTTEXTFIX_TEXT,n.PLACEHOLDER,n.TEXTFIXLABEL,n.CHECKBOX,n.RADIO,n.UNDERLINE;function lt(t,d){const f=Object.keys(t),S=Object.keys(d);if(f.length!==S.length)return!1;for(let X=0;X<f.length;X++){const R=f[X];if(R!=="value"&&!(R==="groupIds"&&Array.isArray(t[R])&&Array.isArray(d[R])&&et(t[R],d[R]))&&t[R]!==d[R])return!1}return!0}function B(t,d={}){const{extraPickAttrs:f}=d,S=[...ot];f&&S.push(...f);const X={value:t?.value===K?`\n`:t?.value};return t&&S.forEach(R=>{const T=t[R];T!==void 0&&(X[R]=T)}),X}function P(t,d={}){const{extraPickAttrs:f,isClassifyArea:S=!1,isClone:X=!0,editorOptions:R}=d,T=(X?b(t):t).filter(e=>e.type!==o.SPLIT_TAG),k=[];let r=0;for(;r<T.length;){let e=T[r];if(r===0&&e.value===K&&!e.listId&&(!e.type||e.type===o.TEXT)){r++;continue}if(e.areaId){const s=e.areaId,O=e.area,E=[];for(;r<T.length;){const i=T[r];if(s!==i.areaId){r--;break}delete i.area,delete i.areaId,E.push(i),r++}const a=P(E,d);if(S){const i={type:o.AREA,value:"",areaId:s,area:O};i.valueList=a,e=i}else{k.splice(r,0,...a);continue}}else if(e.titleId&&e.level){const s=e.titleId;if(s){const O=e.level,E={type:o.TITLE,title:e.title,titleId:s,value:"",level:O},a=[];for(;r<T.length;){const i=T[r];if(s!==i.titleId){r--;break}delete i.level,delete i.title,a.push(i),r++}E.valueList=P(a,d),e=E}}else if(e.listId&&e.listType){const s=e.listId;if(s){const O=e.listType,E=e.listStyle,a=e?.label,i={type:o.LIST,value:"",label:a||"",listId:s,listType:O,listStyle:E},I=[];for(;r<T.length;){const c=T[r];if(s!==c.listId){r--;break}delete c.listType,delete c.listStyle,I.push(c),r++}i.valueList=P(I,d),e=i}}else if(e.type===o.TABLE){if(e.pagingId){let s=r+1,O=0;for(;s<T.length;){const E=T[s];if(E.pagingId===e.pagingId){e.height+=E.height;const a=E.trList.filter(i=>!i.pagingRepeat).filter(i=>(i.tdList=i.tdList.filter(I=>{if(I.originalId){for(let c=0;c<e.trList.length;c++){const u=e.trList[c].tdList.find(({id:l})=>l===I.originalId);if(u){I.value[0]?.type===o.SPLIT_TAG&&I.value.splice(0,1),u.value.push(...I.value),u.rowspan=u.originalRowspan??u.rowspan;break}}return!1}return!0}),!i.originalId));e.trList.push(...a),e.trList?.forEach(i=>i.minHeight=i.originalMinHeight??i.minHeight),s++,O++}else break}r+=O}if(e.trList)for(let s=0;s<e.trList.length;s++){const O=e.trList[s];delete O.id;for(let E=0;E<O.tdList.length;E++){const a=O.tdList[E],i={colspan:a.colspan,rowspan:a.rowspan,value:P(a.value,{...d,isClassifyArea:!1})};nt.forEach(I=>{const c=a[I];c!==void 0&&(i[I]=c)}),O.tdList[E]=i}}}else if(e.type===o.HYPERLINK){const s=e.hyperlinkId;if(s){const O={type:o.HYPERLINK,value:"",url:e.url},E=[];for(;r<T.length;){const a=T[r];if(s!==a.hyperlinkId){r--;break}delete a.type,delete a.url,E.push(a),r++}O.valueList=P(E,d),e=O}}else if(e.type===o.DATE){const s=e.dateId;if(s){const O={type:o.DATE,value:"",dateFormat:e.dateFormat},E=[];for(;r<T.length;){const a=T[r];if(s!==a.dateId){r--;break}delete a.type,delete a.dateFormat,E.push(a),r++}O.valueList=P(E,d),e=O}}else if(e.type!==o.BUTTON){if(e.controlId){const s=e.controlId;if(!(e.controlComponent===n.PREFIX||e.controlComponent===n.PRETEXTFIX||e.controlComponent===n.PRETEXTFIX_TEXT)&&e.controlComponent===n.VALUE){if(e.type===o.MENSTRUAL_HISTORY||e.type===o.FETAL_HEART_POSITION||e.type===o.TOOTH_POSITION||e.type===o.MACRO||e.type===o.CUSTOM_MACRO||e.type===o.REUSABLE_ITEM||e.type===o.LIST||e.type===o.SPECIAL_SYMBOLS){let I=!1;for(let c=r-1;c>=0;c--){const C=T[c],u=C.controlComponent===n.PREFIX||C.controlComponent===n.PRETEXTFIX||C.controlComponent===n.PRETEXTFIX_TEXT;if(C.controlId===s&&u){I=!0;break}if(C.controlId!==s)break}if(!I){const c=b(e);delete c.controlId,delete c.control,delete c.controlComponent,delete c.originControlId,k.push(c),r++;continue}}r++;continue}if(e.controlComponent===n.PLACEHOLDER||e.controlComponent===n.POSTFIX||e.controlComponent===n.POSTTEXTFIX||e.controlComponent===n.POSTTEXTFIX_TEXT||e.controlComponent===n.POST_TEXT||e.controlComponent===n.PRE_TEXT||e.controlComponent===n.CHECKBOX||e.controlComponent===n.RADIO){r++;continue}const E=(i,I,c,C)=>{if(C===L.CHECKBOX||C===L.RADIO){let l=-1;for(let v=i;v<T.length&&T[v].controlId===I;v++)l=v;return l}const u=c?[n.POSTTEXTFIX,n.POSTTEXTFIX_TEXT]:[n.POSTFIX];for(let l=i;l<T.length;l++){const v=T[l];if(v.controlId===I&&u.includes(v.controlComponent))return l}return-1},a=(i,I,c)=>{const C=[];let u=i;for(;u<=I;){const l=T[u];if(l.controlId&&l.controlId!==c&&l.control){const A=l.control?.type,g=A===L.TEXTFIELD,h=g?n.PRETEXTFIX:n.PREFIX,H=l.controlComponent===h,x=A===L.CHECKBOX||A===L.RADIO;if(H||x&&(l.controlComponent===n.CHECKBOX||l.controlComponent===n.RADIO)){const F=E(u+1,l.controlId,g,A);if(F!==-1){const Q=T.slice(u,F+1).map(it=>{const tt=b(it);return delete tt.originControlId,tt}),U=P(Q,d);U.length>0&&C.push(U[0]),u=F+1;continue}}}if(!(l.controlId===c&&(l.controlComponent===n.VALUE||!l.controlComponent)&&(!l.originControlId||l.originControlId===c)||l.originControlId===c&&l.controlComponent===n.VALUE||l.controlId===c&&(l.controlComponent===n.CHECKBOX||l.controlComponent===n.RADIO)&&!l.originControlId)){u++;continue}if(l.type===o.MENSTRUAL_HISTORY||l.type===o.FETAL_HEART_POSITION||l.type===o.TOOTH_POSITION||l.type===o.MACRO||l.type===o.CUSTOM_MACRO||l.type===o.REUSABLE_ITEM||l.type===o.LIST||l.type===o.SPECIAL_SYMBOLS){const A=b(l);delete A.controlId,delete A.control,delete A.controlComponent,delete A.originControlId,C.push(A),u++;continue}if(l.controlComponent===n.CHECKBOX||l.controlComponent===n.RADIO){C.push(b(l)),u++;continue}const $=e.control?.type;if($===L.CHECKBOX||$===L.RADIO){let A=u-1,g=!1;for(;A>=i-1;){const h=T[A];if(h.controlId===c&&!h.originControlId)if(h.controlComponent===n.CHECKBOX){g=h.checkbox?.value===!0;break}else if(h.controlComponent===n.RADIO){g=h.radio?.value===!0;break}else if(h.controlComponent===n.VALUE){A--;continue}else break;A--}if(g){const h={value:l.value||""},H=[...y,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"];for(const x of H){const F=l[x];if(F!==void 0){if(x==="color"&&R){const Q=R.control?.bracketColor,U=R.control?.placeholderColor;if(F===Q||F===U)continue}h[x]=F}}C.push(h)}}else{const A={value:l.value||""},g=[...y,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"];for(const h of g){const H=l[h];if(H!==void 0){if(h==="color"&&R){const x=R.control?.bracketColor,F=R.control?.placeholderColor;if(H===x||H===F)continue}A[h]=H}}C.push(A)}u++}return C};if(e.controlComponent===n.PREFIX){const i=e.control?.type===L.TEXTFIELD,I=E(r+1,s,i);if(I!==-1){const c=a(r+1,I-1,s),C=D(e,w),l=e.control?.type===L.BUTTON&&!e.control?.buttonText?c.length?c:null:c,v={...e.control,...C,value:l},V={...D(e,y),type:o.CONTROL,value:"",control:v,controlId:s};e=B(V,{extraPickAttrs:f}),r=I}}if(e.controlComponent===n.PRETEXTFIX){const i=E(r+1,s,!0);if(i!==-1){const I=a(r+1,i-1,s),c=D(e,w),C={...e.control,...c,value:I},u={...D(e,y),type:o.CONTROL,value:"",control:C,controlId:s};e=B(u,{extraPickAttrs:f}),r=i}}if(e.controlComponent===n.PRETEXTFIX_TEXT){const i=E(r+1,s,!0);if(i!==-1){const I=a(r+1,i-1,s),c=D(e,w),C={...e.control,...c,value:I},u={...D(e,y),type:o.CONTROL,value:"",control:C,controlId:s};e=B(u,{extraPickAttrs:f}),r=i}}}}const G=B(e,{extraPickAttrs:f});if(!e.type||e.type===o.TEXT||e.type===o.SUBSCRIPT||e.type===o.SUPERSCRIPT)for(;r<T.length;){const s=T[r+1];if(r++,s&&lt(G,B(s,{extraPickAttrs:f}))){const O=s.value===K?`\n`:s.value;G.value+=O}else break}else r++;k.push(G)}return k}onmessage=t=>{const d=t.data,{options:f,data:S}=d,{extraPickAttrs:X=[]}=f||{},R={header:P(S.header,{extraPickAttrs:X,isClone:!1}),main:P(S.main,{extraPickAttrs:X,isClassifyArea:!0,isClone:!1}),footer:P(S.footer,{extraPickAttrs:X,isClone:!1})};postMessage(R)}})();\n',Fl=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Nl],{type:"text/javascript;charset=utf-8"});function dT(o){let t;try{if(t=Fl&&(self.URL||self.webkitURL).createObjectURL(Fl),!t)throw"";const e=new Worker(t,{name:o?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Nl),{name:o?.name})}}class uT{draw;wordCountWorker;catalogWorker;groupWorker;valueWorker;constructor(t){this.draw=t,this.wordCountWorker=new lT,this.catalogWorker=new aT,this.groupWorker=new cT,this.valueWorker=new dT}getWordCount(){return new Promise((t,e)=>{this.wordCountWorker.onmessage=i=>{t(i.data)},this.wordCountWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.wordCountWorker.postMessage(n)})}getCatalog(){return new Promise((t,e)=>{this.catalogWorker.onmessage=l=>{t(l.data)},this.catalogWorker.onerror=l=>{e(l)};const n=this.draw.getOriginalMainElementList(),i=this.draw.getPosition().getOriginalMainPositionList();this.catalogWorker.postMessage({elementList:n,positionList:i})})}getGroupIds(){return new Promise((t,e)=>{this.groupWorker.onmessage=i=>{t(i.data)},this.groupWorker.onerror=i=>{e(i)};const n=this.draw.getOriginalMainElementList();this.groupWorker.postMessage(n)})}getValue(t){return new Promise((e,n)=>{this.valueWorker.onmessage=i=>{e({version:fn,data:i.data,options:ct(this.draw.getOptions())})},this.valueWorker.onerror=i=>{n(i)},this.valueWorker.postMessage({data:this.draw.getOriginValue(t),options:t})})}}class RT{container;canvas;draw;options;curElement;curElementSrc;previewerDrawOption;curPosition;eventBus;imageList;curShowElement;imageCount;imagePre;imageNext;resizerSelection;resizerHandleList;resizerImageContainer;resizerImage;resizerSize;width;height;mousedownX;mousedownY;curHandleIndex;previewerContainer;previewerImage;constructor(t){this.container=t.getContainer(),this.canvas=t.getPage(),this.draw=t,this.options=t.getOptions(),this.curElement=null,this.curElementSrc="",this.previewerDrawOption={},this.curPosition=null,this.eventBus=t.getEventBus(),this.imageList=[],this.curShowElement=null,this.imageCount=null,this.imagePre=null,this.imageNext=null;const{resizerSelection:e,resizerHandleList:n,resizerImageContainer:i,resizerImage:l,resizerSize:r}=this._createResizerDom();this.resizerSelection=e,this.resizerHandleList=n,this.resizerImageContainer=i,this.resizerImage=l,this.resizerSize=r,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.previewerContainer=null,this.previewerImage=null}_getElementPosition(t,e=null){const{scale:n}=this.options;let i=0,l=0;const r=this.draw.getHeight(),a=this.draw.getPageGap(),d=(e?.pageNo??this.draw.getPageNo())*(r+a);if(t.imgFloatPosition)i=t.imgFloatPosition.x*n,l=t.imgFloatPosition.y*n+d;else if(e){const{coordinate:{leftTop:[u,R]},ascent:h}=e;i=u,l=R+d+h}return{x:i,y:l}}_createResizerDom(){const{scale:t}=this.options,e=document.createElement("div");e.classList.add(`${rt}-resizer-selection`),e.style.display="none",e.style.borderColor=this.options.resizerColor,e.style.borderWidth=`${t}px`;const n=[];for(let c=0;c<8;c++){const d=document.createElement("div");d.style.background=this.options.resizerColor,d.classList.add("resizer-handle"),d.classList.add(`handle-${c}`),d.setAttribute("data-index",String(c)),d.onmousedown=this._mousedown.bind(this),e.append(d),n.push(d)}this.container.append(e);const i=document.createElement("div");i.classList.add(`${rt}-resizer-size-view`);const l=document.createElement("span");i.append(l),e.append(i);const r=document.createElement("div");r.classList.add(`${rt}-resizer-image`),r.style.display="none";const a=document.createElement("img");return r.append(a),this.container.append(r),{resizerSelection:e,resizerHandleList:n,resizerImageContainer:r,resizerImage:a,resizerSize:l}}_keydown=()=>{this.resizerSelection.style.display==="block"&&(this.clearResizer(),document.removeEventListener("keydown",this._keydown))};_mousedown(t){if(this.canvas=this.draw.getPage(),!this.curElement)return;const{scale:e}=this.options;this.mousedownX=t.x,this.mousedownY=t.y;const n=t.target;this.curHandleIndex=Number(n.dataset.index);const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,this.canvas.style.cursor=i,this.resizerImage.src=this.curElementSrc,this.resizerImageContainer.style.display="block";const{x:l,y:r}=this._getElementPosition(this.curElement,this.curPosition);this.resizerImageContainer.style.left=`${l}px`,this.resizerImageContainer.style.top=`${r}px`,this.resizerImage.style.width=`${this.curElement.width*e}px`,this.resizerImage.style.height=`${this.curElement.height*e}px`;const a=this._mousemove.bind(this);document.addEventListener("mousemove",a),document.addEventListener("mouseup",()=>{this.curElement&&!this.previewerDrawOption.dragDisable&&(this.curElement.width=this.width,this.curElement.height=this.height,this.draw.render({isSetCursor:!0,curIndex:this.curPosition?.index})),this.resizerImageContainer.style.display="none",document.removeEventListener("mousemove",a),document.body.style.cursor="",this.canvas.style.cursor="text"},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.curElement||this.previewerDrawOption.dragDisable)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const d=this.mousedownX-t.x,u=this.mousedownY-t.y;n=Math.cbrt(d**3+u**3),i=this.curElement.height*n/this.curElement.width}break;case 1:i=this.mousedownY-t.y;break;case 2:{const d=t.x-this.mousedownX,u=this.mousedownY-t.y;n=Math.cbrt(d**3+u**3),i=this.curElement.height*n/this.curElement.width}break;case 4:{const d=t.x-this.mousedownX,u=t.y-this.mousedownY;n=Math.cbrt(d**3+u**3),i=this.curElement.height*n/this.curElement.width}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const d=this.mousedownX-t.x,u=t.y-this.mousedownY;n=Math.cbrt(d**3+u**3),i=this.curElement.height*n/this.curElement.width}break;case 7:n=this.mousedownX-t.x;break}const l=this.curElement.width+n/e,r=this.curElement.height+i/e;if(l<=0||r<=0)return;this.width=l,this.height=r;const a=l*e,c=r*e;this.resizerImage.style.width=`${a}px`,this.resizerImage.style.height=`${c}px`,this._updateResizerRect(a,c),this._updateResizerSizeView(a,c),t.preventDefault(),this.eventBus.isSubscribe("imageSizeChange")&&this.eventBus.emit("imageSizeChange",{element:this.curElement})}_drawPreviewer(){const t=document.createElement("div");t.classList.add(`${rt}-image-previewer`);const e=document.createElement("i");e.classList.add("image-close"),e.onclick=()=>{this._clearPreviewer()},t.append(e);const n=document.createElement("div");n.classList.add(`${rt}-image-container`);const i=document.createElement("img");i.src=this.curElementSrc,i.draggable=!1,n.append(i),this.previewerImage=i,t.append(n);let l=0,r=0,a=1,c=0;const d=document.createElement("div");d.classList.add(`${rt}-image-menu`);const u=document.createElement("div");u.classList.add("image-navigate");const R=document.createElement("i");R.classList.add("image-pre"),R.onclick=()=>{const M=this.imageList.findIndex(F=>F.id===this.curShowElement?.id);M<=0||(this.curShowElement=this.imageList[M-1],i.src=this.curShowElement.value,this._updateImageNavigate())},u.append(R),this.imagePre=R;const h=document.createElement("span");h.classList.add("image-count"),this.imageCount=h,u.append(h);const g=document.createElement("i");g.classList.add("image-next"),g.onclick=()=>{const M=this.imageList.findIndex(F=>F.id===this.curShowElement?.id);M>=this.imageList.length-1||(this.curShowElement=this.imageList[M+1],i.src=this.curShowElement.value,this._updateImageNavigate())},this.imageNext=g,u.append(g),d.append(u);const T=document.createElement("i");T.classList.add("zoom-in"),T.onclick=()=>{a+=.1,this._setPreviewerTransform(a,c,l,r)},d.append(T);const f=document.createElement("i");f.onclick=()=>{a-.1<=.1||(a-=.1,this._setPreviewerTransform(a,c,l,r))},f.classList.add("zoom-out"),d.append(f);const p=document.createElement("i");p.classList.add("rotate"),p.onclick=()=>{c+=1,this._setPreviewerTransform(a,c,l,r)},d.append(p);const C=document.createElement("i");C.classList.add("original-size"),C.onclick=()=>{l=0,r=0,a=1,c=0,this._setPreviewerTransform(a,c,l,r)},d.append(C);const I=document.createElement("i");I.classList.add("image-download"),I.onclick=()=>{const{mime:M}=this.previewerDrawOption;Ss(i.src,`${this.curElement?.id}.${M||"png"}`)},d.append(I),t.append(d),this.previewerContainer=t,document.body.append(t);let m=0,P=0,E=!1;i.onmousedown=M=>{E=!0,m=M.x,P=M.y,t.style.cursor="move"},t.onmousemove=M=>{E&&(l+=M.x-m,r+=M.y-P,m=M.x,P=M.y,this._setPreviewerTransform(a,c,l,r))},t.onmouseup=()=>{E=!1,t.style.cursor="auto"},t.onwheel=M=>{if(M.preventDefault(),M.stopPropagation(),M.deltaY<0)a+=.1;else{if(a-.1<=.1)return;a-=.1}this._setPreviewerTransform(a,c,l,r)},this._updateImageNavigate()}_updateImageNavigate(){const t=this.imageList.findIndex(e=>e.id===this.curShowElement?.id);this.imageCount.innerText=`${t+1} / ${this.imageList.length}`,t<=0?this.imagePre.classList.add("disabled"):this.imagePre.classList.remove("disabled"),t>=this.imageList.length-1?this.imageNext.classList.add("disabled"):this.imageNext.classList.remove("disabled")}_setPreviewerTransform(t,e,n,i){this.previewerImage&&(this.previewerImage.style.left=`${n}px`,this.previewerImage.style.top=`${i}px`,this.previewerImage.style.transform=`scale(${t}) rotate(${e*90}deg)`)}_clearPreviewer(){this.previewerContainer?.remove(),this.previewerContainer=null,document.body.style.overflow="auto"}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options,l=this.draw.isReadonly();this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let r=0;r<8;r++){const a=r===0||r===6||r===7?-n:r===1||r===5?t/2:t-n,c=r===0||r===1||r===2?-n:r===3||r===7?e/2-n:e-n;this.resizerHandleList[r].style.transform=`scale(${i})`,this.resizerHandleList[r].style.left=`${a}px`,this.resizerHandleList[r].style.top=`${c}px`,this.resizerHandleList[r].style.display=l?"none":"block"}}_updateResizerSizeView(t,e){this.resizerSize.innerText=`${Math.round(t)} × ${Math.round(e)}`}render(){const t=this.draw.getMode();!this.curElement||this.curElement.imgToolDisabled&&!this.draw.isDesignMode()||t===s.EditorMode.PRINT&&this.options.modeRule[s.EditorMode.PRINT]?.imagePreviewerDisabled||t===s.EditorMode.COMPARE&&this.options.modeRule[s.EditorMode.COMPARE]?.imagePreviewerDisabled||t===s.EditorMode.READONLY&&this.options.modeRule[s.EditorMode.READONLY]?.imagePreviewerDisabled||(this.imageList=this.draw.getImageParticle().getOriginalMainImageList(),this.curShowElement=this.curElement,this._drawPreviewer(),document.body.style.overflow="hidden")}drawResizer(t,e=null,n={}){const i=this.draw.getMode();t.imgToolDisabled&&!this.draw.isDesignMode()||i===s.EditorMode.PRINT&&this.options.modeRule[s.EditorMode.PRINT]?.imagePreviewerDisabled||i===s.EditorMode.COMPARE&&this.options.modeRule[s.EditorMode.COMPARE]?.imagePreviewerDisabled||i===s.EditorMode.READONLY&&this.options.modeRule[s.EditorMode.READONLY]?.imagePreviewerDisabled||(this.previewerDrawOption=n,this.curElementSrc=t[n.srcKey||"value"]||"",this.updateResizer(t,e),document.addEventListener("keydown",this._keydown))}updateResizer(t,e=null){const{scale:n}=this.options,i=t.width*n,l=t.height*n;this._updateResizerSizeView(i,l);const{x:r,y:a}=this._getElementPosition(t,e);this.resizerSelection.style.left=`${r}px`,this.resizerSelection.style.top=`${a}px`,this.resizerSelection.style.borderWidth=`${n}px`,this._updateResizerRect(i,l),this.resizerSelection.style.display="block",this.curElement=t,this.curPosition=e,this.width=i,this.height=l}clearResizer(){this.resizerSelection.style.display="none",document.removeEventListener("keydown",this._keydown)}}class hT{draw;range;datePicker;options;constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.datePicker=new fl(t,{onSubmit:this._setValue.bind(this)})}_setValue(t){if(!t)return;const e=this.getDateElementRange();if(!e)return;const[n,i]=e,l=this.draw.getElementList(),r=l[n+1];this.draw.spliceElementList(l,n+1,i-n),this.range.setRange(n,n);const a={type:s.ElementType.DATE,value:"",dateFormat:r.dateFormat,valueList:[{value:t}]};oe(l,[a],n,{editorOptions:this.options}),this.draw.insertElementList([a])}getDateElementRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=this.draw.getElementList(),r=l[n];if(r.type!==s.ElementType.DATE)return null;let a=n;for(;a>=0;){if(l[a].dateId!==r.dateId){t=a;break}a--}let c=n+1;for(;c<l.length;){if(l[c].dateId!==r.dateId){e=c-1;break}c++}return c===l.length&&(e=c-1),!~t||!~e?null:[t,e]}clearDatePicker(){this.datePicker.dispose()}renderDatePicker(t,e){const n=this.draw.getElementList(),i=this.getDateElementRange(),l=i?n.slice(i[0]+1,i[1]+1).map(r=>r.value).join(""):"";this.datePicker.render({value:l,position:e,dateFormat:t.dateFormat})}}class yl{element;videoCache;constructor(t){this.element=t,this.videoCache=new Map}snapshot(t,e,n){return new Promise((i,l)=>{const r=this.element.block?.videoBlock?.src||"";if(this.videoCache.has(r)){const a=this.videoCache.get(r);t.drawImage(a,e,n,this.element.metrics.width,this.element.metrics.height),i(this.element)}else{const a=document.createElement("video");a.src=r,a.muted=!0,a.crossOrigin="anonymous",a.onloadeddata=()=>{t.drawImage(a,e,n,this.element.metrics.width,this.element.metrics.height),this.videoCache.set(r,a),i(this.element)},a.onerror=c=>{l(c)},a.play().then(()=>{a.pause()})}})}render(t){const e=this.element.block,n=document.createElement("video");n.style.width="100%",n.style.height="100%",n.style.objectFit="contain",n.src=e.videoBlock?.src||"",n.controls=!0,t.append(n)}}class gT{draw;options;element;block;blockContainer;blockItem;blockCache;resizerMask;resizerSelection;resizerHandleList;width;height;mousedownX;mousedownY;curHandleIndex;isAllowResize;constructor(t,e){this.draw=t.getDraw(),this.options=this.draw.getOptions(),this.blockContainer=t.getBlockContainer(),this.element=e,this.block=null;const{blockItem:n,resizerMask:i,resizerSelection:l,resizerHandleList:r}=this._createBlockItem();this.blockItem=n,this.blockContainer.append(this.blockItem),this.blockCache=new Map,this.resizerMask=i,this.resizerSelection=l,this.resizerHandleList=r,this.width=0,this.height=0,this.mousedownX=0,this.mousedownY=0,this.curHandleIndex=0,this.isAllowResize=!1}getBlockElement(){return this.element}getBlockWidth(){return this.element.width||this.element.metrics.width}_createBlockItem(){const{scale:t,resizerColor:e}=this.options,n=document.createElement("div");n.classList.add(`${rt}-block-item`);const i=document.createElement("div");i.style.display="none",i.classList.add(`${rt}-resizer-selection`),i.style.borderColor=e,i.style.borderWidth=`${t}px`;const l=[];for(let a=0;a<8;a++){const c=document.createElement("div");c.style.background=e,c.classList.add("resizer-handle"),c.classList.add(`handle-${a}`),c.setAttribute("data-index",String(a)),c.onmousedown=this._mousedown.bind(this),i.append(c),l.push(c)}const r=document.createElement("div");return r.classList.add(`${rt}-resizer-mask`),r.style.display="none",n.append(r),n.onmouseenter=()=>{if(this.draw.isReadonly())return;const{width:c,height:d}=this.element.metrics;this._updateResizerRect(c,d),i.style.display="block"},n.onmouseleave=()=>{this.isAllowResize||(i.style.display="none")},n.append(i),{blockItem:n,resizerMask:r,resizerSelection:i,resizerHandleList:l}}_updateResizerRect(t,e){const{resizerSize:n,scale:i}=this.options;this.resizerSelection.style.width=`${t}px`,this.resizerSelection.style.height=`${e}px`;for(let l=0;l<8;l++){const r=l===0||l===6||l===7?-n:l===1||l===5?t/2:t-n,a=l===0||l===1||l===2?-n:l===3||l===7?e/2-n:e-n;this.resizerHandleList[l].style.transform=`scale(${i})`,this.resizerHandleList[l].style.left=`${r}px`,this.resizerHandleList[l].style.top=`${a}px`}}_mousedown(t){const e=this.draw.getPage();this.mousedownX=t.x,this.mousedownY=t.y,this.isAllowResize=!0;const n=t.target;this.curHandleIndex=Number(n.dataset.index),this.resizerMask.style.display="block";const i=window.getComputedStyle(n).cursor;document.body.style.cursor=i,e.style.cursor=i;const l=this._mousemove.bind(this);document.addEventListener("mousemove",l),document.addEventListener("mouseup",()=>{this.element.width=Math.min(this.width,this.draw.getInnerWidth()),this.element.height=this.height,this.isAllowResize=!1,this.resizerSelection.style.display="none",this.resizerMask.style.display="none",document.removeEventListener("mousemove",l),document.body.style.cursor="",e.style.cursor="text",this.draw.render()},{once:!0}),t.preventDefault()}_mousemove(t){if(!this.isAllowResize)return;const{scale:e}=this.options;let n=0,i=0;switch(this.curHandleIndex){case 0:{const d=this.mousedownX-t.x,u=this.mousedownY-t.y;n=Math.cbrt(d**3+u**3),i=this.element.height*n/this.getBlockWidth()}break;case 1:i=this.mousedownY-t.y;break;case 2:{const d=t.x-this.mousedownX,u=this.mousedownY-t.y;n=Math.cbrt(d**3+u**3),i=this.element.height*n/this.getBlockWidth()}break;case 4:{const d=t.x-this.mousedownX,u=t.y-this.mousedownY;n=Math.cbrt(d**3+u**3),i=this.element.height*n/this.getBlockWidth()}break;case 3:n=t.x-this.mousedownX;break;case 5:i=t.y-this.mousedownY;break;case 6:{const d=this.mousedownX-t.x,u=t.y-this.mousedownY;n=Math.cbrt(d**3+u**3),i=this.element.height*n/this.getBlockWidth()}break;case 7:n=this.mousedownX-t.x;break}const l=this.getBlockWidth()+n/e,r=this.element.height+i/e;if(l<=0||r<=0)return;this.width=l,this.height=r;const a=l*e,c=r*e;this._updateResizerRect(a,c),this.blockItem.style.width=`${a}px`,this.blockItem.style.height=`${c}px`,t.preventDefault()}snapshot(t,e,n){if(this.element.block.type===s.BlockType.VIDEO)if(this.blockItem.style.display="none",this.blockCache.has(this.element.id))this.blockCache.get(this.element.id).snapshot(t,e,n);else{this.block=new yl(this.element);const l=this.block.snapshot(t,e,n);this.draw.getImageObserver().add(l),this.blockCache.set(this.element.id,this.block)}}render(){const t=this.element.block;t.type===s.BlockType.IFRAME?(this.block=new Fn(this.element),this.block.render(this.blockItem)):t.type===s.BlockType.VIDEO&&(this.block=new yl(this.element),this.block.render(this.blockItem))}setClientRects(t,e,n){const i=this.draw.getHeight(),l=this.draw.getPageGap(),r=t*(i+l),{metrics:a}=this.element;this.blockItem.style.display="block",this.blockItem.style.width=`${a.width}px`,this.blockItem.style.height=`${a.height}px`,this.blockItem.style.left=`${e}px`,this.blockItem.style.top=`${r+n}px`}remove(){this.blockItem.remove()}}class TT{draw;container;blockContainer;blockMap;constructor(t){this.draw=t,this.container=t.getContainer(),this.blockMap=new Map,this.blockContainer=this._createBlockContainer(),this.container.append(this.blockContainer)}_createBlockContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-block-container`),t}getDraw(){return this.draw}getBlockContainer(){return this.blockContainer}render(t,e,n,i,l){const r=n.id;let a=this.blockMap.get(r);a||(a=new gT(this,n),a.render(),this.blockMap.set(r,a)),this.draw.isPrintLikeMode()?a.snapshot(t,i,l):a.setClientRects(e,i,l)}clear(){if(!this.blockMap.size)return;const t=this.draw.getOriginalMainElementList(),e=[];for(let n=0;n<t.length;n++){const i=t[n];i.type===s.ElementType.BLOCK&&e.push(i.id)}this.blockMap.forEach(n=>{const i=n.getBlockElement().id;e.includes(i)||(n.remove(),this.blockMap.delete(i))})}}const Cs={contextmenu:{global:{cut:"剪切",copy:"复制",paste:"粘贴",selectAll:"全选",print:"打印",cancel:"取消"},control:{delete:"删除控件",editAttribute:"修改元素配置",addExpression:"添加表达式",addMenstrualHistory:"月经史",addFetalHeartPosition:"胎心位置"},hyperlink:{delete:"删除链接",cancel:"取消链接",edit:"编辑链接"},image:{change:"更改图片",saveAs:"另存为图片",textWrap:"文字环绕",textWrapType:{embed:"嵌入型",upDown:"上下型环绕",surround:"四周型环绕",floatTop:"浮于文字上方",floatBottom:"衬于文字下方"}},table:{insertRowCol:"插入行列",insertTopRow:"上方插入1行",insertBottomRow:"下方插入1行",insertLeftCol:"左侧插入1列",insertRightCol:"右侧插入1列",deleteRowCol:"删除行列",deleteRow:"删除1行",deleteCol:"删除1列",deleteTable:"删除整个表格",mergeCell:"合并单元格",mergeCancelCell:"取消合并",verticalAlign:"垂直对齐",verticalAlignTop:"顶端对齐",verticalAlignMiddle:"垂直居中",verticalAlignBottom:"底端对齐",border:"表格边框",borderAll:"所有框线",borderEmpty:"无框线",borderDash:"虚框线",borderExternal:"外侧框线",borderInternal:"内侧框线",borderTd:"单元格边框",borderTdTop:"上边框",borderTdRight:"右边框",borderTdBottom:"下边框",borderTdLeft:"左边框",borderTdForward:"正斜线",borderTdBack:"反斜线",tableProperties:"表格属性"}},datePicker:{now:"此刻",confirm:"确定",return:"返回日期",timeSelect:"时间选择",weeks:{sun:"日",mon:"一",tue:"二",wed:"三",thu:"四",fri:"五",sat:"六"},year:"年",month:"月",hour:"时",minute:"分",second:"秒"},frame:{header:"页眉",footer:"页脚"},pageBreak:{displayName:"分页符"},zone:{headerTip:"双击编辑页眉",footerTip:"双击编辑页脚"}},fT={contextmenu:{global:{cut:"Cut",copy:"Copy",paste:"Paste",selectAll:"Select all",print:"Print",cancel:"Cancel"},control:{delete:"Delete control",editAttribute:"Edit element config",addExpression:"Add expression",addMenstrualHistory:"Menstrual History",addFetalHeartPosition:"Fetal Heart Position"},hyperlink:{delete:"Delete hyperlink",cancel:"Cancel hyperlink",edit:"Edit hyperlink"},image:{change:"Change image",saveAs:"Save as image",textWrap:"Text wrap",textWrapType:{embed:"Embed",upDown:"Up down",surround:"Surround",floatTop:"Float above text",floatBottom:"Float below text"}},table:{insertRowCol:"Insert row col",insertTopRow:"Insert top 1 row",insertBottomRow:"Insert bottom 1 row",insertLeftCol:"Insert left 1 col",insertRightCol:"Insert right 1 col",deleteRowCol:"Delete row col",deleteRow:"Delete 1 row",deleteCol:"Delete 1 col",deleteTable:"Delete table",mergeCell:"Merge cell",mergeCancelCell:"Cancel merge cell",verticalAlign:"Vertical align",verticalAlignTop:"Top",verticalAlignMiddle:"Middle",verticalAlignBottom:"Bottom",border:"Table border",borderAll:"All",borderEmpty:"Empty",borderDash:"Dash",borderExternal:"External",borderInternal:"Internal",borderTd:"Table cell border",borderTdTop:"Top",borderTdRight:"Right",borderTdBottom:"Bottom",borderTdLeft:"Left",borderTdForward:"Forward",borderTdBack:"Back",tableProperties:"Table Properties"}},datePicker:{now:"Now",confirm:"Confirm",return:"Return",timeSelect:"Time select",weeks:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},year:" ",month:" ",hour:"Hour",minute:"Minute",second:"Second"},frame:{header:"Header",footer:"Footer"},pageBreak:{displayName:"Page Break"},zone:{headerTip:"Double click to edit header",footerTip:"Double click to edit footer"}};class mT{currentLocale;langMap=new Map([["zhCN",Cs],["en",fT]]);constructor(t){this.currentLocale=t}registerLangMap(t,e){const n=this.langMap.get(t);this.langMap.set(t,Xs(n||Cs,e))}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale=t}getLang(){return this.langMap.get(this.currentLocale)||Cs}t(t){const e=t.split(".");let n="",i=this.getLang();for(let l=0;l<e.length;l++){const r=e[l],a=Reflect.get(i,r);if(a)n=i=a;else return""}return n}}class pT{promiseList;constructor(){this.promiseList=[]}add(t){this.promiseList.push(t)}clearAll(){this.promiseList=[]}allSettled(){return Promise.allSettled(this.promiseList)}}class CT{draw;zone;i18n;container;pageContainer;isDisableMouseMove;tipContainer;tipContent;currentMoveZone;constructor(t,e){this.draw=t,this.zone=e,this.i18n=t.getI18n(),this.container=t.getContainer(),this.pageContainer=t.getPageContainer();const{tipContainer:n,tipContent:i}=this._drawZoneTip();this.tipContainer=n,this.tipContent=i,this.isDisableMouseMove=!0,this.currentMoveZone=s.EditorZone.MAIN;const l=[],{header:r,footer:a}=t.getOptions();r.disabled||l.push(s.EditorZone.HEADER),a.disabled||l.push(s.EditorZone.FOOTER),l.length&&this._watchMouseMoveZoneChange(l)}_watchMouseMoveZoneChange(t){this.pageContainer.addEventListener("mousemove",ra(e=>{if(!(this.isDisableMouseMove||!this.draw.getIsPagingMode())){if(this.draw.getMode()!==s.EditorMode.EDIT){this._updateZoneTip(!1);return}if(e.offsetY)if(e.target instanceof HTMLCanvasElement){const n=this.zone.getZoneByY(e.offsetY);if(!t.includes(n)){this._updateZoneTip(!1);return}this.currentMoveZone=n,this._updateZoneTip(this.zone.getZone()===s.EditorZone.MAIN&&(n===s.EditorZone.HEADER||n===s.EditorZone.FOOTER),e.x,e.y)}else this._updateZoneTip(!1)}},250)),this.pageContainer.addEventListener("mouseenter",()=>{this.isDisableMouseMove=!1}),this.pageContainer.addEventListener("mouseleave",()=>{this.isDisableMouseMove=!0,this._updateZoneTip(!1)})}_drawZoneTip(){const t=document.createElement("div");t.classList.add(`${rt}-zone-tip`);const e=document.createElement("span");return t.append(e),this.container.append(t),{tipContainer:t,tipContent:e}}_updateZoneTip(t,e,n){t?(this.tipContainer.classList.add("show"),this.tipContainer.style.left=`${e}px`,this.tipContainer.style.top=`${n}px`,this.tipContent.innerText=this.i18n.t(`zone.${this.currentMoveZone===s.EditorZone.HEADER?"headerTip":"footerTip"}`)):this.tipContainer.classList.remove("show")}}class IT{INDICATOR_PADDING=2;INDICATOR_TITLE_TRANSLATE=[20,5];draw;options;i18n;container;currentZone;indicatorContainer;constructor(t){this.draw=t,this.i18n=t.getI18n(),this.options=t.getOptions(),this.container=t.getContainer(),this.currentZone=s.EditorZone.MAIN,this.indicatorContainer=null,this.options.zone.tipDisabled||new CT(t,this)}isHeaderActive(){return this.getZone()===s.EditorZone.HEADER}isMainActive(){return this.getZone()===s.EditorZone.MAIN}isFooterActive(){return this.getZone()===s.EditorZone.FOOTER}getZone(){return this.currentZone}setZone(t){const{header:e,footer:n}=this.options;!e.editable&&t===s.EditorZone.HEADER||!n.editable&&t===s.EditorZone.FOOTER||this.currentZone!==t&&(this.currentZone=t,this.draw.getRange().clearRange(),this.draw.render({isSubmitHistory:!1,isSetCursor:!1,isCompute:!1}),this.drawZoneIndicator(),ui(()=>{const i=this.draw.getListener();i.zoneChange&&i.zoneChange(t);const l=this.draw.getEventBus();l.isSubscribe("zoneChange")&&l.emit("zoneChange",t)}))}getZoneByY(t){const e=this.draw.getHeader(),n=e.getHeaderTop()+e.getHeight(),i=this.draw.getFooter(),r=this.draw.getHeight()-(i.getFooterBottom()+i.getHeight());return t<n?s.EditorZone.HEADER:t>r?s.EditorZone.FOOTER:s.EditorZone.MAIN}drawZoneIndicator(){if(this._clearZoneIndicator(),!this.isHeaderActive()&&!this.isFooterActive())return;const{scale:t}=this.options,e=this.isHeaderActive(),[n,i]=this.INDICATOR_TITLE_TRANSLATE,l=this.draw.getPageList(),r=this.draw.getMargins(),a=this.draw.getInnerWidth(),c=this.draw.getHeight(),d=this.draw.getPageGap(),u=c+d;this.indicatorContainer=document.createElement("div"),this.indicatorContainer.classList.add(`${rt}-zone-indicator`);const R=this.draw.getHeader(),h=this.draw.getFooter(),g=e?R.getHeight():h.getHeight(),T=e?R.getHeaderTop():c-h.getFooterBottom()-g;for(let f=0;f<l.length;f++){const p=u*f+T,C=r[3]-this.INDICATOR_PADDING,I=r[3]+a+this.INDICATOR_PADDING,m=e?p-this.INDICATOR_PADDING:p+g+this.INDICATOR_PADDING,P=e?p+g+this.INDICATOR_PADDING:p-this.INDICATOR_PADDING,E=document.createElement("div");E.innerText=this.i18n.t(`frame.${e?"header":"footer"}`),E.style.top=`${P}px`,E.style.transform=`translate(${n*t}px, ${i*t}px) scale(${t})`,this.indicatorContainer.append(E);const M=document.createElement("span");M.classList.add(`${rt}-zone-indicator-border__top`),M.style.top=`${m}px`,M.style.width=`${a}px`,M.style.marginLeft=`${r[3]}px`,this.indicatorContainer.append(M);const F=document.createElement("span");F.classList.add(`${rt}-zone-indicator-border__left`),F.style.top=`${p}px`,F.style.height=`${g}px`,F.style.left=`${C}px`,this.indicatorContainer.append(F);const y=document.createElement("span");y.classList.add(`${rt}-zone-indicator-border__bottom`),y.style.top=`${P}px`,this.indicatorContainer.append(y);const Y=document.createElement("span");Y.classList.add(`${rt}-zone-indicator-border__right`),Y.style.top=`${p}px`,Y.style.height=`${g}px`,Y.style.left=`${I}px`,this.indicatorContainer.append(Y)}this.container.append(this.indicatorContainer)}_clearZoneIndicator(){this.indicatorContainer?.remove(),this.indicatorContainer=null}}class LT{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();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(){const t=this.getFooterBottom(),e=this.draw.getInnerWidth(),i=this.draw.getMargins()[3],l=this.draw.getHeight(),r=this.getHeight(),a=l-t-r;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:i,startY:a,innerWidth:e,zone:s.EditorZone.FOOTER})}getFooterBottom(){const{footer:{bottom:t,disabled:e},scale:n}=this.options;return e?0:Math.floor(t*n)}getMaxHeight(){const{footer:{maxHeightRadio:t}}=this.options,e=this.draw.getHeight();return Math.floor(e*Ms[t])}getHeight(){if(this.options.footer.disabled)return 0;const t=this.getMaxHeight(),e=this.getRowHeight();return e>t?t:e}getRowHeight(){return this.rowList.reduce((t,e)=>t+e.height,0)}getExtraHeight(){const t=this.draw.getMargins(),e=this.getHeight(),i=this.getFooterBottom()+e-t[2];return i<=0?0:i}render(t,e){t.save(),t.globalAlpha=this.zone.isFooterActive()?1:this.options.footer.inactiveAlpha;const n=this.draw.getInnerWidth(),i=this.getMaxHeight(),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.FOOTER}),t.restore()}}class PT{draw;range;options;UN_COUNT_STYLE_WIDTH=20;MEASURE_BASE_TEXT="0";LIST_GAP=10;constructor(t){this.draw=t,this.range=t.getRange(),this.options=t.getOptions()}setList(t,e){if(this.draw.isReadonly())return;const{startIndex:i,endIndex:l}=this.range.getRange();if(!~i&&!~l)return;const r=this.range.getRangeParagraphElementList();if(!r||!r.length)return;if(r.find(R=>R.listType===t&&R.listStyle===e)||!t){this.unsetList();return}const c=ft();r.forEach(R=>{R.listId=c,R.listType=t,R.listStyle=e});const d=i===l,u=d?l:i;this.draw.render({curIndex:u,isSetCursor:d})}unsetList(){if(this.draw.isReadonly())return;const{startIndex:e,endIndex:n}=this.range.getRange();if(!~e&&!~n)return;const i=this.range.getRangeParagraphElementList()?.filter(d=>d.listId);if(!i||!i.length)return;const l=this.draw.getElementList(),r=l[n];if(r.listId){let d=n+1;for(;d<l.length;){const u=l[d];if(u.value===K&&!u.listWrap)break;if(u.listId!==r.listId){this.draw.spliceElementList(l,d,0,[{value:K}]);break}d++}}i.forEach(d=>{delete d.listId,delete d.listType,delete d.listStyle,delete d.listWrap});const a=e===n,c=a?n:e;this.draw.render({curIndex:c,isSetCursor:a})}computeListStyle(t,e){const n=new Map;let i=0,l=e[i]?.listId,r=[];const a=e.length;for(;i<a;){const c=e[i];if(l&&l===c.listId)r.push(c);else if(c.listId&&c.listId!==l){if(r.length){const d=this.getListStyleWidth(t,r);n.set(l,d)}l=c.listId,r=l?[c]:[]}i++}if(r.length){const c=this.getListStyleWidth(t,r);n.set(l,c)}return n}findStyledElement(t){let e=t[0];for(let n=1;n<t.length;n++){const i=t[n];if(i.font||i.size||i.bold||i.italic){e=i;break}}return e}getListFontStyle(t,e){if(this.options.list.inheritStyle){const n=this.findStyledElement(t);return this.draw.getElementFont(n,e)}else{const{defaultFont:n,defaultSize:i}=this.options;return`${i*e}px ${n}`}}getListStyleWidth(t,e){const{scale:n,checkbox:i}=this.options,l=e[0];if(l.listStyle&&l.listStyle!==s.ListStyle.DECIMAL)return l.listStyle===s.ListStyle.CHECKBOX?(i.width+this.LIST_GAP)*n:this.UN_COUNT_STYLE_WIDTH*n;const r=e.reduce((d,u)=>(u.value===K&&(d+=1),d),0);if(!r)return 0;t.save(),t.font=this.getListFontStyle(e,n);const a=`${this.MEASURE_BASE_TEXT.repeat(String(r).length)}${s.KeyMap.PERIOD}`,c=t.measureText(a);return t.restore(),Math.ceil((c.width+this.LIST_GAP)*n)}drawListStyle(t,e,n){const{elementList:i,offsetX:l,listIndex:r,ascent:a}=e,c=i[0];if(c.value!==K||c.listWrap)return;let d=0;const{defaultTabWidth:u,scale:R}=this.options;for(let p=1;p<i.length&&i[p]?.type===s.ElementType.TAB;p++)d+=u*R;const{coordinate:{leftTop:[h,g]}}=n,T=h-l+d,f=g+a;if(c.listStyle===s.ListStyle.CHECKBOX){const{width:p,height:C,gap:I}=this.options.checkbox,m={...c,checkbox:{value:!!c.checkbox?.value},metrics:{...c.metrics,width:(p+I*2)*R,height:C*R}};this.draw.getCheckboxParticle().render({ctx:t,x:T-I*R,y:f,index:0,row:{...e,elementList:[m,...e.elementList]}})}else{let p="";if(c.listType===s.ListType.UL?p=pi[c.listStyle]||pi[Cn.DISC]:p=`${r+1}${s.KeyMap.PERIOD}`,!p)return;t.save(),t.font=this.getListFontStyle(i,R),t.fillText(p,T,f),t.restore()}}}class To{options;static WIDTH=12;static HEIGHT=9;static GAP=3;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:l,lineBreak:{color:r,lineWidth:a}}=this.options;t.save(),t.beginPath();const c=i-To.HEIGHT*l/2,d=n+e.metrics.width;t.translate(d,c),t.scale(l,l),t.strokeStyle=r,t.lineWidth=a,t.lineCap="round",t.lineJoin="round",t.beginPath(),t.moveTo(8,0),t.lineTo(12,0),t.lineTo(12,6),t.lineTo(3,6),t.moveTo(3,6),t.lineTo(6,3),t.moveTo(3,6),t.lineTo(6,9),t.stroke(),t.closePath(),t.restore()}}class bl{draw;position;options;elementList;rowList;positionList;constructor(t){this.draw=t,this.position=t.getPosition(),this.options=t.getOptions(),this.elementList=[],this.rowList=[],this.positionList=[]}_recovery(){this.elementList=[],this.rowList=[],this.positionList=[]}_compute(t){this._computeRowList(),this._computePositionList(t)}_computeRowList(){const t=this.draw.getInnerWidth();this.rowList=this.draw.computeRowList({innerWidth:t,elementList:this.elementList})}_computePositionList(t){const{lineBreak:e,scale:n}=this.options,i=this.draw.getHeader().getExtraHeight(),l=this.draw.getInnerWidth(),r=this.draw.getMargins();let a=r[3];e.disabled||(a+=(To.WIDTH+To.GAP)*n);const c=t?.startY||r[0]+i;this.position.computePageRowPosition({positionList:this.positionList,rowList:this.rowList,pageNo:0,startRowIndex:0,startIndex:0,startX:a,startY:c,innerWidth:l})}render(t,e){const{placeholder:n=this.options.placeholder}=e||{},{data:i,font:l,size:r,color:a,opacity:c}=n;this._recovery(),this.elementList=[{value:i,font:l,size:r,color:a}],jt(this.elementList,{editorOptions:this.options,isForceCompensation:!0}),this._compute(e);const d=this.draw.getInnerWidth();t.save(),t.globalAlpha=c,this.draw.drawRow(t,{elementList:this.elementList,positionList:this.positionList,rowList:this.rowList,pageNo:0,startIndex:0,innerWidth:d,isDrawLineBreak:!1}),t.restore()}}class ET{draw;options;range;fillRectMap;constructor(t){this.draw=t,this.options=t.getOptions(),this.range=t.getRange(),this.fillRectMap=new Map}setGroup(){if(this.draw.isReadonly()||this.draw.getZone().getZone()!==s.EditorZone.MAIN)return null;const t=this.range.getSelection();if(!t)return null;const e=ft();return t.forEach(n=>{Array.isArray(n.groupIds)||(n.groupIds=[]),n.groupIds.push(e)}),this.draw.render({isSetCursor:!1,isCompute:!1}),e}getElementListByGroupId(t,e){const n=[];for(let i=0;i<t.length;i++){const l=t[i];if(l.type===s.ElementType.TABLE){const r=l.trList;for(let a=0;a<r.length;a++){const c=r[a];for(let d=0;d<c.tdList.length;d++){const u=c.tdList[d],R=this.getElementListByGroupId(u.value,e);if(R.length)return n.push(...R),n}}}if(l?.groupIds?.includes(e)&&(n.push(l),!t[i+1]?.groupIds?.includes(e)))break}return n}deleteGroup(t){if(this.draw.isReadonly())return;const e=this.draw.getOriginalMainElementList(),n=this.getElementListByGroupId(e,t);if(n.length){for(let i=0;i<n.length;i++){const l=n[i],r=l.groupIds,a=r.findIndex(c=>c===t);r.splice(a,1),r.length||delete l.groupIds}this.draw.render({isSetCursor:!1,isCompute:!1})}}getContextByGroupId(t,e){for(let n=0;n<t.length;n++){const i=t[n];if(i.type===s.ElementType.TABLE){const r=i.trList;for(let a=0;a<r.length;a++){const c=r[a];for(let d=0;d<c.tdList.length;d++){const u=c.tdList[d],R=this.getContextByGroupId(u.value,e);if(R)return{...R,isTable:!0,index:n,trIndex:a,tdIndex:d,tdId:u.id,trId:c.id,tableId:i.tableId}}}}const l=t[n+1];if(i.groupIds?.includes(e)&&!l?.groupIds?.includes(e))return{isTable:!1,startIndex:n,endIndex:n}}return null}clearFillInfo(){this.fillRectMap.clear()}recordFillInfo(t,e,n,i,l){const r=t.groupIds;if(r)for(const a of r){const c=this.fillRectMap.get(a);c?c.width+=i:this.fillRectMap.set(a,{x:e,y:n,width:i,height:l})}}render(t){if(!this.fillRectMap.size)return;const e=this.range.getRange(),i=this.draw.getElementList()[e.endIndex]?.groupIds,{group:{backgroundColor:l,opacity:r,activeOpacity:a,activeBackgroundColor:c}}=this.options;t.save(),this.fillRectMap.forEach((d,u)=>{const{x:R,y:h,width:g,height:T}=d;i?.includes(u)?(t.globalAlpha=a,t.fillStyle=c):(t.globalAlpha=r,t.fillStyle=l),t.fillRect(R,h,g,T)}),t.restore(),this.clearFillInfo()}}class MT{options;constructor(t){this.options=t.getOptions()}render(t,e,n,i){const{scale:l,whiteSpace:{color:r,radius:a}}=this.options,c=e.metrics;t.save(),t.fillStyle=r,t.beginPath(),t.arc(n+c.width/2,i,a*l,0,Math.PI*2),t.fill(),t.closePath(),t.restore()}}class OT{draw;eventBus;pageContainer;constructor(t){this.draw=t,this.eventBus=this.draw.getEventBus(),this.pageContainer=this.draw.getPageContainer(),this.pageContainer.addEventListener("mousemove",this._mousemove.bind(this)),this.pageContainer.addEventListener("mouseenter",this._mouseenter.bind(this)),this.pageContainer.addEventListener("mouseleave",this._mouseleave.bind(this)),this.pageContainer.addEventListener("mousedown",this._mousedown.bind(this)),this.pageContainer.addEventListener("mouseup",this._mouseup.bind(this)),this.pageContainer.addEventListener("click",this._click.bind(this))}_mousemove(t){this.eventBus.isSubscribe("mousemove")&&this.eventBus.emit("mousemove",t)}_mouseenter(t){this.eventBus.isSubscribe("mouseenter")&&this.eventBus.emit("mouseenter",t)}_mouseleave(t){this.eventBus.isSubscribe("mouseleave")&&this.eventBus.emit("mouseleave",t)}_mousedown(t){this.eventBus.isSubscribe("mousedown")&&this.eventBus.emit("mousedown",t)}_mouseup(t){this.eventBus.isSubscribe("mouseup")&&this.eventBus.emit("mouseup",t)}_click(t){this.eventBus.isSubscribe("click")&&this.eventBus.emit("click",t)}}class ST{draw;options;constructor(t){this.draw=t,this.options=t.getOptions()}render(t,e){const{scale:n,lineNumber:{color:i,size:l,font:r,right:a,type:c}}=this.options,d=this.draw.getTextParticle(),u=this.draw.getMargins(),R=this.draw.getPosition().getOriginalMainPositionList(),g=this.draw.getPageRowList()[e];t.save(),t.fillStyle=i,t.font=`${l*n}px ${r}`;for(let T=0;T<g.length;T++){const f=g[T],{coordinate:{leftBottom:p}}=R[f.startIndex],C=c===s.LineNumberType.PAGE?T+1:f.rowIndex+1,I=d.measureText(t,{value:`${C}`}),m=u[3]-(I.width+a)*n,P=p[1]-I.actualBoundingBoxAscent*n;t.fillText(`${C}`,m,P)}t.restore()}}class XT{draw;header;footer;options;constructor(t){this.draw=t,this.header=t.getHeader(),this.footer=t.getFooter(),this.options=t.getOptions()}render(t){const{scale:e,pageBorder:{color:n,lineWidth:i,padding:l}}=this.options;t.save(),t.translate(.5,.5),t.strokeStyle=n,t.lineWidth=i*e;const r=this.draw.getMargins(),a=r[3]-l[3]*e,c=r[0]+this.header.getExtraHeight()-l[0]*e,d=this.draw.getInnerWidth()+(l[1]+l[3])*e,u=this.draw.getHeight()-c-this.footer.getExtraHeight()-r[2]+l[2]*e;t.rect(a,c,d,u),t.stroke(),t.restore()}}function NT(o,t){const{value:e,oldValue:n}=t;n.isTable&&!e.isTable&&o.getTableTool().dispose()}class FT{draw;eventBus;constructor(t){this.draw=t,this.eventBus=t.getEventBus(),this.execute()}execute(){this.eventBus.on("positionContextChange",t=>{NT(this.draw,t)})}}class yT{draw;range;position;tableTool;tableParticle;options;constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.tableTool=t.getTableTool(),this.tableParticle=t.getTableParticle(),this.options=t.getOptions()}insertTable(t,e){const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{defaultTrMinHeight:l}=this.options.table,r=this.draw.getElementList();let a=0;if(r[n]?.listId){const T=this.position.getPositionList(),{rowIndex:f}=T[n];a=this.draw.getRowList()[f]?.offsetX||0}const c=this.draw.getContextInnerWidth()-a,d=[],u=c/e;for(let T=0;T<e;T++)d.push({width:u});const R=[];for(let T=0;T<t;T++){const f=[],p={height:l,tdList:f};for(let C=0;C<e;C++)f.push({colspan:1,rowspan:1,value:[]});R.push(p)}const h={type:s.ElementType.TABLE,value:"",colgroup:d,trList:R};jt([h],{editorOptions:this.options}),oe(r,[h],n,{editorOptions:this.options});const g=n+1;this.draw.spliceElementList(r,g,n===i?0:i-n,[h]),this.range.setRange(g,g),this.draw.render({curIndex:g,isSetCursor:!1})}insertTableTopRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=a[n];if(c.tdList.length<r.colgroup.length){const R=c.tdList[0].rowIndex;for(let h=0;h<n;h++){const g=a[h];for(let T=0;T<g.tdList.length;T++){const f=g.tdList[T];f.rowspan>1&&f.rowIndex+f.rowspan>=R+1&&(f.rowspan+=1)}}}const d=ft(),u={height:c.height,id:d,tdList:[]};for(let R=0;R<c.tdList.length;R++){const h=c.tdList[R],g=ft();u.tdList.push({id:g,rowspan:1,colspan:h.colspan,value:[{value:K,size:16,tableId:i,trId:d,tdId:g}]})}a.splice(n,0,u),this.position.setPositionContext({isTable:!0,index:e,trIndex:n,tdIndex:0,tdId:u.tdList[0].id,trId:u.id,tableId:i}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableBottomRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tableId:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=a[n],d=a.length-1===n?c:a[n+1];if(d.tdList.length<r.colgroup.length){const h=d.tdList[0].rowIndex;for(let g=0;g<n+1;g++){const T=a[g];for(let f=0;f<T.tdList.length;f++){const p=T.tdList[f];p.rowspan>1&&p.rowIndex+p.rowspan>=h+1&&(p.rowspan+=1)}}}const u=ft(),R={height:d.height,id:u,tdList:[]};for(let h=0;h<d.tdList.length;h++){const g=d.tdList[h],T=ft();R.tdList.push({id:T,rowspan:1,colspan:g.colspan,value:[{value:K,size:16,tableId:i,trId:u,tdId:T}]})}a.splice(n+1,0,R),this.position.setPositionContext({isTable:!0,index:e,trIndex:n+1,tdIndex:0,tdId:R.tdList[0].id,trId:R.id,tableId:r.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}adjustColWidth(t){if(t.type!==s.ElementType.TABLE)return;const{defaultColMinWidth:e}=this.options.table,n=t.colgroup,i=n.reduce((r,a)=>r+a.width,0),l=this.draw.getOriginalInnerWidth();if(i>l){const r=n.filter(c=>c.width>e),a=(i-l)/r.length;for(let c=0;c<n.length;c++){const d=n[c];d.width-a>=e&&(d.width-=a)}}}insertTableLeftCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=n;for(let R=0;R<a.length;R++){const h=a[R],g=ft();h.tdList.splice(c,0,{id:g,rowspan:1,colspan:1,value:[{value:K,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:d}=this.options.table;r.colgroup.splice(c,0,{width:d}),this.adjustColWidth(r),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:c,tdId:a[0].tdList[c].id,trId:a[0].id,tableId:i}),this.range.setRange(0,0),this.draw.render({curIndex:0}),this.tableTool.render()}insertTableRightCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,tableId:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=n+1;for(let R=0;R<a.length;R++){const h=a[R],g=ft();h.tdList.splice(c,0,{id:g,rowspan:1,colspan:1,value:[{value:K,size:16,tableId:i,trId:h.id,tdId:g}]})}const{defaultColMinWidth:d}=this.options.table;r.colgroup.splice(c,0,{width:d}),this.adjustColWidth(r),this.position.setPositionContext({isTable:!0,index:e,trIndex:0,tdIndex:c,tdId:a[0].tdList[c].id,trId:a[0].id,tableId:r.id}),this.range.setRange(0,0),this.draw.render({curIndex:0})}deleteTableRow(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,trIndex:n,tdIndex:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=a[n],d=c.tdList[i].rowIndex;if(a.length<=1&&r.pagingIndex===0){this.deleteTable();return}for(let u=0;u<d;u++){const h=a[u].tdList;for(let g=0;g<h.length;g++){const T=h[g];T.rowIndex+T.rowspan>d&&T.rowspan--}}for(let u=0;u<c.tdList.length;u++){const R=c.tdList[u];if(R.rowspan>1){const h=ft(),g=a[n+1];g.tdList.splice(u,0,{id:h,rowspan:R.rowspan-1,colspan:R.colspan,value:[{value:K,size:16,tableId:r.id,trId:g.id,tdId:h}]})}}a.splice(n,1),this.position.setPositionContext({isTable:!1}),this.range.clearRange(),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTableCol(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,d=a[i].tdList[n].colIndex;if(!a.find(R=>R.tdList.length>1)){this.deleteTable();return}for(let R=0;R<a.length;R++){const h=a[R];for(let g=0;g<h.tdList.length;g++){const T=h.tdList[g];T.colIndex<=d&&T.colIndex+T.colspan>d&&(T.colspan>1?T.colspan--:h.tdList.splice(g,1))}}r.colgroup?.splice(d,1),this.position.setPositionContext({isTable:!1}),this.range.setRange(0,0),this.draw.render({curIndex:t.index}),this.tableTool.dispose()}deleteTable(){const t=this.position.getPositionContext();if(!t.isTable)return;const e=this.draw.getOriginalElementList(),n=e[t.index];let i=1,l=t.index;if(n.pagingId){l=t.index-n.pagingIndex;for(let a=l+1;a<e.length&&e[a].pagingId===n.pagingId;a++)i++}e.splice(l,i);const r=l-1;this.position.setPositionContext({isTable:!1,index:r}),this.range.setRange(r,r),this.draw.render({curIndex:r}),this.tableTool.dispose()}mergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{isCrossRowCol:e,startTdIndex:n,endTdIndex:i,startTrIndex:l,endTrIndex:r}=this.range.getRange();if(!e)return;const{index:a}=t,u=this.draw.getOriginalElementList()[a].trList;let R=u[l].tdList[n],h=u[r].tdList[i];(R.x>h.x||R.y>h.y)&&([R,h]=[h,R]);const g=R.colIndex,T=h.colIndex+(h.colspan-1),f=R.rowIndex,p=h.rowIndex+(h.rowspan-1),C=[];for(let V=0;V<u.length;V++){const X=u[V],N=[];for(let L=0;L<X.tdList.length;L++){const W=X.tdList[L],S=W.colIndex,U=W.rowIndex;S>=g&&S<=T&&U>=f&&U<=p&&N.push(W)}N.length&&C.push(N)}if(!C.length)return;const I=C[C.length-1],m=C[0][0],P=I[I.length-1],E=m.x,M=m.y,F=P.x+P.width,y=P.y+P.height;for(let V=0;V<C.length;V++){const X=C[V];for(let N=0;N<X.length;N++){const L=X[N],W=L.x,S=L.y,U=W+L.width,Q=S+L.height;if(E>W||M>S||F<U||y<Q)return}}const Y=[],D=C[0][0],O=D.value[0];for(let V=0;V<C.length;V++){const X=C[V];for(let N=0;N<X.length;N++){const L=X[N];if(!(V===0&&N===0)){Y.push(L.id);const S=L.value.length>1?0:1;for(let U=S;U<L.value.length;U++){const Q=L.value[U];an(pn,O,Q),D.value.push(Q)}}V===0&&N!==0&&(D.colspan+=L.colspan),V!==0&&D.colIndex===L.colIndex&&(D.rowspan+=L.rowspan)}}for(let V=0;V<u.length;V++){const X=u[V];let N=0;for(;N<X.tdList.length;){const L=X.tdList[N];Y.includes(L.id)&&(X.tdList.splice(N,1),N--),N++}}this.position.setPositionContext({...t,trIndex:D.trIndex,tdIndex:D.tdIndex});const b=D.value.length-1;this.range.setRange(b,b),this.draw.render(),this.tableTool.render()}cancelMergeTableCell(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e,tdIndex:n,trIndex:i}=t,r=this.draw.getOriginalElementList()[e],a=r.trList,c=a[i],d=c.tdList[n];if(d.rowspan===1&&d.colspan===1)return;const u=d.colspan;if(d.colspan>1){for(let h=1;h<d.colspan;h++){const g=ft();c.tdList.splice(n+h,0,{id:g,rowspan:1,colspan:1,value:[{value:K,size:16,tableId:r.id,trId:c.id,tdId:g}]})}d.colspan=1}if(d.rowspan>1){for(let h=1;h<d.rowspan;h++){const g=a[i+h];for(let T=0;T<u;T++){const f=ft();g.tdList.splice(d.colIndex,0,{id:f,rowspan:1,colspan:1,value:[{value:K,size:16,tableId:r.id,trId:g.id,tdId:f}]})}}d.rowspan=1}const R=d.value.length-1;this.range.setRange(R,R),this.draw.render(),this.tableTool.render()}splitVerticalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:l}=t,a=this.draw.getOriginalElementList()[n],c=a.trList,d=c[l],u=d.tdList[i];a.colgroup.splice(i+1,0,{width:this.options.table.defaultColMinWidth});for(let R=0;R<c.length;R++){const h=c[R];let g=0;for(;g<h.tdList.length;){const T=h.tdList[g];if(T.rowIndex!==u.rowIndex)T.colIndex<=u.colIndex&&T.colIndex+T.colspan>u.colIndex&&T.colspan++;else if(T.id===u.id){const f=ft();d.tdList.splice(g+u.colspan,0,{id:f,rowspan:u.rowspan,colspan:1,value:[{value:K,size:16,tableId:a.id,trId:h.id,tdId:f}]}),g++}g++}}this.draw.render(),this.tableTool.render()}splitHorizontalTableCell(){const t=this.position.getPositionContext();if(!t.isTable||this.range.getRange().isCrossRowCol)return;const{index:n,tdIndex:i,trIndex:l}=t,a=this.draw.getOriginalElementList()[n],c=a.trList,u=c[l].tdList[i];let R=-1,h=0;for(;h<c.length;){if(h===R){h++;continue}const g=c[h];let T=0;for(;T<g.tdList.length;){const f=g.tdList[T];if(f.id===u.id){const p=ft(),C=ft();c.splice(h+u.rowspan,0,{id:p,height:this.options.table.defaultTrMinHeight,tdList:[{id:C,rowspan:1,colspan:u.colspan,value:[{value:K,size:16,tableId:a.id,trId:p,tdId:C}]}]}),R=h+u.rowspan}else f.rowIndex>=u.rowIndex&&f.rowIndex<u.rowIndex+u.rowspan&&f.rowIndex+f.rowspan>=u.rowIndex+u.rowspan&&f.rowspan++;T++}h++}this.draw.render(),this.tableTool.render()}tableTdVerticalAlign(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const l=e[i];for(let r=0;r<l.length;r++){const a=l[r];!a||a.verticalAlign===t||!a.verticalAlign&&t===s.VerticalAlign.TOP||(a.verticalAlign=t)}}const{endIndex:n}=this.range.getRange();this.draw.render({curIndex:n})}tableBorderType(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,l=this.draw.getOriginalElementList()[n];if(!l.borderType&&t===s.TableBorder.ALL||l.borderType===t)return;l.borderType=t;const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r})}tableBorderColor(t){const e=this.position.getPositionContext();if(!e.isTable)return;const{index:n}=e,l=this.draw.getOriginalElementList()[n];if(!l.borderColor&&t===this.options.table.defaultBorderColor||l.borderColor===t)return;l.borderColor=t;const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r,isCompute:!1})}tableTdBorderType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(r=>!r.borderTypes?.includes(t));n.forEach(r=>{r.borderTypes||(r.borderTypes=[]);const a=r.borderTypes.findIndex(c=>c===t);i?~a||r.borderTypes.push(t):~a&&r.borderTypes.splice(a,1),r.borderTypes.length||delete r.borderTypes});const{endIndex:l}=this.range.getRange();this.draw.render({curIndex:l})}tableTdSlashType(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;const n=e.flat(),i=n.some(r=>!r.slashTypes?.includes(t));n.forEach(r=>{r.slashTypes||(r.slashTypes=[]);const a=r.slashTypes.findIndex(c=>c===t);i?~a||r.slashTypes.push(t):~a&&r.slashTypes.splice(a,1),r.slashTypes.length||delete r.slashTypes});const{endIndex:l}=this.range.getRange();this.draw.render({curIndex:l})}tableTdBackgroundColor(t){const e=this.tableParticle.getRangeRowCol();if(!e)return;for(let i=0;i<e.length;i++){const l=e[i];for(let r=0;r<l.length;r++){const a=l[r];a.backgroundColor=t}}const{endIndex:n}=this.range.getRange();this.range.setRange(n,n),this.draw.render({isCompute:!1})}tableSelectAll(){const t=this.position.getPositionContext(),{index:e,tableId:n,isTable:i}=t;if(!i||!n)return;const{startIndex:l,endIndex:r}=this.range.getRange(),c=this.draw.getOriginalElementList()[e].trList,d=c.length-1,u=c[d].tdList.length-1;this.range.replaceRange({startIndex:l,endIndex:r,tableId:n,startTdIndex:0,endTdIndex:u,startTrIndex:0,endTrIndex:d}),this.draw.render({isSetCursor:!1,isCompute:!1,isSubmitHistory:!1})}tableProperties(){const t=this.position.getPositionContext();if(!t.isTable)return;const{index:e}=t,i=this.draw.getOriginalElementList()[e],l=this.draw.getOptions().table.tdPadding,r=i.tdPadding||l,a=document.createElement("div");a.className="table-properties-modal",a.setAttribute("editor-component","table-properties-modal"),a.innerHTML=`
524
524
  <div class="table-properties-modal__mask"></div>
525
525
  <div class="table-properties-modal__container">
526
526
  <div class="table-properties-modal__header">
@@ -550,7 +550,7 @@ ${R} `}textToElements(t){const e=[],n=t.split(`
550
550
  <button class="btn-confirm">确定</button>
551
551
  </div>
552
552
  </div>
553
- `,document.body.appendChild(a);const c=a.querySelector(".table-properties-modal__mask"),d=a.querySelector(".table-properties-modal__close"),u=a.querySelector(".btn-cancel"),R=a.querySelector(".btn-confirm"),h=()=>{a.remove()};c.addEventListener("click",h),d.addEventListener("click",h),u.addEventListener("click",h),R.addEventListener("click",()=>{const g=parseInt(a.querySelector("#tdPaddingTop").value)||0,T=parseInt(a.querySelector("#tdPaddingRight").value)||0,f=parseInt(a.querySelector("#tdPaddingBottom").value)||0,p=parseInt(a.querySelector("#tdPaddingLeft").value)||0;i.tdPadding=[g,T,f,p],h();const{endIndex:C}=this.range.getRange();this.draw.render({curIndex:C,isCompute:!0})})}}s.AreaMode=void 0,(function(o){o.EDIT="edit",o.READONLY="readonly",o.FORM="form"})(s.AreaMode||(s.AreaMode={}));class bT{draw;zone;range;position;options;areaInfoMap=new Map;constructor(t){this.draw=t,this.options=t.getOptions(),this.zone=t.getZone(),this.range=t.getRange(),this.position=t.getPosition()}getAreaInfo(){return this.areaInfoMap}getActiveAreaId(){if(!this.areaInfoMap.size)return null;const{startIndex:t}=this.range.getRange();return this.draw.getElementList()[t]?.areaId||null}getActiveAreaInfo(){const t=this.getActiveAreaId();return t&&this.areaInfoMap.get(t)||null}isReadonly(){const t=this.getActiveAreaInfo();if(!t?.area)return!1;switch(t.area.mode){case s.AreaMode.EDIT:return!1;case s.AreaMode.READONLY:return!0;case s.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:l,range:r}=t;if(this.zone.getZone()!==s.EditorZone.MAIN&&this.zone.setZone(s.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),r&&!this.getActiveAreaId()){const{startIndex:c,endIndex:d}=r,u=this.draw.getOriginalMainElementList();if(!u[c]||!u[d])return null;this.range.setRange(r.startIndex,r.endIndex)}else if(l===s.LocationPosition.BEFORE)this.range.setRange(0,0);else{const d=this.draw.getOriginalMainElementList().length-1;this.range.setRange(d,d)}const a=e||ft();return this.draw.insertElementList([{type:s.ElementType.AREA,value:"",areaId:a,valueList:n,area:ct(i)}]),a}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const l of this.areaInfoMap){const{area:r,positionList:a}=l[1];if(r?.hide||!r?.backgroundColor&&!r?.borderColor&&!r?.placeholder)continue;const c=a.filter(T=>T.pageNo===e);if(!c.length)continue;t.translate(.5,.5);const d=c[0],u=c[c.length-1],R=n[3],h=Math.ceil(d.coordinate.leftTop[1]),g=Math.ceil(u.coordinate.rightBottom[1]-h);t.textBaseline="middle",r.backgroundColor&&(t.fillStyle=r.backgroundColor,t.fillRect(R,h,i,g)),r.borderColor&&(t.strokeStyle=r.borderColor,t.strokeRect(R,h,i,g)),r.placeholder&&a.length<=1&&new bl(this.draw).render(t,{placeholder:{...Qs,...r.placeholder},startY:d.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],l=i.areaId;if(l){const r=this.areaInfoMap.get(l);r?(r.elementList.push(i),r.positionList.push(e[n])):this.areaInfoMap.set(l,{id:l,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:wt(n.elementList)}:null}getContextByAreaId(t,e){const n=this.draw.getOriginalMainElementList();for(let i=0;i<n.length;i++){const l=n[i];if(e?.position===s.LocationPosition.OUTER_BEFORE){if(n[i+1]?.areaId!==t)continue}else if(e?.position===s.LocationPosition.AFTER){if(!(l.areaId===t&&n[i+1]?.areaId!==t))continue}else if(e?.position===s.LocationPosition.OUTER_AFTER){if(!(l.areaId!==t&&n[i-1]?.areaId===t))continue}else if(l.areaId!==t)continue;const r=this.position.getOriginalMainPositionList();return{range:{startIndex:i,endIndex:i},elementPosition:r[i]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const l=["top","hide"];Object.entries(t.properties).forEach(([r,a])=>{if(ys(a))return;const c=r;n.area[c]=a,l.includes(c)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,l=this.draw.getOriginalMainElementList(),r=t.value;jt([{type:s.ElementType.AREA,value:"",valueList:r,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(l,i[0].index,i.length,r,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class DT{draw;options;imageCache;mainBadge;areaBadgeMap;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,i,l,r){if(this.imageCache.has(r)){const a=this.imageCache.get(r);t.drawImage(a,e,n,i,l)}else{const a=new Image;a.setAttribute("crossOrigin","Anonymous"),a.src=r,a.onload=()=>{this.imageCache.set(r,a),t.drawImage(a,e,n,i,l)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:l,top:r,width:a,height:c,value:d}=this.mainBadge,u=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),R=(l||i.left)*n,h=(r||i.top)*n+u;this._drawImage(t,R,h,a*n,c*n,d)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:l}=this.options;for(const r of n){const{positionList:a}=r[1],c=a[0];if(c.pageNo!==e)continue;const d=this.areaBadgeMap.get(r[0]);if(!d)continue;const{left:u,top:R,width:h,height:g,value:T}=d,f=(u||l.left)*i,p=(R||l.top)*i+c.coordinate.leftTop[1];this._drawImage(t,f,p,h*i,g*i,T)}}}}}class VT{draw;options;data;pageContainer;isDrawing=!1;startStroke=null;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const l=this.draw.getPageNo();let r=this.data.find(d=>d.pageNo===l);if(this.startStroke&&(r||(r={pageNo:l,strokes:[]},this.data.push(r)),r.strokes.push(this.startStroke),this.startStroke=null),!r?.strokes?.length)return;const{scale:a}=this.options;r.strokes[r.strokes.length-1].points.push(e/a,n/a),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){const n=this.data.find(a=>a.pageNo===e)?.strokes;if(!n?.length)return;const{graffiti:{defaultLineColor:i,defaultLineWidth:l},scale:r}=this.options;t.save();for(let a=0;a<n.length;a++){const c=n[a];t.beginPath(),t.strokeStyle=c.lineColor||i,t.lineWidth=(c.lineWidth||l)*r,t.moveTo(c.points[0]*r,c.points[1]*r);for(let d=2;d<c.points.length;d+=2)t.lineTo(c.points[d]*r,c.points[d+1]*r);t.stroke()}t.restore()}}const Dl=1024,WT=['[aria-modal="true"]','[role="dialog"]','[data-overlay-active="true"]',".ant-modal-root",".ant-modal-wrap",".ant-modal",".ant-drawer",".ant-select-dropdown",".ant-picker-dropdown",".ant-dropdown",".ant-popover",".ant-tooltip",".ant-cascader-dropdown",".ant-mentions-dropdown"].join(", ");function Vl(o,t,e){for(let n=0;n<e.length;n+=Dl){const i=e.slice(n,n+Dl);o.splice(t+n,0,...i)}}class YT{container;pageContainer;pageList;ctxList;pageNo;renderCount;pagePixelRatio;mode;options;position;zone;elementList;listener;eventBus;override;i18n;canvasEvent;globalEvent;cursor;range;margin;background;badge;search;group;area;underline;strikeout;highlight;historyManager;previewer;imageParticle;laTexParticle;textParticle;tableParticle;tableTool;tableOperate;pageNumber;lineNumber;waterMark;placeholder;header;footer;hyperlinkParticle;labelParticle;macroParticle;dateParticle;separatorParticle;pageBreakParticle;superscriptParticle;subscriptParticle;checkboxParticle;radioParticle;menstrualHistoryParticle;fetalHeartPositionParticle;toothPositionParticle;blockParticle;listParticle;lineBreakParticle;whiteSpaceParticle;control;pageBorder;workerManager;scrollObserver;selectionObserver;imageObserver;graffiti;command;interactionPaused;overlayActiveCount;globalShortcutSuspended;LETTER_REG;WORD_LIKE_REG;rowList;pageRowList;painterStyle;painterOptions;visiblePageNoList;intersectionPageNo;lazyRenderIntersectionObserver;printModeData;readonlyModeData;splitTdValueMap=new Map;tdMap=new Map;constructor(t,e,n,i,l,r){this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.renderCount=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=n.main,this.listener=i,this.eventBus=l,this.override=r,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new mT(e.locale),this.historyManager=new pd(this),this.position=new Cd(this),this.zone=new IT(this),this.range=new Id(this),this.margin=new Ed(this),this.background=new Ld(this),this.badge=new DT(this),this.search=new Md(this),this.group=new ET(this),this.area=new bT(this),this.underline=new Sd(this),this.strikeout=new Od(this),this.highlight=new Pd(this),this.previewer=new RT(this),this.imageParticle=new Vs(this),this.laTexParticle=new Us(this),this.textParticle=new Xd(this),this.tableParticle=new yd(this),this.tableTool=new bd(this),this.tableOperate=new yT(this),this.pageNumber=new vn(this),this.lineNumber=new ST(this),this.waterMark=new Qd(this),this.placeholder=new bl(this),this.header=new Yd(this,n.header),this.footer=new LT(this,n.footer),this.hyperlinkParticle=new Dd(this),this.labelParticle=new Vd(this),this.macroParticle=new Wd(this),this.dateParticle=new hT(this),this.separatorParticle=new Zd(this),this.pageBreakParticle=new vd(this),this.superscriptParticle=new Ud,this.subscriptParticle=new wd,this.checkboxParticle=new nT(this),this.radioParticle=new oT(this),this.menstrualHistoryParticle=new iT(this),this.fetalHeartPositionParticle=new sT(this),this.toothPositionParticle=new rT(this),this.blockParticle=new TT(this),this.listParticle=new PT(this),this.lineBreakParticle=new To(this),this.whiteSpaceParticle=new MT(this),this.control=new zg(this),this.pageBorder=new XT(this),this.graffiti=new VT(this,n.graffiti),this.scrollObserver=new Nd(this),this.selectionObserver=new Fd(this),this.imageObserver=new pT,new OT(this),this.canvasEvent=new fd(this),this.cursor=new Dc(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new md(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new uT(this),new FT(this);const{letterClass:a}=e;this.LETTER_REG=new RegExp(`[${a.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${a.map(c=>`[^${c}][${c}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.readonlyModeData=null,this.interactionPaused=!1,this.overlayActiveCount=0,this.globalShortcutSuspended=!1,this.isPrintLikeMode()&&this.setPrintData(),this.mode===s.EditorMode.READONLY&&this.setReadonlyData(),this.mode,s.EditorMode.FORM,this.render({isInit:!0,isSetCursor:!1,isFirstRender:!0})}setPrintData(){this.printModeData||(this.printModeData=ct({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const t=ct(this.printModeData);["header","main","footer"].forEach(l=>{t[l]=this.control.filterAssistElement(t[l])});const n=t,i=this.removeStrikeout(n);t.main=i.main.filter(l=>!l.strikeout),this.setEditorData(i)}removeStrikeout(t){if(Array.isArray(t))return t.map(e=>this.removeStrikeout(e)).filter(e=>!(e&&typeof e=="object"&&"strikeout"in e&&e.strikeout===!0));if(t&&typeof t=="object"){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this.removeStrikeout(t[n]));return e}return t}clearPrintData(){this.printModeData&&(this.setEditorData(ct(this.printModeData)),this.printModeData=null)}setReadonlyData(){this.readonlyModeData||(this.readonlyModeData=ct({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const t=ct(this.readonlyModeData);["header","main","footer"].forEach(n=>{const i=wt(t[n],{editorOptions:this.options});t[n]=Dn(i),jt(t[n],{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData(t)}clearReadonlyData(){if(this.readonlyModeData){const t=ct(this.readonlyModeData);this.readonlyModeData=null,this.setEditorData(t)}}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}isPrintLikeMode(t=this.mode){return t===s.EditorMode.PRINT||t===s.EditorMode.COMPARE}isContentReadonly(){if(this.mode===s.EditorMode.COMPARE)return!0;if(this.area.getActiveAreaInfo()?.area?.mode)return this.area.isReadonly();switch(this.mode){case s.EditorMode.DESIGN:return!1;case s.EditorMode.READONLY:case s.EditorMode.PRINT:case s.EditorMode.GRAFFITI:return!0;case s.EditorMode.FORM:if(this.control.getIsRangeWithinControl()){const t=this.getElementList(),{startIndex:e}=this.range.getRange(),n=t[e];if(n?.control?.type===s.ControlType.TEXTFIELD){const i=n.controlId;if(i){for(let l=0;l<t.length;l++)if(t[l].originControlId===i&&t[l].controlId!==i)return!1}return!0}}return!this.control.getIsRangeWithinControl();default:return!1}}isSelectionDisabled(){return this.mode===s.EditorMode.COMPARE?!1:this.area.getActiveAreaInfo()?.area?.mode?this.area.isReadonly():this.mode===s.EditorMode.READONLY||this.mode===s.EditorMode.PRINT||this.mode===s.EditorMode.GRAFFITI}setMode(t){if(this.mode===t)return;const e=this.mode;this.macroParticle.clearInlineEditor({isSubmitHistory:!1}),this.mode=t,this.options.mode=t;const n=this.isPrintLikeMode(t);this.isPrintLikeMode(e)&&this.clearPrintData(),e===s.EditorMode.READONLY&&t!==s.EditorMode.READONLY&&this.clearReadonlyData(),n&&!this.printModeData&&(this.printModeData=ct({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const i=new Map,l=a=>{a.forEach(c=>{c.controlId&&(c.controlComponent==="value"&&i.set(c.controlId,!0),c.checked&&i.set(c.controlId,!0))})};l(this.elementList),this.elementList.forEach(a=>{a.type==="table"&&a.trList?.forEach(c=>{c.tdList?.forEach(d=>{l(d.value)})})});const r=a=>{a.forEach(c=>{if(!(!c.control&&!c.controlId)&&(c.controlComponent==="value"&&c.strikeout&&(n?c.hide=!0:c.hide=!1),!!c.control&&!(c.type!=="control"&&c.control.type!=="button"))){if(c.control.type==="TextField"&&(c.controlComponent==="placeholder"||c.controlComponent==="preTextFix"||c.controlComponent==="preTextFixText"||c.controlComponent==="postTextFix"||c.controlComponent==="postTextFixText"||c.controlComponent==="textFixLabel")&&(t===s.EditorMode.EDIT?c.hide=!1:c.hide=!0),c.control.type==="text"&&(c.controlComponent==="placeholder"||c.controlComponent==="prefix"||c.controlComponent==="postfix")&&(t===s.EditorMode.EDIT||t===s.EditorMode.FORM?c.hide=!1:c.hide=!0),c.control.type==="number"||c.control.type==="select"||c.control.type==="date"||c.control.type==="checkbox"||c.control.type==="radio"){if(c.controlComponent==="placeholder"||c.controlComponent==="prefix"||c.controlComponent==="postfix"){const u=i.get(c.controlId);c.control.type==="select"&&n||n&&!u?c.hide=!0:c.hide=!1}c.control.type==="number"&&c.controlComponent==="value"&&(n&&c.strikeout?c.hide=!0:!n&&c.strikeout&&(c.hide=!1))}c.control.type==="button"&&(c.hide=!1,c.control.hide=!1),c.control.type==="menstrualHistory"&&(c.controlComponent==="prefix"||c.controlComponent==="postfix")&&(n?c.hide=!0:c.hide=!1)}})};r(this.elementList),this.elementList.forEach(a=>{a.type==="table"&&a.trList.forEach(c=>{c.tdList.forEach(d=>{r(d.value)})})}),t===s.EditorMode.FORM?(this.elementList.filter(a=>a.type==="control").map(a=>{a.control?.type==="button"&&(a.controlComponent==="prefix"||a.controlComponent==="postfix"?(a.color="#1677FF",a.highlight="transparent"):a.controlComponent==="value"&&(a.color=this.options.defaultColor,a.highlight="transparent"))}),this.hideTextFieldWhitespace(this.elementList,!0),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):t===s.EditorMode.EDIT?(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!1,!0)),n?(this.elementList.filter(a=>a?.control?.type==="button").map(a=>{(a?.controlComponent==="prefix"||a?.controlComponent==="postfix")&&(a.color="transparent",a.highlight="transparent"),a?.controlComponent==="value"&&!a.control.buttonText&&(a.color=this.options.defaultColor,a.highlight="transparent")}),this.setPrintData()):(this.clearPrintData(),this.elementList.filter(a=>a?.control?.type==="button").map(a=>{(a?.controlComponent==="prefix"||a?.controlComponent==="postfix")&&(a.color="#1677FF",a.highlight="transparent"),a?.controlComponent==="value"&&!a.control.buttonText&&(a.color=this.options.defaultColor,a.highlight="transparent"),a?.type==="text"&&a.control.buttonText&&(a.color="#000"),a?.type==="control"&&a?.controlComponent==="value"&&a.control.buttonText&&(a.color="#000",a.highlight="transparent")})),t===s.EditorMode.READONLY&&this.setReadonlyData(),this.clearSideEffect(),this.control.destroyControl(),this.range.clearRange(),this.render({isSetCursor:!1,isSubmitHistory:!1})}hideTextFieldWhitespace(t,e){const n=a=>a?/^[\s\u00A0\u2000-\u200B\u3000\n\r\t]+$/.test(a):!1,i=(a,c)=>{for(let d=0;d<a.length;d++){const u=a[d];if(u.type===s.ElementType.TABLE&&u.trList)for(const R of u.trList)for(const h of R.tdList)i(h.value,c);u.originControlId&&u.controlId&&u.originControlId!==u.controlId&&c.add(u.originControlId)}},l=new Set;e&&i(t,l),(a=>{for(let c=0;c<a.length;c++){const d=a[c];if(d.type===s.ElementType.TABLE&&d.trList)for(const u of d.trList)for(const R of u.tdList)this.hideTextFieldWhitespace(R.value,e);d.control?.type===s.ControlType.TEXTFIELD&&d.controlComponent===s.ControlComponent.VALUE&&n(d.value)&&(d.controlId&&l.has(d.controlId)?d.hide=!1:d.hide=e)}})(t)}getSubTemplateRuntimeEndIndex(t,e,n){let i=e+1;for(;i<t.length&&t[i].subTemplateParentId===n;)i++;return i}syncSubTemplateExpandedState(t,e,n,i,l){let r=!1;const a=this.getSubTemplateRuntimeEndIndex(t,e,n.id);if(i&&!n.subTemplateContent?.length&&(i=!1),n.subTemplateExpanded!==i&&(n.subTemplateExpanded=i,r=!0),!!n.hide!==l&&(n.hide=l,r=!0),!i)return a>e+1&&(t.splice(e+1,a-e-1),r=!0),r;if(a===e+1){const c=ct(n.subTemplateContent||[]);jt(c,{isHandleFirstElement:!1,editorOptions:this.options});for(let d=0;d<c.length;d++)c[d].subTemplateParentId=n.id;c.length&&(t.splice(e+1,0,...c),r=!0)}return r}applySubTemplateRuntimeState(t,e){const n=i=>{let l=!1,r=0;for(;r<i.length;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE){const c=!!a.subTemplateConditions?.length;if(this.mode===s.EditorMode.EDIT&&c)l=this.syncSubTemplateExpandedState(i,r,a,!0,!0)||l;else if((this.mode===s.EditorMode.FORM||this.isPrintLikeMode())&&c){const d=e?eT(a.subTemplateConditions,e,a.subTemplateRelation):!1;l=this.syncSubTemplateExpandedState(i,r,a,d,!0)||l}else this.mode!==s.EditorMode.FORM&&!this.isPrintLikeMode()&&(l=this.syncSubTemplateExpandedState(i,r,a,!1,!1)||l)}if(a.valueList?.length&&(l=n(a.valueList)||l),a.control?.value?.length&&(l=n(a.control.value)||l),a.type===s.ElementType.TABLE&&a.trList?.length)for(let c=0;c<a.trList.length;c++){const d=a.trList[c];for(let u=0;u<d.tdList.length;u++)l=n(d.tdList[u].value)||l}r++}return l};return n(t)}updateTextFieldPlaceholderVisibility(t,e,n){const i=[s.ControlType.TEXT,s.ControlType.TEXTFIELD,s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.CHECKBOX,s.ControlType.RADIO,s.ControlType.NUMBER];(r=>{let a=0;for(;a<r.length;){const c=r[a];if(c.type===s.ElementType.TABLE&&c.trList)for(const d of c.trList)for(const u of d.tdList)this.updateTextFieldPlaceholderVisibility(u.value,e,n);if(c.control?.type&&i.includes(c.control.type)&&(c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PRE_TEXT)){const d=c.controlId,u=c.control.type;let R=!1,h=!1,g=!1;const T=[],f=[],p=[];let C=-1,I=a;for(;I<r.length;){const m=r[I];if(m.controlId!==d){const P=m.controlId;let E=u===s.ControlType.TEXT,M=I;if(E)for(;M<r.length&&r[M].controlId===P;)M++;else for(;M<r.length;){const F=r[M];if(F.controlId!==P)break;F.controlComponent===s.ControlComponent.VALUE&&(F.value&&F.value.trim()||F.type===s.ElementType.MENSTRUAL_HISTORY||F.type===s.ElementType.FETAL_HEART_POSITION||F.type===s.ElementType.TOOTH_POSITION||F.type===s.ElementType.MACRO||F.type===s.ElementType.CUSTOM_MACRO)&&(E=!0),M++}E&&(h=!0),I=M;continue}if((m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&f.push(I),m.controlComponent===s.ControlComponent.VALUE&&m.value&&m.value.trim()&&(R=!0),m.controlComponent===s.ControlComponent.VALUE&&(m.type===s.ElementType.MENSTRUAL_HISTORY||m.type===s.ElementType.FETAL_HEART_POSITION||m.type===s.ElementType.TOOTH_POSITION||m.type===s.ElementType.MACRO||m.type===s.ElementType.CUSTOM_MACRO)&&(R=!0),m.controlComponent===s.ControlComponent.VALUE&&m.control&&m.control.type!==u&&(h=!0),m.controlComponent===s.ControlComponent.PLACEHOLDER&&(g=!0,T.push(I)),m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT){p.push(I),C=I;break}I++}if(R||h){if(g&&T.length>0)for(const m of T)r[m].hide=!0}else if(g&&T.length>0)for(const m of T)r[m].hide=!e;else e&&c.control?.placeholder&&(C>0?this.control.addPlaceholder(C-1):this.control.addPlaceholder(a));if(n)if(e&&(R||h)){for(const m of f)r[m].hide=!0;for(const m of p)r[m].hide=!0}else if(e){for(const m of f)r[m].hide=!1;for(const m of p)r[m].hide=!1}else{for(const m of f)r[m].hide=!0;for(const m of p)r[m].hide=!0}else{for(const m of f)r[m].hide=!1;for(const m of p)r[m].hide=!1}a=I}a++}})(t)}isReadonly(){return this.isContentReadonly()}isDisabled(){if(this.mode===s.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if(this.getTd()?.disabled)return!0;if(t===e){const l=n[t],r=n[t+1];return!!(l?.title?.disabled&&r?.title?.disabled&&l.titleId===r.titleId||l?.control?.disabled&&r?.control?.disabled&&l.controlId===r.controlId)}return n.slice(t+1,e+1).some(l=>l.title?.disabled||l.control?.disabled)}isDesignMode(){return this.mode===s.EditorMode.DESIGN}isPrintMode(){return this.mode===s.EditorMode.PRINT}isGraffitiMode(){return this.mode===s.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===s.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===s.PaperDirection.VERTICAL?n:e}getWidth(){return Math.floor(this.getOriginalWidth()*this.options.scale)}getHeight(){return Math.floor(this.getOriginalHeight()*this.options.scale)}getMainHeight(){return this.getHeight()-this.getMainOuterHeight()}getMainOuterHeight(){const t=this.getMargins(),e=this.header.getExtraHeight(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}getCanvasWidth(t=-1){return this.getPage(t).width}getCanvasHeight(t=-1){return this.getPage(t).height}getInnerWidth(){const t=this.getWidth(),e=this.getMargins();return t-e[1]-e[3]}getOriginalInnerWidth(){const t=this.getOriginalWidth(),e=this.getOriginalMargins();return t-e[1]-e[3]}getContextInnerWidth(){const t=this.position.getPositionContext();if(t.isTable){const{index:e,trIndex:n,tdIndex:i}=t,r=this.getOriginalElementList()[e],a=r.trList[n].tdList[i],c=this.getTdPadding(r);return a.width-c[1]-c[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===s.PaperDirection.VERTICAL?t:[t[1],t[2],t[3],t[0]]}getPageGap(){return this.options.pageGap*this.options.scale}getOriginalPageGap(){return this.options.pageGap}getPageNumberBottom(){const{pageNumber:{bottom:t},scale:e}=this.options;return t*e}getMarginIndicatorSize(){return this.options.marginIndicatorSize*this.options.scale}getDefaultBasicRowMarginHeight(){return this.options.defaultBasicRowMarginHeight*this.options.scale}getHighlightMarginHeight(){return this.options.highlightMarginHeight*this.options.scale}getTdPadding(t){const{table:{tdPadding:e},scale:n}=this.options;return(t?.tdPadding||e).map(l=>l*n)}getContainer(){return this.container}getPageContainer(){return this.pageContainer}getEventTarget(t){return t instanceof Element?t:t instanceof Node?t.parentElement:null}isTargetInsideEditor(t){const e=this.getEventTarget(t);return e?this.container.contains(e)?!0:!!Os(e,n=>!!n&&n.nodeType===1&&!!n.getAttribute(Be)):!1}isTargetInsideExternalOverlay(t){const e=this.getEventTarget(t);return!e||this.isTargetInsideEditor(e)?!1:!!e.closest(WT)}pauseInteraction(){this.interactionPaused=!0,this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect()}resumeInteraction(){this.interactionPaused=!1}setOverlayActive(t){this.overlayActiveCount=t?1:0,t&&(this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect())}suspendGlobalShortcut(t){this.globalShortcutSuspended=t}isInteractionSuspended(){return this.interactionPaused||this.overlayActiveCount>0}isGlobalShortcutActive(){return!this.globalShortcutSuspended&&!this.isInteractionSuspended()}getVisiblePageNoList(){return this.visiblePageNoList}setVisiblePageNoList(t){this.visiblePageNoList=t,this.listener.visiblePageNoListChange&&this.listener.visiblePageNoListChange(this.visiblePageNoList),this.eventBus.isSubscribe("visiblePageNoListChange")&&this.eventBus.emit("visiblePageNoListChange",this.visiblePageNoList)}getIntersectionPageNo(){return this.intersectionPageNo}setIntersectionPageNo(t){this.intersectionPageNo=t,this.listener.intersectionPageNoChange&&this.listener.intersectionPageNoChange(this.intersectionPageNo),this.eventBus.isSubscribe("intersectionPageNoChange")&&this.eventBus.emit("intersectionPageNoChange",this.intersectionPageNo)}getPageNo(){return this.pageNo}setPageNo(t){this.pageNo=t}getRenderCount(){return this.renderCount}getPage(t=-1){return this.pageList[~t?t:this.pageNo]}getPageList(){return this.pageList}getPageCount(){return this.pageList.length}getTableRowList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:l}=e;return t[n].trList[i].tdList[l].rowList}getOriginalRowList(){const t=this.getZone();return t.isHeaderActive()?this.header.getRowList():t.isFooterActive()?this.footer.getRowList():this.rowList}getRowList(){return this.position.getPositionContext().isTable?this.getTableRowList(this.getOriginalElementList()):this.getOriginalRowList()}getPageRowList(){return this.pageRowList}getCtx(){return this.ctxList[this.pageNo]}getOptions(){return this.options}getSearch(){return this.search}getGroup(){return this.group}getArea(){return this.area}getBadge(){return this.badge}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getLineBreakParticle(){return this.lineBreakParticle}getTextParticle(){return this.textParticle}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:l}=e;return t[n]?.trList?.[i].tdList[l].value||[]}getElementList(){const t=this.position.getPositionContext(),e=this.getOriginalElementList();return t.isTable?this.getTableElementList(e):e}getMainElementList(){return this.position.getPositionContext().isTable?this.getTableElementList(this.elementList):this.elementList}getOriginalElementList(){const t=this.getZone();return t.isHeaderActive()?this.getHeaderElementList():t.isFooterActive()?this.getFooterElementList():this.elementList}getOriginalMainElementList(){return this.elementList}getFooterElementList(){return this.footer.getElementList()}getTd(){const t=this.position.getPositionContext(),{index:e,trIndex:n,tdIndex:i,isTable:l}=t;return l?this.getOriginalElementList()[e].trList[n].tdList[i]:null}getTdByPosition(t){const{index:e,trIndex:n,tdIndex:i,isTable:l}=t;return l?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementTextField(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.getElementList(),{isSubmitHistory:r=!0}=e;jt(t,{isHandleFirstElement:!1,editorOptions:this.options});let a=-1,c=this.control.getActiveControl();if(!c&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),c=this.control.getActiveControl()),c&&this.control.getIsRangeWithinControl()){const d=n===i,u=n+1;d||this.newSpliceElementList(l,u,i-n),this.newSpliceElementList(l,u,0,t),a=n+t.length}else{const d=n===i,u=n+1;d||this.newSpliceElementList(l,u,i-n),this.newSpliceElementList(l,u,0,t),a=n+t.length;const R=l[u-1];t[0].listId&&R&&!R.listId&&R?.value===K&&(!R.type||R.type===s.ElementType.TEXTFIELD)&&(l.splice(n,1),a-=1)}this.control.destroyControl(),~a&&(this.range.setRange(a,a),this.render({curIndex:a,isSubmitHistory:r}))}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:l=!0}=e;jt(t,{isHandleFirstElement:!1,editorOptions:this.options});let r=-1,a=this.control.getActiveControl();if(!a&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),a=this.control.getActiveControl()),a&&this.control.getIsRangeWithinControl()){const c=this.getElementList(),d=n===i,u=n+1,R=c[n],h=c[u],g=M=>!!(M&&(M.controlComponent===s.ControlComponent.POSTFIX||M.controlComponent===s.ControlComponent.POST_TEXT||M.controlComponent===s.ControlComponent.POSTTEXTFIX||M.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)),T=M=>!!(M&&(M.controlComponent===s.ControlComponent.PREFIX||M.controlComponent===s.ControlComponent.PRE_TEXT||M.controlComponent===s.ControlComponent.PRETEXTFIX||M.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)),f=M=>{if(M)return c.find(F=>F.controlId===M&&!F.originControlId&&!!F.control?.type)},p=R?.originControlId&&h?.originControlId===R.originControlId&&R.controlId&&h.controlId&&R.controlId!==h.controlId&&g(R)&&T(h)?f(R.originControlId):void 0,C=p?.control?.type===s.ControlType.TEXTFIELD,I=!!(R?.originControlId&&g(R)&&h?.controlId===R.originControlId&&!h.originControlId&&h.control?.type===s.ControlType.TEXTFIELD&&g(h)),m=!!(R?.originControlId&&g(R)&&h?.controlId===R.originControlId&&!h.originControlId&&h.control?.type===s.ControlType.TEXTFIELD&&h.controlComponent===s.ControlComponent.VALUE);if(R?.controlComponent===s.ControlComponent.PRE_TEXT||R?.controlComponent===s.ControlComponent.POST_TEXT||R?.controlComponent===s.ControlComponent.PREFIX||R?.controlComponent===s.ControlComponent.POSTFIX)for(let M=0;M<t.length;M++)t[M].control||(t[M].color=this.options.defaultColor);d&&!I&&!m&&(c[n]?.control?.type===s.ControlType.TEXTFIELD||c[n]?.control?.type===s.ControlType.TEXT)&&this.control.removePlaceholder(n),d||this.newSpliceElementList(c,u,i-n);const E=I||m||C?R.originControlId:c[n]?.controlId||c[n-1]?.controlId||c[n+1]?.controlId;for(let M=0;M<t.length;M++){if((I||m||C)&&!t[M].control&&(t[M].controlId=E,t[M].control=C?p?.control:h.control,t[M].controlComponent=s.ControlComponent.VALUE,delete t[M].originControlId),t[M]?.control?.type=="button"&&!t[M]?.control?.buttonText&&(t[M]?.controlComponent==="prefix"||t[M]?.controlComponent==="postfix"?(t[M].color="#1677FF",t[M].highlight="transparent"):(t[M].color=this.options.defaultColor,t[M].highlight="transparent")),t[M]?.type===s.ElementType.MENSTRUAL_HISTORY||t[M]?.type===s.ElementType.FETAL_HEART_POSITION||t[M]?.type===s.ElementType.TOOTH_POSITION||t[M]?.type===s.ElementType.MACRO||t[M]?.type===s.ElementType.CUSTOM_MACRO||t[M]?.type===s.ElementType.REUSABLE_ITEM||t[M]?.type===s.ElementType.SUB_TEMPLATE||t[M]?.type===s.ElementType.SPECIAL_SYMBOLS){t[M].controlComponent=s.ControlComponent.VALUE;let F=c[n]?.controlId;F||(F=c[n-1]?.controlId),F||(F=c[n+1]?.controlId),!t[M].controlId&&F&&(t[M].controlId=F)}E&&t[M]?.control&&t[M].controlId&&t[M].controlId!==E&&(t[M].originControlId=E)}this.newSpliceElementList(c,u,0,t),r=n+t.length}else{const c=this.getElementList(),d=n===i,u=n+1;if(c[u]?.control?.type=="TextField"||c[n]?.control?.type=="TextField"){d||this.newSpliceElementList(c,u,i-n);for(let R=0;R<t.length;R++)if(t[R]?.type===s.ElementType.MENSTRUAL_HISTORY||t[R]?.type===s.ElementType.FETAL_HEART_POSITION||t[R]?.type===s.ElementType.TOOTH_POSITION||t[R]?.type===s.ElementType.MACRO||t[R]?.type===s.ElementType.CUSTOM_MACRO||t[R]?.type===s.ElementType.REUSABLE_ITEM||t[R]?.type===s.ElementType.SUB_TEMPLATE||t[R]?.type===s.ElementType.SPECIAL_SYMBOLS){t[R].controlComponent=s.ControlComponent.VALUE;const h=c[n]?.controlId||c[u]?.controlId;!t[R].controlId&&h&&(t[R].controlId=h)}this.newSpliceElementList(c,u,0,t),r=n+t.length}else{d||this.spliceElementList(c,u,i-n);for(let h=0;h<t.length;h++)t[h]?.control?.type=="button"&&!t[h]?.control?.buttonText&&(t[h]?.controlComponent==="prefix"||t[h]?.controlComponent==="postfix"?(t[h].color="#1677FF",t[h].highlight="transparent"):(t[h].color=this.options.defaultColor,t[h].highlight="transparent"));this.spliceElementList(c,u,0,t),r=n+t.length;const R=c[u-1];t[0].listId&&R&&!R.listId&&R?.value===K&&(!R.type||R.type===s.ElementType.TEXT)&&(c.splice(n,1),r-=1)}}~r&&(this.range.setRange(r,r),this.render({curIndex:r,isSubmitHistory:l}))}appendElementList(t,e={}){if(!t.length)return;jt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:l=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:l})}spliceElementList(t,e,n,i,l){const{isIgnoreDeletedRule:r=!1}=l||{},{group:a,modeRule:c}=this.options;if(n>0){const d=e+n,R=t[d]?.listId;if(R&&t[e-1]?.listId!==R){let h=d;for(;h<t.length;){const g=t[h];if(g.listId!==R||g.value===K)break;delete g.listId,delete g.listType,delete g.listStyle,h++}}if(!r&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const h=this.getTd()?.deletable;let g=d-1;for(;g>=e;){const T=t[g];(ae(T)||h!==!1&&T?.control?.deletable!==!1&&(!T.controlId||this.mode!==s.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&T?.title?.deletable!==!1&&(a.deletable!==!1||!T.groupIds?.length)&&(T?.area?.deletable!==!1||T?.areaIndex!==0))&&t.splice(g,1),g--}}else t.splice(e,n)}if(i?.length){let d=t[e];for(let u=0;u<i.length;u++)!i[u].controlComponent&&d?.controlComponent&&(i[u].controlId=d.controlId,i[u].control=d.control,i[u].controlComponent=d.controlComponent),d=i[u];Vl(t,e,i)}}newSpliceElementList(t,e,n,i,l){const{isIgnoreDeletedRule:r=!1}=l||{},{group:a,modeRule:c}=this.options;if(n>0){const u=e+n,h=t[u]?.listId;if(h&&t[e-1]?.listId!==h){let g=u;for(;g<t.length;){const T=t[g];if(T.listId!==h||T.value===K)break;delete T.listId,delete T.listType,delete T.listStyle,g++}}if(!r&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const g=this.getTd()?.deletable;let T=u-1;for(;T>=e;){const f=t[T];(ae(f)||g!==!1&&f?.control?.deletable!==!1&&(!f.controlId||this.mode!==s.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&f?.title?.deletable!==!1&&(a.deletable!==!1||!f.groupIds?.length)&&(f?.area?.deletable!==!1||f?.areaIndex!==0))&&t.splice(T,1),T--}}else t.splice(e,n)}const d=t[e]?.controlId;if(i?.length){for(let u=0;u<i.length;u++)d&&i[u].controlId!==d&&(i[u].originControlId=d);Vl(t,e,i)}}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}getTableTool(){return this.tableTool}getTableOperate(){return this.tableOperate}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getMacroParticle(){return this.macroParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getMenstrualHistoryParticle(){return this.menstrualHistoryParticle}getFetalHeartPositionParticle(){return this.fetalHeartPositionParticle}getToothPositionParticle(){return this.toothPositionParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}setCommand(t){this.command=t}getCommand(){return this.command}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,l=!!n&&i!==n;l&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const r=this.pageList.map(a=>a.toDataURL());return e&&this.setPagePixelRatio(null),l&&this.setMode(i),r}getPainterStyle(){return this.painterStyle&&Object.keys(this.painterStyle).length?this.painterStyle:null}getPainterOptions(){return this.painterOptions}setPainterStyle(t,e){this.painterStyle=t,this.painterOptions=e||null,this.getPainterStyle()&&this.pageList.forEach(n=>n.style.cursor="copy")}setDefaultRange(){this.elementList.length&&setTimeout(()=>{const t=this.elementList.length-1;this.range.setRange(t,t),this.range.setRangeStyle()})}getIsPagingMode(){return this.options.pageMode===s.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===s.PageMode.PAGING){const{height:i}=this.options,l=this.getPagePixelRatio(),r=this.pageList[0];r.style.height=`${i}px`,r.height=i*l,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(s.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,a)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,r.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[a])});const l=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!l,curIndex:l?.index}),this.listener.pageScaleChange&&this.listener.pageScaleChange(t),this.eventBus.isSubscribe("pageScaleChange")&&this.eventBus.emit("pageScaleChange",t)}getPagePixelRatio(){return this.pagePixelRatio||window.devicePixelRatio}setPagePixelRatio(t){!this.pagePixelRatio&&t===window.devicePixelRatio||t===this.pagePixelRatio||(this.pagePixelRatio=t,this.setPageDevicePixel())}setPageDevicePixel(){const t=this.getPagePixelRatio(),e=this.getWidth(),n=this.getHeight();this.pageList.forEach((i,l)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[l])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),l=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((r,a)=>{r.width=i*n,r.height=l*n,r.style.width=`${i}px`,r.style.height=`${l}px`,this._initPageContext(this.ctxList[a])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((l,r)=>{l.width=n*e,l.height=i*e,l.style.width=`${n}px`,l.style.height=`${i}px`,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getOriginValue(t={}){const{pageNo:e}=t,n=this.readonlyModeData;let i=n?.main||this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(i=this.pageRowList[e].flatMap(r=>r.elementList)),{header:n?.header||this.getHeaderElementList(),main:i,footer:n?.footer||this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t);console.log(this.elementList,"所有元素");const{extraPickAttrs:n}=t,i={header:wt(e.header,{extraPickAttrs:n,editorOptions:this.options}),main:wt(e.main,{extraPickAttrs:n,isClassifyArea:!0,editorOptions:this.options}),footer:wt(e.footer,{extraPickAttrs:n,editorOptions:this.options}),graffiti:e.graffiti};return{version:fn,data:i,options:ct(this.options)}}setValue(t,e){const{header:n,main:i,footer:l}=ct(t);if(!n&&!i&&!l)return;const{isSetCursor:r=!1}=e||{};[n,i,l].forEach(d=>{d&&jt(d,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:l}),this.mode===s.EditorMode.READONLY?(this.readonlyModeData=null,this.setReadonlyData()):this.isPrintLikeMode()&&(this.printModeData=null,this.setPrintData()),this.historyManager.recovery();const c=r?i?.length?i.length-1:0:void 0;c!==void 0&&this.range.setRange(c,c),this.render({curIndex:c,isSetCursor:r,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_wrapContainer(t){const e=document.createElement("div");return t.append(e),e}_formatContainer(){this.container.style.position="relative",this.container.style.width=`${this.getWidth()}px`,this.container.setAttribute(Be,s.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const l=this.getPagePixelRatio();i.width=e*l,i.height=n*l,i.style.cursor="text";const r=i.getContext("2d");this._initPageContext(r),this.pageList.push(i),this.ctxList.push(r)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}getElementFont(t,e=1){const{defaultSize:n,defaultFont:i}=this.options,l=t.font||i,r=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${r*e}px ${l}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:l}=this.options,r=t.size||e;let a=1;return r<12?a=r/12:r>30&&(a=1+(r-30)/30),n*a*(t.rowMargin??i)*l}computeRowList(t){const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:l=!1,startX:r=0,startY:a=0,pageHeight:c=0,mainOuterHeight:d=0,surroundElementList:u=[]}=t,{defaultSize:R,scale:h,imgCaption:g,table:{tdPadding:T,defaultTrMinHeight:f},defaultTabWidth:p}=this.options,C=this.getDefaultBasicRowMarginHeight(),m=document.createElement("canvas").getContext("2d"),P=this.listParticle.computeListStyle(m,n),E=[],M=this._collectTextControlValueSet(n),F=this._collectTextControlHasContentSet(n);n.length&&E.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:n?.[0]?.rowFlex||n?.[1]?.rowFlex});let y=r,Y=a,D=0,O,b=0,V=0;for(let X=0;X<n.length;X++){const N=E[E.length-1],L=n[X];this.clearElementEffect(L);const W=this.getElementRowMargin(L),S={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},U=N.offsetX||L.listId&&P.get(L.listId)||0,v=e-U,Q=N.elementList.length===1;if(y+=Q?U:0,Y+=Q&&N.offsetY||0,(L.control?.type===s.ControlType.TEXTFIELD||L.control?.type===s.ControlType.TEXT)&&!this.isDesignMode()&&(L.controlComponent===s.ControlComponent.PRETEXTFIX||L.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||L.controlComponent===s.ControlComponent.POSTTEXTFIX||L.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||L.controlComponent===s.ControlComponent.TEXTFIXLABEL||L.controlComponent===s.ControlComponent.PLACEHOLDER||L.controlComponent===s.ControlComponent.PREFIX||L.controlComponent===s.ControlComponent.POSTFIX)){const J=L.control?.type===s.ControlType.TEXTFIELD,lt=L.controlId,$=!!lt&&!!M?.has(lt);if(J){const j=!!lt&&!!F?.has(lt);this.mode===s.EditorMode.EDIT?L.controlComponent===s.ControlComponent.PLACEHOLDER||L.controlComponent===s.ControlComponent.TEXTFIXLABEL?L.hide=j:L.hide=!1:L.hide=!0}else{const j=!!lt&&!!F?.has(lt);this.mode===s.EditorMode.EDIT||this.mode===s.EditorMode.FORM?L.controlComponent===s.ControlComponent.PLACEHOLDER||L.controlComponent===s.ControlComponent.TEXTFIXLABEL?L.hide=j:L.hide=!1:L.hide=!0}}if(ae(L)&&!this.isDesignMode()){const J=N.elementList[N.elementList.length-1];S.height=J?.metrics.height||this.options.defaultSize*h,S.boundingBoxAscent=J?.metrics.boundingBoxAscent||0,S.boundingBoxDescent=J?.metrics.boundingBoxDescent||0}else if(L.type===s.ElementType.IMAGE||L.type===s.ElementType.LATEX)if(L.imgDisplay===s.ImageDisplay.SURROUND||L.imgDisplay===s.ImageDisplay.FLOAT_TOP||L.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)S.width=0,S.height=0,S.boundingBoxDescent=0;else{const J=L.width*h,lt=L.height*h;if(J>v){const $=lt*v/J;L.width=v/h,L.height=$/h,S.width=v,S.height=$,S.boundingBoxDescent=$}else S.width=J,S.height=lt,S.boundingBoxDescent=lt;if(L.imgCaption?.value){const $=L.imgCaption.size||g.size,j=L.imgCaption.top??g.top,tt=($+j)*h;S.boundingBoxAscent+=tt}}else if(L.type===s.ElementType.TABLE){const J=L.tdPadding||T;if(L.pagingId){let x=X+1,Rt=0;for(;x<n.length;){const ht=n[x];if(ht.pagingId===L.pagingId){const mt=ht.trList.filter(Pt=>!Pt.pagingRepeat).filter(Pt=>(Pt.tdList=Pt.tdList.filter(vt=>{if(vt.originalId){for(let Lt=0;Lt<L.trList.length;Lt++){const At=L.trList[Lt],ee=At.tdList.find(({id:ne})=>ne===vt.originalId);if(ee){vt.value[0]?.type===s.ElementType.SPLIT_TAG&&vt.value.splice(0,1),ee.value.push(...vt.value.map(ne=>this.updateElementTableInfo(ne,L,At,ee))),ee.rowspan=ee.originalRowspan??ee.rowspan;break}}return!1}return!0}),!Pt.originalId));L.trList.push(...mt),L.height+=ht.height,x++,Rt++}else break}Rt&&n.splice(X+1,Rt)}L.pagingIndex=L.pagingIndex??0,this.tableParticle.computeTrHeight(L,x=>this.computeRowList({innerWidth:(x.width-(J[1]+J[3]))*h,elementList:x.value,isFromTable:!0,isPagingMode:i})),L.trList?.forEach(x=>{x.tdList.forEach(Rt=>{this.tdMap.set(Rt.id,Rt)})});const lt=this.tableParticle.getTableHeight(L),$=this.tableParticle.getTableWidth(L);L.width=$,L.height=lt;const j=$*h,tt=lt*h;if(S.width=j,S.height=tt,S.boundingBoxDescent=tt,S.boundingBoxAscent=-W,n[X+1]?.type===s.ElementType.TABLE&&(S.boundingBoxAscent-=W),i){const x=this.getHeight(),Rt=this.getMainOuterHeight();let ht=Rt;for(let Lt=0;Lt<E.length;Lt++){const At=E[Lt],ee=At.offsetY||0;At.height+ht+ee>x||E[Lt-1]?.isPageBreak?ht=Rt+At.height+ee:ht+=At.height+ee}const mt=W*2,Pt=L.trList[0].height*h;(ht+Pt+mt>x||L.pagingIndex!==0&&L.trList[0].pagingRepeat||n[X-1]?.type===s.ElementType.PAGE_BREAK)&&(ht=Rt);let vt=x-(ht+mt);if(tt>vt){const Lt=L.trList;let At=0,ee=0,ne=0;for(let Yt=0;Yt<Lt.length;Yt++){const Xt=Lt[Yt],bt=Xt.height*h;if(ht+mt+ne+bt>x){const Ft=Xt;let Et=0;const Mt={...ct(Ft),id:ft(),originalId:Ft.originalId??Ft.id,minHeight:void 0,tdList:L.colgroup.map((at,Gt)=>{if(Et--,Et>0)return;const k=Ft.tdList.find(it=>it.colIndex===Gt),ot=k??this.tableParticle.findPreRowSpanTd(Lt,Yt,Gt);k&&(Et=k.colspan);const pt=ft();return ot.originalRowspan=ot.rowspan,k?{...k,id:pt,originalId:k.originalId??k.id,linkTdPrevId:k.id,tdIndex:Gt,original:ot}:{id:pt,originalId:ot.originalId??ot.id,linkTdPrevId:ot.id,tdIndex:Gt,colIndex:Gt,colspan:1,rowspan:1,value:[],rowList:[],original:ot}}).filter(at=>!!at)},St=Mt.tdList,Vt=St.map(at=>at.original);Vt.forEach((at,Gt)=>{const k=[];let ot=vt;if(at.rowspan>1){const it=Lt.slice(at.trIndex,at.trIndex+Yt-at.trIndex);ot+=it.reduce((de,kt)=>kt.height*h+de,0)}for(;at.mainHeight*h>ot&&at.rowList?.length;){const it=at.rowList.pop();at.value.splice(at.value.length-it.elementList.length),k.unshift(it),at.mainHeight-=it.height}const pt=St[Gt];pt.rowList=k,pt.value=k.map(it=>it.elementList).flat()});let me=!0;const Ot=Ft.tdList.some(at=>at.rowList?.length),nt=Mt.tdList.some(at=>at.rowList?.length),Ut=Ft.minHeight>vt;if(nt||Ut){(Ot||!nt&&Ut)&&(Ut&&(Ft.originalMinHeight=Ft.minHeight,Ft.minHeight=vt,Mt.minHeight=Math.max(Ft.originalMinHeight-vt,f)),Mt.tdList.forEach(at=>{at.original.linkTdNextId=at.id,at.value.length&&at.value[0].value!==K&&at.value.unshift({...at.original.value.slice(-1).pop(),value:K,type:s.ElementType.SPLIT_TAG})}),Lt.splice(At+1,0,Mt),At+=1,ee=Lt.length-At,me=!1),Vt.forEach(at=>{if(at.rowspan>1){const Gt=at.rowspan-(Yt-at.trIndex);at.rowspan=Yt-at.trIndex+(Ot?1:0);const k=Mt.tdList.find(ot=>ot.colIndex===at.colIndex);Ot?k.rowspan=Gt:(k.original.linkTdNextId=k.id,Ft.tdList.push({...at,...k,rowspan:Gt}),Ft.tdList.sort((ot,pt)=>ot.colIndex-pt.colIndex),k.value=[])}}),me&&Vt.forEach((at,Gt)=>{at.value.push(...St[Gt].value)});break}}At=Yt+1,ee=Lt.length-At,ne+=bt,vt-=bt}if(ee){const Yt=Lt.splice(At,ee),Xt=L.pagingId||ft();L.pagingId=Xt;const bt=ct(L);bt.originalId=L.originalId??L.id,bt.pagingId=Xt,bt.pagingIndex=L.pagingIndex+1;const Ft=Lt.filter(St=>St.pagingRepeat);if(Ft.length){const St=ct(Ft);St.forEach(Vt=>Vt.id=ft()),Yt.unshift(...St)}bt.trList=Yt,bt.id=ft(),bt.trList?.forEach(St=>{St.tdList.forEach(Vt=>{if(delete Vt.valueStartIndex,Vt.linkTdPrevId){const me=this.getTdById(Vt.linkTdPrevId);Vt.valueStartIndex=me?(me.valueStartIndex??0)+me.value.length:0,this.splitTdValueMap.has(Vt.originalId)?this.splitTdValueMap.get(Vt.originalId).push(...Vt.value):me&&this.splitTdValueMap.set(Vt.originalId,[...me.value,...Vt.value])}Vt.value.forEach(me=>this.updateElementTableInfo(me,bt,St,Vt))})}),this.spliceElementList(n,X+1,0,[bt]),this.tableParticle.computeTrHeight(L);const Et=this.tableParticle.getTableHeight(L),Mt=Et*h;L.height=Et,S.height=Mt,S.boundingBoxDescent=Mt}}if(L.pagingId){const Lt=this.position.getPositionContext();if(Lt.isTable){let At=-1,ee=-1,ne=X;for(;ne<n.length;){const Yt=n[ne];if(Yt.pagingId!==L.pagingId)break;const Xt=Yt.trList.findIndex(bt=>bt.id===Lt.trId);if(~Xt){At=ne,ee=Xt;break}ne++}~At&&(Lt.index=At,Lt.trIndex=ee,this.position.setPositionContext(Lt))}}}this.initTableElementIndex(L,X)}else if(L.type===s.ElementType.SEPARATOR){const{separator:{lineWidth:J}}=this.options,lt=L.lineWidth||J;L.width=v/h,S.width=v,S.height=lt*h,S.boundingBoxAscent=-W,S.boundingBoxDescent=-W+S.height}else if(L.type===s.ElementType.PAGE_BREAK)L.width=v/h,S.width=v,S.height=R;else if(L.type===s.ElementType.RADIO||L.controlComponent===s.ControlComponent.RADIO){const{width:J,height:lt,gap:$}=this.options.radio,j=J+$*(L.controlComponent?1:2);L.width=j,S.width=j*h,S.height=lt*h}else if(L.type===s.ElementType.CHECKBOX||L.controlComponent===s.ControlComponent.CHECKBOX){const{width:J,height:lt,gap:$}=this.options.checkbox,j=J+$*(L.controlComponent?1:2);L.width=j,S.width=j*h,S.height=lt*h}else if(L.type===s.ElementType.MENSTRUAL_HISTORY){const J=this.menstrualHistoryParticle.computeSize(L);L.width=J.width/h,S.width=J.width,S.height=J.height,S.boundingBoxAscent=J.height,S.boundingBoxDescent=0}else if(L.type===s.ElementType.FETAL_HEART_POSITION){const J=this.fetalHeartPositionParticle.computeSize();L.width=J.width/h,S.width=J.width,S.height=J.height,S.boundingBoxAscent=J.height/2,S.boundingBoxDescent=J.height/2}else if(L.type===s.ElementType.TOOTH_POSITION){const J=this.toothPositionParticle.computeSize(L);L.width=J.width/h,S.width=J.width,S.height=J.height,S.boundingBoxAscent=J.height/2,S.boundingBoxDescent=J.height/2}else if(L.type===s.ElementType.TAB)S.width=p*h,S.height=R*h,S.boundingBoxDescent=0,S.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(m,m.font);else if(L.type===s.ElementType.BLOCK){if(!L.width)S.width=v;else{const J=L.width*h;S.width=Math.min(J,v)}S.height=L.height*h,S.boundingBoxDescent=S.height,S.boundingBoxAscent=0}else if(L.type===s.ElementType.LABEL){const{defaultSize:J,label:{defaultPadding:lt}}=this.options;m.font=this.getElementFont(L);const $=this.textParticle.measureText(m,L);S.width=($.width+lt[1]+lt[3])*h,S.height=(L.size||J)*h,S.boundingBoxDescent=0,S.boundingBoxAscent=(lt[0]+$.actualBoundingBoxAscent)*h}else if(L.type===s.ElementType.MACRO||L.type===s.ElementType.CUSTOM_MACRO||L.type===s.ElementType.REUSABLE_ITEM||L.type===s.ElementType.SUB_TEMPLATE){const{defaultSize:J}=this.options;m.font=this.getElementFont(L);const lt=this.getMode(),$=lt===s.EditorMode.EDIT,j=lt===s.EditorMode.FORM;if(lt===s.EditorMode.READONLY&&L.type!==s.ElementType.SUB_TEMPLATE){const tt=Oo(L),x=m.measureText(tt);S.width=x.width,S.height=(L.size||J)*h,S.boundingBoxDescent=x.actualBoundingBoxDescent,S.boundingBoxAscent=x.actualBoundingBoxAscent}else if($){const tt=L.label||L.value||"";m.font=this.getElementFont(L);const x=m.measureText(tt),Rt=8*h,ht=4*h;S.width=x.width+Rt*2;const mt=x.actualBoundingBoxAscent+x.actualBoundingBoxDescent;S.height=mt+ht*2;const Pt=this.textParticle.measureBasisWord(m,this.getElementFont(L));S.boundingBoxAscent=Pt.actualBoundingBoxAscent*h,S.boundingBoxDescent=Pt.actualBoundingBoxDescent*h}else if(L.type===s.ElementType.CUSTOM_MACRO){const tt=L.macroConfig,x=tt?.value||"";if(j){const Rt=tt?.type||"text",ht=this.textParticle.measureText(m,L),mt=L.label||"";if(Rt==="select"){const Pt=x||`请选择${mt}`,vt=m.measureText(Pt),Lt=m.measureText("[").width,At=6*h+2*h;S.width=Lt+vt.width+At+Lt}else{const Pt=x||`请输入${mt}`,vt=m.measureText(Pt),Lt=m.measureText("[").width;S.width=Lt+vt.width+Lt}S.height=(L.size||J)*h,S.boundingBoxDescent=ht.actualBoundingBoxDescent*h,S.boundingBoxAscent=ht.actualBoundingBoxAscent*h}else{const Rt=L.label||"",ht=x||`请输入${Rt}`,mt=m.measureText(ht);S.width=mt.width,S.height=(L.size||J)*h,S.boundingBoxDescent=mt.actualBoundingBoxDescent,S.boundingBoxAscent=mt.actualBoundingBoxAscent}}else if(L.type===s.ElementType.REUSABLE_ITEM){const x=L.reusableItemConfig?.value||"",Rt=L.label||"";if(j){const ht=this.textParticle.measureText(m,L),mt=x||`获取 ${Rt}`,Pt=m.measureText(mt),vt=m.measureText("[").width;S.width=vt+Pt.width+vt,S.height=(L.size||J)*h,S.boundingBoxDescent=ht.actualBoundingBoxDescent*h,S.boundingBoxAscent=ht.actualBoundingBoxAscent*h}else{const ht=x||`获取 ${Rt}`,mt=m.measureText(ht);S.width=mt.width,S.height=(L.size||J)*h,S.boundingBoxDescent=mt.actualBoundingBoxDescent,S.boundingBoxAscent=mt.actualBoundingBoxAscent}}else if(L.type===s.ElementType.SUB_TEMPLATE){const tt=L.label||"子模板";if(j){const x=m.measureText(tt),Rt=8*h,ht=4*h,mt=x.actualBoundingBoxAscent+x.actualBoundingBoxDescent;S.width=x.width+Rt*2,S.height=mt+ht*2;const Pt=this.textParticle.measureBasisWord(m,this.getElementFont(L));S.boundingBoxAscent=Pt.actualBoundingBoxAscent*h,S.boundingBoxDescent=Pt.actualBoundingBoxDescent*h}else{const x=m.measureText(tt);S.width=x.width,S.height=(L.size||J)*h,S.boundingBoxDescent=x.actualBoundingBoxDescent,S.boundingBoxAscent=x.actualBoundingBoxAscent}}else{const tt=L.label||"",x=L.value||`获取 ${tt}`,Rt=m.measureText(x);S.width=Rt.width,S.height=(L.size||J)*h,S.boundingBoxDescent=Rt.actualBoundingBoxDescent,S.boundingBoxAscent=Rt.actualBoundingBoxAscent}}else{const J=L.size||R;(L.type===s.ElementType.SUPERSCRIPT||L.type===s.ElementType.SUBSCRIPT)&&(L.actualSize=Math.ceil(J*.6)),S.height=(L.actualSize||J)*h,m.font=this.getElementFont(L);const lt=this.textParticle.measureText(m,L);S.width=lt.width*h,L.letterSpacing&&(S.width+=L.letterSpacing*h);const $=this.textParticle.measureBasisWord(m,L.font);S.boundingBoxAscent=$.actualBoundingBoxAscent*h,S.boundingBoxDescent=$.actualBoundingBoxDescent*h,L.type===s.ElementType.SUPERSCRIPT?S.boundingBoxAscent+=S.height/2:L.type===s.ElementType.SUBSCRIPT&&(S.boundingBoxDescent+=S.height/2)}const w=!ae(L)&&(L.imgDisplay!==s.ImageDisplay.INLINE&&L.type===s.ElementType.IMAGE||L.type===s.ElementType.LATEX)?S.height+W:S.boundingBoxAscent+W,q=W+S.boundingBoxAscent+S.boundingBoxDescent+W,G=Object.assign(L,{metrics:S,left:0,style:this.getElementFont(L,h)});G.control?.minWidth&&(G.controlComponent&&(V+=S.width),G.controlComponent===s.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:N,rowElement:G,availableWidth:v,controlRealWidth:V}),V=0));const H=n[X-1];let z=n[X+1],_=N.width+S.width;if(this.options.wordBreak===s.WordBreak.BREAK_WORD&&(!H?.type||H?.type===s.ElementType.TEXT)&&(!L.type||L.type===s.ElementType.TEXT)){const J=`${H?.value||""}${L.value}`;if(this.WORD_LIKE_REG.test(J)){const{width:$,endElement:j}=this.textParticle.measureWord(m,n,X),tt=$*h;j&&tt<=v?(_+=tt,z=j):H&&(_+=tt)}const lt=this.textParticle.measurePunctuationWidth(m,z);_+=lt*h}L.listId&&(L.listId!==O?b=0:L.value===K&&!L.listWrap&&b++),O=L.listId;const dt=this.position.setSurroundPosition({pageNo:D,rowElement:G,row:N,rowElementRect:{x:y,y:Y,height:q,width:S.width},availableWidth:v,surroundElementList:u});y=dt.x,_+=dt.rowIncreaseWidth,y+=S.width;let Ct=!1;if(this.mode===s.EditorMode.FORM&&L.control?.type===s.ControlType.BUTTON&&L.controlComponent===s.ControlComponent.PREFIX&&N.elementList.filter(J=>J.controlId!==L.controlId).length>0){const J=L.controlId;if(n.some($=>$.controlId===`${J}_text`&&$.control?.type===s.ControlType.BUTTON)){let $=0;for(let j=X;j<n.length;j++){const tt=n[j];if(tt.controlId!==J)break;m.font=this.getElementFont(tt);const x=this.textParticle.measureText(m,tt);if($+=x.width*h,tt.controlComponent===s.ControlComponent.POSTFIX)break}for(let j=0;j<n.length;j++){const tt=n[j];if(tt.controlId===`${J}_text`){m.font=this.getElementFont(tt);const x=this.textParticle.measureText(m,tt);$+=x.width*h}}Ct=N.width+$>v}}const Kt=L.type===s.ElementType.SEPARATOR||L.type===s.ElementType.TABLE||H?.type===s.ElementType.TABLE||H?.type===s.ElementType.BLOCK||L.type===s.ElementType.BLOCK||H?.imgDisplay===s.ImageDisplay.INLINE||L.imgDisplay===s.ImageDisplay.INLINE||H?.listId!==L.listId||H?.areaId!==L.areaId&&!L.area?.hide||L.control?.flexDirection===s.FlexDirection.COLUMN&&(L.controlComponent===s.ControlComponent.CHECKBOX||L.controlComponent===s.ControlComponent.RADIO)&&H?.controlComponent===s.ControlComponent.VALUE||X!==0&&L.value===K&&!L.area?.hide||Ct,ge=_>v,se=Kt||ge;if(se){const J={width:S.width,height:q,startIndex:X,elementList:[G],ascent:w,rowIndex:N.rowIndex+1,rowFlex:n[X]?.rowFlex||n[X+1]?.rowFlex,isPageBreak:L.type===s.ElementType.PAGE_BREAK};if(G.controlComponent!==s.ControlComponent.PREFIX&&G.control?.indentation===s.ControlIndentation.VALUE_START){const lt=N.elementList.findIndex($=>$.controlId===G.controlId&&$.controlComponent!==s.ControlComponent.PREFIX);if(~lt){const j=this.position.computeRowPosition({row:N,innerWidth:this.getInnerWidth()})[lt];j&&(J.offsetX=j.coordinate.leftTop[0])}}L.listId&&(J.isList=!0,J.offsetX=P.get(L.listId),J.listIndex=b),J.offsetY=!l&&L.area?.top&&L.areaId!==n[X-1]?.areaId?L.area.top*h:0,E.push(J)}else N.width+=S.width,X===0&&(Un(n[1])||n[1]?.areaId)?(N.height=C,N.ascent=C):N.height<q&&(N.height=q,N.ascent=w),N.elementList.push(G);if((se||X===n.length-1)&&(N.isWidthNotEnough=ge&&!Kt,!N.isSurround&&(H?.rowFlex===s.RowFlex.JUSTIFY||H?.rowFlex===s.RowFlex.ALIGNMENT&&N.isWidthNotEnough))){const J=N.elementList[0]?.value===K?N.elementList.slice(1):N.elementList,lt=(v-N.width)/(J.length-1);for(let $=0;$<J.length-1;$++){const j=J[$];j.metrics.width+=lt}N.width=v}if(se){y=r,Y+=N.height,i&&!l&&c&&(Y-a+d+q>c||L.type===s.ElementType.PAGE_BREAK)&&(Y=a,Ec(u,D),D+=1),G.left=0;const J=E[E.length-1];y=this.position.setSurroundPosition({pageNo:D,rowElement:G,row:J,rowElementRect:{x:y,y:Y,height:q,width:S.width},availableWidth:v,surroundElementList:u}).x,y+=S.width}}return E}_collectTextControlValueSet(t){if(this.isDesignMode()||this.mode===s.EditorMode.EDIT)return null;const e=new Set;for(let i=0;i<t.length;i++){const l=t[i];l.controlId&&(l.control?.type===s.ControlType.TEXT||l.control?.type===s.ControlType.TEXTFIELD)&&e.add(l.controlId)}const n=new Set;for(let i=0;i<t.length;i++){const l=t[i];l.controlId&&l.controlComponent===s.ControlComponent.VALUE&&e.has(l.controlId)&&n.add(l.controlId)}return n}_collectTextControlHasContentSet(t){if(this.isDesignMode())return null;const e=new Set;let n=0;for(;n<t.length;){const i=t[n];if(i.controlId&&(i.control?.type===s.ControlType.TEXT||i.control?.type===s.ControlType.TEXTFIELD)&&(i.controlComponent===s.ControlComponent.PREFIX||i.controlComponent===s.ControlComponent.PRE_TEXT||i.controlComponent===s.ControlComponent.PRETEXTFIX||i.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){const l=i.controlId;let r=!1,a=n+1;for(;a<t.length;){const c=t[a];if(c.controlId===l&&(c.controlComponent===s.ControlComponent.POSTFIX||c.controlComponent===s.ControlComponent.POST_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))break;if(c.controlId===l&&c.controlComponent===s.ControlComponent.VALUE&&(r=!0),c.controlId!==l&&c.controlId){(i.control?.type===s.ControlType.TEXT||c.controlComponent===s.ControlComponent.VALUE)&&(r=!0);const d=c.controlId;for(a++;a<t.length&&t[a].controlId===d;)a++;continue}a++}r&&e.add(l)}n++}return e}_computePageList(){const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),l=this.getMainOuterHeight();let r=l,a=0;if(e===s.PageMode.CONTINUITY){t[0]=this.rowList,r+=this.rowList.reduce((R,h)=>R+h.height+(h.offsetY||0),0);const c=this.getPagePixelRatio(),d=this.pageList[0],u=Number(d.style.height.replace("px",""));if(r>u)d.style.height=`${r}px`,d.height=r*c;else{const R=r<i?i:r;d.style.height=`${R}px`,d.height=R*c}this._initPageContext(this.ctxList[0])}else for(let c=0;c<this.rowList.length;c++){const d=this.rowList[c],u=d.offsetY||0;if(d.height+u+r>i||this.rowList[c-1]?.isPageBreak){if(Number.isInteger(n)&&a>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}r=l+d.height+u,t.push([d]),a++}else r+=d.height+u,t[a].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:l}=e,r=this.getDefaultBasicRowMarginHeight(),a=this.getHighlightMarginHeight();for(let c=0;c<n.length;c++){const d=n[c];let u="";for(let R=0;R<d.elementList.length;R++){const h=d.elementList[R],g=d.startIndex+R,T=l[g]===h?g:l.indexOf(h),f=~T?T:g,p=this.control.getControlHighlight(l,f),C=h.highlight||p;if(C){u&&u!==C&&this.highlight.render(t);const I=i[f],{coordinate:{leftTop:[m,P]}}=I,E=h.left||0,M=!h.highlight&&!!p&&this.control.getIsInlineControlBackground(l,f),F=M?P+I.ascent-h.metrics.boundingBoxAscent-a:P+r-a,y=M?h.metrics.boundingBoxAscent+h.metrics.boundingBoxDescent+2*a:d.height-2*r+2*a;this.highlight.recordFillInfo(t,m-E,F,h.metrics.width+E,y,C)}else u&&this.highlight.render(t);u=C}this.highlight.render(t)}}validateNumber(t){return/^\d+$/.test(t)}drawRow(t,e){this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:l,lineBreak:r,whiteSpace:a}=this.options,{rowList:c,pageNo:d,elementList:u,positionList:R,startIndex:h,zone:g,isDrawLineBreak:T=!r.disabled,td:f,isDrawWhiteSpace:p=!a.disabled}=e,C=this.isPrintLikeMode(),I=this.isSelectionDisabled(),{isCrossRowCol:m,tableId:P}=this.range.getRange();let E=h;for(let M=0;M<c.length;M++){const F=c[M],y={x:0,y:0,width:0,height:0};let Y=null;for(let D=0;D<F.elementList.length;D++){const O=F.elementList[D],b=O.metrics,{ascent:V,coordinate:{leftTop:[X,N]}}=R[F.startIndex+D],L=F.elementList[D-1];if(ae(O)&&!this.isDesignMode())this.textParticle.complete();else if(O.type===s.ElementType.IMAGE)this.textParticle.complete(),O.imgDisplay!==s.ImageDisplay.SURROUND&&O.imgDisplay!==s.ImageDisplay.FLOAT_TOP&&O.imgDisplay!==s.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.TABLE)m&&(y.x=X,y.y=N,Y=O),this.tableParticle.render(t,O,X,N);else if(O.type===s.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.MACRO||O.type===s.ElementType.CUSTOM_MACRO||O.type===s.ElementType.REUSABLE_ITEM||O.type===s.ElementType.SUB_TEMPLATE)this.textParticle.complete(),this.macroParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.DATE){const w=F.elementList[D+1];(!L||L.dateId!==O.dateId)&&this.textParticle.complete(),this.textParticle.record(t,O,X,N+V),(!w||w.dateId!==O.dateId)&&this.textParticle.complete()}else O.type===s.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,O,X,N+V)):O.type===s.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,O,X,N+V)):O.type===s.ElementType.SEPARATOR?this.separatorParticle.render(t,O,X,N):O.type===s.ElementType.PAGE_BREAK?this.mode!==s.EditorMode.CLEAN&&!C&&this.pageBreakParticle.render(t,O,X,N):O.type===s.ElementType.CHECKBOX||O.controlComponent===s.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:X,y:N+V,index:D,row:F})):O.type===s.ElementType.RADIO||O.controlComponent===s.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x:X,y:N+V,index:D,row:F})):O.type===s.ElementType.MENSTRUAL_HISTORY?(this.textParticle.complete(),this.menstrualHistoryParticle.render({ctx:t,x:X,y:N+V,index:D,row:F,element:O})):O.type===s.ElementType.FETAL_HEART_POSITION?(this.textParticle.complete(),this.fetalHeartPositionParticle.render({ctx:t,x:X,y:N+V,index:D,row:F,element:O})):O.type===s.ElementType.TOOTH_POSITION?(this.textParticle.complete(),this.toothPositionParticle.render({ctx:t,x:X,y:N+V,index:D,row:F,element:O})):O.type===s.ElementType.TAB?this.textParticle.complete():O.rowFlex===s.RowFlex.ALIGNMENT||O.rowFlex===s.RowFlex.JUSTIFY?(this.textParticle.record(t,O,X,N+V),this.textParticle.complete()):O.type===s.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,d,O,X,N+V)):(O.left&&this.textParticle.complete(),this.textParticle.record(t,O,X,N+V),(O.width||O.letterSpacing||na.test(O.value))&&this.textParticle.complete());if(T&&!C&&this.mode!==s.EditorMode.CLEAN&&!F.isWidthNotEnough&&D===F.elementList.length-1&&this.lineBreakParticle.render(t,O,X,N+F.height/2),p&&ia.test(O.value)&&this.whiteSpaceParticle.render(t,O,X,N+F.height/2),O.control?.border){L?.control?.border&&L.controlId!==O.controlId&&this.control.drawBorder(t);const w=this.getElementRowMargin(O);this.control.recordBorderInfo(X,N+w,O.metrics.width,F.height-2*w)}else L?.control?.border&&this.control.drawBorder(t);if(O.control?.type===s.ControlType.TEXT){const w=O.controlComponent===s.ControlComponent.VALUE,q=O.controlComponent===s.ControlComponent.POSTFIX||O.controlComponent===s.ControlComponent.POST_TEXT,G=!!L&&L.originControlId===O.controlId&&(L.controlComponent===s.ControlComponent.POSTFIX||L.controlComponent===s.ControlComponent.POST_TEXT||L.controlComponent===s.ControlComponent.POSTTEXTFIX||L.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT);O.originControlId&&(O.controlComponent===s.ControlComponent.PREFIX||O.controlComponent===s.ControlComponent.PRE_TEXT||O.controlComponent===s.ControlComponent.PRETEXTFIX||O.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&this.control.drawTextFieldUnderline(t),w&&O.control?.underline&&!O.underline&&((!L||L.controlId!==O.controlId||G||L.controlComponent!==s.ControlComponent.VALUE&&L.controlComponent!==s.ControlComponent.PLACEHOLDER)&&this.control.startTextFieldUnderline(O.controlId,X,N+F.height),this.control.recordTextFieldUnderlineWidth(O.metrics.width)),q&&this.control.drawTextFieldUnderline(t),O.originControlId&&(O.controlComponent===s.ControlComponent.POSTFIX||O.controlComponent===s.ControlComponent.POST_TEXT||O.controlComponent===s.ControlComponent.POSTTEXTFIX||O.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.drawTextFieldUnderline(t)}else L?.control?.type===s.ControlType.TEXT&&this.control.drawTextFieldUnderline(t);if((O.underline||O.control?.underline)&&O.controlComponent!==s.ControlComponent.PLACEHOLDER&&!(O.control?.type===s.ControlType.TEXT&&O.control?.underline&&!O.underline)){L?.type===s.ElementType.SUBSCRIPT&&O.type!==s.ElementType.SUBSCRIPT&&this.underline.render(t);const w=this.getElementRowMargin(O),q=O.left||0;let G=0;O.type===s.ElementType.SUBSCRIPT&&(G=this.subscriptParticle.getOffsetY(O));const H=O.control?.underline?this.options.underlineColor:O.color;this.underline.recordFillInfo(t,X-q,N+F.height-w+G,b.width+q,0,H,O.textDecoration?.style)}else(L?.underline||L?.control?.underline)&&(L?.control?.type===s.ControlType.TEXT&&L?.control?.underline&&!L.underline||this.underline.render(t));if(O.strikeout){if(!O.type||Ce.includes(O.type)){L&&(L.type===s.ElementType.SUBSCRIPT&&O.type!==s.ElementType.SUBSCRIPT||L.type===s.ElementType.SUPERSCRIPT&&O.type!==s.ElementType.SUPERSCRIPT||this.getElementSize(L)!==this.getElementSize(O))&&this.strikeout.render(t);const w=this.textParticle.measureBasisWord(t,this.getElementFont(O));let q=N+V+w.actualBoundingBoxDescent*n-b.height/2;O.type===s.ElementType.SUBSCRIPT?q+=this.subscriptParticle.getOffsetY(O):O.type===s.ElementType.SUPERSCRIPT&&(q+=this.superscriptParticle.getOffsetY(O)),this.strikeout.recordFillInfo(t,X,q,b.width)}}else L?.strikeout&&this.strikeout.render(t);const{zone:W,splitTdRange:S}=this.range.getRange();let{startIndex:U,endIndex:v}=this.range.getRange(),Q=!1;if(f&&S&&[f.originalId,f.id].includes(S.originalId)&&(Q=!0,U=S.startIndex-(f.valueStartIndex??0),v=S.endIndex-(f.valueStartIndex??0)),W===g&&U!==v&&U<=E&&E<=v){const w=this.position.getPositionContext();if(!w.isTable&&!O.tdId||w.tdId===O.tdId||Q)if(U===E){const q=u[U+1];q&&q.value===K&&(y.x=X+b.width,y.y=N,y.height=F.height,y.width+=this.options.rangeMinWidth)}else{let q=b.width;q===0&&F.elementList.length===1&&(q=this.options.rangeMinWidth),y.width||(y.x=X,y.y=N,y.height=F.height),y.width+=q}}if(!l.disabled&&O.groupIds&&this.group.recordFillInfo(O,X,N,b.width,F.height),E++,O.type===s.ElementType.TABLE&&!ae(O)){const w=O.tdPadding||i,q=w[1]+w[3];for(let G=0;G<O.trList.length;G++){const H=O.trList[G];for(let z=0;z<H.tdList.length;z++){const _=H.tdList[z];this.drawRow(t,{elementList:_.value,positionList:_.positionList,rowList:_.rowList,pageNo:d,startIndex:0,innerWidth:(_.width-q)*n,zone:g,isDrawLineBreak:T,td:_})}}}}if(F.isList&&this.listParticle.drawListStyle(t,F,R[F.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!I){if(y.width&&y.height){const{x:D,y:O,width:b,height:V}=y;this.range.render(t,D,O,b,V)}if(m&&Y&&Y.id===P){const{coordinate:{leftTop:[D,O]}}=R[F.startIndex];this.tableParticle.drawRange(t,Y,D,O)}}}this.control.renderQualityMarks(t,e.elementList,e.positionList,e.rowList,e.pageNo,e.zone,e.innerWidth)}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:l,pageNo:r}=e;for(let a=0;a<i.length;a++){const c=i[a],d=c.element;if((r===c.pageNo||c.zone===s.EditorZone.HEADER||c.zone==s.EditorZone.FOOTER)&&d.imgDisplay&&l.includes(d.imgDisplay)&&d.type===s.ElementType.IMAGE){const u=d.imgFloatPosition;this.imageParticle.render(t,d,u.x*n,u.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){const{elementList:e,positionList:n,rowList:i,pageNo:l}=t,{inactiveAlpha:r,pageMode:a,header:c,footer:d,pageNumber:u,lineNumber:R,pageBorder:h}=this.options,g=this.isPrintLikeMode(),T=this.mode===s.EditorMode.COMPARE?this.options.modeRule[s.EditorMode.COMPARE]:this.options.modeRule[s.EditorMode.PRINT],f=this.getInnerWidth(),p=this.ctxList[l];p.globalAlpha=this.zone.isMainActive()?1:r,this._clearPage(l),(!g||!T?.backgroundDisabled)&&this.background.render(p,l),g||this.area.render(p,l),a!==s.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(p,l),g||this.margin.render(p,l),this._drawFloat(p,{pageNo:l,imgDisplays:[s.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(p,l);const C=i[0]?.startIndex;this.drawRow(p,{elementList:e,positionList:n,rowList:i,pageNo:l,startIndex:C,innerWidth:f,zone:s.EditorZone.MAIN}),this.getIsPagingMode()&&(c.disabled||this.header.render(p,l),u.disabled||this.pageNumber.render(p,l),d.disabled||this.footer.render(p,l)),this._drawFloat(p,{pageNo:l,imgDisplays:[s.ImageDisplay.FLOAT_TOP,s.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(p,l),this.elementList.length<=1&&!this.elementList[0]?.listId&&this.placeholder.render(p),R.disabled||this.lineNumber.render(p,l),h.disabled||this.pageBorder.render(p),this.badge.render(p,l),this.isGraffitiMode()&&this.graffiti.render(p,l)}_disconnectLazyRender(){this.lazyRenderIntersectionObserver?.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const l=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[l],pageNo:l})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){const e=re(),n=[],i=(X,N)=>{n.push({label:X,duration:re()-N})};this.renderCount++;const l=this.mode===s.EditorMode.EDIT||this.mode===s.EditorMode.FORM||this.isPrintLikeMode()?tT([...this.getHeaderElementList(),...this.elementList,...this.getFooterElementList()]):null,r=this.applySubTemplateRuntimeState(this.getHeaderElementList(),l)||this.applySubTemplateRuntimeState(this.elementList,l)||this.applySubTemplateRuntimeState(this.getFooterElementList(),l);let{endIndex:a}=this.range.getRange();const{isCrossRowCol:c}=this.range.getRange();if(!c&&~a){const X=this.getElementList(),N=X[a],W=N?.type===s.ElementType.SUB_TEMPLATE&&N.subTemplateExpanded?s.LocationPosition.AFTER:s.LocationPosition.BEFORE,S=wn(X,a,W);S!==a&&!ae(X[S])&&(this.range.setRange(S,S),a=S)}let d;const u=this.position.getPositionContext();if(c)d=this.getOriginalElementList()[u.index];else{const X=~a?a:0,N=this.getElementList();d=Vn(N,X)}const{header:R,footer:h}=this.options,{isSubmitHistory:g=!0,isSetCursor:T=!0,isLazy:f=!0,isInit:p=!1,isSourceHistory:C=!1,isFirstRender:I=!1,isDel:m=!1}=t||{};let{isCompute:P=!0}=t||{};r&&(P=!0);let{curIndex:E}=t||{};const{traceLabel:M}=t||{},F=this.getInnerWidth(),y=this.getIsPagingMode(),Y=this.pageRowList.length;if(P){if(this.splitTdValueMap.clear(),this.tdMap.clear(),this.position.setFloatPositionList([]),y){if(!R.disabled){const H=re();this.header.compute(),i("header.compute",H)}if(!h.disabled){const H=re();this.footer.compute(),i("footer.compute",H)}}const X=this.getMargins(),N=this.getHeight(),L=this.header.getExtraHeight(),W=this.getMainOuterHeight(),S=X[3],U=X[0]+L,v=Oi(this.elementList),Q=re();this.rowList=this.computeRowList({startX:S,startY:U,pageHeight:N,mainOuterHeight:W,isPagingMode:y,innerWidth:F,surroundElementList:v,elementList:this.elementList}),i("computeRowList",Q);const w=re();this.pageRowList=this._computePageList(),i("computePageList",w);const q=re();this.position.computePositionList(),i("computePositionList",q);const G=re();if(this.area.compute(),i("area.compute",G),!this.isPrintLikeMode()){const H=this.search.getSearchKeyword();if(H){const _=re();this.search.compute(H),i("search.compute",_)}const z=re();this.control.computeHighlightList(),i("control.computeHighlightList",z)}if(this.isGraffitiMode()){const H=re();this.graffiti.compute(),i("graffiti.compute",H)}}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let X=0;X<this.pageRowList.length;X++)this.pageList[X]||this._createPage(X);const D=this.pageRowList.length,O=this.pageList.length;if(O>D){const X=O-D;this.ctxList.splice(D,X),this.pageList.splice(D,X).forEach(N=>N.remove())}const b=re();if(f&&y?this._lazyRender():this._immediateRender(),i(f&&y?"lazyRender":"immediateRender",b),T){if(P&&d?.tableId){const{index:X}=u,L=this.getOriginalElementList()[X];if(d.tableId!==L?.id){const S=this.findTableChildrenElement(!0,d.tableId,d);S&&u.index!==S.originalIndex&&(u.index=S.originalIndex,u.tableId=S.table.id,u.trIndex=S.trIndex,u.trId=S.tr.id,u.tdIndex=S.tdIndex,u.tdId=S.td.id,E=S.elementIndex,this.position.setPositionContext(u),this.range.setRange(E,E),this.updateTableTool())}const W=this.getElementList();W[a]!==d&&(E=W.findIndex(S=>S===d))}E=this.setCursor(E)}else this.range.getIsSelection()&&this.cursor.focus();if(m){let X;const N=this.position.getPositionContext();X=this.range.getRange().startIndex-1,N.index=X}(g&&!I||E!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(E);const V=re();ui(()=>{const X=re();this.range.setRangeStyle(),P&&this.control.getActiveControl()&&this.control.reAwakeControl(),P&&!this.isReadonly()&&this.getMode()!==s.EditorMode.FORM&&u.isTable&&this.getOriginalElementList()[u.index].type===s.ElementType.TABLE&&this.tableTool.render(),P&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),Y!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(g||C)&&!p&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"));const N=re();Ri(this.options,M||"render",N-e,[...n,{label:"nextTick.wait",duration:X-V},{label:"nextTick.callback",duration:N-X}],{isCompute:P,pageCount:this.pageRowList.length})}),T&&this.fixPosition()}fixPosition(t=!1){let e;const n=this.position.getPositionContext();if(n.isTable){const i=this.getElementList(),l=this.range.getRange().startIndex;if(t||l>=i.length){const r=this.getTd(),a=n.index+(t?-1:1),d=this.getOriginalElementList()[a];if(!d?.trList)return;e=l-i.length;for(let u=0;u<d.trList.length;u++){const R=d.trList[u],h=R.tdList.find(g=>t?r?.linkTdPrevId===g.id:r?.id===g.linkTdPrevId);if(h){n.index=a,n.trIndex=u,n.tableId=d.id,n.trId=R.id,n.tdId=h?.id,e=t?h.value.length-1:e+(h.value[0]?.type===s.ElementType.SPLIT_TAG?1:0);break}}if(this.position.setPositionContext(n),this.range.setRange(e,e),this.setCursor(e),e===0)return this.fixPosition(t);this.updateTableTool()}}return e}getInlineBackgroundControlType(t,e){if(e===void 0)return;const n=t[e],i=n?.controlId;return i?n.control?.type?n.control.type:t.find(r=>r.controlId===i&&r.originControlId===n.originControlId&&!!r.control?.type)?.control?.type:void 0}getIsHideInlineBackgroundControlCursor(t,e){if(this.options.mode!==s.EditorMode.EDIT&&this.options.mode!==s.EditorMode.FORM)return!1;const n=e!==void 0?t[e]:void 0;if(n?.controlComponent===s.ControlComponent.POSTFIX||n?.controlComponent===s.ControlComponent.POST_TEXT||n?.controlComponent===s.ControlComponent.POSTTEXTFIX||n?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)return!1;const i=this.getInlineBackgroundControlType(t,e);return!!(i&&[s.ControlType.NUMBER,s.ControlType.SELECT,s.ControlType.DATE].includes(i))}setCursor(t){const e=this.position.getPositionContext(),n=this.position.getPositionList(),i=this.getElementList();if(e.isTable){const{index:r,trIndex:a,tdIndex:c}=e,u=this.getOriginalElementList()[r].trList?.[a].tdList[c].positionList;t===void 0&&u&&(t=u.length-1);const R=u?.[t];this.position.setCursorPosition(R||null)}else t!==void 0&&t>=n.length&&(t=n.length-1),this.position.setCursorPosition(t!==void 0&&t>=0?n[t]:null);let l=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const r=i[t];if(r&&Ma.includes(r.type)){l=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(r,a)}}return l&&this.getIsHideInlineBackgroundControlCursor(i,t)&&(l=!1),this.cursor.drawCursor({isShow:l}),t}submitHistory(t){const e=this.position.getPositionContext(),n=Mi(this.elementList),i=Mi(this.header.getElementList()),l=Mi(this.footer.getElementList()),r=ct(this.range.getRange()),a=this.pageNo,c=ct(e),d=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(d),this.setPageNo(a),this.position.setPositionContext(ct(c)),this.header.setElementList(ct(i)),this.footer.setElementList(ct(l)),this.elementList=ct(n),this.range.replaceRange(ct(r)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.macroParticle.clearInlineEditor({isSubmitHistory:!1}),this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getMacroParticle().clearInlineEditor({isSubmitHistory:!1}),this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}updateTableTool(){if(this.getMode()===s.EditorMode.FORM){this.getTableTool().dispose();return}if(this.position.getPositionContext().isTable){const t=this.position.getPositionList();t.length&&(this.setPageNo(t[0].pageNo),this.getTableTool().render())}}initTableElementIndex(t,e){t.trList?.forEach((n,i)=>{n.tdList.forEach((l,r)=>{l.tableIndex=e,l.tableId=t.id,l.trIndex=i,l.trId=n.id,l.tdIndex=r,this.tdMap.set(l.id,l)})})}clearElementEffect(t){t.trList?.forEach(e=>{e.minHeight=e.originalMinHeight??e.minHeight,delete e.originalMinHeight,e.tdList.forEach(n=>{delete n.linkTdNextId})})}updateElementTableInfo(t,e,n,i){return t.tableId=e.id,t.trId=n.id,t.tdId=i.id,t}findTableChildrenElement(t,e,n){const i=this.position.getPositionContext(),{index:l}=i,r=this.getOriginalElementList();let a=l;t&&(a=l>r.length?r.length-1:l);for(let c=a;t?c>=0:c<r.length;t?c--:c++){const d=r[c];if(d&&[d.originalId,d.id].includes(e))for(const[u,R]of d.trList.entries())for(const[h,g]of R.tdList.entries()){const T=g.value.findIndex(typeof n=="function"?n:f=>f===n);if(T>=0)return{originalIndex:c,table:d,tr:R,trIndex:u,td:g,tdIndex:h,elementIndex:T}}}}getTdById(t){return this.tdMap.get(t)}getLinkTdPrevHasValue(t){const e=this.getTdById(t);if(e)return e.value.length?e:this.getLinkTdPrevHasValue(e.linkTdPrevId)}getFirstLinkTd(t){const e=this.getTdById(t);return e?.linkTdPrevId?this.getLastLinkTd(e.linkTdPrevId):e}getLastLinkTd(t){const e=this.getTdById(t);return e?.linkTdNextId?this.getLastLinkTd(e.linkTdNextId):e}removeLinkTd(t,e){const n=this.getTdById(e);if(n){if(n.linkTdPrevId){const i=this.getTdById(n.linkTdPrevId);i&&(delete i.linkTdNextId,this.removeLinkTd(t,n.linkTdPrevId))}if(n.linkTdNextId){const i=this.getTdById(n.linkTdNextId);i&&(delete i.linkTdPrevId,this.removeLinkTd(t,n.linkTdNextId))}t[n.tableIndex].trList[n.trIndex].tdList.splice(n.tdIndex,1),this.initTableElementIndex(t[n.tableIndex],n.tableIndex)}}removeLinkTdControl(t,e){const n=this.getTdById(t);if(n){for(let i=0;i<n.value.length;i++)n.value[i].control===e&&(n.value.splice(i,1),i--);n.linkTdNextId&&this.removeLinkTdControl(n.linkTdNextId,e)}}isSplitTd(t,e){return(!!t?.originalId||!!e?.originalId)&&(t?.originalId===e?.originalId||t?.id===e?.originalId||t?.originalId===e?.id)}getSplitTdValues(t){return this.splitTdValueMap.get(t)}removeSplitTdOtherRangeElements(){const{splitTdRange:t}=this.range.getRange();if(!t)return;const{startIndex:e,endIndex:n}=t;let i=this.getTd();if(i)if((i.valueStartIndex??0)>=e){let l=-1;for(;l<0;){const r=this.getTdById(i.linkTdPrevId);if(r){l=e-(r.valueStartIndex??0);const a=Math.max(0,l);this.spliceElementList(r.value,a+1,r.value.length-a-1),i=r}else l=0}}else{let l=1;for(;l>0;){const r=this.getTdById(i.linkTdNextId);if(r){const a=r.valueStartIndex??0;l=n-(a+r.value.length);const c=Math.min(r.value.length,n-a+1);this.spliceElementList(r.value,0,c),i=r}else l=0}}}getTablesByPagingId(t,e,n){const i=[],l=[];if(t[n].pagingId===e){i.push(n),l.push(t[n]);for(let r=n-1;r>=0&&t[r].pagingId===e;r--)l.unshift(t[r]),i.push(r);for(let r=n+1;r<t.length&&t[r].pagingId===e;r++)l.push(t[r]),i.push(r)}return{list:l,startIndex:i.sort()[0]}}}class Wl{executeMode;executeCut;executeCopy;executePaste;executeSelectAll;executeBackspace;executeSetRange;executeReplaceRange;executeSetPositionContext;executeForceUpdate;executeBlur;executeHideCursor;executeUndo;executeRedo;executePainter;executeApplyPainterStyle;executeFormat;executeFont;executeButton;executeEditElementAttribute;executeTriggerControlEditAttribute;executeCopyControl;executePasteControl;executeSize;executeSizeAdd;executeSizeMinus;executeBold;executeItalic;executeUnderline;executeStrikeout;executeSuperscript;executeSubscript;executeColor;executeHighlight;executeTitle;executeList;executeRowFlex;executeVertical;executeRowMargin;executeInsertTable;executeInsertTableTopRow;executeInsertTableBottomRow;executeInsertTableLeftCol;executeInsertTableRightCol;executeDeleteTableRow;executeDeleteTableCol;executeDeleteTable;executeMergeTableCell;executeCancelMergeTableCell;executeSplitVerticalTableCell;executeSplitHorizontalTableCell;executeTableTdVerticalAlign;executeTableBorderType;executeTableBorderColor;executeTableTdBorderType;executeTableTdSlashType;executeTableTdBackgroundColor;executeTableSelectAll;executeTableProperties;executeImage;executeHyperlink;executeDeleteHyperlink;executeCancelHyperlink;executeEditHyperlink;executeSeparator;executePageBreak;executeAddWatermark;executeDeleteWatermark;executeSearch;executeSearchNavigatePre;executeSearchNavigateNext;executeReplace;executePrint;executeReplaceImageElement;executeSaveAsImageElement;executeSetImageCrop;executeSetImageCaption;executeChangeImageDisplay;executePageMode;executePageScale;executePageScaleRecovery;executePageScaleMinus;executePageScaleAdd;executePaperSize;executePaperDirection;executeSetPaperMargin;executeSetMainBadge;executeSetAreaBadge;executeInsertElementList;executeInsertArea;executeSetAreaValue;executeSetAreaProperties;executeLocationArea;executeClearGraffiti;executeAppendElementList;executeUpdateElementById;executeDeleteElementById;executeSetValue;executeRemoveControl;executeTranslate;executeSetLocale;executeLocationCatalog;executeWordTool;executeSetHTML;executeSetGroup;executeDeleteGroup;executeLocationGroup;executeSetZone;executeSetControlValue;executeSetControlValueList;executeSetControlExtension;executeSetControlExtensionList;executeSetControlProperties;executeSetControlPropertiesList;executeSetControlHighlight;executeSetControlQualityMarks;executeSetButtonContent;executeLocationControl;executeInsertControl;executeInsertTextField;executeJumpControl;executeUpdateOptions;executeSetFormModeTrace;executeInsertTitle;executeFocus;executeComputeElementListHeight;getCatalog;getImage;getPageMode;getOptions;getValue;getValueAsync;getAreaValue;getHTML;getText;getWordCount;getCursorPosition;getRemainingContentHeight;getRange;getRangeText;getRangeContext;getRangeRow;getRangeParagraph;getKeywordRangeList;getKeywordContext;getPaperMargin;getSearchNavigateInfo;getLocale;getGroupIds;getControlValue;getButtonContent;getControlList;getContainer;getTitleValue;getPositionContextByEvent;getElementById;getMacroValue;getMacroList;setMacroValue;setMacroValueList;updateMacroProperties;locationMacro;insertSubTemplate;updateSubTemplate;expandSubTemplate;collapseSubTemplate;toggleSubTemplate;constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeButton=t.buttonText.bind(t),this.executeEditElementAttribute=t.editElementAttribute.bind(t),this.executeTriggerControlEditAttribute=t.triggerControlEditAttribute.bind(t),this.executeCopyControl=t.copyControl.bind(t),this.executePasteControl=t.pasteControl.bind(t),this.executeSize=t.size.bind(t),this.executeSizeAdd=t.sizeAdd.bind(t),this.executeSizeMinus=t.sizeMinus.bind(t),this.executeBold=t.bold.bind(t),this.executeItalic=t.italic.bind(t),this.executeUnderline=t.underline.bind(t),this.executeStrikeout=t.strikeout.bind(t),this.executeSuperscript=t.superscript.bind(t),this.executeSubscript=t.subscript.bind(t),this.executeColor=t.color.bind(t),this.executeHighlight=t.highlight.bind(t),this.executeTitle=t.title.bind(t),this.executeList=t.list.bind(t),this.executeRowFlex=t.rowFlex.bind(t),this.executeVertical=t.vertical.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeTableProperties=t.tableProperties.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeSetFormModeTrace=t.setFormModeTrace.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getPageMode=t.getPageMode.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.executeSetControlQualityMarks=t.setControlQualityMarks.bind(t),this.executeSetButtonContent=t.setButtonContent.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getButtonContent=t.getButtonContent.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeInsertTextField=t.insertTextField.bind(t),this.executeJumpControl=t.jumpControl.bind(t),this.getMacroValue=t.getMacroValue.bind(t),this.getMacroList=t.getMacroList.bind(t),this.setMacroValue=t.setMacroValue.bind(t),this.setMacroValueList=t.setMacroValueList.bind(t),this.updateMacroProperties=t.updateMacroProperties.bind(t),this.locationMacro=t.locationMacro.bind(t),this.insertSubTemplate=t.insertSubTemplate.bind(t),this.updateSubTemplate=t.updateSubTemplate.bind(t),this.expandSubTemplate=t.expandSubTemplate.bind(t),this.collapseSubTemplate=t.collapseSubTemplate.bind(t),this.toggleSubTemplate=t.toggleSubTemplate.bind(t)}}function UT(o,t){return o===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:o===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:o===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${o}px`,height:`${t}px`}}function wT(o,t){const{width:e,height:n,direction:i=s.PaperDirection.VERTICAL}=t,l=document.createElement("iframe");l.style.visibility="hidden",l.style.position="absolute",l.style.left="0",l.style.top="0",l.style.width="0",l.style.height="0",l.style.border="none",document.body.append(l);const r=l.contentWindow,a=r.document;a.open();const c=document.createElement("div"),d=UT(e,n);o.forEach(h=>{const g=document.createElement("img");g.style.width=i===s.PaperDirection.HORIZONTAL?d.height:d.width,g.style.height=i===s.PaperDirection.HORIZONTAL?d.width:d.height,g.src=h,c.append(g)});const u=document.createElement("style"),R=`
553
+ `,document.body.appendChild(a);const c=a.querySelector(".table-properties-modal__mask"),d=a.querySelector(".table-properties-modal__close"),u=a.querySelector(".btn-cancel"),R=a.querySelector(".btn-confirm"),h=()=>{a.remove()};c.addEventListener("click",h),d.addEventListener("click",h),u.addEventListener("click",h),R.addEventListener("click",()=>{const g=parseInt(a.querySelector("#tdPaddingTop").value)||0,T=parseInt(a.querySelector("#tdPaddingRight").value)||0,f=parseInt(a.querySelector("#tdPaddingBottom").value)||0,p=parseInt(a.querySelector("#tdPaddingLeft").value)||0;i.tdPadding=[g,T,f,p],h();const{endIndex:C}=this.range.getRange();this.draw.render({curIndex:C,isCompute:!0})})}}s.AreaMode=void 0,(function(o){o.EDIT="edit",o.READONLY="readonly",o.FORM="form"})(s.AreaMode||(s.AreaMode={}));class bT{draw;zone;range;position;options;areaInfoMap=new Map;constructor(t){this.draw=t,this.options=t.getOptions(),this.zone=t.getZone(),this.range=t.getRange(),this.position=t.getPosition()}getAreaInfo(){return this.areaInfoMap}getActiveAreaId(){if(!this.areaInfoMap.size)return null;const{startIndex:t}=this.range.getRange();return this.draw.getElementList()[t]?.areaId||null}getActiveAreaInfo(){const t=this.getActiveAreaId();return t&&this.areaInfoMap.get(t)||null}isReadonly(){const t=this.getActiveAreaInfo();if(!t?.area)return!1;switch(t.area.mode){case s.AreaMode.EDIT:return!1;case s.AreaMode.READONLY:return!0;case s.AreaMode.FORM:return!this.draw.getControl().getIsRangeWithinControl();default:return!1}}insertArea(t){const{id:e,value:n,area:i,position:l,range:r}=t;if(this.zone.getZone()!==s.EditorZone.MAIN&&this.zone.setZone(s.EditorZone.MAIN),this.draw.getPosition().setPositionContext({isTable:!1}),r&&!this.getActiveAreaId()){const{startIndex:c,endIndex:d}=r,u=this.draw.getOriginalMainElementList();if(!u[c]||!u[d])return null;this.range.setRange(r.startIndex,r.endIndex)}else if(l===s.LocationPosition.BEFORE)this.range.setRange(0,0);else{const d=this.draw.getOriginalMainElementList().length-1;this.range.setRange(d,d)}const a=e||ft();return this.draw.insertElementList([{type:s.ElementType.AREA,value:"",areaId:a,valueList:n,area:ct(i)}]),a}render(t,e){if(!this.areaInfoMap.size)return;t.save();const n=this.draw.getMargins(),i=this.draw.getInnerWidth();for(const l of this.areaInfoMap){const{area:r,positionList:a}=l[1];if(r?.hide||!r?.backgroundColor&&!r?.borderColor&&!r?.placeholder)continue;const c=a.filter(T=>T.pageNo===e);if(!c.length)continue;t.translate(.5,.5);const d=c[0],u=c[c.length-1],R=n[3],h=Math.ceil(d.coordinate.leftTop[1]),g=Math.ceil(u.coordinate.rightBottom[1]-h);t.textBaseline="middle",r.backgroundColor&&(t.fillStyle=r.backgroundColor,t.fillRect(R,h,i,g)),r.borderColor&&(t.strokeStyle=r.borderColor,t.strokeRect(R,h,i,g)),r.placeholder&&a.length<=1&&new bl(this.draw).render(t,{placeholder:{...vs,...r.placeholder},startY:d.coordinate.leftTop[1]}),t.translate(-.5,-.5)}t.restore()}compute(){this.areaInfoMap.clear();const t=this.draw.getOriginalMainElementList(),e=this.position.getOriginalMainPositionList();for(let n=0;n<t.length;n++){const i=t[n],l=i.areaId;if(l){const r=this.areaInfoMap.get(l);r?(r.elementList.push(i),r.positionList.push(e[n])):this.areaInfoMap.set(l,{id:l,area:i.area,elementList:[i],positionList:[e[n]]})}}}getAreaValue(t={}){const e=t.id||this.getActiveAreaId();if(!e)return null;const n=this.areaInfoMap.get(e);return n?{area:n.area,id:n.id,startPageNo:n.positionList[0].pageNo,endPageNo:n.positionList[n.positionList.length-1].pageNo,value:wt(n.elementList)}:null}getContextByAreaId(t,e){const n=this.draw.getOriginalMainElementList();for(let i=0;i<n.length;i++){const l=n[i];if(e?.position===s.LocationPosition.OUTER_BEFORE){if(n[i+1]?.areaId!==t)continue}else if(e?.position===s.LocationPosition.AFTER){if(!(l.areaId===t&&n[i+1]?.areaId!==t))continue}else if(e?.position===s.LocationPosition.OUTER_AFTER){if(!(l.areaId!==t&&n[i-1]?.areaId===t))continue}else if(l.areaId!==t)continue;const r=this.position.getOriginalMainPositionList();return{range:{startIndex:i,endIndex:i},elementPosition:r[i]}}return null}setAreaProperties(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;n.area||(n.area={});let i=!1;const l=["top","hide"];Object.entries(t.properties).forEach(([r,a])=>{if(ys(a))return;const c=r;n.area[c]=a,l.includes(c)&&(i=!0)}),this.draw.render({isCompute:i,isSetCursor:!1})}setAreaValue(t){const e=t.id||this.getActiveAreaId();if(!e)return;const n=this.areaInfoMap.get(e);if(!n)return;const{positionList:i}=n,l=this.draw.getOriginalMainElementList(),r=t.value;jt([{type:s.ElementType.AREA,value:"",valueList:r,areaId:n.id,area:n.area}],{editorOptions:this.options}),this.draw.spliceElementList(l,i[0].index,i.length,r,{isIgnoreDeletedRule:!0}),this.draw.render({isSetCursor:!1})}}class DT{draw;options;imageCache;mainBadge;areaBadgeMap;constructor(t){this.draw=t,this.options=t.getOptions(),this.imageCache=new Map,this.mainBadge=null,this.areaBadgeMap=new Map}setMainBadge(t){this.mainBadge=t}setAreaBadgeMap(t){this.areaBadgeMap.clear(),t.forEach(e=>{this.areaBadgeMap.set(e.areaId,e.badge)})}_drawImage(t,e,n,i,l,r){if(this.imageCache.has(r)){const a=this.imageCache.get(r);t.drawImage(a,e,n,i,l)}else{const a=new Image;a.setAttribute("crossOrigin","Anonymous"),a.src=r,a.onload=()=>{this.imageCache.set(r,a),t.drawImage(a,e,n,i,l)}}}render(t,e){if(e===0&&this.mainBadge){const{scale:n,badge:i}=this.options,{left:l,top:r,width:a,height:c,value:d}=this.mainBadge,u=this.draw.getMargins()[0]+this.draw.getHeader().getExtraHeight(),R=(l||i.left)*n,h=(r||i.top)*n+u;this._drawImage(t,R,h,a*n,c*n,d)}if(this.areaBadgeMap.size){const n=this.draw.getArea().getAreaInfo();if(n.size){const{scale:i,badge:l}=this.options;for(const r of n){const{positionList:a}=r[1],c=a[0];if(c.pageNo!==e)continue;const d=this.areaBadgeMap.get(r[0]);if(!d)continue;const{left:u,top:R,width:h,height:g,value:T}=d,f=(u||l.left)*i,p=(R||l.top)*i+c.coordinate.leftTop[1];this._drawImage(t,f,p,h*i,g*i,T)}}}}}class VT{draw;options;data;pageContainer;isDrawing=!1;startStroke=null;constructor(t,e){this.draw=t,this.options=t.getOptions(),this.data=e||[],this.pageContainer=t.getPageContainer(),this.register()}register(){this.pageContainer.addEventListener("mousedown",this.start.bind(this)),this.pageContainer.addEventListener("mouseup",this.stop.bind(this)),this.pageContainer.addEventListener("mouseleave",this.stop.bind(this)),this.pageContainer.addEventListener("mousemove",this.drawing.bind(this))}start(t){if(!this.draw.isGraffitiMode())return;this.isDrawing=!0;const{scale:e}=this.options;this.startStroke={lineColor:this.options.graffiti.defaultLineColor,lineWidth:this.options.graffiti.defaultLineWidth,points:[t.offsetX/e,t.offsetY/e]}}stop(){this.isDrawing=!1}drawing(t){if(!this.isDrawing||!this.draw.isGraffitiMode())return;const{offsetX:e,offsetY:n}=t,i=2;if(this.startStroke&&Math.abs(this.startStroke.points[0]-e)<i&&Math.abs(this.startStroke.points[1]-n)<i)return;const l=this.draw.getPageNo();let r=this.data.find(d=>d.pageNo===l);if(this.startStroke&&(r||(r={pageNo:l,strokes:[]},this.data.push(r)),r.strokes.push(this.startStroke),this.startStroke=null),!r?.strokes?.length)return;const{scale:a}=this.options;r.strokes[r.strokes.length-1].points.push(e/a,n/a),this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getValue(){return this.data}compute(){const t=this.draw.getPageRowList().length;for(let e=this.data.length-1;e>=0;e--)this.data[e].pageNo>t-1&&this.data.splice(e,1)}clear(){this.data=[]}render(t,e){const n=this.data.find(a=>a.pageNo===e)?.strokes;if(!n?.length)return;const{graffiti:{defaultLineColor:i,defaultLineWidth:l},scale:r}=this.options;t.save();for(let a=0;a<n.length;a++){const c=n[a];t.beginPath(),t.strokeStyle=c.lineColor||i,t.lineWidth=(c.lineWidth||l)*r,t.moveTo(c.points[0]*r,c.points[1]*r);for(let d=2;d<c.points.length;d+=2)t.lineTo(c.points[d]*r,c.points[d+1]*r);t.stroke()}t.restore()}}const Dl=1024,WT=['[aria-modal="true"]','[role="dialog"]','[data-overlay-active="true"]',".ant-modal-root",".ant-modal-wrap",".ant-modal",".ant-drawer",".ant-select-dropdown",".ant-picker-dropdown",".ant-dropdown",".ant-popover",".ant-tooltip",".ant-cascader-dropdown",".ant-mentions-dropdown"].join(", ");function Vl(o,t,e){for(let n=0;n<e.length;n+=Dl){const i=e.slice(n,n+Dl);o.splice(t+n,0,...i)}}class YT{container;pageContainer;pageList;ctxList;pageNo;renderCount;pagePixelRatio;mode;options;position;zone;elementList;listener;eventBus;override;i18n;canvasEvent;globalEvent;cursor;range;margin;background;badge;search;group;area;underline;strikeout;highlight;historyManager;previewer;imageParticle;laTexParticle;textParticle;tableParticle;tableTool;tableOperate;pageNumber;lineNumber;waterMark;placeholder;header;footer;hyperlinkParticle;labelParticle;macroParticle;dateParticle;separatorParticle;pageBreakParticle;superscriptParticle;subscriptParticle;checkboxParticle;radioParticle;menstrualHistoryParticle;fetalHeartPositionParticle;toothPositionParticle;blockParticle;listParticle;lineBreakParticle;whiteSpaceParticle;control;pageBorder;workerManager;scrollObserver;selectionObserver;imageObserver;graffiti;command;interactionPaused;overlayActiveCount;globalShortcutSuspended;LETTER_REG;WORD_LIKE_REG;rowList;pageRowList;painterStyle;painterOptions;visiblePageNoList;intersectionPageNo;lazyRenderIntersectionObserver;printModeData;readonlyModeData;splitTdValueMap=new Map;tdMap=new Map;constructor(t,e,n,i,l,r){this.container=this._wrapContainer(t),this.pageList=[],this.ctxList=[],this.pageNo=0,this.renderCount=0,this.pagePixelRatio=null,this.mode=e.mode,this.options=e,this.elementList=n.main,this.listener=i,this.eventBus=l,this.override=r,this._formatContainer(),this.pageContainer=this._createPageContainer(),this._createPage(0),this.i18n=new mT(e.locale),this.historyManager=new pd(this),this.position=new Cd(this),this.zone=new IT(this),this.range=new Id(this),this.margin=new Ed(this),this.background=new Ld(this),this.badge=new DT(this),this.search=new Md(this),this.group=new ET(this),this.area=new bT(this),this.underline=new Sd(this),this.strikeout=new Od(this),this.highlight=new Pd(this),this.previewer=new RT(this),this.imageParticle=new Vs(this),this.laTexParticle=new Us(this),this.textParticle=new Xd(this),this.tableParticle=new yd(this),this.tableTool=new bd(this),this.tableOperate=new yT(this),this.pageNumber=new Qn(this),this.lineNumber=new ST(this),this.waterMark=new vd(this),this.placeholder=new bl(this),this.header=new Yd(this,n.header),this.footer=new LT(this,n.footer),this.hyperlinkParticle=new Dd(this),this.labelParticle=new Vd(this),this.macroParticle=new Wd(this),this.dateParticle=new hT(this),this.separatorParticle=new Zd(this),this.pageBreakParticle=new Qd(this),this.superscriptParticle=new Ud,this.subscriptParticle=new wd,this.checkboxParticle=new nT(this),this.radioParticle=new oT(this),this.menstrualHistoryParticle=new iT(this),this.fetalHeartPositionParticle=new sT(this),this.toothPositionParticle=new rT(this),this.blockParticle=new TT(this),this.listParticle=new PT(this),this.lineBreakParticle=new To(this),this.whiteSpaceParticle=new MT(this),this.control=new zg(this),this.pageBorder=new XT(this),this.graffiti=new VT(this,n.graffiti),this.scrollObserver=new Nd(this),this.selectionObserver=new Fd(this),this.imageObserver=new pT,new OT(this),this.canvasEvent=new fd(this),this.cursor=new Dc(this,this.canvasEvent),this.canvasEvent.register(),this.globalEvent=new md(this,this.canvasEvent),this.globalEvent.register(),this.workerManager=new uT(this),new FT(this);const{letterClass:a}=e;this.LETTER_REG=new RegExp(`[${a.join("")}]`),this.WORD_LIKE_REG=new RegExp(`${a.map(c=>`[^${c}][${c}]`).join("|")}`),this.rowList=[],this.pageRowList=[],this.painterStyle=null,this.painterOptions=null,this.visiblePageNoList=[],this.intersectionPageNo=0,this.lazyRenderIntersectionObserver=null,this.printModeData=null,this.readonlyModeData=null,this.interactionPaused=!1,this.overlayActiveCount=0,this.globalShortcutSuspended=!1,this.isPrintLikeMode()&&this.setPrintData(),this.mode===s.EditorMode.READONLY&&this.setReadonlyData(),this.mode,s.EditorMode.FORM,this.render({isInit:!0,isSetCursor:!1,isFirstRender:!0})}setPrintData(){this.printModeData||(this.printModeData=ct({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const t=ct(this.printModeData);["header","main","footer"].forEach(l=>{t[l]=this.control.filterAssistElement(t[l])});const n=t,i=this.removeStrikeout(n);t.main=i.main.filter(l=>!l.strikeout),this.setEditorData(i)}removeStrikeout(t){if(Array.isArray(t))return t.map(e=>this.removeStrikeout(e)).filter(e=>!(e&&typeof e=="object"&&"strikeout"in e&&e.strikeout===!0));if(t&&typeof t=="object"){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this.removeStrikeout(t[n]));return e}return t}clearPrintData(){this.printModeData&&(this.setEditorData(ct(this.printModeData)),this.printModeData=null)}setReadonlyData(){this.readonlyModeData||(this.readonlyModeData=ct({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const t=ct(this.readonlyModeData);["header","main","footer"].forEach(n=>{const i=wt(t[n],{editorOptions:this.options});t[n]=Dn(i),jt(t[n],{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData(t)}clearReadonlyData(){if(this.readonlyModeData){const t=ct(this.readonlyModeData);this.readonlyModeData=null,this.setEditorData(t)}}getLetterReg(){return this.LETTER_REG}getMode(){return this.mode}isPrintLikeMode(t=this.mode){return t===s.EditorMode.PRINT||t===s.EditorMode.COMPARE}isContentReadonly(){if(this.mode===s.EditorMode.COMPARE)return!0;if(this.area.getActiveAreaInfo()?.area?.mode)return this.area.isReadonly();switch(this.mode){case s.EditorMode.DESIGN:return!1;case s.EditorMode.READONLY:case s.EditorMode.PRINT:case s.EditorMode.GRAFFITI:return!0;case s.EditorMode.FORM:if(this.control.getIsRangeWithinControl()){const t=this.getElementList(),{startIndex:e}=this.range.getRange(),n=t[e];if(n?.control?.type===s.ControlType.TEXTFIELD){const i=n.controlId;if(i){for(let l=0;l<t.length;l++)if(t[l].originControlId===i&&t[l].controlId!==i)return!1}return!0}}return!this.control.getIsRangeWithinControl();default:return!1}}isSelectionDisabled(){return this.mode===s.EditorMode.COMPARE?!1:this.area.getActiveAreaInfo()?.area?.mode?this.area.isReadonly():this.mode===s.EditorMode.READONLY||this.mode===s.EditorMode.PRINT||this.mode===s.EditorMode.GRAFFITI}setMode(t){if(this.mode===t)return;const e=this.mode;this.macroParticle.clearInlineEditor({isSubmitHistory:!1}),this.mode=t,this.options.mode=t;const n=this.isPrintLikeMode(t);this.isPrintLikeMode(e)&&this.clearPrintData(),e===s.EditorMode.READONLY&&t!==s.EditorMode.READONLY&&this.clearReadonlyData(),n&&!this.printModeData&&(this.printModeData=ct({header:this.header.getElementList(),main:this.elementList,footer:this.footer.getElementList()}));const i=new Map,l=a=>{a.forEach(c=>{c.controlId&&(c.controlComponent==="value"&&i.set(c.controlId,!0),c.checked&&i.set(c.controlId,!0))})};l(this.elementList),this.elementList.forEach(a=>{a.type==="table"&&a.trList?.forEach(c=>{c.tdList?.forEach(d=>{l(d.value)})})});const r=a=>{a.forEach(c=>{if(!(!c.control&&!c.controlId)&&(c.controlComponent==="value"&&c.strikeout&&(n?c.hide=!0:c.hide=!1),!!c.control&&!(c.type!=="control"&&c.control.type!=="button"))){if(c.control.type==="TextField"&&(c.controlComponent==="placeholder"||c.controlComponent==="preTextFix"||c.controlComponent==="preTextFixText"||c.controlComponent==="postTextFix"||c.controlComponent==="postTextFixText"||c.controlComponent==="textFixLabel")&&(t===s.EditorMode.EDIT?c.hide=!1:c.hide=!0),c.control.type==="text"&&(c.controlComponent==="placeholder"||c.controlComponent==="prefix"||c.controlComponent==="postfix")&&(t===s.EditorMode.EDIT||t===s.EditorMode.FORM?c.hide=!1:c.hide=!0),c.control.type==="number"||c.control.type==="select"||c.control.type==="date"||c.control.type==="checkbox"||c.control.type==="radio"){if(c.controlComponent==="placeholder"||c.controlComponent==="prefix"||c.controlComponent==="postfix"){const u=i.get(c.controlId);c.control.type==="select"&&n||n&&!u?c.hide=!0:c.hide=!1}c.control.type==="number"&&c.controlComponent==="value"&&(n&&c.strikeout?c.hide=!0:!n&&c.strikeout&&(c.hide=!1))}c.control.type==="button"&&(c.hide=!1,c.control.hide=!1),c.control.type==="menstrualHistory"&&(c.controlComponent==="prefix"||c.controlComponent==="postfix")&&(n?c.hide=!0:c.hide=!1)}})};r(this.elementList),this.elementList.forEach(a=>{a.type==="table"&&a.trList.forEach(c=>{c.tdList.forEach(d=>{r(d.value)})})}),t===s.EditorMode.FORM?(this.elementList.filter(a=>a.type==="control").map(a=>{a.control?.type==="button"&&(a.controlComponent==="prefix"||a.controlComponent==="postfix"?(a.color="#1677FF",a.highlight="transparent"):a.controlComponent==="value"&&(a.color=this.options.defaultColor,a.highlight="transparent"))}),this.hideTextFieldWhitespace(this.elementList,!0),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):t===s.EditorMode.EDIT?(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!0,!1)):(this.hideTextFieldWhitespace(this.elementList,!1),this.updateTextFieldPlaceholderVisibility(this.elementList,!1,!0)),n?(this.elementList.filter(a=>a?.control?.type==="button").map(a=>{(a?.controlComponent==="prefix"||a?.controlComponent==="postfix")&&(a.color="transparent",a.highlight="transparent"),a?.controlComponent==="value"&&!a.control.buttonText&&(a.color=this.options.defaultColor,a.highlight="transparent")}),this.setPrintData()):(this.clearPrintData(),this.elementList.filter(a=>a?.control?.type==="button").map(a=>{(a?.controlComponent==="prefix"||a?.controlComponent==="postfix")&&(a.color="#1677FF",a.highlight="transparent"),a?.controlComponent==="value"&&!a.control.buttonText&&(a.color=this.options.defaultColor,a.highlight="transparent"),a?.type==="text"&&a.control.buttonText&&(a.color="#000"),a?.type==="control"&&a?.controlComponent==="value"&&a.control.buttonText&&(a.color="#000",a.highlight="transparent")})),t===s.EditorMode.READONLY&&this.setReadonlyData(),this.clearSideEffect(),this.control.destroyControl(),this.range.clearRange(),this.render({isSetCursor:!1,isSubmitHistory:!1})}hideTextFieldWhitespace(t,e){const n=a=>a?/^[\s\u00A0\u2000-\u200B\u3000\n\r\t]+$/.test(a):!1,i=(a,c)=>{for(let d=0;d<a.length;d++){const u=a[d];if(u.type===s.ElementType.TABLE&&u.trList)for(const R of u.trList)for(const h of R.tdList)i(h.value,c);u.originControlId&&u.controlId&&u.originControlId!==u.controlId&&c.add(u.originControlId)}},l=new Set;e&&i(t,l),(a=>{for(let c=0;c<a.length;c++){const d=a[c];if(d.type===s.ElementType.TABLE&&d.trList)for(const u of d.trList)for(const R of u.tdList)this.hideTextFieldWhitespace(R.value,e);d.control?.type===s.ControlType.TEXTFIELD&&d.controlComponent===s.ControlComponent.VALUE&&n(d.value)&&(d.controlId&&l.has(d.controlId)?d.hide=!1:d.hide=e)}})(t)}getSubTemplateRuntimeEndIndex(t,e,n){let i=e+1;for(;i<t.length&&t[i].subTemplateParentId===n;)i++;return i}syncSubTemplateExpandedState(t,e,n,i,l){let r=!1;const a=this.getSubTemplateRuntimeEndIndex(t,e,n.id);if(i&&!n.subTemplateContent?.length&&(i=!1),n.subTemplateExpanded!==i&&(n.subTemplateExpanded=i,r=!0),!!n.hide!==l&&(n.hide=l,r=!0),!i)return a>e+1&&(t.splice(e+1,a-e-1),r=!0),r;if(a===e+1){const c=ct(n.subTemplateContent||[]);jt(c,{isHandleFirstElement:!1,editorOptions:this.options});for(let d=0;d<c.length;d++)c[d].subTemplateParentId=n.id;c.length&&(t.splice(e+1,0,...c),r=!0)}return r}applySubTemplateRuntimeState(t,e){const n=i=>{let l=!1,r=0;for(;r<i.length;){const a=i[r];if(a.type===s.ElementType.SUB_TEMPLATE){const c=!!a.subTemplateConditions?.length;if(this.mode===s.EditorMode.EDIT&&c)l=this.syncSubTemplateExpandedState(i,r,a,!0,!0)||l;else if((this.mode===s.EditorMode.FORM||this.isPrintLikeMode())&&c){const d=e?eT(a.subTemplateConditions,e,a.subTemplateRelation):!1;l=this.syncSubTemplateExpandedState(i,r,a,d,!0)||l}else this.mode!==s.EditorMode.FORM&&!this.isPrintLikeMode()&&(l=this.syncSubTemplateExpandedState(i,r,a,!1,!1)||l)}if(a.valueList?.length&&(l=n(a.valueList)||l),a.control?.value?.length&&(l=n(a.control.value)||l),a.type===s.ElementType.TABLE&&a.trList?.length)for(let c=0;c<a.trList.length;c++){const d=a.trList[c];for(let u=0;u<d.tdList.length;u++)l=n(d.tdList[u].value)||l}r++}return l};return n(t)}updateTextFieldPlaceholderVisibility(t,e,n){const i=[s.ControlType.TEXT,s.ControlType.TEXTFIELD,s.ControlType.SELECT,s.ControlType.DATE,s.ControlType.CHECKBOX,s.ControlType.RADIO,s.ControlType.NUMBER];(r=>{let a=0;for(;a<r.length;){const c=r[a];if(c.type===s.ElementType.TABLE&&c.trList)for(const d of c.trList)for(const u of d.tdList)this.updateTextFieldPlaceholderVisibility(u.value,e,n);if(c.control?.type&&i.includes(c.control.type)&&(c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PRE_TEXT)){const d=c.controlId,u=c.control.type;let R=!1,h=!1,g=!1;const T=[],f=[],p=[];let C=-1,I=a;for(;I<r.length;){const m=r[I];if(m.controlId!==d){const P=m.controlId;let E=u===s.ControlType.TEXT,M=I;if(E)for(;M<r.length&&r[M].controlId===P;)M++;else for(;M<r.length;){const F=r[M];if(F.controlId!==P)break;F.controlComponent===s.ControlComponent.VALUE&&(F.value&&F.value.trim()||F.type===s.ElementType.MENSTRUAL_HISTORY||F.type===s.ElementType.FETAL_HEART_POSITION||F.type===s.ElementType.TOOTH_POSITION||F.type===s.ElementType.MACRO||F.type===s.ElementType.CUSTOM_MACRO)&&(E=!0),M++}E&&(h=!0),I=M;continue}if((m.controlComponent===s.ControlComponent.PREFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX||m.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&f.push(I),m.controlComponent===s.ControlComponent.VALUE&&m.value&&m.value.trim()&&(R=!0),m.controlComponent===s.ControlComponent.VALUE&&(m.type===s.ElementType.MENSTRUAL_HISTORY||m.type===s.ElementType.FETAL_HEART_POSITION||m.type===s.ElementType.TOOTH_POSITION||m.type===s.ElementType.MACRO||m.type===s.ElementType.CUSTOM_MACRO)&&(R=!0),m.controlComponent===s.ControlComponent.VALUE&&m.control&&m.control.type!==u&&(h=!0),m.controlComponent===s.ControlComponent.PLACEHOLDER&&(g=!0,T.push(I)),m.controlComponent===s.ControlComponent.POSTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX||m.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT){p.push(I),C=I;break}I++}if(R||h){if(g&&T.length>0)for(const m of T)r[m].hide=!0}else if(g&&T.length>0)for(const m of T)r[m].hide=!e;else e&&c.control?.placeholder&&(C>0?this.control.addPlaceholder(C-1):this.control.addPlaceholder(a));if(n)if(e&&(R||h)){for(const m of f)r[m].hide=!0;for(const m of p)r[m].hide=!0}else if(e){for(const m of f)r[m].hide=!1;for(const m of p)r[m].hide=!1}else{for(const m of f)r[m].hide=!0;for(const m of p)r[m].hide=!0}else{for(const m of f)r[m].hide=!1;for(const m of p)r[m].hide=!1}a=I}a++}})(t)}isReadonly(){return this.isContentReadonly()}isDisabled(){if(this.mode===s.EditorMode.DESIGN)return!1;const{startIndex:t,endIndex:e}=this.range.getRange(),n=this.getElementList();if(this.getTd()?.disabled)return!0;if(t===e){const l=n[t],r=n[t+1];return!!(l?.title?.disabled&&r?.title?.disabled&&l.titleId===r.titleId||l?.control?.disabled&&r?.control?.disabled&&l.controlId===r.controlId)}return n.slice(t+1,e+1).some(l=>l.title?.disabled||l.control?.disabled)}isDesignMode(){return this.mode===s.EditorMode.DESIGN}isPrintMode(){return this.mode===s.EditorMode.PRINT}isGraffitiMode(){return this.mode===s.EditorMode.GRAFFITI}getOriginalWidth(){const{paperDirection:t,width:e,height:n}=this.options;return t===s.PaperDirection.VERTICAL?e:n}getOriginalHeight(){const{paperDirection:t,width:e,height:n}=this.options;return t===s.PaperDirection.VERTICAL?n:e}getWidth(){return Math.floor(this.getOriginalWidth()*this.options.scale)}getHeight(){return Math.floor(this.getOriginalHeight()*this.options.scale)}getMainHeight(){return this.getHeight()-this.getMainOuterHeight()}getMainOuterHeight(){const t=this.getMargins(),e=this.header.getExtraHeight(),n=this.footer.getExtraHeight();return t[0]+t[2]+e+n}getCanvasWidth(t=-1){return this.getPage(t).width}getCanvasHeight(t=-1){return this.getPage(t).height}getInnerWidth(){const t=this.getWidth(),e=this.getMargins();return t-e[1]-e[3]}getOriginalInnerWidth(){const t=this.getOriginalWidth(),e=this.getOriginalMargins();return t-e[1]-e[3]}getContextInnerWidth(){const t=this.position.getPositionContext();if(t.isTable){const{index:e,trIndex:n,tdIndex:i}=t,r=this.getOriginalElementList()[e],a=r.trList[n].tdList[i],c=this.getTdPadding(r);return a.width-c[1]-c[3]}return this.getOriginalInnerWidth()}getMargins(){return this.getOriginalMargins().map(t=>t*this.options.scale)}getOriginalMargins(){const{margins:t,paperDirection:e}=this.options;return e===s.PaperDirection.VERTICAL?t:[t[1],t[2],t[3],t[0]]}getPageGap(){return this.options.pageGap*this.options.scale}getOriginalPageGap(){return this.options.pageGap}getPageNumberBottom(){const{pageNumber:{bottom:t},scale:e}=this.options;return t*e}getMarginIndicatorSize(){return this.options.marginIndicatorSize*this.options.scale}getDefaultBasicRowMarginHeight(){return this.options.defaultBasicRowMarginHeight*this.options.scale}getHighlightMarginHeight(){return this.options.highlightMarginHeight*this.options.scale}getTdPadding(t){const{table:{tdPadding:e},scale:n}=this.options;return(t?.tdPadding||e).map(l=>l*n)}getContainer(){return this.container}getPageContainer(){return this.pageContainer}getEventTarget(t){return t instanceof Element?t:t instanceof Node?t.parentElement:null}isTargetInsideEditor(t){const e=this.getEventTarget(t);return e?this.container.contains(e)?!0:!!Os(e,n=>!!n&&n.nodeType===1&&!!n.getAttribute(Be)):!1}isTargetInsideExternalOverlay(t){const e=this.getEventTarget(t);return!e||this.isTargetInsideEditor(e)?!1:!!e.closest(WT)}pauseInteraction(){this.interactionPaused=!0,this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect()}resumeInteraction(){this.interactionPaused=!1}setOverlayActive(t){this.overlayActiveCount=t?1:0,t&&(this.cursor?.getAgentDom().blur(),this.globalEvent?.resetSideEffect())}suspendGlobalShortcut(t){this.globalShortcutSuspended=t}isInteractionSuspended(){return this.interactionPaused||this.overlayActiveCount>0}isGlobalShortcutActive(){return!this.globalShortcutSuspended&&!this.isInteractionSuspended()}getVisiblePageNoList(){return this.visiblePageNoList}setVisiblePageNoList(t){this.visiblePageNoList=t,this.listener.visiblePageNoListChange&&this.listener.visiblePageNoListChange(this.visiblePageNoList),this.eventBus.isSubscribe("visiblePageNoListChange")&&this.eventBus.emit("visiblePageNoListChange",this.visiblePageNoList)}getIntersectionPageNo(){return this.intersectionPageNo}setIntersectionPageNo(t){this.intersectionPageNo=t,this.listener.intersectionPageNoChange&&this.listener.intersectionPageNoChange(this.intersectionPageNo),this.eventBus.isSubscribe("intersectionPageNoChange")&&this.eventBus.emit("intersectionPageNoChange",this.intersectionPageNo)}getPageNo(){return this.pageNo}setPageNo(t){this.pageNo=t}getRenderCount(){return this.renderCount}getPage(t=-1){return this.pageList[~t?t:this.pageNo]}getPageList(){return this.pageList}getPageCount(){return this.pageList.length}getTableRowList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:l}=e;return t[n].trList[i].tdList[l].rowList}getOriginalRowList(){const t=this.getZone();return t.isHeaderActive()?this.header.getRowList():t.isFooterActive()?this.footer.getRowList():this.rowList}getRowList(){return this.position.getPositionContext().isTable?this.getTableRowList(this.getOriginalElementList()):this.getOriginalRowList()}getPageRowList(){return this.pageRowList}getCtx(){return this.ctxList[this.pageNo]}getOptions(){return this.options}getSearch(){return this.search}getGroup(){return this.group}getArea(){return this.area}getBadge(){return this.badge}getHistoryManager(){return this.historyManager}getPosition(){return this.position}getZone(){return this.zone}getRange(){return this.range}getLineBreakParticle(){return this.lineBreakParticle}getTextParticle(){return this.textParticle}getHeaderElementList(){return this.header.getElementList()}getTableElementList(t){const e=this.position.getPositionContext(),{index:n,trIndex:i,tdIndex:l}=e;return t[n]?.trList?.[i].tdList[l].value||[]}getElementList(){const t=this.position.getPositionContext(),e=this.getOriginalElementList();return t.isTable?this.getTableElementList(e):e}getMainElementList(){return this.position.getPositionContext().isTable?this.getTableElementList(this.elementList):this.elementList}getOriginalElementList(){const t=this.getZone();return t.isHeaderActive()?this.getHeaderElementList():t.isFooterActive()?this.getFooterElementList():this.elementList}getOriginalMainElementList(){return this.elementList}getFooterElementList(){return this.footer.getElementList()}getTd(){const t=this.position.getPositionContext(),{index:e,trIndex:n,tdIndex:i,isTable:l}=t;return l?this.getOriginalElementList()[e].trList[n].tdList[i]:null}getTdByPosition(t){const{index:e,trIndex:n,tdIndex:i,isTable:l}=t;return l?this.getOriginalElementList()[e].trList[n].tdList[i]:null}insertElementTextField(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.getElementList(),{isSubmitHistory:r=!0}=e;jt(t,{isHandleFirstElement:!1,editorOptions:this.options});let a=-1,c=this.control.getActiveControl();if(!c&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),c=this.control.getActiveControl()),c&&this.control.getIsRangeWithinControl()){const d=n===i,u=n+1;d||this.newSpliceElementList(l,u,i-n),this.newSpliceElementList(l,u,0,t),a=n+t.length}else{const d=n===i,u=n+1;d||this.newSpliceElementList(l,u,i-n),this.newSpliceElementList(l,u,0,t),a=n+t.length;const R=l[u-1];t[0].listId&&R&&!R.listId&&R?.value===K&&(!R.type||R.type===s.ElementType.TEXTFIELD)&&(l.splice(n,1),a-=1)}this.control.destroyControl(),~a&&(this.range.setRange(a,a),this.render({curIndex:a,isSubmitHistory:r}))}insertElementList(t,e={}){if(!t.length||!this.range.getIsCanInput())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const{isSubmitHistory:l=!0}=e;jt(t,{isHandleFirstElement:!1,editorOptions:this.options});let r=-1,a=this.control.getActiveControl();if(!a&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),a=this.control.getActiveControl()),a&&this.control.getIsRangeWithinControl()){const c=this.getElementList(),d=n===i,u=n+1,R=c[n],h=c[u],g=M=>!!(M&&(M.controlComponent===s.ControlComponent.POSTFIX||M.controlComponent===s.ControlComponent.POST_TEXT||M.controlComponent===s.ControlComponent.POSTTEXTFIX||M.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)),T=M=>!!(M&&(M.controlComponent===s.ControlComponent.PREFIX||M.controlComponent===s.ControlComponent.PRE_TEXT||M.controlComponent===s.ControlComponent.PRETEXTFIX||M.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)),f=M=>{if(M)return c.find(F=>F.controlId===M&&!F.originControlId&&!!F.control?.type)},p=R?.originControlId&&h?.originControlId===R.originControlId&&R.controlId&&h.controlId&&R.controlId!==h.controlId&&g(R)&&T(h)?f(R.originControlId):void 0,C=p?.control?.type===s.ControlType.TEXTFIELD,I=!!(R?.originControlId&&g(R)&&h?.controlId===R.originControlId&&!h.originControlId&&h.control?.type===s.ControlType.TEXTFIELD&&g(h)),m=!!(R?.originControlId&&g(R)&&h?.controlId===R.originControlId&&!h.originControlId&&h.control?.type===s.ControlType.TEXTFIELD&&h.controlComponent===s.ControlComponent.VALUE);if(R?.controlComponent===s.ControlComponent.PRE_TEXT||R?.controlComponent===s.ControlComponent.POST_TEXT||R?.controlComponent===s.ControlComponent.PREFIX||R?.controlComponent===s.ControlComponent.POSTFIX)for(let M=0;M<t.length;M++)t[M].control||(t[M].color=this.options.defaultColor);d&&!I&&!m&&(c[n]?.control?.type===s.ControlType.TEXTFIELD||c[n]?.control?.type===s.ControlType.TEXT)&&this.control.removePlaceholder(n),d||this.newSpliceElementList(c,u,i-n);const E=I||m||C?R.originControlId:c[n]?.controlId||c[n-1]?.controlId||c[n+1]?.controlId;for(let M=0;M<t.length;M++){if((I||m||C)&&!t[M].control&&(t[M].controlId=E,t[M].control=C?p?.control:h.control,t[M].controlComponent=s.ControlComponent.VALUE,delete t[M].originControlId),t[M]?.control?.type=="button"&&!t[M]?.control?.buttonText&&(t[M]?.controlComponent==="prefix"||t[M]?.controlComponent==="postfix"?(t[M].color="#1677FF",t[M].highlight="transparent"):(t[M].color=this.options.defaultColor,t[M].highlight="transparent")),t[M]?.type===s.ElementType.MENSTRUAL_HISTORY||t[M]?.type===s.ElementType.FETAL_HEART_POSITION||t[M]?.type===s.ElementType.TOOTH_POSITION||t[M]?.type===s.ElementType.MACRO||t[M]?.type===s.ElementType.CUSTOM_MACRO||t[M]?.type===s.ElementType.REUSABLE_ITEM||t[M]?.type===s.ElementType.SUB_TEMPLATE||t[M]?.type===s.ElementType.SPECIAL_SYMBOLS){t[M].controlComponent=s.ControlComponent.VALUE;let F=c[n]?.controlId;F||(F=c[n-1]?.controlId),F||(F=c[n+1]?.controlId),!t[M].controlId&&F&&(t[M].controlId=F)}E&&t[M]?.control&&t[M].controlId&&t[M].controlId!==E&&(t[M].originControlId=E)}this.newSpliceElementList(c,u,0,t),r=n+t.length}else{const c=this.getElementList(),d=n===i,u=n+1;if(c[u]?.control?.type=="TextField"||c[n]?.control?.type=="TextField"){d||this.newSpliceElementList(c,u,i-n);for(let R=0;R<t.length;R++)if(t[R]?.type===s.ElementType.MENSTRUAL_HISTORY||t[R]?.type===s.ElementType.FETAL_HEART_POSITION||t[R]?.type===s.ElementType.TOOTH_POSITION||t[R]?.type===s.ElementType.MACRO||t[R]?.type===s.ElementType.CUSTOM_MACRO||t[R]?.type===s.ElementType.REUSABLE_ITEM||t[R]?.type===s.ElementType.SUB_TEMPLATE||t[R]?.type===s.ElementType.SPECIAL_SYMBOLS){t[R].controlComponent=s.ControlComponent.VALUE;const h=c[n]?.controlId||c[u]?.controlId;!t[R].controlId&&h&&(t[R].controlId=h)}this.newSpliceElementList(c,u,0,t),r=n+t.length}else{d||this.spliceElementList(c,u,i-n);for(let h=0;h<t.length;h++)t[h]?.control?.type=="button"&&!t[h]?.control?.buttonText&&(t[h]?.controlComponent==="prefix"||t[h]?.controlComponent==="postfix"?(t[h].color="#1677FF",t[h].highlight="transparent"):(t[h].color=this.options.defaultColor,t[h].highlight="transparent"));this.spliceElementList(c,u,0,t),r=n+t.length;const R=c[u-1];t[0].listId&&R&&!R.listId&&R?.value===K&&(!R.type||R.type===s.ElementType.TEXT)&&(c.splice(n,1),r-=1)}}~r&&(this.range.setRange(r,r),this.render({curIndex:r,isSubmitHistory:l}))}appendElementList(t,e={}){if(!t.length)return;jt(t,{isHandleFirstElement:!1,editorOptions:this.options});let n;const{isPrepend:i,isSubmitHistory:l=!0}=e;i?(this.elementList.splice(1,0,...t),n=t.length):(this.elementList.push(...t),n=this.elementList.length-1),this.range.setRange(n,n),this.render({curIndex:n,isSubmitHistory:l})}spliceElementList(t,e,n,i,l){const{isIgnoreDeletedRule:r=!1}=l||{},{group:a,modeRule:c}=this.options;if(n>0){const d=e+n,R=t[d]?.listId;if(R&&t[e-1]?.listId!==R){let h=d;for(;h<t.length;){const g=t[h];if(g.listId!==R||g.value===K)break;delete g.listId,delete g.listType,delete g.listStyle,h++}}if(!r&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const h=this.getTd()?.deletable;let g=d-1;for(;g>=e;){const T=t[g];(ae(T)||h!==!1&&T?.control?.deletable!==!1&&(!T.controlId||this.mode!==s.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&T?.title?.deletable!==!1&&(a.deletable!==!1||!T.groupIds?.length)&&(T?.area?.deletable!==!1||T?.areaIndex!==0))&&t.splice(g,1),g--}}else t.splice(e,n)}if(i?.length){let d=t[e];for(let u=0;u<i.length;u++)!i[u].controlComponent&&d?.controlComponent&&(i[u].controlId=d.controlId,i[u].control=d.control,i[u].controlComponent=d.controlComponent),d=i[u];Vl(t,e,i)}}newSpliceElementList(t,e,n,i,l){const{isIgnoreDeletedRule:r=!1}=l||{},{group:a,modeRule:c}=this.options;if(n>0){const u=e+n,h=t[u]?.listId;if(h&&t[e-1]?.listId!==h){let g=u;for(;g<t.length;){const T=t[g];if(T.listId!==h||T.value===K)break;delete T.listId,delete T.listType,delete T.listStyle,g++}}if(!r&&!this.isDesignMode()&&!this.control.getIsRangeWithinControl()){const g=this.getTd()?.deletable;let T=u-1;for(;T>=e;){const f=t[T];(ae(f)||g!==!1&&f?.control?.deletable!==!1&&(!f.controlId||this.mode!==s.EditorMode.FORM||!c[this.mode].controlDeletableDisabled)&&f?.title?.deletable!==!1&&(a.deletable!==!1||!f.groupIds?.length)&&(f?.area?.deletable!==!1||f?.areaIndex!==0))&&t.splice(T,1),T--}}else t.splice(e,n)}const d=t[e]?.controlId;if(i?.length){for(let u=0;u<i.length;u++)d&&i[u].controlId!==d&&(i[u].originControlId=d);Vl(t,e,i)}}getCanvasEvent(){return this.canvasEvent}getGlobalEvent(){return this.globalEvent}getListener(){return this.listener}getEventBus(){return this.eventBus}getOverride(){return this.override}getCursor(){return this.cursor}getPreviewer(){return this.previewer}getImageParticle(){return this.imageParticle}getTableTool(){return this.tableTool}getTableOperate(){return this.tableOperate}getTableParticle(){return this.tableParticle}getHeader(){return this.header}getFooter(){return this.footer}getHyperlinkParticle(){return this.hyperlinkParticle}getMacroParticle(){return this.macroParticle}getDateParticle(){return this.dateParticle}getListParticle(){return this.listParticle}getCheckboxParticle(){return this.checkboxParticle}getRadioParticle(){return this.radioParticle}getMenstrualHistoryParticle(){return this.menstrualHistoryParticle}getFetalHeartPositionParticle(){return this.fetalHeartPositionParticle}getToothPositionParticle(){return this.toothPositionParticle}getControl(){return this.control}getWorkerManager(){return this.workerManager}getImageObserver(){return this.imageObserver}getI18n(){return this.i18n}getGraffiti(){return this.graffiti}setCommand(t){this.command=t}getCommand(){return this.command}getRowCount(){return this.getRowList().length}async getDataURL(t={}){const{pixelRatio:e,mode:n}=t;e&&this.setPagePixelRatio(e);const i=this.mode,l=!!n&&i!==n;l&&this.setMode(n),this.render({isLazy:!1,isCompute:!1,isSetCursor:!1,isSubmitHistory:!1}),await this.imageObserver.allSettled();const r=this.pageList.map(a=>a.toDataURL());return e&&this.setPagePixelRatio(null),l&&this.setMode(i),r}getPainterStyle(){return this.painterStyle&&Object.keys(this.painterStyle).length?this.painterStyle:null}getPainterOptions(){return this.painterOptions}setPainterStyle(t,e){this.painterStyle=t,this.painterOptions=e||null,this.getPainterStyle()&&this.pageList.forEach(n=>n.style.cursor="copy")}setDefaultRange(){this.elementList.length&&setTimeout(()=>{const t=this.elementList.length-1;this.range.setRange(t,t),this.range.setRangeStyle()})}getIsPagingMode(){return this.options.pageMode===s.PageMode.PAGING}setPageMode(t){if(!t||this.options.pageMode===t)return;if(this.options.pageMode=t,t===s.PageMode.PAGING){const{height:i}=this.options,l=this.getPagePixelRatio(),r=this.pageList[0];r.style.height=`${i}px`,r.height=i*l,this._initPageContext(this.ctxList[0])}else this._disconnectLazyRender(),this.header.recovery(),this.footer.recovery(),this.zone.setZone(s.EditorZone.MAIN);const{startIndex:e}=this.range.getRange(),n=this.range.getIsCollapsed();this.render({isSetCursor:!0,curIndex:e,isSubmitHistory:!1}),n||this.cursor.drawCursor({isShow:!1}),setTimeout(()=>{this.listener.pageModeChange&&this.listener.pageModeChange(t),this.eventBus.isSubscribe("pageModeChange")&&this.eventBus.emit("pageModeChange",t)})}setPageScale(t){const e=this.getPagePixelRatio();this.options.scale=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((r,a)=>{r.width=n*e,r.height=i*e,r.style.width=`${n}px`,r.style.height=`${i}px`,r.style.marginBottom=`${this.getPageGap()}px`,this._initPageContext(this.ctxList[a])});const l=this.position.getCursorPosition();this.render({isSubmitHistory:!1,isSetCursor:!!l,curIndex:l?.index}),this.listener.pageScaleChange&&this.listener.pageScaleChange(t),this.eventBus.isSubscribe("pageScaleChange")&&this.eventBus.emit("pageScaleChange",t)}getPagePixelRatio(){return this.pagePixelRatio||window.devicePixelRatio}setPagePixelRatio(t){!this.pagePixelRatio&&t===window.devicePixelRatio||t===this.pagePixelRatio||(this.pagePixelRatio=t,this.setPageDevicePixel())}setPageDevicePixel(){const t=this.getPagePixelRatio(),e=this.getWidth(),n=this.getHeight();this.pageList.forEach((i,l)=>{i.width=e*t,i.height=n*t,this._initPageContext(this.ctxList[l])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperSize(t,e){this.options.width=t,this.options.height=e;const n=this.getPagePixelRatio(),i=this.getWidth(),l=this.getHeight();this.container.style.width=`${i}px`,this.pageList.forEach((r,a)=>{r.width=i*n,r.height=l*n,r.style.width=`${i}px`,r.style.height=`${l}px`,this._initPageContext(this.ctxList[a])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperDirection(t){const e=this.getPagePixelRatio();this.options.paperDirection=t;const n=this.getWidth(),i=this.getHeight();this.container.style.width=`${n}px`,this.pageList.forEach((l,r)=>{l.width=n*e,l.height=i*e,l.style.width=`${n}px`,l.style.height=`${i}px`,this._initPageContext(this.ctxList[r])}),this.render({isSubmitHistory:!1,isSetCursor:!1})}setPaperMargin(t){this.options.margins=t,this.render({isSubmitHistory:!1,isSetCursor:!1})}getOriginValue(t={}){const{pageNo:e}=t,n=this.readonlyModeData;let i=n?.main||this.elementList;return Number.isInteger(e)&&e>=0&&e<this.pageRowList.length&&(i=this.pageRowList[e].flatMap(r=>r.elementList)),{header:n?.header||this.getHeaderElementList(),main:i,footer:n?.footer||this.getFooterElementList(),graffiti:this.graffiti.getValue()}}getValue(t={}){const e=this.getOriginValue(t);console.log(this.elementList,"所有元素");const{extraPickAttrs:n}=t,i={header:wt(e.header,{extraPickAttrs:n,editorOptions:this.options}),main:wt(e.main,{extraPickAttrs:n,isClassifyArea:!0,editorOptions:this.options}),footer:wt(e.footer,{extraPickAttrs:n,editorOptions:this.options}),graffiti:e.graffiti};return{version:fn,data:i,options:ct(this.options)}}setValue(t,e){const{header:n,main:i,footer:l}=ct(t);if(!n&&!i&&!l)return;const{isSetCursor:r=!1}=e||{};[n,i,l].forEach(d=>{d&&jt(d,{editorOptions:this.options,isForceCompensation:!0})}),this.setEditorData({header:n,main:i,footer:l}),this.mode===s.EditorMode.READONLY?(this.readonlyModeData=null,this.setReadonlyData()):this.isPrintLikeMode()&&(this.printModeData=null,this.setPrintData()),this.historyManager.recovery();const c=r?i?.length?i.length-1:0:void 0;c!==void 0&&this.range.setRange(c,c),this.render({curIndex:c,isSetCursor:r,isFirstRender:!0})}setEditorData(t){const{header:e,main:n,footer:i}=t;e&&this.header.setElementList(e),n&&(this.elementList=n),i&&this.footer.setElementList(i)}_wrapContainer(t){const e=document.createElement("div");return t.append(e),e}_formatContainer(){this.container.style.position="relative",this.container.style.width=`${this.getWidth()}px`,this.container.setAttribute(Be,s.EditorComponent.MAIN)}_createPageContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-page-container`),this.container.append(t),t}_createPage(t){const e=this.getWidth(),n=this.getHeight(),i=document.createElement("canvas");i.style.width=`${e}px`,i.style.height=`${n}px`,i.style.display="block",i.style.backgroundColor="#ffffff",i.style.marginBottom=`${this.getPageGap()}px`,i.setAttribute("data-index",String(t)),this.pageContainer.append(i);const l=this.getPagePixelRatio();i.width=e*l,i.height=n*l,i.style.cursor="text";const r=i.getContext("2d");this._initPageContext(r),this.pageList.push(i),this.ctxList.push(r)}_initPageContext(t){const e=this.getPagePixelRatio();t.scale(e,e),t.letterSpacing="0px",t.wordSpacing="0px",t.direction="ltr"}getElementFont(t,e=1){const{defaultSize:n,defaultFont:i}=this.options,l=t.font||i,r=t.actualSize||t.size||n;return`${t.italic?"italic ":""}${t.bold?"bold ":""}${r*e}px ${l}`}getElementSize(t){return t.actualSize||t.size||this.options.defaultSize}getElementRowMargin(t){const{defaultSize:e,defaultBasicRowMarginHeight:n,defaultRowMargin:i,scale:l}=this.options,r=t.size||e;let a=1;return r<12?a=r/12:r>30&&(a=1+(r-30)/30),n*a*(t.rowMargin??i)*l}computeRowList(t){const{innerWidth:e,elementList:n,isPagingMode:i=!1,isFromTable:l=!1,startX:r=0,startY:a=0,pageHeight:c=0,mainOuterHeight:d=0,surroundElementList:u=[]}=t,{defaultSize:R,scale:h,imgCaption:g,table:{tdPadding:T,defaultTrMinHeight:f},defaultTabWidth:p}=this.options,C=this.getDefaultBasicRowMarginHeight(),m=document.createElement("canvas").getContext("2d"),P=this.listParticle.computeListStyle(m,n),E=[],M=this._collectTextControlValueSet(n),F=this._collectTextControlHasContentSet(n);n.length&&E.push({width:0,height:0,ascent:0,elementList:[],startIndex:0,rowIndex:0,rowFlex:n?.[0]?.rowFlex||n?.[1]?.rowFlex});let y=r,Y=a,D=0,O,b=0,V=0;for(let X=0;X<n.length;X++){const N=E[E.length-1],L=n[X];this.clearElementEffect(L);const W=this.getElementRowMargin(L),S={width:0,height:0,boundingBoxAscent:0,boundingBoxDescent:0},U=N.offsetX||L.listId&&P.get(L.listId)||0,Q=e-U,v=N.elementList.length===1;if(y+=v?U:0,Y+=v&&N.offsetY||0,(L.control?.type===s.ControlType.TEXTFIELD||L.control?.type===s.ControlType.TEXT)&&!this.isDesignMode()&&(L.controlComponent===s.ControlComponent.PRETEXTFIX||L.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||L.controlComponent===s.ControlComponent.POSTTEXTFIX||L.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT||L.controlComponent===s.ControlComponent.TEXTFIXLABEL||L.controlComponent===s.ControlComponent.PLACEHOLDER||L.controlComponent===s.ControlComponent.PREFIX||L.controlComponent===s.ControlComponent.POSTFIX)){const J=L.control?.type===s.ControlType.TEXTFIELD,lt=L.controlId,$=!!lt&&!!M?.has(lt);if(J){const j=!!lt&&!!F?.has(lt);this.mode===s.EditorMode.EDIT?L.controlComponent===s.ControlComponent.PLACEHOLDER||L.controlComponent===s.ControlComponent.TEXTFIXLABEL?L.hide=j:L.hide=!1:L.hide=!0}else{const j=!!lt&&!!F?.has(lt);this.mode===s.EditorMode.EDIT||this.mode===s.EditorMode.FORM?L.controlComponent===s.ControlComponent.PLACEHOLDER||L.controlComponent===s.ControlComponent.TEXTFIXLABEL?L.hide=j:L.hide=!1:L.hide=!0}}if(ae(L)&&!this.isDesignMode()){const J=N.elementList[N.elementList.length-1];S.height=J?.metrics.height||this.options.defaultSize*h,S.boundingBoxAscent=J?.metrics.boundingBoxAscent||0,S.boundingBoxDescent=J?.metrics.boundingBoxDescent||0}else if(L.type===s.ElementType.IMAGE||L.type===s.ElementType.LATEX)if(L.imgDisplay===s.ImageDisplay.SURROUND||L.imgDisplay===s.ImageDisplay.FLOAT_TOP||L.imgDisplay===s.ImageDisplay.FLOAT_BOTTOM)S.width=0,S.height=0,S.boundingBoxDescent=0;else{const J=L.width*h,lt=L.height*h;if(J>Q){const $=lt*Q/J;L.width=Q/h,L.height=$/h,S.width=Q,S.height=$,S.boundingBoxDescent=$}else S.width=J,S.height=lt,S.boundingBoxDescent=lt;if(L.imgCaption?.value){const $=L.imgCaption.size||g.size,j=L.imgCaption.top??g.top,tt=($+j)*h;S.boundingBoxAscent+=tt}}else if(L.type===s.ElementType.TABLE){const J=L.tdPadding||T;if(L.pagingId){let x=X+1,Rt=0;for(;x<n.length;){const ht=n[x];if(ht.pagingId===L.pagingId){const mt=ht.trList.filter(Pt=>!Pt.pagingRepeat).filter(Pt=>(Pt.tdList=Pt.tdList.filter(Qt=>{if(Qt.originalId){for(let Lt=0;Lt<L.trList.length;Lt++){const At=L.trList[Lt],ee=At.tdList.find(({id:ne})=>ne===Qt.originalId);if(ee){Qt.value[0]?.type===s.ElementType.SPLIT_TAG&&Qt.value.splice(0,1),ee.value.push(...Qt.value.map(ne=>this.updateElementTableInfo(ne,L,At,ee))),ee.rowspan=ee.originalRowspan??ee.rowspan;break}}return!1}return!0}),!Pt.originalId));L.trList.push(...mt),L.height+=ht.height,x++,Rt++}else break}Rt&&n.splice(X+1,Rt)}L.pagingIndex=L.pagingIndex??0,this.tableParticle.computeTrHeight(L,x=>this.computeRowList({innerWidth:(x.width-(J[1]+J[3]))*h,elementList:x.value,isFromTable:!0,isPagingMode:i})),L.trList?.forEach(x=>{x.tdList.forEach(Rt=>{this.tdMap.set(Rt.id,Rt)})});const lt=this.tableParticle.getTableHeight(L),$=this.tableParticle.getTableWidth(L);L.width=$,L.height=lt;const j=$*h,tt=lt*h;if(S.width=j,S.height=tt,S.boundingBoxDescent=tt,S.boundingBoxAscent=-W,n[X+1]?.type===s.ElementType.TABLE&&(S.boundingBoxAscent-=W),i){const x=this.getHeight(),Rt=this.getMainOuterHeight();let ht=Rt;for(let Lt=0;Lt<E.length;Lt++){const At=E[Lt],ee=At.offsetY||0;At.height+ht+ee>x||E[Lt-1]?.isPageBreak?ht=Rt+At.height+ee:ht+=At.height+ee}const mt=W*2,Pt=L.trList[0].height*h;(ht+Pt+mt>x||L.pagingIndex!==0&&L.trList[0].pagingRepeat||n[X-1]?.type===s.ElementType.PAGE_BREAK)&&(ht=Rt);let Qt=x-(ht+mt);if(tt>Qt){const Lt=L.trList;let At=0,ee=0,ne=0;for(let Yt=0;Yt<Lt.length;Yt++){const Xt=Lt[Yt],bt=Xt.height*h;if(ht+mt+ne+bt>x){const Ft=Xt;let Et=0;const Mt={...ct(Ft),id:ft(),originalId:Ft.originalId??Ft.id,minHeight:void 0,tdList:L.colgroup.map((at,Gt)=>{if(Et--,Et>0)return;const k=Ft.tdList.find(it=>it.colIndex===Gt),ot=k??this.tableParticle.findPreRowSpanTd(Lt,Yt,Gt);k&&(Et=k.colspan);const pt=ft();return ot.originalRowspan=ot.rowspan,k?{...k,id:pt,originalId:k.originalId??k.id,linkTdPrevId:k.id,tdIndex:Gt,original:ot}:{id:pt,originalId:ot.originalId??ot.id,linkTdPrevId:ot.id,tdIndex:Gt,colIndex:Gt,colspan:1,rowspan:1,value:[],rowList:[],original:ot}}).filter(at=>!!at)},St=Mt.tdList,Vt=St.map(at=>at.original);Vt.forEach((at,Gt)=>{const k=[];let ot=Qt;if(at.rowspan>1){const it=Lt.slice(at.trIndex,at.trIndex+Yt-at.trIndex);ot+=it.reduce((de,kt)=>kt.height*h+de,0)}for(;at.mainHeight*h>ot&&at.rowList?.length;){const it=at.rowList.pop();at.value.splice(at.value.length-it.elementList.length),k.unshift(it),at.mainHeight-=it.height}const pt=St[Gt];pt.rowList=k,pt.value=k.map(it=>it.elementList).flat()});let me=!0;const Ot=Ft.tdList.some(at=>at.rowList?.length),nt=Mt.tdList.some(at=>at.rowList?.length),Ut=Ft.minHeight>Qt;if(nt||Ut){(Ot||!nt&&Ut)&&(Ut&&(Ft.originalMinHeight=Ft.minHeight,Ft.minHeight=Qt,Mt.minHeight=Math.max(Ft.originalMinHeight-Qt,f)),Mt.tdList.forEach(at=>{at.original.linkTdNextId=at.id,at.value.length&&at.value[0].value!==K&&at.value.unshift({...at.original.value.slice(-1).pop(),value:K,type:s.ElementType.SPLIT_TAG})}),Lt.splice(At+1,0,Mt),At+=1,ee=Lt.length-At,me=!1),Vt.forEach(at=>{if(at.rowspan>1){const Gt=at.rowspan-(Yt-at.trIndex);at.rowspan=Yt-at.trIndex+(Ot?1:0);const k=Mt.tdList.find(ot=>ot.colIndex===at.colIndex);Ot?k.rowspan=Gt:(k.original.linkTdNextId=k.id,Ft.tdList.push({...at,...k,rowspan:Gt}),Ft.tdList.sort((ot,pt)=>ot.colIndex-pt.colIndex),k.value=[])}}),me&&Vt.forEach((at,Gt)=>{at.value.push(...St[Gt].value)});break}}At=Yt+1,ee=Lt.length-At,ne+=bt,Qt-=bt}if(ee){const Yt=Lt.splice(At,ee),Xt=L.pagingId||ft();L.pagingId=Xt;const bt=ct(L);bt.originalId=L.originalId??L.id,bt.pagingId=Xt,bt.pagingIndex=L.pagingIndex+1;const Ft=Lt.filter(St=>St.pagingRepeat);if(Ft.length){const St=ct(Ft);St.forEach(Vt=>Vt.id=ft()),Yt.unshift(...St)}bt.trList=Yt,bt.id=ft(),bt.trList?.forEach(St=>{St.tdList.forEach(Vt=>{if(delete Vt.valueStartIndex,Vt.linkTdPrevId){const me=this.getTdById(Vt.linkTdPrevId);Vt.valueStartIndex=me?(me.valueStartIndex??0)+me.value.length:0,this.splitTdValueMap.has(Vt.originalId)?this.splitTdValueMap.get(Vt.originalId).push(...Vt.value):me&&this.splitTdValueMap.set(Vt.originalId,[...me.value,...Vt.value])}Vt.value.forEach(me=>this.updateElementTableInfo(me,bt,St,Vt))})}),this.spliceElementList(n,X+1,0,[bt]),this.tableParticle.computeTrHeight(L);const Et=this.tableParticle.getTableHeight(L),Mt=Et*h;L.height=Et,S.height=Mt,S.boundingBoxDescent=Mt}}if(L.pagingId){const Lt=this.position.getPositionContext();if(Lt.isTable){let At=-1,ee=-1,ne=X;for(;ne<n.length;){const Yt=n[ne];if(Yt.pagingId!==L.pagingId)break;const Xt=Yt.trList.findIndex(bt=>bt.id===Lt.trId);if(~Xt){At=ne,ee=Xt;break}ne++}~At&&(Lt.index=At,Lt.trIndex=ee,this.position.setPositionContext(Lt))}}}this.initTableElementIndex(L,X)}else if(L.type===s.ElementType.SEPARATOR){const{separator:{lineWidth:J}}=this.options,lt=L.lineWidth||J;L.width=Q/h,S.width=Q,S.height=lt*h,S.boundingBoxAscent=-W,S.boundingBoxDescent=-W+S.height}else if(L.type===s.ElementType.PAGE_BREAK)L.width=Q/h,S.width=Q,S.height=R;else if(L.type===s.ElementType.RADIO||L.controlComponent===s.ControlComponent.RADIO){const{width:J,height:lt,gap:$}=this.options.radio,j=J+$*(L.controlComponent?1:2);L.width=j,S.width=j*h,S.height=lt*h}else if(L.type===s.ElementType.CHECKBOX||L.controlComponent===s.ControlComponent.CHECKBOX){const{width:J,height:lt,gap:$}=this.options.checkbox,j=J+$*(L.controlComponent?1:2);L.width=j,S.width=j*h,S.height=lt*h}else if(L.type===s.ElementType.MENSTRUAL_HISTORY){const J=this.menstrualHistoryParticle.computeSize(L);L.width=J.width/h,S.width=J.width,S.height=J.height,S.boundingBoxAscent=J.height,S.boundingBoxDescent=0}else if(L.type===s.ElementType.FETAL_HEART_POSITION){const J=this.fetalHeartPositionParticle.computeSize();L.width=J.width/h,S.width=J.width,S.height=J.height,S.boundingBoxAscent=J.height/2,S.boundingBoxDescent=J.height/2}else if(L.type===s.ElementType.TOOTH_POSITION){const J=this.toothPositionParticle.computeSize(L);L.width=J.width/h,S.width=J.width,S.height=J.height,S.boundingBoxAscent=J.height/2,S.boundingBoxDescent=J.height/2}else if(L.type===s.ElementType.TAB)S.width=p*h,S.height=R*h,S.boundingBoxDescent=0,S.boundingBoxAscent=this.textParticle.getBasisWordBoundingBoxAscent(m,m.font);else if(L.type===s.ElementType.BLOCK){if(!L.width)S.width=Q;else{const J=L.width*h;S.width=Math.min(J,Q)}S.height=L.height*h,S.boundingBoxDescent=S.height,S.boundingBoxAscent=0}else if(L.type===s.ElementType.LABEL){const{defaultSize:J,label:{defaultPadding:lt}}=this.options;m.font=this.getElementFont(L);const $=this.textParticle.measureText(m,L);S.width=($.width+lt[1]+lt[3])*h,S.height=(L.size||J)*h,S.boundingBoxDescent=0,S.boundingBoxAscent=(lt[0]+$.actualBoundingBoxAscent)*h}else if(L.type===s.ElementType.MACRO||L.type===s.ElementType.CUSTOM_MACRO||L.type===s.ElementType.REUSABLE_ITEM||L.type===s.ElementType.SUB_TEMPLATE){const{defaultSize:J}=this.options;m.font=this.getElementFont(L);const lt=this.getMode(),$=lt===s.EditorMode.EDIT,j=lt===s.EditorMode.FORM;if(lt===s.EditorMode.READONLY&&L.type!==s.ElementType.SUB_TEMPLATE){const tt=Oo(L),x=m.measureText(tt);S.width=x.width,S.height=(L.size||J)*h,S.boundingBoxDescent=x.actualBoundingBoxDescent,S.boundingBoxAscent=x.actualBoundingBoxAscent}else if($){const tt=L.label||L.value||"";m.font=this.getElementFont(L);const x=m.measureText(tt),Rt=8*h,ht=4*h;S.width=x.width+Rt*2;const mt=x.actualBoundingBoxAscent+x.actualBoundingBoxDescent;S.height=mt+ht*2;const Pt=this.textParticle.measureBasisWord(m,this.getElementFont(L));S.boundingBoxAscent=Pt.actualBoundingBoxAscent*h,S.boundingBoxDescent=Pt.actualBoundingBoxDescent*h}else if(L.type===s.ElementType.CUSTOM_MACRO){const tt=L.macroConfig,x=tt?.value||"";if(j){const Rt=tt?.type||"text",ht=this.textParticle.measureText(m,L),mt=L.label||"";if(Rt==="select"){const Pt=x||`请选择${mt}`,Qt=m.measureText(Pt),Lt=m.measureText("[").width,At=6*h+2*h;S.width=Lt+Qt.width+At+Lt}else{const Pt=x||`请输入${mt}`,Qt=m.measureText(Pt),Lt=m.measureText("[").width;S.width=Lt+Qt.width+Lt}S.height=(L.size||J)*h,S.boundingBoxDescent=ht.actualBoundingBoxDescent*h,S.boundingBoxAscent=ht.actualBoundingBoxAscent*h}else{const Rt=L.label||"",ht=x||`请输入${Rt}`,mt=m.measureText(ht);S.width=mt.width,S.height=(L.size||J)*h,S.boundingBoxDescent=mt.actualBoundingBoxDescent,S.boundingBoxAscent=mt.actualBoundingBoxAscent}}else if(L.type===s.ElementType.REUSABLE_ITEM){const x=L.reusableItemConfig?.value||"",Rt=L.label||"";if(j){const ht=this.textParticle.measureText(m,L),mt=x||`获取 ${Rt}`,Pt=m.measureText(mt),Qt=m.measureText("[").width;S.width=Qt+Pt.width+Qt,S.height=(L.size||J)*h,S.boundingBoxDescent=ht.actualBoundingBoxDescent*h,S.boundingBoxAscent=ht.actualBoundingBoxAscent*h}else{const ht=x||`获取 ${Rt}`,mt=m.measureText(ht);S.width=mt.width,S.height=(L.size||J)*h,S.boundingBoxDescent=mt.actualBoundingBoxDescent,S.boundingBoxAscent=mt.actualBoundingBoxAscent}}else if(L.type===s.ElementType.SUB_TEMPLATE){const tt=L.label||"子模板";if(j){const x=m.measureText(tt),Rt=8*h,ht=4*h,mt=x.actualBoundingBoxAscent+x.actualBoundingBoxDescent;S.width=x.width+Rt*2,S.height=mt+ht*2;const Pt=this.textParticle.measureBasisWord(m,this.getElementFont(L));S.boundingBoxAscent=Pt.actualBoundingBoxAscent*h,S.boundingBoxDescent=Pt.actualBoundingBoxDescent*h}else{const x=m.measureText(tt);S.width=x.width,S.height=(L.size||J)*h,S.boundingBoxDescent=x.actualBoundingBoxDescent,S.boundingBoxAscent=x.actualBoundingBoxAscent}}else{const tt=L.label||"",x=L.value||`获取 ${tt}`,Rt=m.measureText(x);S.width=Rt.width,S.height=(L.size||J)*h,S.boundingBoxDescent=Rt.actualBoundingBoxDescent,S.boundingBoxAscent=Rt.actualBoundingBoxAscent}}else{const J=L.size||R;(L.type===s.ElementType.SUPERSCRIPT||L.type===s.ElementType.SUBSCRIPT)&&(L.actualSize=Math.ceil(J*.6)),S.height=(L.actualSize||J)*h,m.font=this.getElementFont(L);const lt=this.textParticle.measureText(m,L);S.width=lt.width*h,L.letterSpacing&&(S.width+=L.letterSpacing*h);const $=this.textParticle.measureBasisWord(m,L.font);S.boundingBoxAscent=$.actualBoundingBoxAscent*h,S.boundingBoxDescent=$.actualBoundingBoxDescent*h,L.type===s.ElementType.SUPERSCRIPT?S.boundingBoxAscent+=S.height/2:L.type===s.ElementType.SUBSCRIPT&&(S.boundingBoxDescent+=S.height/2)}const w=!ae(L)&&(L.imgDisplay!==s.ImageDisplay.INLINE&&L.type===s.ElementType.IMAGE||L.type===s.ElementType.LATEX)?S.height+W:S.boundingBoxAscent+W,q=W+S.boundingBoxAscent+S.boundingBoxDescent+W,G=Object.assign(L,{metrics:S,left:0,style:this.getElementFont(L,h)});G.control?.minWidth&&(G.controlComponent&&(V+=S.width),G.controlComponent===s.ControlComponent.POSTFIX&&(this.control.setMinWidthControlInfo({row:N,rowElement:G,availableWidth:Q,controlRealWidth:V}),V=0));const H=n[X-1];let z=n[X+1],_=N.width+S.width;if(this.options.wordBreak===s.WordBreak.BREAK_WORD&&(!H?.type||H?.type===s.ElementType.TEXT)&&(!L.type||L.type===s.ElementType.TEXT)){const J=`${H?.value||""}${L.value}`;if(this.WORD_LIKE_REG.test(J)){const{width:$,endElement:j}=this.textParticle.measureWord(m,n,X),tt=$*h;j&&tt<=Q?(_+=tt,z=j):H&&(_+=tt)}const lt=this.textParticle.measurePunctuationWidth(m,z);_+=lt*h}L.listId&&(L.listId!==O?b=0:L.value===K&&!L.listWrap&&b++),O=L.listId;const dt=this.position.setSurroundPosition({pageNo:D,rowElement:G,row:N,rowElementRect:{x:y,y:Y,height:q,width:S.width},availableWidth:Q,surroundElementList:u});y=dt.x,_+=dt.rowIncreaseWidth,y+=S.width;let Ct=!1;if(this.mode===s.EditorMode.FORM&&L.control?.type===s.ControlType.BUTTON&&L.controlComponent===s.ControlComponent.PREFIX&&N.elementList.filter(J=>J.controlId!==L.controlId).length>0){const J=L.controlId;if(n.some($=>$.controlId===`${J}_text`&&$.control?.type===s.ControlType.BUTTON)){let $=0;for(let j=X;j<n.length;j++){const tt=n[j];if(tt.controlId!==J)break;m.font=this.getElementFont(tt);const x=this.textParticle.measureText(m,tt);if($+=x.width*h,tt.controlComponent===s.ControlComponent.POSTFIX)break}for(let j=0;j<n.length;j++){const tt=n[j];if(tt.controlId===`${J}_text`){m.font=this.getElementFont(tt);const x=this.textParticle.measureText(m,tt);$+=x.width*h}}Ct=N.width+$>Q}}const Kt=L.type===s.ElementType.SEPARATOR||L.type===s.ElementType.TABLE||H?.type===s.ElementType.TABLE||H?.type===s.ElementType.BLOCK||L.type===s.ElementType.BLOCK||H?.imgDisplay===s.ImageDisplay.INLINE||L.imgDisplay===s.ImageDisplay.INLINE||H?.listId!==L.listId||H?.areaId!==L.areaId&&!L.area?.hide||L.control?.flexDirection===s.FlexDirection.COLUMN&&(L.controlComponent===s.ControlComponent.CHECKBOX||L.controlComponent===s.ControlComponent.RADIO)&&H?.controlComponent===s.ControlComponent.VALUE||X!==0&&L.value===K&&!L.area?.hide||Ct,ge=_>Q,se=Kt||ge;if(se){const J={width:S.width,height:q,startIndex:X,elementList:[G],ascent:w,rowIndex:N.rowIndex+1,rowFlex:n[X]?.rowFlex||n[X+1]?.rowFlex,isPageBreak:L.type===s.ElementType.PAGE_BREAK};if(G.controlComponent!==s.ControlComponent.PREFIX&&G.control?.indentation===s.ControlIndentation.VALUE_START){const lt=N.elementList.findIndex($=>$.controlId===G.controlId&&$.controlComponent!==s.ControlComponent.PREFIX);if(~lt){const j=this.position.computeRowPosition({row:N,innerWidth:this.getInnerWidth()})[lt];j&&(J.offsetX=j.coordinate.leftTop[0])}}L.listId&&(J.isList=!0,J.offsetX=P.get(L.listId),J.listIndex=b),J.offsetY=!l&&L.area?.top&&L.areaId!==n[X-1]?.areaId?L.area.top*h:0,E.push(J)}else N.width+=S.width,X===0&&(Un(n[1])||n[1]?.areaId)?(N.height=C,N.ascent=C):N.height<q&&(N.height=q,N.ascent=w),N.elementList.push(G);if((se||X===n.length-1)&&(N.isWidthNotEnough=ge&&!Kt,!N.isSurround&&(H?.rowFlex===s.RowFlex.JUSTIFY||H?.rowFlex===s.RowFlex.ALIGNMENT&&N.isWidthNotEnough))){const J=N.elementList[0]?.value===K?N.elementList.slice(1):N.elementList,lt=(Q-N.width)/(J.length-1);for(let $=0;$<J.length-1;$++){const j=J[$];j.metrics.width+=lt}N.width=Q}if(se){y=r,Y+=N.height,i&&!l&&c&&(Y-a+d+q>c||L.type===s.ElementType.PAGE_BREAK)&&(Y=a,Ec(u,D),D+=1),G.left=0;const J=E[E.length-1];y=this.position.setSurroundPosition({pageNo:D,rowElement:G,row:J,rowElementRect:{x:y,y:Y,height:q,width:S.width},availableWidth:Q,surroundElementList:u}).x,y+=S.width}}return E}_collectTextControlValueSet(t){if(this.isDesignMode()||this.mode===s.EditorMode.EDIT)return null;const e=new Set;for(let i=0;i<t.length;i++){const l=t[i];l.controlId&&(l.control?.type===s.ControlType.TEXT||l.control?.type===s.ControlType.TEXTFIELD)&&e.add(l.controlId)}const n=new Set;for(let i=0;i<t.length;i++){const l=t[i];l.controlId&&l.controlComponent===s.ControlComponent.VALUE&&e.has(l.controlId)&&n.add(l.controlId)}return n}_collectTextControlHasContentSet(t){if(this.isDesignMode())return null;const e=new Set;let n=0;for(;n<t.length;){const i=t[n];if(i.controlId&&(i.control?.type===s.ControlType.TEXT||i.control?.type===s.ControlType.TEXTFIELD)&&(i.controlComponent===s.ControlComponent.PREFIX||i.controlComponent===s.ControlComponent.PRE_TEXT||i.controlComponent===s.ControlComponent.PRETEXTFIX||i.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)){const l=i.controlId;let r=!1,a=n+1;for(;a<t.length;){const c=t[a];if(c.controlId===l&&(c.controlComponent===s.ControlComponent.POSTFIX||c.controlComponent===s.ControlComponent.POST_TEXT||c.controlComponent===s.ControlComponent.POSTTEXTFIX||c.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT))break;if(c.controlId===l&&c.controlComponent===s.ControlComponent.VALUE&&(r=!0),c.controlId!==l&&c.controlId){(i.control?.type===s.ControlType.TEXT||c.controlComponent===s.ControlComponent.VALUE)&&(r=!0);const d=c.controlId;for(a++;a<t.length&&t[a].controlId===d;)a++;continue}a++}r&&e.add(l)}n++}return e}_computePageList(){const t=[[]],{pageMode:e,pageNumber:{maxPageNo:n}}=this.options,i=this.getHeight(),l=this.getMainOuterHeight();let r=l,a=0;if(e===s.PageMode.CONTINUITY){t[0]=this.rowList,r+=this.rowList.reduce((R,h)=>R+h.height+(h.offsetY||0),0);const c=this.getPagePixelRatio(),d=this.pageList[0],u=Number(d.style.height.replace("px",""));if(r>u)d.style.height=`${r}px`,d.height=r*c;else{const R=r<i?i:r;d.style.height=`${R}px`,d.height=R*c}this._initPageContext(this.ctxList[0])}else for(let c=0;c<this.rowList.length;c++){const d=this.rowList[c],u=d.offsetY||0;if(d.height+u+r>i||this.rowList[c-1]?.isPageBreak){if(Number.isInteger(n)&&a>=n){this.elementList=this.elementList.slice(0,d.startIndex);break}r=l+d.height+u,t.push([d]),a++}else r+=d.height+u,t[a].push(d)}return t}_drawHighlight(t,e){const{rowList:n,positionList:i,elementList:l}=e,r=this.getDefaultBasicRowMarginHeight(),a=this.getHighlightMarginHeight();for(let c=0;c<n.length;c++){const d=n[c];let u="";for(let R=0;R<d.elementList.length;R++){const h=d.elementList[R],g=d.startIndex+R,T=l[g]===h?g:l.indexOf(h),f=~T?T:g,p=this.control.getControlHighlight(l,f),C=h.highlight||p;if(C){u&&u!==C&&this.highlight.render(t);const I=i[f],{coordinate:{leftTop:[m,P]}}=I,E=h.left||0,M=!h.highlight&&!!p&&this.control.getIsInlineControlBackground(l,f),F=M?P+I.ascent-h.metrics.boundingBoxAscent-a:P+r-a,y=M?h.metrics.boundingBoxAscent+h.metrics.boundingBoxDescent+2*a:d.height-2*r+2*a;this.highlight.recordFillInfo(t,m-E,F,h.metrics.width+E,y,C)}else u&&this.highlight.render(t);u=C}this.highlight.render(t)}}validateNumber(t){return/^\d+$/.test(t)}drawRow(t,e){this._drawHighlight(t,e);const{scale:n,table:{tdPadding:i},group:l,lineBreak:r,whiteSpace:a}=this.options,{rowList:c,pageNo:d,elementList:u,positionList:R,startIndex:h,zone:g,isDrawLineBreak:T=!r.disabled,td:f,isDrawWhiteSpace:p=!a.disabled}=e,C=this.isPrintLikeMode(),I=this.isSelectionDisabled(),{isCrossRowCol:m,tableId:P}=this.range.getRange();let E=h;for(let M=0;M<c.length;M++){const F=c[M],y={x:0,y:0,width:0,height:0};let Y=null;for(let D=0;D<F.elementList.length;D++){const O=F.elementList[D],b=O.metrics,{ascent:V,coordinate:{leftTop:[X,N]}}=R[F.startIndex+D],L=F.elementList[D-1];if(ae(O)&&!this.isDesignMode())this.textParticle.complete();else if(O.type===s.ElementType.IMAGE)this.textParticle.complete(),O.imgDisplay!==s.ImageDisplay.SURROUND&&O.imgDisplay!==s.ImageDisplay.FLOAT_TOP&&O.imgDisplay!==s.ImageDisplay.FLOAT_BOTTOM&&this.imageParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.LATEX)this.textParticle.complete(),this.laTexParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.TABLE)m&&(y.x=X,y.y=N,Y=O),this.tableParticle.render(t,O,X,N);else if(O.type===s.ElementType.HYPERLINK)this.textParticle.complete(),this.hyperlinkParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.LABEL)this.textParticle.complete(),this.labelParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.MACRO||O.type===s.ElementType.CUSTOM_MACRO||O.type===s.ElementType.REUSABLE_ITEM||O.type===s.ElementType.SUB_TEMPLATE)this.textParticle.complete(),this.macroParticle.render(t,O,X,N+V);else if(O.type===s.ElementType.DATE){const w=F.elementList[D+1];(!L||L.dateId!==O.dateId)&&this.textParticle.complete(),this.textParticle.record(t,O,X,N+V),(!w||w.dateId!==O.dateId)&&this.textParticle.complete()}else O.type===s.ElementType.SUPERSCRIPT?(this.textParticle.complete(),this.superscriptParticle.render(t,O,X,N+V)):O.type===s.ElementType.SUBSCRIPT?(this.underline.render(t),this.textParticle.complete(),this.subscriptParticle.render(t,O,X,N+V)):O.type===s.ElementType.SEPARATOR?this.separatorParticle.render(t,O,X,N):O.type===s.ElementType.PAGE_BREAK?this.mode!==s.EditorMode.CLEAN&&!C&&this.pageBreakParticle.render(t,O,X,N):O.type===s.ElementType.CHECKBOX||O.controlComponent===s.ControlComponent.CHECKBOX?(this.textParticle.complete(),this.checkboxParticle.render({ctx:t,x:X,y:N+V,index:D,row:F})):O.type===s.ElementType.RADIO||O.controlComponent===s.ControlComponent.RADIO?(this.textParticle.complete(),this.radioParticle.render({ctx:t,x:X,y:N+V,index:D,row:F})):O.type===s.ElementType.MENSTRUAL_HISTORY?(this.textParticle.complete(),this.menstrualHistoryParticle.render({ctx:t,x:X,y:N+V,index:D,row:F,element:O})):O.type===s.ElementType.FETAL_HEART_POSITION?(this.textParticle.complete(),this.fetalHeartPositionParticle.render({ctx:t,x:X,y:N+V,index:D,row:F,element:O})):O.type===s.ElementType.TOOTH_POSITION?(this.textParticle.complete(),this.toothPositionParticle.render({ctx:t,x:X,y:N+V,index:D,row:F,element:O})):O.type===s.ElementType.TAB?this.textParticle.complete():O.rowFlex===s.RowFlex.ALIGNMENT||O.rowFlex===s.RowFlex.JUSTIFY?(this.textParticle.record(t,O,X,N+V),this.textParticle.complete()):O.type===s.ElementType.BLOCK?(this.textParticle.complete(),this.blockParticle.render(t,d,O,X,N+V)):(O.left&&this.textParticle.complete(),this.textParticle.record(t,O,X,N+V),(O.width||O.letterSpacing||na.test(O.value))&&this.textParticle.complete());if(T&&!C&&this.mode!==s.EditorMode.CLEAN&&!F.isWidthNotEnough&&D===F.elementList.length-1&&this.lineBreakParticle.render(t,O,X,N+F.height/2),p&&ia.test(O.value)&&this.whiteSpaceParticle.render(t,O,X,N+F.height/2),O.control?.border){L?.control?.border&&L.controlId!==O.controlId&&this.control.drawBorder(t);const w=this.getElementRowMargin(O);this.control.recordBorderInfo(X,N+w,O.metrics.width,F.height-2*w)}else L?.control?.border&&this.control.drawBorder(t);if(O.control?.type===s.ControlType.TEXT){const w=O.controlComponent===s.ControlComponent.VALUE,q=O.controlComponent===s.ControlComponent.POSTFIX||O.controlComponent===s.ControlComponent.POST_TEXT,G=!!L&&L.originControlId===O.controlId&&(L.controlComponent===s.ControlComponent.POSTFIX||L.controlComponent===s.ControlComponent.POST_TEXT||L.controlComponent===s.ControlComponent.POSTTEXTFIX||L.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT);O.originControlId&&(O.controlComponent===s.ControlComponent.PREFIX||O.controlComponent===s.ControlComponent.PRE_TEXT||O.controlComponent===s.ControlComponent.PRETEXTFIX||O.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT)&&this.control.drawTextFieldUnderline(t),w&&O.control?.underline&&!O.underline&&((!L||L.controlId!==O.controlId||G||L.controlComponent!==s.ControlComponent.VALUE&&L.controlComponent!==s.ControlComponent.PLACEHOLDER)&&this.control.startTextFieldUnderline(O.controlId,X,N+F.height),this.control.recordTextFieldUnderlineWidth(O.metrics.width)),q&&this.control.drawTextFieldUnderline(t),O.originControlId&&(O.controlComponent===s.ControlComponent.POSTFIX||O.controlComponent===s.ControlComponent.POST_TEXT||O.controlComponent===s.ControlComponent.POSTTEXTFIX||O.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)&&this.control.drawTextFieldUnderline(t)}else L?.control?.type===s.ControlType.TEXT&&this.control.drawTextFieldUnderline(t);if((O.underline||O.control?.underline)&&O.controlComponent!==s.ControlComponent.PLACEHOLDER&&!(O.control?.type===s.ControlType.TEXT&&O.control?.underline&&!O.underline)){L?.type===s.ElementType.SUBSCRIPT&&O.type!==s.ElementType.SUBSCRIPT&&this.underline.render(t);const w=this.getElementRowMargin(O),q=O.left||0;let G=0;O.type===s.ElementType.SUBSCRIPT&&(G=this.subscriptParticle.getOffsetY(O));const H=O.control?.underline?this.options.underlineColor:O.color;this.underline.recordFillInfo(t,X-q,N+F.height-w+G,b.width+q,0,H,O.textDecoration?.style)}else(L?.underline||L?.control?.underline)&&(L?.control?.type===s.ControlType.TEXT&&L?.control?.underline&&!L.underline||this.underline.render(t));if(O.strikeout){if(!O.type||Ce.includes(O.type)){L&&(L.type===s.ElementType.SUBSCRIPT&&O.type!==s.ElementType.SUBSCRIPT||L.type===s.ElementType.SUPERSCRIPT&&O.type!==s.ElementType.SUPERSCRIPT||this.getElementSize(L)!==this.getElementSize(O))&&this.strikeout.render(t);const w=this.textParticle.measureBasisWord(t,this.getElementFont(O));let q=N+V+w.actualBoundingBoxDescent*n-b.height/2;O.type===s.ElementType.SUBSCRIPT?q+=this.subscriptParticle.getOffsetY(O):O.type===s.ElementType.SUPERSCRIPT&&(q+=this.superscriptParticle.getOffsetY(O)),this.strikeout.recordFillInfo(t,X,q,b.width)}}else L?.strikeout&&this.strikeout.render(t);const{zone:W,splitTdRange:S}=this.range.getRange();let{startIndex:U,endIndex:Q}=this.range.getRange(),v=!1;if(f&&S&&[f.originalId,f.id].includes(S.originalId)&&(v=!0,U=S.startIndex-(f.valueStartIndex??0),Q=S.endIndex-(f.valueStartIndex??0)),W===g&&U!==Q&&U<=E&&E<=Q){const w=this.position.getPositionContext();if(!w.isTable&&!O.tdId||w.tdId===O.tdId||v)if(U===E){const q=u[U+1];q&&q.value===K&&(y.x=X+b.width,y.y=N,y.height=F.height,y.width+=this.options.rangeMinWidth)}else{let q=b.width;q===0&&F.elementList.length===1&&(q=this.options.rangeMinWidth),y.width||(y.x=X,y.y=N,y.height=F.height),y.width+=q}}if(!l.disabled&&O.groupIds&&this.group.recordFillInfo(O,X,N,b.width,F.height),E++,O.type===s.ElementType.TABLE&&!ae(O)){const w=O.tdPadding||i,q=w[1]+w[3];for(let G=0;G<O.trList.length;G++){const H=O.trList[G];for(let z=0;z<H.tdList.length;z++){const _=H.tdList[z];this.drawRow(t,{elementList:_.value,positionList:_.positionList,rowList:_.rowList,pageNo:d,startIndex:0,innerWidth:(_.width-q)*n,zone:g,isDrawLineBreak:T,td:_})}}}}if(F.isList&&this.listParticle.drawListStyle(t,F,R[F.startIndex]),this.textParticle.complete(),this.control.drawBorder(t),this.underline.render(t),this.strikeout.render(t),this.group.render(t),!I){if(y.width&&y.height){const{x:D,y:O,width:b,height:V}=y;this.range.render(t,D,O,b,V)}if(m&&Y&&Y.id===P){const{coordinate:{leftTop:[D,O]}}=R[F.startIndex];this.tableParticle.drawRange(t,Y,D,O)}}}this.control.renderQualityMarks(t,e.elementList,e.positionList,e.rowList,e.pageNo,e.zone,e.innerWidth)}_drawFloat(t,e){const{scale:n}=this.options,i=this.position.getFloatPositionList(),{imgDisplays:l,pageNo:r}=e;for(let a=0;a<i.length;a++){const c=i[a],d=c.element;if((r===c.pageNo||c.zone===s.EditorZone.HEADER||c.zone==s.EditorZone.FOOTER)&&d.imgDisplay&&l.includes(d.imgDisplay)&&d.type===s.ElementType.IMAGE){const u=d.imgFloatPosition;this.imageParticle.render(t,d,u.x*n,u.y*n)}}}_clearPage(t){const e=this.ctxList[t],n=this.pageList[t];e.clearRect(0,0,Math.max(n.width,this.getWidth()),Math.max(n.height,this.getHeight())),this.blockParticle.clear()}_drawPage(t){const{elementList:e,positionList:n,rowList:i,pageNo:l}=t,{inactiveAlpha:r,pageMode:a,header:c,footer:d,pageNumber:u,lineNumber:R,pageBorder:h}=this.options,g=this.isPrintLikeMode(),T=this.mode===s.EditorMode.COMPARE?this.options.modeRule[s.EditorMode.COMPARE]:this.options.modeRule[s.EditorMode.PRINT],f=this.getInnerWidth(),p=this.ctxList[l];p.globalAlpha=this.zone.isMainActive()?1:r,this._clearPage(l),(!g||!T?.backgroundDisabled)&&this.background.render(p,l),g||this.area.render(p,l),a!==s.PageMode.CONTINUITY&&this.options.watermark.data&&this.waterMark.render(p,l),g||this.margin.render(p,l),this._drawFloat(p,{pageNo:l,imgDisplays:[s.ImageDisplay.FLOAT_BOTTOM]}),g||this.control.renderHighlightList(p,l);const C=i[0]?.startIndex;this.drawRow(p,{elementList:e,positionList:n,rowList:i,pageNo:l,startIndex:C,innerWidth:f,zone:s.EditorZone.MAIN}),this.getIsPagingMode()&&(c.disabled||this.header.render(p,l),u.disabled||this.pageNumber.render(p,l),d.disabled||this.footer.render(p,l)),this._drawFloat(p,{pageNo:l,imgDisplays:[s.ImageDisplay.FLOAT_TOP,s.ImageDisplay.SURROUND]}),!g&&this.search.getSearchKeyword()&&this.search.render(p,l),this.elementList.length<=1&&!this.elementList[0]?.listId&&this.placeholder.render(p),R.disabled||this.lineNumber.render(p,l),h.disabled||this.pageBorder.render(p),this.badge.render(p,l),this.isGraffitiMode()&&this.graffiti.render(p,l)}_disconnectLazyRender(){this.lazyRenderIntersectionObserver?.disconnect()}_lazyRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();this._disconnectLazyRender(),this.lazyRenderIntersectionObserver=new IntersectionObserver(n=>{n.forEach(i=>{if(i.isIntersecting){const l=Number(i.target.dataset.index);this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[l],pageNo:l})}})}),this.pageList.forEach(n=>{this.lazyRenderIntersectionObserver.observe(n)})}_immediateRender(){const t=this.position.getOriginalMainPositionList(),e=this.getOriginalMainElementList();for(let n=0;n<this.pageRowList.length;n++)this._drawPage({elementList:e,positionList:t,rowList:this.pageRowList[n],pageNo:n})}render(t){const e=re(),n=[],i=(X,N)=>{n.push({label:X,duration:re()-N})};this.renderCount++;const l=this.mode===s.EditorMode.EDIT||this.mode===s.EditorMode.FORM||this.isPrintLikeMode()?tT([...this.getHeaderElementList(),...this.elementList,...this.getFooterElementList()]):null,r=this.applySubTemplateRuntimeState(this.getHeaderElementList(),l)||this.applySubTemplateRuntimeState(this.elementList,l)||this.applySubTemplateRuntimeState(this.getFooterElementList(),l);let{endIndex:a}=this.range.getRange();const{isCrossRowCol:c}=this.range.getRange();if(!c&&~a){const X=this.getElementList(),N=X[a],W=N?.type===s.ElementType.SUB_TEMPLATE&&N.subTemplateExpanded?s.LocationPosition.AFTER:s.LocationPosition.BEFORE,S=wn(X,a,W);S!==a&&!ae(X[S])&&(this.range.setRange(S,S),a=S)}let d;const u=this.position.getPositionContext();if(c)d=this.getOriginalElementList()[u.index];else{const X=~a?a:0,N=this.getElementList();d=Vn(N,X)}const{header:R,footer:h}=this.options,{isSubmitHistory:g=!0,isSetCursor:T=!0,isLazy:f=!0,isInit:p=!1,isSourceHistory:C=!1,isFirstRender:I=!1,isDel:m=!1}=t||{};let{isCompute:P=!0}=t||{};r&&(P=!0);let{curIndex:E}=t||{};const{traceLabel:M}=t||{},F=this.getInnerWidth(),y=this.getIsPagingMode(),Y=this.pageRowList.length;if(P){if(this.splitTdValueMap.clear(),this.tdMap.clear(),this.position.setFloatPositionList([]),y){if(!R.disabled){const H=re();this.header.compute(),i("header.compute",H)}if(!h.disabled){const H=re();this.footer.compute(),i("footer.compute",H)}}const X=this.getMargins(),N=this.getHeight(),L=this.header.getExtraHeight(),W=this.getMainOuterHeight(),S=X[3],U=X[0]+L,Q=Oi(this.elementList),v=re();this.rowList=this.computeRowList({startX:S,startY:U,pageHeight:N,mainOuterHeight:W,isPagingMode:y,innerWidth:F,surroundElementList:Q,elementList:this.elementList}),i("computeRowList",v);const w=re();this.pageRowList=this._computePageList(),i("computePageList",w);const q=re();this.position.computePositionList(),i("computePositionList",q);const G=re();if(this.area.compute(),i("area.compute",G),!this.isPrintLikeMode()){const H=this.search.getSearchKeyword();if(H){const _=re();this.search.compute(H),i("search.compute",_)}const z=re();this.control.computeHighlightList(),i("control.computeHighlightList",z)}if(this.isGraffitiMode()){const H=re();this.graffiti.compute(),i("graffiti.compute",H)}}this.imageObserver.clearAll(),this.cursor.recoveryCursor();for(let X=0;X<this.pageRowList.length;X++)this.pageList[X]||this._createPage(X);const D=this.pageRowList.length,O=this.pageList.length;if(O>D){const X=O-D;this.ctxList.splice(D,X),this.pageList.splice(D,X).forEach(N=>N.remove())}const b=re();if(f&&y?this._lazyRender():this._immediateRender(),i(f&&y?"lazyRender":"immediateRender",b),T){if(P&&d?.tableId){const{index:X}=u,L=this.getOriginalElementList()[X];if(d.tableId!==L?.id){const S=this.findTableChildrenElement(!0,d.tableId,d);S&&u.index!==S.originalIndex&&(u.index=S.originalIndex,u.tableId=S.table.id,u.trIndex=S.trIndex,u.trId=S.tr.id,u.tdIndex=S.tdIndex,u.tdId=S.td.id,E=S.elementIndex,this.position.setPositionContext(u),this.range.setRange(E,E),this.updateTableTool())}const W=this.getElementList();W[a]!==d&&(E=W.findIndex(S=>S===d))}E=this.setCursor(E)}else this.range.getIsSelection()&&this.cursor.focus();if(m){let X;const N=this.position.getPositionContext();X=this.range.getRange().startIndex-1,N.index=X}(g&&!I||E!==void 0&&this.historyManager.isStackEmpty())&&this.submitHistory(E);const V=re();ui(()=>{const X=re();this.range.setRangeStyle(),P&&this.control.getActiveControl()&&this.control.reAwakeControl(),P&&!this.isReadonly()&&this.getMode()!==s.EditorMode.FORM&&u.isTable&&this.getOriginalElementList()[u.index].type===s.ElementType.TABLE&&this.tableTool.render(),P&&!this.zone.isMainActive()&&this.zone.drawZoneIndicator(),Y!==this.pageRowList.length&&(this.listener.pageSizeChange&&this.listener.pageSizeChange(this.pageRowList.length),this.eventBus.isSubscribe("pageSizeChange")&&this.eventBus.emit("pageSizeChange",this.pageRowList.length)),(g||C)&&!p&&(this.listener.contentChange&&this.listener.contentChange(),this.eventBus.isSubscribe("contentChange")&&this.eventBus.emit("contentChange"));const N=re();Ri(this.options,M||"render",N-e,[...n,{label:"nextTick.wait",duration:X-V},{label:"nextTick.callback",duration:N-X}],{isCompute:P,pageCount:this.pageRowList.length})}),T&&this.fixPosition()}fixPosition(t=!1){let e;const n=this.position.getPositionContext();if(n.isTable){const i=this.getElementList(),l=this.range.getRange().startIndex;if(t||l>=i.length){const r=this.getTd(),a=n.index+(t?-1:1),d=this.getOriginalElementList()[a];if(!d?.trList)return;e=l-i.length;for(let u=0;u<d.trList.length;u++){const R=d.trList[u],h=R.tdList.find(g=>t?r?.linkTdPrevId===g.id:r?.id===g.linkTdPrevId);if(h){n.index=a,n.trIndex=u,n.tableId=d.id,n.trId=R.id,n.tdId=h?.id,e=t?h.value.length-1:e+(h.value[0]?.type===s.ElementType.SPLIT_TAG?1:0);break}}if(this.position.setPositionContext(n),this.range.setRange(e,e),this.setCursor(e),e===0)return this.fixPosition(t);this.updateTableTool()}}return e}getInlineBackgroundControlType(t,e){if(e===void 0)return;const n=t[e],i=n?.controlId;return i?n.control?.type?n.control.type:t.find(r=>r.controlId===i&&r.originControlId===n.originControlId&&!!r.control?.type)?.control?.type:void 0}getIsHideInlineBackgroundControlCursor(t,e){if(this.options.mode!==s.EditorMode.EDIT&&this.options.mode!==s.EditorMode.FORM)return!1;const n=e!==void 0?t[e]:void 0;if(n?.controlComponent===s.ControlComponent.POSTFIX||n?.controlComponent===s.ControlComponent.POST_TEXT||n?.controlComponent===s.ControlComponent.POSTTEXTFIX||n?.controlComponent===s.ControlComponent.POSTTEXTFIX_TEXT)return!1;const i=this.getInlineBackgroundControlType(t,e);return!!(i&&[s.ControlType.NUMBER,s.ControlType.SELECT,s.ControlType.DATE].includes(i))}setCursor(t){const e=this.position.getPositionContext(),n=this.position.getPositionList(),i=this.getElementList();if(e.isTable){const{index:r,trIndex:a,tdIndex:c}=e,u=this.getOriginalElementList()[r].trList?.[a].tdList[c].positionList;t===void 0&&u&&(t=u.length-1);const R=u?.[t];this.position.setCursorPosition(R||null)}else t!==void 0&&t>=n.length&&(t=n.length-1),this.position.setCursorPosition(t!==void 0&&t>=0?n[t]:null);let l=!0;if(t!==void 0&&e.isImage&&e.isDirectHit){const r=i[t];if(r&&Ma.includes(r.type)){l=!1;const a=this.position.getCursorPosition();this.previewer.updateResizer(r,a)}}return l&&this.getIsHideInlineBackgroundControlCursor(i,t)&&(l=!1),this.cursor.drawCursor({isShow:l}),t}submitHistory(t){const e=this.position.getPositionContext(),n=Mi(this.elementList),i=Mi(this.header.getElementList()),l=Mi(this.footer.getElementList()),r=ct(this.range.getRange()),a=this.pageNo,c=ct(e),d=this.zone.getZone();this.historyManager.execute(()=>{this.zone.setZone(d),this.setPageNo(a),this.position.setPositionContext(ct(c)),this.header.setElementList(ct(i)),this.footer.setElementList(ct(l)),this.elementList=ct(n),this.range.replaceRange(ct(r)),this.render({curIndex:t,isSubmitHistory:!1,isSourceHistory:!0})})}destroy(){this.macroParticle.clearInlineEditor({isSubmitHistory:!1}),this.container.remove(),this.globalEvent.removeEvent(),this.scrollObserver.removeEvent(),this.selectionObserver.removeEvent()}clearSideEffect(){this.getMacroParticle().clearInlineEditor({isSubmitHistory:!1}),this.getPreviewer().clearResizer(),this.getTableTool().dispose(),this.getHyperlinkParticle().clearHyperlinkPopup(),this.getDateParticle().clearDatePicker()}updateTableTool(){if(this.getMode()===s.EditorMode.FORM){this.getTableTool().dispose();return}if(this.position.getPositionContext().isTable){const t=this.position.getPositionList();t.length&&(this.setPageNo(t[0].pageNo),this.getTableTool().render())}}initTableElementIndex(t,e){t.trList?.forEach((n,i)=>{n.tdList.forEach((l,r)=>{l.tableIndex=e,l.tableId=t.id,l.trIndex=i,l.trId=n.id,l.tdIndex=r,this.tdMap.set(l.id,l)})})}clearElementEffect(t){t.trList?.forEach(e=>{e.minHeight=e.originalMinHeight??e.minHeight,delete e.originalMinHeight,e.tdList.forEach(n=>{delete n.linkTdNextId})})}updateElementTableInfo(t,e,n,i){return t.tableId=e.id,t.trId=n.id,t.tdId=i.id,t}findTableChildrenElement(t,e,n){const i=this.position.getPositionContext(),{index:l}=i,r=this.getOriginalElementList();let a=l;t&&(a=l>r.length?r.length-1:l);for(let c=a;t?c>=0:c<r.length;t?c--:c++){const d=r[c];if(d&&[d.originalId,d.id].includes(e))for(const[u,R]of d.trList.entries())for(const[h,g]of R.tdList.entries()){const T=g.value.findIndex(typeof n=="function"?n:f=>f===n);if(T>=0)return{originalIndex:c,table:d,tr:R,trIndex:u,td:g,tdIndex:h,elementIndex:T}}}}getTdById(t){return this.tdMap.get(t)}getLinkTdPrevHasValue(t){const e=this.getTdById(t);if(e)return e.value.length?e:this.getLinkTdPrevHasValue(e.linkTdPrevId)}getFirstLinkTd(t){const e=this.getTdById(t);return e?.linkTdPrevId?this.getLastLinkTd(e.linkTdPrevId):e}getLastLinkTd(t){const e=this.getTdById(t);return e?.linkTdNextId?this.getLastLinkTd(e.linkTdNextId):e}removeLinkTd(t,e){const n=this.getTdById(e);if(n){if(n.linkTdPrevId){const i=this.getTdById(n.linkTdPrevId);i&&(delete i.linkTdNextId,this.removeLinkTd(t,n.linkTdPrevId))}if(n.linkTdNextId){const i=this.getTdById(n.linkTdNextId);i&&(delete i.linkTdPrevId,this.removeLinkTd(t,n.linkTdNextId))}t[n.tableIndex].trList[n.trIndex].tdList.splice(n.tdIndex,1),this.initTableElementIndex(t[n.tableIndex],n.tableIndex)}}removeLinkTdControl(t,e){const n=this.getTdById(t);if(n){for(let i=0;i<n.value.length;i++)n.value[i].control===e&&(n.value.splice(i,1),i--);n.linkTdNextId&&this.removeLinkTdControl(n.linkTdNextId,e)}}isSplitTd(t,e){return(!!t?.originalId||!!e?.originalId)&&(t?.originalId===e?.originalId||t?.id===e?.originalId||t?.originalId===e?.id)}getSplitTdValues(t){return this.splitTdValueMap.get(t)}removeSplitTdOtherRangeElements(){const{splitTdRange:t}=this.range.getRange();if(!t)return;const{startIndex:e,endIndex:n}=t;let i=this.getTd();if(i)if((i.valueStartIndex??0)>=e){let l=-1;for(;l<0;){const r=this.getTdById(i.linkTdPrevId);if(r){l=e-(r.valueStartIndex??0);const a=Math.max(0,l);this.spliceElementList(r.value,a+1,r.value.length-a-1),i=r}else l=0}}else{let l=1;for(;l>0;){const r=this.getTdById(i.linkTdNextId);if(r){const a=r.valueStartIndex??0;l=n-(a+r.value.length);const c=Math.min(r.value.length,n-a+1);this.spliceElementList(r.value,0,c),i=r}else l=0}}}getTablesByPagingId(t,e,n){const i=[],l=[];if(t[n].pagingId===e){i.push(n),l.push(t[n]);for(let r=n-1;r>=0&&t[r].pagingId===e;r--)l.unshift(t[r]),i.push(r);for(let r=n+1;r<t.length&&t[r].pagingId===e;r++)l.push(t[r]),i.push(r)}return{list:l,startIndex:i.sort()[0]}}}class Wl{executeMode;executeCut;executeCopy;executePaste;executeSelectAll;executeBackspace;executeSetRange;executeReplaceRange;executeSetPositionContext;executeForceUpdate;executeBlur;executeHideCursor;executeUndo;executeRedo;executePainter;executeApplyPainterStyle;executeFormat;executeFont;executeButton;executeEditElementAttribute;executeTriggerControlEditAttribute;executeCopyControl;executePasteControl;executeSize;executeSizeAdd;executeSizeMinus;executeBold;executeItalic;executeUnderline;executeStrikeout;executeSuperscript;executeSubscript;executeColor;executeHighlight;executeTitle;executeList;executeRowFlex;executeVertical;executeRowMargin;executeInsertTable;executeInsertTableTopRow;executeInsertTableBottomRow;executeInsertTableLeftCol;executeInsertTableRightCol;executeDeleteTableRow;executeDeleteTableCol;executeDeleteTable;executeMergeTableCell;executeCancelMergeTableCell;executeSplitVerticalTableCell;executeSplitHorizontalTableCell;executeTableTdVerticalAlign;executeTableBorderType;executeTableBorderColor;executeTableTdBorderType;executeTableTdSlashType;executeTableTdBackgroundColor;executeTableSelectAll;executeTableProperties;executeImage;executeHyperlink;executeDeleteHyperlink;executeCancelHyperlink;executeEditHyperlink;executeSeparator;executePageBreak;executeAddWatermark;executeDeleteWatermark;executeSearch;executeSearchNavigatePre;executeSearchNavigateNext;executeReplace;executePrint;executeReplaceImageElement;executeSaveAsImageElement;executeSetImageCrop;executeSetImageCaption;executeChangeImageDisplay;executePageMode;executePageScale;executePageScaleRecovery;executePageScaleMinus;executePageScaleAdd;executePaperSize;executePaperDirection;executeSetPaperMargin;executeSetMainBadge;executeSetAreaBadge;executeInsertElementList;executeInsertArea;executeSetAreaValue;executeSetAreaProperties;executeLocationArea;executeClearGraffiti;executeAppendElementList;executeUpdateElementById;executeDeleteElementById;executeSetValue;executeRemoveControl;executeTranslate;executeSetLocale;executeLocationCatalog;executeWordTool;executeSetHTML;executeSetGroup;executeDeleteGroup;executeLocationGroup;executeSetZone;executeSetControlValue;executeSetControlValueList;executeSetControlExtension;executeSetControlExtensionList;executeSetControlProperties;executeSetControlPropertiesList;executeSetControlHighlight;executeSetControlQualityMarks;executeSetButtonContent;executeLocationControl;executeInsertControl;executeInsertTextField;executeJumpControl;executeUpdateOptions;executeSetFormModeTrace;executeInsertTitle;executeFocus;executeComputeElementListHeight;getCatalog;getImage;getPageMode;getOptions;getValue;getValueAsync;getAreaValue;getHTML;getText;getWordCount;getCursorPosition;getRemainingContentHeight;getRange;getRangeText;getRangeContext;getRangeRow;getRangeParagraph;getKeywordRangeList;getKeywordContext;getPaperMargin;getSearchNavigateInfo;getLocale;getGroupIds;getControlValue;getButtonContent;getControlList;getContainer;getTitleValue;getPositionContextByEvent;getElementById;getMacroValue;getMacroList;setMacroValue;setMacroValueList;updateMacroProperties;locationMacro;insertSubTemplate;updateSubTemplate;expandSubTemplate;collapseSubTemplate;toggleSubTemplate;constructor(t){this.executeMode=t.mode.bind(t),this.executeCut=t.cut.bind(t),this.executeCopy=t.copy.bind(t),this.executePaste=t.paste.bind(t),this.executeSelectAll=t.selectAll.bind(t),this.executeBackspace=t.backspace.bind(t),this.executeSetRange=t.setRange.bind(t),this.executeReplaceRange=t.replaceRange.bind(t),this.executeSetPositionContext=t.setPositionContext.bind(t),this.executeForceUpdate=t.forceUpdate.bind(t),this.executeBlur=t.blur.bind(t),this.executeHideCursor=t.hideCursor.bind(t),this.executeUndo=t.undo.bind(t),this.executeRedo=t.redo.bind(t),this.executePainter=t.painter.bind(t),this.executeApplyPainterStyle=t.applyPainterStyle.bind(t),this.executeFormat=t.format.bind(t),this.executeFont=t.font.bind(t),this.executeButton=t.buttonText.bind(t),this.executeEditElementAttribute=t.editElementAttribute.bind(t),this.executeTriggerControlEditAttribute=t.triggerControlEditAttribute.bind(t),this.executeCopyControl=t.copyControl.bind(t),this.executePasteControl=t.pasteControl.bind(t),this.executeSize=t.size.bind(t),this.executeSizeAdd=t.sizeAdd.bind(t),this.executeSizeMinus=t.sizeMinus.bind(t),this.executeBold=t.bold.bind(t),this.executeItalic=t.italic.bind(t),this.executeUnderline=t.underline.bind(t),this.executeStrikeout=t.strikeout.bind(t),this.executeSuperscript=t.superscript.bind(t),this.executeSubscript=t.subscript.bind(t),this.executeColor=t.color.bind(t),this.executeHighlight=t.highlight.bind(t),this.executeTitle=t.title.bind(t),this.executeList=t.list.bind(t),this.executeRowFlex=t.rowFlex.bind(t),this.executeVertical=t.vertical.bind(t),this.executeRowMargin=t.rowMargin.bind(t),this.executeInsertTable=t.insertTable.bind(t),this.executeInsertTableTopRow=t.insertTableTopRow.bind(t),this.executeInsertTableBottomRow=t.insertTableBottomRow.bind(t),this.executeInsertTableLeftCol=t.insertTableLeftCol.bind(t),this.executeInsertTableRightCol=t.insertTableRightCol.bind(t),this.executeDeleteTableRow=t.deleteTableRow.bind(t),this.executeDeleteTableCol=t.deleteTableCol.bind(t),this.executeDeleteTable=t.deleteTable.bind(t),this.executeMergeTableCell=t.mergeTableCell.bind(t),this.executeCancelMergeTableCell=t.cancelMergeTableCell.bind(t),this.executeSplitVerticalTableCell=t.splitVerticalTableCell.bind(t),this.executeSplitHorizontalTableCell=t.splitHorizontalTableCell.bind(t),this.executeTableTdVerticalAlign=t.tableTdVerticalAlign.bind(t),this.executeTableBorderType=t.tableBorderType.bind(t),this.executeTableBorderColor=t.tableBorderColor.bind(t),this.executeTableTdBorderType=t.tableTdBorderType.bind(t),this.executeTableTdSlashType=t.tableTdSlashType.bind(t),this.executeTableTdBackgroundColor=t.tableTdBackgroundColor.bind(t),this.executeTableSelectAll=t.tableSelectAll.bind(t),this.executeTableProperties=t.tableProperties.bind(t),this.executeImage=t.image.bind(t),this.executeHyperlink=t.hyperlink.bind(t),this.executeDeleteHyperlink=t.deleteHyperlink.bind(t),this.executeCancelHyperlink=t.cancelHyperlink.bind(t),this.executeEditHyperlink=t.editHyperlink.bind(t),this.executeSeparator=t.separator.bind(t),this.executePageBreak=t.pageBreak.bind(t),this.executeAddWatermark=t.addWatermark.bind(t),this.executeDeleteWatermark=t.deleteWatermark.bind(t),this.executeSearch=t.search.bind(t),this.executeSearchNavigatePre=t.searchNavigatePre.bind(t),this.executeSearchNavigateNext=t.searchNavigateNext.bind(t),this.executeReplace=t.replace.bind(t),this.executePrint=t.print.bind(t),this.executeReplaceImageElement=t.replaceImageElement.bind(t),this.executeSaveAsImageElement=t.saveAsImageElement.bind(t),this.executeSetImageCrop=t.setImageCrop.bind(t),this.executeSetImageCaption=t.setImageCaption.bind(t),this.executeChangeImageDisplay=t.changeImageDisplay.bind(t),this.executePageMode=t.pageMode.bind(t),this.executePageScale=t.pageScale.bind(t),this.executePageScaleRecovery=t.pageScaleRecovery.bind(t),this.executePageScaleMinus=t.pageScaleMinus.bind(t),this.executePageScaleAdd=t.pageScaleAdd.bind(t),this.executePaperSize=t.paperSize.bind(t),this.executePaperDirection=t.paperDirection.bind(t),this.executeSetPaperMargin=t.setPaperMargin.bind(t),this.executeSetMainBadge=t.setMainBadge.bind(t),this.executeSetAreaBadge=t.setAreaBadge.bind(t),this.getAreaValue=t.getAreaValue.bind(t),this.executeInsertArea=t.insertArea.bind(t),this.executeSetAreaValue=t.setAreaValue.bind(t),this.executeSetAreaProperties=t.setAreaProperties.bind(t),this.executeLocationArea=t.locationArea.bind(t),this.executeClearGraffiti=t.clearGraffiti.bind(t),this.executeInsertElementList=t.insertElementList.bind(t),this.executeAppendElementList=t.appendElementList.bind(t),this.executeUpdateElementById=t.updateElementById.bind(t),this.executeDeleteElementById=t.deleteElementById.bind(t),this.executeSetValue=t.setValue.bind(t),this.executeRemoveControl=t.removeControl.bind(t),this.executeTranslate=t.translate.bind(t),this.executeSetLocale=t.setLocale.bind(t),this.executeLocationCatalog=t.locationCatalog.bind(t),this.executeWordTool=t.wordTool.bind(t),this.executeSetHTML=t.setHTML.bind(t),this.executeSetGroup=t.setGroup.bind(t),this.executeDeleteGroup=t.deleteGroup.bind(t),this.executeLocationGroup=t.locationGroup.bind(t),this.executeSetZone=t.setZone.bind(t),this.executeUpdateOptions=t.updateOptions.bind(t),this.executeSetFormModeTrace=t.setFormModeTrace.bind(t),this.executeInsertTitle=t.insertTitle.bind(t),this.executeFocus=t.focus.bind(t),this.executeComputeElementListHeight=t.computeElementListHeight.bind(t),this.getImage=t.getImage.bind(t),this.getPageMode=t.getPageMode.bind(t),this.getOptions=t.getOptions.bind(t),this.getValue=t.getValue.bind(t),this.getValueAsync=t.getValueAsync.bind(t),this.getHTML=t.getHTML.bind(t),this.getText=t.getText.bind(t),this.getWordCount=t.getWordCount.bind(t),this.getCursorPosition=t.getCursorPosition.bind(t),this.getRemainingContentHeight=t.getRemainingContentHeight.bind(t),this.getRange=t.getRange.bind(t),this.getRangeText=t.getRangeText.bind(t),this.getRangeContext=t.getRangeContext.bind(t),this.getRangeRow=t.getRangeRow.bind(t),this.getRangeParagraph=t.getRangeParagraph.bind(t),this.getKeywordRangeList=t.getKeywordRangeList.bind(t),this.getKeywordContext=t.getKeywordContext.bind(t),this.getCatalog=t.getCatalog.bind(t),this.getPaperMargin=t.getPaperMargin.bind(t),this.getSearchNavigateInfo=t.getSearchNavigateInfo.bind(t),this.getLocale=t.getLocale.bind(t),this.getGroupIds=t.getGroupIds.bind(t),this.getContainer=t.getContainer.bind(t),this.getTitleValue=t.getTitleValue.bind(t),this.getPositionContextByEvent=t.getPositionContextByEvent.bind(t),this.getElementById=t.getElementById.bind(t),this.executeSetControlValue=t.setControlValue.bind(t),this.executeSetControlValueList=t.setControlValueList.bind(t),this.executeSetControlExtension=t.setControlExtension.bind(t),this.executeSetControlExtensionList=t.setControlExtensionList.bind(t),this.executeSetControlProperties=t.setControlProperties.bind(t),this.executeSetControlPropertiesList=t.setControlPropertiesList.bind(t),this.executeSetControlHighlight=t.setControlHighlight.bind(t),this.executeSetControlQualityMarks=t.setControlQualityMarks.bind(t),this.executeSetButtonContent=t.setButtonContent.bind(t),this.getControlValue=t.getControlValue.bind(t),this.getButtonContent=t.getButtonContent.bind(t),this.getControlList=t.getControlList.bind(t),this.executeLocationControl=t.locationControl.bind(t),this.executeInsertControl=t.insertControl.bind(t),this.executeInsertTextField=t.insertTextField.bind(t),this.executeJumpControl=t.jumpControl.bind(t),this.getMacroValue=t.getMacroValue.bind(t),this.getMacroList=t.getMacroList.bind(t),this.setMacroValue=t.setMacroValue.bind(t),this.setMacroValueList=t.setMacroValueList.bind(t),this.updateMacroProperties=t.updateMacroProperties.bind(t),this.locationMacro=t.locationMacro.bind(t),this.insertSubTemplate=t.insertSubTemplate.bind(t),this.updateSubTemplate=t.updateSubTemplate.bind(t),this.expandSubTemplate=t.expandSubTemplate.bind(t),this.collapseSubTemplate=t.collapseSubTemplate.bind(t),this.toggleSubTemplate=t.toggleSubTemplate.bind(t)}}function UT(o,t){return o===1125&&t===1593?{size:"a3",width:"297mm",height:"420mm"}:o===794&&t===1123?{size:"a4",width:"210mm",height:"297mm"}:o===565&&t===796?{size:"a5",width:"148mm",height:"210mm"}:{size:"",width:`${o}px`,height:`${t}px`}}function wT(o,t){const{width:e,height:n,direction:i=s.PaperDirection.VERTICAL}=t,l=document.createElement("iframe");l.style.visibility="hidden",l.style.position="absolute",l.style.left="0",l.style.top="0",l.style.width="0",l.style.height="0",l.style.border="none",document.body.append(l);const r=l.contentWindow,a=r.document;a.open();const c=document.createElement("div"),d=UT(e,n);o.forEach(h=>{const g=document.createElement("img");g.style.width=i===s.PaperDirection.HORIZONTAL?d.height:d.width,g.style.height=i===s.PaperDirection.HORIZONTAL?d.width:d.height,g.src=h,c.append(g)});const u=document.createElement("style"),R=`
554
554
  * {
555
555
  margin: 0;
556
556
  padding: 0;
@@ -558,13 +558,13 @@ ${R} `}textToElements(t){const e=[],n=t.split(`
558
558
  @page {
559
559
  margin: 0;
560
560
  size: ${d.size} ${i===s.PaperDirection.HORIZONTAL?"landscape":"portrait"};
561
- }`;u.append(document.createTextNode(R)),setTimeout(()=>{a.write(`${u.outerHTML}${c.innerHTML}`),r.print(),a.close(),window.addEventListener("mouseover",()=>{l?.remove()},{once:!0})})}const ZT=[s.ControlType.TEXT,s.ControlType.TEXTFIELD],Yl=["id","titleId","listId","areaId","hyperlinkId","dateId","labelId","tableId","trId","tdId","pagingId","menstrualHistoryId","fetalHeartPositionId","toothPositionId"];function ei(o,t){for(let e=0;e<o.length;e++){const n=o[e];if(n.type===s.ElementType.CONTROL&&n.controlId===t&&n.control)return ct(n);if(n.control?.value?.length){const i=ei(n.control.value,t);if(i)return i}if(n.valueList?.length){const i=ei(n.valueList,t);if(i)return i}if(n.type===s.ElementType.TABLE&&n.trList?.length)for(let i=0;i<n.trList.length;i++){const l=n.trList[i];for(let r=0;r<l.tdList.length;r++){const a=l.tdList[r],c=ei(a.value,t);if(c)return c}}}return null}function vT(o){const t=new Map,e=new Map,n=a=>a&&(t.has(a)||t.set(a,ft()),t.get(a)),i=a=>a&&(e.has(a)||e.set(a,ft()),e.get(a)),l=a=>{a.controlId&&(a.controlId=n(a.controlId)),a.originControlId&&(a.originControlId=n(a.originControlId));for(let c=0;c<Yl.length;c++){const d=Yl[c],u=a[d];if(typeof u=="string"){const R=a;R[d]=i(u)}}a.groupIds?.length&&(a.groupIds=a.groupIds.map(c=>i(c))),a.valueList?.length&&a.valueList.forEach(l),a.control?.value?.length&&a.control.value.forEach(l),a.trList?.length&&a.trList.forEach(c=>{const d=c;typeof d.id=="string"&&(d.id=i(d.id)),c.tdList.forEach(u=>{const R=u;typeof R.id=="string"&&(R.id=i(R.id)),u.value.forEach(l)})})},r=ct(o);return l(r),r}function QT(o,t,e){let n=-1;const i=!!e;for(let l=0;l<o.length;l++){const r=o[l];if(i?r.controlId===t&&r.originControlId===e:r.controlId===t&&!r.originControlId)n=l;else if(~n)break}return n}class KT{draw;range;position;historyManager;canvasEvent;options;control;workerManager;searchManager;i18n;zone;tableOperate;constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.canvasEvent=t.getCanvasEvent(),this.options=t.getOptions(),this.control=t.getControl(),this.workerManager=t.getWorkerManager(),this.searchManager=t.getSearch(),this.i18n=t.getI18n(),this.zone=t.getZone(),this.tableOperate=t.getTableOperate()}getButtonContentControlId(t){return`${t}_text`}getButtonContentText(t){return t.map(e=>e.value===K?`
562
- `:e.value||"").join("")}syncButtonPlaceholderElements(t,e,n){const i=[];let l=null,r=-1,a=!1;if(t.forEach((u,R)=>{u.controlId!==e||u.control?.type!==s.ControlType.BUTTON||(u.control.placeholder=n,l||=u,u.controlComponent===s.ControlComponent.VALUE&&u.value&&u.value.trim()&&(a=!0),u.controlComponent===s.ControlComponent.PLACEHOLDER&&i.push({element:u,index:R}),r===-1&&u.controlComponent===s.ControlComponent.POSTFIX&&(r=R))}),!l)return;const c=i.length?Math.min(...i.map(u=>u.index)):r;i.length&&i.sort((u,R)=>R.index-u.index).forEach(u=>{t.splice(u.index,1)});const d=yt(n);!d.length||a&&!i.length||c<0||d.forEach((u,R)=>{const h={...$t(l,ue),value:u===`
563
- `?K:u,controlId:e,type:s.ElementType.CONTROL,control:l.control,controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor,hide:a};oe(t,[h],c-1+R,{editorOptions:this.options}),t.splice(c+R,0,h)})}normalizeButtonContentValue(t){return Array.isArray(t)?ct(t):[{value:t}]}getButtonContentResult(t){if(!t?.length)return null;const e=this.getButtonContentText(t);return e.trim()?t.some(i=>!!i.type&&i.type!==s.ElementType.TEXT&&i.type!==s.ElementType.CONTROL)?ct(t):e:null}isSameButtonControlElement(t,e){return!!(t&&t.controlId===e.element.controlId&&(t.originControlId||null)===(e.element.originControlId||null))}getButtonControlRange(t){let e=t.index;for(;e>0&&this.isSameButtonControlElement(t.elementList[e-1],t);)e--;let n=t.index;for(;n+1<t.elementList.length&&this.isSameButtonControlElement(t.elementList[n+1],t);)n++;return{startIndex:e,endIndex:n}}getButtonRenderedValue(t){const{startIndex:e,endIndex:n}=this.getButtonControlRange(t),i=[];for(let l=e;l<=n;l++){const r=t.elementList[l];if(this.isSameButtonControlElement(r,t)&&r.controlComponent===s.ControlComponent.VALUE){const a={value:r.value||""};[...ue,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"].forEach(d=>{const u=r[d];u!==void 0&&(a[d]=u)}),i.push(a)}}return i}getButtonBusinessValue(t){const e=this.getButtonRenderedValue(t);if(e.length)return e;const n=this.getButtonContentControlId(t.element.controlId),i=t.elementList.find(c=>c.controlId===n&&c.control?.type===s.ControlType.BUTTON&&!!c.control.buttonText);if(i?.control?.value?.length)return ct(i.control.value);const l=t.element.control?.value||[],r=this.getButtonContentText(l),a=t.element.control?.buttonLabel||t.element.control?.label||"";return!r.trim()||r===a?[]:ct(l)}findButtonControlContext(t){const e=(i,l)=>{for(let r=0;r<i.length;r++){const a=i[r];if(a.type===s.ElementType.TABLE&&a.trList?.length)for(const c of a.trList)for(const d of c.tdList){const u=e(d.value,l);if(u)return u}if(a.controlId===t&&a.control?.type===s.ControlType.BUTTON&&!a.control.buttonText)return{elementList:i,index:r,element:a,zone:l}}return null},n=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:i,elementList:l}of n){const r=e(l,i);if(r)return r}return null}removeButtonBusinessElements(t){const e=this.getButtonContentControlId(t.element.controlId);for(let n=t.elementList.length-1;n>=0;n--)t.elementList[n].controlId===e&&t.elementList.splice(n,1)}appendButtonContentValue(t,e){if(!t.length)return e;if(!e.length)return t;const n=this.getButtonContentText(t),i=this.getButtonContentText(e);return n.trim()?i.trim()?[{value:n.endsWith(`
561
+ }`;u.append(document.createTextNode(R)),setTimeout(()=>{a.write(`${u.outerHTML}${c.innerHTML}`),r.print(),a.close(),window.addEventListener("mouseover",()=>{l?.remove()},{once:!0})})}const ZT=[s.ControlType.TEXT,s.ControlType.TEXTFIELD],Yl=["id","titleId","listId","areaId","hyperlinkId","dateId","labelId","tableId","trId","tdId","pagingId","menstrualHistoryId","fetalHeartPositionId","toothPositionId"];function ei(o,t){for(let e=0;e<o.length;e++){const n=o[e];if(n.type===s.ElementType.CONTROL&&n.controlId===t&&n.control)return ct(n);if(n.control?.value?.length){const i=ei(n.control.value,t);if(i)return i}if(n.valueList?.length){const i=ei(n.valueList,t);if(i)return i}if(n.type===s.ElementType.TABLE&&n.trList?.length)for(let i=0;i<n.trList.length;i++){const l=n.trList[i];for(let r=0;r<l.tdList.length;r++){const a=l.tdList[r],c=ei(a.value,t);if(c)return c}}}return null}function QT(o){const t=new Map,e=new Map,n=a=>a&&(t.has(a)||t.set(a,ft()),t.get(a)),i=a=>a&&(e.has(a)||e.set(a,ft()),e.get(a)),l=a=>{a.controlId&&(a.controlId=n(a.controlId)),a.originControlId&&(a.originControlId=n(a.originControlId));for(let c=0;c<Yl.length;c++){const d=Yl[c],u=a[d];if(typeof u=="string"){const R=a;R[d]=i(u)}}a.groupIds?.length&&(a.groupIds=a.groupIds.map(c=>i(c))),a.valueList?.length&&a.valueList.forEach(l),a.control?.value?.length&&a.control.value.forEach(l),a.trList?.length&&a.trList.forEach(c=>{const d=c;typeof d.id=="string"&&(d.id=i(d.id)),c.tdList.forEach(u=>{const R=u;typeof R.id=="string"&&(R.id=i(R.id)),u.value.forEach(l)})})},r=ct(o);return l(r),r}function vT(o,t,e){let n=-1;const i=!!e;for(let l=0;l<o.length;l++){const r=o[l];if(i?r.controlId===t&&r.originControlId===e:r.controlId===t&&!r.originControlId)n=l;else if(~n)break}return n}class KT{draw;range;position;historyManager;canvasEvent;options;control;workerManager;searchManager;i18n;zone;tableOperate;constructor(t){this.draw=t,this.range=t.getRange(),this.position=t.getPosition(),this.historyManager=t.getHistoryManager(),this.canvasEvent=t.getCanvasEvent(),this.options=t.getOptions(),this.control=t.getControl(),this.workerManager=t.getWorkerManager(),this.searchManager=t.getSearch(),this.i18n=t.getI18n(),this.zone=t.getZone(),this.tableOperate=t.getTableOperate()}getButtonContentControlId(t){return`${t}_text`}getButtonContentText(t){return t.map(e=>e.value===K?`
562
+ `:e.value||"").join("")}hasButtonContent(t){return!!t?.length}syncButtonPlaceholderElements(t,e,n){const i=[];let l=null,r=-1,a=!1;if(t.forEach((u,R)=>{u.controlId!==e||u.control?.type!==s.ControlType.BUTTON||(u.control.placeholder=n,l||=u,u.controlComponent===s.ControlComponent.VALUE&&(a=!0),u.controlComponent===s.ControlComponent.PLACEHOLDER&&i.push({element:u,index:R}),r===-1&&u.controlComponent===s.ControlComponent.POSTFIX&&(r=R))}),!l)return;const c=i.length?Math.min(...i.map(u=>u.index)):r;i.length&&i.sort((u,R)=>R.index-u.index).forEach(u=>{t.splice(u.index,1)});const d=yt(n);!d.length||a&&!i.length||c<0||d.forEach((u,R)=>{const h={...$t(l,ue),value:u===`
563
+ `?K:u,controlId:e,type:s.ElementType.CONTROL,control:l.control,controlComponent:s.ControlComponent.PLACEHOLDER,color:this.options.control.placeholderColor,hide:a};oe(t,[h],c-1+R,{editorOptions:this.options}),t.splice(c+R,0,h)})}normalizeButtonContentValue(t){return Array.isArray(t)?ct(t):[{value:t}]}getButtonContentResult(t){if(!t?.length)return null;const e=this.getButtonContentText(t);return t.some(i=>!!i.type&&i.type!==s.ElementType.TEXT&&i.type!==s.ElementType.CONTROL)?ct(t):e}isSameButtonControlElement(t,e){return!!(t&&t.controlId===e.element.controlId&&(t.originControlId||null)===(e.element.originControlId||null))}getButtonControlRange(t){let e=t.index;for(;e>0&&this.isSameButtonControlElement(t.elementList[e-1],t);)e--;let n=t.index;for(;n+1<t.elementList.length&&this.isSameButtonControlElement(t.elementList[n+1],t);)n++;return{startIndex:e,endIndex:n}}getButtonRenderedValue(t){const{startIndex:e,endIndex:n}=this.getButtonControlRange(t),i=[];for(let l=e;l<=n;l++){const r=t.elementList[l];if(this.isSameButtonControlElement(r,t)&&r.controlComponent===s.ControlComponent.VALUE){const a={value:r.value||""};[...ue,"color","bold","italic","underline","strikeout","size","font","highlight","textDecoration"].forEach(d=>{const u=r[d];u!==void 0&&(a[d]=u)}),i.push(a)}}return i}getButtonBusinessValue(t){const e=this.getButtonRenderedValue(t);if(e.length)return e;const n=this.getButtonContentControlId(t.element.controlId),i=t.elementList.find(c=>c.controlId===n&&c.control?.type===s.ControlType.BUTTON&&!!c.control.buttonText);if(i?.control?.value?.length)return ct(i.control.value);const l=t.element.control?.value||[],r=this.getButtonContentText(l),a=t.element.control?.buttonLabel||t.element.control?.label||"";return!this.hasButtonContent(l)||r===a?[]:ct(l)}findButtonControlContext(t){const e=(i,l)=>{for(let r=0;r<i.length;r++){const a=i[r];if(a.type===s.ElementType.TABLE&&a.trList?.length)for(const c of a.trList)for(const d of c.tdList){const u=e(d.value,l);if(u)return u}if(a.controlId===t&&a.control?.type===s.ControlType.BUTTON&&!a.control.buttonText)return{elementList:i,index:r,element:a,zone:l}}return null},n=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:i,elementList:l}of n){const r=e(l,i);if(r)return r}return null}removeButtonBusinessElements(t){const e=this.getButtonContentControlId(t.element.controlId);for(let n=t.elementList.length-1;n>=0;n--)t.elementList[n].controlId===e&&t.elementList.splice(n,1)}appendButtonContentValue(t,e){if(!t.length)return e;if(!e.length)return t;const n=this.getButtonContentText(t),i=this.getButtonContentText(e);return n.trim()?i.trim()?[{value:n.endsWith(`
564
564
  `)||i.startsWith(`
565
565
  `)?n:`${n}
566
- `},{value:i}]:t:e}createButtonBusinessElements(t,e){const n=this.getButtonContentText(e);if(!n.trim())return[];const i=t.element.control,l=t.element.controlId,r=$t(t.element,[...pn,...ue,...Nn,...cn]),a=t.element.originControlId,c={...r,controlId:l,originControlId:a,type:s.ElementType.CONTROL,control:i,hide:!1},d=[];return yt(n).forEach(R=>{d.push({...c,value:R===`
567
- `?K:R,controlComponent:s.ControlComponent.VALUE,color:this.options.defaultColor,highlight:void 0})}),d}replaceButtonRenderedValue(t,e,n){const{startIndex:i,endIndex:l}=this.getButtonControlRange(t);let r=i,a=l;for(let g=i;g<=l;g++){const T=t.elementList[g];if(T.controlComponent===s.ControlComponent.PREFIX)r=g;else if(T.controlComponent===s.ControlComponent.POSTFIX){a=g;break}}const c=r+1,d=Math.max(a-r-1,0);t.elementList.splice(c,d,...e);const R=!!this.getButtonContentText(n).trim()?ct(n):null,h=r+e.length+1;for(let g=r;g<=h;g++){const T=t.elementList[g];this.isSameButtonControlElement(T,t)&&T.control&&(T.control.value=R?ct(R):null,T.control.hide=!1)}return e.length?r+e.length:r}getIsRangeInTextField(){const{startIndex:t}=this.range.getRange(),e=this.draw.getElementList(),n=e[t];if(!n)return!1;let i=null;const l=r=>{if(!r)return null;for(let a=t;a>=0;a--){const c=e[a];if(c.controlId===r&&c.control?.type===s.ControlType.TEXTFIELD&&(c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRE_TEXT))return r}return null};return i=l(n.controlId)||l(n.originControlId),!!i}mode(t){this.draw.setMode(t)}async cut(){this.draw.isReadonly()||this.draw.isDisabled()||await this.canvasEvent.cut()}async copy(t){await this.canvasEvent.copy(t)}paste(t){this.draw.isReadonly()||this.draw.isDisabled()||yc(this.canvasEvent,t)}copyControl(t){if(!t)return;const e=wt(this.draw.getElementList(),{editorOptions:this.options}),n=ei(e,t);n&&Mc({element:n})}pasteControl(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=nr();if(!e?.element)return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.draw.getElementList(),r=vT(e.element),a=r.controlId;if(!a)return;const c=Li([r]);if(!c.length)return;jt(c,{isHandleFirstElement:!1,editorOptions:this.options});let d=n,u=n,R=i,h=!1,g;const T=n===i;let f=this.control.getActiveControl();!f&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),f=this.control.getActiveControl());const p=f?.getElement();if(p?.control?.type&&ZT.includes(p.control.type)&&this.control.getIsRangeWithinControl()){h=!0,g=p.controlId;const m=l[n];T&&(m?.control?.type===s.ControlType.TEXTFIELD||m?.control?.type===s.ControlType.TEXT)&&this.control.removePlaceholder(n)}else if(p?.controlId){const m=QT(l,p.controlId,p.originControlId);~m&&(d=m,u=m,R=m)}oe(l,c,d,{isBreakWhenWrap:!0,editorOptions:this.options}),g&&c.forEach(m=>{m.controlId===a&&!m.originControlId&&(m.originControlId=g)});const C=d+1;u!==R&&this.draw.spliceElementList(l,u+1,R-u),this.draw.spliceElementList(l,C,0,c);const I=d+c.length;this.range.setRange(I,I),this.draw.render({curIndex:I}),h&&this.control.emitControlContentChange()}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.draw.getElementList(),{startIndex:n,endIndex:i}=this.range.getRange(),l=n===i;if(l&&e[n].value===K&&n===0)return;l?this.draw.spliceElementList(e,n,1):this.draw.spliceElementList(e,n+1,i-n);const r=l?n-1:n;this.range.setRange(r,r),this.draw.render({curIndex:r})}setRange(t,e,n,i,l,r,a){if(t<0||e<0||e<t)return;this.range.setRange(t,e,n,i,l,r,a);const c=t===e;this.draw.render({curIndex:c?t:void 0,isCompute:!1,isSubmitHistory:!1,isSetCursor:c})}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}setPositionContext(t){const{tableId:e,startTrIndex:n,startTdIndex:i}=t,l=this.draw.getOriginalElementList();if(e){const r=l.findIndex(u=>u.id===e);if(!~r)return;const c=l[r].trList[n],d=c.tdList[i];this.position.setPositionContext({isTable:!0,index:r,trIndex:n,tdIndex:i,tdId:d.id,trId:c.id,tableId:e})}else this.position.setPositionContext({isTable:!1})}forceUpdate(t){const{isSubmitHistory:e=!1}=t||{};this.range.clearRange(),this.draw.render({isSubmitHistory:e,isSetCursor:!1})}blur(){this.range.clearRange(),this.draw.getCursor().recoveryCursor()}hideCursor(){this.draw.getCursor().recoveryCursor()}undo(){this.draw.isReadonly()||this.historyManager.undo()}redo(){this.draw.isReadonly()||this.historyManager.redo()}painter(t){if(!t.isDblclick&&this.draw.getPainterStyle()){this.canvasEvent.clearPainterStyle();return}const e=this.range.getSelection();if(!e)return;const n={};e.forEach(i=>{Xe.forEach(r=>{const a=r;n[a]===void 0&&Reflect.set(n,a,i[a])})}),this.draw.setPainterStyle(n,t)}applyPainterStyle(){this.draw.isReadonly()||this.draw.isDisabled()||this.canvasEvent.applyPainterStyle()}format(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();let l={},r=[];if(i?.length)r=i,l={isSetCursor:!1};else{const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];d?.value===K&&(r.push(d),l={curIndex:a})}r.length&&(r.forEach(a=>{Xe.forEach(c=>{delete a[c]})}),this.draw.render(l))}buttonText(t){if(t)if([...Array.isArray(t.element)?t.element:t.elementList||[t.element]].filter(l=>l.newButtonValue&&l.newButtonValue.length>0).length){const l=t.controlId;this.removeButtonElementsByControlId(l+"_text").then(()=>{setTimeout(()=>{this.insertButtonValue(t)},500)})}else{const l=t.controlId;l&&this.removeButtonElementsByControlId(l+"_text")}}triggerControlEditAttribute(t,e){const n=this.draw.getElementList(),i=[];t&&ps(n,a=>{a.controlId===t&&i.push(a)});const l=i.length?i:e?[e]:[];this.draw.getEventBus().emit("controlEditAttribute",{controlId:t,element:l,targetElement:e||i[0]||null,isControl:!!t})}editElementAttribute(t){const e=this.draw.getElementList();if(t.controlId&&t.type==="button"){const n=Object.prototype.hasOwnProperty.call(t,"action"),i=[];let l="",r="",a=!1,c=!1;e.forEach((f,p)=>{if(f.controlId!==t.controlId||f.control?.type!==s.ControlType.BUTTON)return;const C=f.control.buttonLabel||f.control.label||"";!l&&C&&(l=C);const I=f.control.value||[],m=this.getButtonContentText(I);m.trim()&&m!==C&&(a=!0),m.trim()&&m===C&&(c=!0),f.controlComponent===s.ControlComponent.VALUE&&(i.push(p),r+=f.value===K?`
566
+ `},{value:i}]:t:e}createButtonBusinessElements(t,e){const n=this.getButtonContentText(e),i=t.element.control,l=t.element.controlId,r=$t(t.element,[...pn,...ue,...Nn,...cn]),a=t.element.originControlId,c={...r,controlId:l,originControlId:a,type:s.ElementType.CONTROL,control:i,hide:!1},d=[];return yt(n).forEach(R=>{d.push({...c,value:R===`
567
+ `?K:R,controlComponent:s.ControlComponent.VALUE,color:this.options.defaultColor,highlight:void 0})}),d}replaceButtonRenderedValue(t,e,n){const{startIndex:i,endIndex:l}=this.getButtonControlRange(t);let r=i,a=l;for(let g=i;g<=l;g++){const T=t.elementList[g];if(T.controlComponent===s.ControlComponent.PREFIX)r=g;else if(T.controlComponent===s.ControlComponent.POSTFIX){a=g;break}}const c=r+1,d=Math.max(a-r-1,0);t.elementList.splice(c,d,...e);const R=this.hasButtonContent(n)?ct(n):null,h=r+e.length+1;for(let g=r;g<=h;g++){const T=t.elementList[g];this.isSameButtonControlElement(T,t)&&T.control&&(T.control.value=R?ct(R):null,T.control.hide=!1)}return e.length?r+e.length:r}getIsRangeInTextField(){const{startIndex:t}=this.range.getRange(),e=this.draw.getElementList(),n=e[t];if(!n)return!1;let i=null;const l=r=>{if(!r)return null;for(let a=t;a>=0;a--){const c=e[a];if(c.controlId===r&&c.control?.type===s.ControlType.TEXTFIELD&&(c.controlComponent===s.ControlComponent.PRETEXTFIX||c.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT||c.controlComponent===s.ControlComponent.PREFIX||c.controlComponent===s.ControlComponent.PRE_TEXT))return r}return null};return i=l(n.controlId)||l(n.originControlId),!!i}mode(t){this.draw.setMode(t)}async cut(){this.draw.isReadonly()||this.draw.isDisabled()||await this.canvasEvent.cut()}async copy(t){await this.canvasEvent.copy(t)}paste(t){this.draw.isReadonly()||this.draw.isDisabled()||yc(this.canvasEvent,t)}copyControl(t){if(!t)return;const e=wt(this.draw.getElementList(),{editorOptions:this.options}),n=ei(e,t);n&&Mc({element:n})}pasteControl(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=nr();if(!e?.element)return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.draw.getElementList(),r=QT(e.element),a=r.controlId;if(!a)return;const c=Li([r]);if(!c.length)return;jt(c,{isHandleFirstElement:!1,editorOptions:this.options});let d=n,u=n,R=i,h=!1,g;const T=n===i;let f=this.control.getActiveControl();!f&&this.control.getIsRangeWithinControl()&&(this.control.initControl(),f=this.control.getActiveControl());const p=f?.getElement();if(p?.control?.type&&ZT.includes(p.control.type)&&this.control.getIsRangeWithinControl()){h=!0,g=p.controlId;const m=l[n];T&&(m?.control?.type===s.ControlType.TEXTFIELD||m?.control?.type===s.ControlType.TEXT)&&this.control.removePlaceholder(n)}else if(p?.controlId){const m=vT(l,p.controlId,p.originControlId);~m&&(d=m,u=m,R=m)}oe(l,c,d,{isBreakWhenWrap:!0,editorOptions:this.options}),g&&c.forEach(m=>{m.controlId===a&&!m.originControlId&&(m.originControlId=g)});const C=d+1;u!==R&&this.draw.spliceElementList(l,u+1,R-u),this.draw.spliceElementList(l,C,0,c);const I=d+c.length;this.range.setRange(I,I),this.draw.render({curIndex:I}),h&&this.control.emitControlContentChange()}selectAll(){this.canvasEvent.selectAll()}backspace(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.draw.getElementList(),{startIndex:n,endIndex:i}=this.range.getRange(),l=n===i;if(l&&e[n].value===K&&n===0)return;l?this.draw.spliceElementList(e,n,1):this.draw.spliceElementList(e,n+1,i-n);const r=l?n-1:n;this.range.setRange(r,r),this.draw.render({curIndex:r})}setRange(t,e,n,i,l,r,a){if(t<0||e<0||e<t)return;this.range.setRange(t,e,n,i,l,r,a);const c=t===e;this.draw.render({curIndex:c?t:void 0,isCompute:!1,isSubmitHistory:!1,isSetCursor:c})}replaceRange(t){this.setRange(t.startIndex,t.endIndex,t.tableId,t.startTdIndex,t.endTdIndex,t.startTrIndex,t.endTrIndex)}setPositionContext(t){const{tableId:e,startTrIndex:n,startTdIndex:i}=t,l=this.draw.getOriginalElementList();if(e){const r=l.findIndex(u=>u.id===e);if(!~r)return;const c=l[r].trList[n],d=c.tdList[i];this.position.setPositionContext({isTable:!0,index:r,trIndex:n,tdIndex:i,tdId:d.id,trId:c.id,tableId:e})}else this.position.setPositionContext({isTable:!1})}forceUpdate(t){const{isSubmitHistory:e=!1}=t||{};this.range.clearRange(),this.draw.render({isSubmitHistory:e,isSetCursor:!1})}blur(){this.range.clearRange(),this.draw.getCursor().recoveryCursor()}hideCursor(){this.draw.getCursor().recoveryCursor()}undo(){this.draw.isReadonly()||this.historyManager.undo()}redo(){this.draw.isReadonly()||this.historyManager.redo()}painter(t){if(!t.isDblclick&&this.draw.getPainterStyle()){this.canvasEvent.clearPainterStyle();return}const e=this.range.getSelection();if(!e)return;const n={};e.forEach(i=>{Xe.forEach(r=>{const a=r;n[a]===void 0&&Reflect.set(n,a,i[a])})}),this.draw.setPainterStyle(n,t)}applyPainterStyle(){this.draw.isReadonly()||this.draw.isDisabled()||this.canvasEvent.applyPainterStyle()}format(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();let l={},r=[];if(i?.length)r=i,l={isSetCursor:!1};else{const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];d?.value===K&&(r.push(d),l={curIndex:a})}r.length&&(r.forEach(a=>{Xe.forEach(c=>{delete a[c]})}),this.draw.render(l))}buttonText(t){if(t)if([...Array.isArray(t.element)?t.element:t.elementList||[t.element]].filter(l=>l.newButtonValue&&l.newButtonValue.length>0).length){const l=t.controlId;this.removeButtonElementsByControlId(l+"_text").then(()=>{setTimeout(()=>{this.insertButtonValue(t)},500)})}else{const l=t.controlId;l&&this.removeButtonElementsByControlId(l+"_text")}}triggerControlEditAttribute(t,e){const n=this.draw.getElementList(),i=[];t&&ps(n,a=>{a.controlId===t&&i.push(a)});const l=i.length?i:e?[e]:[];this.draw.getEventBus().emit("controlEditAttribute",{controlId:t,element:l,targetElement:e||i[0]||null,isControl:!!t})}editElementAttribute(t){const e=this.draw.getElementList();if(t.controlId&&t.type==="button"){const n=Object.prototype.hasOwnProperty.call(t,"action"),i=[];let l="",r="",a=!1,c=!1;e.forEach((f,p)=>{if(f.controlId!==t.controlId||f.control?.type!==s.ControlType.BUTTON)return;const C=f.control.buttonLabel||f.control.label||"";!l&&C&&(l=C);const I=f.control.value||[],m=this.getButtonContentText(I);m.trim()&&m!==C&&(a=!0),m.trim()&&m===C&&(c=!0),f.controlComponent===s.ControlComponent.VALUE&&(i.push(p),r+=f.value===K?`
568
568
  `:f.value||"")});const d=!!(!a&&l&&(r===l||c)),u=t.label!==void 0?t.label:l;d&&i.sort((f,p)=>p-f).forEach(f=>{e.splice(f,1)}),e.forEach(f=>{f.controlId===t.controlId&&f.control?.type===s.ControlType.BUTTON&&(t.label!==void 0&&(f.control.buttonLabel=t.label,f.control.label=t.label),f.control.placeholder=u,t.code!==void 0&&(f.control.code=t.code),d&&(f.control.value=null),f.control.hide=!1,n&&(t.action?f.control.action=t.action:delete f.control.action),f.hide=!1)}),this.syncButtonPlaceholderElements(e,t.controlId,u);const{startIndex:R,endIndex:h}=this.range.getRange(),g=!0,T=h;this.draw.render({curIndex:T,isSetCursor:g})}else if(t.controlId){const n=t.controlId;if(e.forEach(l=>{l.controlId===n&&l.control&&(t.label!==void 0&&(l.control.label=t.label),t.placeholder!==void 0&&(l.control.placeholder=t.placeholder),t.code!==void 0&&(l.control.code=t.code),t.value!==void 0&&(l.control.value=t.value?[{value:t.value}]:null),t.valueSets!==void 0&&(l.control.valueSets=t.valueSets),t.dateFormat!==void 0&&(l.control.dateFormat=t.dateFormat),t.numberExclusiveOptions!==void 0&&(l.control.numberExclusiveOptions=t.numberExclusiveOptions),t.underline!==void 0&&(l.control.underline=t.underline))}),t.placeholder!==void 0){const l=t.placeholder,r=[];if(e.forEach((a,c)=>{a.controlId===n&&a.controlComponent==="placeholder"&&r.push({element:a,index:c})}),r.length===l.length)r.forEach((a,c)=>{a.element.value=l[c]===`
569
569
  `?K:l[c]});else if(r.length>0){const a={...r[0].element};r.sort((d,u)=>u.index-d.index).forEach(d=>{e.splice(d.index,1)});const c=Math.min(...r.map(d=>d.index));for(let d=0;d<l.length;d++){const u=l[d]===`
570
- `?K:l[d];e.splice(c+d,0,{...a,value:u})}}}const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isSetCursor:!0})}}delButton(t,e){return new Promise(n=>{for(let i=t.length-1;i>=0;i--)e.some(r=>r.controlId===t[i].controlId&&r.type===t[i].type)&&t.splice(i,1);n(!0)})}editButton(t,e,n){const i=this.draw.getElementList();n=n+1;for(let d=0;d<e.label.length;d++){const u={value:e.label[d],controlId:e.controlId,type:s.ElementType.CONTROL,control:{type:"button",buttonLabel:e.label,code:e.code,value:[{value:e.label}],label:e.label,hide:!1},controlComponent:"value",color:"#fff",highlight:"#1677FF",style:"16px Microsoft YaHei",hide:!1};i.splice(n+d,0,u)}const{startIndex:l,endIndex:r}=this.range.getRange(),a=!0,c=r;this.draw.render({curIndex:c,isSetCursor:a})}removeButtonElementsByControlId(t){return new Promise(e=>{const n=this.draw.getElementList();for(let c=n.length-1;c>=0;c--)n[c].controlId===t&&n.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),e(!0)})}removeByValue(t,e){return new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text"||t[c].type=="buttonText")&&t[c].control?.buttonLabel===e&&t[c].control?.buttonText&&t.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),n(!0)})}insertButtonValue(t){const e=this.draw.getElementList(),n=t.controlId,l=(Array.isArray(t.element)?t.element:t.elementList||[t.element])[0],r=l.newButtonValue,a=l.control.buttonLabel,c=l.control.code;if(!r||!r.length)return;let d=-1;for(let I=0;I<e.length;I++)if(e[I].controlId===n&&e[I].control?.type==="button"){d=I;break}if(d===-1)return;const u=n+"_text",R=[];for(let I=0;I<r.length;I++){const m=r[I];R.push({value:m.value,code:m.code})}const h={type:"button",buttonLabel:a,buttonText:!0,label:a,code:c,value:R,hide:!1},g=[];g.push({value:"[",controlId:u,type:s.ElementType.CONTROL,control:h,controlComponent:s.ControlComponent.PREFIX,color:"#1677FF",hide:!1});for(let I=0;I<r.length;I++){const m=r[I],P=r.length>1?`${I+1}.${m.value}`:m.value,E=yt(P);for(let M=0;M<E.length;M++)g.push({value:E[M],controlId:u,type:s.ElementType.CONTROL,control:h,controlComponent:s.ControlComponent.VALUE,color:"#000",hide:!1});r.length>1&&I<r.length-1&&g.push({value:K,controlId:u,type:s.ElementType.CONTROL,control:h,controlComponent:s.ControlComponent.VALUE,color:"#000",hide:!1})}g.push({value:"]",controlId:u,type:s.ElementType.CONTROL,control:h,controlComponent:s.ControlComponent.POSTFIX,color:"#1677FF",hide:!1});for(let I=0;I<g.length;I++)e.splice(d+I,0,g[I]);const{startIndex:T,endIndex:f}=this.range.getRange(),p=!0,C=f;this.draw.render({curIndex:C,isSetCursor:p})}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{r.font=t}),this.draw.render({isSetCursor:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({font:t}),d?.value===K?d.font=t:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:l,maxSize:r,defaultSize:a}=this.options;if(t<l||t>r)return;let c={},d=[];const u=this.range.getTextLikeSelectionElementList();if(u?.length)d=u,c={isSetCursor:!1};else{const{endIndex:h}=this.range.getRange(),T=this.draw.getElementList()[h];this.range.setDefaultStyle({size:t}),T?.value===K?(d.push(T),c={curIndex:h}):this.draw.render({curIndex:h,isCompute:!1,isSubmitHistory:!1})}if(!d.length)return;let R=!1;d.forEach(h=>{!h.size&&t===a||h.size&&h.size===t||(h.size=t,R=!0)}),R&&this.draw.render(c)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,maxSize:l}=this.options,r=this.range.getTextLikeSelectionElementList();let a={},c=[];if(r?.length)c=r,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange(),h=this.draw.getElementList()[u],T=this.range.getDefaultStyle()?.size||h.size||i;this.range.setDefaultStyle({size:T+2>l?l:T+2}),h?.value===K?(c.push(h),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(u=>{u.size||(u.size=i),!(u.size>=l)&&(u.size+2>l?u.size=l:u.size+=2,d=!0)}),d&&this.draw.render(a)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,minSize:l}=this.options,r=this.range.getTextLikeSelectionElementList();let a={},c=[];if(r?.length)c=r,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange(),h=this.draw.getElementList()[u],T=this.range.getDefaultStyle()?.size||h.size||i;this.range.setDefaultStyle({size:T-2<l?l:T-2}),h?.value===K?(c.push(h),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(u=>{u.size||(u.size=i),!(u.size<=l)&&(u.size-2<l?u.size=l:u.size-=2,d=!0)}),d&&this.draw.render(a)}bold(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.bold);i.forEach(r=>{r.bold=!!~l}),this.draw.render({isSetCursor:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({bold:c.bold?!1:!this.range.getDefaultStyle()?.bold}),c?.value===K?c.bold=!c.bold:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}italic(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.italic);i.forEach(r=>{r.italic=!!~l}),this.draw.render({isSetCursor:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({italic:c.italic?!1:!this.range.getDefaultStyle()?.italic}),c?.value===K?c.italic=!c.italic:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}underline(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length){const r=l.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!ha(a.textDecoration,t));l.forEach(a=>{a.underline=r,r&&t?a.textDecoration=t:delete a.textDecoration}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({underline:d?.underline?!1:!this.range.getDefaultStyle()?.underline}),d?.value===K?d.underline=!d.underline:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}strikeout(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.strikeout);i.forEach(r=>{r.strikeout=!!~l}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({strikeout:c.strikeout?!1:!this.range.getDefaultStyle()?.strikeout}),c?.value===K?c.strikeout=!c.strikeout:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const l=i.findIndex(r=>r.type===s.ElementType.SUPERSCRIPT);i.forEach(r=>{~l?r.type===s.ElementType.SUPERSCRIPT&&(r.type=s.ElementType.TEXT,delete r.actualSize):(!r.type||r.type===s.ElementType.TEXT||r.type===s.ElementType.SUBSCRIPT)&&(r.type=s.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const l=i.findIndex(r=>r.type===s.ElementType.SUBSCRIPT);i.forEach(r=>{~l?r.type===s.ElementType.SUBSCRIPT&&(r.type=s.ElementType.TEXT,delete r.actualSize):(!r.type||r.type===s.ElementType.TEXT||r.type===s.ElementType.SUPERSCRIPT)&&(r.type=s.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{t?r.color=t:delete r.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({color:t||void 0}),d?.value===K?t?d.color=t:delete d.color:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{t?r.highlight=t:delete r.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({highlight:t||void 0}),d?.value===K?t?d.highlight=t:delete d.highlight:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.draw.getElementList(),r=n===i?this.range.getRangeParagraphElementList():l.slice(n+1,i+1);if(!r||!r.length)return;const a=ft(),c=this.draw.getOptions().title;r.forEach(R=>{!R.type&&R.value===K||(t?(R.level=t,R.titleId=a,Xo(R)&&(R.size=c[Zs[t]],R.bold=!0)):R.titleId&&(delete R.titleId,delete R.title,delete R.level,delete R.size,delete R.bold))});const d=n===i,u=d?i:n;this.draw.render({curIndex:u,isSetCursor:d})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.rowFlex=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}vertical(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.vertical=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.rowMargin=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}insertTable(t,e){this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl()||this.tableOperate.insertTable(t,e)}insertTableTopRow(){this.draw.isReadonly()||this.tableOperate.insertTableTopRow()}insertTableBottomRow(){this.draw.isReadonly()||this.tableOperate.insertTableBottomRow()}insertTableLeftCol(){this.draw.isReadonly()||this.tableOperate.insertTableLeftCol()}insertTableRightCol(){this.draw.isReadonly()||this.tableOperate.insertTableRightCol()}deleteTableRow(){this.draw.isReadonly()||this.tableOperate.deleteTableRow()}deleteTableCol(){this.draw.isReadonly()||this.tableOperate.deleteTableCol()}deleteTable(){this.draw.isReadonly()||this.tableOperate.deleteTable()}mergeTableCell(){this.draw.isReadonly()||this.tableOperate.mergeTableCell()}cancelMergeTableCell(){this.draw.isReadonly()||this.tableOperate.cancelMergeTableCell()}splitVerticalTableCell(){this.draw.isReadonly()||this.tableOperate.splitVerticalTableCell()}splitHorizontalTableCell(){this.draw.isReadonly()||this.tableOperate.splitHorizontalTableCell()}tableTdVerticalAlign(t){this.draw.isReadonly()||this.tableOperate.tableTdVerticalAlign(t)}tableBorderType(t){this.draw.isReadonly()||this.tableOperate.tableBorderType(t)}tableBorderColor(t){this.draw.isReadonly()||this.tableOperate.tableBorderColor(t)}tableTdBorderType(t){this.draw.isReadonly()||this.tableOperate.tableTdBorderType(t)}tableTdSlashType(t){this.draw.isReadonly()||this.tableOperate.tableTdSlashType(t)}tableTdBackgroundColor(t){this.draw.isReadonly()||this.tableOperate.tableTdBackgroundColor(t)}tableSelectAll(){this.tableOperate.tableSelectAll()}tableProperties(){this.draw.isReadonly()||this.tableOperate.tableProperties()}hyperlink(t){const{valueList:e,url:n,hyperlinkId:i}=t;if(!n||!e?.length||this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:a,endIndex:c}=this.range.getRange();!~a&&!~c||this.insertElementList([{type:s.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:i||ft()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=this.draw.getElementList(),r=l[n];if(r.type!==s.ElementType.HYPERLINK)return null;let a=n;for(;a>0;){if(l[a].hyperlinkId!==r.hyperlinkId){t=a+1;break}a--}let c=n+1;for(;c<l.length;){if(l[c].hyperlinkId!==r.hyperlinkId){e=c-1;break}c++}return c===l.length&&(e=c-1),!~t||!~e?null:[t,e]}deleteHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,l]=e;this.draw.spliceElementList(n,i,l-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const r=i-1;this.range.setRange(r,r),this.draw.render({curIndex:r})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,l]=e;for(let a=i;a<=l;a++){const c=n[a];delete c.type,delete c.url,delete c.hyperlinkId,delete c.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const i=this.draw.getElementList(),[l,r]=n;for(let c=l;c<=r;c++){const d=i[c];d.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:a}=this.range.getRange();this.draw.render({curIndex:a,isCompute:!1})}separator(t,e){if(this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl())return;const{startIndex:l,endIndex:r}=this.range.getRange();if(!~l&&!~r)return;const a=this.draw.getElementList();let c=-1;const d=a[r+1];if(d&&d.type===s.ElementType.SEPARATOR){if(d.dashArray&&d.dashArray.join()===t.join())return;c=r,Object.assign(d,{dashArray:t,...e})}else{const u={value:Ps,type:s.ElementType.SEPARATOR,dashArray:t,...e};oe(a,[u],l,{editorOptions:this.options}),l!==0&&a[l].value===K?(this.draw.spliceElementList(a,l,1,[u]),c=l-1):(this.draw.spliceElementList(a,l+1,0,[u]),c=l)}this.range.setRange(c,c),this.draw.render({curIndex:c})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:s.ElementType.PAGE_BREAK,value:Ps}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:i,size:l,opacity:r,font:a,gap:c}=Ii;n.watermark.data=t.data,n.watermark.type=t.type||s.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||i,n.watermark.opacity=t.opacity||r,n.watermark.size=t.size||l,n.watermark.font=t.font||a,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||c,this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1})}deleteWatermark(){if(this.draw.isReadonly())return;const e=this.draw.getOptions();e.watermark&&e.watermark.data&&(e.watermark={...Ii},this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=t.id||ft();return this.insertElementList([{...t,id:l,type:s.ElementType.IMAGE}]),l}search(t,e){this.searchManager.setSearchKeyword(t,e),this.draw.render({isSubmitHistory:!1})}searchNavigatePre(){this.searchManager.searchNavigatePre()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}searchNavigateNext(){this.searchManager.searchNavigateNext()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}getSearchNavigateInfo(){return this.searchManager.getSearchNavigateInfo()}replace(t,e){this.draw.getSearch().replace(t,e)}async print(){const{scale:t,printPixelRatio:e,paperDirection:n,width:i,height:l}=this.options;t!==1&&this.draw.setPageScale(1);const r=await this.draw.getDataURL({pixelRatio:e,mode:s.EditorMode.PRINT});wT(r,{width:i,height:l,direction:n}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==s.ElementType.IMAGE||(i.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==s.ElementType.IMAGE||Ss(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==s.ElementType.IMAGE||(i.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];i?.type===s.ElementType.IMAGE&&(i.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:i}=this.range.getRange();if(e===s.ImageDisplay.SURROUND||e===s.ImageDisplay.FLOAT_TOP||e===s.ImageDisplay.FLOAT_BOTTOM){const l=this.position.getPositionList(),{pageNo:r,coordinate:{leftTop:a}}=l[n];t.imgFloatPosition={pageNo:r,x:a[0],y:a[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:i})}getImage(t){return this.draw.getDataURL(t)}getPageMode(){return this.options}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getValueAsync(t){return this.draw.getWorkerManager().getValue(t)}getAreaValue(t){return this.draw.getArea().getAreaValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:Wn(e,t).innerHTML,main:Wn(n,t).innerHTML,footer:Wn(i,t).innerHTML}}getText(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:In(e,t),main:In(n,t),footer:In(i,t)}}getWordCount(){return this.workerManager.getWordCount()}getCursorPosition(){return this.position.getCursorPosition()}getRemainingContentHeight(){if(!this.draw.getIsPagingMode())return 0;const t=this.draw.getPageRowList(),e=t.length-1,i=(t[e]||[]).reduce((c,d)=>c+d.height+(d.offsetY||0),0),l=this.draw.getHeight(),r=this.draw.getMainOuterHeight(),a=l-(r+i);return a>0?a:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=ct(t);jt(n,{isHandleFirstElement:!1,editorOptions:this.options});const i=Oi(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:i}).reduce((r,a)=>r+a.height+(a.offsetY||0),0)}getRange(){return ct(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const i=e===n,l=this.range.toString(),r=wt(this.range.getSelectionElementList()||[]),a=this.draw.getElementList(),c=dn(a[i?e:e+1],{extraPickAttrs:["id","controlComponent"]}),d=dn(a[n],{extraPickAttrs:["id","controlComponent"]}),u=this.draw.getRowList(),R=this.position.getPositionList(),h=R[e],g=R[n],T=h?.pageNo,f=g?.pageNo,p=h?.rowIndex,C=g?.rowIndex,I=u[p],m=u[C];let P=0,E=0;this.draw.getCursor().getHitLineStartIndex()||(P=I?.elementList[0]?.value===K?h?.index-I?.startIndex:h?.index-I?.startIndex+1),h===g?E=P:E=m.elementList[0]?.value===K?g.index-m.startIndex:g.index-m.startIndex+1;const M=[],F=this.draw.getOriginalHeight(),y=this.draw.getOriginalPageGap(),Y=this.position.getSelectionPositionList();if(Y){let U=null,v=0,Q=null;for(let w=0;w<Y.length;w++){const{rowNo:q,pageNo:G,coordinate:{leftTop:H,rightTop:z},lineHeight:_}=Y[w];U===null||U!==q?(Q&&M.push(Q),Q={x:H[0],y:H[1]+G*(F+y),width:z[0]-H[0],height:_},U=q,v=H[0]):Q.width=z[0]-v,w===Y.length-1&&Q&&M.push(Q)}}else{const v=this.position.getPositionList()[n],{coordinate:{rightTop:Q},pageNo:w,lineHeight:q}=v;M.push({x:Q[0],y:Q[1]+w*(F+y),width:0,height:q})}const D=this.draw.getZone().getZone(),{isTable:O,trIndex:b,tdIndex:V,index:X}=this.position.getPositionContext();let N=null;if(O){const v=this.draw.getOriginalElementList()[X]||null;v&&(N=wt([v])[0])}let L=null,W=null,S=e-1;for(;S>0;){const U=a[S],v=a[S-1];if(U.titleId&&U.titleId!==v?.titleId){L=U.titleId,W=R[S].pageNo;break}S--}return ct({isCollapsed:i,startElement:c,endElement:d,startPageNo:T,endPageNo:f,startRowNo:p,endRowNo:C,startColNo:P,endColNo:E,rangeRects:M,zone:D,isTable:O,trIndex:b??null,tdIndex:V??null,tableElement:N,selectionText:l,selectionElementList:r,titleId:L,titleStartPageNo:W})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?wt(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?wt(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],i=this.position.getOriginalMainPositionList(),l=this.draw.getOriginalMainElementList();for(let r=0;r<e.length;r++){const a=e[r],{startIndex:c,endIndex:d,tableId:u,startTrIndex:R,startTdIndex:h}=a;let g=i;if(a.tableId){const p=l.find(C=>C.id===u);p&&(g=p.trList?.[R]?.tdList?.[h]?.positionList||[])}const T=ct(g[c]),f=ct(g[d]);n.push({range:a,startPosition:T,endPosition:f})}return n}pageMode(t){this.draw.setPageMode(t)}pageScale(t){t!==this.options.scale&&this.draw.setPageScale(t)}pageScaleRecovery(){const{scale:t}=this.options;t!==1&&this.draw.setPageScale(1)}pageScaleMinus(){const{scale:t}=this.options,e=t*10-1;e>=5&&this.draw.setPageScale(e/10)}pageScaleAdd(){const{scale:t}=this.options,e=t*10+1;e<=30&&this.draw.setPageScale(e/10)}paperSize(t,e){this.draw.setPaperSize(t,e)}paperDirection(t){this.draw.setPaperDirection(t)}getPaperMargin(){return this.options.margins}setPaperMargin(t){return this.draw.setPaperMargin(t)}setMainBadge(t){this.draw.getBadge().setMainBadge(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}setAreaBadge(t){this.draw.getBadge().setAreaBadgeMap(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}insertElementList(t,e={}){if(!t.length||this.draw.isReadonly()||this.draw.isDisabled())return;const{isReplace:i=!0,ignoreContextKeys:l}=e;i||this.range.shrinkRange(),console.log(t,"payload");const r=ct(t),{startIndex:a}=this.range.getRange(),c=this.draw.getElementList();oe(c,r,a,{ignoreContextKeys:l,isBreakWhenWrap:!0,editorOptions:this.options}),console.log(r,"cloneElementList"),this.draw.insertElementList(r,e),setTimeout(()=>{console.log(c,"elementList")},500)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(ct(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const i=[];function l(a,c=!1){let d=0;for(;d<a.length;){const u=a[d];if(d++,u.type===s.ElementType.TABLE){const R=u.trList;for(let h=0;h<R.length;h++){const g=R[h];for(let T=0;T<g.tdList.length;T++){const f=g.tdList[T];l(f.value,c)}}}u.type===s.ElementType.CONTROL&&u.control?.value&&l(u.control.value,!0),(e&&u.id===e||n&&u.conceptId===n)&&i.push({elementList:a,index:d-1,isInsideControl:c})}}const r=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);if(i.length){for(let a=0;a<i.length;a++){const{elementList:c,index:d,isInsideControl:u}=i[a],R=c[d],h=R.controlId&&R.controlComponent===s.ControlComponent.VALUE;if(u||h){if(Object.assign(R,t.properties),R.id){const g=cc(R.id);g&&Object.assign(g,t.properties)}}else{const g=wt([{...R,...t.properties}],{extraPickAttrs:["id"]});g.length>0&&g[0]?(an(cn,R,g[0]),jt(g,{isHandleFirstElement:!1,editorOptions:this.options}),c[d]=g[0]):Object.assign(R,t.properties)}}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let i=!1;function l(a){let c=0;for(;c<a.length;){const d=a[c];if(d.type===s.ElementType.TABLE){const u=d.trList;for(let R=0;R<u.length;R++){const h=u[R];for(let g=0;g<h.tdList.length;g++){const T=h.tdList[g];l(T.value)}}}d.type===s.ElementType.CONTROL&&d.control?.value&&l(d.control.value),(e&&d.id===e||n&&d.conceptId===n)&&(i=!0,a.splice(c,1),c--),c++}}const r=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);i&&this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,i=[];if(!e&&!n)return i;const l=a=>{let c=0;for(;c<a.length;){const d=a[c];if(c++,d.type===s.ElementType.TABLE){const u=d.trList;for(let R=0;R<u.length;R++){const h=u[R];for(let g=0;g<h.tdList.length;g++){const T=h.tdList[g];l(T.value)}}}e&&d.id!==e||n&&d.conceptId!==n||i.push(d)}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);return wt(i,{extraPickAttrs:["id"]})}setValue(t,e){this.draw.setValue(t,e)}removeControl(t){if(t?.id||t?.conceptId){const{id:e,conceptId:n}=t;let i=!1;const l=a=>{let c=a.length-1;for(;c>=0;){const d=a[c];if(d.type===s.ElementType.TABLE){const u=d.trList;for(let R=0;R<u.length;R++){const h=u[R];for(let g=0;g<h.tdList.length;g++){const T=h.tdList[g];l(T.value)}}}c--,!(!d.control||e&&d.controlId!==e||n&&d.control.conceptId!==n)&&(i=!0,a.splice(c+1,1))}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);i&&this.draw.render({isSetCursor:!1})}else{const{startIndex:e,endIndex:n}=this.range.getRange();if(e!==n||!this.draw.getElementList()[e].controlId)return;const a=this.draw.getControl().removeControl(e);if(a===null)return;this.range.setRange(a,a),this.draw.render({curIndex:a})}}translate(t){return this.i18n.t(t)}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){const e=this.draw.getOriginalElementList();function n(C,I){for(let m=0;m<C.length;m++){const P=C[m];if(P.type===s.ElementType.TABLE){const E=P.trList;for(let M=0;M<E.length;M++){const F=E[M];for(let y=0;y<F.tdList.length;y++){const Y=F.tdList[y],D=n(Y.value,I);if(D)return{...D,isTable:!0,index:m,trIndex:M,tdIndex:y,tdId:Y.id,trId:F.id,tableId:P.id}}}}if(P.titleId===I){let E=m;for(;E<C.length;){if(C[E+1]?.titleId!==I)return{isTable:!1,startIndex:E,endIndex:E};E++}}}return null}const i=n(e,t);if(!i)return;const{isTable:l,index:r,startTdIndex:a,endTdIndex:c,startTrIndex:d,endTrIndex:u,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f,endIndex:p}=i;this.position.setPositionContext({isTable:l,index:r,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f}),this.range.setRange(p,p,f,a,c,d,u),this.draw.render({curIndex:p,isCompute:!1,isSubmitHistory:!1})}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let n=0;n<t.length;n++)if(t[n].value===K)for(;n+1<t.length;){const l=t[n+1];if(l.value!==K&&l.value!==oi)break;t.splice(n+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const n=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:n})}}setHTML(t){const{header:e,main:n,footer:i}=t,l=this.draw.getOriginalInnerWidth(),r=a=>a!==void 0?Yn(a,{innerWidth:l}):void 0;this.setValue({header:r(e),main:r(n),footer:r(i)})}setGroup(){return this.draw.isReadonly()?null:this.draw.getGroup().setGroup()}deleteGroup(t){this.draw.isReadonly()||this.draw.getGroup().deleteGroup(t)}getGroupIds(){return this.draw.getWorkerManager().getGroupIds()}locationGroup(t){const e=this.draw.getOriginalMainElementList(),n=this.draw.getGroup().getContextByGroupId(e,t);if(!n)return;const{isTable:i,index:l,trIndex:r,tdIndex:a,tdId:c,trId:d,tableId:u,endIndex:R}=n;this.position.setPositionContext({isTable:i,index:l,trIndex:r,tdIndex:a,tdId:c,trId:d,tableId:u}),this.range.setRange(R,R),this.draw.render({curIndex:R,isCompute:!1,isSubmitHistory:!1})}setZone(t){this.draw.getZone().setZone(t)}getControlValue(t){return this.draw.getControl().getValueById(t)}getButtonContent(t){const{controlId:e}=t;if(!e)return null;const n=this.findButtonControlContext(e);return n?this.getButtonContentResult(this.getButtonBusinessValue(n)):null}setButtonContent(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{controlId:n,mode:i,isSubmitHistory:l=!0}=t;if(!n)return;const r=this.findButtonControlContext(n);if(!r)return;const a=this.getButtonBusinessValue(r),c=this.normalizeButtonContentValue(t.value),d=i==="append"?this.appendButtonContentValue(a,c):c;this.removeButtonBusinessElements(r);const u=this.findButtonControlContext(n);if(!u)return;const R=this.createButtonBusinessElements(u,d),h=this.replaceButtonRenderedValue(u,R,d);this.syncButtonPlaceholderElements(u.elementList,n,u.element.control?.placeholder||u.element.control?.buttonLabel||u.element.control?.label||""),l||this.historyManager.recovery(),this.draw.render({curIndex:h,isSubmitHistory:l,isSetCursor:!0})}setControlValue(t){this.draw.getControl().setValueListById([t])}setControlValueList(t){this.draw.getControl().setValueListById(t)}setControlExtension(t){this.draw.getControl().setExtensionListById([t])}setControlExtensionList(t){this.draw.getControl().setExtensionListById(t)}setControlProperties(t){this.draw.getControl().setPropertiesListById([t])}setControlPropertiesList(t){this.draw.getControl().setPropertiesListById(t)}setControlHighlight(t){this.draw.getControl().setHighlightList(t),this.draw.render({isSubmitHistory:!1})}setControlQualityMarks(t){this.draw.getControl().setQualityMarks(t),this.draw.render({isSetCursor:!1,isSubmitHistory:!1})}updateOptions(t){const e=Lo(t);Object.entries(e).forEach(([n,i])=>{Reflect.set(this.options,n,i)}),this.forceUpdate()}setFormModeTrace(t){Object.assign(this.options.modeRule.form,t),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){if(!t)return;function n(r,a,c){let d=0;for(;d<r.length;){const u=r[d];if(d++,u.type===s.ElementType.TABLE){const h=u.trList;for(let g=0;g<h.length;g++){const T=h[g];for(let f=0;f<T.tdList.length;f++){const p=T.tdList[f],C=n(p.value,a,c);if(C)return{...C,positionContext:{isTable:!0,index:d-1,trIndex:g,tdIndex:f,tdId:p.id,trId:T.id,tableId:u.id}}}}}if(!c(u))continue;let R=d-1;if(e?.position===s.LocationPosition.OUTER_AFTER){if(!(u.controlComponent===s.ControlComponent.POSTFIX&&r[d+1]?.controlComponent!==s.ControlComponent.POST_TEXT))continue}else if(e?.position===s.LocationPosition.OUTER_BEFORE)R-=1;else if(e?.position===s.LocationPosition.AFTER){if(R-=1,u.controlComponent!==s.ControlComponent.PLACEHOLDER&&u.controlComponent!==s.ControlComponent.POSTFIX&&u.controlComponent!==s.ControlComponent.POST_TEXT)continue}else if(u.controlComponent!==s.ControlComponent.PREFIX&&u.controlComponent!==s.ControlComponent.PRE_TEXT||r[d]?.controlComponent===s.ControlComponent.PREFIX||r[d]?.controlComponent===s.ControlComponent.PRE_TEXT)continue;return{zone:a,range:{startIndex:R,endIndex:R},positionContext:{isTable:!1}}}return null}const i=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}],l=[r=>r.controlId===t,r=>r.control?.conceptId===t,r=>r.control?.code===t];for(let r=0;r<l.length;r++)for(const a of i){const c=n(a.elementList,a.zone,l[r]);if(c){this.setZone(c.zone),this.position.setPositionContext(c.positionContext),this.range.replaceRange(c.range),this.draw.render({curIndex:c.range.startIndex,isCompute:!1,isSubmitHistory:!1});return}}}insertTextField(t){if(this.draw.isReadonly()||this.draw.isDisabled()||!t)return;const n=ct(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Vn(l,i);if(!r)return;const a=[...pn,...ue,...Nn,...cn];an(a,r,n),this.draw.insertElementTextField([n])}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=ct(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Vn(l,i);if(!r)return;const a=l[i],c=a?.controlComponent===s.ControlComponent.POSTFIX||a?.controlComponent===s.ControlComponent.POSTTEXTFIX;let d=!1;if(a?.controlId&&!c)for(let R=i;R>=0;R--){const h=l[R];if(h.controlId!==a.controlId)break;if(h.controlComponent===s.ControlComponent.PRETEXTFIX||h.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){h.control?.type===s.ControlType.TEXTFIELD&&(d=!0);break}}if(!d&&!c){const R=l[i-1];if(R?.controlId)for(let h=i-1;h>=0;h--){const g=l[h];if(g.controlId!==R.controlId)break;if(g.controlComponent===s.ControlComponent.PRETEXTFIX||g.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){g.control?.type===s.ControlType.TEXTFIELD&&(d=!0);break}}}if(d&&t.control?.type===s.ControlType.TEXTFIELD)return;const u=[...pn,...ue,...Nn,...cn];an(u,r,n),this.draw.insertElementList([n])}jumpControl(t){this.draw.getControl().initNextControl({direction:t?.direction})}getContainer(){return this.draw.getContainer()}getTitleValue(t){const{conceptId:e}=t,n=[],i=(r,a)=>{let c=0;for(;c<r.length;){const d=r[c];if(c++,d.type===s.ElementType.TABLE){const h=d.trList;for(let g=0;g<h.length;g++){const T=h[g];for(let f=0;f<T.tdList.length;f++){const p=T.tdList[f];i(p.value,a)}}}if(d?.title?.conceptId!==e)continue;const u=[];let R=c;for(;R<r.length;){const h=r[R];if(R++,d.titleId!==h.titleId){if(h.level&&Ci[h.level]<=Ci[d.level])break;u.push(h)}}n.push({...d.title,value:In(u),elementList:wt(u),zone:a}),c=R}},l=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:r,elementList:a}of l)i(a,r);return n}getPositionContextByEvent(t,e={}){const n=t.target?.dataset.index;if(!n)return null;const{isMustDirectHit:i=!0}=e,l=Number(n),r=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:l}),{isDirectHit:a,isTable:c,index:d,trIndex:u,tdIndex:R,tdValueIndex:h,zone:g}=r;if(i&&!a||g&&g!==this.zone.getZone())return null;let T=null,f=null;const p=this.draw.getOriginalElementList();let C=null;const I=this.position.getOriginalPositionList();if(c){const P=p[d].trList?.[u].tdList[R];f=P?.value[h]||null,C=P?.positionList?.[h]||null,T={element:p[d],trIndex:u,tdIndex:R}}else f=p[d]||null,C=I[d]||null;let m=null;if(C){const{pageNo:P,coordinate:{leftTop:E,rightTop:M},lineHeight:F}=C,y=this.draw.getOriginalHeight(),Y=this.draw.getOriginalPageGap();m={x:E[0],y:E[1]+P*(y+Y),width:M[0]-E[0],height:F}}return{pageNo:l,element:f,rangeRect:m,tableInfo:T}}insertTitle(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=ct(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Vn(l,i);if(!r)return;const a=[...pn,...ue,...Nn,...cn];n.valueList?.forEach(c=>{an(a,r,c)}),this.draw.insertElementList([n])}focus(t){const{position:e=s.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:i,range:l}=t||{};let r=-1;if(l)this.range.replaceRange(l),r=e===s.LocationPosition.BEFORE?l.startIndex:l.endIndex;else if(di(i)){const c=this.draw.getOriginalRowList();if(r=e===s.LocationPosition.BEFORE?c[i]?.startIndex:c[i+1]?.startIndex-1,!di(r))return;this.range.setRange(r,r)}else r=e===s.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(r,r);const a={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~r&&this.range.getIsCollapsed()&&(a.curIndex=r,a.isSetCursor=!0),this.draw.render(a)}insertArea(t){return this.draw.getArea().insertArea(t)}setAreaValue(t){return this.draw.getArea().setAreaValue(t)}setAreaProperties(t){this.draw.getArea().setAreaProperties(t)}locationArea(t,e){if(e?.isAppendLastLineBreak&&e?.position===s.LocationPosition.OUTER_AFTER){const l=this.draw.getOriginalMainElementList();l[l.length-1].areaId===t&&this.draw.appendElementList([{value:K}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:i}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(i,i),this.draw.render({curIndex:i,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getMacroValue(t){const{id:e,dictCode:n,label:i,areaId:l}=t,r=[],a=(d,u)=>{for(const R of d){if(R.type===s.ElementType.TABLE){const g=R.trList;for(const T of g)for(const f of T.tdList)a(f.value,u);continue}if(R.type!==s.ElementType.MACRO&&R.type!==s.ElementType.CUSTOM_MACRO&&R.type!==s.ElementType.REUSABLE_ITEM||e&&R.id!==e||n&&R.dictCode!==n||i&&R.label!==i||l&&R.areaId!==l)continue;const h={id:R.id,type:R.type,label:R.label,dictCode:R.dictCode,zone:u};R.type===s.ElementType.MACRO?h.value=R.value:R.type===s.ElementType.CUSTOM_MACRO?(h.macroConfig=R.macroConfig,h.value=R.macroConfig?.value):R.type===s.ElementType.REUSABLE_ITEM&&(h.reusableItemConfig=R.reusableItemConfig,h.value=R.reusableItemConfig?.value),r.push(h)}},c=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:d,elementList:u}of c)a(u,d);return r}getMacroList(){const t=[],e=i=>{for(const l of i){if(l.type===s.ElementType.TABLE){const r=l.trList;for(const a of r)for(const c of a.tdList)e(c.value);continue}(l.type===s.ElementType.MACRO||l.type===s.ElementType.CUSTOM_MACRO||l.type===s.ElementType.REUSABLE_ITEM)&&t.push(l)}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i);return t}setMacroValue(t){const{id:e,dictCode:n,label:i,areaId:l,value:r,code:a,isSubmitHistory:c=!0}=t;let d=!1;const u=h=>{for(let g=0;g<h.length;g++){const T=h[g];if(T.type===s.ElementType.TABLE){const f=T.trList;for(const p of f)for(const C of p.tdList)u(C.value);continue}T.type!==s.ElementType.MACRO&&T.type!==s.ElementType.CUSTOM_MACRO&&T.type!==s.ElementType.REUSABLE_ITEM||e&&T.id!==e||n&&T.dictCode!==n||i&&T.label!==i||l&&T.areaId!==l||(d=!0,T.type===s.ElementType.MACRO?T.value=r:T.type===s.ElementType.CUSTOM_MACRO?T.macroConfig?(T.macroConfig.value=r,a!==void 0&&(T.macroConfig.code=a)):T.macroConfig={type:"text",value:r}:T.type===s.ElementType.REUSABLE_ITEM&&(T.reusableItemConfig?T.reusableItemConfig.value=r:T.reusableItemConfig={value:r}))}},R=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const h of R)u(h);d&&this.draw.render({isSubmitHistory:c,isSetCursor:!1})}setMacroValueList(t){if(!t.length)return;let e=!1,n=!1;const i=r=>{for(let a=0;a<r.length;a++){const c=r[a];if(c.type===s.ElementType.TABLE){const g=c.trList;for(const T of g)for(const f of T.tdList)i(f.value);continue}if(c.type!==s.ElementType.MACRO&&c.type!==s.ElementType.CUSTOM_MACRO&&c.type!==s.ElementType.REUSABLE_ITEM)continue;const d=t.find(g=>g.id&&c.id===g.id||g.dictCode&&c.dictCode===g.dictCode||g.label&&c.label===g.label||g.areaId&&c.areaId===g.areaId);if(!d)continue;const{value:u,code:R,isSubmitHistory:h=!0}=d;e=!0,h&&(n=!0),c.type===s.ElementType.MACRO?c.value=u:c.type===s.ElementType.CUSTOM_MACRO?c.macroConfig?(c.macroConfig.value=u,R!==void 0&&(c.macroConfig.code=R)):c.macroConfig={type:"text",value:u}:c.type===s.ElementType.REUSABLE_ITEM&&(c.reusableItemConfig?c.reusableItemConfig.value=u:c.reusableItemConfig={value:u})}},l=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const r of l)i(r);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}updateMacroProperties(t){const{id:e,dictCode:n,label:i,areaId:l,properties:r,isSubmitHistory:a=!0}=t;let c=!1;const d=R=>{for(let h=0;h<R.length;h++){const g=R[h];if(g.type===s.ElementType.TABLE){const T=g.trList;for(const f of T)for(const p of f.tdList)d(p.value);continue}g.type!==s.ElementType.MACRO&&g.type!==s.ElementType.CUSTOM_MACRO&&g.type!==s.ElementType.REUSABLE_ITEM||e&&g.id!==e||n&&g.dictCode!==n||i&&g.label!==i||l&&g.areaId!==l||(c=!0,Object.assign(g,r))}},u=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const R of u)d(R);c&&this.draw.render({isSubmitHistory:a,isSetCursor:!1})}locationMacro(t){const{id:e,dictCode:n,label:i,areaId:l}=t,r=(c,d)=>{for(let u=0;u<c.length;u++){const R=c[u];if(R.type===s.ElementType.TABLE){const h=R.trList;for(let g=0;g<h.length;g++){const T=h[g];for(let f=0;f<T.tdList.length;f++){const p=T.tdList[f],C=r(p.value,d);if(C)return{...C,isTable:!0,index:u,trIndex:g,tdIndex:f,tableId:R.tableId,trId:T.id,tdId:p.id}}}}if(!(R.type!==s.ElementType.MACRO&&R.type!==s.ElementType.CUSTOM_MACRO&&R.type!==s.ElementType.REUSABLE_ITEM)&&!(e&&R.id!==e)&&!(n&&R.dictCode!==n)&&!(i&&R.label!==i)&&!(l&&R.areaId!==l))return{zone:d,index:u}}return null},a=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:c,elementList:d}of a){const u=r(d,c);if(u){this.setZone(u.zone),this.position.setPositionContext({isTable:u.isTable||!1,index:u.index,trIndex:u.trIndex,tdIndex:u.tdIndex,tableId:u.tableId,trId:u.trId,tdId:u.tdId}),this.range.replaceRange({startIndex:u.index,endIndex:u.index}),this.draw.render({curIndex:u.index,isCompute:!1,isSubmitHistory:!1});break}}}insertSubTemplate(t){const{label:e,templateId:n,content:i,conditions:l,relation:r="and",isSubmitHistory:a=!0}=t,c={id:ft(),value:e,type:s.ElementType.SUB_TEMPLATE,label:e,templateId:n,subTemplateContent:i?.map(d=>ct(d)),subTemplateRelation:r,subTemplateConditions:l?.map(d=>({...d})),subTemplateExpanded:!1};this.insertElementList([c],{isSubmitHistory:a})}updateSubTemplate(t){const{id:e,properties:n,isSubmitHistory:i=!0}=t;if(!e)return;const l=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];let r=!1;for(let a=0;a<l.length;a++)ps(l[a],c=>{c.id!==e||c.type!==s.ElementType.SUB_TEMPLATE||(Object.assign(c,{...n,value:n.label??c.value,subTemplateContent:n.subTemplateContent?n.subTemplateContent.map(d=>ct(d)):c.subTemplateContent?.map(d=>ct(d)),subTemplateConditions:n.subTemplateConditions?n.subTemplateConditions.map(d=>({...d})):c.subTemplateConditions?.map(d=>({...d}))}),r=!0)});r&&this.draw.render({isSubmitHistory:i,isCompute:!0})}expandSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,l=this.draw.getOriginalMainElementList();for(let r=0;r<l.length;r++){const a=l[r];if(a.type===s.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){const c=n||a.subTemplateContent;if(!c?.length){console.warn("子模板内容为空,无法展开");return}a.subTemplateExpanded=!0,a.hide=!0;const d=ct(c);jt(d,{isHandleFirstElement:!1,editorOptions:this.options});for(let u=0;u<d.length;u++)d[u].subTemplateParentId=a.id;l.splice(r+1,0,...d),this.draw.render({isSubmitHistory:i,isCompute:!0});return}}}collapseSubTemplate(t){const{id:e,isSubmitHistory:n=!0}=t,i=this.draw.getOriginalMainElementList();for(let l=0;l<i.length;l++){const r=i[l];if(r.type===s.ElementType.SUB_TEMPLATE&&(!e||r.id===e)){r.subTemplateExpanded=!1,r.hide=!1;let a=l+1;for(;a<i.length&&i[a].subTemplateParentId===r.id;)a++;a>l+1&&i.splice(l+1,a-l-1),this.draw.render({isSubmitHistory:n,isCompute:!0});return}}}toggleSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,l=this.draw.getOriginalMainElementList();for(let r=0;r<l.length;r++){const a=l[r];if(a.type===s.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){a.subTemplateExpanded?this.collapseSubTemplate({id:e,isSubmitHistory:i}):this.expandSubTemplate({id:e,content:n,isSubmitHistory:i});return}}}}class HT{rangeStyleChange;visiblePageNoListChange;intersectionPageNoChange;pageSizeChange;pageScaleChange;saved;contentChange;controlChange;controlContentChange;pageModeChange;zoneChange;constructor(){this.rangeStyleChange=null,this.visiblePageNoListChange=null,this.intersectionPageNoChange=null,this.pageSizeChange=null,this.pageScaleChange=null,this.saved=null,this.contentChange=null,this.controlChange=null,this.controlContentChange=null,this.pageModeChange=null,this.zoneChange=null}}class _T{contextMenu;contextMenuList;getContextMenuList;shortcutList;langMap;constructor(t){const{contextMenu:e,shortcut:n,i18n:i}=t;this.contextMenu=e,this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=i.registerLangMap.bind(i)}disposeContextMenu(){this.contextMenu.dispose()}}const Ul={SELECTED_TEXT:"%s"},Jn={GLOBAL:{CUT:"globalCut",COPY:"globalCopy",PASTE:"globalPaste",SELECT_ALL:"globalSelectAll",PRINT:"globalPrint"},CONTROL:{DELETE:"controlDelete",EDIT_ATTRIBUTE:"controlEditAttribute",COPY:"controlCopy",PASTE:"controlPaste"},HYPERLINK:{DELETE:"hyperlinkDelete",CANCEL:"hyperlinkCancel",EDIT:"hyperlinkEdit"},IMAGE:{CHANGE:"imageChange",SAVE_AS:"imageSaveAs",TEXT_WRAP:"imageTextWrap",TEXT_WRAP_EMBED:"imageTextWrapEmbed",TEXT_WRAP_UP_DOWN:"imageTextWrapUpDown",TEXT_WRAP_SURROUND:"imageTextWrapSurround",TEXT_WRAP_FLOAT_TOP:"imageTextWrapFloatTop",TEXT_WRAP_FLOAT_BOTTOM:"imageTextWrapFloatBottom"},TABLE:{BORDER:"border",BORDER_ALL:"tableBorderAll",BORDER_EMPTY:"tableBorderEmpty",BORDER_DASH:"tableBorderDash",BORDER_EXTERNAL:"tableBorderExternal",BORDER_INTERNAL:"tableBorderInternal",BORDER_TD:"tableBorderTd",BORDER_TD_TOP:"tableBorderTdTop",BORDER_TD_RIGHT:"tableBorderTdRight",BORDER_TD_BOTTOM:"tableBorderTdBottom",BORDER_TD_LEFT:"tableBorderTdLeft",BORDER_TD_FORWARD:"tableBorderTdForward",BORDER_TD_BACK:"tableBorderTdBack",VERTICAL_ALIGN:"tableVerticalAlign",VERTICAL_ALIGN_TOP:"tableVerticalAlignTop",VERTICAL_ALIGN_MIDDLE:"tableVerticalAlignMiddle",VERTICAL_ALIGN_BOTTOM:"tableVerticalAlignBottom",INSERT_ROW_COL:"tableInsertRowCol",INSERT_TOP_ROW:"tableInsertTopRow",INSERT_BOTTOM_ROW:"tableInsertBottomRow",INSERT_LEFT_COL:"tableInsertLeftCol",INSERT_RIGHT_COL:"tableInsertRightCol",DELETE_ROW_COL:"tableDeleteRowCol",DELETE_ROW:"tableDeleteRow",DELETE_COL:"tableDeleteCol",DELETE_TABLE:"tableDeleteTable",MERGE_CELL:"tableMergeCell",CANCEL_MERGE_CELL:"tableCancelMergeCell",TABLE_PROPERTIES:"tableProperties"}},{CONTROL:{DELETE:AT,EDIT_ATTRIBUTE:kT,COPY:GT,PASTE:xT}}=Jn;function BT(o,t){if(t!==s.EditorMode.EDIT)return!1;const n=o?.control?.type,i=o?.controlComponent,l=n===s.ControlType.TEXT||n===s.ControlType.TEXTFIELD||n===s.ControlType.NUMBER||n===s.ControlType.SELECT||n===s.ControlType.DATE||n===s.ControlType.CHECKBOX||n===s.ControlType.RADIO||n===s.ControlType.BUTTON,r=i==="prefix"||i==="preText"||i==="preTextFix"||i==="textFixLabel"||n===s.ControlType.BUTTON&&(i==="value"||i==="placeholder");return l&&r}function wl(o){return o.hitElement||o.hitTableElement}const JT=[{key:GT,name:"复制控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&BT(o.startElement,o.options.mode),callback:(o,t)=>{const e=t.startElement?.controlId;e&&o.executeCopyControl(e)}},{key:xT,name:"粘贴控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.editorTextFocus&&o.options.mode===s.EditorMode.EDIT&&Oc(),callback:o=>{o.executePasteControl()}},{key:AT,i18nPath:"contextmenu.control.delete",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeRemoveControl()}},{key:kT,i18nPath:"contextmenu.control.editAttribute",when:o=>{const t=wl(o);return!o.isReadonly&&!o.editorHasSelection&&o.options.mode===s.EditorMode.EDIT&&!!t},callback:(o,t)=>{const e=wl(t);e&&o.executeTriggerControlEditAttribute(e.controlId,e)}}],{GLOBAL:{CUT:$T,COPY:zT,PASTE:jT,SELECT_ALL:qT,PRINT:tf}}=Jn,ef=[{key:$T,i18nPath:"contextmenu.global.cut",shortCut:`${mn?"⌘":"Ctrl"} + X`,when:o=>!o.isReadonly,callback:o=>{o.executeCut()}},{key:zT,i18nPath:"contextmenu.global.copy",shortCut:`${mn?"⌘":"Ctrl"} + C`,when:o=>o.editorHasSelection||o.isCrossRowCol,callback:o=>{o.executeCopy()}},{key:jT,i18nPath:"contextmenu.global.paste",shortCut:`${mn?"⌘":"Ctrl"} + V`,when:o=>!o.isReadonly&&o.editorTextFocus,callback:o=>{o.executePaste()}},{key:qT,i18nPath:"contextmenu.global.selectAll",shortCut:`${mn?"⌘":"Ctrl"} + A`,when:o=>o.editorTextFocus,callback:o=>{o.executeSelectAll()}},{isDivider:!0},{key:tf,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:o=>{o.executePrint()}}],{HYPERLINK:{DELETE:nf,CANCEL:of,EDIT:sf}}=Jn,rf=[{key:nf,i18nPath:"contextmenu.hyperlink.delete",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:o=>{o.executeDeleteHyperlink()}},{key:of,i18nPath:"contextmenu.hyperlink.cancel",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:o=>{o.executeCancelHyperlink()}},{key:sf,i18nPath:"contextmenu.hyperlink.edit",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:(o,t)=>{const e=window.prompt(o.executeTranslate("contextmenu.hyperlink.edit"),t.startElement?.url);e&&o.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:lf,SAVE_AS:af,TEXT_WRAP:cf,TEXT_WRAP_EMBED:df,TEXT_WRAP_UP_DOWN:uf,TEXT_WRAP_SURROUND:Rf,TEXT_WRAP_FLOAT_TOP:hf,TEXT_WRAP_FLOAT_BOTTOM:gf}}=Jn,Tf=[{key:lf,i18nPath:"contextmenu.image.change",icon:"image-change",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,callback:o=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],n=new FileReader;n.readAsDataURL(e),n.onload=()=>{const i=n.result;o.executeReplaceImageElement(i)}},t.click()}},{key:af,i18nPath:"contextmenu.image.saveAs",icon:"image",when:o=>!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,callback:o=>{o.executeSaveAsImageElement()}},{key:cf,i18nPath:"contextmenu.image.textWrap",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,childMenus:[{key:df,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.BLOCK)}},{key:uf,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.INLINE)}},{key:Rf,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.SURROUND)}},{key:hf,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.FLOAT_TOP)}},{key:gf,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:ff,BORDER_ALL:mf,BORDER_EMPTY:pf,BORDER_DASH:Cf,BORDER_EXTERNAL:If,BORDER_INTERNAL:Lf,BORDER_TD:Pf,BORDER_TD_TOP:Ef,BORDER_TD_LEFT:Mf,BORDER_TD_BOTTOM:Of,BORDER_TD_RIGHT:Sf,BORDER_TD_BACK:Xf,BORDER_TD_FORWARD:Nf,VERTICAL_ALIGN:Ff,VERTICAL_ALIGN_TOP:yf,VERTICAL_ALIGN_MIDDLE:bf,VERTICAL_ALIGN_BOTTOM:Df,INSERT_ROW_COL:Vf,INSERT_TOP_ROW:Wf,INSERT_BOTTOM_ROW:Yf,INSERT_LEFT_COL:Uf,INSERT_RIGHT_COL:wf,DELETE_ROW_COL:Zf,DELETE_ROW:vf,DELETE_COL:Qf,DELETE_TABLE:Kf,MERGE_CELL:Hf,CANCEL_MERGE_CELL:_f}}=Jn,Af=[{isDivider:!0},{key:ff,i18nPath:"contextmenu.table.border",icon:"border-all",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:mf,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.ALL)}},{key:pf,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.EMPTY)}},{key:Cf,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.DASH)}},{key:If,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.EXTERNAL)}},{key:Lf,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.INTERNAL)}},{key:Pf,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:Ef,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.TOP)}},{key:Sf,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.RIGHT)}},{key:Of,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.BOTTOM)}},{key:Mf,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.LEFT)}},{key:Nf,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:o=>{o.executeTableTdSlashType(s.TdSlash.FORWARD)}},{key:Xf,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:o=>{o.executeTableTdSlashType(s.TdSlash.BACK)}}]}]},{key:Ff,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:yf,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.TOP)}},{key:bf,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.MIDDLE)}},{key:Df,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.BOTTOM)}}]},{key:Vf,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:Wf,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:o=>{o.executeInsertTableTopRow()}},{key:Yf,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:o=>{o.executeInsertTableBottomRow()}},{key:Uf,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:o=>{o.executeInsertTableLeftCol()}},{key:wf,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:o=>{o.executeInsertTableRightCol()}}]},{key:Zf,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:vf,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:o=>{o.executeDeleteTableRow()}},{key:Qf,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:o=>{o.executeDeleteTableCol()}},{key:Kf,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:o=>{o.executeDeleteTable()}}]},{key:Hf,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:o=>!o.isReadonly&&o.isCrossRowCol&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeMergeTableCell()}},{key:_f,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeCancelMergeTableCell()}}];class kf{options;draw;command;range;position;i18n;container;contextMenuList;contextMenuContainerList;contextMenuRelationShip;context;constructor(t,e){this.options=t.getOptions(),this.draw=t,this.command=e,this.range=t.getRange(),this.position=t.getPosition(),this.i18n=t.getI18n(),this.container=t.getContainer(),this.context=null,this.contextMenuList=[...ef,...Af,...Tf,...JT,...rf],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}getContextMenuList(){return this.contextMenuList}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_filterMenuList(t){const{contextMenuDisableKeys:e}=this.options,n=[];for(let i=0;i<t.length;i++){const l=t[i];l.disable||l.key&&e.includes(l.key)||(l.isDivider||l.when?.(this.context))&&n.push(l)}return n}_proxyContextMenuEvent=t=>{this.context=this._getContext(t);const e=this._filterMenuList(this.contextMenuList);e.some(i=>!i.isDivider)&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()};_handleSideEffect=t=>{const e=t.target;this.contextMenuContainerList.some(i=>i.contains(e))||this.dispose()};_getContext(t){const e=this.draw.isReadonly(),{isCrossRowCol:n,startIndex:i,endIndex:l}=this.range.getRange(),r=!!(~i||~l),a=r&&i!==l,{isTable:c,trIndex:d,tdIndex:u,index:R}=this.position.getPositionContext(),h=t?this.command.getPositionContextByEvent(t,{isMustDirectHit:!0}):null;let g=null;if(c){const M=this.draw.getOriginalElementList()[R]||null;M&&(g=wt([M],{extraPickAttrs:["id"]})[0])}const T=c&&!!n,f=this.draw.getElementList();let p=f[i]||null,C=f[l]||null;h?.element&&(p=h.element,C=h.element);const I=h?.element||null,m=h?.tableInfo?.element||null;h?.tableInfo?.element&&(g=h.tableInfo.element);const P=this.draw.getZone().getZone();return{startElement:p,endElement:C,hitElement:I,hitTableElement:m,isReadonly:e,editorHasSelection:a,editorTextFocus:r,isCrossRowCol:T,zone:P,isInTable:c,trIndex:d??null,tdIndex:u??null,tableElement:g,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-contextmenu-container`),t.setAttribute(Be,s.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){const{contextMenuList:e,left:n,top:i,parentMenuContainer:l}=t,r=this._createContextMenuContainer(),a=document.createElement("div");a.classList.add(`${rt}-contextmenu-content`);let c=null;l&&this.contextMenuRelationShip.set(l,r);for(let P=0;P<e.length;P++){const E=e[P];if(E.isDivider){if(P!==0&&P!==e.length-1&&!e[P-1]?.isDivider){const M=document.createElement("div");M.classList.add(`${rt}-contextmenu-divider`),a.append(M)}}else{const M=document.createElement("div");if(M.classList.add(`${rt}-contextmenu-item`),E.childMenus){const D=this._filterMenuList(E.childMenus);D.some(b=>!b.isDivider)&&(M.classList.add(`${rt}-contextmenu-sub-item`),M.onmouseenter=()=>{this._setHoverStatus(M,!0),this._removeSubMenu(r);const b=M.getBoundingClientRect(),V=b.left+b.width,X=b.top;c=this._render({contextMenuList:D,left:V,top:X,parentMenuContainer:r})},M.onmouseleave=b=>{(!c||!c.contains(b.relatedTarget))&&this._setHoverStatus(M,!1)})}else M.onmouseenter=()=>{this._setHoverStatus(M,!0),this._removeSubMenu(r)},M.onmouseleave=()=>{this._setHoverStatus(M,!1)},M.onclick=()=>{E.callback&&this.context&&E.callback(this.command,this.context),this.dispose()};const F=document.createElement("i");M.append(F),E.icon&&F.classList.add(`${rt}-contextmenu-${E.icon}`);const y=document.createElement("span"),Y=E.i18nPath?this._formatName(this.i18n.t(E.i18nPath)):this._formatName(E.name||"");if(y.append(document.createTextNode(Y)),M.append(y),E.shortCut){const D=document.createElement("span");D.classList.add(`${rt}-shortcut`),D.append(document.createTextNode(E.shortCut)),M.append(D)}a.append(M)}}const d=document.createElement("div");d.classList.add(`${rt}-contextmenu-divider`),a.append(d);const u=document.createElement("div");u.classList.add(`${rt}-contextmenu-item`),u.onmouseenter=()=>{this._setHoverStatus(u,!0),this._removeSubMenu(r)},u.onmouseleave=()=>{this._setHoverStatus(u,!1)},u.onclick=()=>{this.dispose()};const R=document.createElement("i");u.append(R);const h=document.createElement("span");h.append(document.createTextNode(this.i18n.t("contextmenu.global.cancel"))),u.append(h),a.append(u),r.append(a),r.style.display="block";const g=window.innerWidth,T=r.getBoundingClientRect(),f=T.width,p=n+f>g?n-f:n;r.style.left=`${p}px`;const C=window.innerHeight,I=T.height,m=i+I>C?i-I:i;return r.style.top=`${m}px`,this.contextMenuContainerList.push(r),r}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){e?(t.parentNode?.querySelectorAll(`${rt}-contextmenu-item`).forEach(n=>n.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(Ul),n=new RegExp(`${e.join("|")}`);let i=t;if(n.test(i)){const l=new RegExp(Ul.SELECTED_TEXT,"g");if(l.test(i)){const r=this.range.toString();i=i.replace(l,r)}}return i}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const Gf=[{key:s.KeyMap.X,ctrl:!0,shift:!0,callback:o=>{o.executeStrikeout()}},{key:s.KeyMap.LEFT_BRACKET,mod:!0,callback:o=>{o.executeSizeAdd()}},{key:s.KeyMap.RIGHT_BRACKET,mod:!0,callback:o=>{o.executeSizeMinus()}},{key:s.KeyMap.B,mod:!0,callback:o=>{o.executeBold()}},{key:s.KeyMap.I,mod:!0,callback:o=>{o.executeItalic()}},{key:s.KeyMap.U,mod:!0,callback:o=>{o.executeUnderline()}},{key:mn?s.KeyMap.COMMA:s.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSuperscript()}},{key:mn?s.KeyMap.PERIOD:s.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSubscript()}},{key:s.KeyMap.L,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.LEFT)}},{key:s.KeyMap.E,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.CENTER)}},{key:s.KeyMap.R,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.RIGHT)}},{key:s.KeyMap.J,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.ALIGNMENT)}},{key:s.KeyMap.J,mod:!0,shift:!0,callback:o=>{o.executeRowFlex(s.RowFlex.JUSTIFY)}}],xf=[{key:s.KeyMap.ZERO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(null)}},{key:s.KeyMap.ONE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FIRST)}},{key:s.KeyMap.TWO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.SECOND)}},{key:s.KeyMap.THREE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.THIRD)}},{key:s.KeyMap.FOUR,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FOURTH)}},{key:s.KeyMap.FIVE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FIFTH)}},{key:s.KeyMap.SIX,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.SIXTH)}}],Bf=[{key:s.KeyMap.I,shift:!0,mod:!0,callback:o=>{o.executeList(s.ListType.UL,s.ListStyle.DISC)}},{key:s.KeyMap.U,shift:!0,mod:!0,callback:o=>{o.executeList(s.ListType.OL)}}];class Jf{draw;command;globalShortcutList;agentShortcutList;constructor(t,e){this.draw=t,this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...Gf,...xf,...Bf]),this._addEvent(),t.getCursor().getAgentDom().addEventListener("keydown",this._agentKeydown.bind(this))}_addEvent(){document.addEventListener("keydown",this._globalKeydown)}removeEvent(){document.removeEventListener("keydown",this._globalKeydown)}_addShortcutList(t){for(let e=t.length-1;e>=0;e--){const n=t[e];n.isGlobal?this.globalShortcutList.unshift(n):this.agentShortcutList.unshift(n)}}registerShortcutList(t){this._addShortcutList(t)}_globalKeydown=t=>{this.globalShortcutList.length&&this.draw.isGlobalShortcutActive()&&this.draw.isTargetInsideEditor(t.target)&&this._execute(t,this.globalShortcutList)};_agentKeydown(t){this.agentShortcutList.length&&(this.draw.isInteractionSuspended()||this._execute(t,this.agentShortcutList))}_execute(t,e){for(let n=0;n<e.length;n++){const i=e[n];if((i.mod?Qe(t)===!!i.mod:t.ctrlKey===!!i.ctrl&&t.metaKey===!!i.meta)&&t.shiftKey===!!i.shift&&t.altKey===!!i.alt&&t.key.toLowerCase()===i.key.toLowerCase()){i.disable||(i?.callback?.(this.command),t.preventDefault());break}}}}class $f{editor;constructor(t){this.editor=t}use(t,e){t(this.editor,e)}}class zf{eventHub;constructor(){this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t)||new Set;n.add(e),this.eventHub.set(t,n)}emit(t,e){if(!t)return;const n=this.eventHub.get(t);if(n){if(n.size===1)return[...n][0](e);n.forEach(i=>i(e))}}off(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t);n&&n.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}dangerouslyClearAll(){this.eventHub.clear()}}class jf{paste;copy;drop}class Zl{command;version;listener;eventBus;override;register;destroy;use;draw;constructor(t,e,n={}){const i=Lo(n);e=ct(e);let l=[],r=[],a=[],c=[];Array.isArray(e)?r=e:(l=e.header||[],r=e.main,a=e.footer||[],c=e.graffiti||[]),[l,r,a].forEach(T=>{jt(T,{editorOptions:i,isForceCompensation:!0})}),this.version=fn,this.listener=new HT,this.eventBus=new zf,this.override=new jf,this.draw=new YT(t,i,{header:l,main:r,footer:a,graffiti:c},this.listener,this.eventBus,this.override);const u=this.draw;this.command=new Wl(new KT(u)),u.setCommand(this.command);const R=new kf(u,this.command),h=new Jf(u,this.command);this.register=new _T({contextMenu:R,shortcut:h,i18n:u.getI18n()}),this.destroy=()=>{u.destroy(),h.removeEvent(),R.removeEvent(),this.eventBus.dangerouslyClearAll()};const g=new $f(this);this.use=g.use.bind(g)}setFormModeTrace(t){this.command.executeSetFormModeTrace(t)}pauseInteraction(){this.draw.pauseInteraction()}resumeInteraction(){this.draw.resumeInteraction()}setOverlayActive(t){this.draw.setOverlayActive(t)}suspendGlobalShortcut(t){this.draw.suspendGlobalShortcut(t)}}s.Command=Wl,s.EDITOR_CLIPBOARD=zn,s.EDITOR_COMPONENT=Be,s.Editor=Zl,s.INTERNAL_CONTEXT_MENU_KEY=Jn,s.INTERNAL_SHORTCUT_KEY=mr,s.LETTER_CLASS=ii,s.createDomFromElementList=Wn,s.default=Zl,s.getElementListByHTML=Yn,s.getTextFromElementList=In,s.splitText=yt,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
570
+ `?K:l[d];e.splice(c+d,0,{...a,value:u})}}}const{endIndex:i}=this.range.getRange();this.draw.render({curIndex:i,isSetCursor:!0})}}delButton(t,e){return new Promise(n=>{for(let i=t.length-1;i>=0;i--)e.some(r=>r.controlId===t[i].controlId&&r.type===t[i].type)&&t.splice(i,1);n(!0)})}editButton(t,e,n){const i=this.draw.getElementList();n=n+1;for(let d=0;d<e.label.length;d++){const u={value:e.label[d],controlId:e.controlId,type:s.ElementType.CONTROL,control:{type:"button",buttonLabel:e.label,code:e.code,value:[{value:e.label}],label:e.label,hide:!1},controlComponent:"value",color:"#fff",highlight:"#1677FF",style:"16px Microsoft YaHei",hide:!1};i.splice(n+d,0,u)}const{startIndex:l,endIndex:r}=this.range.getRange(),a=!0,c=r;this.draw.render({curIndex:c,isSetCursor:a})}removeButtonElementsByControlId(t){return new Promise(e=>{const n=this.draw.getElementList();for(let c=n.length-1;c>=0;c--)n[c].controlId===t&&n.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),e(!0)})}removeByValue(t,e){return new Promise(n=>{for(let c=t.length-1;c>=0;c--)(t[c].type=="control"||t[c].type=="text"||t[c].type=="buttonText")&&t[c].control?.buttonLabel===e&&t[c].control?.buttonText&&t.splice(c,1);const{startIndex:i,endIndex:l}=this.range.getRange(),r=!0,a=l;this.draw.render({curIndex:a,isSetCursor:r}),n(!0)})}insertButtonValue(t){const e=this.draw.getElementList(),n=t.controlId,l=(Array.isArray(t.element)?t.element:t.elementList||[t.element])[0],r=l.newButtonValue,a=l.control.buttonLabel,c=l.control.code;if(!r||!r.length)return;let d=-1;for(let I=0;I<e.length;I++)if(e[I].controlId===n&&e[I].control?.type==="button"){d=I;break}if(d===-1)return;const u=n+"_text",R=[];for(let I=0;I<r.length;I++){const m=r[I];R.push({value:m.value,code:m.code})}const h={type:"button",buttonLabel:a,buttonText:!0,label:a,code:c,value:R,hide:!1},g=[];g.push({value:"[",controlId:u,type:s.ElementType.CONTROL,control:h,controlComponent:s.ControlComponent.PREFIX,color:"#1677FF",hide:!1});for(let I=0;I<r.length;I++){const m=r[I],P=r.length>1?`${I+1}.${m.value}`:m.value,E=yt(P);for(let M=0;M<E.length;M++)g.push({value:E[M],controlId:u,type:s.ElementType.CONTROL,control:h,controlComponent:s.ControlComponent.VALUE,color:"#000",hide:!1});r.length>1&&I<r.length-1&&g.push({value:K,controlId:u,type:s.ElementType.CONTROL,control:h,controlComponent:s.ControlComponent.VALUE,color:"#000",hide:!1})}g.push({value:"]",controlId:u,type:s.ElementType.CONTROL,control:h,controlComponent:s.ControlComponent.POSTFIX,color:"#1677FF",hide:!1});for(let I=0;I<g.length;I++)e.splice(d+I,0,g[I]);const{startIndex:T,endIndex:f}=this.range.getRange(),p=!0,C=f;this.draw.render({curIndex:C,isSetCursor:p})}font(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{r.font=t}),this.draw.render({isSetCursor:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({font:t}),d?.value===K?d.font=t:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}size(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{minSize:l,maxSize:r,defaultSize:a}=this.options;if(t<l||t>r)return;let c={},d=[];const u=this.range.getTextLikeSelectionElementList();if(u?.length)d=u,c={isSetCursor:!1};else{const{endIndex:h}=this.range.getRange(),T=this.draw.getElementList()[h];this.range.setDefaultStyle({size:t}),T?.value===K?(d.push(T),c={curIndex:h}):this.draw.render({curIndex:h,isCompute:!1,isSubmitHistory:!1})}if(!d.length)return;let R=!1;d.forEach(h=>{!h.size&&t===a||h.size&&h.size===t||(h.size=t,R=!0)}),R&&this.draw.render(c)}sizeAdd(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,maxSize:l}=this.options,r=this.range.getTextLikeSelectionElementList();let a={},c=[];if(r?.length)c=r,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange(),h=this.draw.getElementList()[u],T=this.range.getDefaultStyle()?.size||h.size||i;this.range.setDefaultStyle({size:T+2>l?l:T+2}),h?.value===K?(c.push(h),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(u=>{u.size||(u.size=i),!(u.size>=l)&&(u.size+2>l?u.size=l:u.size+=2,d=!0)}),d&&this.draw.render(a)}sizeMinus(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const{defaultSize:i,minSize:l}=this.options,r=this.range.getTextLikeSelectionElementList();let a={},c=[];if(r?.length)c=r,a={isSetCursor:!1};else{const{endIndex:u}=this.range.getRange(),h=this.draw.getElementList()[u],T=this.range.getDefaultStyle()?.size||h.size||i;this.range.setDefaultStyle({size:T-2<l?l:T-2}),h?.value===K?(c.push(h),a={curIndex:u}):this.draw.render({curIndex:u,isCompute:!1,isSubmitHistory:!1})}if(!c.length)return;let d=!1;c.forEach(u=>{u.size||(u.size=i),!(u.size<=l)&&(u.size-2<l?u.size=l:u.size-=2,d=!0)}),d&&this.draw.render(a)}bold(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.bold);i.forEach(r=>{r.bold=!!~l}),this.draw.render({isSetCursor:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({bold:c.bold?!1:!this.range.getDefaultStyle()?.bold}),c?.value===K?c.bold=!c.bold:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}italic(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.italic);i.forEach(r=>{r.italic=!!~l}),this.draw.render({isSetCursor:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({italic:c.italic?!1:!this.range.getDefaultStyle()?.italic}),c?.value===K?c.italic=!c.italic:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}underline(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length){const r=l.some(a=>!a.underline||!t&&a.textDecoration||t&&!a.textDecoration||t&&a.textDecoration&&!ha(a.textDecoration,t));l.forEach(a=>{a.underline=r,r&&t?a.textDecoration=t:delete a.textDecoration}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({underline:d?.underline?!1:!this.range.getDefaultStyle()?.underline}),d?.value===K?d.underline=!d.underline:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}strikeout(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(i?.length){const l=i.findIndex(r=>!r.strikeout);i.forEach(r=>{r.strikeout=!!~l}),this.draw.render({isSetCursor:!1,isCompute:!1})}else{let l=!0;const{endIndex:r}=this.range.getRange(),c=this.draw.getElementList()[r];this.range.setDefaultStyle({strikeout:c.strikeout?!1:!this.range.getDefaultStyle()?.strikeout}),c?.value===K?c.strikeout=!c.strikeout:l=!1,this.draw.render({isSubmitHistory:l,curIndex:r,isCompute:!1})}}superscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const l=i.findIndex(r=>r.type===s.ElementType.SUPERSCRIPT);i.forEach(r=>{~l?r.type===s.ElementType.SUPERSCRIPT&&(r.type=s.ElementType.TEXT,delete r.actualSize):(!r.type||r.type===s.ElementType.TEXT||r.type===s.ElementType.SUBSCRIPT)&&(r.type=s.ElementType.SUPERSCRIPT)}),this.draw.render({isSetCursor:!1})}subscript(t){const{isIgnoreDisabledRule:e=!1}=t||{};if(!e&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const i=this.range.getSelectionElementList();if(!i)return;const l=i.findIndex(r=>r.type===s.ElementType.SUBSCRIPT);i.forEach(r=>{~l?r.type===s.ElementType.SUBSCRIPT&&(r.type=s.ElementType.TEXT,delete r.actualSize):(!r.type||r.type===s.ElementType.TEXT||r.type===s.ElementType.SUPERSCRIPT)&&(r.type=s.ElementType.SUBSCRIPT)}),this.draw.render({isSetCursor:!1})}color(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{t?r.color=t:delete r.color}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({color:t||void 0}),d?.value===K?t?d.color=t:delete d.color:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}highlight(t,e){const{isIgnoreDisabledRule:n=!1}=e||{};if(!n&&(this.draw.isReadonly()||this.draw.isDisabled()))return;const l=this.range.getSelectionElementList();if(l?.length)l.forEach(r=>{t?r.highlight=t:delete r.highlight}),this.draw.render({isSetCursor:!1,isCompute:!1});else{let r=!0;const{endIndex:a}=this.range.getRange(),d=this.draw.getElementList()[a];this.range.setDefaultStyle({highlight:t||void 0}),d?.value===K?t?d.highlight=t:delete d.highlight:r=!1,this.draw.render({isSubmitHistory:r,curIndex:a,isCompute:!1})}}title(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.draw.getElementList(),r=n===i?this.range.getRangeParagraphElementList():l.slice(n+1,i+1);if(!r||!r.length)return;const a=ft(),c=this.draw.getOptions().title;r.forEach(R=>{!R.type&&R.value===K||(t?(R.level=t,R.titleId=a,Xo(R)&&(R.size=c[Zs[t]],R.bold=!0)):R.titleId&&(delete R.titleId,delete R.title,delete R.level,delete R.size,delete R.bold))});const d=n===i,u=d?i:n;this.draw.render({curIndex:u,isSetCursor:d})}list(t,e){this.draw.isReadonly()||this.draw.getListParticle().setList(t,e)}rowFlex(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.rowFlex=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}vertical(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.vertical=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}rowMargin(t){if(this.draw.isReadonly())return;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return;const l=this.range.getRangeRowElementList();if(!l)return;l.forEach(c=>{c.rowMargin=t});const r=n===i,a=r?i:n;this.draw.render({curIndex:a,isSetCursor:r})}insertTable(t,e){this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl()||this.tableOperate.insertTable(t,e)}insertTableTopRow(){this.draw.isReadonly()||this.tableOperate.insertTableTopRow()}insertTableBottomRow(){this.draw.isReadonly()||this.tableOperate.insertTableBottomRow()}insertTableLeftCol(){this.draw.isReadonly()||this.tableOperate.insertTableLeftCol()}insertTableRightCol(){this.draw.isReadonly()||this.tableOperate.insertTableRightCol()}deleteTableRow(){this.draw.isReadonly()||this.tableOperate.deleteTableRow()}deleteTableCol(){this.draw.isReadonly()||this.tableOperate.deleteTableCol()}deleteTable(){this.draw.isReadonly()||this.tableOperate.deleteTable()}mergeTableCell(){this.draw.isReadonly()||this.tableOperate.mergeTableCell()}cancelMergeTableCell(){this.draw.isReadonly()||this.tableOperate.cancelMergeTableCell()}splitVerticalTableCell(){this.draw.isReadonly()||this.tableOperate.splitVerticalTableCell()}splitHorizontalTableCell(){this.draw.isReadonly()||this.tableOperate.splitHorizontalTableCell()}tableTdVerticalAlign(t){this.draw.isReadonly()||this.tableOperate.tableTdVerticalAlign(t)}tableBorderType(t){this.draw.isReadonly()||this.tableOperate.tableBorderType(t)}tableBorderColor(t){this.draw.isReadonly()||this.tableOperate.tableBorderColor(t)}tableTdBorderType(t){this.draw.isReadonly()||this.tableOperate.tableTdBorderType(t)}tableTdSlashType(t){this.draw.isReadonly()||this.tableOperate.tableTdSlashType(t)}tableTdBackgroundColor(t){this.draw.isReadonly()||this.tableOperate.tableTdBackgroundColor(t)}tableSelectAll(){this.tableOperate.tableSelectAll()}tableProperties(){this.draw.isReadonly()||this.tableOperate.tableProperties()}hyperlink(t){const{valueList:e,url:n,hyperlinkId:i}=t;if(!n||!e?.length||this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl())return;const{startIndex:a,endIndex:c}=this.range.getRange();!~a&&!~c||this.insertElementList([{type:s.ElementType.HYPERLINK,value:"",valueList:e,url:n,hyperlinkId:i||ft()}])}getHyperlinkRange(){let t=-1,e=-1;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=this.draw.getElementList(),r=l[n];if(r.type!==s.ElementType.HYPERLINK)return null;let a=n;for(;a>0;){if(l[a].hyperlinkId!==r.hyperlinkId){t=a+1;break}a--}let c=n+1;for(;c<l.length;){if(l[c].hyperlinkId!==r.hyperlinkId){e=c-1;break}c++}return c===l.length&&(e=c-1),!~t||!~e?null:[t,e]}deleteHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,l]=e;this.draw.spliceElementList(n,i,l-i+1),this.draw.getHyperlinkParticle().clearHyperlinkPopup();const r=i-1;this.range.setRange(r,r),this.draw.render({curIndex:r})}cancelHyperlink(){if(this.draw.isReadonly()||this.draw.isDisabled())return;const e=this.getHyperlinkRange();if(!e)return;const n=this.draw.getElementList(),[i,l]=e;for(let a=i;a<=l;a++){const c=n[a];delete c.type,delete c.url,delete c.hyperlinkId,delete c.underline}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:r}=this.range.getRange();this.draw.render({curIndex:r,isCompute:!1})}editHyperlink(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=this.getHyperlinkRange();if(!n)return;const i=this.draw.getElementList(),[l,r]=n;for(let c=l;c<=r;c++){const d=i[c];d.url=t}this.draw.getHyperlinkParticle().clearHyperlinkPopup();const{endIndex:a}=this.range.getRange();this.draw.render({curIndex:a,isCompute:!1})}separator(t,e){if(this.draw.isReadonly()||this.draw.isDisabled()||this.getIsRangeInTextField()||this.control.getActiveControl())return;const{startIndex:l,endIndex:r}=this.range.getRange();if(!~l&&!~r)return;const a=this.draw.getElementList();let c=-1;const d=a[r+1];if(d&&d.type===s.ElementType.SEPARATOR){if(d.dashArray&&d.dashArray.join()===t.join())return;c=r,Object.assign(d,{dashArray:t,...e})}else{const u={value:Ps,type:s.ElementType.SEPARATOR,dashArray:t,...e};oe(a,[u],l,{editorOptions:this.options}),l!==0&&a[l].value===K?(this.draw.spliceElementList(a,l,1,[u]),c=l-1):(this.draw.spliceElementList(a,l+1,0,[u]),c=l)}this.range.setRange(c,c),this.draw.render({curIndex:c})}pageBreak(){this.draw.isReadonly()||this.draw.isDisabled()||this.control.getActiveControl()||this.insertElementList([{type:s.ElementType.PAGE_BREAK,value:Ps}])}addWatermark(t){if(this.draw.isReadonly())return;const n=this.draw.getOptions(),{color:i,size:l,opacity:r,font:a,gap:c}=Ii;n.watermark.data=t.data,n.watermark.type=t.type||s.WatermarkType.TEXT,t.width&&(n.watermark.width=t.width),t.height&&(n.watermark.height=t.height),n.watermark.color=t.color||i,n.watermark.opacity=t.opacity||r,n.watermark.size=t.size||l,n.watermark.font=t.font||a,n.watermark.repeat=!!t.repeat,t.numberType&&(n.watermark.numberType=t.numberType),n.watermark.gap=t.gap||c,this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1})}deleteWatermark(){if(this.draw.isReadonly())return;const e=this.draw.getOptions();e.watermark&&e.watermark.data&&(e.watermark={...Ii},this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1}))}image(t){if(this.draw.isReadonly()||this.draw.isDisabled())return null;const{startIndex:n,endIndex:i}=this.range.getRange();if(!~n&&!~i)return null;const l=t.id||ft();return this.insertElementList([{...t,id:l,type:s.ElementType.IMAGE}]),l}search(t,e){this.searchManager.setSearchKeyword(t,e),this.draw.render({isSubmitHistory:!1})}searchNavigatePre(){this.searchManager.searchNavigatePre()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}searchNavigateNext(){this.searchManager.searchNavigateNext()!==null&&this.draw.render({isSetCursor:!1,isSubmitHistory:!1,isCompute:!1,isLazy:!1})}getSearchNavigateInfo(){return this.searchManager.getSearchNavigateInfo()}replace(t,e){this.draw.getSearch().replace(t,e)}async print(){const{scale:t,printPixelRatio:e,paperDirection:n,width:i,height:l}=this.options;t!==1&&this.draw.setPageScale(1);const r=await this.draw.getDataURL({pixelRatio:e,mode:s.EditorMode.PRINT});wT(r,{width:i,height:l,direction:n}),t!==1&&this.draw.setPageScale(t)}replaceImageElement(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==s.ElementType.IMAGE||(i.value=t,this.draw.render({isSetCursor:!1}))}saveAsImageElement(){const{startIndex:t}=this.range.getRange(),n=this.draw.getElementList()[t];!n||n.type!==s.ElementType.IMAGE||Ss(n.value,`${n.id}.png`)}setImageCrop(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];!i||i.type!==s.ElementType.IMAGE||(i.imgCrop=t,this.draw.render({isSetCursor:!1,isCompute:!1}))}setImageCaption(t){const{startIndex:e}=this.range.getRange(),i=this.draw.getElementList()[e];i?.type===s.ElementType.IMAGE&&(i.imgCaption=t,this.draw.render({isSetCursor:!1}))}changeImageDisplay(t,e){if(t.imgDisplay===e)return;t.imgDisplay=e;const{startIndex:n,endIndex:i}=this.range.getRange();if(e===s.ImageDisplay.SURROUND||e===s.ImageDisplay.FLOAT_TOP||e===s.ImageDisplay.FLOAT_BOTTOM){const l=this.position.getPositionList(),{pageNo:r,coordinate:{leftTop:a}}=l[n];t.imgFloatPosition={pageNo:r,x:a[0],y:a[1]}}else delete t.imgFloatPosition;this.draw.getPreviewer().clearResizer(),this.draw.render({isSetCursor:!0,curIndex:i})}getImage(t){return this.draw.getDataURL(t)}getPageMode(){return this.options}getOptions(){return this.options}getValue(t){return this.draw.getValue(t)}getValueAsync(t){return this.draw.getWorkerManager().getValue(t)}getAreaValue(t){return this.draw.getArea().getAreaValue(t)}getHTML(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:Wn(e,t).innerHTML,main:Wn(n,t).innerHTML,footer:Wn(i,t).innerHTML}}getText(){const t=this.options,e=this.draw.getHeaderElementList(),n=this.draw.getOriginalMainElementList(),i=this.draw.getFooterElementList();return{header:In(e,t),main:In(n,t),footer:In(i,t)}}getWordCount(){return this.workerManager.getWordCount()}getCursorPosition(){return this.position.getCursorPosition()}getRemainingContentHeight(){if(!this.draw.getIsPagingMode())return 0;const t=this.draw.getPageRowList(),e=t.length-1,i=(t[e]||[]).reduce((c,d)=>c+d.height+(d.offsetY||0),0),l=this.draw.getHeight(),r=this.draw.getMainOuterHeight(),a=l-(r+i);return a>0?a:0}computeElementListHeight(t){if(!t.length)return 0;const e=this.draw.getInnerWidth();if(e<=0)return 0;const n=ct(t);jt(n,{isHandleFirstElement:!1,editorOptions:this.options});const i=Oi(n);return this.draw.computeRowList({innerWidth:e,elementList:n,surroundElementList:i}).reduce((r,a)=>r+a.height+(a.offsetY||0),0)}getRange(){return ct(this.range.getRange())}getRangeText(){return this.range.toString()}getRangeContext(){const t=this.range.getRange(),{startIndex:e,endIndex:n}=t;if(!~e&&!~n)return null;const i=e===n,l=this.range.toString(),r=wt(this.range.getSelectionElementList()||[]),a=this.draw.getElementList(),c=dn(a[i?e:e+1],{extraPickAttrs:["id","controlComponent"]}),d=dn(a[n],{extraPickAttrs:["id","controlComponent"]}),u=this.draw.getRowList(),R=this.position.getPositionList(),h=R[e],g=R[n],T=h?.pageNo,f=g?.pageNo,p=h?.rowIndex,C=g?.rowIndex,I=u[p],m=u[C];let P=0,E=0;this.draw.getCursor().getHitLineStartIndex()||(P=I?.elementList[0]?.value===K?h?.index-I?.startIndex:h?.index-I?.startIndex+1),h===g?E=P:E=m.elementList[0]?.value===K?g.index-m.startIndex:g.index-m.startIndex+1;const M=[],F=this.draw.getOriginalHeight(),y=this.draw.getOriginalPageGap(),Y=this.position.getSelectionPositionList();if(Y){let U=null,Q=0,v=null;for(let w=0;w<Y.length;w++){const{rowNo:q,pageNo:G,coordinate:{leftTop:H,rightTop:z},lineHeight:_}=Y[w];U===null||U!==q?(v&&M.push(v),v={x:H[0],y:H[1]+G*(F+y),width:z[0]-H[0],height:_},U=q,Q=H[0]):v.width=z[0]-Q,w===Y.length-1&&v&&M.push(v)}}else{const Q=this.position.getPositionList()[n],{coordinate:{rightTop:v},pageNo:w,lineHeight:q}=Q;M.push({x:v[0],y:v[1]+w*(F+y),width:0,height:q})}const D=this.draw.getZone().getZone(),{isTable:O,trIndex:b,tdIndex:V,index:X}=this.position.getPositionContext();let N=null;if(O){const Q=this.draw.getOriginalElementList()[X]||null;Q&&(N=wt([Q])[0])}let L=null,W=null,S=e-1;for(;S>0;){const U=a[S],Q=a[S-1];if(U.titleId&&U.titleId!==Q?.titleId){L=U.titleId,W=R[S].pageNo;break}S--}return ct({isCollapsed:i,startElement:c,endElement:d,startPageNo:T,endPageNo:f,startRowNo:p,endRowNo:C,startColNo:P,endColNo:E,rangeRects:M,zone:D,isTable:O,trIndex:b??null,tdIndex:V??null,tableElement:N,selectionText:l,selectionElementList:r,titleId:L,titleStartPageNo:W})}getRangeRow(){const t=this.range.getRangeRowElementList();return t?wt(t):null}getRangeParagraph(){const t=this.range.getRangeParagraphElementList();return t?wt(t):null}getKeywordRangeList(t){return this.range.getKeywordRangeList(t)}getKeywordContext(t){const e=this.getKeywordRangeList(t);if(!e.length)return null;const n=[],i=this.position.getOriginalMainPositionList(),l=this.draw.getOriginalMainElementList();for(let r=0;r<e.length;r++){const a=e[r],{startIndex:c,endIndex:d,tableId:u,startTrIndex:R,startTdIndex:h}=a;let g=i;if(a.tableId){const p=l.find(C=>C.id===u);p&&(g=p.trList?.[R]?.tdList?.[h]?.positionList||[])}const T=ct(g[c]),f=ct(g[d]);n.push({range:a,startPosition:T,endPosition:f})}return n}pageMode(t){this.draw.setPageMode(t)}pageScale(t){t!==this.options.scale&&this.draw.setPageScale(t)}pageScaleRecovery(){const{scale:t}=this.options;t!==1&&this.draw.setPageScale(1)}pageScaleMinus(){const{scale:t}=this.options,e=t*10-1;e>=5&&this.draw.setPageScale(e/10)}pageScaleAdd(){const{scale:t}=this.options,e=t*10+1;e<=30&&this.draw.setPageScale(e/10)}paperSize(t,e){this.draw.setPaperSize(t,e)}paperDirection(t){this.draw.setPaperDirection(t)}getPaperMargin(){return this.options.margins}setPaperMargin(t){return this.draw.setPaperMargin(t)}setMainBadge(t){this.draw.getBadge().setMainBadge(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}setAreaBadge(t){this.draw.getBadge().setAreaBadgeMap(t),this.draw.render({isCompute:!1,isSubmitHistory:!1})}insertElementList(t,e={}){if(!t.length||this.draw.isReadonly()||this.draw.isDisabled())return;const{isReplace:i=!0,ignoreContextKeys:l}=e;i||this.range.shrinkRange(),console.log(t,"payload");const r=ct(t),{startIndex:a}=this.range.getRange(),c=this.draw.getElementList();oe(c,r,a,{ignoreContextKeys:l,isBreakWhenWrap:!0,editorOptions:this.options}),console.log(r,"cloneElementList"),this.draw.insertElementList(r,e),setTimeout(()=>{console.log(c,"elementList")},500)}appendElementList(t,e){!t.length||this.draw.isReadonly()||this.draw.appendElementList(ct(t),e)}updateElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;const i=[];function l(a,c=!1){let d=0;for(;d<a.length;){const u=a[d];if(d++,u.type===s.ElementType.TABLE){const R=u.trList;for(let h=0;h<R.length;h++){const g=R[h];for(let T=0;T<g.tdList.length;T++){const f=g.tdList[T];l(f.value,c)}}}u.type===s.ElementType.CONTROL&&u.control?.value&&l(u.control.value,!0),(e&&u.id===e||n&&u.conceptId===n)&&i.push({elementList:a,index:d-1,isInsideControl:c})}}const r=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);if(i.length){for(let a=0;a<i.length;a++){const{elementList:c,index:d,isInsideControl:u}=i[a],R=c[d],h=R.controlId&&R.controlComponent===s.ControlComponent.VALUE;if(u||h){if(Object.assign(R,t.properties),R.id){const g=cc(R.id);g&&Object.assign(g,t.properties)}}else{const g=wt([{...R,...t.properties}],{extraPickAttrs:["id"]});g.length>0&&g[0]?(an(cn,R,g[0]),jt(g,{isHandleFirstElement:!1,editorOptions:this.options}),c[d]=g[0]):Object.assign(R,t.properties)}}this.draw.render({isSetCursor:!1})}}deleteElementById(t){const{id:e,conceptId:n}=t;if(!e&&!n)return;let i=!1;function l(a){let c=0;for(;c<a.length;){const d=a[c];if(d.type===s.ElementType.TABLE){const u=d.trList;for(let R=0;R<u.length;R++){const h=u[R];for(let g=0;g<h.tdList.length;g++){const T=h.tdList[g];l(T.value)}}}d.type===s.ElementType.CONTROL&&d.control?.value&&l(d.control.value),(e&&d.id===e||n&&d.conceptId===n)&&(i=!0,a.splice(c,1),c--),c++}}const r=[this.draw.getOriginalMainElementList(),this.draw.getHeaderElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);i&&this.draw.render({isSetCursor:!1})}getElementById(t){const{id:e,conceptId:n}=t,i=[];if(!e&&!n)return i;const l=a=>{let c=0;for(;c<a.length;){const d=a[c];if(c++,d.type===s.ElementType.TABLE){const u=d.trList;for(let R=0;R<u.length;R++){const h=u[R];for(let g=0;g<h.tdList.length;g++){const T=h.tdList[g];l(T.value)}}}e&&d.id!==e||n&&d.conceptId!==n||i.push(d)}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);return wt(i,{extraPickAttrs:["id"]})}setValue(t,e){this.draw.setValue(t,e)}removeControl(t){if(t?.id||t?.conceptId){const{id:e,conceptId:n}=t;let i=!1;const l=a=>{let c=a.length-1;for(;c>=0;){const d=a[c];if(d.type===s.ElementType.TABLE){const u=d.trList;for(let R=0;R<u.length;R++){const h=u[R];for(let g=0;g<h.tdList.length;g++){const T=h.tdList[g];l(T.value)}}}c--,!(!d.control||e&&d.controlId!==e||n&&d.control.conceptId!==n)&&(i=!0,a.splice(c+1,1))}},r=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const a of r)l(a);i&&this.draw.render({isSetCursor:!1})}else{const{startIndex:e,endIndex:n}=this.range.getRange();if(e!==n||!this.draw.getElementList()[e].controlId)return;const a=this.draw.getControl().removeControl(e);if(a===null)return;this.range.setRange(a,a),this.draw.render({curIndex:a})}}translate(t){return this.i18n.t(t)}setLocale(t){this.i18n.setLocale(t)}getLocale(){return this.i18n.getLocale()}getCatalog(){return this.workerManager.getCatalog()}locationCatalog(t){const e=this.draw.getOriginalElementList();function n(C,I){for(let m=0;m<C.length;m++){const P=C[m];if(P.type===s.ElementType.TABLE){const E=P.trList;for(let M=0;M<E.length;M++){const F=E[M];for(let y=0;y<F.tdList.length;y++){const Y=F.tdList[y],D=n(Y.value,I);if(D)return{...D,isTable:!0,index:m,trIndex:M,tdIndex:y,tdId:Y.id,trId:F.id,tableId:P.id}}}}if(P.titleId===I){let E=m;for(;E<C.length;){if(C[E+1]?.titleId!==I)return{isTable:!1,startIndex:E,endIndex:E};E++}}}return null}const i=n(e,t);if(!i)return;const{isTable:l,index:r,startTdIndex:a,endTdIndex:c,startTrIndex:d,endTrIndex:u,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f,endIndex:p}=i;this.position.setPositionContext({isTable:l,index:r,trIndex:R,tdIndex:h,tdId:g,trId:T,tableId:f}),this.range.setRange(p,p,f,a,c,d,u),this.draw.render({curIndex:p,isCompute:!1,isSubmitHistory:!1})}wordTool(){const t=this.draw.getMainElementList();let e=!1;for(let n=0;n<t.length;n++)if(t[n].value===K)for(;n+1<t.length;){const l=t[n+1];if(l.value!==K&&l.value!==oi)break;t.splice(n+1,1),e=!0}if(e)this.draw.render({isSetCursor:!1});else{const n=this.range.getIsCollapsed();this.draw.getCursor().drawCursor({isShow:n})}}setHTML(t){const{header:e,main:n,footer:i}=t,l=this.draw.getOriginalInnerWidth(),r=a=>a!==void 0?Yn(a,{innerWidth:l}):void 0;this.setValue({header:r(e),main:r(n),footer:r(i)})}setGroup(){return this.draw.isReadonly()?null:this.draw.getGroup().setGroup()}deleteGroup(t){this.draw.isReadonly()||this.draw.getGroup().deleteGroup(t)}getGroupIds(){return this.draw.getWorkerManager().getGroupIds()}locationGroup(t){const e=this.draw.getOriginalMainElementList(),n=this.draw.getGroup().getContextByGroupId(e,t);if(!n)return;const{isTable:i,index:l,trIndex:r,tdIndex:a,tdId:c,trId:d,tableId:u,endIndex:R}=n;this.position.setPositionContext({isTable:i,index:l,trIndex:r,tdIndex:a,tdId:c,trId:d,tableId:u}),this.range.setRange(R,R),this.draw.render({curIndex:R,isCompute:!1,isSubmitHistory:!1})}setZone(t){this.draw.getZone().setZone(t)}getControlValue(t){return this.draw.getControl().getValueById(t)}getButtonContent(t){const{controlId:e}=t;if(!e)return null;const n=this.findButtonControlContext(e);return n?this.getButtonContentResult(this.getButtonBusinessValue(n)):null}setButtonContent(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const{controlId:n,mode:i,isSubmitHistory:l=!0}=t;if(!n)return;const r=this.findButtonControlContext(n);if(!r)return;const a=this.getButtonBusinessValue(r),c=this.normalizeButtonContentValue(t.value),d=i==="append"?this.appendButtonContentValue(a,c):c;this.removeButtonBusinessElements(r);const u=this.findButtonControlContext(n);if(!u)return;const R=this.createButtonBusinessElements(u,d),h=this.replaceButtonRenderedValue(u,R,d);this.syncButtonPlaceholderElements(u.elementList,n,u.element.control?.placeholder||u.element.control?.buttonLabel||u.element.control?.label||""),l||this.historyManager.recovery(),this.draw.render({curIndex:h,isSubmitHistory:l,isSetCursor:!0})}setControlValue(t){this.draw.getControl().setValueListById([t])}setControlValueList(t){this.draw.getControl().setValueListById(t)}setControlExtension(t){this.draw.getControl().setExtensionListById([t])}setControlExtensionList(t){this.draw.getControl().setExtensionListById(t)}setControlProperties(t){this.draw.getControl().setPropertiesListById([t])}setControlPropertiesList(t){this.draw.getControl().setPropertiesListById(t)}setControlHighlight(t){this.draw.getControl().setHighlightList(t),this.draw.render({isSubmitHistory:!1})}setControlQualityMarks(t){this.draw.getControl().setQualityMarks(t),this.draw.render({isSetCursor:!1,isSubmitHistory:!1})}updateOptions(t){const e=Lo(t);Object.entries(e).forEach(([n,i])=>{Reflect.set(this.options,n,i)}),this.forceUpdate()}setFormModeTrace(t){Object.assign(this.options.modeRule.form,t),this.forceUpdate()}getControlList(){return this.draw.getControl().getList()}locationControl(t,e){if(!t)return;function n(r,a,c){let d=0;for(;d<r.length;){const u=r[d];if(d++,u.type===s.ElementType.TABLE){const h=u.trList;for(let g=0;g<h.length;g++){const T=h[g];for(let f=0;f<T.tdList.length;f++){const p=T.tdList[f],C=n(p.value,a,c);if(C)return{...C,positionContext:{isTable:!0,index:d-1,trIndex:g,tdIndex:f,tdId:p.id,trId:T.id,tableId:u.id}}}}}if(!c(u))continue;let R=d-1;if(e?.position===s.LocationPosition.OUTER_AFTER){if(!(u.controlComponent===s.ControlComponent.POSTFIX&&r[d+1]?.controlComponent!==s.ControlComponent.POST_TEXT))continue}else if(e?.position===s.LocationPosition.OUTER_BEFORE)R-=1;else if(e?.position===s.LocationPosition.AFTER){if(R-=1,u.controlComponent!==s.ControlComponent.PLACEHOLDER&&u.controlComponent!==s.ControlComponent.POSTFIX&&u.controlComponent!==s.ControlComponent.POST_TEXT)continue}else if(u.controlComponent!==s.ControlComponent.PREFIX&&u.controlComponent!==s.ControlComponent.PRE_TEXT||r[d]?.controlComponent===s.ControlComponent.PREFIX||r[d]?.controlComponent===s.ControlComponent.PRE_TEXT)continue;return{zone:a,range:{startIndex:R,endIndex:R},positionContext:{isTable:!1}}}return null}const i=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}],l=[r=>r.controlId===t,r=>r.control?.conceptId===t,r=>r.control?.code===t];for(let r=0;r<l.length;r++)for(const a of i){const c=n(a.elementList,a.zone,l[r]);if(c){this.setZone(c.zone),this.position.setPositionContext(c.positionContext),this.range.replaceRange(c.range),this.draw.render({curIndex:c.range.startIndex,isCompute:!1,isSubmitHistory:!1});return}}}insertTextField(t){if(this.draw.isReadonly()||this.draw.isDisabled()||!t)return;const n=ct(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Vn(l,i);if(!r)return;const a=[...pn,...ue,...Nn,...cn];an(a,r,n),this.draw.insertElementTextField([n])}insertControl(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=ct(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Vn(l,i);if(!r)return;const a=l[i],c=a?.controlComponent===s.ControlComponent.POSTFIX||a?.controlComponent===s.ControlComponent.POSTTEXTFIX;let d=!1;if(a?.controlId&&!c)for(let R=i;R>=0;R--){const h=l[R];if(h.controlId!==a.controlId)break;if(h.controlComponent===s.ControlComponent.PRETEXTFIX||h.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){h.control?.type===s.ControlType.TEXTFIELD&&(d=!0);break}}if(!d&&!c){const R=l[i-1];if(R?.controlId)for(let h=i-1;h>=0;h--){const g=l[h];if(g.controlId!==R.controlId)break;if(g.controlComponent===s.ControlComponent.PRETEXTFIX||g.controlComponent===s.ControlComponent.PRETEXTFIX_TEXT){g.control?.type===s.ControlType.TEXTFIELD&&(d=!0);break}}}if(d&&t.control?.type===s.ControlType.TEXTFIELD)return;const u=[...pn,...ue,...Nn,...cn];an(u,r,n),this.draw.insertElementList([n])}jumpControl(t){this.draw.getControl().initNextControl({direction:t?.direction})}getContainer(){return this.draw.getContainer()}getTitleValue(t){const{conceptId:e}=t,n=[],i=(r,a)=>{let c=0;for(;c<r.length;){const d=r[c];if(c++,d.type===s.ElementType.TABLE){const h=d.trList;for(let g=0;g<h.length;g++){const T=h[g];for(let f=0;f<T.tdList.length;f++){const p=T.tdList[f];i(p.value,a)}}}if(d?.title?.conceptId!==e)continue;const u=[];let R=c;for(;R<r.length;){const h=r[R];if(R++,d.titleId!==h.titleId){if(h.level&&Ci[h.level]<=Ci[d.level])break;u.push(h)}}n.push({...d.title,value:In(u),elementList:wt(u),zone:a}),c=R}},l=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:r,elementList:a}of l)i(a,r);return n}getPositionContextByEvent(t,e={}){const n=t.target?.dataset.index;if(!n)return null;const{isMustDirectHit:i=!0}=e,l=Number(n),r=this.position.getPositionByXY({x:t.offsetX,y:t.offsetY,pageNo:l}),{isDirectHit:a,isTable:c,index:d,trIndex:u,tdIndex:R,tdValueIndex:h,zone:g}=r;if(i&&!a||g&&g!==this.zone.getZone())return null;let T=null,f=null;const p=this.draw.getOriginalElementList();let C=null;const I=this.position.getOriginalPositionList();if(c){const P=p[d].trList?.[u].tdList[R];f=P?.value[h]||null,C=P?.positionList?.[h]||null,T={element:p[d],trIndex:u,tdIndex:R}}else f=p[d]||null,C=I[d]||null;let m=null;if(C){const{pageNo:P,coordinate:{leftTop:E,rightTop:M},lineHeight:F}=C,y=this.draw.getOriginalHeight(),Y=this.draw.getOriginalPageGap();m={x:E[0],y:E[1]+P*(y+Y),width:M[0]-E[0],height:F}}return{pageNo:l,element:f,rangeRect:m,tableInfo:T}}insertTitle(t){if(this.draw.isReadonly()||this.draw.isDisabled())return;const n=ct(t),{startIndex:i}=this.range.getRange(),l=this.draw.getElementList(),r=Vn(l,i);if(!r)return;const a=[...pn,...ue,...Nn,...cn];n.valueList?.forEach(c=>{an(a,r,c)}),this.draw.insertElementList([n])}focus(t){const{position:e=s.LocationPosition.AFTER,isMoveCursorToVisible:n=!0,rowNo:i,range:l}=t||{};let r=-1;if(l)this.range.replaceRange(l),r=e===s.LocationPosition.BEFORE?l.startIndex:l.endIndex;else if(di(i)){const c=this.draw.getOriginalRowList();if(r=e===s.LocationPosition.BEFORE?c[i]?.startIndex:c[i+1]?.startIndex-1,!di(r))return;this.range.setRange(r,r)}else r=e===s.LocationPosition.BEFORE?0:this.draw.getOriginalMainElementList().length-1,this.range.setRange(r,r);const a={isCompute:!1,isSetCursor:!1,isSubmitHistory:!1};n&&~r&&this.range.getIsCollapsed()&&(a.curIndex=r,a.isSetCursor=!0),this.draw.render(a)}insertArea(t){return this.draw.getArea().insertArea(t)}setAreaValue(t){return this.draw.getArea().setAreaValue(t)}setAreaProperties(t){this.draw.getArea().setAreaProperties(t)}locationArea(t,e){if(e?.isAppendLastLineBreak&&e?.position===s.LocationPosition.OUTER_AFTER){const l=this.draw.getOriginalMainElementList();l[l.length-1].areaId===t&&this.draw.appendElementList([{value:K}],{isSubmitHistory:!1})}const n=this.draw.getArea().getContextByAreaId(t,e);if(!n)return;const{range:{endIndex:i}}=n;this.position.setPositionContext({isTable:!1}),this.range.setRange(i,i),this.draw.render({curIndex:i,isSetCursor:!0,isCompute:!1,isSubmitHistory:!1})}clearGraffiti(){this.draw.getGraffiti().clear(),this.draw.isGraffitiMode()&&this.draw.render({isCompute:!1,isSetCursor:!1,isSubmitHistory:!1})}getMacroValue(t){const{id:e,dictCode:n,label:i,areaId:l}=t,r=[],a=(d,u)=>{for(const R of d){if(R.type===s.ElementType.TABLE){const g=R.trList;for(const T of g)for(const f of T.tdList)a(f.value,u);continue}if(R.type!==s.ElementType.MACRO&&R.type!==s.ElementType.CUSTOM_MACRO&&R.type!==s.ElementType.REUSABLE_ITEM||e&&R.id!==e||n&&R.dictCode!==n||i&&R.label!==i||l&&R.areaId!==l)continue;const h={id:R.id,type:R.type,label:R.label,dictCode:R.dictCode,zone:u};R.type===s.ElementType.MACRO?h.value=R.value:R.type===s.ElementType.CUSTOM_MACRO?(h.macroConfig=R.macroConfig,h.value=R.macroConfig?.value):R.type===s.ElementType.REUSABLE_ITEM&&(h.reusableItemConfig=R.reusableItemConfig,h.value=R.reusableItemConfig?.value),r.push(h)}},c=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:d,elementList:u}of c)a(u,d);return r}getMacroList(){const t=[],e=i=>{for(const l of i){if(l.type===s.ElementType.TABLE){const r=l.trList;for(const a of r)for(const c of a.tdList)e(c.value);continue}(l.type===s.ElementType.MACRO||l.type===s.ElementType.CUSTOM_MACRO||l.type===s.ElementType.REUSABLE_ITEM)&&t.push(l)}},n=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const i of n)e(i);return t}setMacroValue(t){const{id:e,dictCode:n,label:i,areaId:l,value:r,code:a,isSubmitHistory:c=!0}=t;let d=!1;const u=h=>{for(let g=0;g<h.length;g++){const T=h[g];if(T.type===s.ElementType.TABLE){const f=T.trList;for(const p of f)for(const C of p.tdList)u(C.value);continue}T.type!==s.ElementType.MACRO&&T.type!==s.ElementType.CUSTOM_MACRO&&T.type!==s.ElementType.REUSABLE_ITEM||e&&T.id!==e||n&&T.dictCode!==n||i&&T.label!==i||l&&T.areaId!==l||(d=!0,T.type===s.ElementType.MACRO?T.value=r:T.type===s.ElementType.CUSTOM_MACRO?T.macroConfig?(T.macroConfig.value=r,a!==void 0&&(T.macroConfig.code=a)):T.macroConfig={type:"text",value:r}:T.type===s.ElementType.REUSABLE_ITEM&&(T.reusableItemConfig?T.reusableItemConfig.value=r:T.reusableItemConfig={value:r}))}},R=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const h of R)u(h);d&&this.draw.render({isSubmitHistory:c,isSetCursor:!1})}setMacroValueList(t){if(!t.length)return;let e=!1,n=!1;const i=r=>{for(let a=0;a<r.length;a++){const c=r[a];if(c.type===s.ElementType.TABLE){const g=c.trList;for(const T of g)for(const f of T.tdList)i(f.value);continue}if(c.type!==s.ElementType.MACRO&&c.type!==s.ElementType.CUSTOM_MACRO&&c.type!==s.ElementType.REUSABLE_ITEM)continue;const d=t.find(g=>g.id&&c.id===g.id||g.dictCode&&c.dictCode===g.dictCode||g.label&&c.label===g.label||g.areaId&&c.areaId===g.areaId);if(!d)continue;const{value:u,code:R,isSubmitHistory:h=!0}=d;e=!0,h&&(n=!0),c.type===s.ElementType.MACRO?c.value=u:c.type===s.ElementType.CUSTOM_MACRO?c.macroConfig?(c.macroConfig.value=u,R!==void 0&&(c.macroConfig.code=R)):c.macroConfig={type:"text",value:u}:c.type===s.ElementType.REUSABLE_ITEM&&(c.reusableItemConfig?c.reusableItemConfig.value=u:c.reusableItemConfig={value:u})}},l=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const r of l)i(r);e&&(n||this.draw.getHistoryManager().recovery(),this.draw.render({isSubmitHistory:n,isSetCursor:!1}))}updateMacroProperties(t){const{id:e,dictCode:n,label:i,areaId:l,properties:r,isSubmitHistory:a=!0}=t;let c=!1;const d=R=>{for(let h=0;h<R.length;h++){const g=R[h];if(g.type===s.ElementType.TABLE){const T=g.trList;for(const f of T)for(const p of f.tdList)d(p.value);continue}g.type!==s.ElementType.MACRO&&g.type!==s.ElementType.CUSTOM_MACRO&&g.type!==s.ElementType.REUSABLE_ITEM||e&&g.id!==e||n&&g.dictCode!==n||i&&g.label!==i||l&&g.areaId!==l||(c=!0,Object.assign(g,r))}},u=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];for(const R of u)d(R);c&&this.draw.render({isSubmitHistory:a,isSetCursor:!1})}locationMacro(t){const{id:e,dictCode:n,label:i,areaId:l}=t,r=(c,d)=>{for(let u=0;u<c.length;u++){const R=c[u];if(R.type===s.ElementType.TABLE){const h=R.trList;for(let g=0;g<h.length;g++){const T=h[g];for(let f=0;f<T.tdList.length;f++){const p=T.tdList[f],C=r(p.value,d);if(C)return{...C,isTable:!0,index:u,trIndex:g,tdIndex:f,tableId:R.tableId,trId:T.id,tdId:p.id}}}}if(!(R.type!==s.ElementType.MACRO&&R.type!==s.ElementType.CUSTOM_MACRO&&R.type!==s.ElementType.REUSABLE_ITEM)&&!(e&&R.id!==e)&&!(n&&R.dictCode!==n)&&!(i&&R.label!==i)&&!(l&&R.areaId!==l))return{zone:d,index:u}}return null},a=[{zone:s.EditorZone.HEADER,elementList:this.draw.getHeaderElementList()},{zone:s.EditorZone.MAIN,elementList:this.draw.getOriginalMainElementList()},{zone:s.EditorZone.FOOTER,elementList:this.draw.getFooterElementList()}];for(const{zone:c,elementList:d}of a){const u=r(d,c);if(u){this.setZone(u.zone),this.position.setPositionContext({isTable:u.isTable||!1,index:u.index,trIndex:u.trIndex,tdIndex:u.tdIndex,tableId:u.tableId,trId:u.trId,tdId:u.tdId}),this.range.replaceRange({startIndex:u.index,endIndex:u.index}),this.draw.render({curIndex:u.index,isCompute:!1,isSubmitHistory:!1});break}}}insertSubTemplate(t){const{label:e,templateId:n,content:i,conditions:l,relation:r="and",isSubmitHistory:a=!0}=t,c={id:ft(),value:e,type:s.ElementType.SUB_TEMPLATE,label:e,templateId:n,subTemplateContent:i?.map(d=>ct(d)),subTemplateRelation:r,subTemplateConditions:l?.map(d=>({...d})),subTemplateExpanded:!1};this.insertElementList([c],{isSubmitHistory:a})}updateSubTemplate(t){const{id:e,properties:n,isSubmitHistory:i=!0}=t;if(!e)return;const l=[this.draw.getHeaderElementList(),this.draw.getOriginalMainElementList(),this.draw.getFooterElementList()];let r=!1;for(let a=0;a<l.length;a++)ps(l[a],c=>{c.id!==e||c.type!==s.ElementType.SUB_TEMPLATE||(Object.assign(c,{...n,value:n.label??c.value,subTemplateContent:n.subTemplateContent?n.subTemplateContent.map(d=>ct(d)):c.subTemplateContent?.map(d=>ct(d)),subTemplateConditions:n.subTemplateConditions?n.subTemplateConditions.map(d=>({...d})):c.subTemplateConditions?.map(d=>({...d}))}),r=!0)});r&&this.draw.render({isSubmitHistory:i,isCompute:!0})}expandSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,l=this.draw.getOriginalMainElementList();for(let r=0;r<l.length;r++){const a=l[r];if(a.type===s.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){const c=n||a.subTemplateContent;if(!c?.length){console.warn("子模板内容为空,无法展开");return}a.subTemplateExpanded=!0,a.hide=!0;const d=ct(c);jt(d,{isHandleFirstElement:!1,editorOptions:this.options});for(let u=0;u<d.length;u++)d[u].subTemplateParentId=a.id;l.splice(r+1,0,...d),this.draw.render({isSubmitHistory:i,isCompute:!0});return}}}collapseSubTemplate(t){const{id:e,isSubmitHistory:n=!0}=t,i=this.draw.getOriginalMainElementList();for(let l=0;l<i.length;l++){const r=i[l];if(r.type===s.ElementType.SUB_TEMPLATE&&(!e||r.id===e)){r.subTemplateExpanded=!1,r.hide=!1;let a=l+1;for(;a<i.length&&i[a].subTemplateParentId===r.id;)a++;a>l+1&&i.splice(l+1,a-l-1),this.draw.render({isSubmitHistory:n,isCompute:!0});return}}}toggleSubTemplate(t){const{id:e,content:n,isSubmitHistory:i=!0}=t,l=this.draw.getOriginalMainElementList();for(let r=0;r<l.length;r++){const a=l[r];if(a.type===s.ElementType.SUB_TEMPLATE&&(!e||a.id===e)){a.subTemplateExpanded?this.collapseSubTemplate({id:e,isSubmitHistory:i}):this.expandSubTemplate({id:e,content:n,isSubmitHistory:i});return}}}}class HT{rangeStyleChange;visiblePageNoListChange;intersectionPageNoChange;pageSizeChange;pageScaleChange;saved;contentChange;controlChange;controlContentChange;pageModeChange;zoneChange;constructor(){this.rangeStyleChange=null,this.visiblePageNoListChange=null,this.intersectionPageNoChange=null,this.pageSizeChange=null,this.pageScaleChange=null,this.saved=null,this.contentChange=null,this.controlChange=null,this.controlContentChange=null,this.pageModeChange=null,this.zoneChange=null}}class _T{contextMenu;contextMenuList;getContextMenuList;shortcutList;langMap;constructor(t){const{contextMenu:e,shortcut:n,i18n:i}=t;this.contextMenu=e,this.contextMenuList=e.registerContextMenuList.bind(e),this.getContextMenuList=e.getContextMenuList.bind(e),this.shortcutList=n.registerShortcutList.bind(n),this.langMap=i.registerLangMap.bind(i)}disposeContextMenu(){this.contextMenu.dispose()}}const Ul={SELECTED_TEXT:"%s"},Jn={GLOBAL:{CUT:"globalCut",COPY:"globalCopy",PASTE:"globalPaste",SELECT_ALL:"globalSelectAll",PRINT:"globalPrint"},CONTROL:{DELETE:"controlDelete",EDIT_ATTRIBUTE:"controlEditAttribute",COPY:"controlCopy",PASTE:"controlPaste"},HYPERLINK:{DELETE:"hyperlinkDelete",CANCEL:"hyperlinkCancel",EDIT:"hyperlinkEdit"},IMAGE:{CHANGE:"imageChange",SAVE_AS:"imageSaveAs",TEXT_WRAP:"imageTextWrap",TEXT_WRAP_EMBED:"imageTextWrapEmbed",TEXT_WRAP_UP_DOWN:"imageTextWrapUpDown",TEXT_WRAP_SURROUND:"imageTextWrapSurround",TEXT_WRAP_FLOAT_TOP:"imageTextWrapFloatTop",TEXT_WRAP_FLOAT_BOTTOM:"imageTextWrapFloatBottom"},TABLE:{BORDER:"border",BORDER_ALL:"tableBorderAll",BORDER_EMPTY:"tableBorderEmpty",BORDER_DASH:"tableBorderDash",BORDER_EXTERNAL:"tableBorderExternal",BORDER_INTERNAL:"tableBorderInternal",BORDER_TD:"tableBorderTd",BORDER_TD_TOP:"tableBorderTdTop",BORDER_TD_RIGHT:"tableBorderTdRight",BORDER_TD_BOTTOM:"tableBorderTdBottom",BORDER_TD_LEFT:"tableBorderTdLeft",BORDER_TD_FORWARD:"tableBorderTdForward",BORDER_TD_BACK:"tableBorderTdBack",VERTICAL_ALIGN:"tableVerticalAlign",VERTICAL_ALIGN_TOP:"tableVerticalAlignTop",VERTICAL_ALIGN_MIDDLE:"tableVerticalAlignMiddle",VERTICAL_ALIGN_BOTTOM:"tableVerticalAlignBottom",INSERT_ROW_COL:"tableInsertRowCol",INSERT_TOP_ROW:"tableInsertTopRow",INSERT_BOTTOM_ROW:"tableInsertBottomRow",INSERT_LEFT_COL:"tableInsertLeftCol",INSERT_RIGHT_COL:"tableInsertRightCol",DELETE_ROW_COL:"tableDeleteRowCol",DELETE_ROW:"tableDeleteRow",DELETE_COL:"tableDeleteCol",DELETE_TABLE:"tableDeleteTable",MERGE_CELL:"tableMergeCell",CANCEL_MERGE_CELL:"tableCancelMergeCell",TABLE_PROPERTIES:"tableProperties"}},{CONTROL:{DELETE:AT,EDIT_ATTRIBUTE:kT,COPY:GT,PASTE:xT}}=Jn;function BT(o,t){if(t!==s.EditorMode.EDIT)return!1;const n=o?.control?.type,i=o?.controlComponent,l=n===s.ControlType.TEXT||n===s.ControlType.TEXTFIELD||n===s.ControlType.NUMBER||n===s.ControlType.SELECT||n===s.ControlType.DATE||n===s.ControlType.CHECKBOX||n===s.ControlType.RADIO||n===s.ControlType.BUTTON,r=i==="prefix"||i==="preText"||i==="preTextFix"||i==="textFixLabel"||n===s.ControlType.BUTTON&&(i==="value"||i==="placeholder");return l&&r}function wl(o){return o.hitElement||o.hitTableElement}const JT=[{key:GT,name:"复制控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&BT(o.startElement,o.options.mode),callback:(o,t)=>{const e=t.startElement?.controlId;e&&o.executeCopyControl(e)}},{key:xT,name:"粘贴控件",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.editorTextFocus&&o.options.mode===s.EditorMode.EDIT&&Oc(),callback:o=>{o.executePasteControl()}},{key:AT,i18nPath:"contextmenu.control.delete",when:o=>!o.isReadonly&&!o.editorHasSelection&&!!o.startElement?.controlId&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeRemoveControl()}},{key:kT,i18nPath:"contextmenu.control.editAttribute",when:o=>{const t=wl(o);return!o.isReadonly&&!o.editorHasSelection&&o.options.mode===s.EditorMode.EDIT&&!!t},callback:(o,t)=>{const e=wl(t);e&&o.executeTriggerControlEditAttribute(e.controlId,e)}}],{GLOBAL:{CUT:$T,COPY:zT,PASTE:jT,SELECT_ALL:qT,PRINT:tf}}=Jn,ef=[{key:$T,i18nPath:"contextmenu.global.cut",shortCut:`${mn?"⌘":"Ctrl"} + X`,when:o=>!o.isReadonly,callback:o=>{o.executeCut()}},{key:zT,i18nPath:"contextmenu.global.copy",shortCut:`${mn?"⌘":"Ctrl"} + C`,when:o=>o.editorHasSelection||o.isCrossRowCol,callback:o=>{o.executeCopy()}},{key:jT,i18nPath:"contextmenu.global.paste",shortCut:`${mn?"⌘":"Ctrl"} + V`,when:o=>!o.isReadonly&&o.editorTextFocus,callback:o=>{o.executePaste()}},{key:qT,i18nPath:"contextmenu.global.selectAll",shortCut:`${mn?"⌘":"Ctrl"} + A`,when:o=>o.editorTextFocus,callback:o=>{o.executeSelectAll()}},{isDivider:!0},{key:tf,i18nPath:"contextmenu.global.print",icon:"print",when:()=>!0,callback:o=>{o.executePrint()}}],{HYPERLINK:{DELETE:nf,CANCEL:of,EDIT:sf}}=Jn,rf=[{key:nf,i18nPath:"contextmenu.hyperlink.delete",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:o=>{o.executeDeleteHyperlink()}},{key:of,i18nPath:"contextmenu.hyperlink.cancel",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:o=>{o.executeCancelHyperlink()}},{key:sf,i18nPath:"contextmenu.hyperlink.edit",when:o=>!o.isReadonly&&o.startElement?.type===s.ElementType.HYPERLINK,callback:(o,t)=>{const e=window.prompt(o.executeTranslate("contextmenu.hyperlink.edit"),t.startElement?.url);e&&o.executeEditHyperlink(e)}}],{IMAGE:{CHANGE:lf,SAVE_AS:af,TEXT_WRAP:cf,TEXT_WRAP_EMBED:df,TEXT_WRAP_UP_DOWN:uf,TEXT_WRAP_SURROUND:Rf,TEXT_WRAP_FLOAT_TOP:hf,TEXT_WRAP_FLOAT_BOTTOM:gf}}=Jn,Tf=[{key:lf,i18nPath:"contextmenu.image.change",icon:"image-change",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,callback:o=>{const t=document.createElement("input");t.type="file",t.accept=".png, .jpg, .jpeg",t.onchange=()=>{const e=t.files[0],n=new FileReader;n.readAsDataURL(e),n.onload=()=>{const i=n.result;o.executeReplaceImageElement(i)}},t.click()}},{key:af,i18nPath:"contextmenu.image.saveAs",icon:"image",when:o=>!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,callback:o=>{o.executeSaveAsImageElement()}},{key:cf,i18nPath:"contextmenu.image.textWrap",when:o=>!o.isReadonly&&!o.editorHasSelection&&o.startElement?.type===s.ElementType.IMAGE,childMenus:[{key:df,i18nPath:"contextmenu.image.textWrapType.embed",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.BLOCK)}},{key:uf,i18nPath:"contextmenu.image.textWrapType.upDown",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.INLINE)}},{key:Rf,i18nPath:"contextmenu.image.textWrapType.surround",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.SURROUND)}},{key:hf,i18nPath:"contextmenu.image.textWrapType.floatTop",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.FLOAT_TOP)}},{key:gf,i18nPath:"contextmenu.image.textWrapType.floatBottom",when:()=>!0,callback:(o,t)=>{o.executeChangeImageDisplay(t.startElement,s.ImageDisplay.FLOAT_BOTTOM)}}]}],{TABLE:{BORDER:ff,BORDER_ALL:mf,BORDER_EMPTY:pf,BORDER_DASH:Cf,BORDER_EXTERNAL:If,BORDER_INTERNAL:Lf,BORDER_TD:Pf,BORDER_TD_TOP:Ef,BORDER_TD_LEFT:Mf,BORDER_TD_BOTTOM:Of,BORDER_TD_RIGHT:Sf,BORDER_TD_BACK:Xf,BORDER_TD_FORWARD:Nf,VERTICAL_ALIGN:Ff,VERTICAL_ALIGN_TOP:yf,VERTICAL_ALIGN_MIDDLE:bf,VERTICAL_ALIGN_BOTTOM:Df,INSERT_ROW_COL:Vf,INSERT_TOP_ROW:Wf,INSERT_BOTTOM_ROW:Yf,INSERT_LEFT_COL:Uf,INSERT_RIGHT_COL:wf,DELETE_ROW_COL:Zf,DELETE_ROW:Qf,DELETE_COL:vf,DELETE_TABLE:Kf,MERGE_CELL:Hf,CANCEL_MERGE_CELL:_f}}=Jn,Af=[{isDivider:!0},{key:ff,i18nPath:"contextmenu.table.border",icon:"border-all",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:mf,i18nPath:"contextmenu.table.borderAll",icon:"border-all",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.ALL)}},{key:pf,i18nPath:"contextmenu.table.borderEmpty",icon:"border-empty",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.EMPTY)}},{key:Cf,i18nPath:"contextmenu.table.borderDash",icon:"border-dash",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.DASH)}},{key:If,i18nPath:"contextmenu.table.borderExternal",icon:"border-external",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.EXTERNAL)}},{key:Lf,i18nPath:"contextmenu.table.borderInternal",icon:"border-internal",when:()=>!0,callback:o=>{o.executeTableBorderType(s.TableBorder.INTERNAL)}},{key:Pf,i18nPath:"contextmenu.table.borderTd",icon:"border-td",when:()=>!0,childMenus:[{key:Ef,i18nPath:"contextmenu.table.borderTdTop",icon:"border-td-top",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.TOP)}},{key:Sf,i18nPath:"contextmenu.table.borderTdRight",icon:"border-td-right",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.RIGHT)}},{key:Of,i18nPath:"contextmenu.table.borderTdBottom",icon:"border-td-bottom",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.BOTTOM)}},{key:Mf,i18nPath:"contextmenu.table.borderTdLeft",icon:"border-td-left",when:()=>!0,callback:o=>{o.executeTableTdBorderType(s.TdBorder.LEFT)}},{key:Nf,i18nPath:"contextmenu.table.borderTdForward",icon:"border-td-forward",when:()=>!0,callback:o=>{o.executeTableTdSlashType(s.TdSlash.FORWARD)}},{key:Xf,i18nPath:"contextmenu.table.borderTdBack",icon:"border-td-back",when:()=>!0,callback:o=>{o.executeTableTdSlashType(s.TdSlash.BACK)}}]}]},{key:Ff,i18nPath:"contextmenu.table.verticalAlign",icon:"vertical-align",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:yf,i18nPath:"contextmenu.table.verticalAlignTop",icon:"vertical-align-top",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.TOP)}},{key:bf,i18nPath:"contextmenu.table.verticalAlignMiddle",icon:"vertical-align-middle",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.MIDDLE)}},{key:Df,i18nPath:"contextmenu.table.verticalAlignBottom",icon:"vertical-align-bottom",when:()=>!0,callback:o=>{o.executeTableTdVerticalAlign(s.VerticalAlign.BOTTOM)}}]},{key:Vf,i18nPath:"contextmenu.table.insertRowCol",icon:"insert-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:Wf,i18nPath:"contextmenu.table.insertTopRow",icon:"insert-top-row",when:()=>!0,callback:o=>{o.executeInsertTableTopRow()}},{key:Yf,i18nPath:"contextmenu.table.insertBottomRow",icon:"insert-bottom-row",when:()=>!0,callback:o=>{o.executeInsertTableBottomRow()}},{key:Uf,i18nPath:"contextmenu.table.insertLeftCol",icon:"insert-left-col",when:()=>!0,callback:o=>{o.executeInsertTableLeftCol()}},{key:wf,i18nPath:"contextmenu.table.insertRightCol",icon:"insert-right-col",when:()=>!0,callback:o=>{o.executeInsertTableRightCol()}}]},{key:Zf,i18nPath:"contextmenu.table.deleteRowCol",icon:"delete-row-col",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,childMenus:[{key:Qf,i18nPath:"contextmenu.table.deleteRow",icon:"delete-row",when:()=>!0,callback:o=>{o.executeDeleteTableRow()}},{key:vf,i18nPath:"contextmenu.table.deleteCol",icon:"delete-col",when:()=>!0,callback:o=>{o.executeDeleteTableCol()}},{key:Kf,i18nPath:"contextmenu.table.deleteTable",icon:"delete-table",when:()=>!0,callback:o=>{o.executeDeleteTable()}}]},{key:Hf,i18nPath:"contextmenu.table.mergeCell",icon:"merge-cell",when:o=>!o.isReadonly&&o.isCrossRowCol&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeMergeTableCell()}},{key:_f,i18nPath:"contextmenu.table.mergeCancelCell",icon:"merge-cancel-cell",when:o=>!o.isReadonly&&o.isInTable&&o.options.mode!==s.EditorMode.FORM,callback:o=>{o.executeCancelMergeTableCell()}}];class kf{options;draw;command;range;position;i18n;container;contextMenuList;contextMenuContainerList;contextMenuRelationShip;context;constructor(t,e){this.options=t.getOptions(),this.draw=t,this.command=e,this.range=t.getRange(),this.position=t.getPosition(),this.i18n=t.getI18n(),this.container=t.getContainer(),this.context=null,this.contextMenuList=[...ef,...Af,...Tf,...JT,...rf],this.contextMenuContainerList=[],this.contextMenuRelationShip=new Map,this._addEvent()}getContextMenuList(){return this.contextMenuList}_addEvent(){this.container.addEventListener("contextmenu",this._proxyContextMenuEvent),document.addEventListener("mousedown",this._handleSideEffect)}removeEvent(){this.container.removeEventListener("contextmenu",this._proxyContextMenuEvent),document.removeEventListener("mousedown",this._handleSideEffect)}_filterMenuList(t){const{contextMenuDisableKeys:e}=this.options,n=[];for(let i=0;i<t.length;i++){const l=t[i];l.disable||l.key&&e.includes(l.key)||(l.isDivider||l.when?.(this.context))&&n.push(l)}return n}_proxyContextMenuEvent=t=>{this.context=this._getContext(t);const e=this._filterMenuList(this.contextMenuList);e.some(i=>!i.isDivider)&&(this.dispose(),this._render({contextMenuList:e,left:t.x,top:t.y})),t.preventDefault()};_handleSideEffect=t=>{const e=t.target;this.contextMenuContainerList.some(i=>i.contains(e))||this.dispose()};_getContext(t){const e=this.draw.isReadonly(),{isCrossRowCol:n,startIndex:i,endIndex:l}=this.range.getRange(),r=!!(~i||~l),a=r&&i!==l,{isTable:c,trIndex:d,tdIndex:u,index:R}=this.position.getPositionContext(),h=t?this.command.getPositionContextByEvent(t,{isMustDirectHit:!0}):null;let g=null;if(c){const M=this.draw.getOriginalElementList()[R]||null;M&&(g=wt([M],{extraPickAttrs:["id"]})[0])}const T=c&&!!n,f=this.draw.getElementList();let p=f[i]||null,C=f[l]||null;h?.element&&(p=h.element,C=h.element);const I=h?.element||null,m=h?.tableInfo?.element||null;h?.tableInfo?.element&&(g=h.tableInfo.element);const P=this.draw.getZone().getZone();return{startElement:p,endElement:C,hitElement:I,hitTableElement:m,isReadonly:e,editorHasSelection:a,editorTextFocus:r,isCrossRowCol:T,zone:P,isInTable:c,trIndex:d??null,tdIndex:u??null,tableElement:g,options:this.options}}_createContextMenuContainer(){const t=document.createElement("div");return t.classList.add(`${rt}-contextmenu-container`),t.setAttribute(Be,s.EditorComponent.CONTEXTMENU),this.container.append(t),t}_render(t){const{contextMenuList:e,left:n,top:i,parentMenuContainer:l}=t,r=this._createContextMenuContainer(),a=document.createElement("div");a.classList.add(`${rt}-contextmenu-content`);let c=null;l&&this.contextMenuRelationShip.set(l,r);for(let P=0;P<e.length;P++){const E=e[P];if(E.isDivider){if(P!==0&&P!==e.length-1&&!e[P-1]?.isDivider){const M=document.createElement("div");M.classList.add(`${rt}-contextmenu-divider`),a.append(M)}}else{const M=document.createElement("div");if(M.classList.add(`${rt}-contextmenu-item`),E.childMenus){const D=this._filterMenuList(E.childMenus);D.some(b=>!b.isDivider)&&(M.classList.add(`${rt}-contextmenu-sub-item`),M.onmouseenter=()=>{this._setHoverStatus(M,!0),this._removeSubMenu(r);const b=M.getBoundingClientRect(),V=b.left+b.width,X=b.top;c=this._render({contextMenuList:D,left:V,top:X,parentMenuContainer:r})},M.onmouseleave=b=>{(!c||!c.contains(b.relatedTarget))&&this._setHoverStatus(M,!1)})}else M.onmouseenter=()=>{this._setHoverStatus(M,!0),this._removeSubMenu(r)},M.onmouseleave=()=>{this._setHoverStatus(M,!1)},M.onclick=()=>{E.callback&&this.context&&E.callback(this.command,this.context),this.dispose()};const F=document.createElement("i");M.append(F),E.icon&&F.classList.add(`${rt}-contextmenu-${E.icon}`);const y=document.createElement("span"),Y=E.i18nPath?this._formatName(this.i18n.t(E.i18nPath)):this._formatName(E.name||"");if(y.append(document.createTextNode(Y)),M.append(y),E.shortCut){const D=document.createElement("span");D.classList.add(`${rt}-shortcut`),D.append(document.createTextNode(E.shortCut)),M.append(D)}a.append(M)}}const d=document.createElement("div");d.classList.add(`${rt}-contextmenu-divider`),a.append(d);const u=document.createElement("div");u.classList.add(`${rt}-contextmenu-item`),u.onmouseenter=()=>{this._setHoverStatus(u,!0),this._removeSubMenu(r)},u.onmouseleave=()=>{this._setHoverStatus(u,!1)},u.onclick=()=>{this.dispose()};const R=document.createElement("i");u.append(R);const h=document.createElement("span");h.append(document.createTextNode(this.i18n.t("contextmenu.global.cancel"))),u.append(h),a.append(u),r.append(a),r.style.display="block";const g=window.innerWidth,T=r.getBoundingClientRect(),f=T.width,p=n+f>g?n-f:n;r.style.left=`${p}px`;const C=window.innerHeight,I=T.height,m=i+I>C?i-I:i;return r.style.top=`${m}px`,this.contextMenuContainerList.push(r),r}_removeSubMenu(t){const e=this.contextMenuRelationShip.get(t);e&&(this._removeSubMenu(e),e.remove(),this.contextMenuRelationShip.delete(t))}_setHoverStatus(t,e){e?(t.parentNode?.querySelectorAll(`${rt}-contextmenu-item`).forEach(n=>n.classList.remove("hover")),t.classList.add("hover")):t.classList.remove("hover")}_formatName(t){const e=Object.values(Ul),n=new RegExp(`${e.join("|")}`);let i=t;if(n.test(i)){const l=new RegExp(Ul.SELECTED_TEXT,"g");if(l.test(i)){const r=this.range.toString();i=i.replace(l,r)}}return i}registerContextMenuList(t){this.contextMenuList.push(...t)}dispose(){this.contextMenuContainerList.forEach(t=>t.remove()),this.contextMenuContainerList=[],this.contextMenuRelationShip.clear()}}const Gf=[{key:s.KeyMap.X,ctrl:!0,shift:!0,callback:o=>{o.executeStrikeout()}},{key:s.KeyMap.LEFT_BRACKET,mod:!0,callback:o=>{o.executeSizeAdd()}},{key:s.KeyMap.RIGHT_BRACKET,mod:!0,callback:o=>{o.executeSizeMinus()}},{key:s.KeyMap.B,mod:!0,callback:o=>{o.executeBold()}},{key:s.KeyMap.I,mod:!0,callback:o=>{o.executeItalic()}},{key:s.KeyMap.U,mod:!0,callback:o=>{o.executeUnderline()}},{key:mn?s.KeyMap.COMMA:s.KeyMap.RIGHT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSuperscript()}},{key:mn?s.KeyMap.PERIOD:s.KeyMap.LEFT_ANGLE_BRACKET,mod:!0,shift:!0,callback:o=>{o.executeSubscript()}},{key:s.KeyMap.L,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.LEFT)}},{key:s.KeyMap.E,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.CENTER)}},{key:s.KeyMap.R,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.RIGHT)}},{key:s.KeyMap.J,mod:!0,callback:o=>{o.executeRowFlex(s.RowFlex.ALIGNMENT)}},{key:s.KeyMap.J,mod:!0,shift:!0,callback:o=>{o.executeRowFlex(s.RowFlex.JUSTIFY)}}],xf=[{key:s.KeyMap.ZERO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(null)}},{key:s.KeyMap.ONE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FIRST)}},{key:s.KeyMap.TWO,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.SECOND)}},{key:s.KeyMap.THREE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.THIRD)}},{key:s.KeyMap.FOUR,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FOURTH)}},{key:s.KeyMap.FIVE,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.FIFTH)}},{key:s.KeyMap.SIX,alt:!0,ctrl:!0,callback:o=>{o.executeTitle(s.TitleLevel.SIXTH)}}],Bf=[{key:s.KeyMap.I,shift:!0,mod:!0,callback:o=>{o.executeList(s.ListType.UL,s.ListStyle.DISC)}},{key:s.KeyMap.U,shift:!0,mod:!0,callback:o=>{o.executeList(s.ListType.OL)}}];class Jf{draw;command;globalShortcutList;agentShortcutList;constructor(t,e){this.draw=t,this.command=e,this.globalShortcutList=[],this.agentShortcutList=[],this._addShortcutList([...Gf,...xf,...Bf]),this._addEvent(),t.getCursor().getAgentDom().addEventListener("keydown",this._agentKeydown.bind(this))}_addEvent(){document.addEventListener("keydown",this._globalKeydown)}removeEvent(){document.removeEventListener("keydown",this._globalKeydown)}_addShortcutList(t){for(let e=t.length-1;e>=0;e--){const n=t[e];n.isGlobal?this.globalShortcutList.unshift(n):this.agentShortcutList.unshift(n)}}registerShortcutList(t){this._addShortcutList(t)}_globalKeydown=t=>{this.globalShortcutList.length&&this.draw.isGlobalShortcutActive()&&this.draw.isTargetInsideEditor(t.target)&&this._execute(t,this.globalShortcutList)};_agentKeydown(t){this.agentShortcutList.length&&(this.draw.isInteractionSuspended()||this._execute(t,this.agentShortcutList))}_execute(t,e){for(let n=0;n<e.length;n++){const i=e[n];if((i.mod?ve(t)===!!i.mod:t.ctrlKey===!!i.ctrl&&t.metaKey===!!i.meta)&&t.shiftKey===!!i.shift&&t.altKey===!!i.alt&&t.key.toLowerCase()===i.key.toLowerCase()){i.disable||(i?.callback?.(this.command),t.preventDefault());break}}}}class $f{editor;constructor(t){this.editor=t}use(t,e){t(this.editor,e)}}class zf{eventHub;constructor(){this.eventHub=new Map}on(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t)||new Set;n.add(e),this.eventHub.set(t,n)}emit(t,e){if(!t)return;const n=this.eventHub.get(t);if(n){if(n.size===1)return[...n][0](e);n.forEach(i=>i(e))}}off(t,e){if(!t||typeof e!="function")return;const n=this.eventHub.get(t);n&&n.delete(e)}isSubscribe(t){const e=this.eventHub.get(t);return!!e&&e.size>0}dangerouslyClearAll(){this.eventHub.clear()}}class jf{paste;copy;drop}class Zl{command;version;listener;eventBus;override;register;destroy;use;draw;constructor(t,e,n={}){const i=Lo(n);e=ct(e);let l=[],r=[],a=[],c=[];Array.isArray(e)?r=e:(l=e.header||[],r=e.main,a=e.footer||[],c=e.graffiti||[]),[l,r,a].forEach(T=>{jt(T,{editorOptions:i,isForceCompensation:!0})}),this.version=fn,this.listener=new HT,this.eventBus=new zf,this.override=new jf,this.draw=new YT(t,i,{header:l,main:r,footer:a,graffiti:c},this.listener,this.eventBus,this.override);const u=this.draw;this.command=new Wl(new KT(u)),u.setCommand(this.command);const R=new kf(u,this.command),h=new Jf(u,this.command);this.register=new _T({contextMenu:R,shortcut:h,i18n:u.getI18n()}),this.destroy=()=>{u.destroy(),h.removeEvent(),R.removeEvent(),this.eventBus.dangerouslyClearAll()};const g=new $f(this);this.use=g.use.bind(g)}setFormModeTrace(t){this.command.executeSetFormModeTrace(t)}pauseInteraction(){this.draw.pauseInteraction()}resumeInteraction(){this.draw.resumeInteraction()}setOverlayActive(t){this.draw.setOverlayActive(t)}suspendGlobalShortcut(t){this.draw.suspendGlobalShortcut(t)}}s.Command=Wl,s.EDITOR_CLIPBOARD=zn,s.EDITOR_COMPONENT=Be,s.Editor=Zl,s.INTERNAL_CONTEXT_MENU_KEY=Jn,s.INTERNAL_SHORTCUT_KEY=mr,s.LETTER_CLASS=ii,s.createDomFromElementList=Wn,s.default=Zl,s.getElementListByHTML=Yn,s.getTextFromElementList=In,s.splitText=yt,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));