From ccfffe6173f874104d5273ebbfe92f947003f18f Mon Sep 17 00:00:00 2001 From: Mekan1206 Date: Sat, 15 Aug 2026 16:07:23 +0500 Subject: [PATCH] Refactor chat functionality: remove ChatController, enhance MessageSent event with broadcasting capabilities, and update Conversation and Message models for improved relationships. Update API routes for chat operations and adjust CORS settings for broadcasting authentication. --- .env.example | 2 + app/Events/Conversation/MessageSent.php | 21 ++- .../Api/V1/Chat/ChatController.php | 134 ++++++++++++++++++ .../V1/Chat/Requests/ChatContactsRequest.php | 27 ++++ .../V1/Chat/Requests/ChatMessagesRequest.php | 26 ++++ .../Chat/Requests/ChatSendMessageRequest.php | 19 +++ .../Api/V1/Chat/Requests/ChatStartRequest.php | 20 +++ .../V1/Chat/Resources/ChatUserResource.php | 20 +++ .../Chat/Resources/ConversationResource.php | 31 ++++ .../Api/V1/Chat/Resources/MessageResource.php | 25 ++++ app/Http/Controllers/ChatController.php | 65 --------- app/Models/Chat/Conversation.php | 38 ++++- app/Models/Chat/Message.php | 25 +++- app/Models/User.php | 10 ++ app/Providers/BroadcastServiceProvider.php | 2 +- config/cors.php | 2 +- ...0_003338_create_private_messages_table.php | 47 ------ ..._15_155100_drop_private_messages_table.php | 23 +++ .../vendor/basement/basement.bundle.min.css | 3 - public/vendor/basement/basement.bundle.min.js | 47 ------ .../basement/basement.bundle.min.js.map | 1 - resources/views/test.blade.php | 19 --- routes/api/v1/v1-api.php | 16 ++- 23 files changed, 425 insertions(+), 198 deletions(-) create mode 100644 app/Http/Controllers/Api/V1/Chat/ChatController.php create mode 100644 app/Http/Controllers/Api/V1/Chat/Requests/ChatContactsRequest.php create mode 100644 app/Http/Controllers/Api/V1/Chat/Requests/ChatMessagesRequest.php create mode 100644 app/Http/Controllers/Api/V1/Chat/Requests/ChatSendMessageRequest.php create mode 100644 app/Http/Controllers/Api/V1/Chat/Requests/ChatStartRequest.php create mode 100644 app/Http/Controllers/Api/V1/Chat/Resources/ChatUserResource.php create mode 100644 app/Http/Controllers/Api/V1/Chat/Resources/ConversationResource.php create mode 100644 app/Http/Controllers/Api/V1/Chat/Resources/MessageResource.php delete mode 100644 app/Http/Controllers/ChatController.php delete mode 100644 database/migrations/2026_04_30_003338_create_private_messages_table.php create mode 100644 database/migrations/2026_08_15_155100_drop_private_messages_table.php delete mode 100644 public/vendor/basement/basement.bundle.min.css delete mode 100644 public/vendor/basement/basement.bundle.min.js delete mode 100644 public/vendor/basement/basement.bundle.min.js.map delete mode 100644 resources/views/test.blade.php diff --git a/.env.example b/.env.example index 15b02b8..aefbb2f 100644 --- a/.env.example +++ b/.env.example @@ -18,6 +18,7 @@ DB_DATABASE=postshop DB_USERNAME=root DB_PASSWORD= +# Use `pusher` (Pusher Cloud or Soketi) for live chat. `log` is fine locally without websockets. BROADCAST_DRIVER=log CACHE_DRIVER=file FILESYSTEM_DISK=local @@ -46,6 +47,7 @@ AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET= AWS_USE_PATH_STYLE_ENDPOINT=false +# Required when BROADCAST_DRIVER=pusher (Pusher Cloud, or Soketi using the pusher driver) PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= diff --git a/app/Events/Conversation/MessageSent.php b/app/Events/Conversation/MessageSent.php index ec82a79..466c164 100644 --- a/app/Events/Conversation/MessageSent.php +++ b/app/Events/Conversation/MessageSent.php @@ -2,6 +2,8 @@ namespace App\Events\Conversation; +use App\Http\Controllers\Api\V1\Chat\Resources\MessageResource; +use App\Models\Chat\Message; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; @@ -13,14 +15,12 @@ class MessageSent implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $message; - /** * Create a new event instance. */ - public function __construct($message) + public function __construct(private Message $message) { - $this->message = $message->load('user'); + $this->message->loadMissing('user'); } /** @@ -34,4 +34,17 @@ class MessageSent implements ShouldBroadcast new PrivateChannel('chat.'.$this->message->conversation_id), ]; } + + public function broadcastAs(): string + { + return 'message.sent'; + } + + /** + * @return array + */ + public function broadcastWith(): array + { + return (new MessageResource($this->message->loadMissing('user')))->resolve(); + } } diff --git a/app/Http/Controllers/Api/V1/Chat/ChatController.php b/app/Http/Controllers/Api/V1/Chat/ChatController.php new file mode 100644 index 0000000..9532a43 --- /dev/null +++ b/app/Http/Controllers/Api/V1/Chat/ChatController.php @@ -0,0 +1,134 @@ +user() + ->conversations() + ->with(['users', 'latestMessage.user']) + ->withCount([ + 'messages as unread_count' => fn ($query) => $query + ->where('user_id', '!=', auth()->id()) + ->whereNull('seen_at'), + ]) + ->withMax('messages', 'created_at') + ->orderByDesc('messages_max_created_at') + ->get(); + + return response()->rest(ConversationResource::collection($conversations)); + } + + /** + * (*) Searchable chat contacts + */ + public function contacts(ChatContactsRequest $request): JsonResponse + { + $paginator = User::query() + ->select(['id', 'first_name', 'last_name']) + ->where('id', '!=', $request->user()->id) + ->when($request->q, function ($query, $search) { + $query->where(function ($query) use ($search) { + $query->where('first_name', 'like', '%'.$search.'%') + ->orWhere('last_name', 'like', '%'.$search.'%') + ->orWhere('phone_number', 'like', '%'.$search.'%'); + }); + }) + ->orderBy('first_name') + ->simplePaginate($request->perPage); + + $paginator->through(fn (User $user) => (new ChatUserResource($user))->resolve()); + + return response()->rest_paginate($paginator); + } + + /** + * (*) Find or create a 1:1 conversation + */ + public function start(ChatStartRequest $request): JsonResponse + { + $conversation = Conversation::findOrCreateOneToOne( + $request->user()->id, + $request->integer('user_id') + ); + + $conversation->load(['users', 'latestMessage.user']) + ->loadCount([ + 'messages as unread_count' => fn ($query) => $query + ->where('user_id', '!=', $request->user()->id) + ->whereNull('seen_at'), + ]); + + return response()->rest(new ConversationResource($conversation)); + } + + /** + * (*) Conversation messages + */ + public function messages(ChatMessagesRequest $request, Conversation $conversation): JsonResponse + { + abort_unless($conversation->hasParticipant($request->user()), 403); + + $paginator = $conversation->messages() + ->with('user') + ->latest() + ->simplePaginate($request->perPage); + + $paginator->through(fn (Message $message) => (new MessageResource($message))->resolve()); + + return response()->rest_paginate($paginator); + } + + /** + * (*) Send a message + */ + public function send(ChatSendMessageRequest $request, Conversation $conversation): JsonResponse + { + abort_unless($conversation->hasParticipant($request->user()), 403); + + $message = $conversation->messages()->create([ + 'user_id' => $request->user()->id, + 'body' => $request->validated('body'), + ]); + + $message->load('user'); + + broadcast(new MessageSent($message))->toOthers(); + + return response()->rest(new MessageResource($message), 201); + } + + /** + * (*) Mark the other user's messages as seen + */ + public function read(Conversation $conversation): JsonResponse + { + abort_unless($conversation->hasParticipant(auth()->user()), 403); + + $conversation->messages() + ->where('user_id', '!=', auth()->id()) + ->whereNull('seen_at') + ->update(['seen_at' => now()]); + + return response()->rest(); + } +} diff --git a/app/Http/Controllers/Api/V1/Chat/Requests/ChatContactsRequest.php b/app/Http/Controllers/Api/V1/Chat/Requests/ChatContactsRequest.php new file mode 100644 index 0000000..73bd86e --- /dev/null +++ b/app/Http/Controllers/Api/V1/Chat/Requests/ChatContactsRequest.php @@ -0,0 +1,27 @@ +|string> + */ + public function rules(): array + { + return [ + 'q' => ['nullable', 'string', 'max:100'], + 'perPage' => ['nullable', 'integer', 'min:1', 'max:50'], + ]; + } + + protected function passedValidation(): void + { + $this->merge([ + 'perPage' => $this->perPage ?: 20, + ]); + } +} diff --git a/app/Http/Controllers/Api/V1/Chat/Requests/ChatMessagesRequest.php b/app/Http/Controllers/Api/V1/Chat/Requests/ChatMessagesRequest.php new file mode 100644 index 0000000..9e86794 --- /dev/null +++ b/app/Http/Controllers/Api/V1/Chat/Requests/ChatMessagesRequest.php @@ -0,0 +1,26 @@ +|string> + */ + public function rules(): array + { + return [ + 'perPage' => ['nullable', 'integer', 'min:1', 'max:100'], + ]; + } + + protected function passedValidation(): void + { + $this->merge([ + 'perPage' => $this->perPage ?: 50, + ]); + } +} diff --git a/app/Http/Controllers/Api/V1/Chat/Requests/ChatSendMessageRequest.php b/app/Http/Controllers/Api/V1/Chat/Requests/ChatSendMessageRequest.php new file mode 100644 index 0000000..d514c9d --- /dev/null +++ b/app/Http/Controllers/Api/V1/Chat/Requests/ChatSendMessageRequest.php @@ -0,0 +1,19 @@ +|string> + */ + public function rules(): array + { + return [ + 'body' => ['required', 'string', 'max:5000'], + ]; + } +} diff --git a/app/Http/Controllers/Api/V1/Chat/Requests/ChatStartRequest.php b/app/Http/Controllers/Api/V1/Chat/Requests/ChatStartRequest.php new file mode 100644 index 0000000..5c0a9c0 --- /dev/null +++ b/app/Http/Controllers/Api/V1/Chat/Requests/ChatStartRequest.php @@ -0,0 +1,20 @@ +|string> + */ + public function rules(): array + { + return [ + 'user_id' => ['required', 'integer', 'exists:users,id', Rule::notIn([$this->user()->id])], + ]; + } +} diff --git a/app/Http/Controllers/Api/V1/Chat/Resources/ChatUserResource.php b/app/Http/Controllers/Api/V1/Chat/Resources/ChatUserResource.php new file mode 100644 index 0000000..290bc9b --- /dev/null +++ b/app/Http/Controllers/Api/V1/Chat/Resources/ChatUserResource.php @@ -0,0 +1,20 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'name' => $this->fullname, + ]; + } +} diff --git a/app/Http/Controllers/Api/V1/Chat/Resources/ConversationResource.php b/app/Http/Controllers/Api/V1/Chat/Resources/ConversationResource.php new file mode 100644 index 0000000..93b948d --- /dev/null +++ b/app/Http/Controllers/Api/V1/Chat/Resources/ConversationResource.php @@ -0,0 +1,31 @@ + + */ + public function toArray(Request $request): array + { + $otherUser = $this->relationLoaded('users') + ? $this->users->firstWhere('id', '!=', $request->user()?->id) + : null; + + return [ + 'id' => $this->id, + 'user' => $this->when($otherUser, fn () => new ChatUserResource($otherUser)), + 'last_message' => $this->when( + $this->relationLoaded('latestMessage') && $this->latestMessage, + fn () => new MessageResource($this->latestMessage) + ), + 'unread_count' => (int) ($this->unread_count ?? 0), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]; + } +} diff --git a/app/Http/Controllers/Api/V1/Chat/Resources/MessageResource.php b/app/Http/Controllers/Api/V1/Chat/Resources/MessageResource.php new file mode 100644 index 0000000..1ee6dac --- /dev/null +++ b/app/Http/Controllers/Api/V1/Chat/Resources/MessageResource.php @@ -0,0 +1,25 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'conversation_id' => $this->conversation_id, + 'body' => $this->body, + 'seen_at' => $this->seen_at, + 'user' => new ChatUserResource($this->whenLoaded('user')), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]; + } +} diff --git a/app/Http/Controllers/ChatController.php b/app/Http/Controllers/ChatController.php deleted file mode 100644 index 6d3138d..0000000 --- a/app/Http/Controllers/ChatController.php +++ /dev/null @@ -1,65 +0,0 @@ -get() - ->map(function ($user) { - return [ - 'id' => $user->id, - 'name' => $user->first_name.' '.$user->last_name, - ]; - }); - } - - public function start(Request $request) - { - $user1 = auth()->id(); - $user2 = $request->user_id; - - $conversation = Conversation::whereHas('users', fn ($q) => $q->where('user_id', $user1)) - ->whereHas('users', fn ($q) => $q->where('user_id', $user2)) - ->first(); - - if (! $conversation) { - $conversation = Conversation::create(); - $conversation->users()->attach([$user1, $user2]); - } - - return $conversation; - } - - public function messages($id) - { - return Message::with('user') - ->where('conversation_id', $id) - ->latest() - ->take(50) - ->get() - ->reverse() - ->values(); - } - - public function send(Request $request) - { - $message = Message::create([ - 'conversation_id' => $request->conversation_id, - 'user_id' => auth()->id(), - 'body' => $request->body, - ]); - - broadcast(new MessageSent($message))->toOthers(); - - return $message->load('user'); - } -} diff --git a/app/Models/Chat/Conversation.php b/app/Models/Chat/Conversation.php index 825cf0b..815a262 100644 --- a/app/Models/Chat/Conversation.php +++ b/app/Models/Chat/Conversation.php @@ -5,18 +5,52 @@ namespace App\Models\Chat; use App\Models\User; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOne; class Conversation extends Model { use HasFactory; - public function users() + /** + * Find or create a 1:1 conversation between two users. + */ + public static function findOrCreateOneToOne(int $userId, int $otherUserId): self + { + $conversation = static::query() + ->whereHas('users', fn ($query) => $query->where('users.id', $userId)) + ->whereHas('users', fn ($query) => $query->where('users.id', $otherUserId)) + ->has('users', '=', 2) + ->first(); + + if ($conversation) { + return $conversation; + } + + $conversation = static::create(); + $conversation->users()->attach([$userId, $otherUserId]); + + return $conversation; + } + + public function users(): BelongsToMany { return $this->belongsToMany(User::class); } - public function messages() + public function messages(): HasMany { return $this->hasMany(Message::class); } + + public function latestMessage(): HasOne + { + return $this->hasOne(Message::class)->latestOfMany(); + } + + public function hasParticipant(User $user): bool + { + return $this->users()->where('users.id', $user->id)->exists(); + } } diff --git a/app/Models/Chat/Message.php b/app/Models/Chat/Message.php index 2a07be5..375057c 100644 --- a/app/Models/Chat/Message.php +++ b/app/Models/Chat/Message.php @@ -5,12 +5,35 @@ namespace App\Models\Chat; use App\Models\User; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class Message extends Model { use HasFactory; - public function user() + /** + * @var array + */ + protected $fillable = [ + 'conversation_id', + 'user_id', + 'body', + 'seen_at', + ]; + + /** + * @var array + */ + protected $casts = [ + 'seen_at' => 'datetime', + ]; + + public function conversation(): BelongsTo + { + return $this->belongsTo(Conversation::class); + } + + public function user(): BelongsTo { return $this->belongsTo(User::class); } diff --git a/app/Models/User.php b/app/Models/User.php index 6d894d7..55ceb2f 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Models\Chat\Conversation; use App\Models\Concerns\HasEcommerceChannels; use App\Models\Concerns\HasSchemalessAttributes; use App\Models\Concerns\InteractsWithNova; @@ -15,6 +16,7 @@ use App\Models\System\Settings\Location\UserAddress; use App\Repositories\System\Cache\CacheRepository; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Foundation\Auth\User as Authenticatable; @@ -112,6 +114,14 @@ class User extends Authenticatable return $this->hasMany(UserAddress::class); } + /** + * Chat conversations + */ + public function conversations(): BelongsToMany + { + return $this->belongsToMany(Conversation::class); + } + /** * User's carts */ diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 2be04f5..f264152 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -12,7 +12,7 @@ class BroadcastServiceProvider extends ServiceProvider */ public function boot(): void { - Broadcast::routes(); + Broadcast::routes(['middleware' => ['auth:sanctum']]); require base_path('routes/channels.php'); } diff --git a/config/cors.php b/config/cors.php index 8a39e6d..6f71473 100644 --- a/config/cors.php +++ b/config/cors.php @@ -15,7 +15,7 @@ return [ | */ - 'paths' => ['api/*', 'sanctum/csrf-cookie'], + 'paths' => ['api/*', 'sanctum/csrf-cookie', 'broadcasting/auth'], 'allowed_methods' => ['*'], diff --git a/database/migrations/2026_04_30_003338_create_private_messages_table.php b/database/migrations/2026_04_30_003338_create_private_messages_table.php deleted file mode 100644 index 07141e6..0000000 --- a/database/migrations/2026_04_30_003338_create_private_messages_table.php +++ /dev/null @@ -1,47 +0,0 @@ -getKeyName(); - $tableName = $user->getTable(); - - $table->id(); - $table->unsignedBigInteger('receiver_id'); - $table->unsignedBigInteger('sender_id'); - $table->foreign('receiver_id')->references($primaryKey)->on($tableName); - $table->foreign('sender_id')->references($primaryKey)->on($tableName); - $table->enum('type', [MessageType::document()->value, MessageType::text()->value]); - $table->string('value'); - $table->timestamp('read_at')->nullable(); - $table->timestamps(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('private_messages'); - } -}; diff --git a/database/migrations/2026_08_15_155100_drop_private_messages_table.php b/database/migrations/2026_08_15_155100_drop_private_messages_table.php new file mode 100644 index 0000000..3a6346a --- /dev/null +++ b/database/migrations/2026_08_15_155100_drop_private_messages_table.php @@ -0,0 +1,23 @@ +:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.25rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.25rem*var(--tw-space-x-reverse))}.basement .bm-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.basement .bm-overflow-auto{overflow:auto}.basement .bm-overflow-hidden{overflow:hidden}.basement .bm-overflow-y-auto{overflow-y:auto}.basement .bm-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.basement .bm-text-ellipsis{text-overflow:ellipsis}.basement .bm-whitespace-nowrap{white-space:nowrap}.basement .bm-break-words{overflow-wrap:break-word}.basement .bm-rounded-full{border-radius:9999px}.basement .bm-rounded-lg{border-radius:.5rem}.basement .bm-rounded-md{border-radius:.375rem}.basement .bm-rounded-xl{border-radius:.75rem}.basement .bm-rounded-b-lg{border-bottom-left-radius:.5rem;border-bottom-right-radius:.5rem}.basement .bm-rounded-l-lg{border-bottom-left-radius:.5rem;border-top-left-radius:.5rem}.basement .bm-rounded-r-lg{border-bottom-right-radius:.5rem;border-top-right-radius:.5rem}.basement .bm-rounded-t-lg{border-top-left-radius:.5rem;border-top-right-radius:.5rem}.basement .bm-rounded-t-md{border-top-left-radius:.375rem;border-top-right-radius:.375rem}.basement .bm-border{border-width:1px}.basement .bm-border-b{border-bottom-width:1px}.basement .bm-border-t{border-top-width:1px}.basement .bm-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.basement .bm-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity))}.basement .bm-bg-blue-400{--tw-bg-opacity:1;background-color:rgb(96 165 250/var(--tw-bg-opacity))}.basement .bm-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity))}.basement .bm-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.basement .bm-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.basement .bm-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity))}.basement .bm-bg-green-400{--tw-bg-opacity:1;background-color:rgb(74 222 128/var(--tw-bg-opacity))}.basement .bm-bg-red-400{--tw-bg-opacity:1;background-color:rgb(248 113 113/var(--tw-bg-opacity))}.basement .bm-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.basement .bm-bg-white\/70{background-color:hsla(0,0%,100%,.7)}.basement .bm-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.basement .bm-p-2{padding:.5rem}.basement .bm-p-3{padding:.75rem}.basement .bm-px-1{padding-left:.25rem;padding-right:.25rem}.basement .bm-px-2{padding-left:.5rem;padding-right:.5rem}.basement .bm-px-3{padding-left:.75rem;padding-right:.75rem}.basement .bm-py-1{padding-bottom:.25rem;padding-top:.25rem}.basement .bm-py-2{padding-bottom:.5rem;padding-top:.5rem}.basement .bm-py-3{padding-bottom:.75rem;padding-top:.75rem}.basement .bm-py-4{padding-bottom:1rem;padding-top:1rem}.basement .bm-pl-4{padding-left:1rem}.basement .bm-pl-9{padding-left:2.25rem}.basement .bm-pt-6{padding-top:1.5rem}.basement .bm-text-center{text-align:center}.basement .bm-text-right{text-align:right}.basement .bm-text-5xl{font-size:3rem;line-height:1}.basement .bm-text-base{font-size:1rem;line-height:1.5rem}.basement .bm-text-sm{font-size:.875rem;line-height:1.25rem}.basement .bm-text-xl{font-size:1.25rem;line-height:1.75rem}.basement .bm-text-xs{font-size:.75rem;line-height:1rem}.basement .bm-font-bold{font-weight:700}.basement .bm-font-extrabold{font-weight:800}.basement .bm-font-semibold{font-weight:600}.basement .bm-leading-tight{line-height:1.25}.basement .bm-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity))}.basement .bm-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.basement .bm-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.basement .bm-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.basement .bm-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.basement .bm-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.basement .bm-text-green-400{--tw-text-opacity:1;color:rgb(74 222 128/var(--tw-text-opacity))}.basement .bm-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.basement .bm-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.basement .bm-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.basement .bm-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity))}.basement .bm-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.basement .bm-shadow-lg,.basement .bm-shadow-md{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.basement .bm-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.basement .bm-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.basement .bm-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.basement .bm-duration-500{transition-duration:.5s}.tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{background-color:#333;border-radius:4px;color:#fff;font-size:14px;line-height:1.4;outline:0;position:relative;transition-property:transform,visibility,opacity;white-space:normal}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{border-top-color:initial;border-width:8px 8px 0;bottom:-7px;left:0;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{border-bottom-color:initial;border-width:0 8px 8px;left:0;top:-7px;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-left-color:initial;border-width:8px 0 8px 8px;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{border-right-color:initial;border-width:8px 8px 8px 0;left:-7px;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{color:#333;height:16px;width:16px}.tippy-arrow:before{border-color:transparent;border-style:solid;content:"";position:absolute}.tippy-content{font-family:Nunito,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;padding:5px 9px;position:relative;z-index:1}.basement .hover\:bm-bg-blue-500:hover{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity))}.basement .hover\:bm-bg-gray-100:hover{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.basement .hover\:bm-text-blue-500:hover{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity))}.basement .hover\:bm-text-white:hover{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.basement .hover\:bm-brightness-90:hover{--tw-brightness:brightness(.9);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.basement .focus\:bm-border-sky-300:focus{--tw-border-opacity:1;border-color:rgb(125 211 252/var(--tw-border-opacity))}.basement .focus\:bm-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.basement .focus\:bm-ring-1:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.basement .focus\:bm-ring-sky-300:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(125 211 252/var(--tw-ring-opacity))}.basement .bm-group:hover .group-hover\:bm-block{display:block} \ No newline at end of file diff --git a/public/vendor/basement/basement.bundle.min.js b/public/vendor/basement/basement.bundle.min.js deleted file mode 100644 index a5b84c7..0000000 --- a/public/vendor/basement/basement.bundle.min.js +++ /dev/null @@ -1,47 +0,0 @@ -!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";var t,e,n,r,i=!1,o=!1,a=[],s=-1;function u(t){!function(t){a.includes(t)||a.push(t);o||i||(i=!0,queueMicrotask(l))}(t)}function c(t){let e=a.indexOf(t);-1!==e&&e>s&&a.splice(e,1)}function l(){i=!1,o=!0;for(let t=0;t{(void 0===e||e.includes(n))&&(r.forEach((t=>t())),delete t._x_attributeCleanups[n])}))}var m=new MutationObserver(T),b=!1;function w(){m.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0}),b=!0}function _(){(x=x.concat(m.takeRecords())).length&&!E&&(E=!0,queueMicrotask((()=>{T(x),x.length=0,E=!1}))),m.disconnect(),b=!1}var x=[],E=!1;function S(t){if(!b)return t();_();let e=t();return w(),e}var O=!1,k=[];function T(t){if(O)return void(k=k.concat(t));let e=[],n=[],r=new Map,i=new Map;for(let o=0;o1===t.nodeType&&e.push(t))),t[o].removedNodes.forEach((t=>1===t.nodeType&&n.push(t)))),"attributes"===t[o].type)){let e=t[o].target,n=t[o].attributeName,a=t[o].oldValue,s=()=>{r.has(e)||r.set(e,[]),r.get(e).push({name:n,value:e.getAttribute(n)})},u=()=>{i.has(e)||i.set(e,[]),i.get(e).push(n)};e.hasAttribute(n)&&null===a?s():e.hasAttribute(n)?(u(),s()):u()}i.forEach(((t,e)=>{y(e,t)})),r.forEach(((t,e)=>{d.forEach((n=>n(e,t)))}));for(let t of n)if(!e.includes(t)&&(p.forEach((e=>e(t))),t._x_cleanups))for(;t._x_cleanups.length;)t._x_cleanups.pop()();e.forEach((t=>{t._x_ignoreSelf=!0,t._x_ignore=!0}));for(let t of e)n.includes(t)||t.isConnected&&(delete t._x_ignoreSelf,delete t._x_ignore,v.forEach((e=>e(t))),t._x_ignore=!0,t._x_ignoreSelf=!0);e.forEach((t=>{delete t._x_ignoreSelf,delete t._x_ignore})),e=null,n=null,r=null,i=null}function P(t){return j(A(t))}function C(t,e,n){return t._x_dataStack=[e,...A(n||t)],()=>{t._x_dataStack=t._x_dataStack.filter((t=>t!==e))}}function A(t){return t._x_dataStack?t._x_dataStack:"function"==typeof ShadowRoot&&t instanceof ShadowRoot?A(t.host):t.parentNode?A(t.parentNode):[]}function j(t){let e=new Proxy({},{ownKeys:()=>Array.from(new Set(t.flatMap((t=>Object.keys(t))))),has:(e,n)=>t.some((t=>t.hasOwnProperty(n))),get:(n,r)=>(t.find((t=>{if(t.hasOwnProperty(r)){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get&&n.get._x_alreadyBound||n.set&&n.set._x_alreadyBound)return!0;if((n.get||n.set)&&n.enumerable){let i=n.get,o=n.set,a=n;i=i&&i.bind(e),o=o&&o.bind(e),i&&(i._x_alreadyBound=!0),o&&(o._x_alreadyBound=!0),Object.defineProperty(t,r,{...a,get:i,set:o})}return!0}return!1}))||{})[r],set:(e,n,r)=>{let i=t.find((t=>t.hasOwnProperty(n)));return i?i[n]=r:t[t.length-1][n]=r,!0}});return e}function N(t){let e=(n,r="")=>{Object.entries(Object.getOwnPropertyDescriptors(n)).forEach((([i,{value:o,enumerable:a}])=>{if(!1===a||void 0===o)return;let s=""===r?i:`${r}.${i}`;var u;"object"==typeof o&&null!==o&&o._x_interceptor?n[i]=o.initialize(t,s,i):"object"!=typeof(u=o)||Array.isArray(u)||null===u||o===n||o instanceof Element||e(o,s)}))};return e(t)}function M(t,e=(()=>{})){let n={initialValue:void 0,_x_interceptor:!0,initialize(e,n,r){return t(this.initialValue,(()=>function(t,e){return e.split(".").reduce(((t,e)=>t[e]),t)}(e,n)),(t=>R(e,n,t)),n,r)}};return e(n),t=>{if("object"==typeof t&&null!==t&&t._x_interceptor){let e=n.initialize.bind(n);n.initialize=(r,i,o)=>{let a=t.initialize(r,i,o);return n.initialValue=a,e(r,i,o)}}else n.initialValue=t;return n}}function R(t,e,n){if("string"==typeof e&&(e=e.split(".")),1!==e.length){if(0===e.length)throw error;return t[e[0]]||(t[e[0]]={}),R(t[e[0]],e.slice(1),n)}t[e[0]]=n}var D={};function L(t,e){D[t]=e}function I(t,e){return Object.entries(D).forEach((([n,r])=>{let i=null;Object.defineProperty(t,`$${n}`,{get:()=>r(e,function(){if(i)return i;{let[t,n]=nt(e);return i={interceptor:M,...t},g(e,n),i}}()),enumerable:!1})})),t}function U(t,e,n,...r){try{return n(...r)}catch(n){F(n,t,e)}}function F(t,e,n=void 0){Object.assign(t,{el:e,expression:n}),console.warn(`Alpine Expression Error: ${t.message}\n\n${n?'Expression: "'+n+'"\n\n':""}`,e),setTimeout((()=>{throw t}),0)}var B=!0;function z(t,e,n={}){let r;return q(t,e)((t=>r=t),n),r}function q(...t){return H(...t)}var H=W;function W(t,e){let n={};I(n,t);let r=[n,...A(t)],i="function"==typeof e?function(t,e){return(n=(()=>{}),{scope:r={},params:i=[]}={})=>{$(n,e.apply(j([r,...t]),i))}}(r,e):function(t,e,n){let r=function(t,e){if(Y[t])return Y[t];let n=Object.getPrototypeOf((async function(){})).constructor,r=/^[\n\s]*if.*\(.*\)/.test(t)||/^(let|const)\s/.test(t)?`(async()=>{ ${t} })()`:t;const i=()=>{try{return new n(["__self","scope"],`with (scope) { __self.result = ${r} }; __self.finished = true; return __self.result;`)}catch(n){return F(n,e,t),Promise.resolve()}};let o=i();return Y[t]=o,o}(e,n);return(i=(()=>{}),{scope:o={},params:a=[]}={})=>{r.result=void 0,r.finished=!1;let s=j([o,...t]);if("function"==typeof r){let t=r(r,s).catch((t=>F(t,n,e)));r.finished?($(i,r.result,s,a,n),r.result=void 0):t.then((t=>{$(i,t,s,a,n)})).catch((t=>F(t,n,e))).finally((()=>r.result=void 0))}}}(r,e,t);return U.bind(null,t,e,i)}var Y={};function $(t,e,n,r,i){if(B&&"function"==typeof e){let o=e.apply(n,r);o instanceof Promise?o.then((e=>$(t,e,n,r))).catch((t=>F(t,i,e))):t(o)}else"object"==typeof e&&e instanceof Promise?e.then((e=>t(e))):t(e)}var V="x-";function J(t=""){return V+t}var X={};function G(t,e){return X[t]=e,{before(e){if(!X[e])return void console.warn("Cannot find directive `${directive}`. `${name}` will use the default order of execution");const n=lt.indexOf(e);lt.splice(n>=0?n:lt.indexOf("DEFAULT"),0,t)}}}function Z(t,e,n){if(e=Array.from(e),t._x_virtualDirectives){let n=Object.entries(t._x_virtualDirectives).map((([t,e])=>({name:t,value:e}))),r=K(n);n=n.map((t=>r.find((e=>e.name===t.name))?{name:`x-bind:${t.name}`,value:`"${t.value}"`}:t)),e=e.concat(n)}let r={},i=e.map(it(((t,e)=>r[t]=e))).filter(st).map(function(t,e){return({name:n,value:r})=>{let i=n.match(ut()),o=n.match(/:([a-zA-Z0-9\-:]+)/),a=n.match(/\.[^.\]]+(?=[^\]]*$)/g)||[],s=e||t[n]||n;return{type:i?i[1]:null,value:o?o[1]:null,modifiers:a.map((t=>t.replace(".",""))),expression:r,original:s}}}(r,n)).sort(ft);return i.map((e=>function(t,e){let n=()=>{},r=X[e.type]||n,[i,o]=nt(t);!function(t,e,n){t._x_attributeCleanups||(t._x_attributeCleanups={}),t._x_attributeCleanups[e]||(t._x_attributeCleanups[e]=[]),t._x_attributeCleanups[e].push(n)}(t,e.original,o);let a=()=>{t._x_ignore||t._x_ignoreSelf||(r.inline&&r.inline(t,e,i),r=r.bind(r,t,e,i),Q?tt.get(et).push(r):r())};return a.runCleanups=o,a}(t,e)))}function K(t){return Array.from(t).map(it()).filter((t=>!st(t)))}var Q=!1,tt=new Map,et=Symbol();function nt(t){let r=[],[i,o]=function(t){let r=()=>{};return[i=>{let o=e(i);return t._x_effects||(t._x_effects=new Set,t._x_runEffects=()=>{t._x_effects.forEach((t=>t()))}),t._x_effects.add(o),r=()=>{void 0!==o&&(t._x_effects.delete(o),n(o))},o},()=>{r()}]}(t);r.push(o);return[{Alpine:Qt,effect:i,cleanup:t=>r.push(t),evaluateLater:q.bind(q,t),evaluate:z.bind(z,t)},()=>r.forEach((t=>t()))]}var rt=(t,e)=>({name:n,value:r})=>(n.startsWith(t)&&(n=n.replace(t,e)),{name:n,value:r});function it(t=(()=>{})){return({name:e,value:n})=>{let{name:r,value:i}=ot.reduce(((t,e)=>e(t)),{name:e,value:n});return r!==e&&t(r,e),{name:r,value:i}}}var ot=[];function at(t){ot.push(t)}function st({name:t}){return ut().test(t)}var ut=()=>new RegExp(`^${V}([^:^.]+)\\b`);var ct="DEFAULT",lt=["ignore","ref","data","id","bind","init","for","model","modelable","transition","show","if",ct,"teleport"];function ft(t,e){let n=-1===lt.indexOf(t.type)?ct:t.type,r=-1===lt.indexOf(e.type)?ct:e.type;return lt.indexOf(n)-lt.indexOf(r)}function ht(t,e,n={}){t.dispatchEvent(new CustomEvent(e,{detail:n,bubbles:!0,composed:!0,cancelable:!0}))}function dt(t,e){if("function"==typeof ShadowRoot&&t instanceof ShadowRoot)return void Array.from(t.children).forEach((t=>dt(t,e)));let n=!1;if(e(t,(()=>n=!0)),n)return;let r=t.firstElementChild;for(;r;)dt(r,e),r=r.nextElementSibling}function pt(t,...e){console.warn(`Alpine Warning: ${t}`,...e)}var vt=!1;var gt=[],yt=[];function mt(){return gt.map((t=>t()))}function bt(){return gt.concat(yt).map((t=>t()))}function wt(t){gt.push(t)}function _t(t){yt.push(t)}function xt(t,e=!1){return Et(t,(t=>{if((e?bt():mt()).some((e=>t.matches(e))))return!0}))}function Et(t,e){if(t){if(e(t))return t;if(t._x_teleportBack&&(t=t._x_teleportBack),t.parentElement)return Et(t.parentElement,e)}}var St=[];function Ot(t,e=dt,n=(()=>{})){!function(t){Q=!0;let e=Symbol();et=e,tt.set(e,[]);let n=()=>{for(;tt.get(e).length;)tt.get(e).shift()();tt.delete(e)};t(n),Q=!1,n()}((()=>{e(t,((t,e)=>{n(t,e),St.forEach((n=>n(t,e))),Z(t,t.attributes).forEach((t=>t())),t._x_ignore&&e()}))}))}function kt(t){dt(t,(t=>y(t)))}var Tt=[],Pt=!1;function Ct(t=(()=>{})){return queueMicrotask((()=>{Pt||setTimeout((()=>{At()}))})),new Promise((e=>{Tt.push((()=>{t(),e()}))}))}function At(){for(Pt=!1;Tt.length;)Tt.shift()()}function jt(t,e){return Array.isArray(e)?Nt(t,e.join(" ")):"object"==typeof e&&null!==e?function(t,e){let n=t=>t.split(" ").filter(Boolean),r=Object.entries(e).flatMap((([t,e])=>!!e&&n(t))).filter(Boolean),i=Object.entries(e).flatMap((([t,e])=>!e&&n(t))).filter(Boolean),o=[],a=[];return i.forEach((e=>{t.classList.contains(e)&&(t.classList.remove(e),a.push(e))})),r.forEach((e=>{t.classList.contains(e)||(t.classList.add(e),o.push(e))})),()=>{a.forEach((e=>t.classList.add(e))),o.forEach((e=>t.classList.remove(e)))}}(t,e):"function"==typeof e?jt(t,e()):Nt(t,e)}function Nt(t,e){return e=!0===e?e="":e||"",n=e.split(" ").filter((e=>!t.classList.contains(e))).filter(Boolean),t.classList.add(...n),()=>{t.classList.remove(...n)};var n}function Mt(t,e){return"object"==typeof e&&null!==e?function(t,e){let n={};return Object.entries(e).forEach((([e,r])=>{n[e]=t.style[e],e.startsWith("--")||(e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()),t.style.setProperty(e,r)})),setTimeout((()=>{0===t.style.length&&t.removeAttribute("style")})),()=>{Mt(t,n)}}(t,e):function(t,e){let n=t.getAttribute("style",e);return t.setAttribute("style",e),()=>{t.setAttribute("style",n||"")}}(t,e)}function Rt(t,e=(()=>{})){let n=!1;return function(){n?e.apply(this,arguments):(n=!0,t.apply(this,arguments))}}function Dt(t,e,n={}){t._x_transition||(t._x_transition={enter:{during:n,start:n,end:n},leave:{during:n,start:n,end:n},in(n=(()=>{}),r=(()=>{})){It(t,e,{during:this.enter.during,start:this.enter.start,end:this.enter.end},n,r)},out(n=(()=>{}),r=(()=>{})){It(t,e,{during:this.leave.during,start:this.leave.start,end:this.leave.end},n,r)}})}function Lt(t){let e=t.parentNode;if(e)return e._x_hidePromise?e:Lt(e)}function It(t,e,{during:n,start:r,end:i}={},o=(()=>{}),a=(()=>{})){if(t._x_transitioning&&t._x_transitioning.cancel(),0===Object.keys(n).length&&0===Object.keys(r).length&&0===Object.keys(i).length)return o(),void a();let s,u,c;!function(t,e){let n,r,i,o=Rt((()=>{S((()=>{n=!0,r||e.before(),i||(e.end(),At()),e.after(),t.isConnected&&e.cleanup(),delete t._x_transitioning}))}));t._x_transitioning={beforeCancels:[],beforeCancel(t){this.beforeCancels.push(t)},cancel:Rt((function(){for(;this.beforeCancels.length;)this.beforeCancels.shift()();o()})),finish:o},S((()=>{e.start(),e.during()})),Pt=!0,requestAnimationFrame((()=>{if(n)return;let o=1e3*Number(getComputedStyle(t).transitionDuration.replace(/,.*/,"").replace("s","")),a=1e3*Number(getComputedStyle(t).transitionDelay.replace(/,.*/,"").replace("s",""));0===o&&(o=1e3*Number(getComputedStyle(t).animationDuration.replace("s",""))),S((()=>{e.before()})),r=!0,requestAnimationFrame((()=>{n||(S((()=>{e.end()})),At(),setTimeout(t._x_transitioning.finish,o+a),i=!0)}))}))}(t,{start(){s=e(t,r)},during(){u=e(t,n)},before:o,end(){s(),c=e(t,i)},after:a,cleanup(){u(),c()}})}function Ut(t,e,n){if(-1===t.indexOf(e))return n;const r=t[t.indexOf(e)+1];if(!r)return n;if("scale"===e&&isNaN(r))return n;if("duration"===e||"delay"===e){let t=r.match(/([0-9]+)ms/);if(t)return t[1]}return"origin"===e&&["top","right","left","center","bottom"].includes(t[t.indexOf(e)+2])?[r,t[t.indexOf(e)+2]].join(" "):r}G("transition",((t,{value:e,modifiers:n,expression:r},{evaluate:i})=>{"function"==typeof r&&(r=i(r)),!1!==r&&(r&&"boolean"!=typeof r?function(t,e,n){Dt(t,jt,"");let r={enter:e=>{t._x_transition.enter.during=e},"enter-start":e=>{t._x_transition.enter.start=e},"enter-end":e=>{t._x_transition.enter.end=e},leave:e=>{t._x_transition.leave.during=e},"leave-start":e=>{t._x_transition.leave.start=e},"leave-end":e=>{t._x_transition.leave.end=e}};r[n](e)}(t,r,e):function(t,e,n){Dt(t,Mt);let r=!e.includes("in")&&!e.includes("out")&&!n,i=r||e.includes("in")||["enter"].includes(n),o=r||e.includes("out")||["leave"].includes(n);e.includes("in")&&!r&&(e=e.filter(((t,n)=>nn>e.indexOf("out"))));let a=!e.includes("opacity")&&!e.includes("scale"),s=a||e.includes("opacity"),u=a||e.includes("scale"),c=s?0:1,l=u?Ut(e,"scale",95)/100:1,f=Ut(e,"delay",0)/1e3,h=Ut(e,"origin","center"),d="opacity, transform",p=Ut(e,"duration",150)/1e3,v=Ut(e,"duration",75)/1e3,g="cubic-bezier(0.4, 0.0, 0.2, 1)";i&&(t._x_transition.enter.during={transformOrigin:h,transitionDelay:`${f}s`,transitionProperty:d,transitionDuration:`${p}s`,transitionTimingFunction:g},t._x_transition.enter.start={opacity:c,transform:`scale(${l})`},t._x_transition.enter.end={opacity:1,transform:"scale(1)"});o&&(t._x_transition.leave.during={transformOrigin:h,transitionDelay:`${f}s`,transitionProperty:d,transitionDuration:`${v}s`,transitionTimingFunction:g},t._x_transition.leave.start={opacity:1,transform:"scale(1)"},t._x_transition.leave.end={opacity:c,transform:`scale(${l})`})}(t,n,e))})),window.Element.prototype._x_toggleAndCascadeWithTransitions=function(t,e,n,r){const i="visible"===document.visibilityState?requestAnimationFrame:setTimeout;let o=()=>i(n);e?t._x_transition&&(t._x_transition.enter||t._x_transition.leave)?t._x_transition.enter&&(Object.entries(t._x_transition.enter.during).length||Object.entries(t._x_transition.enter.start).length||Object.entries(t._x_transition.enter.end).length)?t._x_transition.in(n):o():t._x_transition?t._x_transition.in(n):o():(t._x_hidePromise=t._x_transition?new Promise(((e,n)=>{t._x_transition.out((()=>{}),(()=>e(r))),t._x_transitioning.beforeCancel((()=>n({isFromCancelledTransition:!0})))})):Promise.resolve(r),queueMicrotask((()=>{let e=Lt(t);e?(e._x_hideChildren||(e._x_hideChildren=[]),e._x_hideChildren.push(t)):i((()=>{let e=t=>{let n=Promise.all([t._x_hidePromise,...(t._x_hideChildren||[]).map(e)]).then((([t])=>t()));return delete t._x_hidePromise,delete t._x_hideChildren,n};e(t).catch((t=>{if(!t.isFromCancelledTransition)throw t}))}))})))};var Ft=!1;function Bt(t,e=(()=>{})){return(...n)=>Ft?e(...n):t(...n)}function zt(e,n,r,i=[]){switch(e._x_bindings||(e._x_bindings=t({})),e._x_bindings[n]=r,n=i.includes("camel")?n.toLowerCase().replace(/-(\w)/g,((t,e)=>e.toUpperCase())):n){case"value":!function(t,e){if("radio"===t.type)void 0===t.attributes.value&&(t.value=e),window.fromModel&&(t.checked=Ht(t.value,e));else if("checkbox"===t.type)Number.isInteger(e)?t.value=e:Number.isInteger(e)||Array.isArray(e)||"boolean"==typeof e||[null,void 0].includes(e)?Array.isArray(e)?t.checked=e.some((e=>Ht(e,t.value))):t.checked=!!e:t.value=String(e);else if("SELECT"===t.tagName)!function(t,e){const n=[].concat(e).map((t=>t+""));Array.from(t.options).forEach((t=>{t.selected=n.includes(t.value)}))}(t,e);else{if(t.value===e)return;t.value=e}}(e,r);break;case"style":!function(t,e){t._x_undoAddedStyles&&t._x_undoAddedStyles();t._x_undoAddedStyles=Mt(t,e)}(e,r);break;case"class":!function(t,e){t._x_undoAddedClasses&&t._x_undoAddedClasses();t._x_undoAddedClasses=jt(t,e)}(e,r);break;case"selected":case"checked":!function(t,e,n){qt(t,e,n),function(t,e,n){t[e]!==n&&(t[e]=n)}(t,e,n)}(e,n,r);break;default:qt(e,n,r)}}function qt(t,e,n){[null,void 0,!1].includes(n)&&function(t){return!["aria-pressed","aria-checked","aria-expanded","aria-selected"].includes(t)}(e)?t.removeAttribute(e):(Wt(e)&&(n=e),function(t,e,n){t.getAttribute(e)!=n&&t.setAttribute(e,n)}(t,e,n))}function Ht(t,e){return t==e}function Wt(t){return["disabled","checked","required","readonly","hidden","open","selected","autofocus","itemscope","multiple","novalidate","allowfullscreen","allowpaymentrequest","formnovalidate","autoplay","controls","loop","muted","playsinline","default","ismap","reversed","async","defer","nomodule"].includes(t)}function Yt(t,e){var n;return function(){var r=this,i=arguments;clearTimeout(n),n=setTimeout((function(){n=null,t.apply(r,i)}),e)}}function $t(t,e){let n;return function(){let r=this,i=arguments;n||(t.apply(r,i),n=!0,setTimeout((()=>n=!1),e))}}var Vt={},Jt=!1;var Xt={};function Gt(t,e,n){let r=[];for(;r.length;)r.pop()();let i=Object.entries(e).map((([t,e])=>({name:t,value:e}))),o=K(i);i=i.map((t=>o.find((e=>e.name===t.name))?{name:`x-bind:${t.name}`,value:`"${t.value}"`}:t)),Z(t,i,n).map((t=>{r.push(t.runCleanups),t()}))}var Zt={};var Kt={get reactive(){return t},get release(){return n},get effect(){return e},get raw(){return r},version:"3.12.2",flushAndStopDeferringMutations:function(){O=!1,T(k),k=[]},dontAutoEvaluateFunctions:function(t){let e=B;B=!1,t(),B=e},disableEffectScheduling:function(t){f=!1,t(),f=!0},startObservingMutations:w,stopObservingMutations:_,setReactivityEngine:function(i){t=i.reactive,n=i.release,e=t=>i.effect(t,{scheduler:t=>{f?u(t):t()}}),r=i.raw},closestDataStack:A,skipDuringClone:Bt,onlyDuringClone:function(t){return(...e)=>Ft&&t(...e)},addRootSelector:wt,addInitSelector:_t,addScopeToNode:C,deferMutations:function(){O=!0},mapAttributes:at,evaluateLater:q,interceptInit:function(t){St.push(t)},setEvaluator:function(t){H=t},mergeProxies:j,findClosest:Et,closestRoot:xt,destroyTree:kt,interceptor:M,transition:It,setStyles:Mt,mutateDom:S,directive:G,throttle:$t,debounce:Yt,evaluate:z,initTree:Ot,nextTick:Ct,prefixed:J,prefix:function(t){V=t},plugin:function(t){(Array.isArray(t)?t:[t]).forEach((t=>t(Qt)))},magic:L,store:function(e,n){if(Jt||(Vt=t(Vt),Jt=!0),void 0===n)return Vt[e];Vt[e]=n,"object"==typeof n&&null!==n&&n.hasOwnProperty("init")&&"function"==typeof n.init&&Vt[e].init(),N(Vt[e])},start:function(){var t;vt&&pt("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),vt=!0,document.body||pt("Unable to initialize. Trying to load Alpine before `` is available. Did you forget to add `defer` in Alpine's ` - - \ No newline at end of file diff --git a/routes/api/v1/v1-api.php b/routes/api/v1/v1-api.php index 8b33a4f..732839d 100644 --- a/routes/api/v1/v1-api.php +++ b/routes/api/v1/v1-api.php @@ -7,6 +7,7 @@ use App\Http\Controllers\Api\V1\Carousel\CarouselController; use App\Http\Controllers\Api\V1\CartController; use App\Http\Controllers\Api\V1\Category\CategoryController; use App\Http\Controllers\Api\V1\Channel\ChannelController; +use App\Http\Controllers\Api\V1\Chat\ChatController; use App\Http\Controllers\Api\V1\Collection\CollectionController; use App\Http\Controllers\Api\V1\ContactMessageController; use App\Http\Controllers\Api\V1\Favorite\FavoriteController; @@ -107,18 +108,19 @@ Route::get('filters', [FilterController::class, 'index']); // Global orders... Route::post('global-order', [GlobalOrderController::class, 'store']); -// Route::middleware('auth:sanctum')->group(function () { -// Route::get('/chat/contacts', [ChatController::class, 'contacts']); -// Route::get('/chat/messages/{conversation}', [ChatController::class, 'messages']); -// Route::post('/chat/start', [ChatController::class, 'start']); -// Route::post('/chat/send', [ChatController::class, 'send']); -// }); - Route::middleware(['auth:sanctum', 'banned'])->group(function () { // Profile... Route::get('profile', [ProfileController::class, 'index']); Route::post('profile', [ProfileController::class, 'store']); + // Chat... + Route::get('chat/conversations', [ChatController::class, 'conversations']); + Route::get('chat/contacts', [ChatController::class, 'contacts']); + Route::post('chat/start', [ChatController::class, 'start']); + Route::get('chat/conversations/{conversation}/messages', [ChatController::class, 'messages'])->where(['conversation' => '[0-9]+']); + Route::post('chat/conversations/{conversation}/messages', [ChatController::class, 'send'])->where(['conversation' => '[0-9]+']); + Route::post('chat/conversations/{conversation}/read', [ChatController::class, 'read'])->where(['conversation' => '[0-9]+']); + // Cart items... Route::get('carts', [CartController::class, 'index']); Route::post('carts', [CartController::class, 'store']);