HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: //var/packages/UniversalViewer/target/dist/assets/index-Cz9vdnfs.js
import{I as f,h as m,x as p,y as T,z as b,A as R,D as S,G as H,H as x,d as y,r as E,l as k,o as C,n as Z,u as s,C as I,c as A}from"../uv.main.XdP33zSa.js";import{P as v,u as z,a as B,_ as O}from"./usePaperFloat-QHga-gfl.js";import{S as P,U as V}from"./blockComponent-eH9nLfFc.js";import{c as L,d as D}from"./ZoomFloatingBar.vue_vue_type_script_setup_true_lang-DOYCzXq-.js";import{d as U}from"./codepage-Bc0X_7fV.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./item-B5SDe0MM.js";import"./handler-CIFn3Nrq.js";const{useComponentStore:u,useZoomableStore:_}=L("text");class re extends P{static itemType=f.TEXT;static forceLoadingFlushUi=!1;getComponentStore(){return u()}getZoomableStore(){return _()}async _switchStatePreview(e,t,n){const o=await this.ensureItemView();return o.updateText(n),o.zoomReset(),o.updateLocation(),m().disableHorizontalScroller(),Promise.all([super._switchStatePreview(e,t,n),o.renderBlocks()]).then(([r])=>r).catch(()=>!1)}_onResize(e,t){if(e.width===t.width)return;const n=this.getItemView();n&&n.updateLocation()}_print(e,t){return t.handlePrint().then(n=>{const o=n?.text;return o==null||!this.isIdActive(e)?!1:this.printIFrame(r=>{const a=r.contentDocument,l=a.body.appendChild(a.createElement("pre"));return Object.assign(l.style,{margin:"0",wordBreak:"break-word",whiteSpace:"pre-wrap",textAlign:"left",lineHeight:"normal"}),l.textContent=o,Promise.resolve(!0)})})}}class se extends v{static type=f.TEXT;static previewableSize=8*1024*1024;_handlePreview(){return this.fetchPreview().then(e=>e?this.getTextData(e):null).catch(()=>null)}async getTextData(e){const t=await e.arrayBuffer(),n=new Uint8Array(t),o=await U(n),r=p(o,n);return{uArray:n,charsetName:o,text:r}}async _handlePrintRequester(e){const t=e&&await this.fetchItemUrl(e);return t?this.getTextData(t):null}}function F(i){return typeof i=="object"&&i!==null&&typeof i.info=="object"&&typeof i.info.start_byte_offset=="number"&&typeof i.info.end_byte_offset=="number"}const N=14,$=29,M=9,W=5;class X extends V{handleWheel;_textRenderer;_gestureController;constructor(e){super({maxRatio:$,minRatio:M,zoomStep:W,defaultRatio:N,...e}),this._textRenderer=null,this._gestureController=null,this.handleWheel=T(()=>this.zoomIn(),()=>this.zoomOut())}renderComponent(e,t){const n=document.createElement("div");return n.classList.add("syno-uv-text-view"),this._gestureController=b(n,()=>this.getZoomRatio(),o=>{this.zoomTo(Math.round(o))},!0),e.appendChild(n)}cleanup(){this.clearRenderer(),this._gestureController?.clean(),super.cleanup()}_renderBlocks(){return this.renderNext()}renderBlock(){return this._textRenderer?Promise.resolve(this._textRenderer.renderBlock()):Promise.resolve(!0)}clearRenderer(){this._textRenderer&&(this._textRenderer.destroy(),this._textRenderer=null)}updateText(e){this._textRenderer&&this.clearRenderer(),this._textRenderer=new j(e,this.getComponent())}updateLocation(){const e=m(),t=Math.round(e.width*.8);this.getComponent().style.width=t+"px",R(this.getComponent(),{width:t},{width:e.width,height:e.height})}onZoomUpdate(e,t){this.getComponent().style.fontSize=`${e}px`,this.updateLocation(),this._textRenderer?.rerenderHighlights(),super.onZoomUpdate(e,t)}zoomDisplay(){return this.zoomReset()}updateHighlights(e,{skipScroll:t=!1}={}){if(this._textRenderer?.clearHighlights(),e&&this._textRenderer){this._textRenderer.updateHighlights(e.filter(F));const n=this._textRenderer.getHighlightTop();t||m().scrollTo(null,n)}}}const g=16384;class j{_data;_utf8Array;_textToRender;_blocks;_highlightSegments;_container;_highlightContainer;constructor(e,t){this._data=e,this._textToRender=e.text,this._blocks=[],this._highlightSegments=[],this._container=t,this._highlightContainer=t.appendChild(this.createHighlightContainer())}createHighlightContainer(){const e=document.createElement("div");return e.classList.add("syno-uv-text-highlight-container"),e}createHighlightElement(){const e=document.createElement("div");return e.classList.add("syno-uv-text-highlight",S().getClassForView("default")),e}createTextElement(){const e=document.createElement("pre");return e.classList.add("syno-uv-text-content"),e}getContainer(){return this._container}renderBlock(){const e=this._textToRender;if(e.length===0)return!0;let t;e.length<g?t=e.length:(t=e.lastIndexOf(`
`,g-1)+1,t===0&&(t=g));const n=this.createTextElement(),o=e.slice(0,t);return n.textContent=o,this._blocks.push({el:n,endOffset:(this._blocks.at(-1)?.endOffset??0)+o.length}),this._textToRender=e.slice(t),this.getContainer().appendChild(n),!1}getHighlightTop(){const e=this._highlightContainer.firstElementChild;return e?e.offsetTop:null}updateHighlights(e){this._utf8Array??=new TextEncoder().encode(this._data.text);const t=this._utf8Array,n="utf-8";this._highlightSegments=e.map(({info:o})=>{const r=p(n,t.slice(0,o.start_byte_offset)).length,a=p(n,t.slice(0,o.end_byte_offset)).length;return{start:r,end:a}}),this.rerenderHighlights()}clearHighlights(){this._highlightSegments=[],this.rerenderHighlights()}findSetRangeArgs(e){const t=H(this._blocks,r=>r.endOffset<e),o=this._blocks[t]?.el.firstChild;return o?{textNode:o,offset:e-(this._blocks[t-1]?.endOffset??0)}:null}rerenderHighlights(){const e=this._highlightContainer;x(e);const{x:t,y:n}=e.getBoundingClientRect(),o=new Range;for(const{start:r,end:a}of this._highlightSegments){const l=this.findSetRangeArgs(r),d=this.findSetRangeArgs(a);if(!(!l||!d)){o.setStart(l.textNode,l.offset),o.setEnd(d.textNode,d.offset);for(const h of o.getClientRects()){if(h.height<=0)continue;const c=this.createHighlightElement();c.style.top=`${h.top-n}px`,c.style.left=`${h.left-t}px`,c.style.width=`${h.width||6}px`,c.style.height=`${h.height}px`,e.appendChild(c)}}}o.detach()}destroy(){x(this._container)}}const ie=y({__name:"ItemView",setup(i,{expose:e}){const t=f.TEXT,n=E(null);D(n,{useComponentStore:u,useZoomableStore:_},X);const{redrawHighlights:o}=z(t,()=>u().component);return e({redrawHighlights:o,handleWheel:r=>u().component?.handleWheel(r)}),(r,a)=>(C(),k("div",{ref_key:"container",ref:n,class:Z(s(I).TEXT_VIEW)},null,2))}}),ae=y({__name:"FloatingBar",setup(i){const{enableZoomOut:e,enableZoomIn:t,enableZoomDisplay:n,displayText:o,displayTooltip:r,handType:a,handleZoomOut:l,handleZoomDisplay:d,handleZoomIn:h,handleCursorClick:c,handleHandClick:w}=B({useComponentStore:u,useZoomableStore:_});return(G,Y)=>(C(),A(s(O),{"display-text":s(o),"display-tooltip":s(r),"enable-display-button":s(n),"enable-zoom-in":s(t),"enable-zoom-out":s(e),"hand-type":s(a),onZoomout:s(l),onZoomreset:s(d),onZoomin:s(h),onCursor:s(c),onHand:s(w)},null,8,["display-text","display-tooltip","enable-display-button","enable-zoom-in","enable-zoom-out","hand-type","onZoomout","onZoomreset","onZoomin","onCursor","onHand"]))}});export{ae as FloatingBar,se as Item,ie as ItemView,X as UVTextView,re as ViewHandler};