import{a as C}from"./chunk-UB5P4QTT.mjs";import{a as S,b as L,c as O}from"./chunk-XEHBQAFR.mjs";var b={};L(b,{default:()=>P});var k,P,v=S(()=>{"use strict";k=function(){var e={defaultValue:null,kind:"LocalArgument",name:"connections"},n={defaultValue:null,kind:"LocalArgument",name:"input"},a=[{kind:"Variable",name:"input",variableName:"input"}],t={alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},l={alias:null,args:null,concreteType:"ErrorType",kind:"LinkedField",name:"errors",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"field",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"messages",storageKey:null}],storageKey:null},s=[{alias:null,args:null,kind:"ScalarField",name:"url",storageKey:null}];return{fragment:{argumentDefinitions:[e,n],kind:"Fragment",metadata:null,name:"CreateChatRoomMutation",selections:[{alias:null,args:a,concreteType:"ChatRoomCreatePayload",kind:"LinkedField",name:"chatRoomCreate",plural:!1,selections:[{alias:null,args:null,concreteType:"ChatRoomEdge",kind:"LinkedField",name:"room",plural:!1,selections:[{alias:null,args:null,concreteType:"ChatRoom",kind:"LinkedField",name:"node",plural:!1,selections:[t,{args:null,kind:"FragmentSpread",name:"LastMessageFragment"},{args:null,kind:"FragmentSpread",name:"TitleFragment"},{args:null,kind:"FragmentSpread",name:"UnreadMessagesCountFragment"}],storageKey:null}],storageKey:null},l],storageKey:null}],type:"Mutation",abstractKey:null},kind:"Request",operation:{argumentDefinitions:[n,e],kind:"Operation",name:"CreateChatRoomMutation",selections:[{alias:null,args:a,concreteType:"ChatRoomCreatePayload",kind:"LinkedField",name:"chatRoomCreate",plural:!1,selections:[{alias:null,args:null,concreteType:"ChatRoomEdge",kind:"LinkedField",name:"room",plural:!1,selections:[{alias:null,args:null,concreteType:"ChatRoom",kind:"LinkedField",name:"node",plural:!1,selections:[t,{alias:null,args:null,kind:"ScalarField",name:"lastMessageTime",storageKey:null},{alias:null,args:null,concreteType:"Message",kind:"LinkedField",name:"lastMessage",plural:!1,selections:[t,{alias:null,args:null,kind:"ScalarField",name:"content",storageKey:null}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"isGroup",storageKey:null},{alias:null,args:[{kind:"Literal",name:"first",value:2}],concreteType:"ChatRoomParticipantConnection",kind:"LinkedField",name:"participants",plural:!1,selections:[{alias:null,args:null,concreteType:"ChatRoomParticipantEdge",kind:"LinkedField",name:"edges",plural:!0,selections:[{alias:null,args:null,concreteType:"ChatRoomParticipant",kind:"LinkedField",name:"node",plural:!1,selections:[{alias:null,args:null,concreteType:"Profile",kind:"LinkedField",name:"profile",plural:!1,selections:[t,{alias:null,args:null,kind:"ScalarField",name:"name",storageKey:null},{alias:null,args:[{kind:"Literal",name:"height",value:100},{kind:"Literal",name:"width",value:100}],concreteType:"File",kind:"LinkedField",name:"image",plural:!1,selections:s,storageKey:"image(height:100,width:100)"}],storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"role",storageKey:null},t],storageKey:null}],storageKey:null}],storageKey:"participants(first:2)"},{alias:null,args:[{kind:"Literal",name:"height",value:144},{kind:"Literal",name:"width",value:144}],concreteType:"File",kind:"LinkedField",name:"image",plural:!1,selections:s,storageKey:"image(height:144,width:144)"},{alias:null,args:null,kind:"ScalarField",name:"title",storageKey:null},{alias:null,args:null,concreteType:"UnreadMessageCount",kind:"LinkedField",name:"unreadMessages",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"count",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"markedUnread",storageKey:null},t],storageKey:null}],storageKey:null}],storageKey:null},{alias:null,args:null,filters:null,handle:"prependEdge",key:"",kind:"LinkedHandle",name:"room",handleArgs:[{kind:"Variable",name:"connections",variableName:"connections"}]},l],storageKey:null}]},params:{cacheID:"9622f280ce788a44442ebabf48aadb6e",id:null,metadata:{},name:"CreateChatRoomMutation",operationKind:"mutation",text:`mutation CreateChatRoomMutation(
  $input: ChatRoomCreateInput!
) {
  chatRoomCreate(input: $input) {
    room {
      node {
        id
        ...LastMessageFragment
        ...TitleFragment
        ...UnreadMessagesCountFragment
      }
    }
    errors {
      field
      messages
    }
  }
}

fragment GroupTitleFragment on ChatRoom {
  id
  image(width: 144, height: 144) {
    url
  }
  title
}

fragment LastMessageFragment on ChatRoom {
  id
  lastMessageTime
  lastMessage {
    id
    content
  }
}

fragment RoomTitleFragment on ChatRoom {
  id
  participants(first: 2) {
    edges {
      node {
        profile {
          id
          name
          image(width: 100, height: 100) {
            url
          }
        }
        role
        id
      }
    }
  }
}

fragment TitleFragment on ChatRoom {
  id
  isGroup
  ...RoomTitleFragment
  ...GroupTitleFragment
}

fragment UnreadMessagesCountFragment on ChatRoom {
  id
  unreadMessages {
    count
    markedUnread
    id
  }
}
`}}}();k.hash="304767b39c282d78401577a512369b3e";P=k});import{useNotification as U}from"@baseapp-frontend/utils";import{useMutation as D}from"react-relay";function p(e){"@babel/helpers - typeof";return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},p(e)}var m;function R(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),a.push.apply(a,t)}return a}function F(e){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?R(Object(a),!0).forEach(function(t){j(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):R(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function j(e,n,a){return(n=w(n))in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function w(e){var n=_(e,"string");return p(n)=="symbol"?n:n+""}function _(e,n){if(p(e)!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var t=a.call(e,n||"default");if(p(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function A(e,n){return x(e)||$(e,n)||I(e,n)||E()}function E(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function I(e,n){if(e){if(typeof e=="string")return M(e,n);var a={}.toString.call(e).slice(8,-1);return a==="Object"&&e.constructor&&(a=e.constructor.name),a==="Map"||a==="Set"?Array.from(e):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?M(e,n):void 0}}function M(e,n){(n==null||n>e.length)&&(n=e.length);for(var a=0,t=Array(n);a<n;a++)t[a]=e[a];return t}function $(e,n){var a=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(a!=null){var t,l,s,c,g=[],d=!0,y=!1;try{if(s=(a=a.call(e)).next,n===0){if(Object(a)!==a)return;d=!1}else for(;!(d=(t=s.call(a)).done)&&(g.push(t.value),g.length!==n);d=!0);}catch(h){y=!0,l=h}finally{try{if(!d&&a.return!=null&&(c=a.return(),Object(c)!==c))return}finally{if(y)throw l}}return g}}function x(e){if(Array.isArray(e))return e}var q=(m!==void 0||(m=(v(),O(b)),m.hash&&m.hash!=="304767b39c282d78401577a512369b3e"&&console.error("The definition of 'CreateChatRoomMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data.")),m),Q=function(){var n=U(),a=n.sendToast,t=D(q),l=A(t,2),s=l[0],c=l[1],g=C(),d=g.setChatRoom,y=function(r){return s(F(F({},r),{},{onCompleted:function(u,i){var o,f;i?.forEach(function(K){a(K.message,{type:"error"})}),d({id:u==null||(o=u.chatRoomCreate)===null||o===void 0||(o=o.room)===null||o===void 0||(o=o.node)===null||o===void 0?void 0:o.id}),r==null||(f=r.onCompleted)===null||f===void 0||f.call(r,u,i)},onError:function(u){var i;a(u.message,{type:"error"}),r==null||(i=r.onError)===null||i===void 0||i.call(r,u)}}))};return[y,c]};export{q as a,Q as b};
//# sourceMappingURL=chunk-SQFWWN4R.mjs.map