bitsnap-react 1.21.1 → 1.22.0

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.
Files changed (125) hide show
  1. package/dist/BitsnapCart-AINUJQVF.mjs +2 -0
  2. package/dist/BitsnapCart-GP2UJSG4.js +2 -0
  3. package/dist/BitsnapCart-GP2UJSG4.js.map +1 -0
  4. package/dist/CartProvider-HTKGBPVA.js +2 -0
  5. package/dist/CartProvider-HTKGBPVA.js.map +1 -0
  6. package/dist/CartProvider-YUV2Q523.mjs +2 -0
  7. package/dist/PanelModelFiles-EKQRLF46.js.map +1 -1
  8. package/dist/analytics.js +1 -1
  9. package/dist/analytics.js.map +1 -1
  10. package/dist/analytics.mjs +1 -1
  11. package/dist/catalog.js +1 -1
  12. package/dist/catalog.js.map +1 -1
  13. package/dist/catalog.mjs +1 -1
  14. package/dist/chat.d.mts +2 -2
  15. package/dist/chat.d.ts +2 -2
  16. package/dist/chat.js +1 -1
  17. package/dist/chat.js.map +1 -1
  18. package/dist/chat.mjs +1 -1
  19. package/dist/chat.mjs.map +1 -1
  20. package/dist/{chunk-OCJ7YWFX.js → chunk-35ZQU353.js} +2 -2
  21. package/dist/chunk-35ZQU353.js.map +1 -0
  22. package/dist/chunk-3TUL63IC.js.map +1 -1
  23. package/dist/chunk-4JR74NXR.js +2 -0
  24. package/dist/chunk-4JR74NXR.js.map +1 -0
  25. package/dist/{chunk-QWQPAN4F.mjs → chunk-5MXBUGY3.mjs} +2 -2
  26. package/dist/chunk-6Q3VGPSF.js.map +1 -1
  27. package/dist/chunk-7IP3JWZ3.mjs +2 -0
  28. package/dist/chunk-7IP3JWZ3.mjs.map +1 -0
  29. package/dist/{chunk-EXC5Z5VM.mjs → chunk-C2AJ5B32.mjs} +2 -2
  30. package/dist/{chunk-7WTQGXPQ.mjs → chunk-IVB3E4V3.mjs} +2 -2
  31. package/dist/{chunk-6DEKVABT.js → chunk-JS3KK56H.js} +2 -2
  32. package/dist/chunk-JS3KK56H.js.map +1 -0
  33. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  34. package/dist/{chunk-MMQTRSI5.js → chunk-KFY6IOAA.js} +2 -2
  35. package/dist/chunk-KFY6IOAA.js.map +1 -0
  36. package/dist/chunk-KOYBZORL.js.map +1 -1
  37. package/dist/{chunk-J4GUVJP4.js → chunk-MBSXTB6G.js} +2 -2
  38. package/dist/chunk-MBSXTB6G.js.map +1 -0
  39. package/dist/chunk-MDAFPGPA.js.map +1 -1
  40. package/dist/{chunk-2HINORSP.mjs → chunk-NCCP2UDM.mjs} +2 -2
  41. package/dist/chunk-PFKZ7KUU.js +2 -0
  42. package/dist/chunk-PFKZ7KUU.js.map +1 -0
  43. package/dist/chunk-Q337IQNA.js.map +1 -1
  44. package/dist/{chunk-QXCL5CE6.mjs → chunk-QCIETNFZ.mjs} +2 -2
  45. package/dist/{chunk-56X4DBMQ.mjs → chunk-QJBQ45R6.mjs} +2 -2
  46. package/dist/{chunk-FG7NLLJV.mjs → chunk-QJOMFK4X.mjs} +2 -2
  47. package/dist/{chunk-J6WKSO33.mjs → chunk-QQSCVPOG.mjs} +2 -2
  48. package/dist/{chunk-J6WKSO33.mjs.map → chunk-QQSCVPOG.mjs.map} +1 -1
  49. package/dist/{chunk-EK3D44XW.js → chunk-SAKZOHU7.js} +2 -2
  50. package/dist/chunk-SAKZOHU7.js.map +1 -0
  51. package/dist/{chunk-TWZQ4CBY.js → chunk-SZNTXRFD.js} +3 -3
  52. package/dist/chunk-SZNTXRFD.js.map +1 -0
  53. package/dist/chunk-TVZLDLAV.mjs +2 -0
  54. package/dist/chunk-TVZLDLAV.mjs.map +1 -0
  55. package/dist/chunk-U37ZH4YJ.js +2 -0
  56. package/dist/chunk-U37ZH4YJ.js.map +1 -0
  57. package/dist/chunk-W3RGQYPD.js.map +1 -1
  58. package/dist/{chunk-J6YI6FJN.js → chunk-WYRECFVW.js} +2 -2
  59. package/dist/chunk-WYRECFVW.js.map +1 -0
  60. package/dist/chunk-Z3YOJ6NZ.js.map +1 -1
  61. package/dist/{chunk-YV3UGLQ3.mjs → chunk-ZFUE3AX5.mjs} +2 -2
  62. package/dist/{chunk-FPCMLZFM.js → chunk-ZFZR3CI5.js} +2 -2
  63. package/dist/chunk-ZFZR3CI5.js.map +1 -0
  64. package/dist/consent.js.map +1 -1
  65. package/dist/course.js +1 -1
  66. package/dist/course.js.map +1 -1
  67. package/dist/course.mjs +1 -1
  68. package/dist/embed/analytics.js +1 -1
  69. package/dist/errors.js.map +1 -1
  70. package/dist/index.css +1 -1
  71. package/dist/index.css.map +1 -1
  72. package/dist/index.d.mts +2 -2
  73. package/dist/index.d.ts +2 -2
  74. package/dist/index.js +1 -1
  75. package/dist/index.js.map +1 -1
  76. package/dist/index.mjs +1 -1
  77. package/dist/index.mjs.map +1 -1
  78. package/dist/internal.js.map +1 -1
  79. package/dist/methods-4Q37ITIM.js +2 -0
  80. package/dist/methods-4Q37ITIM.js.map +1 -0
  81. package/dist/methods-JLVRTNPE.mjs +2 -0
  82. package/dist/model-files-client-P4PORZJ6.js.map +1 -1
  83. package/dist/models.js.map +1 -1
  84. package/dist/returns.js +1 -1
  85. package/dist/returns.js.map +1 -1
  86. package/dist/returns.mjs +1 -1
  87. package/dist/viewer3d.js.map +1 -1
  88. package/dist/viewer3d.mjs +1 -1
  89. package/dist/{widgets-DmHlIbp8.d.mts → widgets-CAQRHzT7.d.mts} +41 -1
  90. package/dist/{widgets-BL6pCMdc.d.ts → widgets-DS_Pk7Br.d.ts} +41 -1
  91. package/package.json +2 -2
  92. package/dist/BitsnapCart-3RSI3PIM.mjs +0 -2
  93. package/dist/BitsnapCart-4DKJ7OXL.js +0 -2
  94. package/dist/BitsnapCart-4DKJ7OXL.js.map +0 -1
  95. package/dist/CartProvider-TXRCAXOT.mjs +0 -2
  96. package/dist/CartProvider-ZAGTSCHJ.js +0 -2
  97. package/dist/CartProvider-ZAGTSCHJ.js.map +0 -1
  98. package/dist/chunk-6DEKVABT.js.map +0 -1
  99. package/dist/chunk-EK3D44XW.js.map +0 -1
  100. package/dist/chunk-FPCMLZFM.js.map +0 -1
  101. package/dist/chunk-J4GUVJP4.js.map +0 -1
  102. package/dist/chunk-J6YI6FJN.js.map +0 -1
  103. package/dist/chunk-K2HIALKR.js +0 -2
  104. package/dist/chunk-K2HIALKR.js.map +0 -1
  105. package/dist/chunk-MMQTRSI5.js.map +0 -1
  106. package/dist/chunk-NW5PFIZB.js +0 -2
  107. package/dist/chunk-NW5PFIZB.js.map +0 -1
  108. package/dist/chunk-OCJ7YWFX.js.map +0 -1
  109. package/dist/chunk-TWZQ4CBY.js.map +0 -1
  110. package/dist/chunk-VU2MX5HY.mjs +0 -2
  111. package/dist/chunk-VU2MX5HY.mjs.map +0 -1
  112. package/dist/methods-27HZQY5L.js +0 -2
  113. package/dist/methods-27HZQY5L.js.map +0 -1
  114. package/dist/methods-27JU6IH7.mjs +0 -2
  115. /package/dist/{BitsnapCart-3RSI3PIM.mjs.map → BitsnapCart-AINUJQVF.mjs.map} +0 -0
  116. /package/dist/{CartProvider-TXRCAXOT.mjs.map → CartProvider-YUV2Q523.mjs.map} +0 -0
  117. /package/dist/{chunk-QWQPAN4F.mjs.map → chunk-5MXBUGY3.mjs.map} +0 -0
  118. /package/dist/{chunk-EXC5Z5VM.mjs.map → chunk-C2AJ5B32.mjs.map} +0 -0
  119. /package/dist/{chunk-7WTQGXPQ.mjs.map → chunk-IVB3E4V3.mjs.map} +0 -0
  120. /package/dist/{chunk-2HINORSP.mjs.map → chunk-NCCP2UDM.mjs.map} +0 -0
  121. /package/dist/{chunk-QXCL5CE6.mjs.map → chunk-QCIETNFZ.mjs.map} +0 -0
  122. /package/dist/{chunk-56X4DBMQ.mjs.map → chunk-QJBQ45R6.mjs.map} +0 -0
  123. /package/dist/{chunk-FG7NLLJV.mjs.map → chunk-QJOMFK4X.mjs.map} +0 -0
  124. /package/dist/{chunk-YV3UGLQ3.mjs.map → chunk-ZFUE3AX5.mjs.map} +0 -0
  125. /package/dist/{methods-27JU6IH7.mjs.map → methods-JLVRTNPE.mjs.map} +0 -0
package/dist/chat.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkZ3YOJ6NZjs = require('./chunk-Z3YOJ6NZ.js');var _chunkOCJ7YWFXjs = require('./chunk-OCJ7YWFX.js');var _chunkMDAFPGPAjs = require('./chunk-MDAFPGPA.js');require('./chunk-3TUL63IC.js');var _chunk6DEKVABTjs = require('./chunk-6DEKVABT.js');require('./chunk-EK3D44XW.js');require('./chunk-W3RGQYPD.js');var _chunkQ337IQNAjs = require('./chunk-Q337IQNA.js');require('./chunk-JSDGZ4NY.js');var _react = require('react');async function se(e){await _chunkOCJ7YWFXjs.e.call(void 0, {id:e.productId,name:_nullishCoalesce(e.name, () => ("")),price:_nullishCoalesce(e.priceCents, () => (0)),currency:"",amount:e.amount},{projectID:e.projectID,host:e.host,showCart:!0})}var Ce="https://chat.bitsnap.pl",ve= exports.DEFAULT_CHAT_ATTACHMENTS_URL ="https://bitsnap.pl",Te= exports.DEFAULT_CHAT_REALTIME_URL ="wss://bitsnap-nats-queue-production.up.railway.app";var $=class extends Error{constructor(t,n,a={}){super(`chat: ${t} (${n})`),this.name="ChatError",this.code=t,this.status=n,this.data=a;let r=Number(a.retry_after);Number.isFinite(r)&&r>0&&(this.retryAfter=r)}};function ie(e){let t=(e.baseUrl||Ce).replace(/\/+$/,""),n=typeof window<"u"&&["localhost","127.0.0.1"].includes(window.location.hostname)?window.location.origin:void 0,a=(_nullishCoalesce(_nullishCoalesce(e.attachmentsUrl, () => (n)), () => (ve))).replace(/\/+$/,""),r=_nullishCoalesce(e.fetch, () => (((...u)=>fetch(...u))));async function c(u,i,g){let b;try{b=await r(t+i,{method:u,headers:{Authorization:`Bearer ${e.token}`,"X-Bitsnap-Project":e.projectId,...g===void 0?{}:{"Content-Type":"application/json"}},body:g===void 0?void 0:JSON.stringify(g)})}catch (e2){throw new $("network",0)}let k=null;try{let T=await b.text();k=T?JSON.parse(T):null}catch (e3){k=null}if(!b.ok){let T=K(k)?k:{},f=typeof T.error=="string"?T.error:"internal_error";throw new $(f,b.status,T)}return{status:b.status,json:k}}let v=encodeURIComponent,h;return{baseUrl:t,projectId:e.projectId,async me(){let{json:u}=await c("GET","/v1/me");return lt(u)},async openThread(u){let{json:i}=await c("POST","/v1/threads",{product_id:u});return De(i)},async messages(u,i={}){let g=new URLSearchParams;i.before&&g.set("before",i.before),i.limit&&g.set("limit",String(i.limit));let b=g.toString(),k=b?`?${b}`:"",{json:T}=await c("GET",`/v1/threads/${v(u)}/messages${k}`),f=K(T)?T:{};return{messages:ee(f.messages).map(pe),hasMore:f.has_more===!0}},async send(u,i){let{json:g}=await c("POST",`/v1/threads/${v(u)}/messages`,{body:i.body,...i.clientId?{client_id:i.clientId}:{},...i.attachment?{attachment_key:i.attachment.key,attachment_kind:i.attachment.kind,attachment_name:i.attachment.filename,attachment_size:i.attachment.size,attachment_content_type:i.attachment.contentType}:{}}),b=K(g)?g:{};return{message:pe(b.message),thread:Fe(b.thread)}},async uploadAttachment(u,i,g){let b=async(f,N)=>{let w=await r(`${a}/api/chat/attachments/${f}`,{method:"POST",headers:{Authorization:`Bearer ${e.token}`,"X-Bitsnap-Project":e.projectId,"Content-Type":"application/json"},body:JSON.stringify(N)}),p={};try{p=await w.json()}catch (e4){}if(!w.ok)throw new $(typeof p.error=="string"?p.error:"request_failed",w.status,p);return p},k=await b("upload",{project_id:e.projectId,thread_id:u,filename:i.name,content_type:i.type,size:i.size});await new Promise((f,N)=>{let w=new XMLHttpRequest;w.open("PUT",k.uploadURL),w.setRequestHeader("Content-Type",i.type),w.upload.onprogress=p=>{p.lengthComputable&&g(Math.round(p.loaded/p.total*100))},w.onload=()=>w.status>=200&&w.status<300?f():N(new $("upload_failed",w.status)),w.onerror=()=>N(new $("network",0)),w.send(i)});let T=await b("complete",{project_id:e.projectId,thread_id:u,key:k.key,upload_ticket:k.uploadTicket,filename:i.name,content_type:i.type,size:i.size});return{key:T.key,kind:T.kind,filename:T.filename,size:T.size,contentType:T.content_type}},async attachmentURL(u,i){if(!i.attachmentKey)throw new $("invalid_attachment",400);let g=new URLSearchParams({project_id:e.projectId,thread_id:u,key:i.attachmentKey,filename:_nullishCoalesce(i.attachmentName, () => ("attachment")),size:String(_nullishCoalesce(i.attachmentSize, () => (0)))}),b=await r(`${a}/api/chat/attachments/read?${g}`,{headers:{Authorization:`Bearer ${e.token}`,"X-Bitsnap-Project":e.projectId}}),k={};try{k=await b.json()}catch (e5){}if(!b.ok||typeof k.url!="string")throw new $(typeof k.error=="string"?k.error:"request_failed",b.status,k);return k.url},async deleteMessage(u,i){await c("DELETE",`/v1/threads/${v(u)}/messages/${v(i)}`)},async mute(u,i){await c("POST",`/v1/threads/${v(u)}/mute`,{muted:i})},async report(u){await c("POST","/v1/reports",{thread_id:u.threadId,...u.messageId?{message_id:u.messageId}:{},reason:u.reason,...u.note?{note:u.note}:{}})},async markRead(u,i){await c("POST",`/v1/threads/${v(u)}/receipts`,{state:"read",message_id:i})},async realtimeToken(u={}){if(!u.fresh&&h&&Date.parse(h.expiresAt)-Date.now()>9e4)return h;let{json:i}=await c("POST","/v1/realtime/token"),g=K(i)?i:{};return h={jwt:B(g.jwt),expiresAt:B(g.expires_at),servers:ee(g.servers).filter(b=>typeof b=="string"),subjects:ee(g.subjects).filter(b=>typeof b=="string"),truncated:g.truncated===!0}}}}function Ne(e){if(!K(e)||typeof e.type!="string")return null;let t=B(e.id);switch(e.type){case"message.created":return{type:"message.created",message:pe(e)};case"message.rejected":return{type:"message.rejected",id:t,reason:B(e.reason)};case"message.deleted":case"message.pinned":case"message.unpinned":return{type:e.type,id:t};default:return null}}function K(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}function ee(e){return Array.isArray(e)?e:[]}function B(e){return typeof e=="string"?e:e==null?"":String(e)}function Y(e){let t=Number(e);return Number.isFinite(t)?t:0}function te(e){return typeof e=="string"&&e!==""?e:void 0}function Ie(e){return typeof e=="string"&&e!==""?e:null}function pe(e){let t=K(e)?e:{};return{id:B(t.id),threadId:B(t.thread_id),authorEmail:B(t.author_email),body:B(t.body),attachmentKey:te(t.attachment_key),attachmentKind:te(t.attachment_kind),attachmentName:te(t.attachment_name),attachmentSize:Y(t.attachment_size),attachmentContentType:te(t.attachment_content_type),createdAt:B(t.created_at),pinned:t.pinned===!0,deleted:t.deleted===!0,system:t.system===!0,...t.status==="pending"?{status:"pending"}:{}}}function st(e){let t=K(e)?e:{};return{orderId:B(t.order_id),productId:te(t.product_id),replies:Y(t.replies),used:Y(t.used),left:Y(t.left),expiresAt:Ie(t.expires_at),expired:t.expired===!0}}function Fe(e){let t=K(e)?e:{};return{id:B(t.id),kind:t.kind==="channel"?"channel":"pack",repliesTotal:Y(t.replies_total),repliesUsed:Y(t.replies_used),repliesLeft:Y(t.replies_left),expiresAt:Ie(t.expires_at),composerLocked:t.composer_locked===!0,responseHours:Y(t.response_hours)}}function De(e){let t=K(e)?e:{};return{...Fe(t),channelId:te(t.channel_id),title:B(t.title),lastMessage:K(t.last_message)?pe(t.last_message):void 0,unread:Y(t.unread),productId:te(t.product_id),blocked:t.blocked===!0,packs:ee(t.packs).map(st),muted:t.muted===!0}}function it(e){let t=K(e)?e:{};return{id:B(t.id),name:B(t.name),topic:B(t.topic),welcome:B(t.welcome),whoCanPost:t.who_can_post==="members"?"members":"creator",productId:B(t.product_id),role:B(t.role),memberCount:Y(t.member_count),createdAt:B(t.created_at),blockLinks:t.block_links===!0,blockMedia:t.block_media===!0,cooldownSeconds:Y(t.cooldown_seconds)}}function lt(e){let t=K(e)?e:{},n=K(t.entitlements)?t.entitlements:{};return{email:B(t.email),threads:ee(t.threads).map(De),entitlements:{packs:ee(n.packs).map(a=>{let r=K(a)?a:{};return{productId:B(r.product_id),name:B(r.name),repliesLeftHint:Y(r.replies_left_hint),expiresAt:Ie(r.expires_at)}}),channels:ee(n.channels).map(a=>{let r=K(a)?a:{};return{productId:B(r.product_id),channelId:te(r.channel_id)}})},channels:ee(t.channels).map(it)}}var _lucidereact = require('lucide-react');var $e={pl:{inboxHeading:"Wiadomo\u015Bci",inboxIntro:"Rozmowy z tw\xF3rcami i kana\u0142y, do kt\xF3rych nale\u017Cysz.",inboxEmpty:"Nie masz jeszcze rozm\xF3w. Po zakupie pakietu konsultacji lub dost\u0119pu do spo\u0142eczno\u015Bci rozmowa pojawi si\u0119 tutaj.",inboxError:"Nie uda\u0142o si\u0119 wczyta\u0107 wiadomo\u015Bci.",loading:"Wczytywanie\u2026",retry:"Spr\xF3buj ponownie",back:"Wr\xF3\u0107",selectConversation:"Wybierz rozmow\u0119 z listy.",kindChat:"Czat",kindChannel:"Kana\u0142",startSection:"Do rozpocz\u0119cia",startChat:"Rozpocznij rozmow\u0119",openChannel:"Otw\xF3rz kana\u0142",channelNotReady:"Tw\xF3rca jeszcze nie otworzy\u0142 tego kana\u0142u.",chatFallbackTitle:"Czat z tw\xF3rc\u0105",channelFallbackTitle:"Kana\u0142",repliesLeftOne:"Zosta\u0142a {count} odpowied\u017A",repliesLeftFew:"Zosta\u0142y {count} odpowiedzi",repliesLeftMany:"Zosta\u0142o {count} odpowiedzi",noRepliesLeft:"Brak odpowiedzi w pakiecie",expiresOn:"Wa\u017Cny do {date}",expiredOn:"Wygas\u0142 {date}",responseHours:"Odpowied\u017A w ci\u0105gu {hours} h",unread:"Nieprzeczytane: {count}",members:"Cz\u0142onkowie: {count}",mutedBadge:"Wyciszony",noMessagesYet:"Brak wiadomo\u015Bci",emptyThread:"Napisz pierwsz\u0105 wiadomo\u015B\u0107. Tw\xF3rca odpowie w ramach Twojego pakietu.",emptyChannel:"W kanale nie ma jeszcze wiadomo\u015Bci.",privacyNote:"Wiadomo\u015Bci czyta druga strona rozmowy. Bitsnap przechowuje je przez 90 dni.",loadOlder:"Wcze\u015Bniejsze wiadomo\u015Bci",newMessages:"Nowe wiadomo\u015Bci \u2193",blockedNotice:"Tw\xF3rca zablokowa\u0142 mo\u017Cliwo\u015B\u0107 wysy\u0142ania wiadomo\u015Bci w tej rozmowie.",addAttachment:"Dodaj za\u0142\u0105cznik",photo:"Zdj\u0119cie",file:"Plik",removeAttachment:"Usu\u0144 za\u0142\u0105cznik",uploading:"Wysy\u0142anie pliku",attachmentLoadFailed:"Nie uda\u0142o si\u0119 wczyta\u0107 \u2014 pon\xF3w",you:"Ty",creator:"Tw\xF3rca",systemLabel:"Wiadomo\u015B\u0107 automatyczna",pinned:"Przypi\u0119ta",deletedPlaceholder:"Wiadomo\u015B\u0107 zosta\u0142a usuni\u0119ta",attachment:"Za\u0142\u0105cznik",composerLabel:"Wiadomo\u015B\u0107",composerPlaceholder:"Napisz wiadomo\u015B\u0107\u2026",send:"Wy\u015Blij",composerExpired:"Pakiet wygas\u0142, wi\u0119c nie mo\u017Cesz ju\u017C pisa\u0107 w tej rozmowie.",composerCreatorOnly:"W tym kanale pisze tylko tw\xF3rca.",composerMuted:"Masz wyciszone pisanie w tym kanale.",composerReadOnly:"Ten dost\u0119p pozwala tylko czyta\u0107.",lockRepliesTitle:"Odpowiedzi w pakiecie si\u0119 sko\u0144czy\u0142y",lockRepliesBody:"Mo\u017Cesz dalej pisa\u0107, ale tw\xF3rca odpowie dopiero po zakupie kolejnego pakietu.",lockExpiredTitle:"Pakiet wygas\u0142",lockExpiredBody:"Rozmowa zostaje do wgl\u0105du. Kup nowy pakiet, aby j\u0105 kontynuowa\u0107.",lockThreadTitle:"Nie masz pakietu odpowiedzi",lockThreadBody:"Kup pakiet, aby napisa\u0107 do tw\xF3rcy.",lockChannelTitle:"Kana\u0142 dla cz\u0142onk\xF3w",lockChannelBody:"Kup dost\u0119p, aby czyta\u0107 i pisa\u0107 w tym kanale.",buyPack:"Kup pakiet",buyAccess:"Kup dost\u0119p",buying:"Dodawanie do koszyka\u2026",buyError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",pending:"Wysy\u0142anie\u2026",notConfirmed:"Czekamy na potwierdzenie wys\u0142ania",rejectedLink:"Linki s\u0105 w tym kanale zablokowane. Usu\u0144 link i wy\u015Blij ponownie.",rejectedBannedWord:"Wiadomo\u015B\u0107 zawiera s\u0142owo zablokowane w tym kanale. Popraw j\u0105 i wy\u015Blij ponownie.",rejectedMedia:"Za\u0142\u0105czniki s\u0105 w tym kanale zablokowane.",rejectedCooldown:"Piszesz za szybko. Spr\xF3buj ponownie za {seconds} s.",rejectedBlocked:"Tw\xF3rca zablokowa\u0142 Ci mo\u017Cliwo\u015B\u0107 pisania w tym sklepie.",rejectedMuted:"Masz wyciszone pisanie w tym kanale.",rejectedReadOnly:"Ten dost\u0119p pozwala tylko czyta\u0107.",rejectedPackEmpty:"Pakiet nie ma ju\u017C odpowiedzi.",rejectedForbidden:"Nie mo\u017Cesz pisa\u0107 w tej rozmowie.",rejectedGeneric:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 wiadomo\u015Bci.",failedNetwork:"Brak po\u0142\u0105czenia. Wiadomo\u015B\u0107 nie zosta\u0142a wys\u0142ana.",editMessage:"Popraw",retrySend:"Wy\u015Blij ponownie",dismiss:"Odrzu\u0107",messageActions:"Opcje wiadomo\u015Bci",deleteMessage:"Usu\u0144 wiadomo\u015B\u0107",deleteConfirm:"Na pewno usun\u0105\u0107?",reportMessage:"Zg\u0142o\u015B wiadomo\u015B\u0107",conversationActions:"Opcje rozmowy",muteThread:"Wycisz powiadomienia",unmuteThread:"W\u0142\u0105cz powiadomienia",muteError:"Nie uda\u0142o si\u0119 zmieni\u0107 powiadomie\u0144.",reportConversation:"Zg\u0142o\u015B rozmow\u0119",reportTitle:"Zg\u0142o\u015B wiadomo\u015B\u0107",reportConversationTitle:"Zg\u0142o\u015B rozmow\u0119",reportReason:"Pow\xF3d zg\u0142oszenia",reasonSpam:"Spam",reasonAbuse:"N\u0119kanie lub obra\u017Aliwe tre\u015Bci",reasonIllegal:"Tre\u015Bci niezgodne z prawem",reasonOther:"Inny pow\xF3d",reportNote:"Opis (opcjonalnie)",reportSend:"Wy\u015Blij zg\u0142oszenie",reportCancel:"Anuluj",reportSent:"Dzi\u0119kujemy. Zg\u0142oszenie trafi\u0142o do moderacji.",reportError:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 zg\u0142oszenia. Spr\xF3buj ponownie.",liveLabel:"Nowe wiadomo\u015Bci pojawiaj\u0105 si\u0119 na bie\u017C\u0105co",pollingLabel:"Nowe wiadomo\u015Bci od\u015Bwie\u017Caj\u0105 si\u0119 co kilka sekund",errorNoToken:"Zaloguj si\u0119 w panelu klienta, aby zobaczy\u0107 rozmow\u0119.",errorUnauthorized:"Sesja wygas\u0142a. Zaloguj si\u0119 ponownie.",errorPlan:"Czat nie jest dost\u0119pny w tym sklepie.",errorNotFound:"Nie znaleziono tej rozmowy.",errorUnavailable:"Czat jest chwilowo niedost\u0119pny. Spr\xF3buj za chwil\u0119.",errorGeneric:"Nie uda\u0142o si\u0119 wczyta\u0107 rozmowy."},en:{inboxHeading:"Messages",inboxIntro:"Your conversations with creators and the channels you belong to.",inboxEmpty:"No conversations yet. When you buy a consultation pack or community access, it shows up here.",inboxError:"Your messages could not be loaded.",loading:"Loading\u2026",retry:"Try again",back:"Back",selectConversation:"Pick a conversation from the list.",kindChat:"Chat",kindChannel:"Channel",startSection:"Ready to start",startChat:"Start the conversation",openChannel:"Open the channel",channelNotReady:"The creator has not opened this channel yet.",chatFallbackTitle:"Chat with the creator",channelFallbackTitle:"Channel",repliesLeftOne:"{count} reply left",repliesLeftFew:"{count} replies left",repliesLeftMany:"{count} replies left",noRepliesLeft:"No replies left in your pack",expiresOn:"Valid until {date}",expiredOn:"Expired on {date}",responseHours:"Replies within {hours} h",unread:"Unread: {count}",members:"Members: {count}",mutedBadge:"Muted",noMessagesYet:"No messages yet",emptyThread:"Write the first message. The creator replies within your pack.",emptyChannel:"There are no messages in this channel yet.",privacyNote:"The other side of the conversation reads your messages. Bitsnap keeps them for 90 days.",loadOlder:"Earlier messages",newMessages:"New messages \u2193",blockedNotice:"The creator has blocked you from sending messages in this conversation.",addAttachment:"Add attachment",photo:"Photo",file:"File",removeAttachment:"Remove attachment",uploading:"Uploading file",attachmentLoadFailed:"Could not load \u2014 retry",you:"You",creator:"Creator",systemLabel:"Automatic message",pinned:"Pinned",deletedPlaceholder:"This message was deleted",attachment:"Attachment",composerLabel:"Message",composerPlaceholder:"Write a message\u2026",send:"Send",composerExpired:"Your pack has expired, so you can no longer write here.",composerCreatorOnly:"Only the creator posts in this channel.",composerMuted:"You are muted in this channel.",composerReadOnly:"This access is read only.",lockRepliesTitle:"Your pack has no replies left",lockRepliesBody:"You can keep writing, but the creator can reply only after you buy another pack.",lockExpiredTitle:"Your pack has expired",lockExpiredBody:"You can still read the conversation. Buy a new pack to continue it.",lockThreadTitle:"You have no reply pack",lockThreadBody:"Buy a pack to write to the creator.",lockChannelTitle:"Members-only channel",lockChannelBody:"Buy access to read and post in this channel.",buyPack:"Buy a pack",buyAccess:"Buy access",buying:"Adding to cart\u2026",buyError:"Could not add it to the cart. Try again.",pending:"Sending\u2026",notConfirmed:"Waiting for the send to be confirmed",rejectedLink:"Links are blocked in this channel. Remove the link and send again.",rejectedBannedWord:"Your message contains a word blocked in this channel. Edit it and send again.",rejectedMedia:"Attachments are blocked in this channel.",rejectedCooldown:"You are posting too fast. Try again in {seconds} s.",rejectedBlocked:"The creator has blocked you from posting in this shop.",rejectedMuted:"You are muted in this channel.",rejectedReadOnly:"This access is read only.",rejectedPackEmpty:"The pack has no replies left.",rejectedForbidden:"You cannot post in this conversation.",rejectedGeneric:"Your message could not be sent.",failedNetwork:"No connection. Your message was not sent.",editMessage:"Edit",retrySend:"Send again",dismiss:"Discard",messageActions:"Message options",deleteMessage:"Delete message",deleteConfirm:"Delete for sure?",reportMessage:"Report message",conversationActions:"Conversation options",muteThread:"Mute notifications",unmuteThread:"Unmute notifications",muteError:"Notifications could not be changed.",reportConversation:"Report conversation",reportTitle:"Report message",reportConversationTitle:"Report conversation",reportReason:"Reason",reasonSpam:"Spam",reasonAbuse:"Harassment or abusive content",reasonIllegal:"Illegal content",reasonOther:"Something else",reportNote:"Details (optional)",reportSend:"Send report",reportCancel:"Cancel",reportSent:"Thank you. Your report went to moderation.",reportError:"Your report could not be sent. Try again.",liveLabel:"New messages appear live",pollingLabel:"New messages refresh every few seconds",errorNoToken:"Log in to the customer panel to see this conversation.",errorUnauthorized:"Your session has expired. Log in again.",errorPlan:"Chat is not available in this shop.",errorNotFound:"This conversation was not found.",errorUnavailable:"Chat is unavailable right now. Try again in a moment.",errorGeneric:"The conversation could not be loaded."}};function re(e,t=_chunkQ337IQNAjs.f.call(void 0, )){return _chunkQ337IQNAjs.b.call(void 0, $e,t,e)}function G(e,t){return e.replace(/\{(\w+)\}/g,(n,a)=>a in t?String(t[a]):n)}function le(e,t,n=_chunkQ337IQNAjs.f.call(void 0, )){if(t<=0)return e.noRepliesLeft;let a="other";try{a=new Intl.PluralRules(n).select(t)}catch (e6){}let r=a==="one"?e.repliesLeftOne:a==="few"?e.repliesLeftFew:e.repliesLeftMany;return G(r,{count:t})}function de(e,t=_chunkQ337IQNAjs.f.call(void 0, )){let n=new Date(e);return Number.isNaN(n.getTime())?"":new Intl.DateTimeFormat(t,{day:"numeric",month:"numeric",year:"numeric"}).format(n)}function he(e,t=_chunkQ337IQNAjs.f.call(void 0, ),n=new Date){let a=new Date(e);if(Number.isNaN(a.getTime()))return"";let r=a.toDateString()===n.toDateString();return new Intl.DateTimeFormat(t,r?{hour:"2-digit",minute:"2-digit"}:{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(a)}function He(e,t,n){switch(t){case"moderation_link":return e.rejectedLink;case"moderation_banned_word":return e.rejectedBannedWord;case"moderation_media":return e.rejectedMedia;case"cooldown":return G(e.rejectedCooldown,{seconds:_nullishCoalesce(n, () => (30))});case"blocked":return e.rejectedBlocked;case"muted":return e.rejectedMuted;case"read_only":return e.rejectedReadOnly;case"pack_empty":case"replies_exhausted":return e.rejectedPackEmpty;case"forbidden":case"locked":return e.rejectedForbidden;case"network":case"unavailable":return e.failedNetwork;default:return e.rejectedGeneric}}var _jsxruntime = require('react/jsx-runtime');var Me="focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500";function We(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ze(e=0){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function je(e,t){typeof e.scrollTo=="function"?e.scrollTo({top:e.scrollHeight,behavior:t?"smooth":"auto"}):e.scrollTop=e.scrollHeight}var Z=_chunk6DEKVABTjs.g.call(void 0, "inline-flex min-h-11 items-center gap-2 rounded-md px-3 text-sm text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800",Me),ge=_chunk6DEKVABTjs.g.call(void 0, "inline-flex min-h-11 items-center justify-center gap-2 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white hover:bg-neutral-800 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white dark:text-neutral-900 dark:hover:bg-neutral-200",Me);function Pe({host:e,conversation:t,texts:n,locale:a,kind:r,title:c,onBack:v,onBuy:h,className:u}){let[i,g]=_react.useState.call(void 0, !1),[b,k]=_react.useState.call(void 0, null),[T,f]=_react.useState.call(void 0, ),[N,w]=_react.useState.call(void 0, ""),[p,y]=_react.useState.call(void 0, !1);_react.useEffect.call(void 0, ()=>{if(!p)return;let j=setTimeout(()=>y(!1),6e3);return()=>clearTimeout(j)},[p]);let L=c||_optionalChain([t, 'access', _2 => _2.channel, 'optionalAccess', _3 => _3.name])||(r==="channel"?n.channelFallbackTitle:n.chatFallbackTitle),A=bt(t,n,a);return _jsxruntime.jsxs.call(void 0, "section",{"data-bitsnap-chat":r,"aria-label":L,className:_chunk6DEKVABTjs.g.call(void 0, "flex h-full min-h-[28rem] w-full min-w-0 flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white text-neutral-900 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-50",u),children:[_jsxruntime.jsxs.call(void 0, "header",{className:"flex items-start gap-2 border-b border-neutral-200 px-3 py-2 dark:border-neutral-800",children:[v&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:v,"aria-label":n.back,className:_chunk6DEKVABTjs.g.call(void 0, Z,"w-11 justify-center px-0"),children:_jsxruntime.jsx.call(void 0, _lucidereact.ArrowLeft,{className:"size-5","aria-hidden":"true"})}),_jsxruntime.jsxs.call(void 0, "div",{className:"min-w-0 flex-1 py-1.5",children:[_jsxruntime.jsxs.call(void 0, "h2",{className:"flex items-center gap-2 text-base font-semibold",children:[_jsxruntime.jsx.call(void 0, "span",{className:"truncate",children:L}),_jsxruntime.jsx.call(void 0, kt,{live:t.live,texts:n})]}),A.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:A.map(j=>_jsxruntime.jsx.call(void 0, "span",{children:j},j))})]}),t.status==="ready"&&_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-label":n.conversationActions,"aria-expanded":i,onClick:()=>g(j=>!j),className:_chunk6DEKVABTjs.g.call(void 0, Z,"w-11 justify-center px-0"),children:_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontal,{className:"size-5","aria-hidden":"true"})})]}),i&&t.status==="ready"&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap gap-1 border-b border-neutral-200 bg-neutral-50 px-3 py-1 dark:border-neutral-800 dark:bg-neutral-950",children:[r==="thread"&&t.thread&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Z,onClick:async()=>{g(!1);try{await t.setMuted(!t.thread.muted),f(void 0)}catch (e7){f(n.muteError)}},children:t.thread.muted?n.unmuteThread:n.muteThread}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Z,onClick:()=>{g(!1),k({})},children:n.reportConversation})]}),t.status==="loading"&&_jsxruntime.jsx.call(void 0, wt,{texts:n}),t.status==="error"&&_jsxruntime.jsx.call(void 0, Ct,{conversation:t,texts:n}),t.status==="locked"&&t.lock&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 flex-col justify-center overflow-y-auto p-4",children:_jsxruntime.jsx.call(void 0, Ke,{host:e,lock:t.lock,kind:r,texts:n,locale:a,onBuy:h,prominent:!0})}),t.status==="ready"&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Tt,{conversation:t,texts:n,locale:a,kind:r,onReport:j=>k({messageId:j}),onEdit:j=>{w(j.body),t.discard(j.id)}}),T&&_jsxruntime.jsx.call(void 0, "p",{role:"status",className:"px-4 pb-2 text-xs text-red-700 dark:text-red-400",children:T}),t.lock&&_jsxruntime.jsx.call(void 0, "div",{className:"border-t border-neutral-200 p-3 dark:border-neutral-800",children:_jsxruntime.jsx.call(void 0, Ke,{host:e,lock:t.lock,kind:r,texts:n,locale:a,onBuy:h})}),b?_jsxruntime.jsx.call(void 0, Pt,{texts:n,messageId:b.messageId,onCancel:()=>k(null),onSubmit:async(j,x)=>{await t.report({messageId:b.messageId,reason:j,note:x}),k(null),f(void 0),y(!0)}}):_jsxruntime.jsx.call(void 0, jt,{conversation:t,texts:n,kind:r,draft:N,setDraft:w})]}),p&&_jsxruntime.jsx.call(void 0, "p",{role:"status",className:"border-t border-neutral-200 px-4 py-2 text-xs text-neutral-700 dark:border-neutral-800 dark:text-neutral-300",children:n.reportSent})]})}function bt(e,t,n){let a=[];if(e.thread&&e.thread.kind==="pack"){if(a.push(le(t,e.thread.repliesLeft,n)),e.thread.expiresAt){let r=de(e.thread.expiresAt,n);a.push(G(e.thread.composerLocked?t.expiredOn:t.expiresOn,{date:r}))}e.thread.responseHours>0&&a.push(G(t.responseHours,{hours:e.thread.responseHours})),e.thread.muted&&a.push(t.mutedBadge)}return e.channel&&(e.channel.topic&&a.push(e.channel.topic),e.channel.memberCount>0&&a.push(G(t.members,{count:e.channel.memberCount}))),a}function kt({live:e,texts:t}){if(e!=="live"&&e!=="polling")return null;let n=e==="live"?t.liveLabel:t.pollingLabel;return _jsxruntime.jsx.call(void 0, "span",{title:n,"data-live":e,className:_chunk6DEKVABTjs.g.call(void 0, "inline-block size-2 shrink-0 rounded-full",e==="live"?"bg-emerald-500":"bg-neutral-400 dark:bg-neutral-500"),children:_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:n})})}function wt({texts:e}){return _jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true","aria-label":e.loading,className:"flex flex-1 flex-col gap-3 p-4",children:[60,40,70].map((t,n)=>_jsxruntime.jsx.call(void 0, "div",{"aria-hidden":"true",style:{width:`${t}%`},className:_chunk6DEKVABTjs.g.call(void 0, "h-10 rounded-2xl bg-neutral-100 motion-safe:animate-pulse dark:bg-neutral-800",n===1&&"self-end")},n))})}function xt(e,t){switch(e){case"no_token":return t.errorNoToken;case"unauthorized":return t.errorUnauthorized;case"plan_required":return t.errorPlan;case"not_found":return t.errorNotFound;case"unavailable":case"network":return t.errorUnavailable;default:return t.errorGeneric}}function Ct({conversation:e,texts:t}){let n=_nullishCoalesce(_optionalChain([e, 'access', _4 => _4.error, 'optionalAccess', _5 => _5.code]), () => ("")),a=n!=="no_token"&&n!=="plan_required"&&n!=="unauthorized";return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-1 flex-col items-start justify-center gap-3 p-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700 dark:text-neutral-300",children:xt(n,t)}),a&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:ge,onClick:e.reload,children:t.retry})]})}function Ke({host:e,lock:t,kind:n,texts:a,locale:r,onBuy:c,prominent:v}){let[h,u]=_react.useState.call(void 0, !1),[i,g]=_react.useState.call(void 0, ""),[b,k]=_react.useState.call(void 0, String((_nullishCoalesce(t.priceCents, () => (0)))/100)),T=b.trim().replace(",","."),f=/^\d+(\.\d{0,2})?$/.test(T)?Math.round(Number(T)*100):NaN,N=t.priceType==="pay_what_you_want",w=_nullishCoalesce(t.minimumCents, () => (0)),p=_nullishCoalesce(t.maximumCents, () => (Number.MAX_SAFE_INTEGER)),y=Number.isInteger(f)&&f>=w&&f<=p&&(f>0||t.freeClaimLimit!=null),L=t.freeClaimLimit!=null&&(t.priceType==="free"||N&&w===0&&f===0),[A,j]=_react.useState.call(void 0, ""),[x,d]=_react.useState.call(void 0, ""),[R,_]=_react.useState.call(void 0, !1),[P,s]=_react.useState.call(void 0, null),[l,m]=_react.useState.call(void 0, 0),[C,O]=_react.useState.call(void 0, 0),D=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{R&&_optionalChain([D, 'access', _6 => _6.current, 'optionalAccess', _7 => _7.focus, 'call', _8 => _8()])},[R]),_react.useEffect.call(void 0, ()=>{if(C<=0)return;let q=window.setTimeout(()=>O(C-1),1e3);return()=>window.clearTimeout(q)},[C]);let H=()=>{_(!1),d(""),s(null),m(q=>q+1),g("")},F=r.toLowerCase().startsWith("en"),[E,J]=t.reason==="replies"?[a.lockRepliesTitle,a.lockRepliesBody]:t.reason==="expired"?[a.lockExpiredTitle,a.lockExpiredBody]:n==="channel"?[a.lockChannelTitle,a.lockChannelBody]:[a.lockThreadTitle,a.lockThreadBody],ne=n==="channel"?a.buyAccess:a.buyPack,U=c!=null&&t.productId!=null;return _jsxruntime.jsxs.call(void 0, "div",{"data-testid":"chat-lock","data-lock":t.reason,className:_chunk6DEKVABTjs.g.call(void 0, "flex gap-3 rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",v?"flex-col items-start p-5":"flex-col sm:flex-row sm:items-center"),children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:_chunk6DEKVABTjs.g.call(void 0, "shrink-0 text-neutral-500 dark:text-neutral-400",v?"size-6":"hidden size-5 sm:block"),"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"min-w-0 flex-1",children:[_jsxruntime.jsx.call(void 0, "p",{className:_chunk6DEKVABTjs.g.call(void 0, "font-semibold",v?"text-lg":"text-sm"),children:E}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-0.5 text-sm text-neutral-600 dark:text-neutral-300",children:J}),L&&_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 grid max-w-sm gap-2",children:[_jsxruntime.jsxs.call(void 0, "label",{className:"grid gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{children:F?"Email":"E-mail"}),_jsxruntime.jsx.call(void 0, "input",{type:"email",autoComplete:"email",value:A,onChange:q=>{j(q.currentTarget.value),H()},disabled:h,className:"h-11 rounded-md border border-neutral-300 bg-white px-3 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-50"})]}),R?_jsxruntime.jsxs.call(void 0, "label",{className:"grid gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{children:F?"Email code":"Kod z\xA0e-maila"}),_jsxruntime.jsx.call(void 0, "input",{ref:D,inputMode:"numeric",autoComplete:"one-time-code",value:x,onChange:q=>d(q.currentTarget.value),className:"h-11 rounded-md border border-neutral-300 bg-white px-3 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-50"})]}):A.includes("@")?_jsxruntime.jsx.call(void 0, _chunkZ3YOJ6NZjs.a,{host:e,action:"free_chat_claim",locale:r,onToken:s,onFailure:()=>s(null)},l):null,R&&_jsxruntime.jsxs.call(void 0, "button",{type:"button",disabled:h||C>0,className:"min-h-11 text-sm underline disabled:opacity-50",onClick:H,children:[F?"Request a new code":"Popro\u015B o\xA0nowy kod",C>0?` (${C}s)`:""]})]}),N&&_jsxruntime.jsxs.call(void 0, "label",{className:"mt-3 grid max-w-xs gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{children:F?`Amount (${(w/100).toFixed(2)}\u2013${Number.isFinite(p)?(p/100).toFixed(2):"\u221E"} PLN)`:`Kwota (${(w/100).toFixed(2)}\u2013${Number.isFinite(p)?(p/100).toFixed(2):"\u221E"} z\u0142)`}),_jsxruntime.jsx.call(void 0, "input",{"aria-label":F?"Amount":"Kwota",inputMode:"decimal",type:"text",min:w/100,max:Number.isFinite(p)?p/100:void 0,step:"0.01",value:b,onChange:q=>k(q.currentTarget.value),onBlur:()=>{Number.isFinite(f)&&k((f/100).toFixed(2))},className:"h-11 rounded-md border border-neutral-300 bg-white px-3 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-50"}),!y&&_jsxruntime.jsx.call(void 0, "span",{role:"alert",className:"text-xs text-red-700 dark:text-red-400",children:F?f===0&&t.freeClaimLimit==null?"Free claims are unavailable. Enter a positive amount.":"Enter an amount within the range.":f===0&&t.freeClaimLimit==null?"Darmowy odbi\xF3r jest niedost\u0119pny. Wpisz kwot\u0119 wi\u0119ksz\u0105 od zera.":"Kwota musi mie\u015Bci\u0107 si\u0119 w\xA0podanym zakresie."})]}),t.welcome&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 whitespace-pre-wrap text-sm",children:t.welcome}),i&&_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"mt-2 text-sm text-red-700 dark:text-red-400",children:i})]}),U&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunk6DEKVABTjs.g.call(void 0, ge,"shrink-0"),disabled:h||N&&!y||L&&(!A.includes("@")||!R&&P===null||R&&!x),"aria-busy":h||void 0,onClick:async()=>{u(!0),g("");try{L?(await c({...t,...N?{amount:f}:{},email:A,...R?{code:x}:{turnstileToken:P}}),R||(_(!0),O(60))):await c({...t,...N?{amount:f}:{}})}catch(q){g(zt(q,r,a.buyError)),R||(s(null),m(ot=>ot+1))}finally{u(!1)}},children:h?a.buying:N?F?"Choose what you pay":"Kup pakiet, p\u0142ac\u0105c, ile chcesz":L?R?F?"Claim for free":"Odbierz za darmo":F?"Send code":"Wy\u015Blij kod":ne})]})}function vt(e,t,n,a){return t?a.you:n==="thread"?a.creator:e.authorEmail.split("@")[0]||a.creator}function Tt({conversation:e,texts:t,locale:n,kind:a,onReport:r,onEdit:c}){let v=_react.useRef.call(void 0, null),h=_react.useRef.call(void 0, !0),u=_react.useRef.call(void 0, !1),i=_react.useRef.call(void 0, null),g=_react.useRef.call(void 0, null),[b,k]=_react.useState.call(void 0, ()=>new Set),[T,f]=_react.useState.call(void 0, !1),N=e.messages.length,w=_optionalChain([e, 'access', _9 => _9.messages, 'access', _10 => _10[N-1], 'optionalAccess', _11 => _11.id]);return _react.useEffect.call(void 0, ()=>{if(e.status!=="ready")return;let p=new Set(e.messages.map(x=>x.id)),y=i.current;i.current=p;let L=e.messages.reduce((x,d)=>x==null||d.createdAt<x?d.createdAt:x,null),A=g.current;if(g.current=L,!y)return;let j=e.messages.filter(x=>!y.has(x.id)&&(A==null||x.createdAt>=A));!j.length||e.loadingOlder||(k(x=>new Set([...x,...j.map(d=>d.id)])),h.current?f(!1):f(!0))},[e.messages,e.loadingOlder]),_react.useLayoutEffect.call(void 0, ()=>{let p=v.current;if(p){if(h.current){let y=We();je(p,!y&&u.current)}u.current=!0}},[N,w]),_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex min-h-0 flex-1 flex-col",children:[T&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>{let p=v.current;p&&je(p,!We()),h.current=!0,f(!1)},className:"absolute bottom-3 left-1/2 z-10 -translate-x-1/2 rounded-full bg-neutral-900 px-3 py-1.5 text-xs font-medium text-white shadow-md dark:bg-neutral-100 dark:text-neutral-900",children:_nullishCoalesce(t.newMessages, () => ("Nowe wiadomo\u015Bci \u2193"))}),_jsxruntime.jsxs.call(void 0, "div",{ref:v,role:"log","aria-live":"polite","aria-relevant":"additions",onLoadCapture:()=>{let p=v.current;p&&h.current&&je(p,!1)},onScroll:p=>{let y=p.currentTarget;h.current=y.scrollHeight-y.scrollTop-y.clientHeight<80},className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto overscroll-contain px-3 py-4 sm:px-4",children:[e.hasMore&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>{h.current=!1,e.loadOlder()},disabled:e.loadingOlder,className:_chunk6DEKVABTjs.g.call(void 0, Z,"self-center text-xs"),children:e.loadingOlder?t.loading:t.loadOlder}),N===0&&_jsxruntime.jsxs.call(void 0, "div",{className:"m-auto max-w-sm text-center","data-testid":"chat-empty",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",children:t.noMessagesYet}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:a==="channel"?t.emptyChannel:t.emptyThread}),_optionalChain([e, 'access', _12 => _12.channel, 'optionalAccess', _13 => _13.welcome])&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 whitespace-pre-wrap text-sm",children:e.channel.welcome})]}),e.messages.map(p=>_jsxruntime.jsx.call(void 0, Nt,{message:p,mine:p.authorEmail.toLowerCase()===e.me,kind:a,texts:t,locale:n,getAttachmentURL:e.getAttachmentURL,animateEntry:b.has(p.id),onDelete:()=>e.deleteMessage(p.id),onReport:()=>r(p.id),onRetry:()=>void e.retry(p.id),onDiscard:()=>e.discard(p.id),onEdit:()=>c(p)},p.id))]})]})}function Nt({message:e,mine:t,kind:n,texts:a,locale:r,getAttachmentURL:c,animateEntry:v=!1,onDelete:h,onReport:u,onRetry:i,onDiscard:g,onEdit:b}){let[k,T]=_react.useState.call(void 0, !1),[f,N]=_react.useState.call(void 0, !1),[w,p]=_react.useState.call(void 0, ),[y,L]=_react.useState.call(void 0, !1),[A,j]=_react.useState.call(void 0, 0),x=_react.useRef.call(void 0, 0),d=()=>{p(void 0),L(!1),j(m=>m+1)},R=async m=>{if(w&&Date.now()<x.current)return;m.preventDefault();let C=window.open("about:blank","_blank");C&&(C.opener=null);try{let O=await c(e);x.current=Date.now()+5e4,p(O),C&&(C.location.href=O)}catch (e8){_optionalChain([C, 'optionalAccess', _14 => _14.close, 'call', _15 => _15()]),L(!0)}},_=e.local;if(_react.useEffect.call(void 0, ()=>{if(!e.attachmentKey||e.deleted||e.local)return;let m=!1;return L(!1),c(e).then(C=>{m||(x.current=Date.now()+5e4,p(C))}).catch(()=>{m||L(!0)}),()=>{m=!0}},[e.attachmentKey,e.deleted,!!e.local,c,A]),e.system)return _jsxruntime.jsxs.call(void 0, "div",{"data-message-id":e.id,className:"mx-auto max-w-md text-center text-xs text-neutral-600 dark:text-neutral-400",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:a.systemLabel}),e.body&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-0.5 whitespace-pre-wrap",children:e.body})]});let P=_optionalChain([_, 'optionalAccess', _16 => _16.state])==="rejected"||_optionalChain([_, 'optionalAccess', _17 => _17.state])==="failed",s=_optionalChain([_, 'optionalAccess', _18 => _18.state])==="pending"||_optionalChain([_, 'optionalAccess', _19 => _19.state])==="unconfirmed",l=!_&&!e.deleted;return _jsxruntime.jsxs.call(void 0, "div",{"data-message-id":e.id,"data-state":_nullishCoalesce(_optionalChain([_, 'optionalAccess', _20 => _20.state]), () => ((e.deleted?"deleted":"stored"))),className:_chunk6DEKVABTjs.g.call(void 0, "group flex max-w-[85%] flex-col gap-1 sm:max-w-[75%]",v&&"motion-safe:animate-[bitsnap-chat-message-enter_190ms_ease-out]",t?"items-end self-end":"items-start self-start"),children:[_jsxruntime.jsxs.call(void 0, "div",{className:_chunk6DEKVABTjs.g.call(void 0, "flex items-end gap-1",t&&"flex-row-reverse"),children:[_jsxruntime.jsx.call(void 0, "div",{className:_chunk6DEKVABTjs.g.call(void 0, "min-w-0 rounded-2xl px-3.5 py-2 text-sm leading-relaxed transition-opacity duration-200 ease-out motion-reduce:transition-none",e.deleted?"border border-dashed border-neutral-300 bg-transparent italic text-neutral-500 dark:border-neutral-700 dark:text-neutral-400":t?"bg-neutral-900 text-white dark:bg-neutral-100 dark:text-neutral-900":"bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50",s&&"opacity-70",P&&"border border-red-600 dark:border-red-400"),children:e.deleted?a.deletedPlaceholder:_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-pre-wrap break-words",children:e.body}),!e.deleted&&e.attachmentName&&(e.attachmentKind==="image"?y?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:d,className:"mt-2 text-xs underline",children:a.attachmentLoadFailed}):w?_jsxruntime.jsx.call(void 0, "a",{href:w,onClick:R,target:"_blank",rel:"noreferrer",children:_jsxruntime.jsx.call(void 0, "img",{src:w,onError:()=>{Date.now()>=x.current?d():(p(void 0),L(!0))},alt:e.attachmentName,className:"mt-2 max-h-48 rounded-lg object-cover"})}):_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-label":a.loading,className:"mt-2 h-32 w-48 animate-pulse rounded-lg bg-current/10 motion-reduce:animate-none"}):_jsxruntime.jsxs.call(void 0, "a",{href:_nullishCoalesce(w, () => ("#")),onClick:R,download:e.attachmentName,className:"mt-2 flex max-w-56 items-center gap-2 rounded-lg border border-neutral-300/60 px-2 py-1.5 text-xs dark:border-neutral-700",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Paperclip,{className:"size-3.5 shrink-0","aria-hidden":"true"}),_jsxruntime.jsx.call(void 0, "span",{className:"min-w-0 flex-1 truncate",children:e.attachmentName}),_jsxruntime.jsx.call(void 0, "span",{children:Ze(e.attachmentSize)})]})),y&&e.attachmentKind!=="image"&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:d,className:"mt-1 text-xs underline",children:a.attachmentLoadFailed}),e.attachmentName&&_optionalChain([_, 'optionalAccess', _21 => _21.state])==="pending"&&_.uploadProgress!=null&&_jsxruntime.jsxs.call(void 0, "p",{className:"mt-1 text-[11px] opacity-75",children:[a.uploading," ",_.uploadProgress,"%"]})]})}),l&&_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-label":a.messageActions,"aria-expanded":k,onClick:()=>{T(m=>!m),N(!1)},className:_chunk6DEKVABTjs.g.call(void 0, "inline-flex size-11 shrink-0 items-center justify-center rounded-md text-neutral-500 opacity-100 hover:bg-neutral-100 sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100 dark:text-neutral-400 dark:hover:bg-neutral-800",k&&"sm:opacity-100",Me),children:_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontal,{className:"size-4","aria-hidden":"true"})})]}),_jsxruntime.jsxs.call(void 0, "p",{className:"flex items-center gap-1.5 px-1 text-[11px] text-neutral-500 dark:text-neutral-400",children:[e.pinned&&_jsxruntime.jsxs.call(void 0, "span",{className:"inline-flex items-center gap-0.5",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Pin,{className:"size-3","aria-hidden":"true"}),a.pinned]}),_jsxruntime.jsx.call(void 0, "span",{children:vt(e,t,n,a)}),_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"\xB7"}),s?_jsxruntime.jsxs.call(void 0, "span",{className:"inline-flex items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Clock,{className:"size-3","aria-hidden":"true"}),_optionalChain([_, 'optionalAccess', _22 => _22.state])==="pending"?a.pending:a.notConfirmed]}):_jsxruntime.jsx.call(void 0, "time",{dateTime:e.createdAt,children:he(e.createdAt,r)})]}),P&&_jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:_chunk6DEKVABTjs.g.call(void 0, "flex flex-col gap-1",t?"items-end":"items-start"),children:[_jsxruntime.jsxs.call(void 0, "p",{className:"flex items-start gap-1 text-xs text-red-700 dark:text-red-400",children:[_jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle,{className:"mt-px size-3.5 shrink-0","aria-hidden":"true"}),He(a,_nullishCoalesce(_optionalChain([_, 'optionalAccess', _23 => _23.reason]), () => ("")),_optionalChain([_, 'optionalAccess', _24 => _24.retryAfter]))]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap gap-1",children:[_optionalChain([_, 'optionalAccess', _25 => _25.state])==="failed"||_optionalChain([_, 'optionalAccess', _26 => _26.reason])==="cooldown"?_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunk6DEKVABTjs.g.call(void 0, Z,"text-xs"),onClick:i,children:a.retrySend}):_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunk6DEKVABTjs.g.call(void 0, Z,"text-xs"),onClick:b,children:a.editMessage}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunk6DEKVABTjs.g.call(void 0, Z,"text-xs"),onClick:g,children:a.dismiss})]})]}),k&&l&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-wrap gap-1",children:t?_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunk6DEKVABTjs.g.call(void 0, Z,"text-xs text-red-700 dark:text-red-400"),onClick:async()=>{if(!f){N(!0);return}T(!1),await h().catch(()=>{})},children:f?a.deleteConfirm:a.deleteMessage}):_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunk6DEKVABTjs.g.call(void 0, Z,"text-xs"),onClick:()=>{T(!1),u()},children:a.reportMessage})})]})}function It(e,t,n){if(t==="thread"&&_optionalChain([e, 'access', _27 => _27.thread, 'optionalAccess', _28 => _28.blocked]))return n.blockedNotice;if(t==="thread"&&_optionalChain([e, 'access', _29 => _29.thread, 'optionalAccess', _30 => _30.composerLocked]))return n.composerExpired;if(t==="channel"&&e.channel){if(e.channel.role==="muted")return n.composerMuted;if(e.channel.whoCanPost==="creator"&&e.channel.role!=="creator")return n.composerCreatorOnly}}function jt({conversation:e,texts:t,kind:n,draft:a,setDraft:r}){let c=_react.useId.call(void 0, ),v=_react.useRef.call(void 0, null),h=_react.useRef.call(void 0, null),u=_react.useRef.call(void 0, null),[i,g]=_react.useState.call(void 0, ),[b,k]=_react.useState.call(void 0, !1),[T,f]=_react.useState.call(void 0, !1),[N,w]=_react.useState.call(void 0, ".pdf,.zip,.txt,.docx,.xlsx"),p=It(e,n,t);_react.useEffect.call(void 0, ()=>()=>{u.current&&clearTimeout(u.current)},[]);let y=x=>{u.current&&clearTimeout(u.current),u.current=null,k(!1),g(x)},L=()=>{!i||b||(k(!0),u.current=setTimeout(()=>{g(void 0),k(!1),u.current=null},140))};if(_react.useLayoutEffect.call(void 0, ()=>{let x=v.current;x&&(x.style.height="auto",x.style.height=`${Math.min(x.scrollHeight,160)}px`)},[a]),p)return _jsxruntime.jsx.call(void 0, "p",{"data-testid":"chat-composer-blocked",className:"border-t border-neutral-200 px-4 py-3 text-sm text-neutral-600 dark:border-neutral-800 dark:text-neutral-400",children:p});let A=x=>{_optionalChain([x, 'optionalAccess', _31 => _31.preventDefault, 'call', _32 => _32()]);let d=a.trim();!d&&!i||(r(""),g(void 0),e.send(d,i),requestAnimationFrame(()=>_optionalChain([v, 'access', _33 => _33.current, 'optionalAccess', _34 => _34.focus, 'call', _35 => _35()])))},j=x=>{x.key==="Enter"&&!x.shiftKey&&!x.nativeEvent.isComposing&&(x.preventDefault(),A())};return _jsxruntime.jsxs.call(void 0, "form",{onSubmit:A,className:"border-t border-neutral-200 px-3 pb-3 pt-2 dark:border-neutral-800",children:[e.messages.length===0&&_jsxruntime.jsx.call(void 0, "p",{className:"pb-2 text-xs text-neutral-500 dark:text-neutral-400",children:t.privacyNote}),i&&_jsxruntime.jsxs.call(void 0, "div",{className:_chunk6DEKVABTjs.g.call(void 0, "mb-2 flex max-w-sm items-center gap-2 rounded-lg border border-neutral-300 bg-neutral-50 px-3 py-2 text-xs text-neutral-800 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100",b?"chat-preview-exit":"chat-preview-enter"),children:[_jsxruntime.jsx.call(void 0, "span",{className:"min-w-0 flex-1 truncate",children:i.name}),_jsxruntime.jsx.call(void 0, "span",{className:"text-neutral-500 dark:text-neutral-400",children:Ze(i.size)}),_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-label":t.removeAttachment,onClick:L,disabled:b,className:"rounded p-1 hover:bg-neutral-200 disabled:cursor-default dark:hover:bg-neutral-800",children:_jsxruntime.jsx.call(void 0, _lucidereact.X,{className:"size-3.5"})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-end gap-2",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"relative",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-label":t.addAttachment,"aria-expanded":T,onClick:()=>f(x=>!x),className:_chunk6DEKVABTjs.g.call(void 0, Z,"h-11 w-11 justify-center px-0 transition-transform duration-150 motion-safe:active:scale-95 motion-reduce:transition-none"),children:_jsxruntime.jsx.call(void 0, _lucidereact.Plus,{className:"size-5","aria-hidden":"true"})}),T&&_jsxruntime.jsxs.call(void 0, "div",{role:"menu",className:"absolute bottom-full left-0 z-20 mb-2 min-w-36 rounded-lg border border-neutral-200 bg-white p-1 shadow-lg dark:border-neutral-700 dark:bg-neutral-900",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",role:"menuitem",className:"block w-full rounded px-3 py-2 text-left text-sm hover:bg-neutral-100 dark:hover:bg-neutral-800",onClick:()=>{w("image/jpeg,image/png,image/webp,image/gif"),h.current&&(h.current.accept="image/jpeg,image/png,image/webp,image/gif",h.current.click()),f(!1)},children:t.photo}),_jsxruntime.jsx.call(void 0, "button",{type:"button",role:"menuitem",className:"block w-full rounded px-3 py-2 text-left text-sm hover:bg-neutral-100 dark:hover:bg-neutral-800",onClick:()=>{w(".pdf,.zip,.txt,.docx,.xlsx"),h.current&&(h.current.accept=".pdf,.zip,.txt,.docx,.xlsx",h.current.click()),f(!1)},children:t.file})]}),_jsxruntime.jsx.call(void 0, "input",{ref:h,hidden:!0,type:"file",accept:N,onChange:x=>{let d=_optionalChain([x, 'access', _36 => _36.target, 'access', _37 => _37.files, 'optionalAccess', _38 => _38[0]]);d&&y(d),x.currentTarget.value=""}})]}),_jsxruntime.jsx.call(void 0, "label",{htmlFor:c,className:"sr-only",children:t.composerLabel}),_jsxruntime.jsx.call(void 0, "textarea",{id:c,ref:v,rows:1,value:a,onChange:x=>r(x.target.value),onKeyDown:j,placeholder:t.composerPlaceholder,className:"max-h-40 min-h-11 flex-1 resize-none rounded-xl border border-neutral-300 bg-white px-3 py-2.5 text-sm text-neutral-900 placeholder:text-neutral-500 focus-visible:border-neutral-500 focus-visible:outline-none dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-400"}),_jsxruntime.jsx.call(void 0, "button",{type:"submit","aria-label":t.send,disabled:a.trim().length===0&&!i,className:_chunk6DEKVABTjs.g.call(void 0, ge,"w-11 px-0 transition-[transform,opacity] duration-150 ease-out motion-safe:active:scale-95 disabled:scale-100 motion-reduce:transition-none"),children:_jsxruntime.jsx.call(void 0, _lucidereact.SendHorizontal,{className:"size-5","aria-hidden":"true"})})]})]})}var Mt=["spam","abuse","illegal","other"];function Pt({texts:e,messageId:t,onCancel:n,onSubmit:a}){let[r,c]=_react.useState.call(void 0, "spam"),[v,h]=_react.useState.call(void 0, ""),[u,i]=_react.useState.call(void 0, !1),[g,b]=_react.useState.call(void 0, !1),k=_react.useId.call(void 0, ),T={spam:e.reasonSpam,abuse:e.reasonAbuse,illegal:e.reasonIllegal,other:e.reasonOther};return _jsxruntime.jsxs.call(void 0, "form",{"data-testid":"chat-report",className:"flex flex-col gap-3 border-t border-neutral-200 p-4 dark:border-neutral-800",onSubmit:async f=>{f.preventDefault(),i(!0),b(!1);try{await a(r,v.trim())}catch (e9){b(!0)}finally{i(!1)}},children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-semibold",children:t?e.reportTitle:e.reportConversationTitle}),_jsxruntime.jsxs.call(void 0, "fieldset",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "legend",{className:"mb-1 text-xs text-neutral-600 dark:text-neutral-400",children:e.reportReason}),Mt.map(f=>_jsxruntime.jsxs.call(void 0, "label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[_jsxruntime.jsx.call(void 0, "input",{type:"radio",name:"chat-report-reason",value:f,checked:r===f,onChange:()=>c(f),className:"size-4 accent-neutral-900 dark:accent-white"}),T[f]]},f))]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "label",{htmlFor:k,className:"text-xs text-neutral-600 dark:text-neutral-400",children:e.reportNote}),_jsxruntime.jsx.call(void 0, "textarea",{id:k,rows:2,maxLength:1e3,value:v,onChange:f=>h(f.target.value),className:"resize-none rounded-xl border border-neutral-300 bg-white px-3 py-2 text-sm focus-visible:border-neutral-500 focus-visible:outline-none dark:border-neutral-700 dark:bg-neutral-950"})]}),g&&_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"text-sm text-red-700 dark:text-red-400",children:e.reportError}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap justify-end gap-2",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Z,onClick:n,children:e.reportCancel}),_jsxruntime.jsx.call(void 0, "button",{type:"submit",className:ge,disabled:u,"aria-busy":u||void 0,children:e.reportSend})]})]})}function zt(e,t,n){let a=e instanceof Error?e.message:"",r=t.toLowerCase().startsWith("en");return_nullishCoalesce(_optionalChain([{"amount-below-minimum":["Kwota jest ni\u017Csza od minimalnej.","The amount is below the minimum."],"amount-above-maximum":["Kwota przekracza maksymaln\u0105.","The amount is above the maximum."],"amount-below-gateway-minimum":["Kwota jest za niska dla dost\u0119pnych p\u0142atno\u015Bci.","The amount is too low for available payment methods."],"amount-invalid":["Podaj prawid\u0142ow\u0105 kwot\u0119.","Enter a valid amount."],"email-verification-required":["Potwierd\u017A adres e-mail, aby odebra\u0107 pakiet.","Verify your email to claim this pack."],"free-claim-exists":["Ten adres e-mail wykorzysta\u0142 ju\u017C limit darmowych odbior\xF3w.","This email has reached the free claim limit."],"free-order-not-supported":["Nie mo\u017Cna zrealizowa\u0107 tego darmowego zam\xF3wienia.","This free order cannot be completed."],"captcha-required":["Potwierd\u017A, \u017Ce nie jeste\u015B robotem.","Complete the security check."],"captcha-invalid":["Weryfikacja wygas\u0142a. Spr\xF3buj ponownie.","The security check expired. Try again."],"rate-limited":["Zbyt wiele pr\xF3b. Spr\xF3buj ponownie za chwil\u0119.","Too many attempts. Try again shortly."],"incorrect-code":["Nieprawid\u0142owy kod. Sprawd\u017A wiadomo\u015B\u0107 i\xA0spr\xF3buj ponownie.","The code is incorrect. Check your email and try again."],"too-many-attempts":["Popro\u015B o\xA0nowy kod za kilka minut.","Request a new code in a few minutes."],unavailable:["Weryfikacja jest chwilowo niedost\u0119pna.","Verification is temporarily unavailable."]}, 'access', _39 => _39[a], 'optionalAccess', _40 => _40[r?1:0]]), () => (n))}var Lt=()=>Promise.resolve().then(() => _interopRequireWildcard(require("@nats-io/nats-core")));function ze(e){let t=_nullishCoalesce(e.pollIntervalMs, () => (8e3)),n=_nullishCoalesce(e.retryMs, () => (6e4)),a=_nullishCoalesce(e.loadNats, () => (Lt)),r=`.${e.kind}.${e.id}`,c=!1,v,h="",u,i,g,b=()=>{u!=null&&clearInterval(u),u=void 0},k=()=>{c||(e.onMode("polling"),u==null&&(u=setInterval(()=>{e.poll().catch(()=>{})},t)),i==null&&(i=setTimeout(()=>{i=void 0,f()},n)))},T=N=>{g!=null&&clearTimeout(g);let w=Date.parse(N);if(!Number.isFinite(w))return;let p=Math.max(5e3,w-Date.now()-6e4);g=setTimeout(async()=>{if(!c)try{let y=await e.client.realtimeToken({fresh:!0});h=y.jwt,T(y.expiresAt)}catch (e10){}},p)};async function f(){if(!c){if(typeof WebSocket>"u"){k();return}e.onMode("connecting");try{let N=await e.client.realtimeToken(),w=N.subjects.find(j=>j.endsWith(r));if(w||(N=await e.client.realtimeToken({fresh:!0}),w=N.subjects.find(j=>j.endsWith(r))),!w||!N.jwt)throw new Error("subject not granted");h=N.jwt;let p=await a();if(c)return;let y=e.realtimeUrl?[e.realtimeUrl]:N.servers.length>0?N.servers:[Te],L=await p.wsconnect({servers:y,authenticator:p.jwtAuthenticator(()=>h),name:"bitsnap-react/chat",reconnect:!0,maxReconnectAttempts:5});if(c){L.close().catch(()=>{});return}v=L;let A=new TextDecoder;L.subscribe(w,{callback:(j,x)=>{if(!j)try{let d=Ne(JSON.parse(A.decode(x.data)));d&&e.onEvent(d)}catch (e11){}}}),L.closed().then(()=>{v===L&&(v=void 0,k())}),T(N.expiresAt),b(),e.onMode("live"),e.poll().catch(()=>{})}catch (e12){k()}}}return f(),()=>{c=!0,b(),i!=null&&clearTimeout(i),g!=null&&clearTimeout(g);let N=v;v=void 0,N&&N.close().catch(()=>{})}}var Le=50,ae={status:"loading",messages:[],hasMore:!1,loadingOlder:!1,live:"off"};function Rt(){let e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let a=0;a<16;a++)t[a]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function ce(e,t){let n=new Map(e.map(a=>[a.id,a]));for(let a of t){let r=n.get(a.id);if(a.status==="pending"){if(r&&!r.local)continue;n.set(a.id,{...a,retryFile:_optionalChain([r, 'optionalAccess', _41 => _41.retryFile]),local:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _42 => _42.local]), () => ({state:"pending"}))});continue}_optionalChain([r, 'optionalAccess', _43 => _43.local])&&r.local.state!=="pending"&&r.local.state!=="unconfirmed"||n.set(a.id,{...a,local:void 0})}return[...n.values()].sort((a,r)=>{let c=Date.parse(a.createdAt)||0,v=Date.parse(r.createdAt)||0;return c-v})}function Re(e){if(e.kind==="pack"){if(e.composerLocked)return{reason:"expired",productId:e.productId};if(e.repliesLeft<=0)return{reason:"replies",productId:e.productId}}}function Xe(e,t,n){let a=Number(e.data.price_cents);return{reason:t,productId:typeof e.data.product_id=="string"&&e.data.product_id?e.data.product_id:n,priceCents:Number.isFinite(a)&&a>0?a:void 0,priceType:e.data.price_type==="free"||e.data.price_type==="pay_what_you_want"?e.data.price_type:"one_time",minimumCents:Number.isFinite(Number(e.data.price_min_cents))?Number(e.data.price_min_cents):void 0,maximumCents:Number.isFinite(Number(e.data.price_max_cents))?Number(e.data.price_max_cents):void 0,freeClaimLimit:Number.isFinite(Number(e.data.free_claim_limit))?Number(e.data.free_claim_limit):void 0,welcome:typeof e.data.welcome=="string"?e.data.welcome:void 0}}function be(e){return e instanceof $?e:new $("internal_error",0)}function ke(e){let{client:t,target:n}=e,[a,r]=_react.useState.call(void 0, ae),[c,v]=_react.useState.call(void 0, 0),h=_react.useRef.call(void 0, a);h.current=a;let u=_react.useRef.call(void 0, new Set),i=_react.useRef.call(void 0, void 0),g=_react.useRef.call(void 0, void 0),b=n.kind==="thread"?`t:${_nullishCoalesce(n.threadId, () => (""))}:${_nullishCoalesce(n.productId, () => (""))}`:`c:${n.channelId}:${_nullishCoalesce(n.productId, () => (""))}`;_react.useEffect.call(void 0, ()=>{let s=!1;if(g.current=void 0,r(ae),t!==null){if(!t){r({...ae,status:"error",error:new $("no_token",401)});return}return(async()=>{try{let l=await t.me(),m=l.email.toLowerCase(),C,O,D;if(n.kind==="thread"){if(C=n.threadId?l.threads.find(F=>F.id===n.threadId):l.threads.find(F=>F.productId===n.productId),!C&&n.productId)try{C=await t.openThread(n.productId)}catch(F){let E=be(F);if(E.code==="locked"||E.status===404){s||r({...ae,status:"locked",me:m,lock:Xe(E,"no-pack",n.productId)});return}throw E}if(!C)throw new $("not_found",404);D=C.id}else O=l.channels.find(F=>F.id===n.channelId),D=n.channelId;let H;try{H=await t.messages(D,{limit:Le})}catch(F){let E=be(F);if(E.code==="locked"){s||r({...ae,status:"locked",me:m,thread:C,channel:O,threadId:D,lock:Xe(E,n.kind==="channel"?"no-access":"no-pack",_nullishCoalesce(_nullishCoalesce(n.productId, () => (_optionalChain([O, 'optionalAccess', _44 => _44.productId]))), () => (_optionalChain([C, 'optionalAccess', _45 => _45.productId]))))});return}throw E}if(s)return;r({...ae,status:"ready",me:m,thread:C,channel:O,threadId:D,lock:C?Re(C):void 0,messages:ce([],H.messages),hasMore:H.hasMore})}catch(l){s||r({...ae,status:"error",error:be(l)})}})(),()=>{s=!0}}},[t,b,c]);let k=_react.useCallback.call(void 0, ()=>{t&&(i.current&&clearTimeout(i.current),i.current=setTimeout(async()=>{try{let s=await t.me();r(l=>{if(l.status!=="ready")return l;let m=l.thread&&s.threads.find(O=>O.id===l.thread.id),C=l.channel&&s.channels.find(O=>O.id===l.channel.id);return{...l,thread:_nullishCoalesce(m, () => (l.thread)),channel:_nullishCoalesce(C, () => (l.channel)),lock:m?Re(m):l.lock}})}catch (e13){}},1500))},[t]),T=_react.useCallback.call(void 0, async()=>{let{threadId:s}=h.current;if(!t||!s)return;let l=await t.messages(s,{limit:Le});r(m=>m.threadId===s?{...m,messages:ce(m.messages,l.messages)}:m)},[t]),f=_react.useCallback.call(void 0, s=>{r(l=>{switch(s.type){case"message.created":return{...l,messages:ce(l.messages,[s.message])};case"message.rejected":return{...l,messages:l.messages.map(m=>m.id===s.id?{...m,local:{state:"rejected",reason:s.reason||"rejected"}}:m)};case"message.deleted":return{...l,messages:l.messages.map(m=>m.id===s.id?{...m,deleted:!0,body:"",attachmentKey:void 0}:m)};case"message.pinned":case"message.unpinned":return{...l,messages:l.messages.map(m=>m.id===s.id?{...m,pinned:s.type==="message.pinned"}:m)}}}),s.type==="message.created"&&!s.message.system&&s.message.authorEmail.toLowerCase()!==h.current.me&&k()},[k]),w=a.status==="ready"?a.threadId:void 0;_react.useEffect.call(void 0, ()=>{if(!t||!w)return;let s=ze({client:t,kind:n.kind,id:w,onEvent:f,onMode:l=>r(m=>({...m,live:l})),poll:T,pollIntervalMs:e.pollIntervalMs,realtimeUrl:e.realtimeUrl,loadNats:e.loadNats});return()=>{s(),r(l=>({...l,live:"off"}))}},[t,w,f,T]),_react.useEffect.call(void 0, ()=>{if(!t||!a.threadId||a.status!=="ready")return;let s=[...a.messages].reverse().find(l=>!l.local&&l.authorEmail.toLowerCase()!==a.me);!s||g.current===s.id||(g.current=s.id,t.markRead(a.threadId,s.id).catch(()=>{}))},[t,a.threadId,a.status,a.messages,a.me]),_react.useEffect.call(void 0, ()=>()=>{for(let s of u.current)clearTimeout(s);i.current&&clearTimeout(i.current)},[]);let p=(s,l)=>r(m=>({...m,messages:m.messages.map(C=>C.id===s?l(C):C)})),y=_react.useCallback.call(void 0, async(s,l,m)=>{let C=s.trim(),{threadId:O,me:D}=h.current;if(!t||!O||!C&&!l)return;let H=_nullishCoalesce(m, () => (Rt())),F={id:H,threadId:O,authorEmail:_nullishCoalesce(D, () => ("")),body:C,retryFile:l,...l?{attachmentName:l.name,attachmentSize:l.size,attachmentContentType:l.type,attachmentKind:l.type.startsWith("image/")?"image":"file"}:{},createdAt:new Date().toISOString(),pinned:!1,deleted:!1,system:!1,status:"pending",local:{state:"pending"}};r(E=>({...E,messages:[...E.messages,F]}));try{let E=l?await t.uploadAttachment(O,l,U=>p(H,q=>({...q,local:{...q.local,state:"pending",uploadProgress:U}}))):void 0;E&&p(H,U=>({...U,attachmentKey:E.key,attachmentKind:E.kind,attachmentName:E.filename,attachmentSize:E.size,attachmentContentType:E.contentType,local:{state:"pending"}}));let J=await t.send(O,{body:C,clientId:H,...E?{attachment:E}:{}});r(U=>({...U,messages:ce(U.messages,[{...J.message,id:H}]),thread:U.thread?{...U.thread,...J.thread,id:U.thread.id}:U.thread,lock:U.thread?Re({...U.thread,...J.thread,id:U.thread.id}):U.lock}));let ne=setTimeout(()=>{u.current.delete(ne),p(H,U=>_optionalChain([U, 'access', _46 => _46.local, 'optionalAccess', _47 => _47.state])==="pending"?{...U,local:{state:"unconfirmed"}}:U)},_nullishCoalesce(e.confirmTimeoutMs, () => (45e3)));u.current.add(ne)}catch(E){let J=be(E),ne=J.code==="network"||J.code==="unavailable"||J.status>=500;p(H,U=>({...U,local:{state:ne?"failed":"rejected",reason:J.code,retryAfter:J.retryAfter,keepId:ne||m!=null}}))}},[t,e.confirmTimeoutMs]),L=_react.useCallback.call(void 0, s=>{r(l=>({...l,messages:l.messages.filter(m=>m.id!==s)}))},[]),A=_react.useCallback.call(void 0, async s=>{let l=h.current.messages.find(C=>C.id===s);if(!l)return;let m=_optionalChain([l, 'access', _48 => _48.local, 'optionalAccess', _49 => _49.state])!=="rejected"||l.local.keepId===!0;L(s),await y(l.body,l.retryFile,m?s:void 0)},[L,y]),j=_react.useCallback.call(void 0, async s=>{let{threadId:l}=h.current,m=h.current.messages.find(C=>C.id===s);if(!(!t||!l||!m)){p(s,C=>({...C,deleted:!0,body:"",attachmentKey:void 0}));try{await t.deleteMessage(l,s)}catch(C){throw p(s,()=>m),C}}},[t]),x=_react.useCallback.call(void 0, async s=>{let l=h.current.threadId;if(!t||!l)throw new $("not_found",404);return t.attachmentURL(l,s)},[t]),d=_react.useCallback.call(void 0, async s=>{let{threadId:l}=h.current;!t||!l||await t.report({threadId:l,...s})},[t]),R=_react.useCallback.call(void 0, async s=>{let{threadId:l}=h.current;!t||!l||(await t.mute(l,s),r(m=>m.thread?{...m,thread:{...m.thread,muted:s}}:m))},[t]),_=_react.useCallback.call(void 0, async()=>{let{threadId:s,messages:l,hasMore:m,loadingOlder:C}=h.current,O=l.find(D=>!D.local);if(!(!t||!s||!m||C||!O)){r(D=>({...D,loadingOlder:!0}));try{let D=await t.messages(s,{before:O.id,limit:Le});r(H=>({...H,loadingOlder:!1,hasMore:D.hasMore,messages:ce(H.messages,D.messages)}))}catch (e14){r(D=>({...D,loadingOlder:!1}))}}},[t]),P=_react.useCallback.call(void 0, ()=>v(s=>s+1),[]);return{...a,send:y,retry:A,getAttachmentURL:x,discard:L,deleteMessage:j,report:d,setMuted:R,loadOlder:_,reload:P}}function Qe(e){let[t,n]=_react.useState.call(void 0, null),a=_nullishCoalesce(e.host, () => (_chunkMDAFPGPAjs.b.call(void 0, ).host));_react.useEffect.call(void 0, ()=>{e.client||e.token||n(_chunkMDAFPGPAjs.i.call(void 0, e.projectID,a))},[e.client,e.token,e.projectID,a]);let r=_nullishCoalesce(e.token, () => (t)),c=_nullishCoalesce(e.chatProjectID, () => (e.projectID));return _react.useMemo.call(void 0, ()=>{if(e.client)return e.client;if(r===null)return null;if(r)return ie({projectId:c,token:r,baseUrl:e.apiUrl,attachmentsUrl:e.attachmentsUrl})},[e.client,r,c,e.apiUrl,e.attachmentsUrl])}function et(e){let t=_react.useRef.call(void 0, null);return async n=>{let a=_nullishCoalesce(e.buyProductId, () => (n.productId));if(!a)return;let r={productId:a,reason:n.reason,priceCents:n.priceCents,...n.amount!=null?{amount:n.amount}:{},...n.email?{email:n.email}:{},...n.code?{code:n.code}:{},...n.turnstileToken!=null?{turnstileToken:n.turnstileToken}:{}};if(e.onBuy){await e.onBuy(r);return}let c=(_nullishCoalesce(_nullishCoalesce(e.host, () => (_chunkMDAFPGPAjs.b.call(void 0, ).host)), () => ("https://bitsnap.pl"))).replace(/\/+$/,""),v=n.freeClaimLimit!=null&&(n.priceType==="free"||n.priceType==="pay_what_you_want"&&n.minimumCents===0&&r.amount===0);if(v&&r.email&&r.turnstileToken!=null){t.current=null;let h=await fetch(`${c}/api/integrations/${encodeURIComponent(e.projectID)}/public-commerce/free-claim/request-code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r.email,turnstileToken:r.turnstileToken})}),u=await h.json();if(!h.ok)throw new Error(_nullishCoalesce(u.code, () => ("internal")));return}if(v&&r.email&&r.code){let h=JSON.stringify([c,e.projectID,a,r.email,r.code]);if(!t.current||t.current.key!==h||t.current.expires<=Date.now()){t.current=null;let g=await fetch(`${c}/api/integrations/${encodeURIComponent(e.projectID)}/public-commerce/free-claim/verify-code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r.email,code:r.code})}),b=await g.json();if(!g.ok||!b.claimToken)throw new Error(_nullishCoalesce(b.code, () => ("email-verification-required")));t.current={key:h,token:b.claimToken,expires:Date.now()+(_nullishCoalesce(b.expiresIn, () => (600)))*1e3}}let u=await fetch(`${c}/api/integrations/${encodeURIComponent(e.projectID)}/public-commerce/buy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:a,quantity:1,amount:0}],details:{email:r.email},claimToken:t.current.token})}),i=await u.json();if(!u.ok||!i.url)throw new Error(_nullishCoalesce(i.code, () => ("free-order-not-supported")));window.location.assign(i.url);return}await se({projectID:e.projectID,productId:a,name:e.title,priceCents:n.priceCents,amount:n.amount,host:e.host})}}function _e(e){let t=Qe(e),n=_nullishCoalesce(e.locale, () => (_chunkQ337IQNAjs.f.call(void 0, ))),a=_react.useMemo.call(void 0, ()=>re(e.texts,n),[e.texts,n]),r=ke({client:t,target:{kind:"thread",threadId:e.threadId,productId:e.productId},pollIntervalMs:e.pollIntervalMs,realtimeUrl:e.realtimeUrl,loadNats:e.loadNats}),c=et(e);return _jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react h-full",children:_jsxruntime.jsx.call(void 0, Pe,{host:e.host,conversation:r,texts:a,locale:n,kind:"thread",title:e.title,onBack:e.onBack,onBuy:c,className:e.className})})}function Ae(e){let t=Qe(e),n=_nullishCoalesce(e.locale, () => (_chunkQ337IQNAjs.f.call(void 0, ))),a=_react.useMemo.call(void 0, ()=>re(e.texts,n),[e.texts,n]),r=ke({client:t,target:{kind:"channel",channelId:e.channelId,productId:e.productId},pollIntervalMs:e.pollIntervalMs,realtimeUrl:e.realtimeUrl,loadNats:e.loadNats}),c=et(e);return _jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react h-full",children:_jsxruntime.jsx.call(void 0, Pe,{host:e.host,conversation:r,texts:a,locale:n,kind:"channel",title:e.title,onBack:e.onBack,onBuy:c,className:e.className})})}var Dt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./BitsnapCart-4DKJ7OXL.js")))),nt=e=>e.productType===5||e.productType===6;function at(e,t){let n=[...new Set(e.filter(nt).map(a=>a.projectId).filter(Boolean))];return n.length>0?n:t?[t]:[]}function $t(e){let t=new Map;for(let n of e)nt(n)&&n.projectId&&n.chatProjectId&&t.set(n.projectId,n.chatProjectId);return t}function rt({accessToken:e,products:t,chatApiUrl:n,projectID:a,host:r,selection:c,onSelect:v,locale:h=_chunkQ337IQNAjs.f.call(void 0, ),texts:u}){let i=_react.useMemo.call(void 0, ()=>re(u,h),[u,h]),g=_react.useMemo.call(void 0, ()=>at(t,a),[t,a]),b=_react.useMemo.call(void 0, ()=>$t(t),[t]),k=_react.useMemo.call(void 0, ()=>{let P=new Map;for(let s of g)P.set(s,ie({projectId:_nullishCoalesce(b.get(s), () => (s)),token:e,baseUrl:n}));return P},[g,b,e,n]),[T,f]=_react.useState.call(void 0, {}),[N,w]=_react.useState.call(void 0, 0),p=`${_nullishCoalesce(c.chatProject, () => (""))}:${_nullishCoalesce(c.thread, () => (""))}:${_nullishCoalesce(c.channel, () => (""))}`;_react.useEffect.call(void 0, ()=>{let P=!1;for(let[s,l]of k)f(m=>_optionalChain([m, 'access', _50 => _50[s], 'optionalAccess', _51 => _51.status])==="ready"?m:{...m,[s]:{status:"loading"}}),l.me().then(m=>!P&&f(C=>({...C,[s]:{status:"ready",me:m}})),m=>!P&&f(C=>({...C,[s]:{status:"error",error:m instanceof $?m:new $("internal_error",0)}})));return()=>{P=!0}},[k,N,p]);let y=_react.useMemo.call(void 0, ()=>{let P=new Map;for(let s of t)P.set(s.productId,s);return P},[t]),[L,A]=_react.useState.call(void 0, ),j=P=>async s=>{A(P),await se({projectID:P,productId:s.productId,name:_optionalChain([y, 'access', _52 => _52.get, 'call', _53 => _53(s.productId), 'optionalAccess', _54 => _54.productName]),priceCents:s.priceCents,host:r})},x=c.chatProject?k.get(c.chatProject):void 0,d=!!(x&&(c.thread||c.channel)),R=()=>v({}),_=null;if(d&&x&&c.chatProject){let P=c.chatProject,s=T[P],l=_optionalChain([s, 'optionalAccess', _55 => _55.status])==="ready"?s.me:void 0;if(c.thread){let m=_optionalChain([l, 'optionalAccess', _56 => _56.threads, 'access', _57 => _57.find, 'call', _58 => _58(C=>C.id===c.thread)]);_=_jsxruntime.jsx.call(void 0, _e,{projectID:P,client:x,threadId:c.thread,title:_optionalChain([m, 'optionalAccess', _59 => _59.productId])&&_optionalChain([y, 'access', _60 => _60.get, 'call', _61 => _61(m.productId), 'optionalAccess', _62 => _62.productName])||void 0,locale:h,texts:u,onBack:R,onBuy:j(P)},`t:${P}:${c.thread}`)}else if(c.channel){let m=_optionalChain([l, 'optionalAccess', _63 => _63.entitlements, 'access', _64 => _64.channels, 'access', _65 => _65.find, 'call', _66 => _66(C=>C.channelId===c.channel)]);_=_jsxruntime.jsx.call(void 0, Ae,{projectID:P,client:x,channelId:c.channel,productId:_optionalChain([m, 'optionalAccess', _67 => _67.productId]),locale:h,texts:u,onBack:R,onBuy:j(P)},`c:${P}:${c.channel}`)}}return _jsxruntime.jsxs.call(void 0, "div",{className:"flex min-h-0 flex-1 flex-col",children:[_jsxruntime.jsxs.call(void 0, "div",{className:_chunk6DEKVABTjs.g.call(void 0, d&&"hidden md:block"),children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:i.inboxHeading}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:i.inboxIntro})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 grid min-h-0 flex-1 gap-4 md:grid-cols-[minmax(16rem,22rem)_1fr]",children:[_jsxruntime.jsx.call(void 0, "div",{className:_chunk6DEKVABTjs.g.call(void 0, "min-w-0",d&&"hidden md:block"),children:_jsxruntime.jsx.call(void 0, Ht,{projects:g,loads:T,clients:k,products:t,texts:i,locale:h,selection:c,onSelect:v,onRetry:()=>w(P=>P+1)})}),_jsxruntime.jsx.call(void 0, "div",{className:_chunk6DEKVABTjs.g.call(void 0, "min-h-[32rem] min-w-0 md:h-[calc(100dvh-10rem)]",!d&&"hidden md:flex"),children:_nullishCoalesce(_, () => (_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full w-full items-center justify-center rounded-xl border border-dashed border-neutral-300 p-6 text-sm text-neutral-600 dark:border-neutral-700 dark:text-neutral-400",children:i.selectConversation})))})]}),L&&_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, Dt,{projectID:L,locale:h})})]})}var tt="flex min-h-11 w-full min-w-0 items-start gap-3 rounded-xl p-3 text-left transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500";function Ht({projects:e,loads:t,clients:n,products:a,texts:r,locale:c,selection:v,onSelect:h,onRetry:u}){let[i,g]=_react.useState.call(void 0, ),[b,k]=_react.useState.call(void 0, ),T=new Map(a.map(y=>[y.productId,y])),f=e.length>1,N=e.map(y=>_nullishCoalesce(t[y], () => ({status:"loading"})));if(N.length>0&&N.every(y=>y.status==="loading"))return _jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true","aria-label":r.loading,className:"flex flex-col gap-2",children:[0,1,2].map(y=>_jsxruntime.jsx.call(void 0, "div",{"aria-hidden":"true",className:"h-20 rounded-xl bg-white motion-safe:animate-pulse dark:bg-neutral-800"},y))});if(N.length===0||N.every(y=>y.status==="error"))return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-col items-start gap-3","data-testid":"chat-inbox-error",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700 dark:text-neutral-300",children:r.inboxError}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:u,className:"inline-flex min-h-11 items-center rounded-md bg-neutral-900 px-4 text-sm font-medium text-white hover:bg-neutral-800 focus-visible:outline-2 focus-visible:outline-current dark:bg-white dark:text-neutral-900",children:r.retry})]});let w=[],p=[];for(let y of e){let L=t[y];if(_optionalChain([L, 'optionalAccess', _68 => _68.status])!=="ready")continue;let{me:A}=L,j=f?_optionalChain([a, 'access', _69 => _69.find, 'call', _70 => _70(d=>d.projectId===y), 'optionalAccess', _71 => _71.projectName]):void 0;for(let d of A.threads){let R=d.productId?T.get(d.productId):void 0,_=v.chatProject===y&&v.thread===d.id,P=[le(r,d.repliesLeft,c)];d.expiresAt&&P.push(G(d.composerLocked?r.expiredOn:r.expiresOn,{date:de(d.expiresAt,c)})),d.responseHours>0&&P.push(G(r.responseHours,{hours:d.responseHours}));let s=d.lastMessage;w.push(_jsxruntime.jsx.call(void 0, "li",{children:_jsxruntime.jsxs.call(void 0, "button",{type:"button","data-thread-id":d.id,"aria-current":_?"true":void 0,onClick:()=>h({chatProject:y,thread:d.id}),className:_chunk6DEKVABTjs.g.call(void 0, tt,_?"bg-neutral-200 dark:bg-neutral-800":"bg-white hover:bg-neutral-50 dark:bg-neutral-900 dark:hover:bg-neutral-800"),children:[_jsxruntime.jsx.call(void 0, _lucidereact.MessageCircle,{className:"mt-0.5 size-5 shrink-0 text-neutral-500 dark:text-neutral-400","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[_jsxruntime.jsxs.call(void 0, "span",{className:"flex items-baseline gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:_chunk6DEKVABTjs.g.call(void 0, "truncate",d.unread>0?"font-semibold":"font-medium"),children:_optionalChain([R, 'optionalAccess', _72 => _72.productName])||r.chatFallbackTitle}),s&&_jsxruntime.jsx.call(void 0, "time",{dateTime:s.createdAt,className:"ml-auto shrink-0 text-xs text-neutral-500 dark:text-neutral-400",children:he(s.createdAt,c)})]}),j&&_jsxruntime.jsx.call(void 0, "span",{className:"truncate text-xs text-neutral-500 dark:text-neutral-400",children:j}),_jsxruntime.jsxs.call(void 0, "span",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:"line-clamp-1 flex-1 text-sm text-neutral-600 dark:text-neutral-300",children:s?s.deleted?r.deletedPlaceholder:s.body:r.noMessagesYet}),d.unread>0&&_jsxruntime.jsx.call(void 0, "span",{"aria-label":G(r.unread,{count:d.unread}),className:"inline-flex min-w-5 shrink-0 items-center justify-center rounded-full bg-neutral-900 px-1.5 text-xs font-semibold text-white tabular-nums dark:bg-white dark:text-neutral-900",children:d.unread})]}),_jsxruntime.jsxs.call(void 0, "span",{className:_chunk6DEKVABTjs.g.call(void 0, "text-xs",d.repliesLeft<=0||d.composerLocked?"text-amber-800 dark:text-amber-300":"text-neutral-500 dark:text-neutral-400"),children:[P.join(" \xB7 "),d.muted&&` \xB7 ${r.mutedBadge}`]})]})]})},`t:${y}:${d.id}`))}for(let d of A.channels){let R=v.chatProject===y&&v.channel===d.id;w.push(_jsxruntime.jsx.call(void 0, "li",{children:_jsxruntime.jsxs.call(void 0, "button",{type:"button","data-channel-id":d.id,"aria-current":R?"true":void 0,onClick:()=>h({chatProject:y,channel:d.id}),className:_chunk6DEKVABTjs.g.call(void 0, tt,R?"bg-neutral-200 dark:bg-neutral-800":"bg-white hover:bg-neutral-50 dark:bg-neutral-900 dark:hover:bg-neutral-800"),children:[_jsxruntime.jsx.call(void 0, _lucidereact.Hash,{className:"mt-0.5 size-5 shrink-0 text-neutral-500 dark:text-neutral-400","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"truncate font-medium",children:d.name||r.channelFallbackTitle}),j&&_jsxruntime.jsx.call(void 0, "span",{className:"truncate text-xs text-neutral-500 dark:text-neutral-400",children:j}),_jsxruntime.jsx.call(void 0, "span",{className:"line-clamp-1 text-sm text-neutral-600 dark:text-neutral-300",children:d.topic||r.kindChannel}),d.memberCount>0&&_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:G(r.members,{count:d.memberCount})})]})]})},`c:${y}:${d.id}`))}for(let d of A.entitlements.packs){let R=`${y}:${d.productId}`,_=_optionalChain([T, 'access', _73 => _73.get, 'call', _74 => _74(d.productId), 'optionalAccess', _75 => _75.productName])||d.name||r.chatFallbackTitle;p.push(_jsxruntime.jsxs.call(void 0, "li",{className:"flex flex-col gap-2 rounded-xl bg-white p-3 dark:bg-neutral-900 sm:flex-row sm:items-center",children:[_jsxruntime.jsxs.call(void 0, "span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"truncate font-medium",children:_}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:[le(r,d.repliesLeftHint,c),d.expiresAt?G(r.expiresOn,{date:de(d.expiresAt,c)}):""].filter(Boolean).join(" \xB7 ")})]}),_jsxruntime.jsx.call(void 0, "button",{type:"button",disabled:i===R,"aria-busy":i===R||void 0,onClick:async()=>{let P=n.get(y);if(P){g(R),k(void 0);try{let s=await P.openThread(d.productId);h({chatProject:y,thread:s.id})}catch (e15){k(R)}finally{g(void 0)}}},className:"inline-flex min-h-11 shrink-0 items-center justify-center rounded-md bg-neutral-900 px-4 text-sm font-medium text-white hover:bg-neutral-800 disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500 dark:bg-white dark:text-neutral-900 dark:hover:bg-neutral-200",children:i===R?r.loading:r.startChat}),b===R&&_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"text-xs text-red-700 dark:text-red-400 sm:basis-full",children:r.errorGeneric})]},`p:${R}`))}let x=new Set(A.channels.map(d=>d.id));for(let d of A.entitlements.channels){if(d.channelId&&x.has(d.channelId))continue;let R=_optionalChain([T, 'access', _76 => _76.get, 'call', _77 => _77(d.productId), 'optionalAccess', _78 => _78.productName])||r.channelFallbackTitle;p.push(_jsxruntime.jsxs.call(void 0, "li",{className:"flex flex-col gap-2 rounded-xl bg-white p-3 dark:bg-neutral-900 sm:flex-row sm:items-center",children:[_jsxruntime.jsxs.call(void 0, "span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"truncate font-medium",children:R}),!d.channelId&&_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:r.channelNotReady})]}),d.channelId&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>h({chatProject:y,channel:d.channelId}),className:"inline-flex min-h-11 shrink-0 items-center justify-center rounded-md border border-neutral-300 px-4 text-sm font-medium hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500 dark:border-neutral-700 dark:hover:bg-neutral-800",children:r.openChannel})]},`e:${y}:${d.productId}`))}}return w.length===0&&p.length===0?_jsxruntime.jsx.call(void 0, "p",{"data-testid":"chat-inbox-empty",className:"text-sm text-neutral-600 dark:text-neutral-400",children:r.inboxEmpty}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-6","data-testid":"chat-inbox",children:[w.length>0&&_jsxruntime.jsx.call(void 0, "ul",{className:"flex flex-col gap-2",children:w}),p.length>0&&_jsxruntime.jsxs.call(void 0, "section",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-sm font-semibold text-neutral-700 dark:text-neutral-300",children:r.startSection}),_jsxruntime.jsx.call(void 0, "ul",{className:"flex flex-col gap-2",children:p})]})]})}exports.CHAT_TEXT_TABLES = $e; exports.Channel = Ae; exports.ChatError = $; exports.ChatThread = _e; exports.DEFAULT_CHAT_API_URL = Ce; exports.DEFAULT_CHAT_ATTACHMENTS_URL = ve; exports.DEFAULT_CHAT_REALTIME_URL = Te; exports.PanelMessages = rt; exports.addPackToCart = se; exports.chatProjects = at; exports.createChatClient = ie; exports.getChatTexts = re; exports.parseRealtimeEvent = Ne; exports.startLive = ze; exports.useConversation = ke;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkZ3YOJ6NZjs = require('./chunk-Z3YOJ6NZ.js');var _chunkPFKZ7KUUjs = require('./chunk-PFKZ7KUU.js');var _chunk35ZQU353js = require('./chunk-35ZQU353.js');var _chunkMDAFPGPAjs = require('./chunk-MDAFPGPA.js');require('./chunk-3TUL63IC.js');var _chunkJS3KK56Hjs = require('./chunk-JS3KK56H.js');require('./chunk-SAKZOHU7.js');require('./chunk-W3RGQYPD.js');var _chunkQ337IQNAjs = require('./chunk-Q337IQNA.js');require('./chunk-JSDGZ4NY.js');var _react = require('react');async function ie(e){await _chunk35ZQU353js.e.call(void 0, {id:e.productId,name:_nullishCoalesce(e.name, () => ("")),price:_nullishCoalesce(e.priceCents, () => (0)),currency:"",amount:e.amount},{projectID:e.projectID,host:e.host,showCart:!0})}var Ne="https://chat.bitsnap.pl",Re= exports.DEFAULT_CHAT_ATTACHMENTS_URL ="https://bitsnap.pl",Me= exports.DEFAULT_CHAT_REALTIME_URL ="wss://bitsnap-nats-queue-production.up.railway.app";var $=class extends Error{constructor(t,n,a={}){super(`chat: ${t} (${n})`),this.name="ChatError",this.code=t,this.status=n,this.data=a;let r=Number(a.retry_after);Number.isFinite(r)&&r>0&&(this.retryAfter=r)}};function de(e){let t=(e.baseUrl||Ne).replace(/\/+$/,""),n=typeof window<"u"&&["localhost","127.0.0.1"].includes(window.location.hostname)?window.location.origin:void 0,a=(_nullishCoalesce(_nullishCoalesce(e.attachmentsUrl, () => (n)), () => (Re))).replace(/\/+$/,""),r=_nullishCoalesce(e.fetch, () => (((...l)=>fetch(...l))));async function d(l,i,g){let x;try{x=await r(t+i,{method:l,headers:{Authorization:`Bearer ${e.token}`,"X-Bitsnap-Project":e.projectId,...g===void 0?{}:{"Content-Type":"application/json"}},body:g===void 0?void 0:JSON.stringify(g)})}catch (e2){throw new $("network",0)}let k=null;try{let v=await x.text();k=v?JSON.parse(v):null}catch (e3){k=null}if(!x.ok){let v=H(k)?k:{},f=typeof v.error=="string"?v.error:"internal_error";throw new $(f,x.status,v)}return{status:x.status,json:k}}let y=encodeURIComponent,p;return{baseUrl:t,projectId:e.projectId,async me(){let{json:l}=await d("GET","/v1/me");return ct(l)},async openThread(l){let{json:i}=await d("POST","/v1/threads",{product_id:l});return $e(i)},async messages(l,i={}){let g=new URLSearchParams;i.before&&g.set("before",i.before),i.limit&&g.set("limit",String(i.limit));let x=g.toString(),k=x?`?${x}`:"",{json:v}=await d("GET",`/v1/threads/${y(l)}/messages${k}`),f=H(v)?v:{};return{messages:ee(f.messages).map(le),hasMore:f.has_more===!0}},async send(l,i){let{json:g}=await d("POST",`/v1/threads/${y(l)}/messages`,{body:i.body,...i.clientId?{client_id:i.clientId}:{},...i.attachment?{attachment_key:i.attachment.key,attachment_kind:i.attachment.kind,attachment_name:i.attachment.filename,attachment_size:i.attachment.size,attachment_content_type:i.attachment.contentType}:{}}),x=H(g)?g:{};return{message:le(x.message),thread:De(x.thread)}},async uploadAttachment(l,i,g){let x=async(f,T)=>{let C=await r(`${a}/api/chat/attachments/${f}`,{method:"POST",headers:{Authorization:`Bearer ${e.token}`,"X-Bitsnap-Project":e.projectId,"Content-Type":"application/json"},body:JSON.stringify(T)}),h={};try{h=await C.json()}catch (e4){}if(!C.ok)throw new $(typeof h.error=="string"?h.error:"request_failed",C.status,h);return h},k=await x("upload",{project_id:e.projectId,thread_id:l,filename:i.name,content_type:i.type,size:i.size});await new Promise((f,T)=>{let C=new XMLHttpRequest;C.open("PUT",k.uploadURL),C.setRequestHeader("Content-Type",i.type),C.upload.onprogress=h=>{h.lengthComputable&&g(Math.round(h.loaded/h.total*100))},C.onload=()=>C.status>=200&&C.status<300?f():T(new $("upload_failed",C.status)),C.onerror=()=>T(new $("network",0)),C.send(i)});let v=await x("complete",{project_id:e.projectId,thread_id:l,key:k.key,upload_ticket:k.uploadTicket,filename:i.name,content_type:i.type,size:i.size});return{key:v.key,kind:v.kind,filename:v.filename,size:v.size,contentType:v.content_type}},async attachmentURL(l,i){if(!i.attachmentKey)throw new $("invalid_attachment",400);let g=new URLSearchParams({project_id:e.projectId,thread_id:l,key:i.attachmentKey,filename:_nullishCoalesce(i.attachmentName, () => ("attachment")),size:String(_nullishCoalesce(i.attachmentSize, () => (0)))}),x=await r(`${a}/api/chat/attachments/read?${g}`,{headers:{Authorization:`Bearer ${e.token}`,"X-Bitsnap-Project":e.projectId}}),k={};try{k=await x.json()}catch (e5){}if(!x.ok||typeof k.url!="string")throw new $(typeof k.error=="string"?k.error:"request_failed",x.status,k);return k.url},async deleteMessage(l,i){await d("DELETE",`/v1/threads/${y(l)}/messages/${y(i)}`)},async mute(l,i){await d("POST",`/v1/threads/${y(l)}/mute`,{muted:i})},async report(l){await d("POST","/v1/reports",{thread_id:l.threadId,...l.messageId?{message_id:l.messageId}:{},reason:l.reason,...l.note?{note:l.note}:{}})},async markRead(l,i){await d("POST",`/v1/threads/${y(l)}/receipts`,{state:"read",message_id:i})},async realtimeToken(l={}){if(!l.fresh&&p&&Date.parse(p.expiresAt)-Date.now()>9e4)return p;let{json:i}=await d("POST","/v1/realtime/token"),g=H(i)?i:{};return p={jwt:U(g.jwt),expiresAt:U(g.expires_at),servers:ee(g.servers).filter(x=>typeof x=="string"),subjects:ee(g.subjects).filter(x=>typeof x=="string"),truncated:g.truncated===!0}}}}function Ie(e){if(!H(e)||typeof e.type!="string")return null;let t=U(e.id);switch(e.type){case"message.created":return{type:"message.created",message:le(e)};case"message.updated":return{type:"message.updated",message:le(H(e.message)?e.message:e)};case"message.rejected":return{type:"message.rejected",id:t,reason:U(e.reason)};case"message.deleted":case"message.pinned":case"message.unpinned":return{type:e.type,id:t};default:return null}}function H(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}function ee(e){return Array.isArray(e)?e:[]}function U(e){return typeof e=="string"?e:e==null?"":String(e)}function V(e){let t=Number(e);return Number.isFinite(t)?t:0}function te(e){return typeof e=="string"&&e!==""?e:void 0}function je(e){return typeof e=="string"&&e!==""?e:null}function le(e){let t=H(e)?e:{},n=t.kind==="payment_request"?it(t.payment_request):void 0;return{id:U(t.id),threadId:U(t.thread_id),authorEmail:U(t.author_email),body:U(t.body),kind:t.kind==="payment_request"?"payment_request":"text",...n?{paymentRequest:n}:{},...t.kind==="payment_request"&&!n?{paymentRequestInvalid:!0}:{},attachmentKey:te(t.attachment_key),attachmentKind:te(t.attachment_kind),attachmentName:te(t.attachment_name),attachmentSize:V(t.attachment_size),attachmentContentType:te(t.attachment_content_type),createdAt:U(t.created_at),pinned:t.pinned===!0,deleted:t.deleted===!0,system:t.system===!0,...t.status==="pending"?{status:"pending"}:{}}}function it(e){if(!H(e))return;let t=l=>l==null?null:typeof l=="number"&&Number.isFinite(l)&&l>=0?l:NaN,n=t(e.min_amount_minor),a=t(e.max_amount_minor),r=e.amount_minor,d=e.extra_replies,y=e.extend_expiry_days,p=typeof e.payment_url=="string"&&/^https:\/\//i.test(e.payment_url);if(!(typeof e.request_id!="string"||!e.request_id||typeof e.title!="string"||e.description!==null&&typeof e.description!="string"||e.amount_mode!=="exact"&&e.amount_mode!=="pwyw"||typeof r!="number"||!Number.isFinite(r)||r<0||Number.isNaN(n)||Number.isNaN(a)||e.amount_mode==="pwyw"&&(n==null||a==null||n>a)||typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)||typeof d!="number"||!Number.isFinite(d)||d<0||typeof y!="number"||!Number.isFinite(y)||y<0||!p||typeof e.expires_at!="string"||!Number.isFinite(Date.parse(e.expires_at))||!["pending","paid","expired","cancelled"].includes(String(e.status))||e.paid_at!=null&&typeof e.paid_at!="string"))return{requestId:e.request_id,title:e.title,description:_nullishCoalesce(e.description, () => ("")),amountMode:e.amount_mode,amountMinor:r,minAmountMinor:n,maxAmountMinor:a,currency:e.currency,extraReplies:d,extendExpiryDays:y,paymentUrl:e.payment_url,status:e.status,expiresAt:e.expires_at,paidAt:e.paid_at}}function lt(e){let t=H(e)?e:{};return{orderId:U(t.order_id),productId:te(t.product_id),replies:V(t.replies),used:V(t.used),left:V(t.left),expiresAt:je(t.expires_at),expired:t.expired===!0}}function De(e){let t=H(e)?e:{};return{id:U(t.id),kind:t.kind==="channel"?"channel":"pack",repliesTotal:V(t.replies_total),repliesUsed:V(t.replies_used),repliesLeft:V(t.replies_left),expiresAt:je(t.expires_at),composerLocked:t.composer_locked===!0,responseHours:V(t.response_hours)}}function $e(e){let t=H(e)?e:{};return{...De(t),channelId:te(t.channel_id),title:U(t.title),lastMessage:H(t.last_message)?le(t.last_message):void 0,unread:V(t.unread),productId:te(t.product_id),blocked:t.blocked===!0,packs:ee(t.packs).map(lt),muted:t.muted===!0}}function dt(e){let t=H(e)?e:{};return{id:U(t.id),name:U(t.name),topic:U(t.topic),welcome:U(t.welcome),whoCanPost:t.who_can_post==="members"?"members":"creator",productId:U(t.product_id),role:U(t.role),memberCount:V(t.member_count),createdAt:U(t.created_at),blockLinks:t.block_links===!0,blockMedia:t.block_media===!0,cooldownSeconds:V(t.cooldown_seconds)}}function ct(e){let t=H(e)?e:{},n=H(t.entitlements)?t.entitlements:{};return{email:U(t.email),threads:ee(t.threads).map($e),entitlements:{packs:ee(n.packs).map(a=>{let r=H(a)?a:{};return{productId:U(r.product_id),name:U(r.name),repliesLeftHint:V(r.replies_left_hint),expiresAt:je(r.expires_at)}}),channels:ee(n.channels).map(a=>{let r=H(a)?a:{};return{productId:U(r.product_id),channelId:te(r.channel_id)}})},channels:ee(t.channels).map(dt)}}var _lucidereact = require('lucide-react');var He={pl:{inboxHeading:"Wiadomo\u015Bci",inboxIntro:"Rozmowy z tw\xF3rcami i kana\u0142y, do kt\xF3rych nale\u017Cysz.",inboxEmpty:"Nie masz jeszcze rozm\xF3w. Po zakupie pakietu konsultacji lub dost\u0119pu do spo\u0142eczno\u015Bci rozmowa pojawi si\u0119 tutaj.",inboxError:"Nie uda\u0142o si\u0119 wczyta\u0107 wiadomo\u015Bci.",loading:"Wczytywanie\u2026",retry:"Spr\xF3buj ponownie",back:"Wr\xF3\u0107",selectConversation:"Wybierz rozmow\u0119 z listy.",kindChat:"Czat",kindChannel:"Kana\u0142",startSection:"Do rozpocz\u0119cia",startChat:"Rozpocznij rozmow\u0119",openChannel:"Otw\xF3rz kana\u0142",channelNotReady:"Tw\xF3rca jeszcze nie otworzy\u0142 tego kana\u0142u.",chatFallbackTitle:"Czat z tw\xF3rc\u0105",channelFallbackTitle:"Kana\u0142",repliesLeftOne:"Zosta\u0142a {count} odpowied\u017A",repliesLeftFew:"Zosta\u0142y {count} odpowiedzi",repliesLeftMany:"Zosta\u0142o {count} odpowiedzi",noRepliesLeft:"Brak odpowiedzi w pakiecie",expiresOn:"Wa\u017Cny do {date}",expiredOn:"Wygas\u0142 {date}",responseHours:"Odpowied\u017A w ci\u0105gu {hours} h",unread:"Nieprzeczytane: {count}",members:"Cz\u0142onkowie: {count}",mutedBadge:"Wyciszony",noMessagesYet:"Brak wiadomo\u015Bci",emptyThread:"Napisz pierwsz\u0105 wiadomo\u015B\u0107. Tw\xF3rca odpowie w ramach Twojego pakietu.",emptyChannel:"W kanale nie ma jeszcze wiadomo\u015Bci.",privacyNote:"Wiadomo\u015Bci czyta druga strona rozmowy. Bitsnap przechowuje je przez 90 dni.",loadOlder:"Wcze\u015Bniejsze wiadomo\u015Bci",newMessages:"Nowe wiadomo\u015Bci \u2193",blockedNotice:"Tw\xF3rca zablokowa\u0142 mo\u017Cliwo\u015B\u0107 wysy\u0142ania wiadomo\u015Bci w tej rozmowie.",addAttachment:"Dodaj za\u0142\u0105cznik",photo:"Zdj\u0119cie",file:"Plik",removeAttachment:"Usu\u0144 za\u0142\u0105cznik",uploading:"Wysy\u0142anie pliku",attachmentLoadFailed:"Nie uda\u0142o si\u0119 wczyta\u0107 \u2014 pon\xF3w",you:"Ty",creator:"Tw\xF3rca",systemLabel:"Wiadomo\u015B\u0107 automatyczna",pinned:"Przypi\u0119ta",deletedPlaceholder:"Wiadomo\u015B\u0107 zosta\u0142a usuni\u0119ta",attachment:"Za\u0142\u0105cznik",composerLabel:"Wiadomo\u015B\u0107",composerPlaceholder:"Napisz wiadomo\u015B\u0107\u2026",send:"Wy\u015Blij",composerExpired:"Pakiet wygas\u0142, wi\u0119c nie mo\u017Cesz ju\u017C pisa\u0107 w tej rozmowie.",composerCreatorOnly:"W tym kanale pisze tylko tw\xF3rca.",composerMuted:"Masz wyciszone pisanie w tym kanale.",composerReadOnly:"Ten dost\u0119p pozwala tylko czyta\u0107.",lockRepliesTitle:"Odpowiedzi w pakiecie si\u0119 sko\u0144czy\u0142y",lockRepliesBody:"Mo\u017Cesz dalej pisa\u0107, ale tw\xF3rca odpowie dopiero po zakupie kolejnego pakietu.",lockExpiredTitle:"Pakiet wygas\u0142",lockExpiredBody:"Rozmowa zostaje do wgl\u0105du. Kup nowy pakiet, aby j\u0105 kontynuowa\u0107.",lockThreadTitle:"Nie masz pakietu odpowiedzi",lockThreadBody:"Kup pakiet, aby napisa\u0107 do tw\xF3rcy.",lockChannelTitle:"Kana\u0142 dla cz\u0142onk\xF3w",lockChannelBody:"Kup dost\u0119p, aby czyta\u0107 i pisa\u0107 w tym kanale.",buyPack:"Kup pakiet",buyAccess:"Kup dost\u0119p",buying:"Dodawanie do koszyka\u2026",buyError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",pending:"Wysy\u0142anie\u2026",notConfirmed:"Czekamy na potwierdzenie wys\u0142ania",rejectedLink:"Linki s\u0105 w tym kanale zablokowane. Usu\u0144 link i wy\u015Blij ponownie.",rejectedBannedWord:"Wiadomo\u015B\u0107 zawiera s\u0142owo zablokowane w tym kanale. Popraw j\u0105 i wy\u015Blij ponownie.",rejectedMedia:"Za\u0142\u0105czniki s\u0105 w tym kanale zablokowane.",rejectedCooldown:"Piszesz za szybko. Spr\xF3buj ponownie za {seconds} s.",rejectedBlocked:"Tw\xF3rca zablokowa\u0142 Ci mo\u017Cliwo\u015B\u0107 pisania w tym sklepie.",rejectedMuted:"Masz wyciszone pisanie w tym kanale.",rejectedReadOnly:"Ten dost\u0119p pozwala tylko czyta\u0107.",rejectedPackEmpty:"Pakiet nie ma ju\u017C odpowiedzi.",rejectedForbidden:"Nie mo\u017Cesz pisa\u0107 w tej rozmowie.",rejectedGeneric:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 wiadomo\u015Bci.",failedNetwork:"Brak po\u0142\u0105czenia. Wiadomo\u015B\u0107 nie zosta\u0142a wys\u0142ana.",editMessage:"Popraw",retrySend:"Wy\u015Blij ponownie",dismiss:"Odrzu\u0107",messageActions:"Opcje wiadomo\u015Bci",deleteMessage:"Usu\u0144 wiadomo\u015B\u0107",deleteConfirm:"Na pewno usun\u0105\u0107?",reportMessage:"Zg\u0142o\u015B wiadomo\u015B\u0107",conversationActions:"Opcje rozmowy",muteThread:"Wycisz powiadomienia",unmuteThread:"W\u0142\u0105cz powiadomienia",muteError:"Nie uda\u0142o si\u0119 zmieni\u0107 powiadomie\u0144.",reportConversation:"Zg\u0142o\u015B rozmow\u0119",reportTitle:"Zg\u0142o\u015B wiadomo\u015B\u0107",reportConversationTitle:"Zg\u0142o\u015B rozmow\u0119",reportReason:"Pow\xF3d zg\u0142oszenia",reasonSpam:"Spam",reasonAbuse:"N\u0119kanie lub obra\u017Aliwe tre\u015Bci",reasonIllegal:"Tre\u015Bci niezgodne z prawem",reasonOther:"Inny pow\xF3d",reportNote:"Opis (opcjonalnie)",reportSend:"Wy\u015Blij zg\u0142oszenie",reportCancel:"Anuluj",reportSent:"Dzi\u0119kujemy. Zg\u0142oszenie trafi\u0142o do moderacji.",reportError:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 zg\u0142oszenia. Spr\xF3buj ponownie.",liveLabel:"Nowe wiadomo\u015Bci pojawiaj\u0105 si\u0119 na bie\u017C\u0105co",pollingLabel:"Nowe wiadomo\u015Bci od\u015Bwie\u017Caj\u0105 si\u0119 co kilka sekund",errorNoToken:"Zaloguj si\u0119 w panelu klienta, aby zobaczy\u0107 rozmow\u0119.",errorUnauthorized:"Sesja wygas\u0142a. Zaloguj si\u0119 ponownie.",errorPlan:"Czat nie jest dost\u0119pny w tym sklepie.",errorNotFound:"Nie znaleziono tej rozmowy.",errorUnavailable:"Czat jest chwilowo niedost\u0119pny. Spr\xF3buj za chwil\u0119.",errorGeneric:"Nie uda\u0142o si\u0119 wczyta\u0107 rozmowy.",paymentRequestPay:"Zap\u0142a\u0107 {amount}",paymentRequestChooseAmount:"Wybierz kwot\u0119 i zap\u0142a\u0107",paymentRequestPaid:"Op\u0142acone",paymentRequestExpired:"Pro\u015Bba wygas\u0142a",paymentRequestCancelled:"Pro\u015Bba anulowana",paymentRequestValidUntil:"Wa\u017Cna do {date}",paymentRequestRepliesOne:"+{count} odpowied\u017A",paymentRequestRepliesFew:"+{count} odpowiedzi",paymentRequestRepliesMany:"+{count} odpowiedzi",paymentRequestExtensionOne:"+{count} dzie\u0144 wa\u017Cno\u015Bci",paymentRequestExtensionFew:"+{count} dni wa\u017Cno\u015Bci",paymentRequestExtensionMany:"+{count} dni wa\u017Cno\u015Bci",paymentRequestRange:"od {min} do {max}",paymentRequestFallback:"Pro\u015Bba o p\u0142atno\u015B\u0107 \u2014 od\u015Bwie\u017C czat, aby j\u0105 zobaczy\u0107",paymentRequestPreview:"Pro\u015Bba o p\u0142atno\u015B\u0107"},en:{inboxHeading:"Messages",inboxIntro:"Your conversations with creators and the channels you belong to.",inboxEmpty:"No conversations yet. When you buy a consultation pack or community access, it shows up here.",inboxError:"Your messages could not be loaded.",loading:"Loading\u2026",retry:"Try again",back:"Back",selectConversation:"Pick a conversation from the list.",kindChat:"Chat",kindChannel:"Channel",startSection:"Ready to start",startChat:"Start the conversation",openChannel:"Open the channel",channelNotReady:"The creator has not opened this channel yet.",chatFallbackTitle:"Chat with the creator",channelFallbackTitle:"Channel",repliesLeftOne:"{count} reply left",repliesLeftFew:"{count} replies left",repliesLeftMany:"{count} replies left",noRepliesLeft:"No replies left in your pack",expiresOn:"Valid until {date}",expiredOn:"Expired on {date}",responseHours:"Replies within {hours} h",unread:"Unread: {count}",members:"Members: {count}",mutedBadge:"Muted",noMessagesYet:"No messages yet",emptyThread:"Write the first message. The creator replies within your pack.",emptyChannel:"There are no messages in this channel yet.",privacyNote:"The other side of the conversation reads your messages. Bitsnap keeps them for 90 days.",loadOlder:"Earlier messages",newMessages:"New messages \u2193",blockedNotice:"The creator has blocked you from sending messages in this conversation.",addAttachment:"Add attachment",photo:"Photo",file:"File",removeAttachment:"Remove attachment",uploading:"Uploading file",attachmentLoadFailed:"Could not load \u2014 retry",you:"You",creator:"Creator",systemLabel:"Automatic message",pinned:"Pinned",deletedPlaceholder:"This message was deleted",attachment:"Attachment",composerLabel:"Message",composerPlaceholder:"Write a message\u2026",send:"Send",composerExpired:"Your pack has expired, so you can no longer write here.",composerCreatorOnly:"Only the creator posts in this channel.",composerMuted:"You are muted in this channel.",composerReadOnly:"This access is read only.",lockRepliesTitle:"Your pack has no replies left",lockRepliesBody:"You can keep writing, but the creator can reply only after you buy another pack.",lockExpiredTitle:"Your pack has expired",lockExpiredBody:"You can still read the conversation. Buy a new pack to continue it.",lockThreadTitle:"You have no reply pack",lockThreadBody:"Buy a pack to write to the creator.",lockChannelTitle:"Members-only channel",lockChannelBody:"Buy access to read and post in this channel.",buyPack:"Buy a pack",buyAccess:"Buy access",buying:"Adding to cart\u2026",buyError:"Could not add it to the cart. Try again.",pending:"Sending\u2026",notConfirmed:"Waiting for the send to be confirmed",rejectedLink:"Links are blocked in this channel. Remove the link and send again.",rejectedBannedWord:"Your message contains a word blocked in this channel. Edit it and send again.",rejectedMedia:"Attachments are blocked in this channel.",rejectedCooldown:"You are posting too fast. Try again in {seconds} s.",rejectedBlocked:"The creator has blocked you from posting in this shop.",rejectedMuted:"You are muted in this channel.",rejectedReadOnly:"This access is read only.",rejectedPackEmpty:"The pack has no replies left.",rejectedForbidden:"You cannot post in this conversation.",rejectedGeneric:"Your message could not be sent.",failedNetwork:"No connection. Your message was not sent.",editMessage:"Edit",retrySend:"Send again",dismiss:"Discard",messageActions:"Message options",deleteMessage:"Delete message",deleteConfirm:"Delete for sure?",reportMessage:"Report message",conversationActions:"Conversation options",muteThread:"Mute notifications",unmuteThread:"Unmute notifications",muteError:"Notifications could not be changed.",reportConversation:"Report conversation",reportTitle:"Report message",reportConversationTitle:"Report conversation",reportReason:"Reason",reasonSpam:"Spam",reasonAbuse:"Harassment or abusive content",reasonIllegal:"Illegal content",reasonOther:"Something else",reportNote:"Details (optional)",reportSend:"Send report",reportCancel:"Cancel",reportSent:"Thank you. Your report went to moderation.",reportError:"Your report could not be sent. Try again.",liveLabel:"New messages appear live",pollingLabel:"New messages refresh every few seconds",errorNoToken:"Log in to the customer panel to see this conversation.",errorUnauthorized:"Your session has expired. Log in again.",errorPlan:"Chat is not available in this shop.",errorNotFound:"This conversation was not found.",errorUnavailable:"Chat is unavailable right now. Try again in a moment.",errorGeneric:"The conversation could not be loaded.",paymentRequestPay:"Pay {amount}",paymentRequestChooseAmount:"Choose an amount and pay",paymentRequestPaid:"Paid",paymentRequestExpired:"Request expired",paymentRequestCancelled:"Request cancelled",paymentRequestValidUntil:"Valid until {date}",paymentRequestRepliesOne:"+{count} reply",paymentRequestRepliesFew:"+{count} replies",paymentRequestRepliesMany:"+{count} replies",paymentRequestExtensionOne:"+{count} day of validity",paymentRequestExtensionFew:"+{count} days of validity",paymentRequestExtensionMany:"+{count} days of validity",paymentRequestRange:"from {min} to {max}",paymentRequestFallback:"Payment request \u2014 refresh chat to see it",paymentRequestPreview:"Payment request"}};function re(e,t=_chunkQ337IQNAjs.f.call(void 0, )){return _chunkQ337IQNAjs.b.call(void 0, He,t,e)}function K(e,t){return e.replace(/\{(\w+)\}/g,(n,a)=>a in t?String(t[a]):n)}function ce(e,t,n=_chunkQ337IQNAjs.f.call(void 0, )){if(t<=0)return e.noRepliesLeft;let a="other";try{a=new Intl.PluralRules(n).select(t)}catch (e6){}let r=a==="one"?e.repliesLeftOne:a==="few"?e.repliesLeftFew:e.repliesLeftMany;return K(r,{count:t})}function oe(e,t=_chunkQ337IQNAjs.f.call(void 0, )){let n=new Date(e);return Number.isNaN(n.getTime())?"":new Intl.DateTimeFormat(t,{day:"numeric",month:"numeric",year:"numeric"}).format(n)}function be(e,t=_chunkQ337IQNAjs.f.call(void 0, ),n=new Date){let a=new Date(e);if(Number.isNaN(a.getTime()))return"";let r=a.toDateString()===n.toDateString();return new Intl.DateTimeFormat(t,r?{hour:"2-digit",minute:"2-digit"}:{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(a)}function We(e,t,n){switch(t){case"moderation_link":return e.rejectedLink;case"moderation_banned_word":return e.rejectedBannedWord;case"moderation_media":return e.rejectedMedia;case"cooldown":return K(e.rejectedCooldown,{seconds:_nullishCoalesce(n, () => (30))});case"blocked":return e.rejectedBlocked;case"muted":return e.rejectedMuted;case"read_only":return e.rejectedReadOnly;case"pack_empty":case"replies_exhausted":return e.rejectedPackEmpty;case"forbidden":case"locked":return e.rejectedForbidden;case"network":case"unavailable":return e.failedNetwork;default:return e.rejectedGeneric}}var _jsxruntime = require('react/jsx-runtime');var ke="focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500";function Ke(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Je(e=0){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Pe(e,t){typeof e.scrollTo=="function"?e.scrollTo({top:e.scrollHeight,behavior:t?"smooth":"auto"}):e.scrollTop=e.scrollHeight}var Z=_chunkJS3KK56Hjs.g.call(void 0, "inline-flex min-h-11 items-center gap-2 rounded-md px-3 text-sm text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800",ke),xe=_chunkJS3KK56Hjs.g.call(void 0, "inline-flex min-h-11 items-center justify-center gap-2 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white hover:bg-neutral-800 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white dark:text-neutral-900 dark:hover:bg-neutral-200",ke);function ze({host:e,conversation:t,texts:n,locale:a,kind:r,title:d,onBack:y,onBuy:p,className:l}){let[i,g]=_react.useState.call(void 0, !1),[x,k]=_react.useState.call(void 0, null),[v,f]=_react.useState.call(void 0, ),[T,C]=_react.useState.call(void 0, ""),[h,b]=_react.useState.call(void 0, !1);_react.useEffect.call(void 0, ()=>{if(!h)return;let R=setTimeout(()=>b(!1),6e3);return()=>clearTimeout(R)},[h]);let _=d||_optionalChain([t, 'access', _2 => _2.channel, 'optionalAccess', _3 => _3.name])||(r==="channel"?n.channelFallbackTitle:n.chatFallbackTitle),E=wt(t,n,a);return _jsxruntime.jsxs.call(void 0, "section",{"data-bitsnap-chat":r,"aria-label":_,className:_chunkJS3KK56Hjs.g.call(void 0, "flex h-full min-h-[28rem] w-full min-w-0 flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white text-neutral-900 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-50",l),children:[_jsxruntime.jsxs.call(void 0, "header",{className:"flex items-start gap-2 border-b border-neutral-200 px-3 py-2 dark:border-neutral-800",children:[y&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:y,"aria-label":n.back,className:_chunkJS3KK56Hjs.g.call(void 0, Z,"w-11 justify-center px-0"),children:_jsxruntime.jsx.call(void 0, _lucidereact.ArrowLeft,{className:"size-5","aria-hidden":"true"})}),_jsxruntime.jsxs.call(void 0, "div",{className:"min-w-0 flex-1 py-1.5",children:[_jsxruntime.jsxs.call(void 0, "h2",{className:"flex items-center gap-2 text-base font-semibold",children:[_jsxruntime.jsx.call(void 0, "span",{className:"truncate",children:_}),_jsxruntime.jsx.call(void 0, Ct,{live:t.live,texts:n})]}),E.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:E.map(R=>_jsxruntime.jsx.call(void 0, "span",{children:R},R))})]}),t.status==="ready"&&_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-label":n.conversationActions,"aria-expanded":i,onClick:()=>g(R=>!R),className:_chunkJS3KK56Hjs.g.call(void 0, Z,"w-11 justify-center px-0"),children:_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontal,{className:"size-5","aria-hidden":"true"})})]}),i&&t.status==="ready"&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap gap-1 border-b border-neutral-200 bg-neutral-50 px-3 py-1 dark:border-neutral-800 dark:bg-neutral-950",children:[r==="thread"&&t.thread&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Z,onClick:async()=>{g(!1);try{await t.setMuted(!t.thread.muted),f(void 0)}catch (e7){f(n.muteError)}},children:t.thread.muted?n.unmuteThread:n.muteThread}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Z,onClick:()=>{g(!1),k({})},children:n.reportConversation})]}),t.status==="loading"&&_jsxruntime.jsx.call(void 0, vt,{texts:n}),t.status==="error"&&_jsxruntime.jsx.call(void 0, Nt,{conversation:t,texts:n}),t.status==="locked"&&t.lock&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 flex-col justify-center overflow-y-auto p-4",children:_jsxruntime.jsx.call(void 0, Ye,{host:e,lock:t.lock,kind:r,texts:n,locale:a,onBuy:p,prominent:!0})}),t.status==="ready"&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Mt,{conversation:t,texts:n,locale:a,kind:r,onReport:R=>k({messageId:R}),onEdit:R=>{C(R.body),t.discard(R.id)}}),v&&_jsxruntime.jsx.call(void 0, "p",{role:"status",className:"px-4 pb-2 text-xs text-red-700 dark:text-red-400",children:v}),t.lock&&_jsxruntime.jsx.call(void 0, "div",{className:"border-t border-neutral-200 p-3 dark:border-neutral-800",children:_jsxruntime.jsx.call(void 0, Ye,{host:e,lock:t.lock,kind:r,texts:n,locale:a,onBuy:p})}),x?_jsxruntime.jsx.call(void 0, Lt,{texts:n,messageId:x.messageId,onCancel:()=>k(null),onSubmit:async(R,w)=>{await t.report({messageId:x.messageId,reason:R,note:w}),k(null),f(void 0),b(!0)}}):_jsxruntime.jsx.call(void 0, zt,{conversation:t,texts:n,kind:r,draft:T,setDraft:C})]}),h&&_jsxruntime.jsx.call(void 0, "p",{role:"status",className:"border-t border-neutral-200 px-4 py-2 text-xs text-neutral-700 dark:border-neutral-800 dark:text-neutral-300",children:n.reportSent})]})}function wt(e,t,n){let a=[];if(e.thread&&e.thread.kind==="pack"){if(a.push(ce(t,e.thread.repliesLeft,n)),e.thread.expiresAt){let r=oe(e.thread.expiresAt,n);a.push(K(e.thread.composerLocked?t.expiredOn:t.expiresOn,{date:r}))}e.thread.responseHours>0&&a.push(K(t.responseHours,{hours:e.thread.responseHours})),e.thread.muted&&a.push(t.mutedBadge)}return e.channel&&(e.channel.topic&&a.push(e.channel.topic),e.channel.memberCount>0&&a.push(K(t.members,{count:e.channel.memberCount}))),a}function Ct({live:e,texts:t}){if(e!=="live"&&e!=="polling")return null;let n=e==="live"?t.liveLabel:t.pollingLabel;return _jsxruntime.jsx.call(void 0, "span",{title:n,"data-live":e,className:_chunkJS3KK56Hjs.g.call(void 0, "inline-block size-2 shrink-0 rounded-full",e==="live"?"bg-emerald-500":"bg-neutral-400 dark:bg-neutral-500"),children:_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:n})})}function vt({texts:e}){return _jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true","aria-label":e.loading,className:"flex flex-1 flex-col gap-3 p-4",children:[60,40,70].map((t,n)=>_jsxruntime.jsx.call(void 0, "div",{"aria-hidden":"true",style:{width:`${t}%`},className:_chunkJS3KK56Hjs.g.call(void 0, "h-10 rounded-2xl bg-neutral-100 motion-safe:animate-pulse dark:bg-neutral-800",n===1&&"self-end")},n))})}function Tt(e,t){switch(e){case"no_token":return t.errorNoToken;case"unauthorized":return t.errorUnauthorized;case"plan_required":return t.errorPlan;case"not_found":return t.errorNotFound;case"unavailable":case"network":return t.errorUnavailable;default:return t.errorGeneric}}function Nt({conversation:e,texts:t}){let n=_nullishCoalesce(_optionalChain([e, 'access', _4 => _4.error, 'optionalAccess', _5 => _5.code]), () => ("")),a=n!=="no_token"&&n!=="plan_required"&&n!=="unauthorized";return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-1 flex-col items-start justify-center gap-3 p-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700 dark:text-neutral-300",children:Tt(n,t)}),a&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:xe,onClick:e.reload,children:t.retry})]})}function Ye({host:e,lock:t,kind:n,texts:a,locale:r,onBuy:d,prominent:y}){let[p,l]=_react.useState.call(void 0, !1),[i,g]=_react.useState.call(void 0, ""),[x,k]=_react.useState.call(void 0, String((_nullishCoalesce(t.priceCents, () => (0)))/100)),v=x.trim().replace(",","."),f=/^\d+(\.\d{0,2})?$/.test(v)?Math.round(Number(v)*100):NaN,T=t.priceType==="pay_what_you_want",C=_nullishCoalesce(t.minimumCents, () => (0)),h=_nullishCoalesce(t.maximumCents, () => (Number.MAX_SAFE_INTEGER)),b=Number.isInteger(f)&&f>=C&&f<=h&&(f>0||t.freeClaimLimit!=null),_=t.freeClaimLimit!=null&&(t.priceType==="free"||T&&C===0&&f===0),[E,R]=_react.useState.call(void 0, ""),[w,c]=_react.useState.call(void 0, ""),[L,q]=_react.useState.call(void 0, !1),[I,P]=_react.useState.call(void 0, null),[u,s]=_react.useState.call(void 0, 0),[m,j]=_react.useState.call(void 0, 0),B=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{L&&_optionalChain([B, 'access', _6 => _6.current, 'optionalAccess', _7 => _7.focus, 'call', _8 => _8()])},[L]),_react.useEffect.call(void 0, ()=>{if(m<=0)return;let A=window.setTimeout(()=>j(m-1),1e3);return()=>window.clearTimeout(A)},[m]);let D=()=>{q(!1),c(""),P(null),s(A=>A+1),g("")},F=r.toLowerCase().startsWith("en"),[Y,O]=t.reason==="replies"?[a.lockRepliesTitle,a.lockRepliesBody]:t.reason==="expired"?[a.lockExpiredTitle,a.lockExpiredBody]:n==="channel"?[a.lockChannelTitle,a.lockChannelBody]:[a.lockThreadTitle,a.lockThreadBody],J=n==="channel"?a.buyAccess:a.buyPack,ne=d!=null&&t.productId!=null;return _jsxruntime.jsxs.call(void 0, "div",{"data-testid":"chat-lock","data-lock":t.reason,className:_chunkJS3KK56Hjs.g.call(void 0, "flex gap-3 rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",y?"flex-col items-start p-5":"flex-col sm:flex-row sm:items-center"),children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:_chunkJS3KK56Hjs.g.call(void 0, "shrink-0 text-neutral-500 dark:text-neutral-400",y?"size-6":"hidden size-5 sm:block"),"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"min-w-0 flex-1",children:[_jsxruntime.jsx.call(void 0, "p",{className:_chunkJS3KK56Hjs.g.call(void 0, "font-semibold",y?"text-lg":"text-sm"),children:Y}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-0.5 text-sm text-neutral-600 dark:text-neutral-300",children:O}),_&&_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 grid max-w-sm gap-2",children:[_jsxruntime.jsxs.call(void 0, "label",{className:"grid gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{children:F?"Email":"E-mail"}),_jsxruntime.jsx.call(void 0, "input",{type:"email",autoComplete:"email",value:E,onChange:A=>{R(A.currentTarget.value),D()},disabled:p,className:"h-11 rounded-md border border-neutral-300 bg-white px-3 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-50"})]}),L?_jsxruntime.jsxs.call(void 0, "label",{className:"grid gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{children:F?"Email code":"Kod z\xA0e-maila"}),_jsxruntime.jsx.call(void 0, "input",{ref:B,inputMode:"numeric",autoComplete:"one-time-code",value:w,onChange:A=>c(A.currentTarget.value),className:"h-11 rounded-md border border-neutral-300 bg-white px-3 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-50"})]}):E.includes("@")?_jsxruntime.jsx.call(void 0, _chunkZ3YOJ6NZjs.a,{host:e,action:"free_chat_claim",locale:r,onToken:P,onFailure:()=>P(null)},u):null,L&&_jsxruntime.jsxs.call(void 0, "button",{type:"button",disabled:p||m>0,className:"min-h-11 text-sm underline disabled:opacity-50",onClick:D,children:[F?"Request a new code":"Popro\u015B o\xA0nowy kod",m>0?` (${m}s)`:""]})]}),T&&_jsxruntime.jsxs.call(void 0, "label",{className:"mt-3 grid max-w-xs gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{children:F?`Amount (${(C/100).toFixed(2)}\u2013${Number.isFinite(h)?(h/100).toFixed(2):"\u221E"} PLN)`:`Kwota (${(C/100).toFixed(2)}\u2013${Number.isFinite(h)?(h/100).toFixed(2):"\u221E"} z\u0142)`}),_jsxruntime.jsx.call(void 0, "input",{"aria-label":F?"Amount":"Kwota",inputMode:"decimal",type:"text",min:C/100,max:Number.isFinite(h)?h/100:void 0,step:"0.01",value:x,onChange:A=>k(A.currentTarget.value),onBlur:()=>{Number.isFinite(f)&&k((f/100).toFixed(2))},className:"h-11 rounded-md border border-neutral-300 bg-white px-3 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-50"}),!b&&_jsxruntime.jsx.call(void 0, "span",{role:"alert",className:"text-xs text-red-700 dark:text-red-400",children:F?f===0&&t.freeClaimLimit==null?"Free claims are unavailable. Enter a positive amount.":"Enter an amount within the range.":f===0&&t.freeClaimLimit==null?"Darmowy odbi\xF3r jest niedost\u0119pny. Wpisz kwot\u0119 wi\u0119ksz\u0105 od zera.":"Kwota musi mie\u015Bci\u0107 si\u0119 w\xA0podanym zakresie."})]}),t.welcome&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 whitespace-pre-wrap text-sm",children:t.welcome}),i&&_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"mt-2 text-sm text-red-700 dark:text-red-400",children:i})]}),ne&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunkJS3KK56Hjs.g.call(void 0, xe,"shrink-0"),disabled:p||T&&!b||_&&(!E.includes("@")||!L&&I===null||L&&!w),"aria-busy":p||void 0,onClick:async()=>{l(!0),g("");try{_?(await d({...t,...T?{amount:f}:{},email:E,...L?{code:w}:{turnstileToken:I}}),L||(q(!0),j(60))):await d({...t,...T?{amount:f}:{}})}catch(A){g(At(A,r,a.buyError)),L||(P(null),s(fe=>fe+1))}finally{l(!1)}},children:p?a.buying:T?F?"Choose what you pay":"Kup pakiet, p\u0142ac\u0105c, ile chcesz":_?L?F?"Claim for free":"Odbierz za darmo":F?"Send code":"Wy\u015Blij kod":J})]})}function Rt(e,t,n,a){return t?a.you:n==="thread"?a.creator:e.authorEmail.split("@")[0]||a.creator}function Mt({conversation:e,texts:t,locale:n,kind:a,onReport:r,onEdit:d}){let y=_react.useRef.call(void 0, null),p=_react.useRef.call(void 0, !0),l=_react.useRef.call(void 0, !1),i=_react.useRef.call(void 0, null),g=_react.useRef.call(void 0, null),[x,k]=_react.useState.call(void 0, ()=>new Set),[v,f]=_react.useState.call(void 0, !1),T=e.messages.length,C=_optionalChain([e, 'access', _9 => _9.messages, 'access', _10 => _10[T-1], 'optionalAccess', _11 => _11.id]);return _react.useEffect.call(void 0, ()=>{if(e.status!=="ready")return;let h=new Set(e.messages.map(w=>w.id)),b=i.current;i.current=h;let _=e.messages.reduce((w,c)=>w==null||c.createdAt<w?c.createdAt:w,null),E=g.current;if(g.current=_,!b)return;let R=e.messages.filter(w=>!b.has(w.id)&&(E==null||w.createdAt>=E));!R.length||e.loadingOlder||(k(w=>new Set([...w,...R.map(c=>c.id)])),p.current?f(!1):f(!0))},[e.messages,e.loadingOlder]),_react.useLayoutEffect.call(void 0, ()=>{let h=y.current;if(h){if(p.current){let b=Ke();Pe(h,!b&&l.current)}l.current=!0}},[T,C]),_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex min-h-0 flex-1 flex-col",children:[v&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>{let h=y.current;h&&Pe(h,!Ke()),p.current=!0,f(!1)},className:"absolute bottom-3 left-1/2 z-10 -translate-x-1/2 rounded-full bg-neutral-900 px-3 py-1.5 text-xs font-medium text-white shadow-md dark:bg-neutral-100 dark:text-neutral-900",children:_nullishCoalesce(t.newMessages, () => ("Nowe wiadomo\u015Bci \u2193"))}),_jsxruntime.jsxs.call(void 0, "div",{ref:y,role:"log","aria-live":"polite","aria-relevant":"additions",onLoadCapture:()=>{let h=y.current;h&&p.current&&Pe(h,!1)},onScroll:h=>{let b=h.currentTarget;p.current=b.scrollHeight-b.scrollTop-b.clientHeight<80},className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto overscroll-contain px-3 py-4 sm:px-4",children:[e.hasMore&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>{p.current=!1,e.loadOlder()},disabled:e.loadingOlder,className:_chunkJS3KK56Hjs.g.call(void 0, Z,"self-center text-xs"),children:e.loadingOlder?t.loading:t.loadOlder}),T===0&&_jsxruntime.jsxs.call(void 0, "div",{className:"m-auto max-w-sm text-center","data-testid":"chat-empty",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",children:t.noMessagesYet}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:a==="channel"?t.emptyChannel:t.emptyThread}),_optionalChain([e, 'access', _12 => _12.channel, 'optionalAccess', _13 => _13.welcome])&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 whitespace-pre-wrap text-sm",children:e.channel.welcome})]}),e.messages.map(h=>_jsxruntime.jsx.call(void 0, It,{message:h,mine:h.authorEmail.toLowerCase()===e.me,kind:a,texts:t,locale:n,getAttachmentURL:e.getAttachmentURL,animateEntry:x.has(h.id),onDelete:()=>e.deleteMessage(h.id),onReport:()=>r(h.id),onRetry:()=>void e.retry(h.id),onDiscard:()=>e.discard(h.id),onEdit:()=>d(h)},h.id))]})]})}function It({message:e,mine:t,kind:n,texts:a,locale:r,getAttachmentURL:d,animateEntry:y=!1,onDelete:p,onReport:l,onRetry:i,onDiscard:g,onEdit:x}){let[k,v]=_react.useState.call(void 0, !1),[f,T]=_react.useState.call(void 0, !1),[C,h]=_react.useState.call(void 0, ),[b,_]=_react.useState.call(void 0, !1),[E,R]=_react.useState.call(void 0, 0),w=_react.useRef.call(void 0, 0),c=()=>{h(void 0),_(!1),R(s=>s+1)},L=async s=>{if(C&&Date.now()<w.current)return;s.preventDefault();let m=window.open("about:blank","_blank");m&&(m.opener=null);try{let j=await d(e);w.current=Date.now()+5e4,h(j),m&&(m.location.href=j)}catch (e8){_optionalChain([m, 'optionalAccess', _14 => _14.close, 'call', _15 => _15()]),_(!0)}},q=e.local;if(_react.useEffect.call(void 0, ()=>{if(!e.attachmentKey||e.deleted||e.local)return;let s=!1;return _(!1),d(e).then(m=>{s||(w.current=Date.now()+5e4,h(m))}).catch(()=>{s||_(!0)}),()=>{s=!0}},[e.attachmentKey,e.deleted,!!e.local,d,E]),e.system)return _jsxruntime.jsxs.call(void 0, "div",{"data-message-id":e.id,className:"mx-auto max-w-md text-center text-xs text-neutral-600 dark:text-neutral-400",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:a.systemLabel}),e.body&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-0.5 whitespace-pre-wrap",children:e.body})]});let I=_optionalChain([q, 'optionalAccess', _16 => _16.state])==="rejected"||_optionalChain([q, 'optionalAccess', _17 => _17.state])==="failed",P=_optionalChain([q, 'optionalAccess', _18 => _18.state])==="pending"||_optionalChain([q, 'optionalAccess', _19 => _19.state])==="unconfirmed",u=!q&&!e.deleted;return _jsxruntime.jsxs.call(void 0, "div",{"data-message-id":e.id,"data-state":_nullishCoalesce(_optionalChain([q, 'optionalAccess', _20 => _20.state]), () => ((e.deleted?"deleted":"stored"))),className:_chunkJS3KK56Hjs.g.call(void 0, "group flex max-w-[85%] flex-col gap-1 sm:max-w-[75%]",y&&"motion-safe:animate-[bitsnap-chat-message-enter_190ms_ease-out]",t?"items-end self-end":"items-start self-start"),children:[_jsxruntime.jsxs.call(void 0, "div",{className:_chunkJS3KK56Hjs.g.call(void 0, "flex items-end gap-1",t&&"flex-row-reverse"),children:[_jsxruntime.jsx.call(void 0, "div",{className:_chunkJS3KK56Hjs.g.call(void 0, "min-w-0 rounded-2xl px-3.5 py-2 text-sm leading-relaxed transition-opacity duration-200 ease-out motion-reduce:transition-none",e.deleted?"border border-dashed border-neutral-300 bg-transparent italic text-neutral-500 dark:border-neutral-700 dark:text-neutral-400":t?"bg-neutral-900 text-white dark:bg-neutral-100 dark:text-neutral-900":"bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50",P&&"opacity-70",I&&"border border-red-600 dark:border-red-400"),children:e.deleted?a.deletedPlaceholder:e.kind==="payment_request"?_jsxruntime.jsx.call(void 0, jt,{message:e,mine:t,texts:a,locale:r}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-pre-wrap break-words",children:e.body}),!e.deleted&&e.attachmentName&&(e.attachmentKind==="image"?b?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:c,className:"mt-2 text-xs underline",children:a.attachmentLoadFailed}):C?_jsxruntime.jsx.call(void 0, "a",{href:C,onClick:L,target:"_blank",rel:"noreferrer",children:_jsxruntime.jsx.call(void 0, "img",{src:C,onError:()=>{Date.now()>=w.current?c():(h(void 0),_(!0))},alt:e.attachmentName,className:"mt-2 max-h-48 rounded-lg object-cover"})}):_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-label":a.loading,className:"mt-2 h-32 w-48 animate-pulse rounded-lg bg-current/10 motion-reduce:animate-none"}):_jsxruntime.jsxs.call(void 0, "a",{href:_nullishCoalesce(C, () => ("#")),onClick:L,download:e.attachmentName,className:"mt-2 flex max-w-56 items-center gap-2 rounded-lg border border-neutral-300/60 px-2 py-1.5 text-xs dark:border-neutral-700",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Paperclip,{className:"size-3.5 shrink-0","aria-hidden":"true"}),_jsxruntime.jsx.call(void 0, "span",{className:"min-w-0 flex-1 truncate",children:e.attachmentName}),_jsxruntime.jsx.call(void 0, "span",{children:Je(e.attachmentSize)})]})),b&&e.attachmentKind!=="image"&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:c,className:"mt-1 text-xs underline",children:a.attachmentLoadFailed}),e.attachmentName&&_optionalChain([q, 'optionalAccess', _21 => _21.state])==="pending"&&q.uploadProgress!=null&&_jsxruntime.jsxs.call(void 0, "p",{className:"mt-1 text-[11px] opacity-75",children:[a.uploading," ",q.uploadProgress,"%"]})]})}),u&&_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-label":a.messageActions,"aria-expanded":k,onClick:()=>{v(s=>!s),T(!1)},className:_chunkJS3KK56Hjs.g.call(void 0, "inline-flex size-11 shrink-0 items-center justify-center rounded-md text-neutral-500 opacity-100 hover:bg-neutral-100 sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100 dark:text-neutral-400 dark:hover:bg-neutral-800",k&&"sm:opacity-100",ke),children:_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontal,{className:"size-4","aria-hidden":"true"})})]}),_jsxruntime.jsxs.call(void 0, "p",{className:"flex items-center gap-1.5 px-1 text-[11px] text-neutral-500 dark:text-neutral-400",children:[e.pinned&&_jsxruntime.jsxs.call(void 0, "span",{className:"inline-flex items-center gap-0.5",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Pin,{className:"size-3","aria-hidden":"true"}),a.pinned]}),_jsxruntime.jsx.call(void 0, "span",{children:Rt(e,t,n,a)}),_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"\xB7"}),P?_jsxruntime.jsxs.call(void 0, "span",{className:"inline-flex items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Clock,{className:"size-3","aria-hidden":"true"}),_optionalChain([q, 'optionalAccess', _22 => _22.state])==="pending"?a.pending:a.notConfirmed]}):_jsxruntime.jsx.call(void 0, "time",{dateTime:e.createdAt,children:be(e.createdAt,r)})]}),I&&_jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:_chunkJS3KK56Hjs.g.call(void 0, "flex flex-col gap-1",t?"items-end":"items-start"),children:[_jsxruntime.jsxs.call(void 0, "p",{className:"flex items-start gap-1 text-xs text-red-700 dark:text-red-400",children:[_jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle,{className:"mt-px size-3.5 shrink-0","aria-hidden":"true"}),We(a,_nullishCoalesce(_optionalChain([q, 'optionalAccess', _23 => _23.reason]), () => ("")),_optionalChain([q, 'optionalAccess', _24 => _24.retryAfter]))]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap gap-1",children:[_optionalChain([q, 'optionalAccess', _25 => _25.state])==="failed"||_optionalChain([q, 'optionalAccess', _26 => _26.reason])==="cooldown"?_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunkJS3KK56Hjs.g.call(void 0, Z,"text-xs"),onClick:i,children:a.retrySend}):_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunkJS3KK56Hjs.g.call(void 0, Z,"text-xs"),onClick:x,children:a.editMessage}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunkJS3KK56Hjs.g.call(void 0, Z,"text-xs"),onClick:g,children:a.dismiss})]})]}),k&&u&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-wrap gap-1",children:t?_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunkJS3KK56Hjs.g.call(void 0, Z,"text-xs text-red-700 dark:text-red-400"),onClick:async()=>{if(!f){T(!0);return}v(!1),await p().catch(()=>{})},children:f?a.deleteConfirm:a.deleteMessage}):_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunkJS3KK56Hjs.g.call(void 0, Z,"text-xs"),onClick:()=>{v(!1),l()},children:a.reportMessage})})]})}function jt({message:e,mine:t,texts:n,locale:a}){let r=e.paymentRequest;if(!r||e.paymentRequestInvalid)return _jsxruntime.jsx.call(void 0, "article",{"aria-label":n.paymentRequestFallback,className:"min-w-0 max-w-full text-sm",children:n.paymentRequestFallback});let y=r.status==="expired"||r.status==="pending"&&Date.parse(r.expiresAt)<=Date.now()?"expired":r.status,p=r.amountMode==="exact"?_chunkPFKZ7KUUjs.a.call(void 0, r.amountMinor,r.currency,a):K(n.paymentRequestRange,{min:_chunkPFKZ7KUUjs.a.call(void 0, _nullishCoalesce(r.minAmountMinor, () => (0)),r.currency,a),max:_chunkPFKZ7KUUjs.a.call(void 0, _nullishCoalesce(r.maxAmountMinor, () => (0)),r.currency,a)}),l=(g,x,k,v)=>{let f="other";try{f=new Intl.PluralRules(a).select(g)}catch (e9){}return K(f==="one"?x:f==="few"?k:v,{count:g})},i=y==="paid"?n.paymentRequestPaid:y==="expired"?n.paymentRequestExpired:y==="cancelled"?n.paymentRequestCancelled:void 0;return _jsxruntime.jsxs.call(void 0, "article",{"aria-label":r.title,className:"w-full min-w-0 max-w-full rounded-lg border border-neutral-300 bg-white p-3 text-left text-neutral-900 shadow-sm dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-100",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"break-words text-sm font-semibold",children:r.title}),r.description&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-1 max-h-24 overflow-hidden whitespace-pre-wrap break-words text-xs text-neutral-600 dark:text-neutral-300",children:r.description}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 break-words text-base font-semibold",children:p}),_jsxruntime.jsxs.call(void 0, "ul",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-neutral-600 dark:text-neutral-300",children:[_jsxruntime.jsx.call(void 0, "li",{children:l(r.extraReplies,n.paymentRequestRepliesOne,n.paymentRequestRepliesFew,n.paymentRequestRepliesMany)}),r.extendExpiryDays>0&&_jsxruntime.jsx.call(void 0, "li",{children:l(r.extendExpiryDays,n.paymentRequestExtensionOne,n.paymentRequestExtensionFew,n.paymentRequestExtensionMany)})]}),y==="pending"&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-xs text-neutral-500 dark:text-neutral-400",children:K(n.paymentRequestValidUntil,{date:oe(r.expiresAt,a)})}),i?_jsxruntime.jsxs.call(void 0, "p",{className:"mt-3 inline-flex items-center gap-1 rounded-full bg-neutral-100 px-2.5 py-1 text-xs font-medium text-neutral-600 dark:bg-neutral-800 dark:text-neutral-300",children:[y==="paid"&&_jsxruntime.jsx.call(void 0, _lucidereact.Check,{className:"size-3.5","aria-hidden":"true"}),i]}):!t&&y==="pending"?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>window.open(r.paymentUrl,"_blank","noopener,noreferrer"),className:_chunkJS3KK56Hjs.g.call(void 0, "mt-3 flex min-h-11 w-full items-center justify-center rounded-md bg-blue-600 px-3 py-2 text-sm font-semibold text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-400",ke),children:r.amountMode==="exact"?K(n.paymentRequestPay,{amount:p}):n.paymentRequestChooseAmount}):null]})}function Pt(e,t,n){if(t==="thread"&&_optionalChain([e, 'access', _27 => _27.thread, 'optionalAccess', _28 => _28.blocked]))return n.blockedNotice;if(t==="thread"&&_optionalChain([e, 'access', _29 => _29.thread, 'optionalAccess', _30 => _30.composerLocked]))return n.composerExpired;if(t==="channel"&&e.channel){if(e.channel.role==="muted")return n.composerMuted;if(e.channel.whoCanPost==="creator"&&e.channel.role!=="creator")return n.composerCreatorOnly}}function zt({conversation:e,texts:t,kind:n,draft:a,setDraft:r}){let d=_react.useId.call(void 0, ),y=_react.useRef.call(void 0, null),p=_react.useRef.call(void 0, null),l=_react.useRef.call(void 0, null),[i,g]=_react.useState.call(void 0, ),[x,k]=_react.useState.call(void 0, !1),[v,f]=_react.useState.call(void 0, !1),[T,C]=_react.useState.call(void 0, ".pdf,.zip,.txt,.docx,.xlsx"),h=Pt(e,n,t);_react.useEffect.call(void 0, ()=>()=>{l.current&&clearTimeout(l.current)},[]);let b=w=>{l.current&&clearTimeout(l.current),l.current=null,k(!1),g(w)},_=()=>{!i||x||(k(!0),l.current=setTimeout(()=>{g(void 0),k(!1),l.current=null},140))};if(_react.useLayoutEffect.call(void 0, ()=>{let w=y.current;w&&(w.style.height="auto",w.style.height=`${Math.min(w.scrollHeight,160)}px`)},[a]),h)return _jsxruntime.jsx.call(void 0, "p",{"data-testid":"chat-composer-blocked",className:"border-t border-neutral-200 px-4 py-3 text-sm text-neutral-600 dark:border-neutral-800 dark:text-neutral-400",children:h});let E=w=>{_optionalChain([w, 'optionalAccess', _31 => _31.preventDefault, 'call', _32 => _32()]);let c=a.trim();!c&&!i||(r(""),g(void 0),e.send(c,i),requestAnimationFrame(()=>_optionalChain([y, 'access', _33 => _33.current, 'optionalAccess', _34 => _34.focus, 'call', _35 => _35()])))},R=w=>{w.key==="Enter"&&!w.shiftKey&&!w.nativeEvent.isComposing&&(w.preventDefault(),E())};return _jsxruntime.jsxs.call(void 0, "form",{onSubmit:E,className:"border-t border-neutral-200 px-3 pb-3 pt-2 dark:border-neutral-800",children:[e.messages.length===0&&_jsxruntime.jsx.call(void 0, "p",{className:"pb-2 text-xs text-neutral-500 dark:text-neutral-400",children:t.privacyNote}),i&&_jsxruntime.jsxs.call(void 0, "div",{className:_chunkJS3KK56Hjs.g.call(void 0, "mb-2 flex max-w-sm items-center gap-2 rounded-lg border border-neutral-300 bg-neutral-50 px-3 py-2 text-xs text-neutral-800 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100",x?"chat-preview-exit":"chat-preview-enter"),children:[_jsxruntime.jsx.call(void 0, "span",{className:"min-w-0 flex-1 truncate",children:i.name}),_jsxruntime.jsx.call(void 0, "span",{className:"text-neutral-500 dark:text-neutral-400",children:Je(i.size)}),_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-label":t.removeAttachment,onClick:_,disabled:x,className:"rounded p-1 hover:bg-neutral-200 disabled:cursor-default dark:hover:bg-neutral-800",children:_jsxruntime.jsx.call(void 0, _lucidereact.X,{className:"size-3.5"})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-end gap-2",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"relative",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button","aria-label":t.addAttachment,"aria-expanded":v,onClick:()=>f(w=>!w),className:_chunkJS3KK56Hjs.g.call(void 0, Z,"h-11 w-11 justify-center px-0 transition-transform duration-150 motion-safe:active:scale-95 motion-reduce:transition-none"),children:_jsxruntime.jsx.call(void 0, _lucidereact.Plus,{className:"size-5","aria-hidden":"true"})}),v&&_jsxruntime.jsxs.call(void 0, "div",{role:"menu",className:"absolute bottom-full left-0 z-20 mb-2 min-w-36 rounded-lg border border-neutral-200 bg-white p-1 shadow-lg dark:border-neutral-700 dark:bg-neutral-900",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",role:"menuitem",className:"block w-full rounded px-3 py-2 text-left text-sm hover:bg-neutral-100 dark:hover:bg-neutral-800",onClick:()=>{C("image/jpeg,image/png,image/webp,image/gif"),p.current&&(p.current.accept="image/jpeg,image/png,image/webp,image/gif",p.current.click()),f(!1)},children:t.photo}),_jsxruntime.jsx.call(void 0, "button",{type:"button",role:"menuitem",className:"block w-full rounded px-3 py-2 text-left text-sm hover:bg-neutral-100 dark:hover:bg-neutral-800",onClick:()=>{C(".pdf,.zip,.txt,.docx,.xlsx"),p.current&&(p.current.accept=".pdf,.zip,.txt,.docx,.xlsx",p.current.click()),f(!1)},children:t.file})]}),_jsxruntime.jsx.call(void 0, "input",{ref:p,hidden:!0,type:"file",accept:T,onChange:w=>{let c=_optionalChain([w, 'access', _36 => _36.target, 'access', _37 => _37.files, 'optionalAccess', _38 => _38[0]]);c&&b(c),w.currentTarget.value=""}})]}),_jsxruntime.jsx.call(void 0, "label",{htmlFor:d,className:"sr-only",children:t.composerLabel}),_jsxruntime.jsx.call(void 0, "textarea",{id:d,ref:y,rows:1,value:a,onChange:w=>r(w.target.value),onKeyDown:R,placeholder:t.composerPlaceholder,className:"max-h-40 min-h-11 flex-1 resize-none rounded-xl border border-neutral-300 bg-white px-3 py-2.5 text-sm text-neutral-900 placeholder:text-neutral-500 focus-visible:border-neutral-500 focus-visible:outline-none dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-400"}),_jsxruntime.jsx.call(void 0, "button",{type:"submit","aria-label":t.send,disabled:a.trim().length===0&&!i,className:_chunkJS3KK56Hjs.g.call(void 0, xe,"w-11 px-0 transition-[transform,opacity] duration-150 ease-out motion-safe:active:scale-95 disabled:scale-100 motion-reduce:transition-none"),children:_jsxruntime.jsx.call(void 0, _lucidereact.SendHorizontal,{className:"size-5","aria-hidden":"true"})})]})]})}var _t=["spam","abuse","illegal","other"];function Lt({texts:e,messageId:t,onCancel:n,onSubmit:a}){let[r,d]=_react.useState.call(void 0, "spam"),[y,p]=_react.useState.call(void 0, ""),[l,i]=_react.useState.call(void 0, !1),[g,x]=_react.useState.call(void 0, !1),k=_react.useId.call(void 0, ),v={spam:e.reasonSpam,abuse:e.reasonAbuse,illegal:e.reasonIllegal,other:e.reasonOther};return _jsxruntime.jsxs.call(void 0, "form",{"data-testid":"chat-report",className:"flex flex-col gap-3 border-t border-neutral-200 p-4 dark:border-neutral-800",onSubmit:async f=>{f.preventDefault(),i(!0),x(!1);try{await a(r,y.trim())}catch (e10){x(!0)}finally{i(!1)}},children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-semibold",children:t?e.reportTitle:e.reportConversationTitle}),_jsxruntime.jsxs.call(void 0, "fieldset",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "legend",{className:"mb-1 text-xs text-neutral-600 dark:text-neutral-400",children:e.reportReason}),_t.map(f=>_jsxruntime.jsxs.call(void 0, "label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[_jsxruntime.jsx.call(void 0, "input",{type:"radio",name:"chat-report-reason",value:f,checked:r===f,onChange:()=>d(f),className:"size-4 accent-neutral-900 dark:accent-white"}),v[f]]},f))]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "label",{htmlFor:k,className:"text-xs text-neutral-600 dark:text-neutral-400",children:e.reportNote}),_jsxruntime.jsx.call(void 0, "textarea",{id:k,rows:2,maxLength:1e3,value:y,onChange:f=>p(f.target.value),className:"resize-none rounded-xl border border-neutral-300 bg-white px-3 py-2 text-sm focus-visible:border-neutral-500 focus-visible:outline-none dark:border-neutral-700 dark:bg-neutral-950"})]}),g&&_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"text-sm text-red-700 dark:text-red-400",children:e.reportError}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap justify-end gap-2",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Z,onClick:n,children:e.reportCancel}),_jsxruntime.jsx.call(void 0, "button",{type:"submit",className:xe,disabled:l,"aria-busy":l||void 0,children:e.reportSend})]})]})}function At(e,t,n){let a=e instanceof Error?e.message:"",r=t.toLowerCase().startsWith("en");return_nullishCoalesce(_optionalChain([{"amount-below-minimum":["Kwota jest ni\u017Csza od minimalnej.","The amount is below the minimum."],"amount-above-maximum":["Kwota przekracza maksymaln\u0105.","The amount is above the maximum."],"amount-below-gateway-minimum":["Kwota jest za niska dla dost\u0119pnych p\u0142atno\u015Bci.","The amount is too low for available payment methods."],"amount-invalid":["Podaj prawid\u0142ow\u0105 kwot\u0119.","Enter a valid amount."],"email-verification-required":["Potwierd\u017A adres e-mail, aby odebra\u0107 pakiet.","Verify your email to claim this pack."],"free-claim-exists":["Ten adres e-mail wykorzysta\u0142 ju\u017C limit darmowych odbior\xF3w.","This email has reached the free claim limit."],"free-order-not-supported":["Nie mo\u017Cna zrealizowa\u0107 tego darmowego zam\xF3wienia.","This free order cannot be completed."],"captcha-required":["Potwierd\u017A, \u017Ce nie jeste\u015B robotem.","Complete the security check."],"captcha-invalid":["Weryfikacja wygas\u0142a. Spr\xF3buj ponownie.","The security check expired. Try again."],"rate-limited":["Zbyt wiele pr\xF3b. Spr\xF3buj ponownie za chwil\u0119.","Too many attempts. Try again shortly."],"incorrect-code":["Nieprawid\u0142owy kod. Sprawd\u017A wiadomo\u015B\u0107 i\xA0spr\xF3buj ponownie.","The code is incorrect. Check your email and try again."],"too-many-attempts":["Popro\u015B o\xA0nowy kod za kilka minut.","Request a new code in a few minutes."],unavailable:["Weryfikacja jest chwilowo niedost\u0119pna.","Verification is temporarily unavailable."]}, 'access', _39 => _39[a], 'optionalAccess', _40 => _40[r?1:0]]), () => (n))}var Et=()=>Promise.resolve().then(() => _interopRequireWildcard(require("@nats-io/nats-core")));function _e(e){let t=_nullishCoalesce(e.pollIntervalMs, () => (8e3)),n=_nullishCoalesce(e.retryMs, () => (6e4)),a=_nullishCoalesce(e.loadNats, () => (Et)),r=`.${e.kind}.${e.id}`,d=!1,y,p="",l,i,g,x=()=>{l!=null&&clearInterval(l),l=void 0},k=()=>{d||(e.onMode("polling"),l==null&&(l=setInterval(()=>{e.poll().catch(()=>{})},t)),i==null&&(i=setTimeout(()=>{i=void 0,f()},n)))},v=T=>{g!=null&&clearTimeout(g);let C=Date.parse(T);if(!Number.isFinite(C))return;let h=Math.max(5e3,C-Date.now()-6e4);g=setTimeout(async()=>{if(!d)try{let b=await e.client.realtimeToken({fresh:!0});p=b.jwt,v(b.expiresAt)}catch (e11){}},h)};async function f(){if(!d){if(typeof WebSocket>"u"){k();return}e.onMode("connecting");try{let T=await e.client.realtimeToken(),C=T.subjects.find(R=>R.endsWith(r));if(C||(T=await e.client.realtimeToken({fresh:!0}),C=T.subjects.find(R=>R.endsWith(r))),!C||!T.jwt)throw new Error("subject not granted");p=T.jwt;let h=await a();if(d)return;let b=e.realtimeUrl?[e.realtimeUrl]:T.servers.length>0?T.servers:[Me],_=await h.wsconnect({servers:b,authenticator:h.jwtAuthenticator(()=>p),name:"bitsnap-react/chat",reconnect:!0,maxReconnectAttempts:5});if(d){_.close().catch(()=>{});return}y=_;let E=new TextDecoder;_.subscribe(C,{callback:(R,w)=>{if(!R)try{let c=Ie(JSON.parse(E.decode(w.data)));c&&e.onEvent(c)}catch (e12){}}}),_.closed().then(()=>{y===_&&(y=void 0,k())}),v(T.expiresAt),x(),e.onMode("live"),e.poll().catch(()=>{})}catch (e13){k()}}}return f(),()=>{d=!0,x(),i!=null&&clearTimeout(i),g!=null&&clearTimeout(g);let T=y;y=void 0,T&&T.close().catch(()=>{})}}var Le=50,ae={status:"loading",messages:[],hasMore:!1,loadingOlder:!1,live:"off"};function St(){let e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let a=0;a<16;a++)t[a]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function pe(e,t){let n=new Map(e.map(a=>[a.id,a]));for(let a of t){let r=n.get(a.id);if(a.status==="pending"){if(r&&!r.local)continue;n.set(a.id,{...a,retryFile:_optionalChain([r, 'optionalAccess', _41 => _41.retryFile]),local:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _42 => _42.local]), () => ({state:"pending"}))});continue}_optionalChain([r, 'optionalAccess', _43 => _43.local])&&r.local.state!=="pending"&&r.local.state!=="unconfirmed"||n.set(a.id,{...a,local:void 0})}return[...n.values()].sort((a,r)=>{let d=Date.parse(a.createdAt)||0,y=Date.parse(r.createdAt)||0;return d-y})}function qt(e,t){let n=e.findIndex(r=>r.id===t.id);if(n<0)return e;let a=[...e];return a[n]={...t,local:void 0},a}function Ae(e){if(e.kind==="pack"){if(e.composerLocked)return{reason:"expired",productId:e.productId};if(e.repliesLeft<=0)return{reason:"replies",productId:e.productId}}}function et(e,t,n){let a=Number(e.data.price_cents);return{reason:t,productId:typeof e.data.product_id=="string"&&e.data.product_id?e.data.product_id:n,priceCents:Number.isFinite(a)&&a>0?a:void 0,priceType:e.data.price_type==="free"||e.data.price_type==="pay_what_you_want"?e.data.price_type:"one_time",minimumCents:Number.isFinite(Number(e.data.price_min_cents))?Number(e.data.price_min_cents):void 0,maximumCents:Number.isFinite(Number(e.data.price_max_cents))?Number(e.data.price_max_cents):void 0,freeClaimLimit:Number.isFinite(Number(e.data.free_claim_limit))?Number(e.data.free_claim_limit):void 0,welcome:typeof e.data.welcome=="string"?e.data.welcome:void 0}}function we(e){return e instanceof $?e:new $("internal_error",0)}function Ce(e){let{client:t,target:n}=e,[a,r]=_react.useState.call(void 0, ae),[d,y]=_react.useState.call(void 0, 0),p=_react.useRef.call(void 0, a);p.current=a;let l=_react.useRef.call(void 0, new Set),i=_react.useRef.call(void 0, void 0),g=_react.useRef.call(void 0, void 0),x=n.kind==="thread"?`t:${_nullishCoalesce(n.threadId, () => (""))}:${_nullishCoalesce(n.productId, () => (""))}`:`c:${n.channelId}:${_nullishCoalesce(n.productId, () => (""))}`;_react.useEffect.call(void 0, ()=>{let u=!1;if(g.current=void 0,r(ae),t!==null){if(!t){r({...ae,status:"error",error:new $("no_token",401)});return}return(async()=>{try{let s=await t.me(),m=s.email.toLowerCase(),j,B,D;if(n.kind==="thread"){if(j=n.threadId?s.threads.find(Y=>Y.id===n.threadId):s.threads.find(Y=>Y.productId===n.productId),!j&&n.productId)try{j=await t.openThread(n.productId)}catch(Y){let O=we(Y);if(O.code==="locked"||O.status===404){u||r({...ae,status:"locked",me:m,lock:et(O,"no-pack",n.productId)});return}throw O}if(!j)throw new $("not_found",404);D=j.id}else B=s.channels.find(Y=>Y.id===n.channelId),D=n.channelId;let F;try{F=await t.messages(D,{limit:Le})}catch(Y){let O=we(Y);if(O.code==="locked"){u||r({...ae,status:"locked",me:m,thread:j,channel:B,threadId:D,lock:et(O,n.kind==="channel"?"no-access":"no-pack",_nullishCoalesce(_nullishCoalesce(n.productId, () => (_optionalChain([B, 'optionalAccess', _44 => _44.productId]))), () => (_optionalChain([j, 'optionalAccess', _45 => _45.productId]))))});return}throw O}if(u)return;r({...ae,status:"ready",me:m,thread:j,channel:B,threadId:D,lock:j?Ae(j):void 0,messages:pe([],F.messages),hasMore:F.hasMore})}catch(s){u||r({...ae,status:"error",error:we(s)})}})(),()=>{u=!0}}},[t,x,d]);let k=_react.useCallback.call(void 0, ()=>{t&&(i.current&&clearTimeout(i.current),i.current=setTimeout(async()=>{try{let u=await t.me();r(s=>{if(s.status!=="ready")return s;let m=s.thread&&u.threads.find(B=>B.id===s.thread.id),j=s.channel&&u.channels.find(B=>B.id===s.channel.id);return{...s,thread:_nullishCoalesce(m, () => (s.thread)),channel:_nullishCoalesce(j, () => (s.channel)),lock:m?Ae(m):s.lock}})}catch (e14){}},1500))},[t]),v=_react.useRef.call(void 0, new Set);_react.useEffect.call(void 0, ()=>{let u=!1;for(let s of a.messages)_optionalChain([s, 'access', _46 => _46.paymentRequest, 'optionalAccess', _47 => _47.status])!=="paid"||v.current.has(s.id)||(v.current.add(s.id),u=!0);u&&k()},[a.messages,k]);let f=_react.useCallback.call(void 0, async()=>{let{threadId:u}=p.current;if(!t||!u)return;let s=await t.messages(u,{limit:Le});r(m=>m.threadId===u?{...m,messages:pe(m.messages,s.messages)}:m)},[t]),T=_react.useCallback.call(void 0, u=>{r(s=>{switch(u.type){case"message.created":return{...s,messages:pe(s.messages,[u.message])};case"message.updated":{let m=qt(s.messages,u.message);return m===s.messages?s:{...s,messages:m}}case"message.rejected":return{...s,messages:s.messages.map(m=>m.id===u.id?{...m,local:{state:"rejected",reason:u.reason||"rejected"}}:m)};case"message.deleted":return{...s,messages:s.messages.map(m=>m.id===u.id?{...m,deleted:!0,body:"",attachmentKey:void 0}:m)};case"message.pinned":case"message.unpinned":return{...s,messages:s.messages.map(m=>m.id===u.id?{...m,pinned:u.type==="message.pinned"}:m)}}}),u.type==="message.created"&&!u.message.system&&u.message.authorEmail.toLowerCase()!==p.current.me&&k()},[k]),h=a.status==="ready"?a.threadId:void 0;_react.useEffect.call(void 0, ()=>{if(!t||!h)return;let u=_e({client:t,kind:n.kind,id:h,onEvent:T,onMode:s=>r(m=>({...m,live:s})),poll:f,pollIntervalMs:e.pollIntervalMs,realtimeUrl:e.realtimeUrl,loadNats:e.loadNats});return()=>{u(),r(s=>({...s,live:"off"}))}},[t,h,T,f]),_react.useEffect.call(void 0, ()=>{if(!t||!a.threadId||a.status!=="ready")return;let u=[...a.messages].reverse().find(s=>!s.local&&s.authorEmail.toLowerCase()!==a.me);!u||g.current===u.id||(g.current=u.id,t.markRead(a.threadId,u.id).catch(()=>{}))},[t,a.threadId,a.status,a.messages,a.me]),_react.useEffect.call(void 0, ()=>()=>{for(let u of l.current)clearTimeout(u);i.current&&clearTimeout(i.current)},[]);let b=(u,s)=>r(m=>({...m,messages:m.messages.map(j=>j.id===u?s(j):j)})),_=_react.useCallback.call(void 0, async(u,s,m)=>{let j=u.trim(),{threadId:B,me:D}=p.current;if(!t||!B||!j&&!s)return;let F=_nullishCoalesce(m, () => (St())),Y={id:F,threadId:B,authorEmail:_nullishCoalesce(D, () => ("")),body:j,kind:"text",retryFile:s,...s?{attachmentName:s.name,attachmentSize:s.size,attachmentContentType:s.type,attachmentKind:s.type.startsWith("image/")?"image":"file"}:{},createdAt:new Date().toISOString(),pinned:!1,deleted:!1,system:!1,status:"pending",local:{state:"pending"}};r(O=>({...O,messages:[...O.messages,Y]}));try{let O=s?await t.uploadAttachment(B,s,A=>b(F,fe=>({...fe,local:{...fe.local,state:"pending",uploadProgress:A}}))):void 0;O&&b(F,A=>({...A,attachmentKey:O.key,attachmentKind:O.kind,attachmentName:O.filename,attachmentSize:O.size,attachmentContentType:O.contentType,local:{state:"pending"}}));let J=await t.send(B,{body:j,clientId:F,...O?{attachment:O}:{}});r(A=>({...A,messages:pe(A.messages,[{...J.message,id:F}]),thread:A.thread?{...A.thread,...J.thread,id:A.thread.id}:A.thread,lock:A.thread?Ae({...A.thread,...J.thread,id:A.thread.id}):A.lock}));let ne=setTimeout(()=>{l.current.delete(ne),b(F,A=>_optionalChain([A, 'access', _48 => _48.local, 'optionalAccess', _49 => _49.state])==="pending"?{...A,local:{state:"unconfirmed"}}:A)},_nullishCoalesce(e.confirmTimeoutMs, () => (45e3)));l.current.add(ne)}catch(O){let J=we(O),ne=J.code==="network"||J.code==="unavailable"||J.status>=500;b(F,A=>({...A,local:{state:ne?"failed":"rejected",reason:J.code,retryAfter:J.retryAfter,keepId:ne||m!=null}}))}},[t,e.confirmTimeoutMs]),E=_react.useCallback.call(void 0, u=>{r(s=>({...s,messages:s.messages.filter(m=>m.id!==u)}))},[]),R=_react.useCallback.call(void 0, async u=>{let s=p.current.messages.find(j=>j.id===u);if(!s)return;let m=_optionalChain([s, 'access', _50 => _50.local, 'optionalAccess', _51 => _51.state])!=="rejected"||s.local.keepId===!0;E(u),await _(s.body,s.retryFile,m?u:void 0)},[E,_]),w=_react.useCallback.call(void 0, async u=>{let{threadId:s}=p.current,m=p.current.messages.find(j=>j.id===u);if(!(!t||!s||!m)){b(u,j=>({...j,deleted:!0,body:"",attachmentKey:void 0}));try{await t.deleteMessage(s,u)}catch(j){throw b(u,()=>m),j}}},[t]),c=_react.useCallback.call(void 0, async u=>{let s=p.current.threadId;if(!t||!s)throw new $("not_found",404);return t.attachmentURL(s,u)},[t]),L=_react.useCallback.call(void 0, async u=>{let{threadId:s}=p.current;!t||!s||await t.report({threadId:s,...u})},[t]),q=_react.useCallback.call(void 0, async u=>{let{threadId:s}=p.current;!t||!s||(await t.mute(s,u),r(m=>m.thread?{...m,thread:{...m.thread,muted:u}}:m))},[t]),I=_react.useCallback.call(void 0, async()=>{let{threadId:u,messages:s,hasMore:m,loadingOlder:j}=p.current,B=s.find(D=>!D.local);if(!(!t||!u||!m||j||!B)){r(D=>({...D,loadingOlder:!0}));try{let D=await t.messages(u,{before:B.id,limit:Le});r(F=>({...F,loadingOlder:!1,hasMore:D.hasMore,messages:pe(F.messages,D.messages)}))}catch (e15){r(D=>({...D,loadingOlder:!1}))}}},[t]),P=_react.useCallback.call(void 0, ()=>y(u=>u+1),[]);return{...a,send:_,retry:R,getAttachmentURL:c,discard:E,deleteMessage:w,report:L,setMuted:q,loadOlder:I,reload:P}}function tt(e){let[t,n]=_react.useState.call(void 0, null),a=_nullishCoalesce(e.host, () => (_chunkMDAFPGPAjs.b.call(void 0, ).host));_react.useEffect.call(void 0, ()=>{e.client||e.token||n(_chunkMDAFPGPAjs.i.call(void 0, e.projectID,a))},[e.client,e.token,e.projectID,a]);let r=_nullishCoalesce(e.token, () => (t)),d=_nullishCoalesce(e.chatProjectID, () => (e.projectID));return _react.useMemo.call(void 0, ()=>{if(e.client)return e.client;if(r===null)return null;if(r)return de({projectId:d,token:r,baseUrl:e.apiUrl,attachmentsUrl:e.attachmentsUrl})},[e.client,r,d,e.apiUrl,e.attachmentsUrl])}function nt(e){let t=_react.useRef.call(void 0, null);return async n=>{let a=_nullishCoalesce(e.buyProductId, () => (n.productId));if(!a)return;let r={productId:a,reason:n.reason,priceCents:n.priceCents,...n.amount!=null?{amount:n.amount}:{},...n.email?{email:n.email}:{},...n.code?{code:n.code}:{},...n.turnstileToken!=null?{turnstileToken:n.turnstileToken}:{}};if(e.onBuy){await e.onBuy(r);return}let d=(_nullishCoalesce(_nullishCoalesce(e.host, () => (_chunkMDAFPGPAjs.b.call(void 0, ).host)), () => ("https://bitsnap.pl"))).replace(/\/+$/,""),y=n.freeClaimLimit!=null&&(n.priceType==="free"||n.priceType==="pay_what_you_want"&&n.minimumCents===0&&r.amount===0);if(y&&r.email&&r.turnstileToken!=null){t.current=null;let p=await fetch(`${d}/api/integrations/${encodeURIComponent(e.projectID)}/public-commerce/free-claim/request-code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r.email,turnstileToken:r.turnstileToken})}),l=await p.json();if(!p.ok)throw new Error(_nullishCoalesce(l.code, () => ("internal")));return}if(y&&r.email&&r.code){let p=JSON.stringify([d,e.projectID,a,r.email,r.code]);if(!t.current||t.current.key!==p||t.current.expires<=Date.now()){t.current=null;let g=await fetch(`${d}/api/integrations/${encodeURIComponent(e.projectID)}/public-commerce/free-claim/verify-code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r.email,code:r.code})}),x=await g.json();if(!g.ok||!x.claimToken)throw new Error(_nullishCoalesce(x.code, () => ("email-verification-required")));t.current={key:p,token:x.claimToken,expires:Date.now()+(_nullishCoalesce(x.expiresIn, () => (600)))*1e3}}let l=await fetch(`${d}/api/integrations/${encodeURIComponent(e.projectID)}/public-commerce/buy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:a,quantity:1,amount:0}],details:{email:r.email},claimToken:t.current.token})}),i=await l.json();if(!l.ok||!i.url)throw new Error(_nullishCoalesce(i.code, () => ("free-order-not-supported")));window.location.assign(i.url);return}await ie({projectID:e.projectID,productId:a,name:e.title,priceCents:n.priceCents,amount:n.amount,host:e.host})}}function Se(e){let t=tt(e),n=_nullishCoalesce(e.locale, () => (_chunkQ337IQNAjs.f.call(void 0, ))),a=_react.useMemo.call(void 0, ()=>re(e.texts,n),[e.texts,n]),r=Ce({client:t,target:{kind:"thread",threadId:e.threadId,productId:e.productId},pollIntervalMs:e.pollIntervalMs,realtimeUrl:e.realtimeUrl,loadNats:e.loadNats}),d=nt(e);return _jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react h-full",children:_jsxruntime.jsx.call(void 0, ze,{host:e.host,conversation:r,texts:a,locale:n,kind:"thread",title:e.title,onBack:e.onBack,onBuy:d,className:e.className})})}function qe(e){let t=tt(e),n=_nullishCoalesce(e.locale, () => (_chunkQ337IQNAjs.f.call(void 0, ))),a=_react.useMemo.call(void 0, ()=>re(e.texts,n),[e.texts,n]),r=Ce({client:t,target:{kind:"channel",channelId:e.channelId,productId:e.productId},pollIntervalMs:e.pollIntervalMs,realtimeUrl:e.realtimeUrl,loadNats:e.loadNats}),d=nt(e);return _jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react h-full",children:_jsxruntime.jsx.call(void 0, ze,{host:e.host,conversation:r,texts:a,locale:n,kind:"channel",title:e.title,onBack:e.onBack,onBuy:d,className:e.className})})}var Kt=_react.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./BitsnapCart-GP2UJSG4.js"))));function Yt(e,t){return e?e.deleted?t.deletedPlaceholder:e.kind==="payment_request"?`${t.paymentRequestPreview}: ${_nullishCoalesce(_optionalChain([e, 'access', _52 => _52.paymentRequest, 'optionalAccess', _53 => _53.title]), () => (t.paymentRequestFallback))}`:e.body:t.noMessagesYet}var rt=e=>e.productType===5||e.productType===6;function ot(e,t){let n=[...new Set(e.filter(rt).map(a=>a.projectId).filter(Boolean))];return n.length>0?n:t?[t]:[]}function Vt(e){let t=new Map;for(let n of e)rt(n)&&n.projectId&&n.chatProjectId&&t.set(n.projectId,n.chatProjectId);return t}function st({accessToken:e,products:t,chatApiUrl:n,projectID:a,host:r,selection:d,onSelect:y,locale:p=_chunkQ337IQNAjs.f.call(void 0, ),texts:l}){let i=_react.useMemo.call(void 0, ()=>re(l,p),[l,p]),g=_react.useMemo.call(void 0, ()=>ot(t,a),[t,a]),x=_react.useMemo.call(void 0, ()=>Vt(t),[t]),k=_react.useMemo.call(void 0, ()=>{let I=new Map;for(let P of g)I.set(P,de({projectId:_nullishCoalesce(x.get(P), () => (P)),token:e,baseUrl:n}));return I},[g,x,e,n]),[v,f]=_react.useState.call(void 0, {}),[T,C]=_react.useState.call(void 0, 0),h=`${_nullishCoalesce(d.chatProject, () => (""))}:${_nullishCoalesce(d.thread, () => (""))}:${_nullishCoalesce(d.channel, () => (""))}`;_react.useEffect.call(void 0, ()=>{let I=!1;for(let[P,u]of k)f(s=>_optionalChain([s, 'access', _54 => _54[P], 'optionalAccess', _55 => _55.status])==="ready"?s:{...s,[P]:{status:"loading"}}),u.me().then(s=>!I&&f(m=>({...m,[P]:{status:"ready",me:s}})),s=>!I&&f(m=>({...m,[P]:{status:"error",error:s instanceof $?s:new $("internal_error",0)}})));return()=>{I=!0}},[k,T,h]);let b=_react.useMemo.call(void 0, ()=>{let I=new Map;for(let P of t)I.set(P.productId,P);return I},[t]),[_,E]=_react.useState.call(void 0, ),R=I=>async P=>{E(I),await ie({projectID:I,productId:P.productId,name:_optionalChain([b, 'access', _56 => _56.get, 'call', _57 => _57(P.productId), 'optionalAccess', _58 => _58.productName]),priceCents:P.priceCents,host:r})},w=d.chatProject?k.get(d.chatProject):void 0,c=!!(w&&(d.thread||d.channel)),L=()=>y({}),q=null;if(c&&w&&d.chatProject){let I=d.chatProject,P=v[I],u=_optionalChain([P, 'optionalAccess', _59 => _59.status])==="ready"?P.me:void 0;if(d.thread){let s=_optionalChain([u, 'optionalAccess', _60 => _60.threads, 'access', _61 => _61.find, 'call', _62 => _62(m=>m.id===d.thread)]);q=_jsxruntime.jsx.call(void 0, Se,{projectID:I,client:w,threadId:d.thread,title:_optionalChain([s, 'optionalAccess', _63 => _63.productId])&&_optionalChain([b, 'access', _64 => _64.get, 'call', _65 => _65(s.productId), 'optionalAccess', _66 => _66.productName])||void 0,locale:p,texts:l,onBack:L,onBuy:R(I)},`t:${I}:${d.thread}`)}else if(d.channel){let s=_optionalChain([u, 'optionalAccess', _67 => _67.entitlements, 'access', _68 => _68.channels, 'access', _69 => _69.find, 'call', _70 => _70(m=>m.channelId===d.channel)]);q=_jsxruntime.jsx.call(void 0, qe,{projectID:I,client:w,channelId:d.channel,productId:_optionalChain([s, 'optionalAccess', _71 => _71.productId]),locale:p,texts:l,onBack:L,onBuy:R(I)},`c:${I}:${d.channel}`)}}return _jsxruntime.jsxs.call(void 0, "div",{className:"flex min-h-0 flex-1 flex-col",children:[_jsxruntime.jsxs.call(void 0, "div",{className:_chunkJS3KK56Hjs.g.call(void 0, c&&"hidden md:block"),children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:i.inboxHeading}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:i.inboxIntro})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 grid min-h-0 flex-1 gap-4 md:grid-cols-[minmax(16rem,22rem)_1fr]",children:[_jsxruntime.jsx.call(void 0, "div",{className:_chunkJS3KK56Hjs.g.call(void 0, "min-w-0",c&&"hidden md:block"),children:_jsxruntime.jsx.call(void 0, Zt,{projects:g,loads:v,clients:k,products:t,texts:i,locale:p,selection:d,onSelect:y,onRetry:()=>C(I=>I+1)})}),_jsxruntime.jsx.call(void 0, "div",{className:_chunkJS3KK56Hjs.g.call(void 0, "min-h-[32rem] min-w-0 md:h-[calc(100dvh-10rem)]",!c&&"hidden md:flex"),children:_nullishCoalesce(q, () => (_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full w-full items-center justify-center rounded-xl border border-dashed border-neutral-300 p-6 text-sm text-neutral-600 dark:border-neutral-700 dark:text-neutral-400",children:i.selectConversation})))})]}),_&&_jsxruntime.jsx.call(void 0, _react.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, Kt,{projectID:_,locale:p})})]})}var at="flex min-h-11 w-full min-w-0 items-start gap-3 rounded-xl p-3 text-left transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500";function Zt({projects:e,loads:t,clients:n,products:a,texts:r,locale:d,selection:y,onSelect:p,onRetry:l}){let[i,g]=_react.useState.call(void 0, ),[x,k]=_react.useState.call(void 0, ),v=new Map(a.map(b=>[b.productId,b])),f=e.length>1,T=e.map(b=>_nullishCoalesce(t[b], () => ({status:"loading"})));if(T.length>0&&T.every(b=>b.status==="loading"))return _jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true","aria-label":r.loading,className:"flex flex-col gap-2",children:[0,1,2].map(b=>_jsxruntime.jsx.call(void 0, "div",{"aria-hidden":"true",className:"h-20 rounded-xl bg-white motion-safe:animate-pulse dark:bg-neutral-800"},b))});if(T.length===0||T.every(b=>b.status==="error"))return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-col items-start gap-3","data-testid":"chat-inbox-error",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700 dark:text-neutral-300",children:r.inboxError}),_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:l,className:"inline-flex min-h-11 items-center rounded-md bg-neutral-900 px-4 text-sm font-medium text-white hover:bg-neutral-800 focus-visible:outline-2 focus-visible:outline-current dark:bg-white dark:text-neutral-900",children:r.retry})]});let C=[],h=[];for(let b of e){let _=t[b];if(_optionalChain([_, 'optionalAccess', _72 => _72.status])!=="ready")continue;let{me:E}=_,R=f?_optionalChain([a, 'access', _73 => _73.find, 'call', _74 => _74(c=>c.projectId===b), 'optionalAccess', _75 => _75.projectName]):void 0;for(let c of E.threads){let L=c.productId?v.get(c.productId):void 0,q=y.chatProject===b&&y.thread===c.id,I=[ce(r,c.repliesLeft,d)];c.expiresAt&&I.push(K(c.composerLocked?r.expiredOn:r.expiresOn,{date:oe(c.expiresAt,d)})),c.responseHours>0&&I.push(K(r.responseHours,{hours:c.responseHours}));let P=c.lastMessage;C.push(_jsxruntime.jsx.call(void 0, "li",{children:_jsxruntime.jsxs.call(void 0, "button",{type:"button","data-thread-id":c.id,"aria-current":q?"true":void 0,onClick:()=>p({chatProject:b,thread:c.id}),className:_chunkJS3KK56Hjs.g.call(void 0, at,q?"bg-neutral-200 dark:bg-neutral-800":"bg-white hover:bg-neutral-50 dark:bg-neutral-900 dark:hover:bg-neutral-800"),children:[_jsxruntime.jsx.call(void 0, _lucidereact.MessageCircle,{className:"mt-0.5 size-5 shrink-0 text-neutral-500 dark:text-neutral-400","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[_jsxruntime.jsxs.call(void 0, "span",{className:"flex items-baseline gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:_chunkJS3KK56Hjs.g.call(void 0, "truncate",c.unread>0?"font-semibold":"font-medium"),children:_optionalChain([L, 'optionalAccess', _76 => _76.productName])||r.chatFallbackTitle}),P&&_jsxruntime.jsx.call(void 0, "time",{dateTime:P.createdAt,className:"ml-auto shrink-0 text-xs text-neutral-500 dark:text-neutral-400",children:be(P.createdAt,d)})]}),R&&_jsxruntime.jsx.call(void 0, "span",{className:"truncate text-xs text-neutral-500 dark:text-neutral-400",children:R}),_jsxruntime.jsxs.call(void 0, "span",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:"line-clamp-1 flex-1 text-sm text-neutral-600 dark:text-neutral-300",children:Yt(P,r)}),c.unread>0&&_jsxruntime.jsx.call(void 0, "span",{"aria-label":K(r.unread,{count:c.unread}),className:"inline-flex min-w-5 shrink-0 items-center justify-center rounded-full bg-neutral-900 px-1.5 text-xs font-semibold text-white tabular-nums dark:bg-white dark:text-neutral-900",children:c.unread})]}),_jsxruntime.jsxs.call(void 0, "span",{className:_chunkJS3KK56Hjs.g.call(void 0, "text-xs",c.repliesLeft<=0||c.composerLocked?"text-amber-800 dark:text-amber-300":"text-neutral-500 dark:text-neutral-400"),children:[I.join(" \xB7 "),c.muted&&` \xB7 ${r.mutedBadge}`]})]})]})},`t:${b}:${c.id}`))}for(let c of E.channels){let L=y.chatProject===b&&y.channel===c.id;C.push(_jsxruntime.jsx.call(void 0, "li",{children:_jsxruntime.jsxs.call(void 0, "button",{type:"button","data-channel-id":c.id,"aria-current":L?"true":void 0,onClick:()=>p({chatProject:b,channel:c.id}),className:_chunkJS3KK56Hjs.g.call(void 0, at,L?"bg-neutral-200 dark:bg-neutral-800":"bg-white hover:bg-neutral-50 dark:bg-neutral-900 dark:hover:bg-neutral-800"),children:[_jsxruntime.jsx.call(void 0, _lucidereact.Hash,{className:"mt-0.5 size-5 shrink-0 text-neutral-500 dark:text-neutral-400","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"truncate font-medium",children:c.name||r.channelFallbackTitle}),R&&_jsxruntime.jsx.call(void 0, "span",{className:"truncate text-xs text-neutral-500 dark:text-neutral-400",children:R}),_jsxruntime.jsx.call(void 0, "span",{className:"line-clamp-1 text-sm text-neutral-600 dark:text-neutral-300",children:c.topic||r.kindChannel}),c.memberCount>0&&_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:K(r.members,{count:c.memberCount})})]})]})},`c:${b}:${c.id}`))}for(let c of E.entitlements.packs){let L=`${b}:${c.productId}`,q=_optionalChain([v, 'access', _77 => _77.get, 'call', _78 => _78(c.productId), 'optionalAccess', _79 => _79.productName])||c.name||r.chatFallbackTitle;h.push(_jsxruntime.jsxs.call(void 0, "li",{className:"flex flex-col gap-2 rounded-xl bg-white p-3 dark:bg-neutral-900 sm:flex-row sm:items-center",children:[_jsxruntime.jsxs.call(void 0, "span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"truncate font-medium",children:q}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:[ce(r,c.repliesLeftHint,d),c.expiresAt?K(r.expiresOn,{date:oe(c.expiresAt,d)}):""].filter(Boolean).join(" \xB7 ")})]}),_jsxruntime.jsx.call(void 0, "button",{type:"button",disabled:i===L,"aria-busy":i===L||void 0,onClick:async()=>{let I=n.get(b);if(I){g(L),k(void 0);try{let P=await I.openThread(c.productId);p({chatProject:b,thread:P.id})}catch (e16){k(L)}finally{g(void 0)}}},className:"inline-flex min-h-11 shrink-0 items-center justify-center rounded-md bg-neutral-900 px-4 text-sm font-medium text-white hover:bg-neutral-800 disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500 dark:bg-white dark:text-neutral-900 dark:hover:bg-neutral-200",children:i===L?r.loading:r.startChat}),x===L&&_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"text-xs text-red-700 dark:text-red-400 sm:basis-full",children:r.errorGeneric})]},`p:${L}`))}let w=new Set(E.channels.map(c=>c.id));for(let c of E.entitlements.channels){if(c.channelId&&w.has(c.channelId))continue;let L=_optionalChain([v, 'access', _80 => _80.get, 'call', _81 => _81(c.productId), 'optionalAccess', _82 => _82.productName])||r.channelFallbackTitle;h.push(_jsxruntime.jsxs.call(void 0, "li",{className:"flex flex-col gap-2 rounded-xl bg-white p-3 dark:bg-neutral-900 sm:flex-row sm:items-center",children:[_jsxruntime.jsxs.call(void 0, "span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"truncate font-medium",children:L}),!c.channelId&&_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:r.channelNotReady})]}),c.channelId&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:()=>p({chatProject:b,channel:c.channelId}),className:"inline-flex min-h-11 shrink-0 items-center justify-center rounded-md border border-neutral-300 px-4 text-sm font-medium hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-500 dark:border-neutral-700 dark:hover:bg-neutral-800",children:r.openChannel})]},`e:${b}:${c.productId}`))}}return C.length===0&&h.length===0?_jsxruntime.jsx.call(void 0, "p",{"data-testid":"chat-inbox-empty",className:"text-sm text-neutral-600 dark:text-neutral-400",children:r.inboxEmpty}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-6","data-testid":"chat-inbox",children:[C.length>0&&_jsxruntime.jsx.call(void 0, "ul",{className:"flex flex-col gap-2",children:C}),h.length>0&&_jsxruntime.jsxs.call(void 0, "section",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-sm font-semibold text-neutral-700 dark:text-neutral-300",children:r.startSection}),_jsxruntime.jsx.call(void 0, "ul",{className:"flex flex-col gap-2",children:h})]})]})}exports.CHAT_TEXT_TABLES = He; exports.Channel = qe; exports.ChatError = $; exports.ChatThread = Se; exports.DEFAULT_CHAT_API_URL = Ne; exports.DEFAULT_CHAT_ATTACHMENTS_URL = Re; exports.DEFAULT_CHAT_REALTIME_URL = Me; exports.PanelMessages = st; exports.addPackToCart = ie; exports.chatProjects = ot; exports.createChatClient = de; exports.getChatTexts = re; exports.parseRealtimeEvent = Ie; exports.startLive = _e; exports.useConversation = Ce;
2
2
  //# sourceMappingURL=chat.js.map