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