@bitux/review-layer-react 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(G,
|
|
1
|
+
(function(G,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],s):(G=typeof globalThis<"u"?globalThis:G||self,s(G.ReviewLayerReact={},G.React,G.ReactDOM))})(this,function(G,s,Ne){"use strict";var Se={exports:{}},ie={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Me;function hr(){if(Me)return ie;Me=1;var r=s,o=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(p,v,w){var b,E={},V=null,P=null;w!==void 0&&(V=""+w),v.key!==void 0&&(V=""+v.key),v.ref!==void 0&&(P=v.ref);for(b in v)n.call(v,b)&&!l.hasOwnProperty(b)&&(E[b]=v[b]);if(p&&p.defaultProps)for(b in v=p.defaultProps,v)E[b]===void 0&&(E[b]=v[b]);return{$$typeof:o,type:p,key:V,ref:P,props:E,_owner:i.current}}return ie.Fragment=t,ie.jsx=c,ie.jsxs=c,ie}var ae={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,32 +14,32 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),D=
|
|
21
|
-
`+
|
|
17
|
+
*/var We;function br(){return We||(We=1,process.env.NODE_ENV!=="production"&&function(){var r=s,o=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),p=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),P=Symbol.for("react.offscreen"),O=Symbol.iterator,M="@@iterator";function L(e){if(e===null||typeof e!="object")return null;var a=O&&e[O]||e[M];return typeof a=="function"?a:null}var h=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function d(e){{for(var a=arguments.length,u=new Array(a>1?a-1:0),g=1;g<a;g++)u[g-1]=arguments[g];x("error",e,u)}}function x(e,a,u){{var g=h.ReactDebugCurrentFrame,C=g.getStackAddendum();C!==""&&(a+="%s",u=u.concat([C]));var k=u.map(function(R){return String(R)});k.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,k)}}var A=!1,F=!1,le=!1,ue=!1,ce=!1,ee;ee=Symbol.for("react.module.reference");function re(e){return!!(typeof e=="string"||typeof e=="function"||e===n||e===l||ce||e===i||e===w||e===b||ue||e===P||A||F||le||typeof e=="object"&&e!==null&&(e.$$typeof===V||e.$$typeof===E||e.$$typeof===c||e.$$typeof===p||e.$$typeof===v||e.$$typeof===ee||e.getModuleId!==void 0))}function m(e,a,u){var g=e.displayName;if(g)return g;var C=a.displayName||a.name||"";return C!==""?u+"("+C+")":u}function S(e){return e.displayName||"Context"}function j(e){if(e==null)return null;if(typeof e.tag=="number"&&d("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case n:return"Fragment";case t:return"Portal";case l:return"Profiler";case i:return"StrictMode";case w:return"Suspense";case b:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var a=e;return S(a)+".Consumer";case c:var u=e;return S(u._context)+".Provider";case v:return m(e,e.render,"ForwardRef");case E:var g=e.displayName||null;return g!==null?g:j(e.type)||"Memo";case V:{var C=e,k=C._payload,R=C._init;try{return j(R(k))}catch{return null}}}return null}var I=Object.assign,Y=0,Q,te,xe,de,fe,_,Z;function K(){}K.__reactDisabledLog=!0;function J(){{if(Y===0){Q=console.log,te=console.info,xe=console.warn,de=console.error,fe=console.group,_=console.groupCollapsed,Z=console.groupEnd;var e={configurable:!0,enumerable:!0,value:K,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Y++}}function me(){{if(Y--,Y===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},e,{value:Q}),info:I({},e,{value:te}),warn:I({},e,{value:xe}),error:I({},e,{value:de}),group:I({},e,{value:fe}),groupCollapsed:I({},e,{value:_}),groupEnd:I({},e,{value:Z})})}Y<0&&d("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ve=h.ReactCurrentDispatcher,Ie;function we(e,a,u){{if(Ie===void 0)try{throw Error()}catch(C){var g=C.stack.trim().match(/\n( *(at )?)/);Ie=g&&g[1]||""}return`
|
|
18
|
+
`+Ie+e}}var Oe=!1,Ee;{var bt=typeof WeakMap=="function"?WeakMap:Map;Ee=new bt}function rr(e,a){if(!e||Oe)return"";{var u=Ee.get(e);if(u!==void 0)return u}var g;Oe=!0;var C=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var k;k=Ve.current,Ve.current=null,J();try{if(a){var R=function(){throw Error()};if(Object.defineProperty(R.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(R,[])}catch(U){g=U}Reflect.construct(e,[],R)}else{try{R.call()}catch(U){g=U}e.call(R.prototype)}}else{try{throw Error()}catch(U){g=U}e()}}catch(U){if(U&&g&&typeof U.stack=="string"){for(var y=U.stack.split(`
|
|
19
|
+
`),W=g.stack.split(`
|
|
20
|
+
`),D=y.length-1,z=W.length-1;D>=1&&z>=0&&y[D]!==W[z];)z--;for(;D>=1&&z>=0;D--,z--)if(y[D]!==W[z]){if(D!==1||z!==1)do if(D--,z--,z<0||y[D]!==W[z]){var H=`
|
|
21
|
+
`+y[D].replace(" at new "," at ");return e.displayName&&H.includes("<anonymous>")&&(H=H.replace("<anonymous>",e.displayName)),typeof e=="function"&&Ee.set(e,H),H}while(D>=1&&z>=0);break}}}finally{Oe=!1,Ve.current=k,me(),Error.prepareStackTrace=C}var ne=e?e.displayName||e.name:"",q=ne?we(ne):"";return typeof e=="function"&&Ee.set(e,q),q}function yt(e,a,u){return rr(e,!1)}function xt(e){var a=e.prototype;return!!(a&&a.isReactComponent)}function _e(e,a,u){if(e==null)return"";if(typeof e=="function")return rr(e,xt(e));if(typeof e=="string")return we(e);switch(e){case w:return we("Suspense");case b:return we("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return yt(e.render);case E:return _e(e.type,a,u);case V:{var g=e,C=g._payload,k=g._init;try{return _e(k(C),a,u)}catch{}}}return""}var ve=Object.prototype.hasOwnProperty,tr={},or=h.ReactDebugCurrentFrame;function Re(e){if(e){var a=e._owner,u=_e(e.type,e._source,a?a.type:null);or.setExtraStackFrame(u)}else or.setExtraStackFrame(null)}function mt(e,a,u,g,C){{var k=Function.call.bind(ve);for(var R in e)if(k(e,R)){var y=void 0;try{if(typeof e[R]!="function"){var W=Error((g||"React class")+": "+u+" type `"+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[R]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}y=e[R](a,R,g,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(D){y=D}y&&!(y instanceof Error)&&(Re(C),d("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",g||"React class",u,R,typeof y),Re(null)),y instanceof Error&&!(y.message in tr)&&(tr[y.message]=!0,Re(C),d("Failed %s type: %s",u,y.message),Re(null))}}}var wt=Array.isArray;function De(e){return wt(e)}function Et(e){{var a=typeof Symbol=="function"&&Symbol.toStringTag,u=a&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u}}function _t(e){try{return nr(e),!1}catch{return!0}}function nr(e){return""+e}function ir(e){if(_t(e))return d("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Et(e)),nr(e)}var ar=h.ReactCurrentOwner,Rt={key:!0,ref:!0,__self:!0,__source:!0},sr,lr;function St(e){if(ve.call(e,"ref")){var a=Object.getOwnPropertyDescriptor(e,"ref").get;if(a&&a.isReactWarning)return!1}return e.ref!==void 0}function Ct(e){if(ve.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function kt(e,a){typeof e.ref=="string"&&ar.current}function Pt(e,a){{var u=function(){sr||(sr=!0,d("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}}function Tt(e,a){{var u=function(){lr||(lr=!0,d("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};u.isReactWarning=!0,Object.defineProperty(e,"ref",{get:u,configurable:!0})}}var jt=function(e,a,u,g,C,k,R){var y={$$typeof:o,type:e,key:a,ref:u,props:R,_owner:k};return y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(y,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(y,"_source",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y};function Vt(e,a,u,g,C){{var k,R={},y=null,W=null;u!==void 0&&(ir(u),y=""+u),Ct(a)&&(ir(a.key),y=""+a.key),St(a)&&(W=a.ref,kt(a,C));for(k in a)ve.call(a,k)&&!Rt.hasOwnProperty(k)&&(R[k]=a[k]);if(e&&e.defaultProps){var D=e.defaultProps;for(k in D)R[k]===void 0&&(R[k]=D[k])}if(y||W){var z=typeof e=="function"?e.displayName||e.name||"Unknown":e;y&&Pt(R,z),W&&Tt(R,z)}return jt(e,y,W,C,g,ar.current,R)}}var Le=h.ReactCurrentOwner,ur=h.ReactDebugCurrentFrame;function oe(e){if(e){var a=e._owner,u=_e(e.type,e._source,a?a.type:null);ur.setExtraStackFrame(u)}else ur.setExtraStackFrame(null)}var Ae;Ae=!1;function ze(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function cr(){{if(Le.current){var e=j(Le.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function It(e){return""}var dr={};function Ot(e){{var a=cr();if(!a){var u=typeof e=="string"?e:e.displayName||e.name;u&&(a=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+u+">.")}return
|
|
25
|
+
Check the top-level render call using <`+u+">.")}return a}}function fr(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var u=Ot(a);if(dr[u])return;dr[u]=!0;var g="";e&&e._owner&&e._owner!==Le.current&&(g=" It was passed a child from "+j(e._owner.type)+"."),oe(e),d('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,g),oe(null)}}function vr(e,a){{if(typeof e!="object")return;if(De(e))for(var u=0;u<e.length;u++){var g=e[u];ze(g)&&fr(g,a)}else if(ze(e))e._store&&(e._store.validated=!0);else if(e){var C=L(e);if(typeof C=="function"&&C!==e.entries)for(var k=C.call(e),R;!(R=k.next()).done;)ze(R.value)&&fr(R.value,a)}}}function Dt(e){{var a=e.type;if(a==null||typeof a=="string")return;var u;if(typeof a=="function")u=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===v||a.$$typeof===E))u=a.propTypes;else return;if(u){var g=j(a);mt(u,e.props,"prop",g,e)}else if(a.PropTypes!==void 0&&!Ae){Ae=!0;var C=j(a);d("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",C||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&d("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Lt(e){{for(var a=Object.keys(e.props),u=0;u<a.length;u++){var g=a[u];if(g!=="children"&&g!=="key"){oe(e),d("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),oe(null);break}}e.ref!==null&&(oe(e),d("Invalid attribute `ref` supplied to `React.Fragment`."),oe(null))}}var pr={};function gr(e,a,u,g,C,k){{var R=re(e);if(!R){var y="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var W=It();W?y+=W:y+=cr();var D;e===null?D="null":De(e)?D="array":e!==void 0&&e.$$typeof===o?(D="<"+(j(e.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):D=typeof e,d("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,y)}var z=Vt(e,a,u,C,k);if(z==null)return z;if(R){var H=a.children;if(H!==void 0)if(g)if(De(H)){for(var ne=0;ne<H.length;ne++)vr(H[ne],e);Object.freeze&&Object.freeze(H)}else d("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else vr(H,e)}if(ve.call(a,"key")){var q=j(e),U=Object.keys(a).filter(function(Wt){return Wt!=="key"}),Fe=U.length>0?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}";if(!pr[q+Fe]){var Mt=U.length>0?"{"+U.join(": ..., ")+": ...}":"{}";d(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,ze,Q,zt,Q),cr[Q+ze]=!0}}return e===i?Tt(O):Vt(O),O}}function Dt(e,n,u){return dr(e,n,u,!0)}function It(e,n,u){return dr(e,n,u,!1)}var Ot=It,Lt=Dt;re.Fragment=i,re.jsx=Ot,re.jsxs=Lt}()),re}process.env.NODE_ENV==="production"?Ee.exports=fr():Ee.exports=vr();var s=Ee.exports;function pr(r){if(r.id&&/^[a-zA-Z][\w-]*$/.test(r.id))return`#${r.id}`;const o=[];let t=r;for(;t&&t.nodeType===Node.ELEMENT_NODE;){let i=t.nodeName.toLowerCase();if(t.id&&/^[a-zA-Z][\w-]*$/.test(t.id)){o.unshift(`#${t.id}`);break}if(t.className&&typeof t.className=="string"){const l=t.className.trim().split(/\s+/).filter(Boolean);if(l.length>0){const c=l.filter(g=>/^[a-zA-Z][\w-]*$/.test(g)).slice(0,2).map(g=>`.${g}`).join("");c&&(i+=c)}}if(o.length>0){const l=t.parentElement;if(l){const c=Array.from(l.children).filter(g=>g.nodeName===t.nodeName);if(c.length>1){const g=c.indexOf(t)+1;i+=`:nth-child(${g})`}}}o.unshift(i),t=t.parentElement}return o.join(" > ")}const gr="[data-review-layer-root]",br=16;function Re(r,o,t=br){if(typeof window>"u")return{x:r,y:o};const i=t,l=t,c=window.innerWidth-t,g=window.innerHeight-t;return{x:Math.max(i,Math.min(c,r)),y:Math.max(l,Math.min(g,o))}}function Me(r){var o;if(typeof document>"u"||!(r!=null&&r.trim()))return null;try{const t=document.querySelector(r);return!t||(o=t.closest)!=null&&o.call(t,gr)?null:t.getBoundingClientRect()}catch{return null}}function hr(r){if(typeof window>"u")return{relativeX:0,relativeY:0};const o=window.innerWidth,t=window.innerHeight;return{relativeX:o>0?r.left/o:0,relativeY:t>0?r.top/t:0}}function Se(r){if(typeof window>"u")return{x:r.x??0,y:r.y??0};const o=r.relativeX??r.relative_x??null,t=r.relativeY??r.relative_y??null;return o!=null&&t!=null?{x:o*window.innerWidth,y:t*window.innerHeight}:{x:r.x??0,y:r.y??0}}function xr(r){const{x:o,y:t}=Se(r),i=r.width??100,l=r.height??40;return new DOMRect(o,t,i,l)}function ce(r){const o=(r.relativeX??r.relative_x)!=null&&(r.relativeY??r.relative_y)!=null,t=r.x!=null&&r.y!=null;if(o||t)return Se(r);if(r.selector){const i=Me(r.selector);if(i!=null)return{x:i.left,y:i.top}}return Se(r)}const C={PENDING:"pending",DEV_FIXED:"dev_fixed",VALIDATED:"validated"};function te(r){return{"Content-Type":"application/json","x-review-key":r}}async function yr(r,o,t){const i=await fetch(`${r}/reviewers`,{headers:te(o),signal:t==null?void 0:t.signal});if(!i.ok)throw new Error("Failed to fetch reviewers");return(await i.json()).data??[]}async function mr(r,o,t){const i=await fetch(`${r}/comments`,{method:"POST",headers:te(o),body:JSON.stringify(t)});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.message||"Failed to create comment")}return(await i.json()).data}async function wr(r,o,t,i){const l=new URLSearchParams({url:t}),c=await fetch(`${r}/comments?${l}`,{headers:te(o),signal:i==null?void 0:i.signal});if(!c.ok)throw new Error("Failed to fetch comments");return(await c.json()).data??[]}async function _r(r,o,t,i){const l=await fetch(`${r}/comments/${t}/status`,{method:"PATCH",headers:te(o),body:JSON.stringify({status:i})});if(!l.ok){const g=await l.json().catch(()=>({}));throw new Error(g.message||"Failed to update comment status")}return(await l.json()).data}async function Er(r,o,t){const i=await fetch(`${r}/comments/${t}`,{method:"DELETE",headers:te(o)});if(!i.ok){const l=await i.json().catch(()=>({}));throw new Error(l.message||"Failed to delete comment")}}const Rr={position:"fixed",inset:0,zIndex:999997,backgroundColor:"transparent"},Sr={position:"fixed",minWidth:320,maxWidth:400,padding:"var(--ui-positive-Value_400, 16px)",backgroundColor:"var(--ui-color-bg-surface-default, #fff)",border:"1px solid var(--ui-color-border-subtle, #e8e8e8)",borderRadius:"var(--ui-radius_8, 8px)",boxShadow:"0 8px 24px var(--ui-color-black-alpha-20, rgba(0,0,0,0.15))",zIndex:999998},kr={width:"100%",minHeight:80,padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_300, 12px)",marginBottom:"var(--ui-positive-Value_200, 12px)",border:"1px solid var(--ui-color-border-default, #d9d9d9)",borderRadius:"var(--ui-radius_6, 6px)",fontSize:"var(--ui-font-size-sm, 14px)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",resize:"vertical",boxSizing:"border-box"},Cr={width:"100%",padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_300, 12px)",marginBottom:"var(--ui-positive-Value_300, 12px)",border:"1px solid var(--ui-color-border-default, #d9d9d9)",borderRadius:"var(--ui-radius_6, 6px)",fontSize:"var(--ui-font-size-sm, 14px)"},We={padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_400, 16px)",backgroundColor:"var(--ui-color-bg-fill-danger-default, #ff4d4f)",color:"var(--ui-color-text-on-color, #fff)",border:"none",borderRadius:"var(--ui-radius_6, 6px)",fontSize:"var(--ui-font-size-sm, 14px)",cursor:"pointer",fontWeight:"var(--ui-font-weight-medium, 500)"};function Pr({apiUrl:r,apiKey:o,reviewers:t,position:i,payload:l,onClose:c,onSuccess:g}){var L;const[b,f]=a.useState(""),[_,y]=a.useState(((L=t[0])==null?void 0:L.id)??0),[m,j]=a.useState(!1),[k,V]=a.useState(null);a.useEffect(()=>{t.length>0&&!_&&y(t[0].id)},[t,_]);const F=a.useCallback(async d=>{if(d.preventDefault(),!(!b.trim()||!_)){j(!0),V(null);try{await mr(r,o,{...l,message:b.trim(),reviewerId:_}),g(),c()}catch(v){V(v instanceof Error?v.message:"Failed to send comment")}finally{j(!1)}}},[r,o,l,b,_,g,c]);return a.useEffect(()=>{const d=v=>{v.key==="Escape"&&(v.preventDefault(),c())};return document.addEventListener("keydown",d,!0),()=>document.removeEventListener("keydown",d,!0)},[c]),s.jsxs(s.Fragment,{children:[s.jsx("div",{role:"presentation",style:Rr,onClick:c}),s.jsx("div",{style:{...Sr,left:Math.min(i.x,typeof window<"u"?window.innerWidth-420:i.x),top:i.y+12},onClick:d=>d.stopPropagation(),children:s.jsxs("form",{onSubmit:F,children:[s.jsx("textarea",{placeholder:"Escribe tu comentario...",value:b,onChange:d=>f(d.target.value),style:kr,required:!0,autoFocus:!0}),s.jsxs("select",{value:_,onChange:d=>y(Number(d.target.value)),style:Cr,required:!0,disabled:t.length===0,children:[s.jsx("option",{value:"",children:t.length===0?"No hay revisores (ejecuta php artisan db:seed en la API)":"Selecciona revisor"}),t.map(d=>s.jsx("option",{value:d.id,children:d.name},d.id))]}),k&&s.jsx("div",{style:{color:"var(--ui-color-text-danger-default, #ff4d4f)",fontSize:"var(--ui-font-size-xs, 12px)",marginBottom:"var(--ui-positive-Value_200, 8px)"},children:k}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"var(--ui-positive-Value_200, 8px)"},children:[s.jsx("button",{type:"button",onClick:c,style:{...We,backgroundColor:"var(--ui-color-bg-fill-secondary-default, #f0f0f0)",color:"var(--ui-color-text-primary, #333)"},children:"Cancelar"}),s.jsx("button",{type:"submit",style:We,disabled:m||t.length===0,children:m?"Enviando...":"Enviar comentario"})]})]})})]})}const jr=a.memo(Pr),Vr="var(--ui-color-red-500, #ef4444)";function Tr(r){return{position:"fixed",outline:`2px solid ${r}`,outlineOffset:"var(--ui-positive-Value_200, 2px)",pointerEvents:"none",zIndex:999997,boxSizing:"border-box"}}const Dr=a.memo(function({selector:o,active:t,fallbackComment:i,outlineColor:l=Vr}){const[c,g]=a.useState(null),b=a.useCallback(()=>{if(!t){g(null);return}const f=o!=null&&o.trim()?Me(o):null;if(f){g(f);return}if(i){g(xr(i));return}g(null)},[o,t,i]);return a.useEffect(()=>{b()},[b]),a.useEffect(()=>{if(t)return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[t,b]),!t||c==null?null:s.jsx("div",{"aria-hidden":!0,style:{...Tr(l),left:c.left,top:c.top,width:c.width,height:c.height}})}),de=32,Be=150,ke=250,M={cardBg:"var(--ui-color-bg-surface-default, #ffffff)",cardFooterBg:"var(--ui-color-bg-surface-secondary-default, #f8fafc)",textDark:"var(--ui-color-text-primary, #333333)",textMuted:"var(--ui-color-text-secondary, #888888)",border:"var(--ui-color-border-default, #cccccc)",shadow:"var(--ui-shadow-card, 0 4px 16px rgba(0, 0, 0, 0.12))"},Ir={[C.PENDING]:"Pendiente",[C.DEV_FIXED]:"Corregido",[C.VALIDATED]:"Validado"},Or={[C.PENDING]:"PENDIENTE",[C.DEV_FIXED]:"CORREGIDO",[C.VALIDATED]:"VALIDADO"},K={[C.PENDING]:"var(--ui-color-red-500, rgb(240, 69, 69))",[C.DEV_FIXED]:"var(--ui-color-yellow-500, rgb(235, 179, 8))",[C.VALIDATED]:"var(--ui-color-green-500, rgb(33, 196, 94))"},Ye={[C.PENDING]:"var(--ui-color-bg-surface-danger-default, #fef2f2)",[C.DEV_FIXED]:"var(--ui-color-bg-surface-warning-default, #fffbeb)",[C.VALIDATED]:"var(--ui-color-bg-surface-success-default, #f0fdf4)"},fe={[C.PENDING]:"var(--ui-color-red-500, #ef4444)",[C.DEV_FIXED]:"var(--ui-color-orange-500, #f59e0b)",[C.VALIDATED]:"var(--ui-color-green-500, #22c55e)"};function Lr(r){const o=r.trim().split(/\s+/);return o.length>=2?(o[0][0]+o[o.length-1][0]).toUpperCase():r.slice(0,2).toUpperCase()||"?"}const zr=()=>s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{marginRight:4,flexShrink:0},children:s.jsx("path",{d:"M10 3L4.5 8.5L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Ar=({color:r})=>s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[s.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),s.jsx("path",{d:"M8 10h.01M12 10h.01M16 10h.01",stroke:"var(--ui-color-white, #fff)",strokeWidth:"1.5",strokeLinecap:"round"})]}),Fr=r=>({position:"fixed",width:de,height:de,borderRadius:"50%",backgroundColor:K[r]??K[C.PENDING],color:"var(--ui-color-text-on-color, #fff)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",boxShadow:"0 2px 8px var(--ui-color-black-alpha-20, rgba(0,0,0,0.2))",zIndex:999998,border:"2px solid var(--ui-color-white, #fff)"}),Nr={position:"fixed",width:ke,minWidth:ke,maxWidth:ke,boxSizing:"border-box",backgroundColor:M.cardBg,borderRadius:"var(--ui-radius_12, 12px)",boxShadow:M.shadow,fontSize:"var(--ui-font-size-sm, 14px)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",zIndex:999999,pointerEvents:"auto"},Mr={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--ui-positive-Value_250, 10px)",borderBottom:`1px solid ${M.border}`,padding:"var(--ui-positive-Value_300, 12px)"},Wr=r=>({width:40,height:40,borderRadius:"50%",backgroundColor:K[r]??K[C.PENDING],color:"var(--ui-color-text-on-color, #fff)",border:"2px solid var(--ui-color-white, #fff)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"var(--ui-font-size-sm, 14px)",fontWeight:"var(--ui-font-weight-bold, 700)",flexShrink:0,overflow:"hidden"}),Br=a.memo(function({reviewer:o,status:t}){const i=o==null?void 0:o.image_url,l=(o==null?void 0:o.name)??"Revisor",c=Wr(t);if(i&&i.trim()){const g=K[t]??K[C.PENDING];return s.jsx("div",{style:{...c,border:`2px solid ${g}`},children:s.jsx("img",{src:i,alt:l,style:{width:"100%",height:"100%",objectFit:"cover"},loading:"lazy"})})}return s.jsx("div",{style:c,children:Lr(l)})}),Yr={flexShrink:0,width:"var(--ui-positive-Value_600, 24px)",height:"var(--ui-positive-Value_600, 24px)",padding:0,border:"none",borderRadius:"var(--ui-radius_6, 6px)",backgroundColor:"transparent",color:M.textDark,cursor:"pointer",fontSize:"var(--ui-positive-Value_450, 18px)",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},Ur=r=>{const o=fe[r]??fe[C.PENDING];return{display:"inline-flex",alignItems:"center",padding:"var(--ui-positive-Value_50, 4px) var(--ui-positive-Value_100, 10px)",borderRadius:"var(--ui-radius_full, 9999px)",fontSize:"8px",fontWeight:"var(--ui-font-weight-bold, 700)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",textTransform:"uppercase",letterSpacing:"0.02em",backgroundColor:Ye[r]??Ye[C.PENDING],color:o,border:`1px solid ${o}`}},Gr={display:"block",fontSize:"var(--ui-font-size-2xs, 10px)",fontWeight:"var(--ui-font-weight-semibold, 600)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",color:M.textMuted,textTransform:"uppercase",letterSpacing:"0.04em"},Hr={width:"100%",padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_300, 12px)",paddingRight:"var(--ui-positive-Value_800, 32px)",fontSize:"var(--ui-font-size-xs, 13px)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",borderRadius:"var(--ui-radius_8, 8px)",border:`1px solid ${M.border}`,backgroundColor:M.cardBg,color:M.textDark,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L2 4h8z'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right var(--ui-positive-Value_250, 10px) center"},Xr={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"var(--ui-positive-Value_200, 8px)",padding:"var(--ui-positive-Value_300, 12px)",borderTop:`1px solid ${M.border}`,backgroundColor:M.cardFooterBg},Ue={minWidth:100,padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_350, 14px)",fontSize:"var(--ui-font-size-xs, 13px)",fontWeight:"var(--ui-font-weight-semibold, 600)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",borderRadius:"var(--ui-radius_8, 8px)",cursor:"pointer",border:"none"},Jr={...Ue,backgroundColor:"transparent",color:M.textDark},ve="review-layer-resolve-btn",Zr=["pending","dev_fixed","validated"],Qr={...Ue,backgroundColor:"var(--ui-color-bg-fill-success-default, #22c55e)",color:"var(--ui-color-text-on-color, #fff)"};function Kr({comment:r,offset:o={dx:0,dy:0},apiUrl:t,apiKey:i,onStatusChange:l,reviewMode:c=!1}){var ae,le;const[g,b]=a.useState(!1),[f,_]=a.useState(!1),[y,m]=a.useState(()=>ce(r)),[j,k]=a.useState(!1),[V,F]=a.useState(null),L=a.useRef(null),d=a.useRef(null),v=a.useRef(null),I=a.useCallback(()=>{m(ce(r))},[r]);a.useEffect(()=>{I()},[I]),a.useEffect(()=>{if(!(typeof window>"u"))return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[I]);const A=a.useCallback(()=>{L.current!==null&&(clearTimeout(L.current),L.current=null)},[]),H=a.useCallback(()=>{c||(A(),b(!0))},[c,A]),oe=a.useCallback(()=>{f||(L.current=setTimeout(()=>{L.current=null,b(!1)},Be))},[f]),ne=a.useCallback(()=>{A(),b(!0)},[A]),ie=a.useCallback(()=>{f||(L.current=setTimeout(()=>{L.current=null,b(!1)},Be))},[f]),X=a.useCallback(()=>{if(c){f&&(_(!1),b(!1));return}f?(_(!1),b(!1)):(_(!0),b(!0))},[c,f]);a.useEffect(()=>{if(!f)return;const E=Z=>{var he,xe;const ue=Z.target;(he=d.current)!=null&&he.contains(ue)||(xe=v.current)!=null&&xe.contains(ue)||(_(!1),b(!1))};return document.addEventListener("mousedown",E,!0),()=>document.removeEventListener("mousedown",E,!0)},[f]),a.useEffect(()=>()=>A(),[A]),a.useEffect(()=>{c&&(_(!1),b(!1))},[c]);const w=y.x+o.dx,P=y.y+o.dy,{x:z,y:T}=Re(w,P,de/2),U=g&&!f,B=a.useCallback(()=>{_(!1),b(!1)},[]),J=a.useCallback(async E=>{if(E!==r.status){F(null),k(!0);try{await _r(t,i,r.id,E),l()}catch(Z){F(Z instanceof Error?Z.message:"Error al actualizar")}finally{k(!1)}}},[t,i,r.id,r.status,l]),ge=a.useCallback(async()=>{F(null),k(!0);try{await Er(t,i,r.id),l(),B()}catch(E){F(E instanceof Error?E.message:"Error al eliminar")}finally{k(!1)}},[t,i,r.id,l,B]),be=a.useMemo(()=>({...Fr(r.status),left:z,top:T,transform:"translate(-50%, -50%)"}),[r.status,z,T]);return s.jsxs(s.Fragment,{children:[s.jsx(Dr,{selector:r.selector,active:U,fallbackComment:r,outlineColor:fe[r.status]??fe[C.PENDING]}),s.jsx("div",{ref:d,role:"button",tabIndex:0,"aria-label":`Comentario: ${r.message.slice(0,30)}...`,"aria-expanded":g,style:be,onMouseEnter:H,onMouseLeave:oe,onClick:X,children:s.jsx(Ar,{color:"var(--ui-color-white, #fff)"})}),g&&s.jsxs("div",{ref:v,role:"dialog","aria-label":"Detalle del comentario",style:{...Nr,left:z+de/2+6,top:T},onMouseEnter:ne,onMouseLeave:ie,children:[s.jsxs("div",{style:Mr,children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1,minWidth:0},children:[s.jsx(Br,{reviewer:r.reviewer,status:r.status}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:700,fontSize:14,color:M.textDark},children:((ae=r.reviewer)==null?void 0:ae.name)??"Revisor"}),s.jsx("div",{style:{fontSize:12,color:M.textMuted},children:((le=r.reviewer)==null?void 0:le.job_title)??"Revisor"})]})]}),s.jsx("button",{type:"button","aria-label":r.status===C.VALIDATED?"Eliminar comentario":"Cerrar",style:Yr,disabled:j,onClick:E=>{E.stopPropagation(),r.status===C.VALIDATED?ge():B()},onMouseDown:E=>E.stopPropagation(),children:"✕"})]}),s.jsxs("div",{style:{padding:12,display:"flex",alignItems:"flex-start",flexDirection:"column",gap:4},children:[s.jsxs("div",{style:Ur(r.status),children:[r.status===C.VALIDATED&&s.jsx(zr,{}),Or[r.status]??r.status]}),s.jsx("div",{style:{color:M.textDark,lineHeight:1.5,marginBottom:12,marginTop:12},children:r.message}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[s.jsx("label",{style:Gr,htmlFor:`comment-status-${r.id}`,children:"Cambiar estado"}),s.jsx("select",{id:`comment-status-${r.id}`,style:Hr,value:r.status,disabled:j,onChange:E=>J(E.target.value),onMouseDown:E=>E.stopPropagation(),"aria-label":"Cambiar estado del comentario",children:Zr.map(E=>s.jsx("option",{value:E,children:Ir[E]},E))}),V&&s.jsx("div",{style:{marginTop:8,fontSize:11,color:"var(--ui-color-text-danger-default, rgb(240, 69, 69))"},children:V})]})]}),s.jsxs("div",{style:Xr,children:[s.jsx("button",{type:"button",style:Jr,onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),B()},children:"Cerrar"}),r.status!==C.VALIDATED&&s.jsxs(s.Fragment,{children:[s.jsx("style",{children:`
|
|
31
|
-
.${
|
|
30
|
+
<%s key={someKey} {...props} />`,Fe,q,Mt,q),pr[q+Fe]=!0}}return e===n?Lt(z):Dt(z),z}}function At(e,a,u){return gr(e,a,u,!0)}function zt(e,a,u){return gr(e,a,u,!1)}var Ft=zt,Nt=At;ae.Fragment=n,ae.jsx=Ft,ae.jsxs=Nt}()),ae}process.env.NODE_ENV==="production"?Se.exports=hr():Se.exports=br();var f=Se.exports;function yr(r){if(r.id&&/^[a-zA-Z][\w-]*$/.test(r.id))return`#${r.id}`;const o=[];let t=r;for(;t&&t.nodeType===Node.ELEMENT_NODE;){let n=t.nodeName.toLowerCase();if(t.id&&/^[a-zA-Z][\w-]*$/.test(t.id)){o.unshift(`#${t.id}`);break}if(t.className&&typeof t.className=="string"){const i=t.className.trim().split(/\s+/).filter(Boolean);if(i.length>0){const l=i.filter(c=>/^[a-zA-Z][\w-]*$/.test(c)).slice(0,2).map(c=>`.${c}`).join("");l&&(n+=l)}}if(o.length>0){const i=t.parentElement;if(i){const l=Array.from(i.children).filter(c=>c.nodeName===t.nodeName);if(l.length>1){const c=l.indexOf(t)+1;n+=`:nth-child(${c})`}}}o.unshift(n),t=t.parentElement}return o.join(" > ")}const xr="[data-review-layer-root]",mr=16;function Ce(r,o,t=mr){if(typeof window>"u")return{x:r,y:o};const n=t,i=t,l=window.innerWidth-t,c=window.innerHeight-t;return{x:Math.max(n,Math.min(l,r)),y:Math.max(i,Math.min(c,o))}}function Be(r){if(typeof document>"u"||!r)return[];const o=[];let t=r.parentElement;for(;t&&t!==document.body;){const n=getComputedStyle(t),i=n.overflowX,l=n.overflowY;(i==="scroll"||i==="auto"||i==="overlay"||l==="scroll"||l==="auto"||l==="overlay")&&(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&o.push(t),t=t.parentElement}return o}function Ue(r){var o;if(typeof document>"u"||!(r!=null&&r.trim()))return null;try{const t=document.querySelector(r);return!t||(o=t.closest)!=null&&o.call(t,xr)?null:t.getBoundingClientRect()}catch{return null}}function wr(r){if(typeof window>"u")return{relativeX:0,relativeY:0};const o=window.innerWidth,t=window.innerHeight;return{relativeX:o>0?r.left/o:0,relativeY:t>0?r.top/t:0}}function Ye(r){if(typeof window>"u")return{x:r.x??0,y:r.y??0};const o=r.relativeX??r.relative_x??null,t=r.relativeY??r.relative_y??null;return o!=null&&t!=null?{x:o*window.innerWidth,y:t*window.innerHeight}:{x:r.x??0,y:r.y??0}}function Er(r){const{x:o,y:t}=Ye(r),n=r.width??100,i=r.height??40;return new DOMRect(o,t,n,i)}function pe(r){if(r.selector){const o=Ue(r.selector);if(o!=null)return{x:o.left,y:o.top}}return Ye(r)}function ke(){if(typeof window>"u")return"/";try{const r=new URLSearchParams(window.location.search).get("path");if(r!=null&&r.trim()!=="")return r.startsWith("/")?r:`/${r}`}catch{}return window.location.pathname||"/"}const T={PENDING:"pending",DEV_FIXED:"dev_fixed",VALIDATED:"validated"},He="[review-layer API]";function X(r,o,t){if("status"in t){const{status:p,statusText:v,body:w=""}=t;let b;p===401?b="No autorizado (401). Revisa que apiKey sea correcta y esté aceptada por la API.":p===403?b="Acceso denegado (403). Revisa apiKey o permisos del proyecto.":p===404?b="Recurso no encontrado (404). Revisa apiUrl y que la ruta exista en el backend.":p>=500?b="Error del servidor (5xx). El backend puede estar caído o sobrecargado.":b=`Respuesta HTTP ${p} ${v}. Revisa la API.`,console.error(He,r,{motivo:b,url:o,status:p,statusText:v,body:w.slice(0,300)});return}const n=t.networkError,i=n instanceof Error?n.message:String(n),c=n instanceof TypeError||/failed to fetch|networkerror|load failed|network request failed/i.test(i)?"Posible CORS o error de red (servidor inalcanzable, bloqueo CORS o certificado). Revisa que apiUrl sea accesible desde este origen y que el backend permita CORS.":`Error inesperado: ${i}`;console.error(He,r,{motivo:c,url:o,error:n})}function se(r){return{"Content-Type":"application/json","x-review-key":r}}async function _r(r,o,t){const n=`${r}/reviewers`;let i;try{i=await fetch(n,{headers:se(o),signal:t==null?void 0:t.signal})}catch(c){throw X("fetchReviewers (red/CORS)",n,{networkError:c}),c}if(!i.ok){const c=await i.text();throw X("fetchReviewers",n,{status:i.status,statusText:i.statusText,body:c}),new Error("Failed to fetch reviewers")}return(await i.json()).data??[]}async function Rr(r,o,t){const n=`${r}/comments`;let i;try{i=await fetch(n,{method:"POST",headers:se(o),body:JSON.stringify(t)})}catch(c){throw X("createComment (red/CORS)",n,{networkError:c}),c}if(!i.ok){const c=await i.text();let p="Failed to create comment";try{p=JSON.parse(c).message??p}catch{}throw X("createComment",n,{status:i.status,statusText:i.statusText,body:c}),new Error(p)}return(await i.json()).data}async function Sr(r,o,t,n){const i=new URLSearchParams({url:t}),l=`${r}/comments?${i}`;let c;try{c=await fetch(l,{headers:se(o),signal:n==null?void 0:n.signal})}catch(v){throw X("fetchComments (red/CORS)",l,{networkError:v}),v}if(!c.ok){const v=await c.text();throw X("fetchComments",l,{status:c.status,statusText:c.statusText,body:v}),new Error("Failed to fetch comments")}return(await c.json()).data??[]}async function Cr(r,o,t,n){const i=`${r}/comments/${t}/status`;let l;try{l=await fetch(i,{method:"PATCH",headers:se(o),body:JSON.stringify({status:n})})}catch(p){throw X("updateCommentStatus (red/CORS)",i,{networkError:p}),p}if(!l.ok){const p=await l.text();X("updateCommentStatus",i,{status:l.status,statusText:l.statusText,body:p});let v="Failed to update comment status";try{v=JSON.parse(p).message??v}catch{}throw new Error(v)}return(await l.json()).data}async function kr(r,o,t){const n=`${r}/comments/${t}`;let i;try{i=await fetch(n,{method:"DELETE",headers:se(o)})}catch(l){throw X("deleteComment (red/CORS)",n,{networkError:l}),l}if(!i.ok){const l=await i.text();X("deleteComment",n,{status:i.status,statusText:i.statusText,body:l});let c="Failed to delete comment";try{c=JSON.parse(l).message??c}catch{}throw new Error(c)}}const Pr={position:"fixed",inset:0,zIndex:999997,backgroundColor:"transparent"},Tr={position:"fixed",minWidth:320,maxWidth:400,padding:"var(--ui-positive-Value_400, 16px)",backgroundColor:"var(--ui-color-bg-surface-default, #fff)",border:"1px solid var(--ui-color-border-subtle, #e8e8e8)",borderRadius:"var(--ui-radius_8, 8px)",boxShadow:"0 8px 24px var(--ui-color-black-alpha-20, rgba(0,0,0,0.15))",zIndex:999998},jr={width:"100%",minHeight:80,padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_300, 12px)",marginBottom:"var(--ui-positive-Value_200, 12px)",border:"1px solid var(--ui-color-border-default, #d9d9d9)",borderRadius:"var(--ui-radius_6, 6px)",fontSize:"var(--ui-font-size-sm, 14px)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",resize:"vertical",boxSizing:"border-box"},Vr={width:"100%",padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_300, 12px)",marginBottom:"var(--ui-positive-Value_300, 12px)",border:"1px solid var(--ui-color-border-default, #d9d9d9)",borderRadius:"var(--ui-radius_6, 6px)",fontSize:"var(--ui-font-size-sm, 14px)"},Ge={padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_400, 16px)",backgroundColor:"var(--ui-color-bg-fill-danger-default, #ff4d4f)",color:"var(--ui-color-text-on-color, #fff)",border:"none",borderRadius:"var(--ui-radius_6, 6px)",fontSize:"var(--ui-font-size-sm, 14px)",cursor:"pointer",fontWeight:"var(--ui-font-weight-medium, 500)"};function Ir({apiUrl:r,apiKey:o,reviewers:t,position:n,payload:i,onClose:l,onSuccess:c}){var h;const[p,v]=s.useState(""),[w,b]=s.useState(((h=t[0])==null?void 0:h.id)??0),[E,V]=s.useState(!1),[P,O]=s.useState(null);s.useEffect(()=>{t.length>0&&!w&&b(t[0].id)},[t,w]);const M=s.useCallback(async d=>{if(d.preventDefault(),!(!p.trim()||!w)){V(!0),O(null);try{await Rr(r,o,{...i,message:p.trim(),reviewerId:w}),c(),l()}catch(x){O(x instanceof Error?x.message:"Failed to send comment")}finally{V(!1)}}},[r,o,i,p,w,c,l]),L=s.useRef(null);return s.useEffect(()=>{const d=x=>{x.key==="Escape"&&(x.preventDefault(),l())};return document.addEventListener("keydown",d,!0),()=>document.removeEventListener("keydown",d,!0)},[l]),s.useEffect(()=>{const d=x=>{const A=x.target;L.current&&!L.current.contains(A)&&(x.preventDefault(),x.stopPropagation(),l())};return document.addEventListener("mousedown",d,!0),()=>document.removeEventListener("mousedown",d,!0)},[l]),s.useEffect(()=>{var d;(d=L.current)==null||d.focus()},[]),f.jsxs("div",{ref:L,role:"dialog","aria-modal":"true",tabIndex:-1,style:{position:"fixed",inset:0,zIndex:999997,outline:"none"},children:[f.jsx("div",{role:"presentation",style:Pr,onClick:l}),f.jsx("div",{style:{...Tr,left:Math.min(n.x,typeof window<"u"?window.innerWidth-420:n.x),top:n.y+12},onClick:d=>d.stopPropagation(),children:f.jsxs("form",{onSubmit:M,children:[f.jsx("textarea",{placeholder:"Escribe tu comentario...",value:p,onChange:d=>v(d.target.value),style:jr,required:!0,autoFocus:!0}),f.jsxs("select",{value:w,onChange:d=>b(Number(d.target.value)),style:Vr,required:!0,disabled:t.length===0,children:[f.jsx("option",{value:"",children:t.length===0?"No hay revisores (ejecuta php artisan db:seed en la API)":"Selecciona revisor"}),t.map(d=>f.jsx("option",{value:d.id,children:d.name},d.id))]}),P&&f.jsx("div",{style:{color:"var(--ui-color-text-danger-default, #ff4d4f)",fontSize:"var(--ui-font-size-xs, 12px)",marginBottom:"var(--ui-positive-Value_200, 8px)"},children:P}),f.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"var(--ui-positive-Value_200, 8px)"},children:[f.jsx("button",{type:"button",onClick:l,style:{...Ge,backgroundColor:"var(--ui-color-bg-fill-secondary-default, #f0f0f0)",color:"var(--ui-color-text-primary, #333)"},children:"Cancelar"}),f.jsx("button",{type:"submit",style:Ge,disabled:E||t.length===0,children:E?"Enviando...":"Enviar comentario"})]})]})})]})}const Or=s.memo(Ir),Dr="var(--ui-color-red-500, #ef4444)";function Lr(r){return{position:"fixed",outline:`2px solid ${r}`,outlineOffset:"var(--ui-positive-Value_200, 2px)",pointerEvents:"none",zIndex:999997,boxSizing:"border-box"}}const Ar=s.memo(function({selector:o,active:t,fallbackComment:n,outlineColor:i=Dr}){const[l,c]=s.useState(null),p=s.useCallback(()=>{if(!t){c(null);return}const v=o!=null&&o.trim()?Ue(o):null;if(v){c(v);return}if(n){c(Er(n));return}c(null)},[o,t,n]);return s.useEffect(()=>{p()},[p]),s.useEffect(()=>{if(t)return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[t,p]),!t||l==null?null:f.jsx("div",{"aria-hidden":!0,style:{...Lr(i),left:l.left,top:l.top,width:l.width,height:l.height}})}),ge=32,Xe=150,Pe=250,B={cardBg:"var(--ui-color-bg-surface-default, #ffffff)",cardFooterBg:"var(--ui-color-bg-surface-secondary-default, #f8fafc)",textDark:"var(--ui-color-text-primary, #333333)",textMuted:"var(--ui-color-text-secondary, #888888)",border:"var(--ui-color-border-default, #cccccc)",shadow:"var(--ui-shadow-card, 0 4px 16px rgba(0, 0, 0, 0.12))"},zr={[T.PENDING]:"Pendiente",[T.DEV_FIXED]:"Corregido",[T.VALIDATED]:"Validado"},Fr={[T.PENDING]:"PENDIENTE",[T.DEV_FIXED]:"CORREGIDO",[T.VALIDATED]:"VALIDADO"},$={[T.PENDING]:"var(--ui-color-red-500, rgb(240, 69, 69))",[T.DEV_FIXED]:"var(--ui-color-yellow-500, rgb(235, 179, 8))",[T.VALIDATED]:"var(--ui-color-green-500, rgb(33, 196, 94))"},Je={[T.PENDING]:"var(--ui-color-bg-surface-danger-default, #fef2f2)",[T.DEV_FIXED]:"var(--ui-color-bg-surface-warning-default, #fffbeb)",[T.VALIDATED]:"var(--ui-color-bg-surface-success-default, #f0fdf4)"},he={[T.PENDING]:"var(--ui-color-red-500, #ef4444)",[T.DEV_FIXED]:"var(--ui-color-orange-500, #f59e0b)",[T.VALIDATED]:"var(--ui-color-green-500, #22c55e)"};function Nr(r){const o=r.trim().split(/\s+/);return o.length>=2?(o[0][0]+o[o.length-1][0]).toUpperCase():r.slice(0,2).toUpperCase()||"?"}const Mr=()=>f.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{marginRight:4,flexShrink:0},children:f.jsx("path",{d:"M10 3L4.5 8.5L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Wr=({color:r})=>f.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[f.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),f.jsx("path",{d:"M8 10h.01M12 10h.01M16 10h.01",stroke:"var(--ui-color-white, #fff)",strokeWidth:"1.5",strokeLinecap:"round"})]}),Br=r=>({position:"fixed",width:ge,height:ge,borderRadius:"50%",backgroundColor:$[r]??$[T.PENDING],color:"var(--ui-color-text-on-color, #fff)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",boxShadow:"0 2px 8px var(--ui-color-black-alpha-20, rgba(0,0,0,0.2))",zIndex:999998,border:"2px solid var(--ui-color-white, #fff)"}),Ur={position:"fixed",width:Pe,minWidth:Pe,maxWidth:Pe,boxSizing:"border-box",backgroundColor:B.cardBg,borderRadius:"var(--ui-radius_12, 12px)",boxShadow:B.shadow,fontSize:"var(--ui-font-size-sm, 14px)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",zIndex:999999,pointerEvents:"auto"},Yr={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--ui-positive-Value_250, 10px)",borderBottom:`1px solid ${B.border}`,padding:"var(--ui-positive-Value_300, 12px)"},Hr=r=>({width:40,height:40,borderRadius:"50%",backgroundColor:$[r]??$[T.PENDING],color:"var(--ui-color-text-on-color, #fff)",border:"2px solid var(--ui-color-white, #fff)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"var(--ui-font-size-sm, 14px)",fontWeight:"var(--ui-font-weight-bold, 700)",flexShrink:0,overflow:"hidden"}),Gr=s.memo(function({reviewer:o,status:t}){const n=o==null?void 0:o.image_url,i=(o==null?void 0:o.name)??"Revisor",l=Hr(t);if(n&&n.trim()){const c=$[t]??$[T.PENDING];return f.jsx("div",{style:{...l,border:`2px solid ${c}`},children:f.jsx("img",{src:n,alt:i,style:{width:"100%",height:"100%",objectFit:"cover"},loading:"lazy"})})}return f.jsx("div",{style:l,children:Nr(i)})}),Xr={flexShrink:0,width:"var(--ui-positive-Value_600, 24px)",height:"var(--ui-positive-Value_600, 24px)",padding:0,border:"none",borderRadius:"var(--ui-radius_6, 6px)",backgroundColor:"transparent",color:B.textDark,cursor:"pointer",fontSize:"var(--ui-positive-Value_450, 18px)",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},Jr=r=>{const o=he[r]??he[T.PENDING];return{display:"inline-flex",alignItems:"center",padding:"var(--ui-positive-Value_50, 4px) var(--ui-positive-Value_100, 10px)",borderRadius:"var(--ui-radius_full, 9999px)",fontSize:"8px",fontWeight:"var(--ui-font-weight-bold, 700)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",textTransform:"uppercase",letterSpacing:"0.02em",backgroundColor:Je[r]??Je[T.PENDING],color:o,border:`1px solid ${o}`}},Zr={display:"block",fontSize:"var(--ui-font-size-2xs, 10px)",fontWeight:"var(--ui-font-weight-semibold, 600)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",color:B.textMuted,textTransform:"uppercase",letterSpacing:"0.04em"},Qr={width:"100%",padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_300, 12px)",paddingRight:"var(--ui-positive-Value_800, 32px)",fontSize:"var(--ui-font-size-xs, 13px)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",borderRadius:"var(--ui-radius_8, 8px)",border:`1px solid ${B.border}`,backgroundColor:B.cardBg,color:B.textDark,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L2 4h8z'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right var(--ui-positive-Value_250, 10px) center"},Kr={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"var(--ui-positive-Value_200, 8px)",padding:"var(--ui-positive-Value_300, 12px)",borderTop:`1px solid ${B.border}`,backgroundColor:B.cardFooterBg},Ze={minWidth:100,padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_350, 14px)",fontSize:"var(--ui-font-size-xs, 13px)",fontWeight:"var(--ui-font-weight-semibold, 600)",fontFamily:"var(--ui-font-family-ui, 'Inter', sans-serif)",borderRadius:"var(--ui-radius_8, 8px)",cursor:"pointer",border:"none"},qr={...Ze,backgroundColor:"transparent",color:B.textDark},be="review-layer-resolve-btn",$r=["pending","dev_fixed","validated"],et={...Ze,backgroundColor:"var(--ui-color-bg-fill-success-default, #22c55e)",color:"var(--ui-color-text-on-color, #fff)"};function rt({comment:r,offset:o={dx:0,dy:0},apiUrl:t,apiKey:n,onStatusChange:i,reviewMode:l=!1}){var de,fe;const[c,p]=s.useState(!1),[v,w]=s.useState(!1),[b,E]=s.useState(()=>pe(r)),[V,P]=s.useState(!1),[O,M]=s.useState(null),L=s.useRef(null),h=s.useRef(null),d=s.useRef(null),x=s.useCallback(()=>{E(pe(r))},[r]);s.useEffect(()=>{x()},[x]),s.useEffect(()=>{if(!(typeof window>"u"))return window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[x]),s.useEffect(()=>{if(!r.selector||typeof document>"u")return;const _=document.querySelector(r.selector);if(!_)return;const K=Be(_).map(J=>(J.addEventListener("scroll",x,!0),()=>J.removeEventListener("scroll",x,!0)));return()=>K.forEach(J=>J())},[r.selector,x]);const A=s.useCallback(()=>{L.current!==null&&(clearTimeout(L.current),L.current=null)},[]),F=s.useCallback(()=>{l||(A(),p(!0))},[l,A]),le=s.useCallback(()=>{v||(L.current=setTimeout(()=>{L.current=null,p(!1)},Xe))},[v]),ue=s.useCallback(()=>{A(),p(!0)},[A]),ce=s.useCallback(()=>{v||(L.current=setTimeout(()=>{L.current=null,p(!1)},Xe))},[v]),ee=s.useCallback(()=>{if(l){v&&(w(!1),p(!1));return}v?(w(!1),p(!1)):(w(!0),p(!0))},[l,v]);s.useEffect(()=>{if(!v)return;const _=Z=>{var J,me;const K=Z.target;(J=h.current)!=null&&J.contains(K)||(me=d.current)!=null&&me.contains(K)||(w(!1),p(!1))};return document.addEventListener("mousedown",_,!0),()=>document.removeEventListener("mousedown",_,!0)},[v]),s.useEffect(()=>()=>A(),[A]),s.useEffect(()=>{l&&(w(!1),p(!1))},[l]);const re=b.x+o.dx,m=b.y+o.dy,{x:S,y:j}=Ce(re,m,ge/2),I=c&&!v,Y=s.useCallback(()=>{w(!1),p(!1)},[]),Q=s.useCallback(async _=>{if(_!==r.status){M(null),P(!0);try{await Cr(t,n,r.id,_),i()}catch(Z){M(Z instanceof Error?Z.message:"Error al actualizar")}finally{P(!1)}}},[t,n,r.id,r.status,i]),te=s.useCallback(async()=>{M(null),P(!0);try{await kr(t,n,r.id),i(),Y()}catch(_){M(_ instanceof Error?_.message:"Error al eliminar")}finally{P(!1)}},[t,n,r.id,i,Y]),xe=s.useMemo(()=>({...Br(r.status),left:S,top:j,transform:"translate(-50%, -50%)"}),[r.status,S,j]);return f.jsxs(f.Fragment,{children:[f.jsx(Ar,{selector:r.selector,active:I,fallbackComment:r,outlineColor:he[r.status]??he[T.PENDING]}),f.jsx("div",{ref:h,role:"button",tabIndex:0,"aria-label":`Comentario: ${r.message.slice(0,30)}...`,"aria-expanded":c,style:xe,onMouseEnter:F,onMouseLeave:le,onClick:ee,children:f.jsx(Wr,{color:"var(--ui-color-white, #fff)"})}),c&&f.jsxs("div",{ref:d,role:"dialog","aria-label":"Detalle del comentario",style:{...Ur,left:S+ge/2+6,top:j},onMouseEnter:ue,onMouseLeave:ce,children:[f.jsxs("div",{style:Yr,children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1,minWidth:0},children:[f.jsx(Gr,{reviewer:r.reviewer,status:r.status}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:700,fontSize:14,color:B.textDark},children:((de=r.reviewer)==null?void 0:de.name)??"Revisor"}),f.jsx("div",{style:{fontSize:12,color:B.textMuted},children:((fe=r.reviewer)==null?void 0:fe.job_title)??"Revisor"})]})]}),f.jsx("button",{type:"button","aria-label":r.status===T.VALIDATED?"Eliminar comentario":"Cerrar",style:Xr,disabled:V,onClick:_=>{_.stopPropagation(),r.status===T.VALIDATED?te():Y()},onMouseDown:_=>_.stopPropagation(),children:"✕"})]}),f.jsxs("div",{style:{padding:12,display:"flex",alignItems:"flex-start",flexDirection:"column",gap:4},children:[f.jsxs("div",{style:Jr(r.status),children:[r.status===T.VALIDATED&&f.jsx(Mr,{}),Fr[r.status]??r.status]}),f.jsx("div",{style:{color:B.textDark,lineHeight:1.5,marginBottom:12,marginTop:12},children:r.message}),f.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[f.jsx("label",{style:Zr,htmlFor:`comment-status-${r.id}`,children:"Cambiar estado"}),f.jsx("select",{id:`comment-status-${r.id}`,style:Qr,value:r.status,disabled:V,onChange:_=>Q(_.target.value),onMouseDown:_=>_.stopPropagation(),"aria-label":"Cambiar estado del comentario",children:$r.map(_=>f.jsx("option",{value:_,children:zr[_]},_))}),O&&f.jsx("div",{style:{marginTop:8,fontSize:11,color:"var(--ui-color-text-danger-default, rgb(240, 69, 69))"},children:O})]})]}),f.jsxs("div",{style:Kr,children:[f.jsx("button",{type:"button",style:qr,onMouseDown:_=>_.stopPropagation(),onClick:_=>{_.stopPropagation(),Y()},children:"Cerrar"}),r.status!==T.VALIDATED&&f.jsxs(f.Fragment,{children:[f.jsx("style",{children:`
|
|
31
|
+
.${be}:hover:not(:disabled) {
|
|
32
32
|
background-color: var(--ui-color-bg-fill-success-hover, #16a34a) !important;
|
|
33
33
|
}
|
|
34
|
-
.${
|
|
34
|
+
.${be}:active:not(:disabled) {
|
|
35
35
|
background-color: var(--ui-color-bg-fill-success-pressed, #15803d) !important;
|
|
36
36
|
}
|
|
37
|
-
.${
|
|
37
|
+
.${be}:disabled {
|
|
38
38
|
background-color: var(--ui-color-bg-fill-success-default, #22c55e) !important;
|
|
39
39
|
opacity: 0.7;
|
|
40
40
|
cursor: not-allowed;
|
|
41
41
|
}
|
|
42
|
-
`}),
|
|
42
|
+
`}),f.jsx("button",{type:"button",className:be,style:et,disabled:V,onMouseDown:_=>_.stopPropagation(),onClick:_=>{_.stopPropagation(),Q("validated")},children:"Validar"})]})]})]})]})}const tt=s.memo(rt),ot=25,nt=36;function it(r){const o=new Map;for(let t=0;t<r.length;t++){const n=r[t],{x:i,y:l}=pe(n),{x:c,y:p}=Ce(i,l);let v=0;for(let w=0;w<t;w++){const{x:b,y:E}=pe(r[w]),{x:V,y:P}=Ce(b,E);Math.hypot(c-V,p-P)<ot&&v++}o.set(n.id,{dx:v*nt,dy:0})}return o}function at(){return typeof window>"u"?"":`${window.innerWidth}x${window.innerHeight}`}function st({apiUrl:r,apiKey:o,reviewMode:t,setReviewMode:n,reviewers:i,comments:l,loadComments:c,commentsLoadFailed:p=!1}){const[v,w]=s.useState(null),b=s.useRef(null),[E,V]=s.useState(null),P=s.useCallback(()=>{v&&(v.style.outline="",v.style.outlineOffset="",w(null))},[v]),O=s.useCallback(()=>{b.current&&(b.current.style.outline="",b.current.style.outlineOffset="",b.current=null)},[]);s.useEffect(()=>{t||(P(),O())},[t,P,O]),s.useEffect(()=>{if(typeof document>"u")return;const m=document.body.style.cursor;return E?document.body.style.cursor="default":t&&(document.body.style.cursor="crosshair"),()=>{document.body.style.cursor=m}},[t,E]);const M=s.useCallback(m=>{var j;if(!m||typeof document>"u"||m===document.body||m===document.documentElement)return!0;const S=(j=m.tagName)==null?void 0:j.toUpperCase();return S==="BODY"||S==="HTML"?!0:m.parentElement!==document.body?!1:m.id==="root"||m.getAttribute("data-review-layer-host")!=null||document.body.children.length===1},[]),L=s.useCallback(m=>{if(!t||E)return;const S=m.target.nodeType===Node.ELEMENT_NODE?m.target:m.target.parentElement;!S||M(S)||(P(),w(S),S.style.outline="2px solid var(--ui-color-bg-fill-danger-default, #ff4d4f)",S.style.outlineOffset="2px")},[t,E,P,M]),h=s.useCallback(m=>{var j;if(E)return;const S=m.relatedTarget;v&&(!S||!v.contains(S))&&!(S&&((j=v.contains)!=null&&j.call(v,S)))&&P()},[v,E,P]),d=s.useCallback(m=>{if(!t||E)return;const S=m.target;if(!S||M(S)||S.closest("[data-review-layer-root]"))return;m.preventDefault(),m.stopPropagation(),P();const j=S;b.current=j,j.style.outline="2px solid var(--ui-color-bg-fill-danger-default, #ff4d4f)",j.style.outlineOffset="2px";const I=j.getBoundingClientRect(),Y=yr(S),{relativeX:Q,relativeY:te}=wr(I);V({position:{x:I.left+I.width/2,y:I.bottom},payload:{selector:Y,x:Math.round(I.left),y:Math.round(I.top),relativeX:Q,relativeY:te,width:Math.round(I.width),height:Math.round(I.height),url:typeof window<"u"?ke():"/",viewport:at(),userAgent:typeof navigator<"u"?navigator.userAgent:"",pageTitle:typeof document<"u"?document.title:""}})},[t,E,P,M]);s.useEffect(()=>{if(t)return document.addEventListener("mouseover",L,!0),document.addEventListener("mouseout",h,!0),document.addEventListener("click",d,!0),()=>{document.removeEventListener("mouseover",L,!0),document.removeEventListener("mouseout",h,!0),document.removeEventListener("click",d,!0)}},[t,L,h,d]);const[x,A]=s.useState(0),F=s.useCallback(()=>{if(A(m=>m+1),b.current){const m=b.current.getBoundingClientRect();V(S=>S?{...S,position:{x:m.left+m.width/2,y:m.bottom}}:null)}},[]);s.useEffect(()=>{if(!(typeof window>"u"))return window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[F]),s.useEffect(()=>{if(!E||!b.current)return;const m=b.current,j=Be(m).map(I=>(I.addEventListener("scroll",F,!0),()=>I.removeEventListener("scroll",F,!0)));return()=>j.forEach(I=>I())},[E,F]);const le=s.useMemo(()=>it(l),[l,x]),ue=s.useCallback(()=>{O(),V(null)},[O]),ce={position:"fixed",inset:0,zIndex:999999,pointerEvents:"none",cursor:t?"crosshair":void 0},ee=f.jsxs(f.Fragment,{children:[f.jsx("div",{style:ce,"aria-hidden":!0,"data-review-layer-root":!0}),t&&f.jsxs("div",{"data-review-layer-root":!0,style:{position:"fixed",top:"var(--ui-positive-Value_250, 10px)",left:"var(--ui-positive-Value_250, 10px)",zIndex:1e6,display:"flex",alignItems:"center",gap:"var(--ui-positive-Value_250, 10px)",padding:"var(--ui-positive-Value_150, 6px) var(--ui-positive-Value_300, 12px)",backgroundColor:"var(--ui-color-bg-fill-danger-default, #ff4d4f)",color:"var(--ui-color-text-on-color, #fff)",borderRadius:"var(--ui-radius_6, 6px)",fontSize:"var(--ui-font-size-xs, 12px)",fontWeight:"var(--ui-font-weight-medium, 500)",pointerEvents:"auto"},children:[f.jsx("span",{children:"Modo revisión (Shift+R para salir)"}),f.jsx("button",{type:"button",onClick:()=>n(!1),"aria-label":"Salir del modo revisión",style:{padding:0,margin:0,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:"var(--ui-radius_6, 6px)",backgroundColor:"rgba(255,255,255,0.2)",color:"inherit",fontSize:14,lineHeight:1,cursor:"pointer"},children:"×"})]}),p&&f.jsxs("div",{style:{position:"fixed",bottom:"var(--ui-positive-Value_400, 16px)",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"var(--ui-positive-Value_250, 10px)",padding:"var(--ui-positive-Value_200, 8px) var(--ui-positive-Value_350, 14px)",backgroundColor:"var(--ui-color-bg-surface-default, #fff)",border:"1px solid var(--ui-color-border-subtle, #e8e8e8)",borderRadius:"var(--ui-radius_8, 8px)",boxShadow:"0 2px 12px var(--ui-color-black-alpha-10, rgba(0,0,0,0.1))",fontSize:"var(--ui-font-size-xs, 12px)",color:"var(--ui-color-text-primary, #333)",zIndex:999997,pointerEvents:"auto"},children:[f.jsx("span",{children:"No se pudo conectar. Mostrando últimos datos guardados. Reintentar no garantiza respuesta hasta que el servicio esté activo."}),f.jsx("button",{type:"button",onClick:()=>c(),style:{padding:"var(--ui-positive-Value_100, 4px) var(--ui-positive-Value_250, 10px)",fontSize:"var(--ui-font-size-xs, 12px)",fontWeight:"var(--ui-font-weight-semibold, 600)",backgroundColor:"var(--ui-color-bg-fill-success-default, rgb(33, 196, 94))",color:"var(--ui-color-text-on-color, #fff)",border:"none",borderRadius:"var(--ui-radius_6, 6px)",cursor:"pointer"},children:"Reintentar"})]}),l.map(m=>f.jsx("div",{"data-review-layer-pin":!0,style:{pointerEvents:"auto"},children:f.jsx(tt,{comment:m,offset:le.get(m.id),apiUrl:r,apiKey:o,onStatusChange:c,reviewMode:t})},m.id)),E&&f.jsx("div",{"data-review-layer-modal":!0,style:{pointerEvents:"auto"},children:f.jsx(Or,{apiUrl:r,apiKey:o,reviewers:i,position:E.position,payload:E.payload,onClose:ue,onSuccess:c})})]}),re=typeof document<"u"?document.body:null;return re?Ne.createPortal(ee,re):null}const lt=`/**
|
|
43
43
|
* Tokens de diseño UI para review-layer-react.
|
|
44
44
|
* Las variables se inyectan en :root al montar ReviewProvider.
|
|
45
45
|
* Puedes sobrescribirlas en tu app para adaptar el tema.
|
|
@@ -364,5 +364,5 @@ React keys must be passed directly to JSX without using spread:
|
|
|
364
364
|
--ui-shadow-popover: 0 var(--ui-shadow-02-y) var(--ui-shadow-02-blur) var(--ui-shadow-02-Color);
|
|
365
365
|
--ui-shadow-modal: 0 var(--ui-shadow-04-y) var(--ui-shadow-04-blur) var(--ui-shadow-04-Color);
|
|
366
366
|
}
|
|
367
|
-
`;function
|
|
367
|
+
`;function ut(r,o,t){const n=s.useCallback(()=>{r&&t(i=>!i)},[r,t]);s.useEffect(()=>{if(!r)return;const i=l=>{(l.key==="r"||l.key==="R"||l.code==="KeyR")&&l.shiftKey&&!l.ctrlKey&&!l.metaKey&&(l.preventDefault(),n())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[r,n])}const ct="review_layer:v1:";function dt(r,o){if(r==null)return o;try{return JSON.parse(r)??o}catch{return o}}function ye(r,o,t,n){const i=`${ct}${ft(r)}:${t}`;return n!=null?`${i}:${n}`:i}function ft(r){return r.replace(/\/+$/,"")||"/"}function Qe(r){if(typeof localStorage>"u")return null;const o=localStorage.getItem(r);return dt(o,null)}function Ke(r,o){if(!(typeof localStorage>"u"))try{localStorage.setItem(r,JSON.stringify({data:o,at:Date.now()}))}catch{}}function Te(r,o,t){const n=Qe(ye(r,o,"comments",t));return(n==null?void 0:n.data)??null}function vt(r,o,t,n){Ke(ye(r,o,"comments",t),n)}function qe(r,o){const t=Qe(ye(r,o,"reviewers"));return(t==null?void 0:t.data)??null}function pt(r,o,t){Ke(ye(r,o,"reviewers"),t)}const $e="https://review-layer-api.onrender.com/api",er=s.createContext(null);let je=null;function gt(){const r=s.useContext(er);if(!r)throw new Error("useReview must be used within ReviewProvider");return r}const N="[review-layer]";function ht({children:r,enabled:o=!0,apiUrl:t,apiKey:n}){const i=(t==null?void 0:t.trim())||$e,[l,c]=s.useState(!1),[p,v]=s.useState([]),[w,b]=s.useState([]),[E,V]=s.useState(!1);ut(o,l,c);const P=s.useCallback(async h=>{if(!o||!i||!n){console.warn(N,"loadReviewers omitido: faltan enabled, apiUrl o apiKey",{enabled:o,apiUrl:i,hasApiKey:!!n});return}console.log(N,"Cargando revisores...",{apiUrl:i});try{const d=await _r(i,n,{signal:h});h!=null&&h.aborted||(v(d),pt(i,n,d),console.log(N,"Revisores cargados:",d.length))}catch(d){if(d instanceof Error&&d.name==="AbortError")return;if(!(h!=null&&h.aborted)){console.error(N,"Error al cargar revisores:",d);const x=qe(i,n);x!=null&&(v(x),console.log(N,"Usando revisores en caché:",x.length))}}},[o,i,n]),O=s.useCallback(async h=>{if(!o||!i||!n){console.warn(N,"loadComments omitido: faltan enabled, apiUrl o apiKey",{enabled:o,apiUrl:i,hasApiKey:!!n});return}const d=ke(),x=Te(i,n,d);x!=null&&b(x),console.log(N,"Cargando comentarios...",{apiUrl:i,url:d});try{V(!1);const A=await Sr(i,n,d,{signal:h});h!=null&&h.aborted||(b(A),vt(i,n,d,A),console.log(N,"Comentarios cargados:",A.length))}catch(A){if(A instanceof Error&&A.name==="AbortError")return;if(!(h!=null&&h.aborted)){V(!0),console.error(N,"Error al cargar comentarios:",A);const F=Te(i,n,d);F!=null?(b(F),console.log(N,"Usando comentarios en caché:",F.length)):console.warn(N,"Sin caché de comentarios; la lista quedará vacía hasta que la API responda.")}}},[o,i,n]);s.useEffect(()=>{if(!o||!i||!n){console.warn(N,"Provider activo pero sin carga: enabled, apiUrl y apiKey son requeridos.",{enabled:o,apiUrl:i,hasApiKey:!!n});return}const h=ke(),d=qe(i,n),x=Te(i,n,h);d!=null&&(v(d),console.log(N,"Revisores desde caché (inicial):",d.length)),x!=null&&(b(x),console.log(N,"Comentarios desde caché (inicial):",x.length,{url:h}))},[o,i,n]),s.useEffect(()=>{if(typeof document>"u")return;const h="review-layer-ui-variables";if(!document.getElementById(h)){const d=document.createElement("style");d.id=h,d.textContent=lt,document.head.appendChild(d)}},[]),s.useEffect(()=>{if(!o||!i||!n)return;const h=`${i}:${n}`;if(je!==h)return je=h,console.log(N,"Inicio de carga (revisores + comentarios)",{apiUrl:i,apiKey:n?"***":"(vacío)"}),P(),O(),()=>{setTimeout(()=>{je=null},0)}},[o,i,n,P,O]),s.useEffect(()=>{if(!o)return;const h=()=>O();return window.addEventListener("popstate",h),()=>window.removeEventListener("popstate",h)},[o,O]);const M=s.useMemo(()=>({apiUrl:i,apiKey:n,reviewMode:l,setReviewMode:c,reviewers:p,comments:w,loadComments:O,commentsLoadFailed:E}),[i,n,l,c,p,w,O,E]),L=o&&typeof document<"u"?Ne.createPortal(f.jsx(st,{apiUrl:i,apiKey:n,reviewMode:l,setReviewMode:c,reviewers:p,comments:w,loadComments:O,commentsLoadFailed:E}),document.body):null;return f.jsxs(er.Provider,{value:M,children:[r,L]})}G.DEFAULT_API_URL=$e,G.ReviewProvider=ht,G.useReview=gt,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|
|
368
368
|
//# sourceMappingURL=review-layer-react.umd.cjs.map
|