hplx-feature-library 1.0.222 → 1.0.224
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.
- package/dist/Attachments/index.js +1 -1
- package/dist/{Attachments-B9GrTokn.cjs → Attachments-BIIHwdo1.cjs} +1 -1
- package/dist/{Attachments-3UkuRnaT.js → Attachments-Bf4IIvHa.js} +94 -96
- package/dist/PatientPopup/index.js +1 -1
- package/dist/{PatientPopupContainer-Bk00pVxe.js → PatientPopupContainer-B283bpwr.js} +1 -1
- package/dist/{PatientPopupContainer-BA2JxU5G.cjs → PatientPopupContainer-CRyDfB0s.cjs} +1 -1
- package/dist/{PrintModal-4jT2v6c1.js → PrintModal-Bum6_fNo.js} +124 -156
- package/dist/{PrintModal-DOzge7E-.cjs → PrintModal-tamolKuC.cjs} +25 -25
- package/dist/index.js +3 -3
- package/dist/print-pdf/index.js +1 -1
- package/package.json +1 -1
|
@@ -199,4 +199,4 @@ For more info see: https://github.com/konvajs/react-konva/issues/256
|
|
|
199
199
|
`,eS=`ReactKonva: You are using "zIndex" attribute for a Konva node.
|
|
200
200
|
react-konva may get confused with ordering. Just define correct order of elements in your render function of a component.
|
|
201
201
|
For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
202
|
-
`,tS={};function op(s,l,f=tS){if(!Iy&&"zIndex"in l&&(console.warn(eS),Iy=!0),!_y&&l.draggable){var p=l.x!==void 0||l.y!==void 0,x=l.onDragEnd||l.onDragMove;p&&!x&&(console.warn($7),_y=!0)}for(var g in f)if(!Yy[g]){var d=g.slice(0,2)==="on",S=f[g]!==l[g];if(d&&S){var E=g.substr(2).toLowerCase();E.substr(0,7)==="content"&&(E="content"+E.substr(7,1).toUpperCase()+E.substr(8)),s.off(E,f[g])}var h=!l.hasOwnProperty(g);h&&s.setAttr(g,void 0)}var b=l._useStrictMode,A={},w=!1;const C={};for(var g in l)if(!Yy[g]){var d=g.slice(0,2)==="on",R=f[g]!==l[g];if(d&&R){var E=g.substr(2).toLowerCase();E.substr(0,7)==="content"&&(E="content"+E.substr(7,1).toUpperCase()+E.substr(8)),l[g]&&(C[E]=l[g])}!d&&(l[g]!==f[g]||b&&l[g]!==s.getAttr(g))&&(w=!0,A[g]=l[g])}w&&(s.setAttrs(A),il(s));for(var E in C)s.on(E+Rv,C[E])}function il(s){if(!K7.Konva.autoDrawEnabled){var l=s.getLayer()||s.getStage();l&&l.batchDraw()}}var sv=bv();const O5={},nS={};_f.Node.prototype._applyProps=op;function rS(s,l){if(typeof l=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${l}`);return}s.add(l),il(s)}function aS(s,l,f){let p=_f[s];p||(console.error(`Konva has no node with the type ${s}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${s}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),p=_f.Group);const x={},g={};for(var d in l){var S=d.slice(0,2)==="on";S?g[d]=l[d]:x[d]=l[d]}const E=new p(x);return op(E,g),E}function iS(s,l,f){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${s}"`)}function sS(s,l,f){return!1}function lS(s){return s}function oS(){return null}function uS(){return null}function cS(s,l,f,p){return nS}function fS(){}function dS(s){}function hS(s,l){return!1}function pS(){return O5}function mS(){return O5}const vS=setTimeout,gS=clearTimeout,yS=-1;function xS(s,l){return!1}const SS=!1,ES=!0,CS=!0;function bS(s,l){l.parent===s?l.moveToTop():s.add(l),il(s)}function RS(s,l){l.parent===s?l.moveToTop():s.add(l),il(s)}function L5(s,l,f){l._remove(),s.add(l),l.setZIndex(f.getZIndex()),il(s)}function wS(s,l,f){L5(s,l,f)}function TS(s,l){l.destroy(),l.off(Rv),il(s)}function AS(s,l){l.destroy(),l.off(Rv),il(s)}function DS(s,l,f){console.error(`Text components are not yet supported in ReactKonva. You text is: "${f}"`)}function NS(s,l,f){}function MS(s,l,f,p,x){op(s,x,p)}function PS(s){s.hide(),il(s)}function OS(s){}function LS(s,l){(l.visible==null||l.visible)&&s.show()}function jS(s,l){}function FS(s){}function zS(){}const US=()=>P5.DefaultEventPriority,GS=Object.freeze(Object.defineProperty({__proto__:null,appendChild:bS,appendChildToContainer:RS,appendInitialChild:rS,cancelTimeout:gS,clearContainer:FS,commitMount:NS,commitTextUpdate:DS,commitUpdate:MS,createInstance:aS,createTextInstance:iS,detachDeletedInstance:zS,finalizeInitialChildren:sS,getChildHostContext:mS,getCurrentEventPriority:US,getPublicInstance:lS,getRootHostContext:pS,hideInstance:PS,hideTextInstance:OS,idlePriority:sv.unstable_IdlePriority,insertBefore:L5,insertInContainerBefore:wS,isPrimaryRenderer:SS,noTimeout:yS,now:sv.unstable_now,prepareForCommit:oS,preparePortalMount:uS,prepareUpdate:cS,removeChild:TS,removeChildFromContainer:AS,resetAfterCommit:fS,resetTextContent:dS,run:sv.unstable_runWithPriority,scheduleTimeout:vS,shouldDeprioritizeSubtree:hS,shouldSetTextContent:xS,supportsMutation:CS,unhideInstance:LS,unhideTextInstance:jS,warnsIfNotActing:ES},Symbol.toStringTag,{value:"Module"}));var kS=Object.defineProperty,HS=Object.defineProperties,BS=Object.getOwnPropertyDescriptors,Wy=Object.getOwnPropertySymbols,VS=Object.prototype.hasOwnProperty,YS=Object.prototype.propertyIsEnumerable,Xy=(s,l,f)=>l in s?kS(s,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):s[l]=f,Qy=(s,l)=>{for(var f in l||(l={}))VS.call(l,f)&&Xy(s,f,l[f]);if(Wy)for(var f of Wy(l))YS.call(l,f)&&Xy(s,f,l[f]);return s},IS=(s,l)=>HS(s,BS(l)),Jy,qy;typeof window<"u"&&((Jy=window.document)!=null&&Jy.createElement||((qy=window.navigator)==null?void 0:qy.product)==="ReactNative")?ia.useLayoutEffect:ia.useEffect;function j5(s,l,f){if(!s)return;if(f(s)===!0)return s;let p=s.child;for(;p;){const x=j5(p,l,f);if(x)return x;p=p.sibling}}function F5(s){try{return Object.defineProperties(s,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return s}}const Zy=console.error;console.error=function(){const s=[...arguments].join("");if(s?.startsWith("Warning:")&&s.includes("useContext")){console.error=Zy;return}return Zy.apply(this,arguments)};const wv=F5(ia.createContext(null));class z5 extends ia.Component{render(){return ia.createElement(wv.Provider,{value:this._reactInternals},this.props.children)}}function _S(){const s=ia.useContext(wv);if(s===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const l=ia.useId();return ia.useMemo(()=>{for(const p of[s,s?.alternate]){if(!p)continue;const x=j5(p,!1,g=>{let d=g.memoizedState;for(;d;){if(d.memoizedState===l)return!0;d=d.next}});if(x)return x}},[s,l])}function WS(){const s=_S(),[l]=ia.useState(()=>new Map);l.clear();let f=s;for(;f;){if(f.type&&typeof f.type=="object"){const x=f.type._context===void 0&&f.type.Provider===f.type?f.type:f.type._context;x&&x!==wv&&!l.has(x)&&l.set(x,ia.useContext(F5(x)))}f=f.return}return l}function XS(){const s=WS();return ia.useMemo(()=>Array.from(s.keys()).reduce((l,f)=>p=>ia.createElement(l,null,ia.createElement(f.Provider,IS(Qy({},p),{value:s.get(f)}))),l=>ia.createElement(z5,Qy({},l))),[s])}function QS(s){const l=ae.useRef({});return ae.useLayoutEffect(()=>{l.current=s}),ae.useLayoutEffect(()=>()=>{l.current={}},[]),l.current}const JS=s=>{const l=ae.useRef(),f=ae.useRef(),p=ae.useRef(),x=QS(s),g=XS(),d=S=>{const{forwardedRef:E}=s;E&&(typeof E=="function"?E(S):E.current=S)};return ae.useLayoutEffect(()=>(f.current=new _f.Stage({width:s.width,height:s.height,container:l.current}),d(f.current),p.current=Bf.createContainer(f.current,P5.LegacyRoot,!1,null),Bf.updateContainer(ae.createElement(g,{},s.children),p.current),()=>{_f.isBrowser&&(d(null),Bf.updateContainer(null,p.current,null),f.current.destroy())}),[]),ae.useLayoutEffect(()=>{d(f.current),op(f.current,s,x),Bf.updateContainer(ae.createElement(g,{},s.children),p.current,null)}),ae.createElement("div",{ref:l,id:s.id,accessKey:s.accessKey,className:s.className,role:s.role,style:s.style,tabIndex:s.tabIndex,title:s.title})},qS="Layer",Ky="Rect",$y="Circle",ZS="Line",KS="Image",Bf=Q7(GS);Bf.injectIntoDevTools({findHostInstanceByFiber:()=>null,bundleType:process.env.NODE_ENV!=="production"?1:0,version:ae.version,rendererPackageName:"react-konva"});const $S=ae.forwardRef((s,l)=>ae.createElement(z5,{},ae.createElement(JS,{...s,forwardedRef:l}))),U5=({imageUrl:s,customClassName:l="",containerRef:f})=>{const{showPenTool:p,penColor:x,penTool:g,strokeWidth:d}=Xf(),[S,E]=ae.useState(null),[h,b]=ae.useState({width:0,height:0}),[A,w]=ae.useState(!1),[C,R]=ae.useState([]),[M,k]=ae.useState([]),[G,T]=ae.useState(null),y=ae.useRef(null),P=ae.useRef(null),L=600,B=600;ae.useEffect(()=>{const O=new window.Image;O.onload=()=>{E(O);const W=Math.min(L/O.width,B/O.height,1);b({width:Math.min(O.width*W,L),height:Math.min(O.height*W,B)})},O.src=s},[s]);const Q=ae.useCallback(O=>{if(!p||!S)return;if(O.evt.type.startsWith("touch")){O.evt.preventDefault();const q=O.evt;if(q.touches&&q.touches.length>1)return}const W=O.target.getStage()?.getPointerPosition();W&&(w(!0),g===it.E_CANVAS_TOOLS.PEN?R([...C,{points:[{x:W.x,y:W.y}],color:x,width:d}]):(g===it.E_CANVAS_TOOLS.RECT||g===it.E_CANVAS_TOOLS.CIRCLE)&&T({points:[{x:W.x,y:W.y}]}))},[p,S,g,C,x,d]),j=ae.useCallback(O=>{if(!p||!A||!S)return;if(O.evt.type.startsWith("touch")){O.evt.preventDefault();const q=O.evt;if(q.touches&&q.touches.length>1)return}const W=O.target.getStage()?.getPointerPosition();if(W)if(g===it.E_CANVAS_TOOLS.PEN){const q=C[C.length-1];q&&(q.points.push({x:W.x,y:W.y}),C.splice(C.length-1,1,q),R([...C]))}else G&&(g===it.E_CANVAS_TOOLS.RECT||g===it.E_CANVAS_TOOLS.CIRCLE)&&T({points:[G.points[0],{x:W.x,y:W.y}]})},[p,A,S,g,C,G]),H=ae.useCallback(O=>{!p||!S||(O?.evt.type.startsWith("touch")&&O.evt.preventDefault(),w(!1),G&&(g===it.E_CANVAS_TOOLS.RECT||g===it.E_CANVAS_TOOLS.CIRCLE)&&(G.points.length===2&&k([...M,{...G,tool:g,color:x,width:d}]),T(null)))},[p,S,G,g,M,x,d]);return ae.useEffect(()=>{if(!f)return;const O=()=>{const W=document.getElementById(f);if(W&&S){const{clientWidth:q,clientHeight:$}=W,ne=Math.min(q/S.width,$/S.height);b({width:S.width*ne,height:S.height*ne})}};return O(),window.addEventListener("resize",O),()=>window.removeEventListener("resize",O)},[f,S]),ae.useEffect(()=>{const O=W=>{A&&p&&W.preventDefault()};return document.addEventListener("touchstart",O,{passive:!1}),document.addEventListener("touchmove",O,{passive:!1}),document.addEventListener("touchend",O,{passive:!1}),()=>{document.removeEventListener("touchstart",O),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",O)}},[A,p]),S?I.jsxRuntimeExports.jsx("div",{style:{position:"relative",touchAction:"none",WebkitUserSelect:"none",userSelect:"none"},className:l,children:I.jsxRuntimeExports.jsx($S,{ref:y,width:h.width,height:h.height,onMouseDown:Q,onMousemove:j,onMouseup:H,onTouchStart:Q,onTouchMove:j,onTouchEnd:H,style:{border:"1px solid #ccc",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"},children:I.jsxRuntimeExports.jsxs(qS,{children:[I.jsxRuntimeExports.jsx(KS,{ref:P,image:S,x:0,y:0,width:h.width,height:h.height}),C.map((O,W)=>I.jsxRuntimeExports.jsx(ZS,{points:O.points.flatMap(q=>[q.x,q.y]),stroke:O.color,strokeWidth:O.width,tension:.5,lineCap:"round",lineJoin:"round",globalCompositeOperation:"source-over"},`line-${W}`)),M.map((O,W)=>{if(O.tool===it.E_CANVAS_TOOLS.RECT&&O.points.length===2){const[q,$]=O.points;return I.jsxRuntimeExports.jsx(Ky,{x:q.x,y:q.y,width:$.x-q.x,height:$.y-q.y,stroke:O.color,strokeWidth:O.width,fill:"transparent"},`rect-${W}`)}else if(O.tool===it.E_CANVAS_TOOLS.CIRCLE&&O.points.length===2){const[q,$]=O.points,ne=Math.sqrt(Math.pow($.x-q.x,2)+Math.pow($.y-q.y,2));return I.jsxRuntimeExports.jsx($y,{x:q.x,y:q.y,radius:ne,stroke:O.color,strokeWidth:O.width,fill:"transparent"},`circle-${W}`)}return null}),G&&G.points.length===2&&I.jsxRuntimeExports.jsxs(I.jsxRuntimeExports.Fragment,{children:[g===it.E_CANVAS_TOOLS.RECT&&I.jsxRuntimeExports.jsx(Ky,{x:G.points[0].x,y:G.points[0].y,width:G.points[1].x-G.points[0].x,height:G.points[1].y-G.points[0].y,stroke:x,strokeWidth:d,fill:"transparent",dash:[5,5]}),g===it.E_CANVAS_TOOLS.CIRCLE&&I.jsxRuntimeExports.jsx($y,{x:G.points[0].x,y:G.points[0].y,radius:Math.sqrt(Math.pow(G.points[1].x-G.points[0].x,2)+Math.pow(G.points[1].y-G.points[0].y,2)),stroke:x,strokeWidth:d,fill:"transparent",dash:[5,5]})]})]})})}):I.jsxRuntimeExports.jsx("div",{style:{position:"relative"},children:I.jsxRuntimeExports.jsx("div",{style:{width:600,height:400,background:"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center"},children:"Loading image..."})})};function eE(s){const{containerHeight:l,containerWidth:f}=s,{groupDocuments:p}=e7(),{parentRef:x}=ka(),g=ae.useRef(null);let d=1,S=p.length;(p.length===3||p.length===4)&&(d=2,S=2);const E=l/d,h=f/S;return ae.useEffect(()=>{g.current&&(g.current.style.height=`${l}px`,g.current.style.width=`${f}px`)},[l,f,x]),I.jsxRuntimeExports.jsx("div",{ref:g,className:"hfl-bg-Gray-400 hfl-py-2",style:{display:p.length>1?"grid":"flex",gridTemplateColumns:p.length>1?`repeat(${S}, 1fr)`:void 0,gridTemplateRows:p.length>2?`repeat(${d}, 1fr)`:void 0,gap:"8px",height:`${l}px`,width:`${f}px`,justifyContent:p.length===1?"center":void 0,alignItems:"center"},children:p.map((b,A)=>I.jsxRuntimeExports.jsx("div",{style:{width:`${h}px`,height:`${E}px`,display:"flex",alignItems:"center",justifyContent:A%2===0?"flex-end":"flex-start"},id:`compare-${b.id}`,children:I.jsxRuntimeExports.jsx(U5,{imageUrl:b.filePath,containerRef:`compare-${b.id}`})},`compare-${b.id}`))})}const tE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.75%203H18.25C19.7688%203%2021%204.23122%2021%205.75V18.25C21%2019.7688%2019.7688%2021%2018.25%2021H5.75C4.23122%2021%203%2019.7688%203%2018.25V5.75C3%204.23122%204.23122%203%205.75%203ZM5.75%204.5C5.05964%204.5%204.5%205.05964%204.5%205.75V18.25C4.5%2018.9404%205.05964%2019.5%205.75%2019.5H18.25C18.9404%2019.5%2019.5%2018.9404%2019.5%2018.25V5.75C19.5%205.05964%2018.9404%204.5%2018.25%204.5H5.75Z'%20fill='%237C8897'/%3e%3c/svg%3e",nE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADxSURBVHgB7ZI9DoIwGIa/0gt4IRk0TnIR44IjEUNJiIbJDeI9ZJNEceE6HABqqwvy169MDDxJk6Yt7wP0BZiZHKcwst0w9kAT+dzxHNnNdaN1sqQAHJiOxA1vHufkSghfNPdocyFL77m5toiYMnNjQfZIXqpw4BUTww+cPVMKfpLkiZGownsFGAkmfFAwJMGGSwggcC8xEyc9Mdi3F8hwtOBPIkGGSwzAYhi8c66AYg7V/7n4aHkPqAqjBM0LxVYYJehri46E6obrSuiYcB0JHRveJVmutsU7TfL6fqumpISCV/yA7bkkcHbihcCHmUnyAbVr1q3eVypyAAAAAElFTkSuQmCC",rE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0302%202.96967C22.4276%204.36713%2022.4276%206.63286%2021.0302%208.03033L9.06186%2019.9987C8.78498%2020.2755%208.44064%2020.4754%208.06288%2020.5784L2.94719%2021.9736C2.38732%2022.1263%201.87359%2021.6125%202.02628%2021.0527L3.42147%2015.937C3.52449%2015.5592%203.72432%2015.2149%204.0012%2014.938L15.9695%202.96967C17.367%201.5722%2019.6327%201.5722%2021.0302%202.96967ZM15%206.06057L5.06186%2015.9987C4.96956%2016.0909%204.90296%2016.2057%204.86861%2016.3316L3.81877%2020.1811L7.6682%2019.1312C7.79412%2019.0969%207.9089%2019.0303%208.0012%2018.938L17.939%208.99957L15%206.06057ZM17.0302%204.03033L16.06%204.99957L18.999%207.93957L19.9695%206.96967C20.7812%206.15799%2020.7812%204.842%2019.9695%204.03033C19.1578%203.21865%2017.8419%203.21865%2017.0302%204.03033Z'%20fill='%237C8897'/%3e%3c/svg%3e",aE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%202C17.5228%202%2022%206.47715%2022%2012C22%2017.5228%2017.5228%2022%2012%2022C6.47715%2022%202%2017.5228%202%2012C2%206.47715%206.47715%202%2012%202ZM12%203.5C7.30558%203.5%203.5%207.30558%203.5%2012C3.5%2016.6944%207.30558%2020.5%2012%2020.5C16.6944%2020.5%2020.5%2016.6944%2020.5%2012C20.5%207.30558%2016.6944%203.5%2012%203.5Z'%20fill='%237C8897'/%3e%3c/svg%3e";function iE(){const{setShowPenTool:s,setPenTool:l}=Xf(),f=ae.useMemo(()=>[{image:nE,onClick:()=>s(!1),label:"Close icon"},{image:aE,onClick:()=>l(it.E_CANVAS_TOOLS.CIRCLE),label:"Circle icon"},{image:tE,onClick:()=>l(it.E_CANVAS_TOOLS.RECT),label:"Checkbox icon"},{image:rE,onClick:()=>l(it.E_CANVAS_TOOLS.PEN),label:"Edit icon"}],[l,s]);return I.jsxRuntimeExports.jsx("div",{className:"hfl-rounded-md hfl-p-2 hfl-bg-White hfl-flex hfl-flex-col hfl-gap-2 hfl-items-center",children:f.map(p=>I.jsxRuntimeExports.jsx("img",{src:p.image,onClick:p.onClick,width:24,height:24,className:"hfl-cursor-pointer"},p.label))})}function sE(){const{setPenColor:s,penColor:l}=Xf();return I.jsxRuntimeExports.jsx("div",{className:"hfl-rounded-md hfl-p-2 hfl-bg-White hfl-flex hfl-flex-col hfl-gap-2 hfl-items-center",children:li.C_PEN_TOOL_COLORS.map(f=>l===f?I.jsxRuntimeExports.jsx("div",{className:"hfl-border-Primary-600 hfl-w-[26px] hfl-h-[26px] hfl-rounded-full hfl-flex hfl-justify-center hfl-items-center hfl-border-2",children:I.jsxRuntimeExports.jsx("div",{className:"hfl-rounded-full hfl-w-[24px] hfl-h-[24px] ",style:{backgroundColor:f},onClick:()=>s(f)})},f):I.jsxRuntimeExports.jsx("div",{className:"hfl-rounded-full hfl-w-[24px] hfl-h-[24px] ",style:{backgroundColor:f},onClick:()=>s(f)},f))})}function G5(){const s=ae.useRef(null),{parentRef:l}=ka(),{showPenTool:f}=Xf();return ae.useEffect(()=>{if(f&&l.current&&s.current){const p=l.current.getBoundingClientRect(),x=p.width,g=p.height,d=p.top+g*.1,S=p.left+x*.9;s.current.style.position="fixed",s.current.style.top=`${d}px`,s.current.style.left=`${S}px`}},[l,f]),f?I.jsxRuntimeExports.jsxs("div",{className:"hfl-fixed hfl-z-99999999 hfl-flex hfl-flex-col hfl-gap-2",ref:s,children:[I.jsxRuntimeExports.jsx(iE,{}),I.jsxRuntimeExports.jsx(sE,{})]}):null}function lE(){const{clearSelectedDocuments:s,setSelectedGroup:l,selectedGroup:f,selectedDocuments:p,addDocument:x,setShowSaveGroupPreview:g,updateDocument:d}=Sa(),[S,E]=ae.useState(!1),h=ae.useRef(null),{onSaveComparision:b,setCompareMode:A,setShowPreview:w,setError:C}=ka(),[R,M]=ae.useState(f?.label||""),k=ae.useCallback(()=>{w(!1),A(!1),l(null),s(),g(!1)},[s,A,l,w,g]),G=ae.useCallback(async()=>{if(!R){C&&C("Group Name is required");return}try{E(!0);const y=await b(f?.id||"",R,p.map(P=>P.id));y.status&&y.data&&(f?.id?d(y.data):x(y.data))}catch(y){console.error("Error saving comparison:",y)}finally{E(!1),k()}},[x,k,b,p,f?.id,R,C,d]),T=ae.useCallback(()=>{g(!1)},[g]);return I.jsxRuntimeExports.jsxs("div",{className:"hfl-absolute hfl-top-1/2 hfl-left-1/2 hfl-p-4 hfl-bg-white hfl-rounded-lg hfl-shadow-lg hfl-z-[9999999999] hfl-flex hfl-flex-col hfl-gap-2 hfl-transform hfl--translate-x-1/2 hfl--translate-y-1/2",ref:h,children:[I.jsxRuntimeExports.jsx("div",{className:`hfl-w-[400px] hfl-h-[400px] ${p.length<2?"hfl-flex ":"hfl-grid hfl-grid-cols-2"} hfl-border-1 hfl-border-Gray-900 hfl-rounded-lg`,children:p.map((y,P)=>I.jsxRuntimeExports.jsx("img",{src:y.filePath,className:`hfl-object-contain ${p.length<2?"":P%2===0?"hfl-flex hfl-justify-end":"hfl-flex hfl-justify-start"} `,width:200,style:{height:Math.floor(400/Math.round(p.length/2)-2)}},`${y.id}-save`))}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text lg",className:"hfl-text-gray-900",children:"Save Comparision Group"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-gray-500",children:"Save the details of the comparison group"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-gray-900",children:"Group Name"}),I.jsxRuntimeExports.jsx(I.Ps,{inputProps:{value:R,onChange:y=>M(y.target.value),placeholder:"Name"}}),I.jsxRuntimeExports.jsxs("div",{className:"hfl-w-full hfl-flex hfl-justify-between hfl-mt-1 hfl-gap-2",children:[I.jsxRuntimeExports.jsx(I.Ku,{hierarchy:"Secondary",size:"md",textField:"Cancel",onClick:T,className:"hfl-w-full hfl-flex hfl-justify-center"}),I.jsxRuntimeExports.jsx(I.Ku,{hierarchy:"Primary",className:"hfl-bg-Primary-600 hfl-w-full hfl-flex hfl-justify-center",size:"md",textField:"Save",onClick:G,disabled:S})]})]})}function oE(){const{parentRef:s}=ka(),{selectedDocuments:l,selectedGroup:f,showSaveGroupPreview:p}=Sa(),x=ae.useRef(null),[g,d]=ae.useState(void 0),[S,E]=ae.useState([]),[h,b]=ae.useState(0),[A,w]=ae.useState(0);return ae.useEffect(()=>{s.current&&x.current&&(x.current.style.height=`${s.current.clientHeight}px`,x.current.style.width=`${s.current.clientWidth}px`,x.current.style.top=s.current.getBoundingClientRect().top+"px",x.current.style.left=s.current.getBoundingClientRect().left+"px")},[s]),ae.useEffect(()=>{f?(E(f.documents),d(f.id)):(E(l),d(void 0))},[l,f]),ae.useEffect(()=>{if(s.current){const C=s.current.clientHeight;b(C-A)}},[A,s]),I.jsxRuntimeExports.jsx(n5.Provider,{value:{groupDocuments:S,setGroupDocuments:E,groupId:g,setGroupId:d},children:I.jsxRuntimeExports.jsxs("div",{ref:x,className:"hfl-fixed hfl-z-99999",children:[I.jsxRuntimeExports.jsx(R5,{setHeaderHeight:w}),I.jsxRuntimeExports.jsx(eE,{containerHeight:h,containerWidth:x.current?.clientWidth||0}),I.jsxRuntimeExports.jsx(G5,{}),p&&I.jsxRuntimeExports.jsx(lE,{})]})})}function uE(s){const{selectedIndex:l,selectedPreview:f,setSelectedIndex:p}=s,x=ae.useCallback(g=>{p(g)},[p]);return I.jsxRuntimeExports.jsx("div",{className:`hfl-flex hfl-bg-Gray-600 hfl-p-2 hfl-flex-col hfl-gap-2 hfl-h-full ${f.length<2?"hfl-hidden":""}`,children:f.map((g,d)=>I.jsxRuntimeExports.jsx("img",{src:g.filePath,alt:g.label,className:` hfl-object-cover hfl-border-1 ${l===d?"hfl-border-Blue-600":"hfl-border-White"} hfl-cursor-pointer`,width:118,height:146,onClick:()=>x(d)},`${g.id}-document-preview`))})}const cE=ae.memo(uE),fE="data:image/svg+xml,%3csvg%20width='9'%20height='16'%20viewBox='0%200%209%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.03033%2015.2803C8.32322%2014.9874%208.32322%2014.5126%208.03033%2014.2197L1.81066%208L8.03033%201.78033C8.32322%201.48744%208.32322%201.01256%208.03033%200.71967C7.73744%200.426777%207.26256%200.426777%206.96967%200.71967L0.219671%207.46967C-0.0732224%207.76256%20-0.0732225%208.23744%200.219671%208.53033L6.96967%2015.2803C7.26256%2015.5732%207.73744%2015.5732%208.03033%2015.2803Z'%20fill='%23101828'/%3e%3c/svg%3e",dE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.96967%204.71967C8.67678%205.01256%208.67678%205.48744%208.96967%205.78033L15.1893%2012L8.96967%2018.2197C8.67678%2018.5126%208.67678%2018.9874%208.96967%2019.2803C9.26256%2019.5732%209.73744%2019.5732%2010.0303%2019.2803L16.7803%2012.5303C17.0732%2012.2374%2017.0732%2011.7626%2016.7803%2011.4697L10.0303%204.71967C9.73744%204.42678%209.26256%204.42678%208.96967%204.71967Z'%20fill='%23101828'/%3e%3c/svg%3e";function hE(s){const{selectedIndex:l,documentPreview:f,handleImageChange:p,showButtons:x}=s,g=ae.useRef(null),d=ae.useMemo(()=>f[l],[f,l]);return I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-gap-4 hfl-py-2 hfl-items-center",ref:g,children:[x&&I.jsxRuntimeExports.jsx("button",{onClick:()=>p("prev"),className:" hfl-w-[48px] hfl-h-[48px] hfl-rounded-full hfl-bg-Gray-300 hfl-cursor-pointer hfl-flex hfl-justify-center hfl-items-center",disabled:l===0,children:I.jsxRuntimeExports.jsx("img",{src:fE})}),I.jsxRuntimeExports.jsx(U5,{imageUrl:d.filePath,customClassName:" hfl-flex hfl-items-center"}),x&&I.jsxRuntimeExports.jsx("button",{onClick:()=>p("next"),className:" hfl-w-[48px] hfl-h-[48px] hfl-rounded-full hfl-cursor-pointer hfl-bg-Gray-300 hfl-flex hfl-justify-center hfl-items-center",disabled:l===f.length-1,children:I.jsxRuntimeExports.jsx("img",{src:dE})})]})}function pE(){const{parentRef:s}=ka(),l=ae.useRef(null),[f,p]=ae.useState(0),{selectedDocuments:x,selectedGroup:g}=Sa(),d=ae.useRef(null),S=ae.useMemo(()=>g?g.documents:x,[x,g]),E=ae.useMemo(()=>g?g.documents.length:x.length,[x,g]),[h,b]=ae.useState(0);ae.useEffect(()=>{s.current&&l.current&&(l.current.style.height=`${s.current.clientHeight}px`,l.current.style.width=`${s.current.clientWidth}px`,l.current.style.top=s.current.getBoundingClientRect().top+"px",l.current.style.left=s.current.getBoundingClientRect().left+"px")},[s]),ae.useEffect(()=>{if(s.current&&d.current){const w=s.current.clientHeight;d.current.style.height=`${w-f}px`}},[f,s]);const A=ae.useCallback(w=>{b(C=>w==="next"?S.length-1===C?0:C+1:C===0?S.length-1:C-1)},[S.length,b]);return ae.useEffect(()=>{const w=C=>{C.key==="ArrowRight"?A("next"):C.key==="ArrowLeft"&&A("prev")};return window.addEventListener("keydown",w),()=>{window.removeEventListener("keydown",w)}},[A]),I.jsxRuntimeExports.jsxs("div",{className:"hfl-z-99999 hfl-fixed",ref:l,children:[I.jsxRuntimeExports.jsx(R5,{setHeaderHeight:p,isPreview:!0}),I.jsxRuntimeExports.jsxs("div",{className:" hfl-bg-Gray-400 hfl-flex hfl-flex-justify-center hfl-pr-2 hfl-w-full",ref:d,children:[I.jsxRuntimeExports.jsx(cE,{selectedPreview:S,selectedIndex:h,setSelectedIndex:b}),I.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-justify-center hfl-flex",children:I.jsxRuntimeExports.jsx(hE,{showButtons:E>1,documentPreview:S,selectedIndex:h,handleImageChange:A})})]}),I.jsxRuntimeExports.jsx(G5,{})]})}const mE=({file_data:s})=>{const[l,f]=ae.useState(!1),p=ae.useRef(null),x=[{src:s,type:"video/mp4"}],g=d=>{d.currentTarget.remove(),p.current&&p.current.children.length===0&&f(!0)};return I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-justify-center hfl-items-center hfl-w-full hfl-max-w-[800px] hfl-mx-auto",children:l?I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-col hfl-justify-center hfl-items-center hfl-gap-2 hfl-h-[300px] hfl-p-2",children:I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text md",className:"xxxs:max-sm:hfl-text-[10px]",children:"Live preview is not supported for this video. Please download it to watch."})}):I.jsxRuntimeExports.jsxs("video",{ref:p,controls:!0,autoPlay:!0,className:"hfl-flex hfl-justify-center hfl-items-center hfl-w-full hfl-max-w-[800px] hfl-mx-auto hfl-h-[350px]",children:[x.map(({src:d,type:S})=>I.jsxRuntimeExports.jsx("source",{src:d,type:S,onError:g},S)),"Your browser does not support the video tag."]})})},vE=()=>I.jsxRuntimeExports.jsx("div",{className:"hfl-inset-0 hfl-z-[100] hfl-flex hfl-h-full hfl-w-full hfl-items-center hfl-justify-center hfl-overflow-y-auto hfl-outline-none focus:hfl-outline-none",children:I.jsxRuntimeExports.jsx(I.Eu,{progress:10,spinnerMode:!0})}),gE=({file_data:s})=>{const[l,f]=ae.useState(!0),[p,x]=ae.useState(!1);return I.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-w-full hfl-max-w-[800px] hfl-mx-auto",children:[l&&!p&&I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-w-full hfl-justify-center hfl-items-center hfl-h-full",children:I.jsxRuntimeExports.jsx(vE,{})}),p?I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-col hfl-justify-center hfl-items-center hfl-gap-2 hfl-h-[300px] hfl-bg-gray-100 hfl-rounded-lg hfl-p-2",children:I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text md",className:"xxxs:max-sm:hfl-text-[10px]",children:"Live preview is not supported for this image. Please download it."})}):I.jsxRuntimeExports.jsx("img",{src:`${s}?t=${Date.now()}`,loading:"lazy",className:"hfl-w-full hfl-h-auto hfl-transition-opacity hfl-duration-300 hfl-rounded-lg",onLoad:()=>f(!1),onError:()=>{f(!1),x(!0)},style:{opacity:l?0:1},alt:"Preview"})]})},yE=()=>{const{selectedDocuments:s,clearSelectedDocuments:l}=Sa(),{setShowPreview:f,parentRef:p}=ka(),x=ae.useMemo(()=>s[0],[s]),g=ae.useRef(null),d=ae.useCallback(()=>{f(!1),l()},[l,f]),S=ae.useCallback(()=>p?.current&&p.current.clientWidth<=1180,[p]),E=ae.useCallback(()=>{x?.filePath&&(window.open(x.filePath,"_blank"),d())},[x?.filePath,d]);ae.useEffect(()=>{x?.mimeType===it.E_DOCUMENT_FORMAT.PDF&&S()&&E()},[x?.mimeType,S,E]);const h=b=>{switch(b){case it.E_DOCUMENT_FORMAT.PDF:return S()?null:I.jsxRuntimeExports.jsx("div",{className:"hfl-px-6 hfl-pt-4 hfl-pb-20 hfl-bg-white hfl-h-[100vh] hfl-w-full",children:I.jsxRuntimeExports.jsx("iframe",{src:`${x.filePath}`,width:"100%",height:"100%",style:{border:"none"},children:"Your browser does not support PDFs."})});case it.E_DOCUMENT_FORMAT.MP4:return I.jsxRuntimeExports.jsx(mE,{file_data:x.filePath});default:return I.jsxRuntimeExports.jsx(gE,{file_data:x.filePath})}};return I.jsxRuntimeExports.jsx(I.jsxRuntimeExports.Fragment,{children:I.jsxRuntimeExports.jsx(Sx.ReusableModal,{childModalRef:g,backdropClasses:"",clickOutsideHandler:()=>{},closeOnClickOutside:!1,hideBackDrop:!1,modalClasses:"hfl-mx-10 xsm:hfl-mx-6 hfl-w-[70%]",position:"hfl-inset-0",children:I.jsxRuntimeExports.jsxs("div",{className:"hfl-relative",children:[I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-h-12 hfl-items-center hfl-border-b-1 hfl-justify-between hfl-px-4",children:I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-col hfl-gap-0",children:I.jsxRuntimeExports.jsx(I.bs,{variant:"Bold",type:"Text md",className:"hfl-text-Gray-800",children:x.label})})}),I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-w-full",children:I.jsxRuntimeExports.jsx("div",{className:"hfl-bg-gray-200 hfl-flex hfl-justify-center hfl-w-full hfl-h-full hfl-px-10 hfl-pt-6 hfl-pb-20 hfl-max-h-[80vh] hfl-overflow-y-auto hfl-rounded-bl-lg",children:h(x.mimeType)})}),I.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-absolute hfl-bottom-0 hfl-mt-[10px] hfl-bg-white hfl-py-2 hfl-px-2",children:I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center hfl-justify-end hfl-gap-2",children:I.jsxRuntimeExports.jsx(I.Ku,{textField:"Close",size:"sm",hierarchy:"Primary",onClick:d,className:"hfl-border-Blue-300 hfl-bg-Blue-50 hfl-text-Blue-600 hfl-border-1 hover:hfl-text-White hover:hfl-bg-Blue-600"})})})]})})})},xE=[{label:"Unspecified",value:it.E_DOCUMENT_TYPE.REPORT_TYPE_UNSPECIFIED},...Object.values(it.E_DOCUMENT_TYPE).filter(s=>s!==it.E_DOCUMENT_TYPE.REPORT_TYPE_UNSPECIFIED).map(s=>({label:s.charAt(0).toUpperCase()+s.slice(1).replace(/_/g," "),value:s}))];function SE({isOpen:s,document:l,onClose:f,onSave:p}){const[x,g]=ae.useState(""),[d,S]=ae.useState(""),[E,h]=ae.useState(!1),[b,A]=ae.useState(""),[w,C]=ae.useState("");ae.useEffect(()=>{if(l){const M=l.label,k=M.lastIndexOf(".");k!==-1?(A(M.substring(0,k)),C(M.substring(k))):(A(M),C("")),g(l.reportType||it.E_DOCUMENT_TYPE.REPORT_TYPE_UNSPECIFIED),S(new Date(l.createdAt).toISOString().split("T")[0])}},[l]);const R=async()=>{if(l){h(!0);try{const M={id:l.id,label:`${b}${w}`,reportType:x===it.E_DOCUMENT_TYPE.REPORT_TYPE_UNSPECIFIED?"":x,createdAt:new Date(d).toISOString(),filePath:l.filePath,mimeType:l.mimeType,downloadPath:l.downloadPath,fileName:l.fileName};await p(M),f()}catch(M){console.error("Failed to save document:",M)}finally{h(!1)}}};return!s||!l?null:I.jsxRuntimeExports.jsx("div",{className:"hfl-fixed hfl-inset-0 hfl-bg-black hfl-bg-opacity-50 hfl-flex hfl-items-center hfl-justify-center hfl-z-50",children:I.jsxRuntimeExports.jsxs("div",{className:"hfl-bg-white hfl-rounded-lg hfl-p-8 hfl-w-full hfl-max-w-md hfl-flex hfl-flex-col hfl-gap-6",children:[I.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-h-48 hfl-bg-Gray-100 hfl-rounded-lg hfl-overflow-hidden",children:I.jsxRuntimeExports.jsx(d5,{documents:l})}),I.jsxRuntimeExports.jsxs("div",{children:[I.jsxRuntimeExports.jsx(I.bs,{variant:"Semibold",type:"Text xl",className:"hfl-text-Gray-900",children:"Edit Document"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-500",children:"Edit the details of the document."})]}),I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-4",children:[I.jsxRuntimeExports.jsxs("div",{children:[I.jsxRuntimeExports.jsx("label",{htmlFor:"documentName",className:"hfl-block hfl-text-sm hfl-font-medium hfl-text-Gray-700 hfl-mb-1",children:"Document Name"}),I.jsxRuntimeExports.jsx("input",{id:"documentName",value:b,onChange:M=>A(M.target.value),placeholder:"Enter document name",className:"hfl-w-full hfl-border hfl-border-Gray-300 hfl-rounded-md hfl-px-3 hfl-py-2 focus:hfl-outline-none focus:hfl-ring-2 focus:hfl-ring-Primary-500"})]}),I.jsxRuntimeExports.jsxs("div",{children:[I.jsxRuntimeExports.jsx("label",{className:"hfl-block hfl-text-sm hfl-font-medium hfl-text-Gray-700 hfl-mb-1",children:"Type"}),I.jsxRuntimeExports.jsx("select",{value:x,onChange:M=>g(M.target.value),className:"hfl-w-full hfl-border hfl-border-Gray-300 hfl-rounded-md hfl-px-3 hfl-py-2 focus:hfl-outline-none focus:hfl-ring-2 focus:hfl-ring-Primary-500",children:xE.map(M=>I.jsxRuntimeExports.jsx("option",{value:M.value,children:M.label},M.value))})]}),I.jsxRuntimeExports.jsxs("div",{children:[I.jsxRuntimeExports.jsx("label",{className:"hfl-block hfl-text-sm hfl-font-medium hfl-text-Gray-700 hfl-mb-1",children:"Creation Date"}),I.jsxRuntimeExports.jsx("input",{type:"date",value:d,onChange:M=>S(M.target.value),className:"hfl-w-full hfl-border hfl-border-Gray-300 hfl-rounded-md hfl-px-3 hfl-py-2 focus:hfl-outline-none focus:hfl-ring-2 focus:hfl-ring-Primary-500"})]})]}),I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-justify-end hfl-gap-3 hfl-mt-4",children:[I.jsxRuntimeExports.jsx(I.Ku,{textField:"Cancel",hierarchy:"Secondary",onClick:f,disabled:E,size:"sm"}),I.jsxRuntimeExports.jsx(I.Ku,{textField:E?"Saving...":"Save",hierarchy:"Primary",onClick:R,disabled:E,size:"sm"})]})]})})}function EE({isOpen:s,onClose:l,onCapture:f}){const p=ae.useRef(null),x=ae.useRef(null),g=ae.useRef(null),[d,S]=ae.useState(!1),[E,h]=ae.useState(null),[b,A]=ae.useState(!1),[w,C]=ae.useState(!1),[R,M]=ae.useState([]),[k,G]=ae.useState(null),T=async()=>{try{const j=(await navigator.mediaDevices.enumerateDevices()).filter(H=>H.kind==="videoinput");console.log("Available video devices:",j),M(j)}catch(Q){console.error("Error enumerating devices:",Q)}};ae.useEffect(()=>{s&&T()},[s]);const y=async()=>{console.log("inside startCamera"),console.log("videoRef.current at start:",p.current),console.log("videoRef.current?.readyState:",p.current?.readyState);try{S(!0),h(null),console.log("before getUserMedia");const Q=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720},facingMode:"environment"},audio:!1});console.log("after getUserMedia, stream:",Q),console.log("stream.getTracks():",Q.getTracks()),g.current=Q,console.log("videoRef.current after getUserMedia:",p.current),console.log("videoRef.current?.readyState after getUserMedia:",p.current?.readyState),G(Q),C(!0),console.log("after setHasPermission")}catch(Q){console.error("Error accessing camera:",Q),Q instanceof Error?Q.name==="NotAllowedError"?h("Camera access denied. Please grant permission to use the camera."):Q.name==="NotFoundError"?h("No camera found on this device."):Q.name==="NotSupportedError"?h("Camera is not supported on this device."):h("Failed to access camera. Please try again."):h("Failed to access camera. Please try again.")}finally{S(!1),console.log("startCamera finally block - isLoading set to false")}};ae.useEffect(()=>{k&&p.current&&w&&(p.current.srcObject=k,p.current.play().catch(Q=>{console.error("Error playing video:",Q)}))},[k,w]);const P=()=>{console.log("stopCamera called"),g.current&&(console.log("Stopping stream tracks:",g.current.getTracks().length),g.current.getTracks().forEach(Q=>{console.log("Stopping track:",Q.kind,Q.readyState),Q.stop()}),g.current=null),p.current&&(console.log("Clearing video srcObject"),p.current.srcObject=null),C(!1),console.log("stopCamera completed")},L=async()=>{if(!(!p.current||!x.current)){A(!0);try{const Q=p.current,j=x.current,H=j.getContext("2d");if(!H)throw new Error("Unable to get canvas context");j.width=Q.videoWidth,j.height=Q.videoHeight,H.drawImage(Q,0,0,j.width,j.height);const O=await new Promise(($,ne)=>{j.toBlob(ee=>{ee?$(ee):ne(new Error("Failed to create image blob"))},"image/jpeg",.8)}),W=new Date().toISOString().replace(/[:.]/g,"-"),q=new File([O],`captured-image-${W}.jpg`,{type:"image/jpeg"});await f(q),l()}catch(Q){console.error("Error capturing photo:",Q),h("Failed to capture photo. Please try again.")}finally{A(!1)}}},B=async()=>{if(!g.current)return;const j=g.current.getVideoTracks()[0].getSettings().facingMode;P();try{const H=j==="environment"?"user":"environment",O=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720},facingMode:H},audio:!1});g.current=O,p.current&&(p.current.srcObject=O,p.current.play())}catch(H){console.error("Error switching camera:",H),h("Failed to switch camera. Using default camera."),y()}};return ae.useEffect(()=>(console.log("useEffect triggered with isOpen:",s),s?(console.log("Calling startCamera from useEffect"),T(),y()):(console.log("Calling stopCamera from useEffect"),P(),h(null)),()=>{console.log("useEffect cleanup - calling stopCamera"),P()}),[s]),s?I.jsxRuntimeExports.jsx("div",{className:"hfl-fixed hfl-inset-0 hfl-bg-black hfl-bg-opacity-75 hfl-flex hfl-items-center hfl-justify-center hfl-z-50",children:I.jsxRuntimeExports.jsxs("div",{className:"hfl-bg-white hfl-rounded-lg hfl-p-6 hfl-w-full hfl-max-w-2xl hfl-max-h-[90vh] hfl-overflow-hidden",children:[I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between hfl-mb-4",children:[I.jsxRuntimeExports.jsx(I.bs,{variant:"Semibold",type:"Text lg",className:"hfl-text-Gray-900",children:"Capture Photo"}),I.jsxRuntimeExports.jsx("button",{onClick:l,className:"hfl-text-Gray-500 hfl-hover:text-Gray-700 hfl-p-1 hfl-h-4 hfl-w-4",children:I.jsxRuntimeExports.jsx("i",{className:"hx_close hfl-text-xl"})})]}),I.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-bg-black hfl-rounded-lg hfl-overflow-hidden hfl-mb-4",children:[d&&I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-h-64",children:I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-white",children:"Loading camera..."})}),E&&I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-justify-center hfl-h-64 hfl-p-4",children:[I.jsxRuntimeExports.jsx("i",{className:"hx_camera hfl-text-4xl hfl-text-Gray-400 hfl-mb-2"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-600 hfl-text-center",children:E}),I.jsxRuntimeExports.jsx("button",{onClick:y,className:"hfl-mt-3 hfl-px-4 hfl-py-2 hfl-bg-Blue-600 hfl-text-white hfl-rounded-lg hfl-hover:bg-Blue-700",children:"Try Again"})]}),w&&!E&&I.jsxRuntimeExports.jsx("video",{ref:p,className:"hfl-w-full hfl-h-auto hfl-max-h-96",onLoadedMetadata:()=>console.log("Video onLoadedMetadata"),onCanPlay:()=>console.log("Video onCanPlay"),onPlaying:()=>console.log("Video onPlaying"),onWaiting:()=>console.log("Video onWaiting"),onError:Q=>console.log("Video onError:",Q),onLoadStart:()=>console.log("Video onLoadStart"),autoPlay:!0,playsInline:!0,muted:!0}),I.jsxRuntimeExports.jsx("canvas",{ref:x,className:"hfl-hidden"})]}),w&&!E&&I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-gap-4",children:[R.length>1&&I.jsxRuntimeExports.jsxs("button",{onClick:B,className:"hfl-flex hfl-items-center hfl-gap-2 hfl-px-4 hfl-py-2 hfl-text-sm hfl-text-Gray-700 hfl-border hfl-border-Gray-300 hfl-rounded-lg hfl-hover:bg-Gray-50",children:[I.jsxRuntimeExports.jsx("i",{className:"hx_refresh hfl-text-base"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text sm",children:"Switch Camera"})]}),I.jsxRuntimeExports.jsxs("button",{onClick:L,disabled:b,className:`hfl-flex hfl-items-center hfl-gap-2 hfl-px-6 hfl-py-3 hfl-text-sm hfl-text-white hfl-rounded-lg hfl-transition-colors ${b?"hfl-bg-Gray-400 hfl-cursor-not-allowed":"hfl-bg-Blue-600 hfl-hover:bg-Blue-700"}`,children:[I.jsxRuntimeExports.jsx("i",{className:"hx_camera hfl-text-base"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text sm",className:"hfl-text-white",children:b?"Capturing...":"Capture Photo"})]})]})]})}):null}function CE({containerRef:s,setPage:l,hasData:f,shouldScroll:p,setNextDate:x,cursor:g,query_type:d}){const S=ae.useRef(p),E=ae.useRef(0),h=ae.useRef(!1);ae.useEffect(()=>{S.current=p},[p]),ae.useEffect(()=>{if(!s||!s.current)return;console.log("Inside scroll event",f);const b=s.current;if(!b)return;const A=()=>{if(!S.current||!f)return;const{scrollTop:w,scrollHeight:C,clientHeight:R}=b;h.current=w>E.current,E.current=w,h.current&&w+R>=C-10&&(d===it.E_ATTACHMENT_QUERY_TYPE.VIEW_GRID?l(M=>M+1):x(g))};return b.addEventListener("scroll",A),()=>{b.removeEventListener("scroll",A)}},[s,l,f,d,x,g])}function bE(s){const{isUploading:l}=s;return l?I.jsxRuntimeExports.jsxs("div",{className:"hfl-absolute hfl-flex hfl-gap-2 hfl-items-center hfl-left-[90%] hfl-top-[80%] hfl-p-3 hfl-rounded-md hfl-border-l-2 hfl-border-b-2 hfl-border-l-Success-600 hfl-border-b-Success-600 hfl-bg-White hfl-shadow-upload hfl-translate-x-[-80%] hfl-translate-y-[-90%] hfl-min-w-[375px] ",children:[I.jsxRuntimeExports.jsx("div",{className:"hfl-h-[32px] hfl-min-w-[32px] hfl-flex hfl-justify-center hfl-items-center hfl-rounded-md hfl-bg-Success-600",children:I.jsxRuntimeExports.jsx("i",{className:"hx_checkmark hfl-text-White "})}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-800",children:"Your file(s) are being uploaded. Do not refresh or close the page."})]}):null}const RE=ae.memo(bE);function wE(s){const{parentRef:l,fetchAttachments:f,uploadFiles:p,onDocumentPreview:x,onDocumentDownload:g,onDocumentUpdate:d,setError:S,showHeaderBackButton:E,patient_id:h="",patient_role_id:b="",doctor_id:A="",doctor_role_id:w="",branch_id:C="",onDeleteAttachments:R,onSaveComparision:M,onHeaderBackClick:k}=s,[G,T]=ae.useState(!1),[y,P]=ae.useState(!1),[L,B]=ae.useState(""),[Q,j]=ae.useState(!0),[H,O]=ae.useState([]),[W,q]=ae.useState({startDate:null,endDate:null}),[$,ne]=ae.useState(1),[ee,me]=ae.useState(""),[F,U]=ae.useState(""),X=ae.useRef(null),[Y,Z]=ae.useState(it.E_ATTACHMENT_QUERY_TYPE.VIEW_GRID),{documentView:le,setDocument:re,addDocuments:ge,selectedDocuments:be,addDocument:oe,updateDocument:J}=Sa(),ue=ae.useMemo(()=>le===it.E_DOCUMENT_VIEW_TYPE.GRID_VIEW?20:3,[le]),[Ae,De]=ae.useState(null),[Oe,Xe]=ae.useState(!1),[xe,je]=ae.useState(!1),Le=ae.useMemo(()=>!G&&!y,[G,y]),{isLoading:qe}=J9(`attachments?page=${$}&page_size=${ue}&query_type=${Y}&search=${L}&types=${H.join(",")}&start_date=${W.startDate}&end_date=${W.endDate}&next_date=${ee}&patient_id=${h}&patient_role_id=${b}&doctor_id=${A}&doctor_role_id=${w}&branch_id=${C}`,()=>f($,L,H,ue,Y,W,ee),{revalidateOnFocus:!1,onSuccess:nt=>{nt.data&&($===1&&Y===it.E_ATTACHMENT_QUERY_TYPE.VIEW_GRID?re(nt.data):ee&&Y===it.E_ATTACHMENT_QUERY_TYPE.VIEW_DATE?ge(nt.data):Y===it.E_ATTACHMENT_QUERY_TYPE.VIEW_DATE?re(nt.data):ge(nt.data),(nt.data.length===0||nt.data.length<ue)&&j(!1),U(nt.next_date||""))},onError:nt=>S?.(`Failed to fetch documents: ${nt.message}`)});ae.useEffect(()=>{l.current&&X.current&&(X.current.style.height=`${l.current.clientHeight}px`)},[l]);const Ze=async nt=>{je(!0);try{const{validFiles:Vt,errors:fn}=f5(nt);if(fn.length>0&&fn.forEach(sn=>S?.(sn)),Vt.length>0){const sn=await p({files:Vt});let Ne=!0;console.log("Upload response for a file1: ",sn.data),sn.data.forEach(Be=>{console.log("Upload response for a file: ",Be),Be.success&&Be.data?(console.log("Adding document: ",Be.data),oe(Be.data)):Ne=!1}),Ne||S?.("Failed to upload all files")}}catch(Vt){S?.(`Failed to upload files. Please try again. ${Vt}`)}finally{je(!1)}},gt=async nt=>{await Ze([nt])},Dt=nt=>{De(nt)},dt=nt=>{x&&x(nt)},yt=nt=>{g&&g(nt)},St=()=>{De(null)},cn=async nt=>{try{const Vt=await d(nt);Vt.success&&Vt.data?J(Vt.data):S?.("Failed to update document.")}catch(Vt){S?.("An unexpected error occurred while updating the document."),console.error(Vt)}},nn=()=>Xe(!0),Bt=()=>Xe(!1);return CE({containerRef:X,setPage:ne,hasData:Q,shouldScroll:!qe,cursor:F,setNextDate:me,query_type:Y}),ae.useEffect(()=>{console.log("Page",$)},[$]),I.jsxRuntimeExports.jsxs(t5.Provider,{value:{page:$,setPage:ne,hasData:Q,queryType:Y,setQueryType:Z,setShowPreview:T,showPreview:G,compareMode:y,setCompareMode:P,parentRef:l,search:L,setSearch:B,types:H,setTypes:O,dates:W,setDates:q,setHasData:j,onSaveComparision:M,onDeleteAttachments:R,setError:S},children:[I.jsxRuntimeExports.jsxs("div",{ref:X,className:`hfl-w-full hfl-relative hfl-overflow-scroll ${Oe?"hfl-overflow-hidden":""}`,children:[Le&&I.jsxRuntimeExports.jsx($9,{showBackButton:E&&!G&&!y,onFileUpload:Ze,setNextDate:me,setCursor:U,onCaptureClick:nn,isUploading:xe,setIsUploading:je,onHeaderBackClickCb:E&&k?k:void 0}),le===it.E_DOCUMENT_VIEW_TYPE.GRID_VIEW?I.jsxRuntimeExports.jsx(h9,{onFileUpload:Ze,onEdit:Dt,onPreview:dt,onDownload:yt}):I.jsxRuntimeExports.jsx(m9,{onFileUpload:Ze,onEdit:Dt,onPreview:dt,onDownload:yt}),be.length>0&&!G&&!y&&I.jsxRuntimeExports.jsx(Z9,{})]}),y&&I.jsxRuntimeExports.jsx(oE,{}),G&&be.length>0&&(be[0].mimeType===it.E_DOCUMENT_FORMAT.JPEG||be[0].mimeType===it.E_DOCUMENT_FORMAT.PNG)&&I.jsxRuntimeExports.jsx(pE,{}),G&&be.length>0&&be[0].mimeType!==it.E_DOCUMENT_FORMAT.JPEG&&be[0].mimeType!==it.E_DOCUMENT_FORMAT.PNG&&I.jsxRuntimeExports.jsx(yE,{}),Ae&&I.jsxRuntimeExports.jsx(SE,{isOpen:!!Ae,document:Ae,onClose:St,onSave:cn}),I.jsxRuntimeExports.jsx(EE,{isOpen:Oe,onClose:Bt,onCapture:gt}),I.jsxRuntimeExports.jsx(RE,{isUploading:xe})]})}exports.Attachments=wE;
|
|
202
|
+
`,tS={};function op(s,l,f=tS){if(!Iy&&"zIndex"in l&&(console.warn(eS),Iy=!0),!_y&&l.draggable){var p=l.x!==void 0||l.y!==void 0,x=l.onDragEnd||l.onDragMove;p&&!x&&(console.warn($7),_y=!0)}for(var g in f)if(!Yy[g]){var d=g.slice(0,2)==="on",S=f[g]!==l[g];if(d&&S){var E=g.substr(2).toLowerCase();E.substr(0,7)==="content"&&(E="content"+E.substr(7,1).toUpperCase()+E.substr(8)),s.off(E,f[g])}var h=!l.hasOwnProperty(g);h&&s.setAttr(g,void 0)}var b=l._useStrictMode,A={},w=!1;const C={};for(var g in l)if(!Yy[g]){var d=g.slice(0,2)==="on",R=f[g]!==l[g];if(d&&R){var E=g.substr(2).toLowerCase();E.substr(0,7)==="content"&&(E="content"+E.substr(7,1).toUpperCase()+E.substr(8)),l[g]&&(C[E]=l[g])}!d&&(l[g]!==f[g]||b&&l[g]!==s.getAttr(g))&&(w=!0,A[g]=l[g])}w&&(s.setAttrs(A),il(s));for(var E in C)s.on(E+Rv,C[E])}function il(s){if(!K7.Konva.autoDrawEnabled){var l=s.getLayer()||s.getStage();l&&l.batchDraw()}}var sv=bv();const O5={},nS={};_f.Node.prototype._applyProps=op;function rS(s,l){if(typeof l=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${l}`);return}s.add(l),il(s)}function aS(s,l,f){let p=_f[s];p||(console.error(`Konva has no node with the type ${s}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${s}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),p=_f.Group);const x={},g={};for(var d in l){var S=d.slice(0,2)==="on";S?g[d]=l[d]:x[d]=l[d]}const E=new p(x);return op(E,g),E}function iS(s,l,f){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${s}"`)}function sS(s,l,f){return!1}function lS(s){return s}function oS(){return null}function uS(){return null}function cS(s,l,f,p){return nS}function fS(){}function dS(s){}function hS(s,l){return!1}function pS(){return O5}function mS(){return O5}const vS=setTimeout,gS=clearTimeout,yS=-1;function xS(s,l){return!1}const SS=!1,ES=!0,CS=!0;function bS(s,l){l.parent===s?l.moveToTop():s.add(l),il(s)}function RS(s,l){l.parent===s?l.moveToTop():s.add(l),il(s)}function L5(s,l,f){l._remove(),s.add(l),l.setZIndex(f.getZIndex()),il(s)}function wS(s,l,f){L5(s,l,f)}function TS(s,l){l.destroy(),l.off(Rv),il(s)}function AS(s,l){l.destroy(),l.off(Rv),il(s)}function DS(s,l,f){console.error(`Text components are not yet supported in ReactKonva. You text is: "${f}"`)}function NS(s,l,f){}function MS(s,l,f,p,x){op(s,x,p)}function PS(s){s.hide(),il(s)}function OS(s){}function LS(s,l){(l.visible==null||l.visible)&&s.show()}function jS(s,l){}function FS(s){}function zS(){}const US=()=>P5.DefaultEventPriority,GS=Object.freeze(Object.defineProperty({__proto__:null,appendChild:bS,appendChildToContainer:RS,appendInitialChild:rS,cancelTimeout:gS,clearContainer:FS,commitMount:NS,commitTextUpdate:DS,commitUpdate:MS,createInstance:aS,createTextInstance:iS,detachDeletedInstance:zS,finalizeInitialChildren:sS,getChildHostContext:mS,getCurrentEventPriority:US,getPublicInstance:lS,getRootHostContext:pS,hideInstance:PS,hideTextInstance:OS,idlePriority:sv.unstable_IdlePriority,insertBefore:L5,insertInContainerBefore:wS,isPrimaryRenderer:SS,noTimeout:yS,now:sv.unstable_now,prepareForCommit:oS,preparePortalMount:uS,prepareUpdate:cS,removeChild:TS,removeChildFromContainer:AS,resetAfterCommit:fS,resetTextContent:dS,run:sv.unstable_runWithPriority,scheduleTimeout:vS,shouldDeprioritizeSubtree:hS,shouldSetTextContent:xS,supportsMutation:CS,unhideInstance:LS,unhideTextInstance:jS,warnsIfNotActing:ES},Symbol.toStringTag,{value:"Module"}));var kS=Object.defineProperty,HS=Object.defineProperties,BS=Object.getOwnPropertyDescriptors,Wy=Object.getOwnPropertySymbols,VS=Object.prototype.hasOwnProperty,YS=Object.prototype.propertyIsEnumerable,Xy=(s,l,f)=>l in s?kS(s,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):s[l]=f,Qy=(s,l)=>{for(var f in l||(l={}))VS.call(l,f)&&Xy(s,f,l[f]);if(Wy)for(var f of Wy(l))YS.call(l,f)&&Xy(s,f,l[f]);return s},IS=(s,l)=>HS(s,BS(l)),Jy,qy;typeof window<"u"&&((Jy=window.document)!=null&&Jy.createElement||((qy=window.navigator)==null?void 0:qy.product)==="ReactNative")?ia.useLayoutEffect:ia.useEffect;function j5(s,l,f){if(!s)return;if(f(s)===!0)return s;let p=s.child;for(;p;){const x=j5(p,l,f);if(x)return x;p=p.sibling}}function F5(s){try{return Object.defineProperties(s,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return s}}const Zy=console.error;console.error=function(){const s=[...arguments].join("");if(s?.startsWith("Warning:")&&s.includes("useContext")){console.error=Zy;return}return Zy.apply(this,arguments)};const wv=F5(ia.createContext(null));class z5 extends ia.Component{render(){return ia.createElement(wv.Provider,{value:this._reactInternals},this.props.children)}}function _S(){const s=ia.useContext(wv);if(s===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const l=ia.useId();return ia.useMemo(()=>{for(const p of[s,s?.alternate]){if(!p)continue;const x=j5(p,!1,g=>{let d=g.memoizedState;for(;d;){if(d.memoizedState===l)return!0;d=d.next}});if(x)return x}},[s,l])}function WS(){const s=_S(),[l]=ia.useState(()=>new Map);l.clear();let f=s;for(;f;){if(f.type&&typeof f.type=="object"){const x=f.type._context===void 0&&f.type.Provider===f.type?f.type:f.type._context;x&&x!==wv&&!l.has(x)&&l.set(x,ia.useContext(F5(x)))}f=f.return}return l}function XS(){const s=WS();return ia.useMemo(()=>Array.from(s.keys()).reduce((l,f)=>p=>ia.createElement(l,null,ia.createElement(f.Provider,IS(Qy({},p),{value:s.get(f)}))),l=>ia.createElement(z5,Qy({},l))),[s])}function QS(s){const l=ae.useRef({});return ae.useLayoutEffect(()=>{l.current=s}),ae.useLayoutEffect(()=>()=>{l.current={}},[]),l.current}const JS=s=>{const l=ae.useRef(),f=ae.useRef(),p=ae.useRef(),x=QS(s),g=XS(),d=S=>{const{forwardedRef:E}=s;E&&(typeof E=="function"?E(S):E.current=S)};return ae.useLayoutEffect(()=>(f.current=new _f.Stage({width:s.width,height:s.height,container:l.current}),d(f.current),p.current=Bf.createContainer(f.current,P5.LegacyRoot,!1,null),Bf.updateContainer(ae.createElement(g,{},s.children),p.current),()=>{_f.isBrowser&&(d(null),Bf.updateContainer(null,p.current,null),f.current.destroy())}),[]),ae.useLayoutEffect(()=>{d(f.current),op(f.current,s,x),Bf.updateContainer(ae.createElement(g,{},s.children),p.current,null)}),ae.createElement("div",{ref:l,id:s.id,accessKey:s.accessKey,className:s.className,role:s.role,style:s.style,tabIndex:s.tabIndex,title:s.title})},qS="Layer",Ky="Rect",$y="Circle",ZS="Line",KS="Image",Bf=Q7(GS);Bf.injectIntoDevTools({findHostInstanceByFiber:()=>null,bundleType:process.env.NODE_ENV!=="production"?1:0,version:ae.version,rendererPackageName:"react-konva"});const $S=ae.forwardRef((s,l)=>ae.createElement(z5,{},ae.createElement(JS,{...s,forwardedRef:l}))),U5=({imageUrl:s,customClassName:l="",containerRef:f})=>{const{showPenTool:p,penColor:x,penTool:g,strokeWidth:d}=Xf(),[S,E]=ae.useState(null),[h,b]=ae.useState({width:0,height:0}),[A,w]=ae.useState(!1),[C,R]=ae.useState([]),[M,k]=ae.useState([]),[G,T]=ae.useState(null),y=ae.useRef(null),P=ae.useRef(null),L=600,B=600;ae.useEffect(()=>{const O=new window.Image;O.onload=()=>{E(O);const W=Math.min(L/O.width,B/O.height,1);b({width:Math.min(O.width*W,L),height:Math.min(O.height*W,B)})},O.src=s},[s]);const Q=ae.useCallback(O=>{if(!p||!S)return;if(O.evt.type.startsWith("touch")){O.evt.preventDefault();const q=O.evt;if(q.touches&&q.touches.length>1)return}const W=O.target.getStage()?.getPointerPosition();W&&(w(!0),g===it.E_CANVAS_TOOLS.PEN?R([...C,{points:[{x:W.x,y:W.y}],color:x,width:d}]):(g===it.E_CANVAS_TOOLS.RECT||g===it.E_CANVAS_TOOLS.CIRCLE)&&T({points:[{x:W.x,y:W.y}]}))},[p,S,g,C,x,d]),j=ae.useCallback(O=>{if(!p||!A||!S)return;if(O.evt.type.startsWith("touch")){O.evt.preventDefault();const q=O.evt;if(q.touches&&q.touches.length>1)return}const W=O.target.getStage()?.getPointerPosition();if(W)if(g===it.E_CANVAS_TOOLS.PEN){const q=C[C.length-1];q&&(q.points.push({x:W.x,y:W.y}),C.splice(C.length-1,1,q),R([...C]))}else G&&(g===it.E_CANVAS_TOOLS.RECT||g===it.E_CANVAS_TOOLS.CIRCLE)&&T({points:[G.points[0],{x:W.x,y:W.y}]})},[p,A,S,g,C,G]),H=ae.useCallback(O=>{!p||!S||(O?.evt.type.startsWith("touch")&&O.evt.preventDefault(),w(!1),G&&(g===it.E_CANVAS_TOOLS.RECT||g===it.E_CANVAS_TOOLS.CIRCLE)&&(G.points.length===2&&k([...M,{...G,tool:g,color:x,width:d}]),T(null)))},[p,S,G,g,M,x,d]);return ae.useEffect(()=>{if(!f)return;const O=()=>{const W=document.getElementById(f);if(W&&S){const{clientWidth:q,clientHeight:$}=W,ne=Math.min(q/S.width,$/S.height);b({width:S.width*ne,height:S.height*ne})}};return O(),window.addEventListener("resize",O),()=>window.removeEventListener("resize",O)},[f,S]),ae.useEffect(()=>{const O=W=>{A&&p&&W.preventDefault()};return document.addEventListener("touchstart",O,{passive:!1}),document.addEventListener("touchmove",O,{passive:!1}),document.addEventListener("touchend",O,{passive:!1}),()=>{document.removeEventListener("touchstart",O),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",O)}},[A,p]),S?I.jsxRuntimeExports.jsx("div",{style:{position:"relative",touchAction:"none",WebkitUserSelect:"none",userSelect:"none"},className:l,children:I.jsxRuntimeExports.jsx($S,{ref:y,width:h.width,height:h.height,onMouseDown:Q,onMousemove:j,onMouseup:H,onTouchStart:Q,onTouchMove:j,onTouchEnd:H,style:{border:"1px solid #ccc",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"},children:I.jsxRuntimeExports.jsxs(qS,{children:[I.jsxRuntimeExports.jsx(KS,{ref:P,image:S,x:0,y:0,width:h.width,height:h.height}),C.map((O,W)=>I.jsxRuntimeExports.jsx(ZS,{points:O.points.flatMap(q=>[q.x,q.y]),stroke:O.color,strokeWidth:O.width,tension:.5,lineCap:"round",lineJoin:"round",globalCompositeOperation:"source-over"},`line-${W}`)),M.map((O,W)=>{if(O.tool===it.E_CANVAS_TOOLS.RECT&&O.points.length===2){const[q,$]=O.points;return I.jsxRuntimeExports.jsx(Ky,{x:q.x,y:q.y,width:$.x-q.x,height:$.y-q.y,stroke:O.color,strokeWidth:O.width,fill:"transparent"},`rect-${W}`)}else if(O.tool===it.E_CANVAS_TOOLS.CIRCLE&&O.points.length===2){const[q,$]=O.points,ne=Math.sqrt(Math.pow($.x-q.x,2)+Math.pow($.y-q.y,2));return I.jsxRuntimeExports.jsx($y,{x:q.x,y:q.y,radius:ne,stroke:O.color,strokeWidth:O.width,fill:"transparent"},`circle-${W}`)}return null}),G&&G.points.length===2&&I.jsxRuntimeExports.jsxs(I.jsxRuntimeExports.Fragment,{children:[g===it.E_CANVAS_TOOLS.RECT&&I.jsxRuntimeExports.jsx(Ky,{x:G.points[0].x,y:G.points[0].y,width:G.points[1].x-G.points[0].x,height:G.points[1].y-G.points[0].y,stroke:x,strokeWidth:d,fill:"transparent",dash:[5,5]}),g===it.E_CANVAS_TOOLS.CIRCLE&&I.jsxRuntimeExports.jsx($y,{x:G.points[0].x,y:G.points[0].y,radius:Math.sqrt(Math.pow(G.points[1].x-G.points[0].x,2)+Math.pow(G.points[1].y-G.points[0].y,2)),stroke:x,strokeWidth:d,fill:"transparent",dash:[5,5]})]})]})})}):I.jsxRuntimeExports.jsx("div",{style:{position:"relative"},children:I.jsxRuntimeExports.jsx("div",{style:{width:600,height:400,background:"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center"},children:"Loading image..."})})};function eE(s){const{containerHeight:l,containerWidth:f}=s,{groupDocuments:p}=e7(),{parentRef:x}=ka(),g=ae.useRef(null);let d=1,S=p.length;(p.length===3||p.length===4)&&(d=2,S=2);const E=l/d,h=f/S;return ae.useEffect(()=>{g.current&&(g.current.style.height=`${l}px`,g.current.style.width=`${f}px`)},[l,f,x]),I.jsxRuntimeExports.jsx("div",{ref:g,className:"hfl-bg-Gray-400 hfl-py-2",style:{display:p.length>1?"grid":"flex",gridTemplateColumns:p.length>1?`repeat(${S}, 1fr)`:void 0,gridTemplateRows:p.length>2?`repeat(${d}, 1fr)`:void 0,gap:"8px",height:`${l}px`,width:`${f}px`,justifyContent:p.length===1?"center":void 0,alignItems:"center"},children:p.map((b,A)=>I.jsxRuntimeExports.jsx("div",{style:{width:`${h}px`,height:`${E}px`,display:"flex",alignItems:"center",justifyContent:A%2===0?"flex-end":"flex-start"},id:`compare-${b.id}`,children:I.jsxRuntimeExports.jsx(U5,{imageUrl:b.filePath,containerRef:`compare-${b.id}`})},`compare-${b.id}`))})}const tE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.75%203H18.25C19.7688%203%2021%204.23122%2021%205.75V18.25C21%2019.7688%2019.7688%2021%2018.25%2021H5.75C4.23122%2021%203%2019.7688%203%2018.25V5.75C3%204.23122%204.23122%203%205.75%203ZM5.75%204.5C5.05964%204.5%204.5%205.05964%204.5%205.75V18.25C4.5%2018.9404%205.05964%2019.5%205.75%2019.5H18.25C18.9404%2019.5%2019.5%2018.9404%2019.5%2018.25V5.75C19.5%205.05964%2018.9404%204.5%2018.25%204.5H5.75Z'%20fill='%237C8897'/%3e%3c/svg%3e",nE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAADxSURBVHgB7ZI9DoIwGIa/0gt4IRk0TnIR44IjEUNJiIbJDeI9ZJNEceE6HABqqwvy169MDDxJk6Yt7wP0BZiZHKcwst0w9kAT+dzxHNnNdaN1sqQAHJiOxA1vHufkSghfNPdocyFL77m5toiYMnNjQfZIXqpw4BUTww+cPVMKfpLkiZGownsFGAkmfFAwJMGGSwggcC8xEyc9Mdi3F8hwtOBPIkGGSwzAYhi8c66AYg7V/7n4aHkPqAqjBM0LxVYYJehri46E6obrSuiYcB0JHRveJVmutsU7TfL6fqumpISCV/yA7bkkcHbihcCHmUnyAbVr1q3eVypyAAAAAElFTkSuQmCC",rE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0302%202.96967C22.4276%204.36713%2022.4276%206.63286%2021.0302%208.03033L9.06186%2019.9987C8.78498%2020.2755%208.44064%2020.4754%208.06288%2020.5784L2.94719%2021.9736C2.38732%2022.1263%201.87359%2021.6125%202.02628%2021.0527L3.42147%2015.937C3.52449%2015.5592%203.72432%2015.2149%204.0012%2014.938L15.9695%202.96967C17.367%201.5722%2019.6327%201.5722%2021.0302%202.96967ZM15%206.06057L5.06186%2015.9987C4.96956%2016.0909%204.90296%2016.2057%204.86861%2016.3316L3.81877%2020.1811L7.6682%2019.1312C7.79412%2019.0969%207.9089%2019.0303%208.0012%2018.938L17.939%208.99957L15%206.06057ZM17.0302%204.03033L16.06%204.99957L18.999%207.93957L19.9695%206.96967C20.7812%206.15799%2020.7812%204.842%2019.9695%204.03033C19.1578%203.21865%2017.8419%203.21865%2017.0302%204.03033Z'%20fill='%237C8897'/%3e%3c/svg%3e",aE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%202C17.5228%202%2022%206.47715%2022%2012C22%2017.5228%2017.5228%2022%2012%2022C6.47715%2022%202%2017.5228%202%2012C2%206.47715%206.47715%202%2012%202ZM12%203.5C7.30558%203.5%203.5%207.30558%203.5%2012C3.5%2016.6944%207.30558%2020.5%2012%2020.5C16.6944%2020.5%2020.5%2016.6944%2020.5%2012C20.5%207.30558%2016.6944%203.5%2012%203.5Z'%20fill='%237C8897'/%3e%3c/svg%3e";function iE(){const{setShowPenTool:s,setPenTool:l}=Xf(),f=ae.useMemo(()=>[{image:nE,onClick:()=>s(!1),label:"Close icon"},{image:aE,onClick:()=>l(it.E_CANVAS_TOOLS.CIRCLE),label:"Circle icon"},{image:tE,onClick:()=>l(it.E_CANVAS_TOOLS.RECT),label:"Checkbox icon"},{image:rE,onClick:()=>l(it.E_CANVAS_TOOLS.PEN),label:"Edit icon"}],[l,s]);return I.jsxRuntimeExports.jsx("div",{className:"hfl-rounded-md hfl-p-2 hfl-bg-White hfl-flex hfl-flex-col hfl-gap-2 hfl-items-center",children:f.map(p=>I.jsxRuntimeExports.jsx("img",{src:p.image,onClick:p.onClick,width:24,height:24,className:"hfl-cursor-pointer"},p.label))})}function sE(){const{setPenColor:s,penColor:l}=Xf();return I.jsxRuntimeExports.jsx("div",{className:"hfl-rounded-md hfl-p-2 hfl-bg-White hfl-flex hfl-flex-col hfl-gap-2 hfl-items-center",children:li.C_PEN_TOOL_COLORS.map(f=>l===f?I.jsxRuntimeExports.jsx("div",{className:"hfl-border-Primary-600 hfl-w-[26px] hfl-h-[26px] hfl-rounded-full hfl-flex hfl-justify-center hfl-items-center hfl-border-2",children:I.jsxRuntimeExports.jsx("div",{className:"hfl-rounded-full hfl-w-[24px] hfl-h-[24px] ",style:{backgroundColor:f},onClick:()=>s(f)})},f):I.jsxRuntimeExports.jsx("div",{className:"hfl-rounded-full hfl-w-[24px] hfl-h-[24px] ",style:{backgroundColor:f},onClick:()=>s(f)},f))})}function G5(){const s=ae.useRef(null),{parentRef:l}=ka(),{showPenTool:f}=Xf();return ae.useEffect(()=>{if(f&&l.current&&s.current){const p=l.current.getBoundingClientRect(),x=p.width,g=p.height,d=p.top+g*.1,S=p.left+x*.9;s.current.style.position="fixed",s.current.style.top=`${d}px`,s.current.style.left=`${S}px`}},[l,f]),f?I.jsxRuntimeExports.jsxs("div",{className:"hfl-fixed hfl-z-99999999 hfl-flex hfl-flex-col hfl-gap-2",ref:s,children:[I.jsxRuntimeExports.jsx(iE,{}),I.jsxRuntimeExports.jsx(sE,{})]}):null}function lE(){const{clearSelectedDocuments:s,setSelectedGroup:l,selectedGroup:f,selectedDocuments:p,addDocument:x,setShowSaveGroupPreview:g,updateDocument:d}=Sa(),[S,E]=ae.useState(!1),h=ae.useRef(null),{onSaveComparision:b,setCompareMode:A,setShowPreview:w,setError:C}=ka(),[R,M]=ae.useState(f?.label||""),k=ae.useCallback(()=>{w(!1),A(!1),l(null),s(),g(!1)},[s,A,l,w,g]),G=ae.useCallback(async()=>{if(!R){C&&C("Group Name is required");return}try{E(!0);const y=await b(f?.id||"",R,p.map(P=>P.id));y.status&&y.data&&(f?.id?d(y.data):x(y.data))}catch(y){console.error("Error saving comparison:",y)}finally{E(!1),k()}},[x,k,b,p,f?.id,R,C,d]),T=ae.useCallback(()=>{g(!1)},[g]);return I.jsxRuntimeExports.jsxs("div",{className:"hfl-absolute hfl-top-1/2 hfl-left-1/2 hfl-p-4 hfl-bg-white hfl-rounded-lg hfl-shadow-lg hfl-z-[9999999999] hfl-flex hfl-flex-col hfl-gap-2 hfl-transform hfl--translate-x-1/2 hfl--translate-y-1/2",ref:h,children:[I.jsxRuntimeExports.jsx("div",{className:`hfl-w-[400px] hfl-h-[400px] ${p.length<2?"hfl-flex ":"hfl-grid hfl-grid-cols-2"} hfl-border-1 hfl-border-Gray-900 hfl-rounded-lg`,children:p.map((y,P)=>I.jsxRuntimeExports.jsx("img",{src:y.filePath,className:`hfl-object-contain ${p.length<2?"":P%2===0?"hfl-flex hfl-justify-end":"hfl-flex hfl-justify-start"} `,width:200,style:{height:Math.floor(400/Math.round(p.length/2)-2)}},`${y.id}-save`))}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text lg",className:"hfl-text-gray-900",children:"Save Comparision Group"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-gray-500",children:"Save the details of the comparison group"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-gray-900",children:"Group Name"}),I.jsxRuntimeExports.jsx(I.Ps,{inputProps:{value:R,onChange:y=>M(y.target.value),placeholder:"Name"}}),I.jsxRuntimeExports.jsxs("div",{className:"hfl-w-full hfl-flex hfl-justify-between hfl-mt-1 hfl-gap-2",children:[I.jsxRuntimeExports.jsx(I.Ku,{hierarchy:"Secondary",size:"md",textField:"Cancel",onClick:T,className:"hfl-w-full hfl-flex hfl-justify-center"}),I.jsxRuntimeExports.jsx(I.Ku,{hierarchy:"Primary",className:"hfl-bg-Primary-600 hfl-w-full hfl-flex hfl-justify-center",size:"md",textField:"Save",onClick:G,disabled:S})]})]})}function oE(){const{parentRef:s}=ka(),{selectedDocuments:l,selectedGroup:f,showSaveGroupPreview:p}=Sa(),x=ae.useRef(null),[g,d]=ae.useState(void 0),[S,E]=ae.useState([]),[h,b]=ae.useState(0),[A,w]=ae.useState(0);return ae.useEffect(()=>{s.current&&x.current&&(x.current.style.height=`${s.current.clientHeight}px`,x.current.style.width=`${s.current.clientWidth}px`,x.current.style.top=s.current.getBoundingClientRect().top+"px",x.current.style.left=s.current.getBoundingClientRect().left+"px")},[s]),ae.useEffect(()=>{f?(E(f.documents),d(f.id)):(E(l),d(void 0))},[l,f]),ae.useEffect(()=>{if(s.current){const C=s.current.clientHeight;b(C-A)}},[A,s]),I.jsxRuntimeExports.jsx(n5.Provider,{value:{groupDocuments:S,setGroupDocuments:E,groupId:g,setGroupId:d},children:I.jsxRuntimeExports.jsxs("div",{ref:x,className:"hfl-fixed hfl-z-99999",children:[I.jsxRuntimeExports.jsx(R5,{setHeaderHeight:w}),I.jsxRuntimeExports.jsx(eE,{containerHeight:h,containerWidth:x.current?.clientWidth||0}),I.jsxRuntimeExports.jsx(G5,{}),p&&I.jsxRuntimeExports.jsx(lE,{})]})})}function uE(s){const{selectedIndex:l,selectedPreview:f,setSelectedIndex:p}=s,x=ae.useCallback(g=>{p(g)},[p]);return I.jsxRuntimeExports.jsx("div",{className:`hfl-flex hfl-bg-Gray-600 hfl-p-2 hfl-flex-col hfl-gap-2 hfl-h-full ${f.length<2?"hfl-hidden":""}`,children:f.map((g,d)=>I.jsxRuntimeExports.jsx("img",{src:g.filePath,alt:g.label,className:` hfl-object-cover hfl-border-1 ${l===d?"hfl-border-Blue-600":"hfl-border-White"} hfl-cursor-pointer`,width:118,height:146,onClick:()=>x(d)},`${g.id}-document-preview`))})}const cE=ae.memo(uE),fE="data:image/svg+xml,%3csvg%20width='9'%20height='16'%20viewBox='0%200%209%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.03033%2015.2803C8.32322%2014.9874%208.32322%2014.5126%208.03033%2014.2197L1.81066%208L8.03033%201.78033C8.32322%201.48744%208.32322%201.01256%208.03033%200.71967C7.73744%200.426777%207.26256%200.426777%206.96967%200.71967L0.219671%207.46967C-0.0732224%207.76256%20-0.0732225%208.23744%200.219671%208.53033L6.96967%2015.2803C7.26256%2015.5732%207.73744%2015.5732%208.03033%2015.2803Z'%20fill='%23101828'/%3e%3c/svg%3e",dE="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.96967%204.71967C8.67678%205.01256%208.67678%205.48744%208.96967%205.78033L15.1893%2012L8.96967%2018.2197C8.67678%2018.5126%208.67678%2018.9874%208.96967%2019.2803C9.26256%2019.5732%209.73744%2019.5732%2010.0303%2019.2803L16.7803%2012.5303C17.0732%2012.2374%2017.0732%2011.7626%2016.7803%2011.4697L10.0303%204.71967C9.73744%204.42678%209.26256%204.42678%208.96967%204.71967Z'%20fill='%23101828'/%3e%3c/svg%3e";function hE(s){const{selectedIndex:l,documentPreview:f,handleImageChange:p,showButtons:x}=s,g=ae.useRef(null),d=ae.useMemo(()=>f[l],[f,l]);return I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-gap-4 hfl-py-2 hfl-items-center",ref:g,children:[x&&I.jsxRuntimeExports.jsx("button",{onClick:()=>p("prev"),className:" hfl-w-[48px] hfl-h-[48px] hfl-rounded-full hfl-bg-Gray-300 hfl-cursor-pointer hfl-flex hfl-justify-center hfl-items-center",disabled:l===0,children:I.jsxRuntimeExports.jsx("img",{src:fE})}),I.jsxRuntimeExports.jsx(U5,{imageUrl:d.filePath,customClassName:" hfl-flex hfl-items-center"}),x&&I.jsxRuntimeExports.jsx("button",{onClick:()=>p("next"),className:" hfl-w-[48px] hfl-h-[48px] hfl-rounded-full hfl-cursor-pointer hfl-bg-Gray-300 hfl-flex hfl-justify-center hfl-items-center",disabled:l===f.length-1,children:I.jsxRuntimeExports.jsx("img",{src:dE})})]})}function pE(){const{parentRef:s}=ka(),l=ae.useRef(null),[f,p]=ae.useState(0),{selectedDocuments:x,selectedGroup:g}=Sa(),d=ae.useRef(null),S=ae.useMemo(()=>g?g.documents:x,[x,g]),E=ae.useMemo(()=>g?g.documents.length:x.length,[x,g]),[h,b]=ae.useState(0);ae.useEffect(()=>{s.current&&l.current&&(l.current.style.height=`${s.current.clientHeight}px`,l.current.style.width=`${s.current.clientWidth}px`,l.current.style.top=s.current.getBoundingClientRect().top+"px",l.current.style.left=s.current.getBoundingClientRect().left+"px")},[s]),ae.useEffect(()=>{if(s.current&&d.current){const w=s.current.clientHeight;d.current.style.height=`${w-f}px`}},[f,s]);const A=ae.useCallback(w=>{b(C=>w==="next"?S.length-1===C?0:C+1:C===0?S.length-1:C-1)},[S.length,b]);return ae.useEffect(()=>{const w=C=>{C.key==="ArrowRight"?A("next"):C.key==="ArrowLeft"&&A("prev")};return window.addEventListener("keydown",w),()=>{window.removeEventListener("keydown",w)}},[A]),I.jsxRuntimeExports.jsxs("div",{className:"hfl-z-99999 hfl-fixed",ref:l,children:[I.jsxRuntimeExports.jsx(R5,{setHeaderHeight:p,isPreview:!0}),I.jsxRuntimeExports.jsxs("div",{className:" hfl-bg-Gray-400 hfl-flex hfl-flex-justify-center hfl-pr-2 hfl-w-full",ref:d,children:[I.jsxRuntimeExports.jsx(cE,{selectedPreview:S,selectedIndex:h,setSelectedIndex:b}),I.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-justify-center hfl-flex",children:I.jsxRuntimeExports.jsx(hE,{showButtons:E>1,documentPreview:S,selectedIndex:h,handleImageChange:A})})]}),I.jsxRuntimeExports.jsx(G5,{})]})}const mE=({file_data:s})=>{const[l,f]=ae.useState(!1),p=ae.useRef(null),x=[{src:s,type:"video/mp4"}],g=d=>{d.currentTarget.remove(),p.current&&p.current.children.length===0&&f(!0)};return I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-justify-center hfl-items-center hfl-w-full hfl-max-w-[800px] hfl-mx-auto",children:l?I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-col hfl-justify-center hfl-items-center hfl-gap-2 hfl-h-[300px] hfl-p-2",children:I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text md",className:"xxxs:max-sm:hfl-text-[10px]",children:"Live preview is not supported for this video. Please download it to watch."})}):I.jsxRuntimeExports.jsxs("video",{ref:p,controls:!0,autoPlay:!0,className:"hfl-flex hfl-justify-center hfl-items-center hfl-w-full hfl-max-w-[800px] hfl-mx-auto hfl-h-[350px]",children:[x.map(({src:d,type:S})=>I.jsxRuntimeExports.jsx("source",{src:d,type:S,onError:g},S)),"Your browser does not support the video tag."]})})},vE=()=>I.jsxRuntimeExports.jsx("div",{className:"hfl-inset-0 hfl-z-[100] hfl-flex hfl-h-full hfl-w-full hfl-items-center hfl-justify-center hfl-overflow-y-auto hfl-outline-none focus:hfl-outline-none",children:I.jsxRuntimeExports.jsx(I.Eu,{progress:10,spinnerMode:!0})}),gE=({file_data:s})=>{const[l,f]=ae.useState(!0),[p,x]=ae.useState(!1);return I.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-w-full hfl-max-w-[800px] hfl-mx-auto",children:[l&&!p&&I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-w-full hfl-justify-center hfl-items-center hfl-h-full",children:I.jsxRuntimeExports.jsx(vE,{})}),p?I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-col hfl-justify-center hfl-items-center hfl-gap-2 hfl-h-[300px] hfl-bg-gray-100 hfl-rounded-lg hfl-p-2",children:I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text md",className:"xxxs:max-sm:hfl-text-[10px]",children:"Live preview is not supported for this image. Please download it."})}):I.jsxRuntimeExports.jsx("img",{src:`${s}?t=${Date.now()}`,loading:"lazy",className:"hfl-w-full hfl-h-auto hfl-transition-opacity hfl-duration-300 hfl-rounded-lg",onLoad:()=>f(!1),onError:()=>{f(!1),x(!0)},style:{opacity:l?0:1},alt:"Preview"})]})},yE=()=>{const{selectedDocuments:s,clearSelectedDocuments:l}=Sa(),{setShowPreview:f,parentRef:p}=ka(),x=ae.useMemo(()=>s[0],[s]),g=ae.useRef(null),d=ae.useCallback(()=>{f(!1),l()},[l,f]),S=ae.useCallback(()=>p?.current&&p.current.clientWidth<=1180,[p]),E=ae.useCallback(()=>{x?.filePath&&(window.open(x.filePath,"_blank"),d())},[x?.filePath,d]);ae.useEffect(()=>{x?.mimeType===it.E_DOCUMENT_FORMAT.PDF&&S()&&E()},[x?.mimeType,S,E]);const h=b=>{switch(b){case it.E_DOCUMENT_FORMAT.PDF:return S()?null:I.jsxRuntimeExports.jsx("div",{className:"hfl-px-6 hfl-pt-4 hfl-pb-20 hfl-bg-white hfl-h-[100vh] hfl-w-full",children:I.jsxRuntimeExports.jsx("iframe",{src:`${x.filePath}`,width:"100%",height:"100%",style:{border:"none"},children:"Your browser does not support PDFs."})});case it.E_DOCUMENT_FORMAT.MP4:return I.jsxRuntimeExports.jsx(mE,{file_data:x.filePath});default:return I.jsxRuntimeExports.jsx(gE,{file_data:x.filePath})}};return I.jsxRuntimeExports.jsx(I.jsxRuntimeExports.Fragment,{children:I.jsxRuntimeExports.jsx(Sx.ReusableModal,{childModalRef:g,backdropClasses:"",clickOutsideHandler:()=>{},closeOnClickOutside:!1,hideBackDrop:!1,modalClasses:"hfl-mx-10 xsm:hfl-mx-6 hfl-w-[70%]",position:"hfl-inset-0",children:I.jsxRuntimeExports.jsxs("div",{className:"hfl-relative",children:[I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-h-12 hfl-items-center hfl-border-b-1 hfl-justify-between hfl-px-4",children:I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-col hfl-gap-0",children:I.jsxRuntimeExports.jsx(I.bs,{variant:"Bold",type:"Text md",className:"hfl-text-Gray-800",children:x.label})})}),I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-w-full",children:I.jsxRuntimeExports.jsx("div",{className:"hfl-bg-gray-200 hfl-flex hfl-justify-center hfl-w-full hfl-h-full hfl-px-10 hfl-pt-6 hfl-pb-20 hfl-max-h-[80vh] hfl-overflow-y-auto hfl-rounded-bl-lg",children:h(x.mimeType)})}),I.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-absolute hfl-bottom-0 hfl-mt-[10px] hfl-bg-white hfl-py-2 hfl-px-2",children:I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center hfl-justify-end hfl-gap-2",children:I.jsxRuntimeExports.jsx(I.Ku,{textField:"Close",size:"sm",hierarchy:"Primary",onClick:d,className:"hfl-border-Blue-300 hfl-bg-Blue-50 hfl-text-Blue-600 hfl-border-1 hover:hfl-text-White hover:hfl-bg-Blue-600"})})})]})})})},xE=[{label:"Unspecified",value:it.E_DOCUMENT_TYPE.REPORT_TYPE_UNSPECIFIED},...Object.values(it.E_DOCUMENT_TYPE).filter(s=>s!==it.E_DOCUMENT_TYPE.REPORT_TYPE_UNSPECIFIED).map(s=>({label:s.charAt(0).toUpperCase()+s.slice(1).replace(/_/g," "),value:s}))];function SE({isOpen:s,document:l,onClose:f,onSave:p}){const[x,g]=ae.useState(""),[d,S]=ae.useState(""),[E,h]=ae.useState(!1),[b,A]=ae.useState(""),[w,C]=ae.useState("");ae.useEffect(()=>{if(l){const M=l.label,k=M.lastIndexOf(".");k!==-1?(A(M.substring(0,k)),C(M.substring(k))):(A(M),C("")),g(l.reportType||it.E_DOCUMENT_TYPE.REPORT_TYPE_UNSPECIFIED),S(new Date(l.createdAt).toISOString().split("T")[0])}},[l]);const R=async()=>{if(l){h(!0);try{const M={id:l.id,label:`${b}${w}`,reportType:x===it.E_DOCUMENT_TYPE.REPORT_TYPE_UNSPECIFIED?"":x,createdAt:new Date(d).toISOString(),filePath:l.filePath,mimeType:l.mimeType,downloadPath:l.downloadPath,fileName:l.fileName};await p(M),f()}catch(M){console.error("Failed to save document:",M)}finally{h(!1)}}};return!s||!l?null:I.jsxRuntimeExports.jsx("div",{className:"hfl-fixed hfl-inset-0 hfl-bg-black hfl-bg-opacity-50 hfl-flex hfl-items-center hfl-justify-center hfl-z-50",children:I.jsxRuntimeExports.jsxs("div",{className:"hfl-bg-white hfl-rounded-lg hfl-p-8 hfl-w-full hfl-max-w-md hfl-flex hfl-flex-col hfl-gap-6",children:[I.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-h-48 hfl-bg-Gray-100 hfl-rounded-lg hfl-overflow-hidden",children:I.jsxRuntimeExports.jsx(d5,{documents:l})}),I.jsxRuntimeExports.jsxs("div",{children:[I.jsxRuntimeExports.jsx(I.bs,{variant:"Semibold",type:"Text xl",className:"hfl-text-Gray-900",children:"Edit Document"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-500",children:"Edit the details of the document."})]}),I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-4",children:[I.jsxRuntimeExports.jsxs("div",{children:[I.jsxRuntimeExports.jsx("label",{htmlFor:"documentName",className:"hfl-block hfl-text-sm hfl-font-medium hfl-text-Gray-700 hfl-mb-1",children:"Document Name"}),I.jsxRuntimeExports.jsx("input",{id:"documentName",value:b,onChange:M=>A(M.target.value),placeholder:"Enter document name",className:"hfl-w-full hfl-border hfl-border-Gray-300 hfl-rounded-md hfl-px-3 hfl-py-2 focus:hfl-outline-none focus:hfl-ring-2 focus:hfl-ring-Primary-500"})]}),I.jsxRuntimeExports.jsxs("div",{children:[I.jsxRuntimeExports.jsx("label",{className:"hfl-block hfl-text-sm hfl-font-medium hfl-text-Gray-700 hfl-mb-1",children:"Type"}),I.jsxRuntimeExports.jsx("select",{value:x,onChange:M=>g(M.target.value),className:"hfl-w-full hfl-border hfl-border-Gray-300 hfl-rounded-md hfl-px-3 hfl-py-2 focus:hfl-outline-none focus:hfl-ring-2 focus:hfl-ring-Primary-500",children:xE.map(M=>I.jsxRuntimeExports.jsx("option",{value:M.value,children:M.label},M.value))})]}),I.jsxRuntimeExports.jsxs("div",{children:[I.jsxRuntimeExports.jsx("label",{className:"hfl-block hfl-text-sm hfl-font-medium hfl-text-Gray-700 hfl-mb-1",children:"Creation Date"}),I.jsxRuntimeExports.jsx("input",{type:"date",value:d,onChange:M=>S(M.target.value),className:"hfl-w-full hfl-border hfl-border-Gray-300 hfl-rounded-md hfl-px-3 hfl-py-2 focus:hfl-outline-none focus:hfl-ring-2 focus:hfl-ring-Primary-500"})]})]}),I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-justify-end hfl-gap-3 hfl-mt-4",children:[I.jsxRuntimeExports.jsx(I.Ku,{textField:"Cancel",hierarchy:"Secondary",onClick:f,disabled:E,size:"sm"}),I.jsxRuntimeExports.jsx(I.Ku,{textField:E?"Saving...":"Save",hierarchy:"Primary",onClick:R,disabled:E,size:"sm"})]})]})})}function EE({isOpen:s,onClose:l,onCapture:f}){const p=ae.useRef(null),x=ae.useRef(null),g=ae.useRef(null),[d,S]=ae.useState(!1),[E,h]=ae.useState(null),[b,A]=ae.useState(!1),[w,C]=ae.useState(!1),[R,M]=ae.useState([]),[k,G]=ae.useState(null),T=async()=>{try{const j=(await navigator.mediaDevices.enumerateDevices()).filter(H=>H.kind==="videoinput");console.log("Available video devices:",j),M(j)}catch(Q){console.error("Error enumerating devices:",Q)}};ae.useEffect(()=>{s&&T()},[s]);const y=async()=>{console.log("inside startCamera"),console.log("videoRef.current at start:",p.current),console.log("videoRef.current?.readyState:",p.current?.readyState);try{S(!0),h(null),console.log("before getUserMedia");const Q=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720},facingMode:"environment"},audio:!1});console.log("after getUserMedia, stream:",Q),console.log("stream.getTracks():",Q.getTracks()),g.current=Q,console.log("videoRef.current after getUserMedia:",p.current),console.log("videoRef.current?.readyState after getUserMedia:",p.current?.readyState),G(Q),C(!0),console.log("after setHasPermission")}catch(Q){console.error("Error accessing camera:",Q),Q instanceof Error?Q.name==="NotAllowedError"?h("Camera access denied. Please grant permission to use the camera."):Q.name==="NotFoundError"?h("No camera found on this device."):Q.name==="NotSupportedError"?h("Camera is not supported on this device."):h("Failed to access camera. Please try again."):h("Failed to access camera. Please try again.")}finally{S(!1),console.log("startCamera finally block - isLoading set to false")}};ae.useEffect(()=>{k&&p.current&&w&&(p.current.srcObject=k,p.current.play().catch(Q=>{console.error("Error playing video:",Q)}))},[k,w]);const P=()=>{console.log("stopCamera called"),g.current&&(console.log("Stopping stream tracks:",g.current.getTracks().length),g.current.getTracks().forEach(Q=>{console.log("Stopping track:",Q.kind,Q.readyState),Q.stop()}),g.current=null),p.current&&(console.log("Clearing video srcObject"),p.current.srcObject=null),C(!1),console.log("stopCamera completed")},L=async()=>{if(!(!p.current||!x.current)){A(!0);try{const Q=p.current,j=x.current,H=j.getContext("2d");if(!H)throw new Error("Unable to get canvas context");j.width=Q.videoWidth,j.height=Q.videoHeight,H.drawImage(Q,0,0,j.width,j.height);const O=await new Promise(($,ne)=>{j.toBlob(ee=>{ee?$(ee):ne(new Error("Failed to create image blob"))},"image/jpeg",.8)}),W=new Date().toISOString().replace(/[:.]/g,"-"),q=new File([O],`captured-image-${W}.jpg`,{type:"image/jpeg"});await f(q),l()}catch(Q){console.error("Error capturing photo:",Q),h("Failed to capture photo. Please try again.")}finally{A(!1)}}},B=async()=>{if(!g.current)return;const j=g.current.getVideoTracks()[0].getSettings().facingMode;P();try{const H=j==="environment"?"user":"environment",O=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720},facingMode:H},audio:!1});g.current=O,p.current&&(p.current.srcObject=O,p.current.play())}catch(H){console.error("Error switching camera:",H),h("Failed to switch camera. Using default camera."),y()}};return ae.useEffect(()=>(console.log("useEffect triggered with isOpen:",s),s?(console.log("Calling startCamera from useEffect"),T(),y()):(console.log("Calling stopCamera from useEffect"),P(),h(null)),()=>{console.log("useEffect cleanup - calling stopCamera"),P()}),[s]),s?I.jsxRuntimeExports.jsx("div",{className:"hfl-fixed hfl-inset-0 hfl-bg-black hfl-bg-opacity-75 hfl-flex hfl-items-center hfl-justify-center hfl-z-50",children:I.jsxRuntimeExports.jsxs("div",{className:"hfl-bg-white hfl-rounded-lg hfl-p-6 hfl-w-full hfl-max-w-2xl hfl-max-h-[90vh] hfl-overflow-hidden",children:[I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between hfl-mb-4",children:[I.jsxRuntimeExports.jsx(I.bs,{variant:"Semibold",type:"Text lg",className:"hfl-text-Gray-900",children:"Capture Photo"}),I.jsxRuntimeExports.jsx("button",{onClick:l,className:"hfl-text-Gray-500 hfl-hover:text-Gray-700 hfl-p-1 hfl-h-4 hfl-w-4",children:I.jsxRuntimeExports.jsx("i",{className:"hx_close hfl-text-xl"})})]}),I.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-bg-black hfl-rounded-lg hfl-overflow-hidden hfl-mb-4",children:[d&&I.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-h-64",children:I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-white",children:"Loading camera..."})}),E&&I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-justify-center hfl-h-64 hfl-p-4",children:[I.jsxRuntimeExports.jsx("i",{className:"hx_camera hfl-text-4xl hfl-text-Gray-400 hfl-mb-2"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-600 hfl-text-center",children:E}),I.jsxRuntimeExports.jsx("button",{onClick:y,className:"hfl-mt-3 hfl-px-4 hfl-py-2 hfl-bg-Blue-600 hfl-text-white hfl-rounded-lg hfl-hover:bg-Blue-700",children:"Try Again"})]}),w&&!E&&I.jsxRuntimeExports.jsx("video",{ref:p,className:"hfl-w-full hfl-h-auto hfl-max-h-96",onLoadedMetadata:()=>console.log("Video onLoadedMetadata"),onCanPlay:()=>console.log("Video onCanPlay"),onPlaying:()=>console.log("Video onPlaying"),onWaiting:()=>console.log("Video onWaiting"),onError:Q=>console.log("Video onError:",Q),onLoadStart:()=>console.log("Video onLoadStart"),autoPlay:!0,playsInline:!0,muted:!0}),I.jsxRuntimeExports.jsx("canvas",{ref:x,className:"hfl-hidden"})]}),w&&!E&&I.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-gap-4",children:[R.length>1&&I.jsxRuntimeExports.jsxs("button",{onClick:B,className:"hfl-flex hfl-items-center hfl-gap-2 hfl-px-4 hfl-py-2 hfl-text-sm hfl-text-Gray-700 hfl-border hfl-border-Gray-300 hfl-rounded-lg hfl-hover:bg-Gray-50",children:[I.jsxRuntimeExports.jsx("i",{className:"hx_refresh hfl-text-base"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text sm",children:"Switch Camera"})]}),I.jsxRuntimeExports.jsxs("button",{onClick:L,disabled:b,className:`hfl-flex hfl-items-center hfl-gap-2 hfl-px-6 hfl-py-3 hfl-text-sm hfl-text-white hfl-rounded-lg hfl-transition-colors ${b?"hfl-bg-Gray-400 hfl-cursor-not-allowed":"hfl-bg-Blue-600 hfl-hover:bg-Blue-700"}`,children:[I.jsxRuntimeExports.jsx("i",{className:"hx_camera hfl-text-base"}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text sm",className:"hfl-text-white",children:b?"Capturing...":"Capture Photo"})]})]})]})}):null}function CE({containerRef:s,setPage:l,hasData:f,shouldScroll:p,setNextDate:x,cursor:g,query_type:d}){const S=ae.useRef(p),E=ae.useRef(0),h=ae.useRef(!1);ae.useEffect(()=>{S.current=p},[p]),ae.useEffect(()=>{if(!s||!s.current)return;console.log("Inside scroll event",f);const b=s.current;if(!b)return;const A=()=>{if(!S.current||!f)return;const{scrollTop:w,scrollHeight:C,clientHeight:R}=b;h.current=w>E.current,E.current=w,h.current&&w+R>=C-10&&(d===it.E_ATTACHMENT_QUERY_TYPE.VIEW_GRID?l(M=>M+1):x(g))};return b.addEventListener("scroll",A),()=>{b.removeEventListener("scroll",A)}},[s,l,f,d,x,g])}function bE(s){const{isUploading:l}=s;return l?I.jsxRuntimeExports.jsxs("div",{className:"hfl-absolute hfl-flex hfl-gap-2 hfl-items-center hfl-left-[90%] hfl-top-[80%] hfl-p-3 hfl-rounded-md hfl-border-l-2 hfl-border-b-2 hfl-border-l-Success-600 hfl-border-b-Success-600 hfl-bg-White hfl-shadow-upload hfl-translate-x-[-80%] hfl-translate-y-[-90%] hfl-min-w-[375px] ",children:[I.jsxRuntimeExports.jsx("div",{className:"hfl-h-[32px] hfl-min-w-[32px] hfl-flex hfl-justify-center hfl-items-center hfl-rounded-md hfl-bg-Success-600",children:I.jsxRuntimeExports.jsx("i",{className:"hx_checkmark hfl-text-White "})}),I.jsxRuntimeExports.jsx(I.bs,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-800",children:"Your file(s) are being uploaded. Do not refresh or close the page."})]}):null}const RE=ae.memo(bE);function wE(s){const{parentRef:l,fetchAttachments:f,uploadFiles:p,onDocumentPreview:x,onDocumentDownload:g,onDocumentUpdate:d,setError:S,showHeaderBackButton:E,patient_id:h="",patient_role_id:b="",doctor_id:A="",doctor_role_id:w="",branch_id:C="",onDeleteAttachments:R,onSaveComparision:M,onHeaderBackClick:k}=s,[G,T]=ae.useState(!1),[y,P]=ae.useState(!1),[L,B]=ae.useState(""),[Q,j]=ae.useState(!0),[H,O]=ae.useState([]),[W,q]=ae.useState({startDate:null,endDate:null}),[$,ne]=ae.useState(1),[ee,me]=ae.useState(""),[F,U]=ae.useState(""),X=ae.useRef(null),[Y,Z]=ae.useState(it.E_ATTACHMENT_QUERY_TYPE.VIEW_GRID),{documentView:le,setDocument:re,addDocuments:ge,selectedDocuments:be,addDocument:oe,updateDocument:J}=Sa(),ue=ae.useMemo(()=>le===it.E_DOCUMENT_VIEW_TYPE.GRID_VIEW?20:3,[le]),[Ae,De]=ae.useState(null),[Oe,Xe]=ae.useState(!1),[xe,je]=ae.useState(!1),Le=ae.useMemo(()=>!G&&!y,[G,y]),{isLoading:qe}=J9(`attachments?page=${$}&page_size=${ue}&query_type=${Y}&search=${L}&types=${H.join(",")}&start_date=${W.startDate}&end_date=${W.endDate}&next_date=${ee}&patient_id=${h}&patient_role_id=${b}&doctor_id=${A}&doctor_role_id=${w}&branch_id=${C}`,()=>f($,L,H,ue,Y,W,ee),{revalidateOnFocus:!1,onSuccess:nt=>{nt.data&&($===1&&Y===it.E_ATTACHMENT_QUERY_TYPE.VIEW_GRID?re(nt.data):ee&&Y===it.E_ATTACHMENT_QUERY_TYPE.VIEW_DATE?ge(nt.data):Y===it.E_ATTACHMENT_QUERY_TYPE.VIEW_DATE?re(nt.data):ge(nt.data),(nt.data.length===0||nt.data.length<ue)&&j(!1),U(nt.next_date||""))},onError:nt=>S?.(`Failed to fetch documents: ${nt.message}`)});ae.useEffect(()=>{l.current&&X.current&&(X.current.style.height=`${l.current.clientHeight}px`)},[l]);const Ze=async nt=>{je(!0);try{const{validFiles:Vt,errors:fn}=f5(nt);if(fn.length>0&&fn.forEach(sn=>S?.(sn)),Vt.length>0){const sn=await p({files:Vt});let Ne=!0;console.log("Upload response for a file1: ",sn.data),sn.data.forEach(Be=>{console.log("Upload response for a file: ",Be),Be.success&&Be.data?(console.log("Adding document: ",Be.data),oe(Be.data)):Ne=!1}),Ne||S?.("Failed to upload all files")}}catch(Vt){S?.(`Failed to upload files. Please try again. ${Vt}`)}finally{je(!1)}},gt=async nt=>{await Ze([nt])},Dt=nt=>{De(nt)},dt=nt=>{x&&x(nt)},yt=nt=>{g&&g(nt)},St=()=>{De(null)},cn=async nt=>{try{const Vt=await d(nt);Vt.success&&Vt.data?J(Vt.data):S?.("Failed to update document.")}catch(Vt){S?.("An unexpected error occurred while updating the document."),console.error(Vt)}},nn=()=>Xe(!0),Bt=()=>Xe(!1);return CE({containerRef:X,setPage:ne,hasData:Q,shouldScroll:!qe,cursor:F,setNextDate:me,query_type:Y}),I.jsxRuntimeExports.jsxs(t5.Provider,{value:{page:$,setPage:ne,hasData:Q,queryType:Y,setQueryType:Z,setShowPreview:T,showPreview:G,compareMode:y,setCompareMode:P,parentRef:l,search:L,setSearch:B,types:H,setTypes:O,dates:W,setDates:q,setHasData:j,onSaveComparision:M,onDeleteAttachments:R,setError:S},children:[I.jsxRuntimeExports.jsxs("div",{ref:X,className:`hfl-w-full hfl-relative hfl-overflow-scroll ${Oe?"hfl-overflow-hidden":""}`,children:[Le&&I.jsxRuntimeExports.jsx($9,{showBackButton:E&&!G&&!y,onFileUpload:Ze,setNextDate:me,setCursor:U,onCaptureClick:nn,isUploading:xe,setIsUploading:je,onHeaderBackClickCb:E&&k?k:void 0}),le===it.E_DOCUMENT_VIEW_TYPE.GRID_VIEW?I.jsxRuntimeExports.jsx(h9,{onFileUpload:Ze,onEdit:Dt,onPreview:dt,onDownload:yt}):I.jsxRuntimeExports.jsx(m9,{onFileUpload:Ze,onEdit:Dt,onPreview:dt,onDownload:yt}),be.length>0&&!G&&!y&&I.jsxRuntimeExports.jsx(Z9,{})]}),y&&I.jsxRuntimeExports.jsx(oE,{}),G&&be.length>0&&(be[0].mimeType===it.E_DOCUMENT_FORMAT.JPEG||be[0].mimeType===it.E_DOCUMENT_FORMAT.PNG)&&I.jsxRuntimeExports.jsx(pE,{}),G&&be.length>0&&be[0].mimeType!==it.E_DOCUMENT_FORMAT.JPEG&&be[0].mimeType!==it.E_DOCUMENT_FORMAT.PNG&&I.jsxRuntimeExports.jsx(yE,{}),Ae&&I.jsxRuntimeExports.jsx(SE,{isOpen:!!Ae,document:Ae,onClose:St,onSave:cn}),I.jsxRuntimeExports.jsx(EE,{isOpen:Oe,onClose:Bt,onCapture:gt}),I.jsxRuntimeExports.jsx(RE,{isUploading:xe})]})}exports.Attachments=wE;
|