PageSourceSearch

https://karanroy2908-pdf.hf.space/assets/FileEditor-BqTC-u7_.js

js karanroy2908-pdf.hf.space collected 2026-10-03 17:02:19 UTC 42,375 bytes, 6 lines download raw bytes

1import{c as Oe,a,fP as _t,cR as Kt,u as ke,a6 as Vt,cp as Me,bj as Gt,a2 as dt,db as Yt,r as x,fm as ut,bQ as L,fK as pt,fh as Xt,ez as qt,e0 as Zt,fQ as Qt,eA as Jt,dm as en,eH as tn,bo as ft,q as nn,U as rn,ae as xe,bN as Te,S as pe,T as $,G as _,B as H,fR as an,fS as on,e$ as ln,dM as gt,aX as sn,fT as cn,L as _e,fU as dn,R as Ke,fk as un,al as fe,C as pn,bd as fn,dZ as gn,bC as vn,dL as mn,cs as hn,by as yn,m as bn,bb as xn,ec as wn,di as Sn,fL as jn,bn as Cn}from"./index-BkeMuzUz.js";import{H as Fn}from"./HoverActionMenu-DKZ5cge8.js";import{t as Tn}from"./textUtils-B7NfPJfH.js";import"./vendor-react-CW0cBZaz.js";import"./pdf-engine-BPdFjzQc.js";const Ve=Oe(a.jsx("path",{fillRule:"evenodd",d:"M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3"})),Dn=Oe(a.jsx("path",{d:"M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m0 12H6V10h12z"})),Pn=Oe(a.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}));function En(e){if(Array.isArray(e))return e}function An(e,n){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var r,o,s,i,l=[],c=!0,u=!1;try{if(s=(t=t.call(e)).next,n!==0)for(;!(c=(r=s.call(t)).done)&&(l.push(r.value),l.length!==n);c=!0);}catch(h){u=!0,o=h}finally{try{if(!c&&t.return!=null&&(i=t.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}function De(e,n){(n==null||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function vt(e,n){if(e){if(typeof e=="string")return De(e,n);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?De(e,n):void 0}}function On(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mt(e,n){return En(e)||An(e,n)||vt(e,n)||On()}var we={},ie={},Ge;function ht(){if(Ge)return ie;Ge=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.bind=void 0;function e(n,t){var r=t.type,o=t.listener,s=t.options;return n.addEventListener(r,o,s),function(){n.removeEventListener(r,o,s)}}return ie.bind=e,ie}var q={},Ye;function kn(){if(Ye)return q;Ye=1;var e=q&&q.__assign||function(){return e=Object.assign||function(s){for(var i,l=1,c=arguments.length;l<c;l++){i=arguments[l];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(s[u]=i[u])}return s},e.apply(this,arguments)};Object.defineProperty(q,"__esModule",{value:!0}),q.bindAll=void 0;var n=ht();function t(s){if(!(typeof s>"u"))return typeof s=="boolean"?{capture:s}:s}function r(s,i){if(i==null)return s;var l=e(e({},s),{options:e(e({},t(i)),t(s.options))});return l}function o(s,i,l){var c=i.map(function(u){var h=r(u,l);return(0,n.bind)(s,h)});return function(){c.forEach(function(h){return h()})}}return q.bindAll=o,q}var Xe;function Mn(){return Xe||(Xe=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=e.bind=void 0;var n=ht();Object.defineProperty(e,"bind",{enumerable:!0,get:function(){return n.bind}});var t=kn();Object.defineProperty(e,"bindAll",{enumerable:!0,get:function(){return t.bindAll}})})(we)),we}var re=Mn(),yt="data-pdnd-honey-pot";function bt(e){return e instanceof Element&&e.hasAttribute(yt)}function xt(e){var n=document.elementsFromPoint(e.x,e.y),t=mt(n,2),r=t[0],o=t[1];return r?bt(r)?o??null:r:null}function se(e){"@babel/helpers - typeof";return se=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},se(e)}function In(e,n){if(se(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var r=t.call(e,n);if(se(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Nn(e){var n=In(e,"string");return se(n)=="symbol"?n:n+""}function Ie(e,n,t){return(n=Nn(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Bn=2147483647;function qe(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),t.push.apply(t,r)}return t}function Ze(e){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};
2n%2?qe(Object(t),!0).forEach(function(r){Ie(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):qe(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var ce=2,Qe=ce/2;function zn(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}function Un(e){return{x:e.x-Qe,y:e.y-Qe}}function Rn(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}function Hn(e){return{x:Math.min(e.x,window.innerWidth-ce),y:Math.min(e.y,window.innerHeight-ce)}}function Je(e){var n=e.client,t=Hn(Rn(Un(zn(n))));return DOMRect.fromRect({x:t.x,y:t.y,width:ce,height:ce})}function et(e){var n=e.clientRect;return{left:"".concat(n.left,"px"),top:"".concat(n.top,"px"),width:"".concat(n.width,"px"),height:"".concat(n.height,"px")}}function Ln(e){var n=e.client,t=e.clientRect;return n.x>=t.x&&n.x<=t.x+t.width&&n.y>=t.y&&n.y<=t.y+t.height}function Wn(e){var n=e.initial,t=document.createElement("div");t.setAttribute(yt,"true");var r=Je({client:n});Object.assign(t.style,Ze(Ze({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},et({clientRect:r})),{},{pointerEvents:"auto",zIndex:Bn})),document.body.appendChild(t);var o=re.bind(window,{type:"pointermove",listener:function(i){var l={x:i.clientX,y:i.clientY};r=Je({client:l}),Object.assign(t.style,et({clientRect:r}))},options:{capture:!0}});return function(i){var l=i.current;if(o(),Ln({client:l,clientRect:r})){t.remove();return}function c(){u(),t.remove()}var u=re.bindAll(window,[{type:"pointerdown",listener:c},{type:"pointermove",listener:c},{type:"focusin",listener:c},{type:"focusout",listener:c},{type:"dragstart",listener:c},{type:"dragenter",listener:c},{type:"dragover",listener:c}],{capture:!0})}}function $n(){var e=null;function n(){return e=null,re.bind(window,{type:"pointermove",listener:function(o){e={x:o.clientX,y:o.clientY}},options:{capture:!0}})}function t(){var r=null;return function(s){var i=s.eventName,l=s.payload;if(i==="onDragStart"){var c=l.location.initial.input,u=e??{x:c.clientX,y:c.clientY};r=Wn({initial:u})}if(i==="onDrop"){var h,g=l.location.current.input;(h=r)===null||h===void 0||h({current:{x:g.clientX,y:g.clientY}}),r=null,e=null}}}return{bindEvents:n,getOnPostDispatch:t}}function _n(e){if(Array.isArray(e))return De(e)}function Kn(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Vn(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
3In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wt(e){return _n(e)||Kn(e)||vt(e)||Vn()}function ae(e){var n=null;return function(){if(!n){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];var i=e.apply(this,o);n={result:i}}return n.result}}var Gn=ae(function(){return navigator.userAgent.includes("Firefox")}),Ne=ae(function(){var n=navigator,t=n.userAgent;return t.includes("AppleWebKit")&&!t.includes("Chrome")}),Pe={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function Yn(e){var n=e.dragLeave;return Ne()?n.hasOwnProperty(Pe.isLeavingWindow):!1}(function(){if(typeof window>"u"||!Ne())return;function n(){return{enterCount:0,isOverWindow:!1}}var t=n();function r(){t=n()}re.bindAll(window,[{type:"dragstart",listener:function(){t.enterCount=0,t.isOverWindow=!0}},{type:"drop",listener:r},{type:"dragend",listener:r},{type:"dragenter",listener:function(s){!t.isOverWindow&&t.enterCount===0&&(s[Pe.isEnteringWindow]=!0),t.isOverWindow=!0,t.enterCount++}},{type:"dragleave",listener:function(s){t.enterCount--,t.isOverWindow&&t.enterCount===0&&(s[Pe.isLeavingWindow]=!0,t.isOverWindow=!1)}}],{capture:!0})})();function Xn(e){return"nodeName"in e}function qn(e){return Xn(e)&&e.ownerDocument!==document}function Zn(e){var n=e.dragLeave,t=n.type,r=n.relatedTarget;return t!=="dragleave"?!1:Ne()?Yn({dragLeave:n}):r==null?!0:Gn()?qn(r):r instanceof HTMLIFrameElement}function Qn(e){var n=e.onDragEnd;return[{type:"pointermove",listener:(function(){var t=0;return function(){if(t<20){t++;return}n()}})()}
3,{type:"pointerdown",listener:n}]}function le(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var Jn=function(n){var t=[],r=null,o=function(){for(var i=arguments.length,l=new Array(i),c=0;c<i;c++)l[c]=arguments[c];t=l,!r&&(r=requestAnimationFrame(function(){r=null,n.apply(void 0,t)}))};return o.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},o},Se=Jn(function(e){return e()}),ue=(function(){var e=null;function n(r){var o=requestAnimationFrame(function(){e=null,r()});e={frameId:o,fn:r}}function t(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return{schedule:n,flush:t}})();function er(e){var n=e.source,t=e.initial,r=e.dispatchEvent,o={dropTargets:[]};function s(l){r(l),o={dropTargets:l.payload.location.current.dropTargets}}var i={start:function(c){var u=c.nativeSetDragImage,h={current:t,previous:o,initial:t};s({eventName:"onGenerateDragPreview",payload:{source:n,location:h,nativeSetDragImage:u}}),ue.schedule(function(){s({eventName:"onDragStart",payload:{source:n,location:h}})})},dragUpdate:function(c){var u=c.current;ue.flush(),Se.cancel(),s({eventName:"onDropTargetChange",payload:{source:n,location:{initial:t,previous:o,current:u}}})},drag:function(c){var u=c.current;Se(function(){ue.flush();var h={initial:t,previous:o,current:u};s({eventName:"onDrag",payload:{source:n,location:h}})})},drop:function(c){var u=c.current,h=c.updatedSourcePayload;ue.flush(),Se.cancel(),s({eventName:"onDrop",payload:{source:h??n,location:{current:u,previous:o,initial:t}}})}};return i}var Ee={isActive:!1};function St(){return!Ee.isActive}function tr(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function nr(e){var n=e.current,t=e.next;if(n.length!==t.length)return!0;for(var r=0;r<n.length;r++)if(n[r].element!==t[r].element)return!0;return!1}function rr(e){var n=e.event,t=e.dragType,r=e.getDropTargetsOver,o=e.dispatchEvent;if(!St())return;var s=ar({event:n,dragType:t,getDropTargetsOver:r});Ee.isActive=!0;var i={current:s};je({event:n,current:s.dropTargets});var l=er({source:t.payload,dispatchEvent:o,initial:s});function c(d){var p=nr({current:i.current.dropTargets,next:d.dropTargets});i.current=d,p&&l.dragUpdate({current:i.current})}function u(d){var p=le(d),y=bt(d.target)?xt({x:p.clientX,y:p.clientY}):d.target,f=r({target:y,input:p,source:t.payload,current:i.current.dropTargets});f.length&&(d.preventDefault(),je({event:d,current:f})),c({dropTargets:f,input:p})}function h(){i.current.dropTargets.length&&c({dropTargets:[],input:i.current.input}),l.drop({current:i.current,updatedSourcePayload:null}),g()}function g(){Ee.isActive=!1,F()}var F=re.bindAll(window,[{type:"dragover",listener:function(p){u(p),l.drag({current:i.current})}},{type:"dragenter",listener:u},{type:"dragleave",listener:function(p){Zn({dragLeave:p})&&(c({input:i.current.input,dropTargets:[]}),t.startedFrom==="external"&&h())}},{type:"drop",listener:function(p){if(i.current={dropTargets:i.current.dropTargets,input:le(p)},!i.current.dropTargets.length){h();return}p.preventDefault(),je({event:p,current:i.current.dropTargets}),l.drop({current:i.current,updatedSourcePayload:t.type==="external"?t.getDropPayload(p):null}),g()}},{type:"dragend",listener:function(p){i.current={dropTargets:i.current.dropTargets,input:le(p)},h()}}].concat(wt(Qn({onDragEnd:h}))),{capture:!0});l.start({nativeSetDragImage:tr(n)})}function je(e){var n,t=e.event,r=e.current,o=(n=r[0])===null||n===void 0?void 0:n.dropEffect;o!=null&&t.dataTransfer&&(t.dataTransfer.dropEffect=o)}function ar(e){var n=e.event,t=e.dragType,r=e.getDropTargetsOver,o=le(n);if(t.startedFrom==="external")return{input:o,dropTargets:[]};var s=r({input:o,source:t.payload,target:n.target,current:[]});return{input:o,dropTargets:s}}var tt={canStart:St,start:rr},Ae=new Map;function or(e){var n=e.typeKey,t=e.mount,r=Ae.get(n);if(r)return r.usageCount++,r;var o={typeKey:n,unmount:t(),usageCount:1};return Ae.set(n,o),o}function ir(e){var n=or(e);return function(){n.usageCount--,!(n.usageCount>0)&&(n.unmount(),Ae.delete(e.typeKey))}}function Be(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];
3return function(){n.forEach(function(o){return o()})}}function jt(e,n){var t=n.attribute,r=n.value;return e.setAttribute(t,r),function(){return e.removeAttribute(t)}}function nt(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),t.push.apply(t,r)}return t}function G(e){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?nt(Object(t),!0).forEach(function(r){Ie(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):nt(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function Ce(e,n){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=lr(e))||n){t&&(e=t);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
4In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,i=!0,l=!1;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return i=u.done,u},e:function(u){l=!0,s=u},f:function(){try{i||t.return==null||t.return()}finally{if(l)throw s}}}}function lr(e,n){if(e){if(typeof e=="string")return rt(e,n);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?rt(e,n):void 0}}function rt(e,n){(n==null||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function Fe(e){return e.slice(0).reverse()}function sr(e){var n=e.typeKey,t=e.defaultDropEffect,r=new WeakMap,o="data-drop-target-for-".concat(n),s="[".concat(o,"]");function i(d){return r.set(d.element,d),function(){return r.delete(d.element)}}function l(d){var p=Be(jt(d.element,{attribute:o,value:"true"}),i(d));return ae(p)}function c(d){var p,y,f,P,j=d.source,T=d.target,D=d.input,C=d.result,b=C===void 0?[]:C;if(T==null)return b;if(!(T instanceof Element))return T instanceof Node?c({source:j,target:T.parentElement,input:D,result:b}):b;var B=T.closest(s);if(B==null)return b;var A=r.get(B);if(A==null)return b;var O={input:D,source:j,element:A.element};if(A.canDrop&&!A.canDrop(O))return c({source:j,target:A.element.parentElement,input:D,result:b});var I=(p=(y=A.getData)===null||y===void 0?void 0:y.call(A,O))!==null&&p!==void 0?p:{},z=(f=(P=A.getDropEffect)===null||P===void 0?void 0:P.call(A,O))!==null&&f!==void 0?f:t,N={data:I,element:A.element,dropEffect:z,isActiveDueToStickiness:!1};return c({source:j,target:A.element.parentElement,input:D,result:[].concat(wt(b),[N])})}function u(d){var p=d.eventName,y=d.payload,f=Ce(y.location.current.dropTargets),P;try{for(f.s();!(P=f.n()).done;){var j,T=P.value,D=r.get(T.element),C=G(G({},y),{},{self:T});D==null||(j=D[p])===null||j===void 0||j.call(D,C)}}catch(b){f.e(b)}finally{f.f()}}var h={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:function(p){var y=p.payload,f=new Set(y.location.current.dropTargets.map(function(v){return v.element})),P=new Set,j=Ce(y.location.previous.dropTargets),T;try{for(j.s();!(T=j.n()).done;){var D,C=T.value;P.add(C.element);var b=r.get(C.element),B=f.has(C.element),A=G(G({},y),{},{self:C});if(b==null||(D=b.onDropTargetChange)===null||D===void 0||D.call(b,A),!B){var O;b==null||(O=b.onDragLeave)===null||O===void 0||O.call(b,A)}}}catch(v){j.e(v)}finally{j.f()}var I=Ce(y.location.current.dropTargets),z;try{for(I.s();!(z=I.n()).done;){var N,U,K=z.value;if(!P.has(K.element)){var Z=G(G({},y),{},{self:K}),m=r.get(K.element);m==null||(N=m.onDropTargetChange)===null||N===void 0||N.call(m,Z),m==null||(U=m.onDragEnter)===null||U===void 0||U.call(m,Z)}}}catch(v){I.e(v)}finally{I.f()}}};function g(d){h[d.eventName](d)}function F(d){var p=d.source,y=d.target,f=d.input,P=d.current,j=c({source:p,target:y,input:f});if(j.length>=P.length)return j;for(var T=Fe(P),D=Fe(j),C=[],b=0;b<T.length;b++){var B,A=T[b],O=D[b];if(O!=null){C.push(O);continue}var I=C[b-1],z=T[b-1];if(I?.element!==z?.element)break;var N=r.get(A.element);if(!N)break;var U={input:f,source:p,element:N.element};
4if(N.canDrop&&!N.canDrop(U)||!((B=N.getIsSticky)!==null&&B!==void 0&&B.call(N,U)))break;C.push(G(G({},A),{},{isActiveDueToStickiness:!0}))}return Fe(C)}return{dropTargetForConsumers:l,getIsOver:F,dispatchEvent:g}}function cr(e,n){var t=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=dr(e))||n){t&&(e=t);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
5In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,i=!0,l=!1;return{s:function(){t=t.call(e)},n:function(){var u=t.next();return i=u.done,u},e:function(u){l=!0,s=u},f:function(){try{i||t.return==null||t.return()}finally{if(l)throw s}}}}function dr(e,n){if(e){if(typeof e=="string")return at(e,n);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?at(e,n):void 0}}function at(e,n){(n==null||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function ot(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),t.push.apply(t,r)}return t}function ur(e){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?ot(Object(t),!0).forEach(function(r){Ie(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ot(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function pr(){var e=new Set,n=null;function t(s){n&&(!s.canMonitor||s.canMonitor(n.canMonitorArgs))&&n.active.add(s)}function r(s){var i=ur({},s);e.add(i),t(i);function l(){e.delete(i),n&&n.active.delete(i)}return ae(l)}function o(s){var i=s.eventName,l=s.payload;if(i==="onGenerateDragPreview"){n={canMonitorArgs:{initial:l.location.initial,source:l.source},active:new Set};var c=cr(e),u;try{for(c.s();!(u=c.n()).done;){var h=u.value;t(h)}}catch(f){c.e(f)}finally{c.f()}}if(n){for(var g=Array.from(n.active),F=0,d=g;F<d.length;F++){var p=d[F];if(n.active.has(p)){var y;(y=p[i])===null||y===void 0||y.call(p,l)}}i==="onDrop"&&(n.active.clear(),n=null)}}return{dispatchEvent:o,monitorForConsumers:r}}function fr(e){var n=e.typeKey,t=e.mount,r=e.dispatchEventToSource,o=e.onPostDispatch,s=e.defaultDropEffect,i=pr(),l=sr({typeKey:n,defaultDropEffect:s});function c(g){r?.(g),l.dispatchEvent(g),i.dispatchEvent(g),o?.(g)}function u(g){var F=g.event,d=g.dragType;tt.start({event:F,dragType:d,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}function h(){function g(){var F={canStart:tt.canStart,start:u};return t(F)}return ir({typeKey:n,mount:g})}return{registerUsage:h,dropTarget:l.dropTargetForConsumers,monitor:i.monitorForConsumers}}var gr=ae(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")}),vr="pdnd:android-fallback",it="text/plain",mr="text/uri-list",hr="application/vnd.pdnd",ge=new WeakMap;function yr(e){return ge.set(e.element,e),function(){ge.delete(e.element)}}var lt=$n(),Ct=fr({typeKey:"element",defaultDropEffect:"move",mount:function(n){return Be(lt.bindEvents(),re.bind(document,{type:"dragstart",listener:function(r){var o,s,i,l,c,u;if(n.canStart(r)&&!r.defaultPrevented&&r.dataTransfer){var h=r.target;if(h instanceof HTMLElement){var g=ge.get(h);if(g){var F=le(r),d={element:g.element,dragHandle:(o=g.dragHandle)!==null&&o!==void 0?o:null,input:F};if(g.canDrag&&!g.canDrag(d)){r.preventDefault();return}if(g.dragHandle){var p=xt({x:F.clientX,y:F.clientY});if(!g.dragHandle.contains(p)){r.preventDefault();return}}var y=(s=(i=g.getInitialDataForExternal)===null||i===void 0?void 0:i.call(g,d))!==null&&s!==void 0?s:null;if(y)for(var f=0,P=Object.entries(y);f<P.length;f++){var j=mt(P[f],2),T=j[0],D=j[1];r.dataTransfer.setData(T,D??"")}gr()&&!r.dataTransfer.types.includes(it)&&!r.dataTransfer.types.includes(mr)&&r.dataTransfer.setData(it,vr),r.dataTransfer.setData(hr,"");var C={element:g.element,dragHandle:(l=g.dragHandle)!==null&&l!==void 0?l:null,data:(c=(u=g.getInitialData)===null||u===void 0?void 0:u.call(g,d))!==null&&c!==void 0?c:{}},b={type:"element",payload:C,startedFrom:"internal"};n.start({event:r,dragType:b})}}}}}))},dispatchEventToSource:function(n){var t,r,o=n.eventName,s=n.payload;(t=ge.get(s.source.element))===null||t===void 0||(r=t[o])===null||r===void 0||r.call(t,s)},onPostDispatch:lt.getOnPostDispatch()}),br=Ct.dropTarget;function xr(e){var n=Be(Ct.registerUsage(),yr(e),jt(e.element,{attribute:"draggable",value:"true"}));return ae(n)}const wr="_card_1bwty_1",Sr="_thumbInner_1bwty_22",jr="_thumbUnit_1bwty_32",Cr="_toolChainBar_1bwty_41",Fr="_thumbWrap_1bwty_60",Tr="_thumbContainer_1bwty_69",Dr="_thumbImage_1bwty_89",Pr="_fileText_1bwty_101",Er="_fileName_1bwty_115",Ar="_fileMeta_1bwty_136",Or="_errorOverlay_1bwty_166",kr="_errorPill_1bwty_178",Mr="_thumbBadges_1bwty_188",Ir="_ownershipBadge_1bwty_219",Nr="_versionBadgeThumb_1bwty_229",Br="_pinnedBadge_1bwty_240",zr="_dragHandle_1bwty_251",M={card:wr,thumbInner:Sr,thumbUnit:jr,toolChainBar:Cr,thumbWrap:Fr,thumbContainer:Tr,thumbImage:Dr,fileText:Pr,fileName:Er,fileMeta:Ar,errorOverlay:Or,errorPill:kr,thumbBadges:Mr,ownershipBadge:Ir,versionBadgeThumb:Nr,pinnedBadge:Br,dragHandle:zr};function Ur(e){const n=!!e?.processedFile?.isEncrypted,{thumbnail:t,isGenerating:r}=_t(n?null:e),o=n?null:e?.thumbnailUrl||t||null;return{isEncrypted:n,thumbnail:o,isGenerating:r}}function Rr(e){return null}
5const Hr=({file:e,onCloseFile:n,onViewFile:t,onReorderFiles:r,onDownloadFile:o,onUnzipFile:s,isSupported:i=!0})=>{const{t:l}=ke(),{config:c}=Vt(),u=Me(),g=gt().download,{pinFile:F,unpinFile:d,isFilePinned:p,activeFiles:y,actions:f,openEncryptedUnlockPrompt:P}=Gt(),{state:j,selectors:T}=dt(),D=Yt(),C=x.useMemo(()=>y.find(w=>w.fileId===e.id),[y,e.id]),b=C?p(C):!1,B=ut.isZipFileStub(e),A=j.ui.errorFileIds.includes(e.id),O=e.processedFile?.totalPages||0,{isEncrypted:I,thumbnail:z,isGenerating:N}=Ur(e),U=e.processedFile?.pages?.[0],K=U?.rotation??0,Z=K===90||K===270,m=(()=>{const w=U?.width,R=U?.height;return w&&R&&w>0&&R>0?`${w} / ${R}`:Z?"11 / 8.5":"8.5 / 11"})(),v=x.useRef(null),E=x.useRef(null),S=x.useMemo(()=>(/\.([a-z0-9]+)$/i.exec(e.name??"")?.[1]||"").toUpperCase(),[e.name]),Y=x.useMemo(()=>(/\.([a-z0-9]+)$/i.exec(e.name??"")?.[1]||"").toLowerCase(),[e.name]),X=Y==="cbz",Q=Y==="cbr",W=c?.storageEnabled===!0,J=W&&c?.storageSharingEnabled===!0&&c?.storageShareLinksEnabled===!0,ee=e.remoteOwnedByCurrentUser!==!1,oe=e.remoteOwnedByCurrentUser===!1||e.remoteSharedViaLink,de=e.createdAt??e.lastModified??0,k=e.remoteStorageUpdatedAt??0,V=!!e.remoteStorageId,Tt=V&&k>=de,ve=W&&ee&&e.isLeaf&&(!V||!Tt),me=J&&ee&&e.isLeaf,Dt=x.useMemo(()=>O>0?`${O} ${O===1?"Page":"Pages"}`:"",[O]),Pt=x.useMemo(()=>{const w=new Date(e.lastModified);return Number.isNaN(w.getTime())?"":new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",year:"numeric"}).format(w)},[e.lastModified]),[Et,ze]=x.useState(!1),[At,te]=x.useState(!1),[Ot,Ue]=x.useState(!1),[kt,Re]=x.useState(!1),[Mt,he]=x.useState(!1),He=x.useRef(!1),It=x.useCallback(w=>{if(!w)return;E.current=w;const R=xr({element:w,getInitialData:()=>({type:"file",fileId:e.id,fileName:e.name,selectedFiles:[e.id]}),onDragStart:()=>ze(!0),onDrop:()=>ze(!1)}),Lt=br({element:w,getData:()=>({type:"file",fileId:e.id}),canDrop:({source:be})=>{const ne=be.data;return ne.type==="file"&&ne.fileId!==e.id},onDrop:({source:be})=>{const ne=be.data;if(ne.type==="file"&&r){const Wt=ne.fileId,$t=ne.selectedFiles;r(Wt,e.id,$t)}}});return()=>{R(),Lt()}},[e.id,e.name,r]),Le=x.useCallback(()=>te(!0),[]),ye=x.useCallback(()=>te(!1),[]),We=x.useCallback(()=>{n(e.id),L({alertType:"neutral",title:`Closed ${e.name}`,expandable:!1,durationMs:3500}),te(!1)},[e.id,e.name,n]),Nt=x.useCallback(async()=>{const w=T.getFile(e.id);if(w)try{const R=await pt({data:w,filename:e.name,localPath:e.localFilePath,fileId:e.id});if(!R.cancelled&&R.savedPath)f.updateStirlingFileStub(e.id,{localFilePath:e.localFilePath??R.savedPath,isDirty:!1});else if(R.cancelled){te(!1);return}}catch(R){console.error(`Failed to save ${e.name}:`,R),L({alertType:"error",title:"Save failed",body:`Could not save ${e.name}`,expandable:!0}),te(!1);return}n(e.id),L({alertType:"success",title:`Saved and closed ${e.name}`,expandable:!1,durationMs:3500}),te(!1)},[e.id,e.name,e.localFilePath,n,T,f]),[Bt,$e]=x.useState(!1),zt=x.useMemo(()=>[{id:"view",icon:a.jsx(Xt,{style:{fontSize:20}}),label:l("openInViewer","Open in Viewer"),onClick:w=>{w.stopPropagation(),t(e.id)}},{id:"pin",icon:a.jsx(Ve,{style:{fontSize:20}}),label:b?l("unpin","Unpin File (replace after tool run)"):l("pin","Pin File (keep active after tool run)"),dataTour:"file-card-pin",onClick:w=>{w.stopPropagation(),C&&(b?(d(C),L({alertType:"neutral",title:`Unpinned ${e.name}`,expandable:!1,durationMs:3e3})):(F(C),L({alertType:"success",title:`Pinned ${e.name}`,expandable:!1,durationMs:3e3})))}},{id:"download",icon:a.jsx(g,{style:{fontSize:20}}),label:u.download,onClick:w=>{w.stopPropagation(),o(e.id)}},...ve?[{id:"upload",icon:a.jsx(qt,{style:{fontSize:20}}),label:V?l("fileManager.updateOnServer","Update on Server"):l("fileManager.uploadToServer","Upload to Server"),onClick:w=>{w.stopPropagation(),Ue(!0)}}]:[],...me?[{id:"share",icon:a.jsx(Zt,{style:{fontSize:20}}),label:l("fileManager.share","Share"),onClick:w=>{w.stopPropagation(),Re(!0)}}]:[],{id:"unzip",icon:a.jsx(Qt,{style:{fontSize:20}}),label:l("fileManager.unzip","Unzip"),onClick:w=>{w.stopPropagation(),s&&(s(e.id),L({alertType:"success",title:`Unzipping ${e.name}`,expandable:!1,durationMs:2500}))},hidden:!B||!s||X||Q},{id:"versionHistory",icon:a.jsx(Jt,{style:{fontSize:20}}),label:l("fileManager.versionHistory","Version history"),onClick:w=>{w.stopPropagation(),$e(!0)},hidden:(e.versionNumber??1)<=1},{id:"close",icon:a.jsx(en,{style:{fontSize:20}}),label:l("close","Close"),onClick:w=>{w.stopPropagation(),Le()},color:"red"}],[l,e.id,e.name,e.versionNumber,B,X,Q,b,C,u,g,t,o,s,Le,ve,me,V,F,d]),Ut=()=>{if(i){if(A)try{f.clearFileError(e.id)}catch{}oe&&!He.current&&(He.current=!0,he(!0))}},Rt=()=>{i&&t(e.id)},Ht=[Pt,S?`${S}
5 file`:"",Dt].filter(Boolean).join(" - ");return a.jsxs("div",{ref:It,"data-file-id":e.id,"data-testid":"file-thumbnail","data-tour":"file-card-checkbox","data-supported":i,className:`${M.card} select-none`,style:{opacity:Et?.9:1},tabIndex:0,role:"listitem",onClick:Ut,onDoubleClick:Rt,children:[a.jsxs("div",{className:M.thumbInner,children:[a.jsxs("div",{className:M.thumbWrap,children:[a.jsxs("div",{className:M.thumbUnit,children:[a.jsx("div",{className:M.toolChainBar,children:e.toolHistory&&e.toolHistory.length>0&&a.jsx(tn,{toolChain:e.toolHistory,displayStyle:"text",size:"xs",maxWidth:"100%",color:"var(--mantine-color-gray-7)"})}),a.jsxs("div",{className:M.thumbContainer,"data-supported":i,style:{"--thumb-aspect":m},children:[A&&a.jsx("div",{className:M.errorOverlay,children:a.jsx("span",{className:M.errorPill,children:l("error._value","Error")})}),a.jsx(ft,{file:e,thumbnail:z||void 0,isEncrypted:I,isLoading:!I&&!z&&(N||e.type?.startsWith("application/pdf")||e.type?.startsWith("image/")),iconSize:"6rem",imgClassName:M.thumbImage,onImageError:w=>{w.currentTarget.style.display="none"}}),a.jsxs("div",{className:M.thumbBadges,children:[a.jsxs("span",{className:M.versionBadgeThumb,children:["v",e.versionNumber]}),b&&a.jsx("span",{className:M.pinnedBadge,children:a.jsx(Ve,{style:{fontSize:12}})}),oe&&!ee&&a.jsx("span",{className:M.ownershipBadge,children:l("fileManager.sharedWithYou","Shared")}),I&&a.jsx(nn,{label:l("encryptedPdfUnlock.unlockPrompt","Unlock PDF to continue"),children:a.jsx(rn,{size:"xs",variant:"filled",color:"yellow",onClick:w=>{w.stopPropagation(),P(e.id)},style:{pointerEvents:"auto"},children:a.jsx(Dn,{style:{fontSize:12}})})})]}),a.jsx(Rr,{file:e})]})]}),a.jsx("span",{ref:v,className:M.dragHandle,"aria-hidden":!0,children:a.jsx(Pn,{fontSize:"small"})})]}),a.jsx(Fn,{show:D,actions:zt,position:"outside",visibility:"cssHover"})]}),a.jsxs("div",{className:M.fileText,children:[a.jsx("p",{className:M.fileName,children:a.jsx(xe,{children:Tn(e.name,40)})}),a.jsx("p",{className:M.fileMeta,children:Ht})]}),a.jsx(Te,{opened:At,onClose:ye,title:l("confirmClose","Confirm Close"),centered:!0,size:"auto",children:a.jsx(pe,{gap:"md",children:e.isDirty&&e.localFilePath?a.jsxs(a.Fragment,{children:[a.jsx($,{size:"md",children:l("confirmCloseUnsaved","This file has unsaved changes.")}),a.jsx($,{size:"sm",c:"dimmed",fw:500,children:a.jsx(xe,{children:e.name})}),a.jsxs(_,{justify:"flex-end",gap:"sm",children:[a.jsx(H,{variant:"light",onClick:ye,children:l("confirmCloseCancel","Cancel")}),a.jsx(H,{variant:"filled",color:"red",onClick:We,children:l("confirmCloseDiscard","Discard changes and close")}),a.jsx(H,{variant:"filled",onClick:Nt,children:l("confirmCloseSave","Save and close")})]})]}):a.jsxs(a.Fragment,{children:[a.jsx($,{size:"md",children:l("confirmCloseMessage","Are you sure you want to close this file?")}),a.jsx($,{size:"sm",c:"dimmed",fw:500,children:a.jsx(xe,{children:e.name})}),a.jsxs(_,{justify:"flex-end",gap:"sm",children:[a.jsx(H,{variant:"light",onClick:ye,children:l("confirmCloseCancel","Cancel")}),a.jsx(H,{variant:"filled",color:"red",onClick:We,children:l("confirmCloseConfirm","Close File")})]})]})})}),a.jsx(Te,{opened:Mt,onClose:()=>he(!1),title:l("fileManager.sharedEditNoticeTitle","Read-only server copy"),centered:!0,size:"auto",children:a.jsxs(pe,{gap:"md",children:[a.jsx($,{size:"sm",children:l("fileManager.sharedEditNoticeBody","You do not have edit rights to the server version of this file. Any edits you make will be saved as a local copy.")}),a.jsx(_,{justify:"flex-end",gap:"sm",children:a.jsx(H,{onClick:()=>he(!1),children:l("fileManager.sharedEditNoticeConfirm","Got it")})})]})}),ve&&a.jsx(an,{opened:Ot,onClose:()=>Ue(!1),file:e}),me&&a.jsx(on,{opened:kt,onClose:()=>Re(!1),file:e}),a.jsx(ln,{opened:Bt,onClose:()=>$e(!1),file:e})]})},Lr=Kt.memo(Hr),Wr="_addFileCard_ulg0d_330",$r="_addFileContent_ulg0d_358",st={addFileCard:Wr,addFileContent:$r},ct=({onFileSelect:e,accept:n,multiple:t=!0})=>{const{t:r}=ke(),o=x.useRef(null),{openFilesModal:s}=sn(),[i,l]=x.useState(!1),c=Me(),u=gt(),h=()=>{s()},g=async p=>{p.stopPropagation();const y=await dn({multiple:t,onFallbackOpen:()=>o.current?.click()});y.length>0&&e(y)},F=p=>{p.stopPropagation(),s()},d=p=>{const y=Array.from(p.target.files||[]);y.length>0&&e(y),p.target.value=""};return a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:o,type:"file",accept:n,multiple:t,onChange:d,style:{display:"none"}}),a.jsx("div",{className:`${st.addFileCard} select-none flex flex-col transition-all relative cursor-pointer`,tabIndex:0,role:"button","aria-label":r("fileEditor.addFiles","Add files"),onClick:h,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),h())},children:a.jsxs("div",{className:st.addFileContent,children:[a.jsx(_,{gap:"xs",align:"center",children:a.jsx(cn,{alt:"Stirling PDF",muted:!0,style:{height:"2.2rem",width:"auto"}})}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"0.6rem",width:"100%",marginTop:"0.8rem",marginBottom:"0.8rem"},onMouseLeave:()=>l(!1),children:[!i&&a.jsxs(H,{style:{backgroundColor:"var(--landing-button-bg)",color:"var(--landing-button-color)",border:"1px solid var(--landing-button-border)",borderRadius:"2rem",height:"38px",paddingLeft:"1rem",paddingRight:"1rem",width:"calc(100% - 58px - 0.6rem)",display:"flex",alignItems:"center",justifyContent:"center",transition:"width .5s ease, padding .5s ease"},onClick:F,onMouseEnter:()=>l(!1),children:[a.jsx(_e,{icon:"add",width:"1.5rem",height:"1.5rem",className:"text-[var(--accent-interactive)]"}),a.jsx("span",{children:r("landing.addFiles","Add Files")})]}),a.jsxs(H,{"aria-label":r("addFileCard.upload","Upload"),title:c.uploadFromComputer,style:{backgroundColor:"var(--landing-button-bg)",color:"var(--landing-button-color)",border:"1px solid var(--landing-button-border)",borderRadius:"1rem",he
5ight:"38px",width:i?"100%":"58px",minWidth:"58px",paddingLeft:i?"1rem":0,paddingRight:i?"1rem":0,display:"flex",alignItems:"center",justifyContent:"center",transition:"width .5s ease, padding .5s ease",overflow:"hidden"},onClick:g,onMouseEnter:()=>l(!0),children:[a.jsx(_e,{icon:u.uploadIconName,width:"1.25rem",height:"1.25rem",style:{color:"var(--accent-interactive)",flexShrink:0}}),i&&a.jsx("span",{style:{marginLeft:".5rem",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:c.uploadFromComputer})]})]}),a.jsx("span",{className:"text-[var(--accent-interactive)]",style:{fontSize:".8rem",textAlign:"center",marginTop:"0.5rem"},children:c.dropFilesHere})]})})]})},_r=({opened:e,onClose:n,storedFiles:t,onSelectFiles:r})=>{const{t:o}=ke(),s=Me(),[i,l]=x.useState([]);x.useEffect(()=>{e&&l([])},[e]);const c=d=>{l(p=>p.includes(d)?p.filter(y=>y!==d):[...p,d])},u=()=>{l(t.map(d=>d.id).filter(Boolean))},h=()=>{l([])},g=async()=>{const d=t.filter(f=>i.includes(f.id)),y=(await Promise.all(d.map(async f=>{try{if(f instanceof File)return f;if(f.file&&f.file instanceof File)return f.file;if(f.arrayBuffer&&typeof f.arrayBuffer=="function"){const P=await f.arrayBuffer(),j=new Blob([P],{type:f.type||"application/pdf"});return new File([j],f.name,{type:f.type||"application/pdf",lastModified:f.lastModified||Date.now()})}if(f.data){const P=new Blob([f.data],{type:f.type||"application/pdf"});return new File([P],f.name,{type:f.type||"application/pdf",lastModified:f.lastModified||Date.now()})}return console.warn("Could not convert file item:",f),null}catch(P){return console.error("Error converting file:",P,f),null}}))).filter(f=>f!==null);r(y),n()},F=d=>{if(d===0)return"0 B";const p=1024,y=["B","KB","MB","GB"],f=Math.floor(Math.log(d)/Math.log(p));return parseFloat((d/Math.pow(p,f)).toFixed(1))+" "+y[f]};return a.jsx(Te,{opened:e,onClose:n,title:o("fileUpload.selectFromStorage","Select Files from Storage"),size:"lg",scrollAreaComponent:Ke.Autosize,zIndex:1100,children:a.jsxs(pe,{gap:"md",children:[t.length===0?a.jsx($,{c:"dimmed",ta:"center",py:"xl",children:s.noFilesInStorage}):a.jsxs(a.Fragment,{children:[a.jsxs(_,{justify:"space-between",children:[a.jsxs($,{size:"sm",c:"dimmed",children:[t.length," ",o("fileUpload.filesAvailable","files available"),i.length>0&&a.jsxs(a.Fragment,{children:[" • ",i.length," selected"]})]}),a.jsxs(_,{gap:"xs",children:[a.jsx(H,{size:"xs",variant:"light",onClick:u,children:o("pageEdit.selectAll","Select All")}),a.jsx(H,{size:"xs",variant:"light",onClick:h,children:o("pageEdit.deselectAll","Select None")})]})]}),a.jsx(Ke.Autosize,{mah:400,children:a.jsx(un,{cols:2,spacing:"md",children:t.map(d=>{const p=d.id,y=i.includes(p);return a.jsx(fe,{p:"sm",style:{border:y?"2px solid var(--mantine-color-blue-6)":"1px solid var(--mantine-color-gray-3)",borderRadius:8,backgroundColor:y?"var(--mantine-color-blue-0)":"transparent",cursor:"pointer",transition:"all 0.2s ease"},onClick:()=>c(p),children:a.jsxs(_,{gap:"sm",align:"flex-start",children:[a.jsx(pn,{checked:y,onChange:()=>c(p),onClick:f=>f.stopPropagation()}),a.jsx(fe,{style:{width:60,height:80,border:"1px solid var(--mantine-color-gray-3)",borderRadius:4,backgroundColor:"white",flexShrink:0,overflow:"hidden"},children:a.jsx(ft,{file:d,thumbnail:d.processedFile?.isEncrypted?void 0:d.thumbnail,isEncrypted:!!d.processedFile?.isEncrypted,iconSize:"2rem"})}),a.jsxs(pe,{gap:"xs",style:{flex:1,minWidth:0},children:[a.jsx($,{size:"sm",fw:500,lineClamp:2,children:d.name}),a.jsx(_,{gap:"xs",children:a.jsx(fn,{size:"xs",variant:"light",color:"gray",children:F(d.size||d.file?.size||0)})})]})]})},p)})})}),i.length>0&&a.jsxs($,{size:"sm",c:"blue",ta:"center",children:[i.length," ",o("fileManager.filesSelected","files selected")]})]}),a.jsxs(_,{justify:"flex-end",mt:"md",children:[a.jsx(H,{variant:"light",onClick:n,children:o("close","Cancel")}),a.jsx(H,{onClick:g,disabled:i.length===0,children:i.length>0?`${o("fileUpload.loadFromStorage","Load")} ${i.length} ${s.uploadFiles}`:o("fileUpload.loadFromStorage","Load Files")})]})]})})},qr=({toolMode:e=!1,supportedExtensions:n=["pdf"]})=>{const t=x.useCallback(m=>{const v=gn(m);return v?n.includes(v):!1},[n]),{state:r,selectors:o}=dt(),{addFiles:s,removeFiles:i,reorderFiles:l}=vn(),{actions:c}=mn(),{selectedFileIds:u,setSelectedFiles:h}=hn(),g=x.useMemo(()=>o.getStirlingFileStubs(),[r.files.byId,r.files.ids]),{actions:F}=yn(),{setActiveFileIndex:d,setActiveFileId:p}
5=bn(),[y,f]=x.useState(null),[P,j]=x.useState(null),T=x.useCallback((m,v="neutral")=>{L({alertType:v,title:m,expandable:!1,durationMs:4e3})},[]),D=x.useCallback(m=>{L({alertType:"error",title:"Error",body:m,expandable:!0})},[]),{selectedTool:C}=xn(),b=x.useMemo(()=>{const m=C?.maxFiles;return!e||m==null||m<0?1/0:m},[C?.maxFiles,e]),[B,A]=x.useState(!1),O=x.useCallback(async m=>{j(null);try{if(m.length>0){if(await s(m,{selectFiles:!0}),Number.isFinite(b)){const v=o.getSelectedStirlingFileStubs().map(E=>E.id);v.length>b&&h(v.slice(-b))}T(`Added ${m.length} file(s)`,"success")}}catch(v){const E=v instanceof Error?v.message:"Failed to process files";D(E),console.error("File processing error:",v)}},[s,T,D,o,b,h]);x.useEffect(()=>{Number.isFinite(b)&&u.length>b&&h(u.slice(-b))},[b,u,h]);const I=x.useCallback((m,v,E)=>{const S=g.map(k=>k.id),Y=S.findIndex(k=>k===m),X=S.findIndex(k=>k===v);if(Y===-1||X===-1){console.warn("Could not find source or target file for reordering");return}const Q=E.length>1?E.filter(k=>S.includes(k)):[m],W=[...S];Q.map(k=>W.findIndex(V=>V===k)).sort((k,V)=>V-k).forEach(k=>{W.splice(k,1)});let J=W.findIndex(k=>k===v);J!==-1?Y<X&&(J+=1):J=W.length,W.splice(J,0,...Q);const ee=()=>l(W),oe=document;typeof oe.startViewTransition=="function"?oe.startViewTransition(()=>{wn.flushSync(ee)}):ee();const de=Q.length;T(`${de>1?`${de} files`:"File"} reordered`)},[g,l,f]),z=x.useCallback(m=>{const v=g.find(S=>S.id===m),E=v?o.getFile(v.id):null;if(v&&E){const S=v.id;i([S],!1);const Y=u.filter(X=>X!==S);h(Y)}},[g,o,i,h,u]),N=x.useCallback(async m=>{const v=g.find(S=>S.id===m),E=v?o.getFile(v.id):null;if(console.log("[FileEditor] handleDownloadFile called:",{fileId:m,hasRecord:!!v,hasFile:!!E,localFilePath:v?.localFilePath,isDirty:v?.isDirty}),v&&E){const S=await pt({data:E,filename:E.name,localPath:v.localFilePath,fileId:m});console.log("[FileEditor] Download complete, checking dirty state:",{localFilePath:v.localFilePath,isDirty:v.isDirty,savedPath:S.savedPath}),S.savedPath?(console.log("[FileEditor] Marking file as clean:",m),c.updateStirlingFileStub(m,{localFilePath:v.localFilePath??S.savedPath,isDirty:!1})):console.log("[FileEditor] Skipping clean mark:",{savedPath:S.savedPath,isDirty:v.isDirty})}},[g,o,c]),U=x.useCallback(async m=>{const v=g.find(S=>S.id===m),E=v?o.getFile(v.id):null;if(v&&E)try{const S=await ut.extractAndStoreFilesWithHistory(E,v);S.success&&S.extractedStubs.length>0?(await c.addStirlingFileStubs(S.extractedStubs),i([m],!1),L({alertType:"success",title:`Extracted ${S.extractedStubs.length} file(s) from ${E.name}`,expandable:!1,durationMs:3500})):L({alertType:"error",title:`Failed to extract files from ${E.name}`,body:S.errors.join(`
6`),expandable:!0,durationMs:3500})}catch(S){console.error("Failed to unzip file:",S),L({alertType:"error",title:`Error unzipping ${E.name}`,expandable:!1,durationMs:3500})}},[g,o,c,i]),K=x.useCallback(m=>{const v=g.findIndex(E=>E.id===m);v!==-1&&(p(m),d(v),F.setWorkbench("viewer"))},[g,p,d,F.setWorkbench]),Z=x.useCallback(async m=>{if(m.length!==0)try{T(`Loaded ${m.length} files from storage`)}catch(v){console.error("Error loading files from storage:",v),D("Failed to load some files from storage")}},[]);return a.jsx(Sn,{onDrop:O,multiple:!0,maxSize:2*1024*1024*1024,style:{border:"none",borderRadius:0,backgroundColor:"transparent"},activateOnClick:!1,activateOnDrag:!0,children:a.jsxs(fe,{pos:"relative",style:{overflow:"auto"},children:[a.jsx(jn,{visible:r.ui.isProcessing}),a.jsx(fe,{p:"md",children:g.length===0?a.jsx(Cn,{h:"60vh",children:a.jsx(ct,{onFileSelect:O})}):a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",rowGap:"1.5rem",padding:"1rem",pointerEvents:"auto"},children:[g.length>0&&a.jsx(ct,{onFileSelect:O},"add-file-card"),g.map((m,v)=>a.jsx(Lr,{file:m,index:v,totalFiles:g.length,onCloseFile:z,onViewFile:K,onReorderFiles:I,onDownloadFile:N,onUnzipFile:U,toolMode:e,isSupported:t(m.name)},m.id))]})}),a.jsx(_r,{opened:B,onClose:()=>A(!1),storedFiles:[],onSelectFiles:Z})]})})};export{qr as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.