@semapps/activitypub-components 0.4.7 → 0.5.0-alpha.1
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/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +2 -2
- package/dist/index.es.js.map +1 -1
- package/package.json +8 -8
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e,{
|
|
1
|
+
import*as e from"react";import t,{createContext as n,useState as r,useContext as o,useEffect as i,useMemo as a,useCallback as l,forwardRef as c,useImperativeHandle as u}from"react";import{useGetIdentity as s,fetchUtils as d,useRecordContext as f,useNotify as p,Form as m,TextField as h,DateField as v,RichTextField as g,useGetOne as b,LinearProgress as y,useGetList as E}from"react-admin";import w from"@tiptap/extension-placeholder";import{ToggleButtonGroup as x,ToggleButton as O,List as T,ListItem as k,ListItemText as L,Menu as A,MenuItem as C,Box as I,useTheme as S,Card as j,FormHelperText as R,Avatar as P,Button as N,Typography as z,CircularProgress as _}from"@mui/material";import D from"@mui/styles/makeStyles";import F from"@mui/icons-material/Send";import{buildBlankNodesQuery as U,useDataModel as B}from"@semapps/semantic-data-provider";import{AuthDialog as H}from"@semapps/auth-provider";import{mergeAttributes as M}from"@tiptap/core";import G from"@tiptap/extension-mention";import{useEditor as V,EditorContent as W,ReactRenderer as q}from"@tiptap/react";import J from"@tiptap/starter-kit";import K from"@tiptap/extension-underline";import Q from"@tiptap/extension-link";import X from"@tiptap/extension-text-align";import Y from"@tiptap/extension-image";import Z from"@tiptap/extension-text-style";import{Color as $}from"@tiptap/extension-color";import ee from"@tiptap/extension-highlight";import{styled as te,alpha as ne}from"@mui/material/styles";import{useTranslate as re,useResourceContext as oe,useInput as ie}from"ra-core";import{Labeled as ae,InputHelperText as le}from"ra-ui-materialui";import ce from"@mui/icons-material/ArrowDropDown";import ue from"@mui/icons-material/FormatBold";import se from"@mui/icons-material/FormatItalic";import de from"@mui/icons-material/FormatUnderlined";import fe from"@mui/icons-material/FormatStrikethrough";import pe from"@mui/icons-material/Code";import me from"@mui/icons-material/FormatColorText";import he from"@mui/icons-material/FontDownload";import{grey as ve,red as ge,orange as be,yellow as ye,green as Ee,blue as we,purple as xe}from"@mui/material/colors";import Oe from"@mui/icons-material/FormatAlignCenter";import Te from"@mui/icons-material/FormatAlignLeft";import ke from"@mui/icons-material/FormatAlignRight";import Le from"@mui/icons-material/FormatAlignJustify";import Ae from"@mui/icons-material/FormatListBulleted";import Ce from"@mui/icons-material/FormatListNumbered";import Ie from"@mui/icons-material/InsertLink";import Se from"@mui/icons-material/Image";import je from"@mui/icons-material/FormatQuote";import Re from"@mui/icons-material/FormatClear";import{ReferenceField as Pe,AvatarWithLabelField as Ne,ReferenceArrayField as ze}from"@semapps/field-components";import _e from"tippy.js";function De(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Fe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?De(Object(n),!0).forEach((function(t){Me(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):De(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ue(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3
|
-
B=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=t&&t.prototype instanceof d?t:d,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return I()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=w(a,r);if(c){if(c===s)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var l=u(e,t,r);if("normal"===l.type){if(n=r.done?"completed":"suspendedYield",l.arg===s)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n="completed",r.method="throw",r.arg=l.arg)}}}(e,r,a),i}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var s={};function d(){}function f(){}function p(){}var m={};c(m,o,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(T([])));v&&v!==t&&r.call(v,o)&&(m=v);var y=p.prototype=d.prototype=Object.create(m);function g(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(o,i){function a(){return new t((function(n,a){!function n(o,i,a,c){var l=u(e[o],e,i);if("throw"!==l.type){var s=l.arg,d=s.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(d).then((function(e){s.value=e,a(s)}),(function(e){return n("throw",e,a,c)}))}c(l.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return s;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,s;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,s):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,s)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function T(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return f.prototype=p,c(y,"constructor",p),c(p,"constructor",f),f.displayName=c(p,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,c(e,a,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(b.prototype),c(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new b(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),c(y,a,"Generator"),c(y,o,(function(){return this})),c(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=T,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),l=r.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,s):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),s},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),s}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},e}function _(e,t,r,n,o,i,a){try{var c=e[i](a),l=c.value}catch(e){return void r(e)}c.done?t(l):Promise.resolve(l).then(n,o)}function G(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){_(i,n,o,a,c,"next",e)}function c(e){_(i,n,o,a,c,"throw",e)}a(void 0)}))}}function V(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function z(){return(z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function J(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function W(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}(e,t)||q(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function K(e){return function(e){if(Array.isArray(e))return Q(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||q(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(e,t){if(e){if("string"==typeof e)return Q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Q(e,t):void 0}}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var X={ACCEPT:"Accept",ADD:"Add",ANNOUNCE:"Announce",ARRIVE:"Arrive",BLOCK:"Block",CREATE:"Create",DELETE:"Delete",DISLIKE:"Dislike",FLAG:"Flag",FOLLOW:"Follow",IGNORE:"Ignore",INVITE:"Invite",JOIN:"Join",LEAVE:"Leave",LIKE:"Like",LISTEN:"Listen",MOVE:"Move",OFFER:"Offer",QUESTION:"Question",REJECT:"Reject",READ:"Read",REMOVE:"Remove",TENTATIVE_REJECT:"TentativeReject",TENTATIVE_ACCEPT:"TentativeAccept",TRAVAL:"Travel",UNDO:"Undo",UPDATE:"Update",VIEW:"View"},Y={APPLICATION:"Application",GROUP:"Group",ORGANIZATION:"Organization",PERSON:"Person",SERVICE:"Service"},Z={ARTICLE:"Article",AUDIO:"Audio",DOCUMENT:"Document",EVENT:"Event",IMAGE:"Image",NOTE:"Note",PAGE:"Page",PLACE:"Place",PROFILE:"Profile",RELATIONSHIP:"Relationship",TOMBSTONE:"Tombstone",VIDEO:"Video"},$="https://www.w3.org/ns/activitystreams#Public",ee=function(){var e=c().identity,n=t((function(){var t;if(null!=e&&e.webIdData)return null==e||null===(t=e.webIdData)||void 0===t?void 0:t.outbox}),[e]),o=t((function(){var t,r;if(null!=e&&e.webIdData)return(null==e||null===(t=e.webIdData)||void 0===t||null===(r=t.endpoints)||void 0===r?void 0:r["void:sparqlEndpoint"])||(null==e?void 0:e.id)+"/sparql"}),[e]);return{post:r(function(){var e=G(B().mark((function e(t){var r,o,i;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=localStorage.getItem("token"),e.next=3,l.fetchJson(n,{method:"POST",body:JSON.stringify(U({"@context":"https://www.w3.org/ns/activitystreams"},t)),headers:new Headers({"Content-Type":"application/ld+json",Authorization:"Bearer ".concat(r)})});case 3:return o=e.sent,i=o.headers,e.abrupt("return",i.get("Location"));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[n]),fetch:r(G(B().mark((function e(){var t,r,i,a,c;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o&&n){e.next=2;break}return e.abrupt("return");case 2:return t=localStorage.getItem("token"),r=k(["as:object"]),i="\n PREFIX as: <https://www.w3.org/ns/activitystreams#>\n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ".concat(r.construct,"\n }\n WHERE {\n <").concat(n,"> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n ").concat(r.where,"\n }\n "),e.next=7,l.fetchJson(o,{method:"POST",body:i,headers:new Headers({Accept:"application/ld+json",Authorization:t?"Bearer ".concat(t):void 0})});case 7:if(a=e.sent,!(c=a.json)["@graph"]){e.next=13;break}return e.abrupt("return",c["@graph"]);case 13:return e.abrupt("return",null);case 14:case"end":return e.stop()}}),e)}))),[o,n]),url:n,owner:null==e?void 0:e.id}},te=C.extend({renderHTML:function(e){var t=e.node,r=e.HTMLAttributes;return["span",N(this.options.HTMLAttributes,r),"@".concat(t.attrs.id.label)]},addAttributes:function(){return{label:{default:null,parseHTML:function(e){return{label:e.getAttribute("data-mention-label")}},renderHTML:function(e){return e.id.label?{"data-mention-label":e.id.label}:{}}},id:{default:null,parseHTML:function(e){return{id:e.getAttribute("data-mention-id")}},renderHTML:function(e){return e.id.id?{"data-mention-id":e.id.id}:{}}}}}}),re=E((function(e){return{form:{marginTop:-12},container:{paddingLeft:80,position:"relative"},avatar:{position:"absolute",top:16,left:0,bottom:0,width:64,height:64},editorContent:{"& > div":{backgroundColor:"rgba(0, 0, 0, 0.09)",padding:"2px 12px",borderWidth:"0px !important",borderRadius:0,borderBottom:"1px solid #FFF",minHeight:60,outline:"unset !important"},"& > div > p":{marginTop:12,marginBottom:12,fontFamily:e.typography.body1.fontFamily,marginBlockStart:"0.5em",marginBlockEnd:"0.5em"},"& > div > p.is-editor-empty:first-child::before":{color:"grey",content:"attr(data-placeholder)",float:"left",height:0,pointerEvents:"none"},marginBottom:-19},button:{marginBottom:15}}})),ne=function(t){var o=t.context,i=t.placeholder,a=t.helperText,l=t.mentions,d=t.userResource,f=t.addItem,p=t.removeItem,m=u(),h=c().identity,v=R(d),E=re(),I=s(),L=ee(),k=W(n(!1),2),N=k[0],C=k[1],S=W(n(!1),2),P=S[0],D=S[1],F=r(function(){var e=G(B().mark((function e(t,r){var n,i,a,c,l,u;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.reset,i=(new DOMParser).parseFromString(t.comment,"text/html"),a=Array.from(i.body.getElementsByClassName("mention")),c=[],a.forEach((function(e){var t=e.attributes["data-mention-id"].value,r=e.attributes["data-mention-label"].value,n=i.createElement("a");n.setAttribute("href",new URL(window.location.href).origin+"/"+d+"/"+encodeURIComponent(t)+"/show"),n.textContent="@"+r,e.parentNode.replaceChild(n,e),c.push(t)})),"undefined"!==i.body.innerHTML){e.next=9;break}I("Votre commentaire est vide","error"),e.next=24;break;case 9:return l=Date.now(),u={type:Z.NOTE,attributedTo:L.owner,content:i.body.innerHTML,inReplyTo:m[o],published:(new Date).toISOString()},e.prev=11,f(U({id:l},u)),n(),C(!1),e.next=17,L.post(U(U({},u),{},{to:[].concat(c,[$])}));case 17:I("Commentaire posté avec succès","success"),e.next=24;break;case 20:e.prev=20,e.t0=e.catch(11),p(l),I(e.t0.message,"error");case 24:case"end":return e.stop()}}),e,null,[[11,20]])})));return function(t,r){return e.apply(this,arguments)}}(),[L,I,C,f,p]),M=r((function(){h.id||D(!0)}),[h,D]);return l&&!l.items||!h?null:e.createElement(e.Fragment,null,e.createElement(w,{onSubmit:F,subscription:{submitting:!0,pristine:!0},render:function(t){var r,n,o,c,u=t.handleSubmit,s=t.submitting;if(t.pristine){var d=document.getElementById("comment");d&&""!==d.textContent&&(d.innerHTML="")}return e.createElement("form",{onSubmit:u,className:E.form},e.createElement(x,{className:E.container,onClick:M},e.createElement(O,{src:(null==h||null===(r=h.webIdData)||void 0===r?void 0:r[null==v||null===(n=v.fieldsMapping)||void 0===n?void 0:n.image])||(null==h||null===(o=h.profileData)||void 0===o?void 0:o[null==v||null===(c=v.fieldsMapping)||void 0===c?void 0:c.image]),className:E.avatar}),e.createElement(y,{source:"comment",label:"",toolbar:null,fullWidth:!0,classes:{editorContent:E.editorContent},editorOptions:U(U({},g),{},{onFocus:function(){C(!0)},extensions:[].concat(K(g.extensions),[i?b.configure({placeholder:i}):null,l?te.configure({HTMLAttributes:{class:"mention"},suggestion:l}):null]),editable:!!h.id}),helperText:a}),N&&e.createElement(T,{type:"submit",size:"small",variant:"contained",color:"primary",endIcon:e.createElement(A,null),disabled:s,className:E.button},"Envoyer")))}}),e.createElement(j,{open:P,onClose:function(){return D(!1)},message:"Pour poster un commentaire, vous devez être connecté."}))},oe=E((function(){return{container:{paddingLeft:80,marginTop:8,minHeight:80,position:"relative"},avatar:{position:"absolute",top:0,left:0,bottom:0,width:64,height:64},text:{paddingTop:2,paddingBottom:8},label:{fontWeight:"bold"},content:{"& p":{marginBlockStart:"0.5em",marginBlockEnd:"0.5em"}},loading:{zIndex:1e3,backgroundColor:"white",opacity:.5,position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",minHeight:200,marginTop:5}}})),ie=function(t){var r=t.comments,n=t.userResource,o=t.loading,i=oe(),a=R(n);return e.createElement(x,{position:"relative"},r&&r.sort((function(e,t){return new Date(t.published)-new Date(e.published)})).map((function(t){var r,o;return e.createElement(x,{className:i.container},e.createElement(x,{className:i.avatar},e.createElement(S,{record:t,reference:n,source:"attributedTo",linkType:"show"},e.createElement(P,{image:null==a||null===(r=a.fieldsMapping)||void 0===r?void 0:r.image}))),e.createElement(x,{className:i.text},e.createElement(I,{variant:"body2"},e.createElement(S,{record:t,reference:n,source:"attributedTo",linkType:"show"},e.createElement(d,{variant:"body2",source:null==a||null===(o=a.fieldsMapping)||void 0===o?void 0:o.title,className:i.label}))," • ",e.createElement(f,{record:t,variant:"body2",source:"published",showTime:!0})),e.createElement(p,{record:t,variant:"body1",source:"content",className:i.content})))})),o&&e.createElement(x,{minHeight:200},e.createElement(x,{alignItems:"center",className:i.loading},e.createElement(L,{size:60,thickness:6}))))},ae=function(e){var i=c(),a=i.identity,u=i.loaded,s=W(n([]),2),d=s[0],f=s[1],p=W(n(!1),2),m=p[0],h=p[1],v=W(n(!1),2),y=v[0],g=v[1],b=W(n(!1),2),w=b[0],E=b[1],x=t((function(){if(e){if(e.startsWith("http"))return e;var t;if(null!=a&&a.webIdData)return null==a||null===(t=a.webIdData)||void 0===t?void 0:t[e]}}),[a,e]),O=r(G(B().mark((function e(){var t,r,n,o;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(x){e.next=2;break}return e.abrupt("return");case 2:h(!0),t=new Headers({Accept:"application/ld+json"}),r=a&&new URL(a.id).origin,n=new URL(x).origin,o=localStorage.getItem("token"),r===n&&o&&t.set("Authorization","Bearer ".concat(o)),l.fetchJson(x,{headers:t}).then((function(e){var t=e.json;t&&t.items?f(t.items):t&&t.orderedItems?f(t.orderedItems):f([]),E(!1),g(!0),h(!1)})).catch((function(){E(!0),g(!0),h(!1)}));case 9:case"end":return e.stop()}}),e)}))),[f,g,h,E,x,a]);o((function(){!u||m||y||w||O()}),[O,u,m,y,w]);var T=r((function(e){f((function(t){return[].concat(K(t),[e])}))}),[f]),I=r((function(e){f((function(t){return t.filter((function(t){return"string"==typeof t?t!==e:t.id!==e}))}))}),[f]);return{items:d,loading:m,loaded:y,error:w,refetch:O,addItem:T,removeItem:I,url:x}},ce=function(t){t.source;var r=t.context,n=t.helperText,o=t.placeholder,i=t.userResource,a=t.mentions,c=u(),l=ae(c.replies),s=l.items,d=l.loading,f=l.addItem,p=l.removeItem;if(!i)throw new Error("No userResource defined for CommentsField");return e.createElement(e.Fragment,null,e.createElement(ne,{context:r,helperText:n,userResource:i,placeholder:o,mentions:a,addItem:f,removeItem:p}),e.createElement(ie,{comments:s,loading:d,userResource:i}))};ce.defaultProps={addLabel:!0,label:"Commentaires",placeholder:"Commencez à taper votre commentaire...",source:"id",context:"id"};var le=["collectionUrl","resource","children"],ue=function(t){var r=t.collectionUrl,n=t.resource,o=t.children,i=J(t,le);if(1!==e.Children.count(o))throw new Error("<CollectionList> only accepts a single child");var a=m(n,r,{enabled:!!r}),c=a.data;return a.loading?e.createElement("div",{style:{marginTop:8}},e.createElement(h,null)):c?e.createElement(D,z({reference:n,record:c,source:"items"},i),o):null},se=["source","record","reference","children"],de=function(t){var r=t.source,n=t.record,o=t.reference,i=t.children,a=J(t,se);if(1!==e.Children.count(i))throw new Error("<ReferenceCollectionField> only accepts a single child");return n&&n[r]?e.createElement(ue,z({resource:o,collectionUrl:n[r]},a),i):null};de.defaultProps={addLabel:!0};var fe=function(){var e=c().identity,n=t((function(){var t;if(null!=e&&e.webIdData)return null==e||null===(t=e.webIdData)||void 0===t?void 0:t.inbox}),[e]),o=t((function(){var t,r;if(null!=e&&e.webIdData)return(null==e||null===(t=e.webIdData)||void 0===t||null===(r=t.endpoints)||void 0===r?void 0:r["void:sparqlEndpoint"])||(null==e?void 0:e.id)+"/sparql"}),[e]);return{fetch:r(function(){var e=G(B().mark((function e(t){var r,i,a,c,u,s,d;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.filters,console.log("inboxUrl",n,o),o&&n){e.next=4;break}return e.abrupt("return");case 4:return i=localStorage.getItem("token"),a=k(["as:object"]),c="",r&&Object.keys(r).forEach((function(e){if(r[e]){var t=r[e].startsWith("http")?"<".concat(r[e],">"):r[e];c+="?s1 ".concat(e," ").concat(t," .")}})),u="\n PREFIX as: <https://www.w3.org/ns/activitystreams#>\n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ".concat(a.construct,"\n }\n WHERE {\n <").concat(n,"> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n FILTER( (isIRI(?s1)) ) .\n ").concat(c,"\n ").concat(a.where,"\n }\n "),e.next=11,l.fetchJson(o,{method:"POST",body:u,headers:new Headers({Accept:"application/ld+json",Authorization:i?"Bearer ".concat(i):void 0})});case 11:if(s=e.sent,!(d=s.json)["@graph"]){e.next=17;break}return e.abrupt("return",d["@graph"]);case 17:return e.abrupt("return",null);case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[o,n]),url:n,owner:null==e?void 0:e.id}},pe=function(){return{fetch:r(function(){var e=G(B().mark((function e(t){var r,n,o,i,a,c,u,s,d;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.split("@"),(n=W(r,3))[0],o=n[1],!(i=n[2])){e.next=18;break}return a=i.includes(":")?"http":"https",c="".concat(a,"://").concat(i,"/.well-known/webfinger?resource=acct:").concat(o,"@").concat(i),e.prev=4,e.next=7,l.fetchJson(c);case 7:return u=e.sent,s=u.json,d=s.links.find((function(e){return"application/activity+json"===e.type})),e.abrupt("return",d?d.href:null);case 13:return e.prev=13,e.t0=e.catch(4),e.abrupt("return",null);case 16:e.next=19;break;case 18:return e.abrupt("return",null);case 19:case"end":return e.stop()}}),e,null,[[4,13]])})));return function(t){return e.apply(this,arguments)}}(),[])}},me=E((function(e){return{items:{background:"#fff",borderRadius:"0.5rem",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)",color:"rgba(0, 0, 0, 0.8)",fontSize:"0.9rem",overflow:"hidden",padding:"0.2rem",position:"relative"},item:{background:"transparent",border:"1px solid transparent",borderRadius:"0.4rem",display:"block",margin:0,padding:"0.2rem 0.4rem",textAlign:"left",width:"100%","&.selected":{borderColor:"#000"}}}})),he=i((function(t,r){var i=W(n(0),2),c=i[0],l=i[1],u=me(),s=function(e){var r=t.items[e];r&&t.command({id:r})};return o((function(){return l(0)}),[t.items]),a(r,(function(){return{onKeyDown:function(e){var r=e.event;return"ArrowUp"===r.key?(l((c+t.items.length-1)%t.items.length),!0):"ArrowDown"===r.key?(l((c+1)%t.items.length),!0):"Enter"===r.key&&(s(c),!0)}}})),e.createElement("div",{className:u.items},t.items.length?t.items.map((function(t,r){return e.createElement("button",{className:u.item+(r===c?" selected":""),key:r,onClick:function(){return s(r)}},t.label)})):e.createElement("div",{className:u.item},"Aucun résultat"))})),ve=function(){var e,t;return{onStart:function(r){e=new F(he,{props:r,editor:r.editor}),t=M("body",{getReferenceClientRect:r.clientRect,appendTo:function(){return document.body},content:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:function(r){e.updateProps(r),t[0].setProps({getReferenceClientRect:r.clientRect})},onKeyDown:function(r){var n;return"Escape"===r.event.key?(t[0].hide(),!0):null===(n=e.ref)||void 0===n?void 0:n.onKeyDown(r)},onExit:function(){t[0].destroy(),e.destroy()}}},ye=function(e){var r,n,o=R(e),i=v({type:"getList",resource:e,payload:{filter:{_predicates:[null==o||null===(r=o.fieldsMapping)||void 0===r?void 0:r.title],blankNodes:[]}}},{enabled:!(null==o||null===(n=o.fieldsMapping)||void 0===n||!n.title)}).data,a=t((function(){if(i)return i.map((function(e){var t;return{id:e.id,label:e[null==o||null===(t=o.fieldsMapping)||void 0===t?void 0:t.title]}}))}),[i]);return{items:t((function(){if(a)return function(e){var t=e.query;return a.filter((function(e){return e.label.toLowerCase().startsWith(t.toLowerCase())})).slice(0,5)}}),[a]),render:ve}};export{X as ACTIVITY_TYPES,Y as ACTOR_TYPES,ue as CollectionList,ce as CommentsField,Z as OBJECT_TYPES,$ as PUBLIC_URI,de as ReferenceCollectionField,ae as useCollection,fe as useInbox,ye as useMentions,ee as useOutbox,pe as useWebfinger};
|
|
3
|
+
Ue=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var o=t&&t.prototype instanceof d?t:d,i=Object.create(o.prototype),a=new O(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return k()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var l=E(a,n);if(l){if(l===s)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=u(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===s)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(e,n,a),i}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var s={};function d(){}function f(){}function p(){}var m={};l(m,o,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(T([])));v&&v!==t&&n.call(v,o)&&(m=v);var g=p.prototype=d.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){var r;this._invoke=function(o,i){function a(){return new t((function(r,a){!function r(o,i,a,l){var c=u(e[o],e,i);if("throw"!==c.type){var s=c.arg,d=s.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,l)}),(function(e){r("throw",e,a,l)})):t.resolve(d).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,l)}))}l(c.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}}function E(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method))return s;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,s;var o=r.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,s):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,s)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function T(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return f.prototype=p,l(g,"constructor",p),l(p,"constructor",f),f.displayName=l(p,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,a,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(y.prototype),l(y.prototype,i,(function(){return this})),e.AsyncIterator=y,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new y(c(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(g),l(g,a,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=T,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var l=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(l&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(l){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,s):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),s},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),s}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;x(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),s}},e}function Be(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,o)}function He(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Be(i,r,o,a,l,"next",e)}function l(e){Be(i,r,o,a,l,"throw",e)}a(void 0)}))}}function Me(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ge(){return(Ge=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function Ve(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function We(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw o}}return i}(e,t)||Je(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qe(e){return function(e){if(Array.isArray(e))return Ke(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Je(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Je(e,t){if(e){if("string"==typeof e)return Ke(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ke(e,t):void 0}}function Ke(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Qe(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=Qe(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function Xe(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=Qe(e))&&(r&&(r+=" "),r+=t);return r}var Ye,Ze=n(void 0),$e=function(t){var n=t.children,r=t.value;return e.createElement(Ze.Provider,{value:r},n)},et=function(){var e=r(!1),t=e[0],n=e[1],a=o(Ze);return i((function(){var e=function(){n(!0)};return null!=a&&(n(a.isEditable),a.on("create",e)),function(){null!=a&&a.off("create",e)}}),[a]),t?a:null},tt=function(){return(tt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},nt=function(t){var n=et(),o=re(),a=r([]),l=a[0],c=a[1],u=o("ra.tiptap.bold",{_:"Bold"}),s=o("ra.tiptap.italic",{_:"Italic"}),d=o("ra.tiptap.underline",{_:"Underline"}),f=o("ra.tiptap.strike",{_:"Strikethrough"}),p=o("ra.tiptap.code",{_:"Code"});i((function(){var e=function(){c((function(){return rt.reduce((function(e,t){return n&&n.isActive(t)&&e.push(t),e}),[])}))};return n&&(n.on("update",e),n.on("selectionUpdate",e)),function(){n&&(n.off("update",e),n.off("selectionUpdate",e))}}),[n]);return e.createElement(x,tt({},t,{disabled:!(null==n?void 0:n.isEditable),onChange:function(e,t){rt.forEach((function(e){var r=n&&n.isActive(e)&&!t.includes(e),o=n&&!n.isActive(e)&&t.includes(e);(r||o)&&ot[e](n)}))},value:l}),e.createElement(O,{value:"bold","aria-label":u,title:u},e.createElement(ue,{fontSize:"inherit"})),e.createElement(O,{value:"italic","aria-label":s,title:s},e.createElement(se,{fontSize:"inherit"})),e.createElement(O,{value:"underline","aria-label":d,title:d},e.createElement(de,{fontSize:"inherit"})),e.createElement(O,{value:"strike","aria-label":f,title:f},e.createElement(fe,{fontSize:"inherit"})),e.createElement(O,{value:"code","aria-label":p,title:p},e.createElement(pe,{fontSize:"inherit"})))},rt=["bold","italic","underline","strike","code"],ot={bold:function(e){return e.chain().focus().toggleBold().run()},italic:function(e){return e.chain().focus().toggleItalic().run()},underline:function(e){return e.chain().focus().toggleUnderline().run()},strike:function(e){return e.chain().focus().toggleStrike().run()},code:function(e){return e.chain().focus().toggleCode().run()}},it=function(){return(it=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},at=function(t){var n=et(),o=re(),a=o("ra.tiptap.list_bulleted",{_:"Bulleted list"}),l=o("ra.tiptap.list_numbered",{_:"Numbered list"}),c=r(),u=c[0],s=c[1];return i((function(){var e=function(){s((function(){return lt.reduce((function(e,t){return n&&n.isActive(t)?t:e}),void 0)}))};return n&&(n.on("update",e),n.on("selectionUpdate",e)),function(){n&&(n.off("update",e),n.off("selectionUpdate",e))}}),[n]),e.createElement(x,it({},t,{disabled:!(null==n?void 0:n.isEditable),exclusive:!0,onChange:function(e,t){lt.forEach((function(e){var r=n&&n.isActive(e)&&t!==e,o=n&&!n.isActive(e)&&t===e;(r||o)&&ct[e](n)}))},value:u}),e.createElement(O,{value:"bulletList","aria-label":a,title:a},e.createElement(Ae,{fontSize:"inherit"})),e.createElement(O,{value:"orderedList","aria-label":l,title:l},e.createElement(Ce,{fontSize:"inherit"})))},lt=["bulletList","orderedList"],ct={bulletList:function(e){return e.chain().focus().toggleBulletList().run()},orderedList:function(e){return e.chain().focus().toggleOrderedList().run()}},ut=function(){return(ut=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},st=function(t){var n=et(),o=re(),a=r("left"),l=a[0],c=a[1],u=o("ra.tiptap.align_left",{_:"Align left"}),s=o("ra.tiptap.align_right",{_:"Align right"}),d=o("ra.tiptap.align_center",{_:"Center"}),f=o("ra.tiptap.align_justify",{_:"Justify"});i((function(){var e=function(){c((function(e){return dt.reduce((function(e,t){return n&&n.isActive({textAlign:t})?t:e}),e)}))};return n&&(n.on("update",e),n.on("selectionUpdate",e)),function(){n&&(n.off("update",e),n.off("selectionUpdate",e))}}),[n]);return e.createElement(x,ut({},t,{disabled:!(null==n?void 0:n.isEditable),exclusive:!0,onChange:function(e,t){ft[t]&&ft[t](n)},value:l}),e.createElement(O,{value:"left","aria-label":u,title:u},e.createElement(Te,{fontSize:"inherit"})),e.createElement(O,{value:"center","aria-label":d,title:d},e.createElement(Oe,{fontSize:"inherit"})),e.createElement(O,{value:"right","aria-label":s,title:s},e.createElement(ke,{fontSize:"inherit"})),e.createElement(O,{value:"justify","aria-label":f,title:f},e.createElement(Le,{fontSize:"inherit"})))},dt=["left","center","right","justify","code"],ft={left:function(e){return e.chain().focus().setTextAlign("left").run()},center:function(e){return e.chain().focus().setTextAlign("center").run()},right:function(e){return e.chain().focus().setTextAlign("right").run()},justify:function(e){return e.chain().focus().setTextAlign("justify").run()}},pt=function(){return(pt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},mt=function(t){var n=et(),o=re(),a=function(){var e=et(),t=r(e?e.state.doc.textBetween(e.state.selection.from,e.state.selection.to):null),n=t[0],o=t[1];return i((function(){var t=function(){o(e?e.state.doc.textBetween(e.state.selection.from,e.state.selection.to):null)};return e&&e.on("selectionUpdate",t),function(){e&&e.off("selectionUpdate",t)}}),[e]),n}(),l=o("ra.tiptap.link",{_:"Add a link"});return e.createElement(O,pt({"aria-label":l,title:l},t,{disabled:!(null==n?void 0:n.isEditable)||!a,value:"link",onClick:function(){if(n.can().setLink({href:""})){var e=window.prompt("URL");n.chain().focus().extendMarkRange("link").setLink({href:e}).run()}},selected:n&&n.isActive("link")}),e.createElement(Ie,{fontSize:"inherit"}))},ht=function(){return(ht=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},vt=function(t){var n=et(),o=re(),a=r(!1),l=a[0],c=a[1],u=o("ra.tiptap.blockquote",{_:"Blockquote"});return i((function(){var e=function(){c(n&&n.isActive("blockquote"))};return n&&(n.on("update",e),n.on("selectionUpdate",e)),function(){n&&(n.off("update",e),n.off("selectionUpdate",e))}}),[n]),e.createElement(O,ht({"aria-label":u,title:u},t,{disabled:!(null==n?void 0:n.isEditable),onClick:function(){return n.chain().focus().toggleBlockquote().run()},selected:l,value:"quote"}),e.createElement(je,{fontSize:"inherit"}))},gt=function(){return(gt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},bt=function(t){var n=et(),r=re()("ra.tiptap.clear_format",{_:"Clear format"});return e.createElement(O,gt({"aria-label":r,title:r},t,{disabled:!(null==n?void 0:n.isEditable),value:"clear",onClick:function(){return n.chain().focus().unsetAllMarks().run()}}),e.createElement(Re,{fontSize:"inherit"}))},yt=function(t){var n,o=re(),a=et(),l=r(null),c=l[0],u=l[1],s=t.size,d=r(Et[0]),f=d[0],p=d[1];return i((function(){var e=function(){p((function(e){return Et.reduce((function(e,t){if(a){if("paragraph"===t.value&&a.isActive("paragraph"))return t;if(a.isActive("heading",{level:t.level}))return t}return e}),e)}))};return a&&(a.on("update",e),a.on("selectionUpdate",e)),function(){a&&(a.off("update",e),a.off("selectionUpdate",e))}}),[a]),e.createElement(Ot,null,e.createElement(T,{component:"nav","aria-label":o("ra.tiptap.select_level",{_:"Select the level"}),dense:!0,disablePadding:!0,className:xt.list},e.createElement(k,{button:!0,"aria-haspopup":"true","aria-controls":"level-menu","aria-label":o("ra.tiptap.current_level",{_:"Current level"}),disabled:!(null==a?void 0:a.isEditable),onClick:function(e){u(e.currentTarget)},className:Xe((n={},n[xt.sizeSmall]="small"===s,n[xt.sizeLarge]="large"===s,n))},e.createElement(L,{primary:o(f.label,{_:f.defaultLabel})}),e.createElement(ce,null))),e.createElement(A,{anchorEl:c,open:Boolean(c),id:"level-menu",onClose:function(e){u(null)}},Et.map((function(t,n){return e.createElement(C,{key:t.label,selected:t===f,onClick:function(e){!function(e,t){u(null);var n=Et[t];"paragraph"===n.value?a.chain().focus().setParagraph().run():"heading"===n.value&&a.chain().focus().setHeading({level:n.level}).run()}(0,n)}},o(t.label,{_:t.defaultLabel}))}))))},Et=[{label:"ra.tiptap.paragraph",defaultLabel:"Normal",value:"paragraph"},{label:"ra.tiptap.heading1",defaultLabel:"Heading 1",value:"heading",level:1},{label:"ra.tiptap.heading2",defaultLabel:"Heading 2",value:"heading",level:2},{label:"ra.tiptap.heading3",defaultLabel:"Heading 3",value:"heading",level:3},{label:"ra.tiptap.heading4",defaultLabel:"Heading 4",value:"heading",level:4},{label:"ra.tiptap.heading5",defaultLabel:"Heading 5",value:"heading",level:5},{label:"ra.tiptap.heading6",defaultLabel:"Heading 6",value:"heading",level:6}],wt="RaRichTextInputLevelSelect",xt={list:"".concat(wt,"-list"),sizeSmall:"".concat(wt,"-sizeSmall"),sizeLarge:"".concat(wt,"-sizeLarge")},Ot=te("div")((function(e){var t,n=e.theme;return(t={})["&.".concat(xt.list)]={borderRadius:n.shape.borderRadius,border:"1px solid ".concat(ne(n.palette.action.active,.12))},t["& .".concat(xt.sizeSmall)]={paddingTop:1,paddingBottom:1,"& .MuiTypography-root":{fontSize:n.typography.pxToRem(13)}},t["& .".concat(xt.sizeLarge)]={paddingTop:8,paddingBottom:8,"& .MuiTypography-root":{fontSize:n.typography.pxToRem(15)}},t})),Tt=function(){return(Tt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},kt=function(t){var n=re(),r=et(),o=n("ra.tiptap.image",{_:"Image"}),i=e.useCallback((function(){var e=window.prompt(n("ra.tiptap.image_dialog",{_:"Image URL"}));e&&r.chain().focus().setImage({src:e}).run()}),[r,n]);return r?e.createElement(O,Tt({"aria-label":o,title:o},t,{disabled:!(null==r?void 0:r.isEditable),value:"image",onClick:i}),e.createElement(Se,{fontSize:"inherit"})):null},Lt=function(){return(Lt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};!function(e){e.FONT="font",e.BACKGROUND="background"}(Ye||(Ye={}));var At=function(t){var n=re(),r=et(),o=e.useState(!1),i=o[0],a=o[1],l=e.useState(Ye.FONT),c=l[0],u=l[1],s=n("ra.tiptap.color",{_:"Color"}),d=n("ra.tiptap.highlight",{_:"Highlight"}),f=function(e){a(!0),u(e)};return r?e.createElement(I,{sx:{position:"relative"}},e.createElement(It,{onClick:function(){return a(!1)}},e.createElement(x,null,e.createElement(O,Lt({"aria-label":s,title:s},t,{disabled:!(null==r?void 0:r.isEditable),value:"color",onClick:function(){return f(Ye.FONT)}}),e.createElement(me,{fontSize:"inherit"})),e.createElement(O,Lt({"aria-label":d,title:d},t,{disabled:!(null==r?void 0:r.isEditable),value:"highlight",onClick:function(){return f(Ye.BACKGROUND)}}),e.createElement(he,{fontSize:"inherit"}))),i&&e.createElement(Ct,{editor:r,close:function(){return a(!1)},colorType:c}))):null},Ct=function(t){var n,r,o=t.editor,i=t.close,a=t.colorType,l=S(),c=[ve,ge,be,ye,Ee,we,xe];return e.createElement(j,{sx:{position:"absolute",top:38,left:a===Ye.FONT?0:"50%",p:1,border:"1px solid ".concat(null===(r=null===(n=null==l?void 0:l.palette)||void 0===n?void 0:n.background)||void 0===r?void 0:r.default),display:"flex",flexDirection:"column",gap:1,zIndex:1}},[900,700,500,300,100].map((function(t,n){return e.createElement(I,{key:"shade-".concat(t),sx:{display:"flex",flexDirection:"row",gap:1}},c.map((function(r,l){return e.createElement(I,{key:"color-".concat(n*c.length+l+1),sx:{width:16,height:16,cursor:"pointer",backgroundColor:r[t]},onClick:function(){return function(e){a===Ye.FONT?o.chain().focus().setColor(e).run():o.chain().focus().toggleHighlight({color:e}).run(),i()}(r[t])}})})))})))},It=function(t){var n=t.className,r=t.onClick,o=t.children,i=e.useRef(null);return St(i,r),e.createElement("div",{className:n,ref:i},o)},St=function(t,n){e.useEffect((function(){var e=function(e){t.current&&!t.current.contains(e.target)&&n()};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[t,n])},jt=function(){return(jt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Rt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},Pt=function(t){var n=t.size,r=void 0===n?"medium":n,o=t.children,i=void 0===o?e.createElement(e.Fragment,null,e.createElement(yt,{size:r}),e.createElement(nt,{size:r}),e.createElement(At,{size:r}),e.createElement(st,{size:r}),e.createElement(at,{size:r}),e.createElement(mt,{size:r}),e.createElement(kt,{size:r}),e.createElement(vt,{size:r}),e.createElement(bt,{size:r})):o,a=Rt(t,["size","children"]);return e.createElement(zt,jt({className:Nt.root},a),i)},Nt={root:"".concat("RaRichTextInputToolbar","-root")},zt=te("div")((function(e){var t,n=e.theme;return(t={})["&.".concat(Nt.root)]={display:"flex",flexWrap:"wrap",alignItems:"center","& > *":{marginRight:n.spacing(1),marginBottom:n.spacing(1)},"& > *:last-child":{marginRight:0}},t})),_t=function(){return(_t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Dt=function(t){var n,r,o=t.className,a=t.defaultValue,l=void 0===a?"":a,c=t.disabled,u=void 0!==c&&c,s=t.editorOptions,d=void 0===s?Ut:s,f=t.fullWidth,p=t.helperText,m=t.label,h=t.readOnly,v=void 0!==h&&h,g=t.source,b=t.toolbar,y=oe(t),E=ie(_t(_t({},t),{source:g,defaultValue:l})),w=E.id,x=E.field,O=E.isRequired,T=E.fieldState,k=E.formState.isSubmitted,L=V(_t(_t({},d),{editable:!u&&!v,content:x.value,editorProps:_t(_t({},null==d?void 0:d.editorProps),{attributes:_t(_t({},null===(n=null==d?void 0:d.editorProps)||void 0===n?void 0:n.attributes),{id:w})})})),A=T.error,C=T.invalid,I=T.isTouched;return i((function(){if(L){var e=L.state.selection,t=e.from,n=e.to;L.commands.setContent(x.value,!1,{preserveWhitespace:!0}),L.commands.setTextSelection({from:t,to:n})}}),[L,x.value]),i((function(){var e;L&&L.setOptions({editable:!u&&!v,editorProps:_t(_t({},null==d?void 0:d.editorProps),{attributes:_t(_t({},null===(e=null==d?void 0:d.editorProps)||void 0===e?void 0:e.attributes),{id:w})})})}),[u,L,v,w,null==d?void 0:d.editorProps,null===(r=null==d?void 0:d.editorProps)||void 0===r?void 0:r.attributes]),i((function(){if(L){var e=function(){if(L.isEmpty)return x.onChange(""),void x.onBlur();var e=L.getHTML();x.onChange(e),x.onBlur()};return L.on("update",e),function(){L.off("update",e)}}}),[L,x]),e.createElement(ae,{isRequired:O,label:m,id:"".concat(w,"-label"),color:(null==T?void 0:T.invalid)?"error":void 0,source:g,resource:y,fullWidth:f},e.createElement(Ft,{className:Xe("ra-input","ra-input-".concat(g),o),editor:L,error:A,helperText:p,id:w,isTouched:I,isSubmitted:k,invalid:C,toolbar:b||e.createElement(Pt,null)}))},Ft=function(t){var n=t.className,r=t.editor,o=t.error;t.fullWidth;var i=t.helperText,a=t.id,l=t.isTouched,c=t.isSubmitted,u=t.invalid,s=t.toolbar;return e.createElement(Ht,{className:n},e.createElement($e,{value:r},s,e.createElement(W,{"aria-labelledby":"".concat(a,"-label"),className:Bt.editorContent,editor:r})),e.createElement(R,{className:(l||c)&&u?"ra-rich-text-input-error":"",error:(l||c)&&u},e.createElement(le,{touched:l||c,error:null==o?void 0:o.message,helperText:i})))},Ut={extensions:[J,K,Q,X.configure({types:["heading","paragraph"]}),Y.configure({inline:!0}),Z,$,ee.configure({multicolor:!0})]},Bt={editorContent:"".concat("RaRichTextInput","-editorContent")},Ht=te("div",{name:"RaRichTextInput",overridesResolver:function(e,t){return t.root}})((function(e){var t,n=e.theme;return(t={display:"flex",flexDirection:"column",alignItems:"center"})["& .".concat(Bt.editorContent)]={width:"100%","& .ProseMirror":{backgroundColor:n.palette.background.default,borderColor:"light"===n.palette.mode?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)",borderRadius:n.shape.borderRadius,borderStyle:"solid",borderWidth:"1px",padding:n.spacing(1),'&[contenteditable="false"], &[contenteditable="false"]:hover, &[contenteditable="false"]:focus':{backgroundColor:n.palette.action.disabledBackground},"&:hover":{backgroundColor:n.palette.action.hover},"&:focus":{backgroundColor:n.palette.background.default},"& p":{margin:"0 0 1em 0","&:last-child":{marginBottom:0}}}},t})),Mt={ACCEPT:"Accept",ADD:"Add",ANNOUNCE:"Announce",ARRIVE:"Arrive",BLOCK:"Block",CREATE:"Create",DELETE:"Delete",DISLIKE:"Dislike",FLAG:"Flag",FOLLOW:"Follow",IGNORE:"Ignore",INVITE:"Invite",JOIN:"Join",LEAVE:"Leave",LIKE:"Like",LISTEN:"Listen",MOVE:"Move",OFFER:"Offer",QUESTION:"Question",REJECT:"Reject",READ:"Read",REMOVE:"Remove",TENTATIVE_REJECT:"TentativeReject",TENTATIVE_ACCEPT:"TentativeAccept",TRAVAL:"Travel",UNDO:"Undo",UPDATE:"Update",VIEW:"View"},Gt={APPLICATION:"Application",GROUP:"Group",ORGANIZATION:"Organization",PERSON:"Person",SERVICE:"Service"},Vt={ARTICLE:"Article",AUDIO:"Audio",DOCUMENT:"Document",EVENT:"Event",IMAGE:"Image",NOTE:"Note",PAGE:"Page",PLACE:"Place",PROFILE:"Profile",RELATIONSHIP:"Relationship",TOMBSTONE:"Tombstone",VIDEO:"Video"},Wt="https://www.w3.org/ns/activitystreams#Public",qt=function(){var e=s().identity,t=a((function(){var t;if(null!=e&&e.webIdData)return null==e||null===(t=e.webIdData)||void 0===t?void 0:t.outbox}),[e]),n=a((function(){var t,n;if(null!=e&&e.webIdData)return(null==e||null===(t=e.webIdData)||void 0===t||null===(n=t.endpoints)||void 0===n?void 0:n["void:sparqlEndpoint"])||(null==e?void 0:e.id)+"/sparql"}),[e]);return{post:l(function(){var e=He(Ue().mark((function e(n){var r,o,i;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}throw new Error("Cannot post to outbox before user identity is loaded. Please use the loaded argument of useOutbox");case 2:return r=localStorage.getItem("token"),e.next=5,d.fetchJson(t,{method:"POST",body:JSON.stringify(Fe({"@context":"https://www.w3.org/ns/activitystreams"},n)),headers:new Headers({"Content-Type":"application/ld+json",Authorization:"Bearer ".concat(r)})});case 5:return o=e.sent,i=o.headers,e.abrupt("return",i.get("Location"));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[t]),fetch:l(He(Ue().mark((function e(){var r,o,i,a,l;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n&&t){e.next=2;break}return e.abrupt("return");case 2:return r=localStorage.getItem("token"),o=U(["as:object"]),i="\n PREFIX as: <https://www.w3.org/ns/activitystreams#>\n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ".concat(o.construct,"\n }\n WHERE {\n <").concat(t,"> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n ").concat(o.where,"\n }\n "),e.next=7,d.fetchJson(n,{method:"POST",body:i,headers:new Headers({Accept:"application/ld+json",Authorization:r?"Bearer ".concat(r):void 0})});case 7:if(a=e.sent,!(l=a.json)["@graph"]){e.next=13;break}return e.abrupt("return",l["@graph"]);case 13:return e.abrupt("return",null);case 14:case"end":return e.stop()}}),e)}))),[n,t]),url:t,loaded:!!t,owner:null==e?void 0:e.id}},Jt=G.extend({renderHTML:function(e){var t=e.node,n=e.HTMLAttributes;return["span",M(this.options.HTMLAttributes,n),"@".concat(t.attrs.id.label)]},addAttributes:function(){return{label:{default:null,parseHTML:function(e){return{label:e.getAttribute("data-mention-label")}},renderHTML:function(e){return e.id.label?{"data-mention-label":e.id.label}:{}}},id:{default:null,parseHTML:function(e){return{id:e.getAttribute("data-mention-id")}},renderHTML:function(e){return e.id.id?{"data-mention-id":e.id.id}:{}}}}}}),Kt=D((function(e){return{form:{marginTop:-12},container:{paddingLeft:80,position:"relative"},avatar:{position:"absolute",top:16,left:0,bottom:0,width:64,height:64},editorContent:{"& > div":{backgroundColor:"rgba(0, 0, 0, 0.09)",padding:"2px 12px",borderWidth:"0px !important",borderRadius:0,borderBottom:"1px solid #FFF",minHeight:60,outline:"unset !important"},"& > div > p":{marginTop:12,marginBottom:12,fontFamily:e.typography.body1.fontFamily,marginBlockStart:"0.5em",marginBlockEnd:"0.5em"},"& > div > p.is-editor-empty:first-child::before":{color:"grey",content:"attr(data-placeholder)",float:"left",height:0,pointerEvents:"none"}},button:{marginTop:-10,marginBottom:15}}})),Qt=function(){return null},Xt=function(e){var n,o,i,a,c=e.context,u=e.placeholder,d=e.helperText,h=e.mentions,v=e.userResource,g=e.addItem,b=e.removeItem,y=f(),E=s(),x=E.identity,O=E.isLoading,T=B(v),k=Kt(),L=p(),A=qt(),C=We(r(!1),2),S=C[0],j=C[1],R=We(r(!1),2),z=R[0],_=R[1],D=l(function(){var e=He(Ue().mark((function e(t){var n,r,o,i,a;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=(new DOMParser).parseFromString(t.comment,"text/html"),r=Array.from(n.body.getElementsByClassName("mention")),o=[],r.forEach((function(e){var t=e.attributes["data-mention-id"].value,r=e.attributes["data-mention-label"].value,i=n.createElement("a");i.setAttribute("href",new URL(window.location.href).origin+"/"+v+"/"+encodeURIComponent(t)+"/show"),i.textContent="@"+r,e.parentNode.replaceChild(i,e),o.push(t)})),"undefined"!==n.body.innerHTML){e.next=8;break}L("Votre commentaire est vide",{type:"error"}),e.next=23;break;case 8:return i=Date.now(),a={type:Vt.NOTE,attributedTo:A.owner,content:n.body.innerHTML,inReplyTo:y[c],published:(new Date).toISOString()},e.prev=10,g(Fe({id:i},a)),j(!1),e.next=15,A.post(Fe(Fe({},a),{},{to:[].concat(o,[Wt])}));case 15:L("Commentaire posté avec succès",{type:"success"}),e.next=23;break;case 18:e.prev=18,e.t0=e.catch(10),console.error(e.t0),b(i),L(e.t0.message,{type:"error"});case 23:case"end":return e.stop()}}),e,null,[[10,18]])})));return function(t){return e.apply(this,arguments)}}(),[A,L,j,g,b]),U=l((function(){null!=x&&x.id||_(!0)}),[x,_]);return h&&!h.items||O?null:t.createElement(t.Fragment,null,t.createElement(m,{onSubmit:D,className:k.form},t.createElement(I,{className:k.container,onClick:U},t.createElement(P,{src:(null==x||null===(n=x.webIdData)||void 0===n?void 0:n[null==T||null===(o=T.fieldsMapping)||void 0===o?void 0:o.image])||(null==x||null===(i=x.profileData)||void 0===i?void 0:i[null==T||null===(a=T.fieldsMapping)||void 0===a?void 0:a.image]),className:k.avatar}),t.createElement(Dt,{source:"comment",label:" ",toolbar:t.createElement(Qt,null),fullWidth:!0,classes:{editorContent:k.editorContent},editorOptions:Fe(Fe({},Ut),{},{onFocus:function(){j(!0)},extensions:[].concat(qe(Ut.extensions),[u?w.configure({placeholder:u}):null,h?Jt.configure({HTMLAttributes:{class:"mention"},suggestion:h}):null]),editable:!(null==x||!x.id)}),helperText:d}),S&&t.createElement(N,{type:"submit",size:"small",variant:"contained",color:"primary",endIcon:t.createElement(F,null),className:k.button},"Envoyer"))),t.createElement(H,{open:z,onClose:function(){return _(!1)},message:"Pour poster un commentaire, vous devez être connecté."}))},Yt=D((function(){return{container:{paddingLeft:80,marginTop:8,minHeight:80,position:"relative"},avatar:{position:"absolute",top:0,left:0,bottom:0,width:64,height:64},text:{paddingTop:2,paddingBottom:8},label:{fontWeight:"bold"},content:{"& p":{marginBlockStart:"0.5em",marginBlockEnd:"0.5em"}},loading:{zIndex:1e3,backgroundColor:"white",opacity:.5,position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",minHeight:200,marginTop:5}}})),Zt=function(e){var n=e.comments,r=e.userResource,o=e.loading,i=Yt(),a=B(r);return t.createElement(I,{position:"relative"},n&&n.sort((function(e,t){return new Date(t.published)-new Date(e.published)})).map((function(e){var n,o;return t.createElement(I,{className:i.container,key:e.id},t.createElement(I,{className:i.avatar},t.createElement(Pe,{record:e,reference:r,source:"attributedTo",linkType:"show"},t.createElement(Ne,{image:null==a||null===(n=a.fieldsMapping)||void 0===n?void 0:n.image}))),t.createElement(I,{className:i.text},t.createElement(z,{variant:"body2"},t.createElement(Pe,{record:e,reference:r,source:"attributedTo",linkType:"show"},t.createElement(h,{variant:"body2",source:null==a||null===(o=a.fieldsMapping)||void 0===o?void 0:o.title,className:i.label}))," • ",t.createElement(v,{record:e,variant:"body2",source:"published",showTime:!0})),t.createElement(g,{record:e,variant:"body1",source:"content",className:i.content})))})),o&&t.createElement(I,{minHeight:200},t.createElement(I,{alignItems:"center",className:i.loading},t.createElement(_,{size:60,thickness:6}))))},$t=function(e){var t=s(),n=t.identity,o=t.loaded,c=We(r([]),2),u=c[0],f=c[1],p=We(r(!1),2),m=p[0],h=p[1],v=We(r(!1),2),g=v[0],b=v[1],y=We(r(!1),2),E=y[0],w=y[1],x=a((function(){if(e){if(e.startsWith("http"))return e;var t;if(null!=n&&n.webIdData)return null==n||null===(t=n.webIdData)||void 0===t?void 0:t[e]}}),[n,e]),O=l(He(Ue().mark((function e(){var t,r,o,i;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(x){e.next=2;break}return e.abrupt("return");case 2:h(!0),t=new Headers({Accept:"application/ld+json"}),r=n.id&&new URL(n.id).origin,o=new URL(x).origin,i=localStorage.getItem("token"),r===o&&i&&t.set("Authorization","Bearer ".concat(i)),d.fetchJson(x,{headers:t}).then((function(e){var t=e.json;t&&t.items?f(t.items):t&&t.orderedItems?f(t.orderedItems):f([]),w(!1),b(!0),h(!1)})).catch((function(){w(!0),b(!0),h(!1)}));case 9:case"end":return e.stop()}}),e)}))),[f,b,h,w,x,n]);i((function(){!o||m||g||E||O()}),[O,o,m,g,E]);var T=l((function(e){f((function(t){return[].concat(qe(t),[e])}))}),[f]),k=l((function(e){f((function(t){return t.filter((function(t){return"string"==typeof t?t!==e:t.id!==e}))}))}),[f]);return{items:u,loading:m,loaded:g,error:E,refetch:O,addItem:T,removeItem:k,url:x}},en=function(e){e.source;var n=e.context,r=e.helperText,o=e.placeholder,i=e.userResource,a=e.mentions,l=f(),c=$t(l.replies),u=c.items,s=c.loading,d=c.addItem,p=c.removeItem;if(!i)throw new Error("No userResource defined for CommentsField");return t.createElement(t.Fragment,null,t.createElement(Xt,{context:n,helperText:r,userResource:i,placeholder:o,mentions:a,addItem:d,removeItem:p}),t.createElement(Zt,{comments:u,loading:s,userResource:i}))};en.defaultProps={label:"Commentaires",placeholder:"Commencez à taper votre commentaire...",source:"id",context:"id"};var tn=["collectionUrl","resource","children"],nn=function(e){var n=e.collectionUrl,r=e.resource,o=e.children,i=Ve(e,tn);if(1!==t.Children.count(o))throw new Error("<CollectionList> only accepts a single child");var a=b(r,n,{enabled:!!n}),l=a.data;return a.isLoading?t.createElement("div",{style:{marginTop:8}},t.createElement(y,null)):l?t.createElement(ze,Ge({reference:r,record:l,source:"items"},i),o):null},rn=["source","record","reference","children"],on=function(e){var n=e.source,r=e.record,o=e.reference,i=e.children,a=Ve(e,rn);if(1!==t.Children.count(i))throw new Error("<ReferenceCollectionField> only accepts a single child");return r&&r[n]?t.createElement(nn,Ge({resource:o,collectionUrl:r[n]},a),i):null},an=function(){var e=s().identity,t=a((function(){var t;if(null!=e&&e.webIdData)return null==e||null===(t=e.webIdData)||void 0===t?void 0:t.inbox}),[e]),n=a((function(){var t,n;if(null!=e&&e.webIdData)return(null==e||null===(t=e.webIdData)||void 0===t||null===(n=t.endpoints)||void 0===n?void 0:n["void:sparqlEndpoint"])||(null==e?void 0:e.id)+"/sparql"}),[e]);return{fetch:l(function(){var e=He(Ue().mark((function e(r){var o,i,a,l,c,u,s;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=r.filters,n&&t){e.next=3;break}return e.abrupt("return");case 3:return i=localStorage.getItem("token"),a=U(["as:object"]),l="",o&&Object.keys(o).forEach((function(e){if(o[e]){var t=o[e].startsWith("http")?"<".concat(o[e],">"):o[e];l+="?s1 ".concat(e," ").concat(t," .")}})),c="\n PREFIX as: <https://www.w3.org/ns/activitystreams#>\n CONSTRUCT {\n ?s1 ?p1 ?o1 .\n ".concat(a.construct,"\n }\n WHERE {\n <").concat(t,"> as:items ?s1 .\n ?s1 ?p1 ?o1 .\n FILTER( (isIRI(?s1)) ) .\n ").concat(l,"\n ").concat(a.where,"\n }\n "),e.next=10,d.fetchJson(n,{method:"POST",body:c,headers:new Headers({Accept:"application/ld+json",Authorization:i?"Bearer ".concat(i):void 0})});case 10:if(u=e.sent,!(s=u.json)["@graph"]){e.next=16;break}return e.abrupt("return",s["@graph"]);case 16:return e.abrupt("return",null);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[n,t]),url:t,owner:null==e?void 0:e.id}},ln=function(){return{fetch:l(function(){var e=He(Ue().mark((function e(t){var n,r,o,i,a,l,c,u,s;return Ue().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.split("@"),(r=We(n,3))[0],o=r[1],!(i=r[2])){e.next=18;break}return a=i.includes(":")?"http":"https",l="".concat(a,"://").concat(i,"/.well-known/webfinger?resource=acct:").concat(o,"@").concat(i),e.prev=4,e.next=7,d.fetchJson(l);case 7:return c=e.sent,u=c.json,s=u.links.find((function(e){return"application/activity+json"===e.type})),e.abrupt("return",s?s.href:null);case 13:return e.prev=13,e.t0=e.catch(4),e.abrupt("return",null);case 16:e.next=19;break;case 18:return e.abrupt("return",null);case 19:case"end":return e.stop()}}),e,null,[[4,13]])})));return function(t){return e.apply(this,arguments)}}(),[])}},cn=D((function(e){return{items:{background:"#fff",borderRadius:"0.5rem",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1)",color:"rgba(0, 0, 0, 0.8)",fontSize:"0.9rem",overflow:"hidden",padding:"0.2rem",position:"relative"},item:{background:"transparent",border:"1px solid transparent",borderRadius:"0.4rem",display:"block",margin:0,padding:"0.2rem 0.4rem",textAlign:"left",width:"100%","&.selected":{borderColor:"#000"}}}})),un=c((function(e,n){var o=We(r(0),2),a=o[0],l=o[1],c=cn(),s=function(t){var n=e.items[t];n&&e.command({id:n})};return i((function(){return l(0)}),[e.items]),u(n,(function(){return{onKeyDown:function(t){var n=t.event;return"ArrowUp"===n.key?(l((a+e.items.length-1)%e.items.length),!0):"ArrowDown"===n.key?(l((a+1)%e.items.length),!0):"Enter"===n.key&&(s(a),!0)}}})),t.createElement("div",{className:c.items},e.items.length?e.items.map((function(e,n){return t.createElement("button",{className:c.item+(n===a?" selected":""),key:n,onClick:function(){return s(n)}},e.label)})):t.createElement("div",{className:c.item},"Aucun résultat"))})),sn=function(){var e,t;return{onStart:function(n){e=new q(un,{props:n,editor:n.editor}),t=_e("body",{getReferenceClientRect:n.clientRect,appendTo:function(){return document.body},content:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:function(n){e.updateProps(n),t[0].setProps({getReferenceClientRect:n.clientRect})},onKeyDown:function(n){var r;return"Escape"===n.event.key?(t[0].hide(),!0):null===(r=e.ref)||void 0===r?void 0:r.onKeyDown(n)},onExit:function(){t[0].destroy(),e.destroy()}}},dn=function(e){var t,n,r=B(e),o=E(e,{filter:{_predicates:[null==r||null===(t=r.fieldsMapping)||void 0===t?void 0:t.title],blankNodes:[]}},{enabled:!(null==r||null===(n=r.fieldsMapping)||void 0===n||!n.title)}).data,i=a((function(){if(o)return o.map((function(e){var t;return{id:e.id,label:e[null==r||null===(t=r.fieldsMapping)||void 0===t?void 0:t.title]}}))}),[o]);return{items:a((function(){if(i)return function(e){var t=e.query;return i.filter((function(e){return e.label.toLowerCase().startsWith(t.toLowerCase())})).slice(0,5)}}),[i]),render:sn}};export{Mt as ACTIVITY_TYPES,Gt as ACTOR_TYPES,nn as CollectionList,en as CommentsField,Vt as OBJECT_TYPES,Wt as PUBLIC_URI,on as ReferenceCollectionField,$t as useCollection,an as useInbox,dn as useMentions,qt as useOutbox,ln as useWebfinger};
|
|
4
4
|
//# sourceMappingURL=index.es.js.map
|