reactiveadmin 0.2.0 → 0.3.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/README.md +1 -1
  4. data/lib/reactive_admin/aa/input.rb +26 -0
  5. data/lib/reactive_admin/aa/v3/form_hooks.rb +38 -0
  6. data/lib/reactive_admin/aa/v3/forms.rb +9 -1
  7. data/lib/reactive_admin/aa/v3/recorders.rb +51 -0
  8. data/lib/reactive_admin/aa/v3/views.rb +20 -1
  9. data/lib/reactive_admin/aa/v3.rb +2 -0
  10. data/lib/reactive_admin/aa/v4.rb +10 -0
  11. data/lib/reactive_admin/aa.rb +2 -1
  12. data/lib/reactive_admin/engine.rb +6 -0
  13. data/lib/reactive_admin/form_field.rb +3 -3
  14. data/lib/reactive_admin/form_recorder.rb +8 -10
  15. data/lib/reactive_admin/html_nodes.rb +17 -16
  16. data/lib/reactive_admin/index_recorder.rb +9 -11
  17. data/lib/reactive_admin/open_api/page_doc.rb +2 -2
  18. data/lib/reactive_admin/open_api/parts.rb +3 -0
  19. data/lib/reactive_admin/open_api/resource_doc.rb +1 -8
  20. data/lib/reactive_admin/page_forms.rb +3 -26
  21. data/lib/reactive_admin/page_payload.rb +4 -6
  22. data/lib/reactive_admin/rspec.rb +12 -2
  23. data/lib/reactive_admin/show_payload.rb +4 -6
  24. data/lib/reactive_admin/style_sources.rb +1 -1
  25. data/lib/reactive_admin/template_form.rb +12 -27
  26. data/lib/reactive_admin/ui/assets.rb +19 -1
  27. data/lib/reactive_admin/ui/helper.rb +2 -2
  28. data/lib/reactive_admin/version.rb +1 -1
  29. data/openapi/core.yaml +59 -5
  30. data/vendor/client/assets/{ActionPage-XUYorI8E.js → ActionPage-B_eluF5e.js} +1 -1
  31. data/vendor/client/assets/{ActionView-BsZFcsgp.js → ActionView-CGcC3D3z.js} +1 -1
  32. data/vendor/client/assets/{CommandPalette-C59HT1ip.js → CommandPalette-IF4e0T2d.js} +1 -1
  33. data/vendor/client/assets/{DatePicker-DuaK0iMg.js → DatePicker-CgNVJIOj.js} +1 -1
  34. data/vendor/client/assets/DateRangeCalendar-BbIDUkc0.js +1 -0
  35. data/vendor/client/assets/{DegradedNotice-DiH5n2DO.js → DegradedNotice-DPH_YfUt.js} +1 -1
  36. data/vendor/client/assets/{FormDialog-pmYl8Eov.js → FormDialog-DzHVGQ6M.js} +1 -1
  37. data/vendor/client/assets/{FormSkeleton-DuSBZO3C.js → FormSkeleton-5eT0T2pe.js} +1 -1
  38. data/vendor/client/assets/{FrameView-zmUeDO8d.js → FrameView-CczSy0lF.js} +1 -1
  39. data/vendor/client/assets/{GroupOverview-DI5T3k5K.js → GroupOverview-BgyZuNFr.js} +1 -1
  40. data/vendor/client/assets/{InlineForm-CMEIMgeh.js → InlineForm-D0e87tnu.js} +1 -1
  41. data/vendor/client/assets/{JsonDiff-o7JWr7CH.js → JsonDiff-CAW7eyGU.js} +1 -1
  42. data/vendor/client/assets/{JsonEditor-D4VXdlEx.js → JsonEditor-DQGi6MrZ.js} +1 -1
  43. data/vendor/client/assets/{JsonView-BrJLDmSN.js → JsonView-WqpIBVJn.js} +1 -1
  44. data/vendor/client/assets/{MobileMenu-GAeFOeEb.js → MobileMenu-BmrGFN_r.js} +1 -1
  45. data/vendor/client/assets/{Node-SQl61V4K.js → Node-BFhcTc_1.js} +2 -2
  46. data/vendor/client/assets/{PageView-C-laNEPZ.js → PageView-DJSTdX6o.js} +1 -1
  47. data/vendor/client/assets/{ResourceForm-BPjsoCY6.js → ResourceForm-7FgpxGHE.js} +1 -1
  48. data/vendor/client/assets/{ResourceIndex-COezAw5t.js → ResourceIndex-BXnX5xpb.js} +3 -3
  49. data/vendor/client/assets/{ResourceOrPage-CRZGCY84.js → ResourceOrPage-54vonIqh.js} +1 -1
  50. data/vendor/client/assets/{ResourceShow-DweRXn18.js → ResourceShow-BAO32hZ2.js} +1 -1
  51. data/vendor/client/assets/{Sidebars-CsB9rFqX.js → Sidebars-C3SKSr0y.js} +1 -1
  52. data/vendor/client/assets/{breadcrumb-DSA3Tlyd.js → breadcrumb-FT076GDh.js} +1 -1
  53. data/vendor/client/assets/{calendar-BoyMpJIf.js → calendar-C7i0aj0N.js} +1 -1
  54. data/vendor/client/assets/{command-CMuk0oAt.js → command-Cxg-I-G2.js} +1 -1
  55. data/vendor/client/assets/{frames-C9gPCc3N.js → frames-5gaTmR-V.js} +1 -1
  56. data/vendor/client/assets/{index-B51aUaAY.js → index-BX4ymNYp.js} +2 -2
  57. data/vendor/client/assets/{json-oTp7Q-d-.js → json-DJQxJYgz.js} +1 -1
  58. data/vendor/client/assets/{media-D4a_En8R.js → media-D9RvvA8H.js} +1 -1
  59. data/vendor/client/assets/{popover-CDtI9R8Q.js → popover-C_DGv69u.js} +1 -1
  60. data/vendor/client/assets/{rich-BQc_q5T7.js → rich-Dl2s62g4.js} +1 -1
  61. data/vendor/client/assets/{select-C43qDA3k.js → select-DWKulrU7.js} +1 -1
  62. data/vendor/client/assets/{sheet-BPl2n-4n.js → sheet-CihU0Mcq.js} +1 -1
  63. data/vendor/client/assets/{useRecordForm-X_DExEP2.js → useRecordForm-BOmRWZbo.js} +1 -1
  64. data/vendor/client/index.html +1 -1
  65. data/vendor/client/manifest.json +110 -110
  66. data/vendor/client/reactiveadmin-client.json +1 -1
  67. metadata +38 -35
  68. data/vendor/client/assets/DateRangeCalendar-B2BDsG-X.js +0 -1
@@ -37,8 +37,18 @@ module ReactiveAdmin
37
37
  def valid?(schema, data) = errors(schema, data).empty?
38
38
 
39
39
  # What core.yaml declares for `status` on the operation that serves `path`; nil when it declares nothing.
40
- def response_schema(verb, path, status)
41
- keys = ["paths", template(path), verb.to_s.downcase, "responses", status.to_s]
40
+ def response_schema(verb, path, status) = (route = template(path)) && schema_at(["paths", route, verb.to_s.downcase], status)
41
+
42
+ # The same for the operation with `operation_id`.
43
+ def operation_schema(operation_id, status)
44
+ document["paths"].each do |route, operations|
45
+ operations.each { |verb, operation| return schema_at(["paths", route, verb], status) if operation.is_a?(Hash) && operation["operationId"] == operation_id }
46
+ end
47
+ nil
48
+ end
49
+
50
+ def schema_at(operation, status)
51
+ keys = [*operation, "responses", status.to_s]
42
52
  ref = document.dig(*keys, "$ref")
43
53
  keys = ref.delete_prefix("#/").split("/") if ref
44
54
  keys += ["content", "application/json", "schema"]
@@ -1,9 +1,7 @@
1
1
  module ReactiveAdmin
2
2
  class ShowPayload
3
3
  # Arbre context mirroring ActiveAdmin::Views::Pages::Show#attributes_table.
4
- class Page < AA.arbre_element
5
- include PageForms::ArbreForms
6
-
4
+ class Page < AA.page_element_base
7
5
  def attributes_table(*args, &block)
8
6
  options = args.extract_options!
9
7
  title = if options.key?(:title)
@@ -74,15 +72,15 @@ module ReactiveAdmin
74
72
  page = new_page
75
73
  run = -> { presenter&.block ? page.instance_exec(record, &presenter.block) : page.default_main_content }
76
74
  forms ? PageForms.recording(@view, @controller, &run) : run.call
77
- page.arbre_context.to_s
75
+ page.document_html
78
76
  rescue => e
79
77
  Rails.logger.warn("[reactiveadmin] #{@config.resource_name} show block fell back to defaults: #{e.class} at #{e.backtrace&.first}")
80
78
  Degradation.record(kind: :show_block_failed, where: "show", reason: "Show block raised #{e.class}; showing default attributes")
81
79
  page = new_page
82
80
  page.default_main_content
83
- page.arbre_context.to_s
81
+ page.document_html
84
82
  end
85
83
 
86
- def new_page = AA.arbre_context(@controller.view_assigns, @view).insert_tag(Page)
84
+ def new_page = Page.build_in(@controller.view_assigns, @view)
87
85
  end
88
86
  end
@@ -51,7 +51,7 @@ module ReactiveAdmin
51
51
  where = origin if strings.any?
52
52
  return unless where
53
53
 
54
- resource = tag.arbre_context.helpers.try(:active_admin_config)&.resource_name.to_s
54
+ resource = AA.arbre_helpers(tag).try(:active_admin_config)&.resource_name.to_s
55
55
  strings.each { (STATE[KEY][[resource, it]] ||= Set.new) << where }
56
56
  end
57
57
 
@@ -9,32 +9,6 @@ module ReactiveAdmin
9
9
 
10
10
  METHODS = %w[get post put patch delete].freeze
11
11
 
12
- # Mixed into the view that renders the template.
13
- module Recording
14
- def semantic_form_for(*args, &block)
15
- state = @_reactiveadmin_template
16
- return super unless state
17
- return state.extra_form(self) { semantic_form_for(*args, &block) } if state.extra_form?
18
-
19
- items = nil
20
- markup = super do |builder|
21
- state.objects << builder.object
22
- items = state.expand(state.capture(self, Recorder.new(builder, state, self), &block))
23
- "".html_safe
24
- end
25
- state.mark([:form, {items:, **Form.target(markup)}])
26
- end
27
-
28
- # AA's version builds an Arbre form around a real builder, which the recorder can't stand in for.
29
- def active_admin_form_for(resource, options = {}, &block)
30
- state = @_reactiveadmin_template
31
- return super unless state
32
- return state.extra_form(self) { active_admin_form_for(resource, options, &block) } if state.extra_form?
33
-
34
- state.arbre { semantic_form_for(resource, {builder: AA.form_builder}.merge(options), &block) }
35
- end
36
- end
37
-
38
12
  # Reads the form tag Rails built: its action and verb, whichever way `url:` and `method:` were given.
39
13
  module Form
40
14
  module_function
@@ -101,6 +75,17 @@ module ReactiveAdmin
101
75
  forms.node(view, &block) || forms.suspended { printing(view, &block) }
102
76
  end
103
77
 
78
+ # Records the form the view's helper builds: the block gets the builder, and its items become the form's.
79
+ def record_form(view, block)
80
+ items = nil
81
+ markup = yield proc { |builder|
82
+ objects << builder.object
83
+ items = expand(capture(view, Recorder.new(builder, self, view), &block))
84
+ "".html_safe
85
+ }
86
+ mark([:form, {items:, **Form.target(markup)}])
87
+ end
88
+
104
89
  def mark(entry)
105
90
  @entries << entry
106
91
  marker(@entries.size - 1).html_safe.tap { @buffers.last&.push(it) }
@@ -371,7 +356,7 @@ module ReactiveAdmin
371
356
  # Runs the block (a render) on a view whose Formtastic forms record; returns the state and the html.
372
357
  def self.recording(schema, view, controller: nil)
373
358
  state = State.new(schema, controller:)
374
- view.extend(Recording)
359
+ view.extend(AA.template_form_hooks)
375
360
  view.instance_variable_set(:@_reactiveadmin_template, state)
376
361
  [state, yield]
377
362
  ensure
@@ -71,6 +71,7 @@ module ReactiveAdmin
71
71
  # Hashed files never change, so they cache for good; everything else revalidates.
72
72
  class Server
73
73
  IMMUTABLE = {"cache-control" => "public, max-age=31536000, immutable"}.freeze
74
+ REVALIDATE = {"cache-control" => "no-cache"}.freeze
74
75
 
75
76
  # The packaged build's stamp names the exact gem version, which is nobody's business. Judged on the path as
76
77
  # Rack::Files will read it, decoded and cleaned, so an encoded name can't slip past.
@@ -79,13 +80,30 @@ module ReactiveAdmin
79
80
  return not_found unless Rack::Utils.valid_path?(path)
80
81
  return not_found if File.basename(Rack::Utils.clean_path_info(path)) == PackagedClient::INFO
81
82
 
82
- Rack::Files.new(Assets.root.to_s, env["PATH_INFO"].start_with?("/assets/") ? IMMUTABLE : {}).call(env)
83
+ Rack::Files.new(Assets.root.to_s, env["PATH_INFO"].start_with?("/assets/") ? IMMUTABLE : REVALIDATE).call(env)
83
84
  end
84
85
 
85
86
  private
86
87
 
87
88
  def not_found = [404, {"content-type" => "text/plain"}, ["Not Found"]]
88
89
  end
90
+
91
+ # Answers the client's files ahead of the session middleware. These responses are public and cacheable, so
92
+ # they must never carry a session cookie: a shared cache (a CDN) would hand it to other visitors.
93
+ class Middleware
94
+ def initialize(app)
95
+ @app = app
96
+ @server = Server.new
97
+ end
98
+
99
+ def call(env)
100
+ prefix = Assets.prefix
101
+ path = env["PATH_INFO"].to_s
102
+ return @app.call(env) unless prefix.start_with?("/") && %w[GET HEAD].include?(env["REQUEST_METHOD"]) && path.start_with?("#{prefix}/")
103
+
104
+ @server.call(env.merge("SCRIPT_NAME" => env["SCRIPT_NAME"].to_s + prefix, "PATH_INFO" => path.delete_prefix(prefix)))
105
+ end
106
+ end
89
107
  end
90
108
  end
91
109
  end
@@ -11,9 +11,9 @@ module ReactiveAdmin
11
11
  return "".html_safe unless script && params[:embed] != "1" && Ui.available?(user)
12
12
 
13
13
  returning = params[:classic] == "1"
14
- tag.div(class: "panel reactiveadmin-ui-toggle", data: {reactiveadmin_ui: Ui.default_mode(user)}) do
14
+ tag.div(class: [AA.markup[:panel], "reactiveadmin-ui-toggle"], data: {reactiveadmin_ui: Ui.default_mode(user)}) do
15
15
  tag.h3(returning ? "The new admin" : "Try the new admin") +
16
- tag.div(class: "panel_contents") do
16
+ tag.div(class: AA.markup[:panel_contents]) do
17
17
  tag.p(returning ? "You're viewing a classic page on request." : "The same pages in a faster, redesigned admin. You can switch back at any time.") +
18
18
  tag.button(returning ? "Return to the new admin" : "Try the new admin", type: "button", data: {reactiveadmin_ui_mode: "new"})
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module ReactiveAdmin
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/openapi/core.yaml CHANGED
@@ -308,6 +308,29 @@ paths:
308
308
  "403": { $ref: "#/components/responses/Error" }
309
309
  "404": { $ref: "#/components/responses/Error" }
310
310
  /admin/{resource}/{id}/{action}:
311
+ get:
312
+ operationId: runMemberActionGet
313
+ tags: [core]
314
+ description: |
315
+ A GET member action. Its template answers as a FormResponse (a form) or a PageResponse (read-only
316
+ content), as `Action.view` says; with `context=template` and `field`, that template form field's options
317
+ (OptionsResponse); a redirect answers an ActionResult; an html page the API can't describe answers 501
318
+ `unsupported`. Collection actions are served the same way at `/admin/{resource}/{action}`, and page actions
319
+ at `/admin/{page}/{action}`: those paths can't be declared apart from `/admin/{resource}/{id}` and
320
+ `/admin/{resource}`, so this operation stands for them too.
321
+ parameters:
322
+ - { $ref: "#/components/parameters/Resource" }
323
+ - { $ref: "#/components/parameters/Id" }
324
+ - { $ref: "#/components/parameters/Action" }
325
+ - { name: context, in: query, description: "`template` asks for a template form field's options (its `options_path` carries context and field)", schema: { type: string, enum: [template] } }
326
+ - { name: field, in: query, description: "With context=template", schema: { type: string } }
327
+ - { name: term, in: query, description: "With context=template", schema: { type: string } }
328
+ responses:
329
+ "200": { $ref: "#/components/responses/ActionGet" }
330
+ "401": { $ref: "#/components/responses/Error" }
331
+ "403": { $ref: "#/components/responses/Error" }
332
+ "404": { $ref: "#/components/responses/Error" }
333
+ "501": { $ref: "#/components/responses/Unsupported" }
311
334
  post:
312
335
  operationId: runMemberActionPost
313
336
  tags: [core]
@@ -315,18 +338,19 @@ paths:
315
338
  A member action declared with `member_action` (HTTP verb per `Action.method`). The action's
316
339
  redirect + flash become an ActionResult; an alert/error flash becomes a 422. Authorized with
317
340
  the same permission that gates `Action.enabled`. Collection actions are served the same way at
318
- `/admin/{resource}/{action}` (no id).
341
+ `/admin/{resource}/{action}` (no id), and page actions at `/admin/{page}/{action}`.
319
342
  parameters:
320
343
  - { $ref: "#/components/parameters/Resource" }
321
344
  - { $ref: "#/components/parameters/Id" }
322
345
  - { $ref: "#/components/parameters/Action" }
323
346
  requestBody: { $ref: "#/components/requestBodies/ActionParams" }
324
347
  responses:
325
- "200": { $ref: "#/components/responses/ActionResult" }
348
+ "200": { $ref: "#/components/responses/ActionWrite" }
326
349
  "401": { $ref: "#/components/responses/Error" }
327
350
  "403": { $ref: "#/components/responses/Error" }
328
351
  "404": { $ref: "#/components/responses/Error" }
329
352
  "422": { $ref: "#/components/responses/Invalid" }
353
+ "501": { $ref: "#/components/responses/Unsupported" }
330
354
  put:
331
355
  operationId: runMemberActionPut
332
356
  tags: [core]
@@ -337,11 +361,12 @@ paths:
337
361
  - { $ref: "#/components/parameters/Action" }
338
362
  requestBody: { $ref: "#/components/requestBodies/ActionParams" }
339
363
  responses:
340
- "200": { $ref: "#/components/responses/ActionResult" }
364
+ "200": { $ref: "#/components/responses/ActionWrite" }
341
365
  "401": { $ref: "#/components/responses/Error" }
342
366
  "403": { $ref: "#/components/responses/Error" }
343
367
  "404": { $ref: "#/components/responses/Error" }
344
368
  "422": { $ref: "#/components/responses/Invalid" }
369
+ "501": { $ref: "#/components/responses/Unsupported" }
345
370
  "409": { $ref: "#/components/responses/Conflict" }
346
371
  patch:
347
372
  operationId: runMemberActionPatch
@@ -353,11 +378,12 @@ paths:
353
378
  - { $ref: "#/components/parameters/Action" }
354
379
  requestBody: { $ref: "#/components/requestBodies/ActionParams" }
355
380
  responses:
356
- "200": { $ref: "#/components/responses/ActionResult" }
381
+ "200": { $ref: "#/components/responses/ActionWrite" }
357
382
  "401": { $ref: "#/components/responses/Error" }
358
383
  "403": { $ref: "#/components/responses/Error" }
359
384
  "404": { $ref: "#/components/responses/Error" }
360
385
  "422": { $ref: "#/components/responses/Invalid" }
386
+ "501": { $ref: "#/components/responses/Unsupported" }
361
387
  "409": { $ref: "#/components/responses/Conflict" }
362
388
  delete:
363
389
  operationId: runMemberActionDelete
@@ -369,11 +395,12 @@ paths:
369
395
  - { $ref: "#/components/parameters/Action" }
370
396
  requestBody: { $ref: "#/components/requestBodies/ActionParams" }
371
397
  responses:
372
- "200": { $ref: "#/components/responses/ActionResult" }
398
+ "200": { $ref: "#/components/responses/ActionWrite" }
373
399
  "401": { $ref: "#/components/responses/Error" }
374
400
  "403": { $ref: "#/components/responses/Error" }
375
401
  "404": { $ref: "#/components/responses/Error" }
376
402
  "422": { $ref: "#/components/responses/Invalid" }
403
+ "501": { $ref: "#/components/responses/Unsupported" }
377
404
  /admin/{resource}:
378
405
  post:
379
406
  operationId: createRecord
@@ -567,7 +594,34 @@ components:
567
594
  content:
568
595
  application/json:
569
596
  schema: { $ref: "#/components/schemas/ActionResult" }
597
+ ActionGet:
598
+ description: What a GET custom action answers; see runMemberActionGet.
599
+ headers: { X-Reactiveadmin-Degraded: { $ref: "#/components/headers/Degraded" } }
600
+ content:
601
+ application/json:
602
+ schema: { $ref: "#/components/schemas/ActionGetResponse" }
603
+ ActionWrite:
604
+ description: "The action ran: an ActionResult, or a FormResponse when it rendered its template again (see the ActionResult response)."
605
+ headers: { X-Reactiveadmin-Degraded: { $ref: "#/components/headers/Degraded" } }
606
+ content:
607
+ application/json:
608
+ schema: { $ref: "#/components/schemas/ActionWriteResponse" }
609
+ Unsupported:
610
+ description: The action renders an html page the API can't describe (`unsupported`); use the classic admin.
611
+ content:
612
+ application/json:
613
+ schema: { $ref: "#/components/schemas/Error" }
570
614
  schemas:
615
+ ActionGetResponse:
616
+ oneOf:
617
+ - $ref: "#/components/schemas/FormResponse"
618
+ - $ref: "#/components/schemas/PageResponse"
619
+ - $ref: "#/components/schemas/OptionsResponse"
620
+ - $ref: "#/components/schemas/ActionResult"
621
+ ActionWriteResponse:
622
+ oneOf:
623
+ - $ref: "#/components/schemas/ActionResult"
624
+ - $ref: "#/components/schemas/FormResponse"
571
625
  ClientErrorReport:
572
626
  type: object
573
627
  required: [error_name]
@@ -1 +1 @@
1
- import{d as e,l as t,t as n,u as r}from"./vendor-router-CI6Vh4k_.js";import{A as i,F as a,P as o,R as s,r as c,st as l,z as u}from"./index-B51aUaAY.js";import{a as d,i as f,n as p,o as m,r as h,t as g}from"./breadcrumb-DSA3Tlyd.js";import{E as _,K as v,q as y}from"./Node-SQl61V4K.js";import{ActionViewBody as b}from"./ActionView-BsZFcsgp.js";import{r as x}from"./humanize-DtU_Kpr4.js";import{t as S}from"./vendor-react-C1iE8mnY.js";var C=S();function w(){let{resource:S=``,id:w,key:T=``}=e(),{state:E}=t(),D=r(),O=l(S,w??``,{query:{enabled:!!w}}),{summary:k}=a(S),{meta:A}=o(w?``:S),j=E?.action??O.data?.actions.find(e=>e.key===T)??A?.action_items?.find(e=>e.key===T),M=O.data?.display_name??(w?v(w)?`${y(w)}…`:`#${w}`:void 0),N=_({resource:S,id:w,name:O.data?.display_name}),P=x(k??A,S),F=w?`/${S}/${w}`:`/${S}`;i(j?.label);let I=!j&&(w?!O.isPending:!!A);return O.error||I?(0,C.jsx)(u,{error:O.error??Error(`That action is not available`),label:`this action`,backTo:{to:F,label:`Back to ${P}`}}):(0,C.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,C.jsx)(g,{children:(0,C.jsxs)(f,{children:[(0,C.jsx)(p,{children:(0,C.jsx)(h,{asChild:!0,children:(0,C.jsx)(n,{to:`/${S}`,children:P})})}),(0,C.jsx)(m,{}),M&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p,{children:(0,C.jsx)(h,{asChild:!0,children:(0,C.jsx)(n,{to:F,children:M})})}),(0,C.jsx)(m,{})]}),(0,C.jsx)(p,{children:(0,C.jsx)(d,{children:j?.label??T})})]})}),(0,C.jsx)(c,{title:j?.label??(0,C.jsx)(s,{className:`h-8 w-64`})}),j?(0,C.jsx)(b,{action:j,resource:S,id:w,container:`page`,onClose:()=>D(F),onResult:e=>{N(j,e),e.location||D(F)}}):(0,C.jsx)(s,{className:`h-40 w-full max-w-3xl`})]})}export{w as ActionPage};
1
+ import{d as e,l as t,t as n,u as r}from"./vendor-router-CI6Vh4k_.js";import{A as i,F as a,P as o,R as s,r as c,st as l,z as u}from"./index-BX4ymNYp.js";import{a as d,i as f,n as p,o as m,r as h,t as g}from"./breadcrumb-FT076GDh.js";import{E as _,K as v,q as y}from"./Node-BFhcTc_1.js";import{ActionViewBody as b}from"./ActionView-CGcC3D3z.js";import{r as x}from"./humanize-DtU_Kpr4.js";import{t as S}from"./vendor-react-C1iE8mnY.js";var C=S();function w(){let{resource:S=``,id:w,key:T=``}=e(),{state:E}=t(),D=r(),O=l(S,w??``,{query:{enabled:!!w}}),{summary:k}=a(S),{meta:A}=o(w?``:S),j=E?.action??O.data?.actions.find(e=>e.key===T)??A?.action_items?.find(e=>e.key===T),M=O.data?.display_name??(w?v(w)?`${y(w)}…`:`#${w}`:void 0),N=_({resource:S,id:w,name:O.data?.display_name}),P=x(k??A,S),F=w?`/${S}/${w}`:`/${S}`;i(j?.label);let I=!j&&(w?!O.isPending:!!A);return O.error||I?(0,C.jsx)(u,{error:O.error??Error(`That action is not available`),label:`this action`,backTo:{to:F,label:`Back to ${P}`}}):(0,C.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,C.jsx)(g,{children:(0,C.jsxs)(f,{children:[(0,C.jsx)(p,{children:(0,C.jsx)(h,{asChild:!0,children:(0,C.jsx)(n,{to:`/${S}`,children:P})})}),(0,C.jsx)(m,{}),M&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p,{children:(0,C.jsx)(h,{asChild:!0,children:(0,C.jsx)(n,{to:F,children:M})})}),(0,C.jsx)(m,{})]}),(0,C.jsx)(p,{children:(0,C.jsx)(d,{children:j?.label??T})})]})}),(0,C.jsx)(c,{title:j?.label??(0,C.jsx)(s,{className:`h-8 w-64`})}),j?(0,C.jsx)(b,{action:j,resource:S,id:w,container:`page`,onClose:()=>D(F),onResult:e=>{N(j,e),e.location||D(F)}}):(0,C.jsx)(s,{className:`h-40 w-full max-w-3xl`})]})}export{w as ActionPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{n as r}from"./vendor-query-DZ6APRNI.js";import{n as i}from"./dist-IW4yX942.js";import{Ct as a,bt as o,d as s,f as c,h as l,m as u,u as d,xt as f}from"./index-B51aUaAY.js";import{t as p}from"./FormSkeleton-DuSBZO3C.js";import{t as m}from"./button-CvZ4_DFC.js";import{a as h,i as g,n as _,r as v,t as y}from"./sheet-BPl2n-4n.js";import{t as b}from"./FormDialog-pmYl8Eov.js";import{n as x,t as S}from"./query-CCsZN2fa.js";import{i as C,r as w,t as T}from"./useRecordForm-X_DExEP2.js";import{B as E,F as D,H as O,O as k,R as A,k as j,n as M,z as N}from"./Node-SQl61V4K.js";import{n as P,r as F,t as I}from"./FrameView-zmUeDO8d.js";var L=e(t(),1),R={},z=n(),B=e=>`form`in e&&`action`in e,V=e=>`form`in e,H=e=>t=>D(e,t);function U({nodes:e,ctx:t}){return(0,z.jsx)(A.Provider,{value:t,children:(0,z.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,z.jsx)(M,{nodes:e})})})}function W({response:e,label:t,classicHref:n,ctx:r,onResult:i,onClose:a}){let o=T(e,{classicHref:n}),{setSearch:s}=O(),c=e.action.method===`get`?o.submit(async e=>s(S(e)),()=>{}):o.submit(H(e),i),l=(0,z.jsx)(w,{form:o,onSubmit:c,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,z.jsx)(m,{type:`button`,variant:`outline`,onClick:a,children:`Cancel`}),(0,z.jsx)(C,{form:o,label:t,pendingLabel:`Working…`})]})});return e.layout?(0,z.jsx)(N.Provider,{value:l,children:(0,z.jsx)(U,{nodes:e.layout,ctx:r})}):l}var G=e=>e instanceof o&&e.status===501&&e.code===`unsupported`;function K({action:e,path:t,container:n,resource:o,id:m,onResult:h,onClose:g,onUnsupported:_}){let v=O(),[y,S]=(0,L.useState)(``),C=n===`page`?v:{search:y,setSearch:S},{data:w,error:T,dataUpdatedAt:D,isFetching:k,isPlaceholderData:A}=r({queryKey:[`/admin/${o??`_`}/action-form`,t,C.search],queryFn:()=>f(x(t,C.search)),placeholderData:(e,n)=>n?.queryKey[1]===t?e:void 0,gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),[j,M]=(0,L.useState)(D);!A&&j!==D&&M(D);let[N,P]=(0,L.useState)(),F=(0,L.useEffectEvent)(e=>{if(_&&G(e))return _(C.search);i.error(a(e)),g()});(0,L.useEffect)(()=>{T&&F(T)},[T]);let I=N?.at===j?N:void 0,R=I?.response??w,K=`${j}-${I?.count??0}`,q=e=>B(e)?P({response:e,at:j,count:(I?.count??0)+1}):h(e),J=e.href??void 0,Y={resource:o,id:m},X=R&&V(R)&&R.submit_label||e.label,Z=R&&(V(R)?(0,z.jsx)(W,{response:R,label:X,classicHref:J,ctx:Y,onResult:q,onClose:g},K):(0,z.jsx)(U,{nodes:R.layout,ctx:Y})),Q=e=>(0,z.jsx)(E,{value:C,children:e});return n===`page`?Q(Z?(0,z.jsx)(`div`,{"aria-busy":k,className:`contents`,children:Z}):(0,z.jsx)(p,{})):R?!V(R)||R.layout||R.action.method===`get`?Q((0,z.jsx)(d,{open:!0,onOpenChange:e=>!e&&g(),children:(0,z.jsxs)(s,{"aria-busy":k,className:`max-h-[90dvh] gap-4 overflow-y-auto sm:max-w-5xl`,children:[(0,z.jsxs)(u,{children:[(0,z.jsx)(l,{children:R.title||e.label}),(0,z.jsx)(c,{className:`sr-only`,children:R.title||e.label})]}),Z]})})):(0,z.jsx)(b,{open:!0,response:R,submitLabel:X,send:H(R),onDone:q,onClose:g,classicHref:J},K):null}function q({action:e,mode:t,path:n,container:r,onClose:i}){let a=r!==`page`;return t===`iframe`?n?(0,z.jsx)(F,{src:n,title:e.label,bare:a,onLeave:i}):null:(0,z.jsx)(P,{src:n,title:e.label,children:(0,z.jsx)(I,{src:n,title:e.label,bare:a,autoFocus:!0,onLeave:i})})}function J(e){let{action:t,container:n,onClose:r}=e,[i,a]=(0,L.useState)();if(i===void 0||!t.href)return(0,z.jsx)(K,{...e,onUnsupported:t.href?e=>a(x(t.href,e)):void 0});let o=j(t)!==`dialog`,s=(0,z.jsx)(q,{action:t,mode:k(t),path:i,container:n===`page`?`page`:o?`sheet`:`dialog`,onClose:r});return n===`page`?s:(0,z.jsx)(Z,{action:t,sheet:o,onClose:r,children:s})}function Y(e){let{action:t,resource:n,id:r,container:i,onClose:a}=e,o=t.view,s=o?.path??t.href??void 0;if(!o)return null;if(o.mode===`native`&&o.path)return(0,z.jsx)(J,{...e,path:o.path},o.path);if(o.mode===`iframe`&&s)return(0,z.jsx)(q,{action:t,mode:`iframe`,path:s,container:i,onClose:a});let c=o.mode===`custom`&&o.custom_key?R[o.custom_key]:void 0;return c?(0,z.jsx)(c,{action:t,resource:n,id:r,onClose:a}):(0,z.jsx)(q,{action:t,mode:`frame`,path:s,container:i,onClose:a})}function X({action:e,ctx:t,onResult:n,onClose:r}){let i=j(e)!==`dialog`&&e.view?.mode!==`native`,a=(0,z.jsx)(Y,{action:e,...t,container:i?`sheet`:`dialog`,onResult:n,onClose:r});return e.view?.mode===`native`?a:(0,z.jsx)(Z,{action:e,sheet:i,onClose:r,children:a})}function Z({action:e,sheet:t,onClose:n,children:r}){return t?(0,z.jsx)(y,{open:!0,onOpenChange:e=>!e&&n(),children:(0,z.jsxs)(_,{side:`right`,className:`w-[min(44rem,calc(100vw-3rem))] gap-0 overflow-y-auto p-0`,children:[(0,z.jsxs)(g,{children:[(0,z.jsx)(h,{children:e.label}),(0,z.jsx)(v,{className:`sr-only`,children:e.label})]}),(0,z.jsx)(`div`,{className:`p-4`,children:r})]})}):(0,z.jsx)(d,{open:!0,onOpenChange:e=>!e&&n(),children:(0,z.jsxs)(s,{className:`max-h-[90dvh] gap-4 overflow-y-auto sm:max-w-2xl`,children:[(0,z.jsxs)(u,{children:[(0,z.jsx)(l,{children:e.label}),(0,z.jsx)(c,{className:`sr-only`,children:e.label})]}),r]})})}export{Y as ActionViewBody,X as ActionViewOverlay};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{n as r}from"./vendor-query-DZ6APRNI.js";import{n as i}from"./dist-IW4yX942.js";import{Ct as a,bt as o,d as s,f as c,h as l,m as u,u as d,xt as f}from"./index-BX4ymNYp.js";import{t as p}from"./FormSkeleton-5eT0T2pe.js";import{t as m}from"./button-CvZ4_DFC.js";import{a as h,i as g,n as _,r as v,t as y}from"./sheet-CihU0Mcq.js";import{t as b}from"./FormDialog-DzHVGQ6M.js";import{n as x,t as S}from"./query-CCsZN2fa.js";import{i as C,r as w,t as T}from"./useRecordForm-BOmRWZbo.js";import{B as E,F as D,H as O,O as k,R as A,k as j,n as M,z as N}from"./Node-BFhcTc_1.js";import{n as P,r as F,t as I}from"./FrameView-CczSy0lF.js";var L=e(t(),1),R={},z=n(),B=e=>`form`in e&&`action`in e,V=e=>`form`in e,H=e=>t=>D(e,t);function U({nodes:e,ctx:t}){return(0,z.jsx)(A.Provider,{value:t,children:(0,z.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,z.jsx)(M,{nodes:e})})})}function W({response:e,label:t,classicHref:n,ctx:r,onResult:i,onClose:a}){let o=T(e,{classicHref:n}),{setSearch:s}=O(),c=e.action.method===`get`?o.submit(async e=>s(S(e)),()=>{}):o.submit(H(e),i),l=(0,z.jsx)(w,{form:o,onSubmit:c,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,z.jsx)(m,{type:`button`,variant:`outline`,onClick:a,children:`Cancel`}),(0,z.jsx)(C,{form:o,label:t,pendingLabel:`Working…`})]})});return e.layout?(0,z.jsx)(N.Provider,{value:l,children:(0,z.jsx)(U,{nodes:e.layout,ctx:r})}):l}var G=e=>e instanceof o&&e.status===501&&e.code===`unsupported`;function K({action:e,path:t,container:n,resource:o,id:m,onResult:h,onClose:g,onUnsupported:_}){let v=O(),[y,S]=(0,L.useState)(``),C=n===`page`?v:{search:y,setSearch:S},{data:w,error:T,dataUpdatedAt:D,isFetching:k,isPlaceholderData:A}=r({queryKey:[`/admin/${o??`_`}/action-form`,t,C.search],queryFn:()=>f(x(t,C.search)),placeholderData:(e,n)=>n?.queryKey[1]===t?e:void 0,gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),[j,M]=(0,L.useState)(D);!A&&j!==D&&M(D);let[N,P]=(0,L.useState)(),F=(0,L.useEffectEvent)(e=>{if(_&&G(e))return _(C.search);i.error(a(e)),g()});(0,L.useEffect)(()=>{T&&F(T)},[T]);let I=N?.at===j?N:void 0,R=I?.response??w,K=`${j}-${I?.count??0}`,q=e=>B(e)?P({response:e,at:j,count:(I?.count??0)+1}):h(e),J=e.href??void 0,Y={resource:o,id:m},X=R&&V(R)&&R.submit_label||e.label,Z=R&&(V(R)?(0,z.jsx)(W,{response:R,label:X,classicHref:J,ctx:Y,onResult:q,onClose:g},K):(0,z.jsx)(U,{nodes:R.layout,ctx:Y})),Q=e=>(0,z.jsx)(E,{value:C,children:e});return n===`page`?Q(Z?(0,z.jsx)(`div`,{"aria-busy":k,className:`contents`,children:Z}):(0,z.jsx)(p,{})):R?!V(R)||R.layout||R.action.method===`get`?Q((0,z.jsx)(d,{open:!0,onOpenChange:e=>!e&&g(),children:(0,z.jsxs)(s,{"aria-busy":k,className:`max-h-[90dvh] gap-4 overflow-y-auto sm:max-w-5xl`,children:[(0,z.jsxs)(u,{children:[(0,z.jsx)(l,{children:R.title||e.label}),(0,z.jsx)(c,{className:`sr-only`,children:R.title||e.label})]}),Z]})})):(0,z.jsx)(b,{open:!0,response:R,submitLabel:X,send:H(R),onDone:q,onClose:g,classicHref:J},K):null}function q({action:e,mode:t,path:n,container:r,onClose:i}){let a=r!==`page`;return t===`iframe`?n?(0,z.jsx)(F,{src:n,title:e.label,bare:a,onLeave:i}):null:(0,z.jsx)(P,{src:n,title:e.label,children:(0,z.jsx)(I,{src:n,title:e.label,bare:a,autoFocus:!0,onLeave:i})})}function J(e){let{action:t,container:n,onClose:r}=e,[i,a]=(0,L.useState)();if(i===void 0||!t.href)return(0,z.jsx)(K,{...e,onUnsupported:t.href?e=>a(x(t.href,e)):void 0});let o=j(t)!==`dialog`,s=(0,z.jsx)(q,{action:t,mode:k(t),path:i,container:n===`page`?`page`:o?`sheet`:`dialog`,onClose:r});return n===`page`?s:(0,z.jsx)(Z,{action:t,sheet:o,onClose:r,children:s})}function Y(e){let{action:t,resource:n,id:r,container:i,onClose:a}=e,o=t.view,s=o?.path??t.href??void 0;if(!o)return null;if(o.mode===`native`&&o.path)return(0,z.jsx)(J,{...e,path:o.path},o.path);if(o.mode===`iframe`&&s)return(0,z.jsx)(q,{action:t,mode:`iframe`,path:s,container:i,onClose:a});let c=o.mode===`custom`&&o.custom_key?R[o.custom_key]:void 0;return c?(0,z.jsx)(c,{action:t,resource:n,id:r,onClose:a}):(0,z.jsx)(q,{action:t,mode:`frame`,path:s,container:i,onClose:a})}function X({action:e,ctx:t,onResult:n,onClose:r}){let i=j(e)!==`dialog`&&e.view?.mode!==`native`,a=(0,z.jsx)(Y,{action:e,...t,container:i?`sheet`:`dialog`,onResult:n,onClose:r});return e.view?.mode===`native`?a:(0,z.jsx)(Z,{action:e,sheet:i,onClose:r,children:a})}function Z({action:e,sheet:t,onClose:n,children:r}){return t?(0,z.jsx)(y,{open:!0,onOpenChange:e=>!e&&n(),children:(0,z.jsxs)(_,{side:`right`,className:`w-[min(44rem,calc(100vw-3rem))] gap-0 overflow-y-auto p-0`,children:[(0,z.jsxs)(g,{children:[(0,z.jsx)(h,{children:e.label}),(0,z.jsx)(v,{className:`sr-only`,children:e.label})]}),(0,z.jsx)(`div`,{className:`p-4`,children:r})]})}):(0,z.jsx)(d,{open:!0,onOpenChange:e=>!e&&n(),children:(0,z.jsxs)(s,{className:`max-h-[90dvh] gap-4 overflow-y-auto sm:max-w-2xl`,children:[(0,z.jsxs)(u,{children:[(0,z.jsx)(l,{children:e.label}),(0,z.jsx)(c,{className:`sr-only`,children:e.label})]}),r]})})}export{Y as ActionViewBody,X as ActionViewOverlay};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{r}from"./vendor-query-DZ6APRNI.js";import{t as i}from"./external-link-C2aR4slL.js";import{$ as a,G as o,H as s,M as c,N as l,R as u,U as d,V as f,W as p,bt as m,sn as h}from"./index-B51aUaAY.js";import{u as g}from"./vendor-router-CI6Vh4k_.js";import{a as _,i as v,n as y,o as b,r as x,s as S,t as C}from"./command-CMuk0oAt.js";import{n as w,t as T}from"./recent-BrzLwL0D.js";var E=e(t(),1),D=e=>Object.entries(Object.groupBy(e,e=>e.resource)).map(([e,t=[]])=>({resource:e,ids:t.map(e=>e.id)})),O=({resource:e,ids:t})=>a(e,{ids:t},{query:{staleTime:6e4,retry:!1}}),k=e=>new Map(e.flatMap(e=>e?.labels??[]).map(e=>[`${e.resource}/${e.id}`,e.display_name])),A=n(),j=5,M=e=>e instanceof m&&(e.status===403||e.status===404);function N({go:e}){let{data:t}=c(),n=(0,E.useMemo)(()=>w().slice(0,j),[]),i=(0,E.useMemo)(()=>D(n),[n]),a=r({queries:i.map(O)}),o=k(a.map(e=>e.data)),s=e=>{let t=a[i.findIndex(t=>t.resource===e.resource)];return M(t.error)||t.isSuccess&&!o.has(`${e.resource}/${e.id}`)};(0,E.useEffect)(()=>{n.filter(s).forEach(T)},[a,n]);let l=n.filter(e=>!s(e));return l.length===0?null:(0,A.jsx)(v,{heading:`Recent records`,children:l.map(n=>{let r=o.get(`${n.resource}/${n.id}`),i=t?.resources.find(e=>e.key===n.resource)?.label??n.resource;return r?(0,A.jsx)(b,{value:`${i} ${r} ${n.id}`,onSelect:()=>e(`/${n.resource}/${n.id}`),children:(0,A.jsxs)(`span`,{children:[(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[i,` / `]}),r]})},`${n.resource}/${n.id}`):(0,A.jsx)(`div`,{"aria-hidden":!0,className:`flex h-8 items-center px-2`,children:(0,A.jsx)(u,{className:`h-4 w-48`})},`${n.resource}/${n.id}`)})})}function P({items:e,open:t,onOpenChange:n}){let r=g(),a=l(),c=(0,E.useMemo)(()=>p(e),[e]),u=(0,E.useMemo)(()=>d(e),[e]),m=(e,t)=>{n(!1),e?r(e):window.open(t??``,`_blank`,`noopener,noreferrer`)},w=e=>m(o(e,a),e.url);return(0,A.jsx)(y,{open:t,onOpenChange:n,title:`Go to a page`,description:`Search every page in the menu`,children:(0,A.jsxs)(C,{children:[(0,A.jsx)(_,{placeholder:`Go to a page or recent record`}),(0,A.jsxs)(S,{children:[(0,A.jsx)(x,{children:`No pages match.`}),(0,A.jsx)(N,{go:m}),(0,A.jsx)(v,{heading:`Pages`,children:c.map(e=>{let t=!o(e,a);return(0,A.jsxs)(b,{value:`${f(e)} ${e.description??``}`,onSelect:()=>w(e),children:[(0,A.jsxs)(`span`,{children:[e.path.length>0&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.path.join(` / `),` / `]}),e.label]}),t&&(0,A.jsx)(i,{"aria-label":`Opens in a new tab`,className:`size-3.5 text-muted-foreground`})]},e.id)})}),u.length>0&&(0,A.jsx)(v,{heading:`Sections`,children:u.map(e=>(0,A.jsxs)(b,{value:`${f(e)} overview ${e.description??``}`,onSelect:()=>m(s(e.id)),children:[(0,A.jsxs)(`span`,{children:[e.path.length>0&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.path.join(` / `),` / `]}),e.label]}),(0,A.jsx)(h,{"aria-label":`Section overview`,className:`size-3.5 text-muted-foreground`})]},e.id))})]})]})})}export{P as CommandPalette};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{r}from"./vendor-query-DZ6APRNI.js";import{t as i}from"./external-link-C2aR4slL.js";import{$ as a,G as o,H as s,M as c,N as l,R as u,U as d,V as f,W as p,bt as m,sn as h}from"./index-BX4ymNYp.js";import{u as g}from"./vendor-router-CI6Vh4k_.js";import{a as _,i as v,n as y,o as b,r as x,s as S,t as C}from"./command-Cxg-I-G2.js";import{n as w,t as T}from"./recent-BrzLwL0D.js";var E=e(t(),1),D=e=>Object.entries(Object.groupBy(e,e=>e.resource)).map(([e,t=[]])=>({resource:e,ids:t.map(e=>e.id)})),O=({resource:e,ids:t})=>a(e,{ids:t},{query:{staleTime:6e4,retry:!1}}),k=e=>new Map(e.flatMap(e=>e?.labels??[]).map(e=>[`${e.resource}/${e.id}`,e.display_name])),A=n(),j=5,M=e=>e instanceof m&&(e.status===403||e.status===404);function N({go:e}){let{data:t}=c(),n=(0,E.useMemo)(()=>w().slice(0,j),[]),i=(0,E.useMemo)(()=>D(n),[n]),a=r({queries:i.map(O)}),o=k(a.map(e=>e.data)),s=e=>{let t=a[i.findIndex(t=>t.resource===e.resource)];return M(t.error)||t.isSuccess&&!o.has(`${e.resource}/${e.id}`)};(0,E.useEffect)(()=>{n.filter(s).forEach(T)},[a,n]);let l=n.filter(e=>!s(e));return l.length===0?null:(0,A.jsx)(v,{heading:`Recent records`,children:l.map(n=>{let r=o.get(`${n.resource}/${n.id}`),i=t?.resources.find(e=>e.key===n.resource)?.label??n.resource;return r?(0,A.jsx)(b,{value:`${i} ${r} ${n.id}`,onSelect:()=>e(`/${n.resource}/${n.id}`),children:(0,A.jsxs)(`span`,{children:[(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[i,` / `]}),r]})},`${n.resource}/${n.id}`):(0,A.jsx)(`div`,{"aria-hidden":!0,className:`flex h-8 items-center px-2`,children:(0,A.jsx)(u,{className:`h-4 w-48`})},`${n.resource}/${n.id}`)})})}function P({items:e,open:t,onOpenChange:n}){let r=g(),a=l(),c=(0,E.useMemo)(()=>p(e),[e]),u=(0,E.useMemo)(()=>d(e),[e]),m=(e,t)=>{n(!1),e?r(e):window.open(t??``,`_blank`,`noopener,noreferrer`)},w=e=>m(o(e,a),e.url);return(0,A.jsx)(y,{open:t,onOpenChange:n,title:`Go to a page`,description:`Search every page in the menu`,children:(0,A.jsxs)(C,{children:[(0,A.jsx)(_,{placeholder:`Go to a page or recent record`}),(0,A.jsxs)(S,{children:[(0,A.jsx)(x,{children:`No pages match.`}),(0,A.jsx)(N,{go:m}),(0,A.jsx)(v,{heading:`Pages`,children:c.map(e=>{let t=!o(e,a);return(0,A.jsxs)(b,{value:`${f(e)} ${e.description??``}`,onSelect:()=>w(e),children:[(0,A.jsxs)(`span`,{children:[e.path.length>0&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.path.join(` / `),` / `]}),e.label]}),t&&(0,A.jsx)(i,{"aria-label":`Opens in a new tab`,className:`size-3.5 text-muted-foreground`})]},e.id)})}),u.length>0&&(0,A.jsx)(v,{heading:`Sections`,children:u.map(e=>(0,A.jsxs)(b,{value:`${f(e)} overview ${e.description??``}`,onSelect:()=>m(s(e.id)),children:[(0,A.jsxs)(`span`,{children:[e.path.length>0&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.path.join(` / `),` / `]}),e.label]}),(0,A.jsx)(h,{"aria-label":`Section overview`,className:`size-3.5 text-muted-foreground`})]},e.id))})]})]})})}export{P as CommandPalette};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{l as r,t as i}from"./button-CvZ4_DFC.js";import{U as a,W as o}from"./Node-SQl61V4K.js";import{n as s,r as c,t as l}from"./popover-CDtI9R8Q.js";import{t as u}from"./utils-DwBGbDkG.js";import{j as d,pn as f}from"./index-B51aUaAY.js";import{E as p,i as m,p as h}from"./vendor-datefns-BoC6MCnl.js";import{t as g}from"./calendar-BoyMpJIf.js";var _={name:`circle-exclamation-point`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`,`circle-alert`]};_.node;var v=r(_),y=e(t(),1),b=n(),x=`yyyy-MM-dd`;function S({value:e,onChange:t,onCommit:n,clearable:r,placeholder:_=`Select date`,min:v,max:S,className:C,"aria-required":w,...T}){let[E,D]=(0,y.useState)(!1),O=d(),k=o(e),A=e?m(e):void 0,[j,M]=[v,S].map(e=>e?m(e):void 0).map(e=>e&&p(e)?e:void 0),N=[j&&{before:j},M&&{after:M}].filter(e=>!!e),P=e=>{t(e),n?.(),D(!1)};return(0,b.jsxs)(l,{open:E,onOpenChange:D,children:[(0,b.jsx)(c,{asChild:!0,children:(0,b.jsxs)(i,{type:`button`,variant:`outline`,...T,className:u(`w-full justify-start bg-transparent font-normal aria-invalid:border-destructive sm:w-48`,C),children:[(0,b.jsx)(f,{className:`opacity-60`}),k?a(k,O):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:_})]})}),(0,b.jsxs)(s,{align:`start`,"aria-label":`Choose a date`,className:`w-auto gap-0 p-0`,children:[(0,b.jsx)(g,{mode:`single`,selected:A&&p(A)?A:void 0,defaultMonth:A,startMonth:j,endMonth:M,disabled:N,onSelect:e=>e&&P(h(e,x))}),r&&k&&(0,b.jsx)(i,{type:`button`,variant:`ghost`,size:`sm`,className:`m-1 mt-0 justify-start text-muted-foreground`,onClick:()=>P(``),children:`Clear`})]})]})}export{v as n,S as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{l as r,t as i}from"./button-CvZ4_DFC.js";import{U as a,W as o}from"./Node-BFhcTc_1.js";import{n as s,r as c,t as l}from"./popover-C_DGv69u.js";import{t as u}from"./utils-DwBGbDkG.js";import{j as d,pn as f}from"./index-BX4ymNYp.js";import{E as p,i as m,p as h}from"./vendor-datefns-BoC6MCnl.js";import{t as g}from"./calendar-C7i0aj0N.js";var _={name:`circle-exclamation-point`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`,`circle-alert`]};_.node;var v=r(_),y=e(t(),1),b=n(),x=`yyyy-MM-dd`;function S({value:e,onChange:t,onCommit:n,clearable:r,placeholder:_=`Select date`,min:v,max:S,className:C,"aria-required":w,...T}){let[E,D]=(0,y.useState)(!1),O=d(),k=o(e),A=e?m(e):void 0,[j,M]=[v,S].map(e=>e?m(e):void 0).map(e=>e&&p(e)?e:void 0),N=[j&&{before:j},M&&{after:M}].filter(e=>!!e),P=e=>{t(e),n?.(),D(!1)};return(0,b.jsxs)(l,{open:E,onOpenChange:D,children:[(0,b.jsx)(c,{asChild:!0,children:(0,b.jsxs)(i,{type:`button`,variant:`outline`,...T,className:u(`w-full justify-start bg-transparent font-normal aria-invalid:border-destructive sm:w-48`,C),children:[(0,b.jsx)(f,{className:`opacity-60`}),k?a(k,O):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:_})]})}),(0,b.jsxs)(s,{align:`start`,"aria-label":`Choose a date`,className:`w-auto gap-0 p-0`,children:[(0,b.jsx)(g,{mode:`single`,selected:A&&p(A)?A:void 0,defaultMonth:A,startMonth:j,endMonth:M,disabled:N,onSelect:e=>e&&P(h(e,x))}),r&&k&&(0,b.jsx)(i,{type:`button`,variant:`ghost`,size:`sm`,className:`m-1 mt-0 justify-start text-muted-foreground`,onClick:()=>P(``),children:`Clear`})]})]})}export{v as n,S as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./calendar-C7i0aj0N.js";import{t}from"./vendor-react-C1iE8mnY.js";var n=t();function r(t){return(0,n.jsx)(e,{...t})}export{r as DateRangeCalendar};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{st as r}from"./Node-SQl61V4K.js";import{t as i}from"./external-link-C2aR4slL.js";import{cn as a,nn as o}from"./index-B51aUaAY.js";import"./dist-IW4yX942.js";import{t as s}from"./button-CvZ4_DFC.js";import{t as c}from"./utils-DwBGbDkG.js";var l=e(t(),1),u=n(),d=e=>e.map(e=>`${e.kind}@${e.where??``}`).join(`|`),f=e=>e.charAt(0).toUpperCase()+e.slice(1)+(/[.!?]$/.test(e)?``:`.`);function p({degraded:e,classicHref:t}){let[n,p]=(0,l.useState)(),[m,h]=(0,l.useState)(!1),g=e?.length?d(e):``;if((0,l.useEffect)(()=>{},[e,g]),!e?.length||n===g)return null;let _=[...new Set(e.map(e=>f(e.reason)))];return(0,u.jsxs)(`div`,{role:`status`,"data-slot":`degraded-notice`,className:`rounded-lg border bg-muted/40 px-3 py-2 text-sm`,children:[(0,u.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,u.jsx)(a,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,u.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,u.jsx)(`p`,{className:`text-muted-foreground`,children:`Some parts of this page are shown in a simplified form.`}),t&&(0,u.jsxs)(`a`,{href:t,className:`inline-flex items-center gap-1 whitespace-nowrap underline decoration-muted-foreground/50 underline-offset-4 hover:decoration-foreground`,children:[`Open in classic admin`,(0,u.jsx)(i,{className:`size-3`,"aria-hidden":!0})]}),(0,u.jsxs)(`button`,{type:`button`,"aria-expanded":m,onClick:()=>h(!m),className:`inline-flex items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[m?`Hide details`:`What changed?`,(0,u.jsx)(r,{className:c(`size-3.5 transition-transform motion-reduce:transition-none`,m&&`rotate-180`),"aria-hidden":!0})]})]}),(0,u.jsx)(s,{variant:`ghost`,size:`icon-xs`,"aria-label":`Dismiss`,onClick:()=>p(g),children:(0,u.jsx)(o,{})})]}),m&&(0,u.jsx)(`ul`,{className:`mt-2 flex list-disc flex-col gap-1 pl-[1.625rem] text-muted-foreground marker:text-muted-foreground/60`,children:_.map(e=>(0,u.jsx)(`li`,{children:e},e))})]})}export{p as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{st as r}from"./Node-BFhcTc_1.js";import{t as i}from"./external-link-C2aR4slL.js";import{cn as a,nn as o}from"./index-BX4ymNYp.js";import"./dist-IW4yX942.js";import{t as s}from"./button-CvZ4_DFC.js";import{t as c}from"./utils-DwBGbDkG.js";var l=e(t(),1),u=n(),d=e=>e.map(e=>`${e.kind}@${e.where??``}`).join(`|`),f=e=>e.charAt(0).toUpperCase()+e.slice(1)+(/[.!?]$/.test(e)?``:`.`);function p({degraded:e,classicHref:t}){let[n,p]=(0,l.useState)(),[m,h]=(0,l.useState)(!1),g=e?.length?d(e):``;if((0,l.useEffect)(()=>{},[e,g]),!e?.length||n===g)return null;let _=[...new Set(e.map(e=>f(e.reason)))];return(0,u.jsxs)(`div`,{role:`status`,"data-slot":`degraded-notice`,className:`rounded-lg border bg-muted/40 px-3 py-2 text-sm`,children:[(0,u.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,u.jsx)(a,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,u.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,u.jsx)(`p`,{className:`text-muted-foreground`,children:`Some parts of this page are shown in a simplified form.`}),t&&(0,u.jsxs)(`a`,{href:t,className:`inline-flex items-center gap-1 whitespace-nowrap underline decoration-muted-foreground/50 underline-offset-4 hover:decoration-foreground`,children:[`Open in classic admin`,(0,u.jsx)(i,{className:`size-3`,"aria-hidden":!0})]}),(0,u.jsxs)(`button`,{type:`button`,"aria-expanded":m,onClick:()=>h(!m),className:`inline-flex items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[m?`Hide details`:`What changed?`,(0,u.jsx)(r,{className:c(`size-3.5 transition-transform motion-reduce:transition-none`,m&&`rotate-180`),"aria-hidden":!0})]})]}),(0,u.jsx)(s,{variant:`ghost`,size:`icon-xs`,"aria-label":`Dismiss`,onClick:()=>p(g),children:(0,u.jsx)(o,{})})]}),m&&(0,u.jsx)(`ul`,{className:`mt-2 flex list-disc flex-col gap-1 pl-[1.625rem] text-muted-foreground marker:text-muted-foreground/60`,children:_.map(e=>(0,u.jsx)(`li`,{children:e},e))})]})}export{p as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./button-CvZ4_DFC.js";import{d as n,f as r,h as i,m as a,p as o,u as s}from"./index-B51aUaAY.js";import{i as c,r as l,t as u}from"./useRecordForm-X_DExEP2.js";import{t as d}from"./vendor-react-C1iE8mnY.js";var f=e({FormDialog:()=>h}),p=d();function m({response:e,submitLabel:s,send:d,onDone:f,onClose:m,description:h,classicHref:g}){let _=u(e,{classicHref:g});return(0,p.jsxs)(n,{className:`max-h-[90dvh] gap-4 overflow-y-auto sm:max-w-lg`,children:[(0,p.jsxs)(a,{children:[(0,p.jsx)(i,{children:e.title}),(0,p.jsx)(r,{className:h?void 0:`sr-only`,children:h??e.title})]}),(0,p.jsx)(l,{form:_,plain:!0,onSubmit:_.submit(d,f),children:(0,p.jsxs)(o,{className:`mt-1`,children:[(0,p.jsx)(t,{type:`button`,variant:`outline`,onClick:m,children:`Cancel`}),(0,p.jsx)(c,{form:_,label:s,pendingLabel:`Working…`})]})})]})}function h(e){let{open:t,...n}=e;return(0,p.jsx)(s,{open:t,onOpenChange:t=>!t&&e.onClose(),children:t&&(0,p.jsx)(m,{...n})})}export{f as n,h as t};
1
+ import{n as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./button-CvZ4_DFC.js";import{d as n,f as r,h as i,m as a,p as o,u as s}from"./index-BX4ymNYp.js";import{i as c,r as l,t as u}from"./useRecordForm-BOmRWZbo.js";import{t as d}from"./vendor-react-C1iE8mnY.js";var f=e({FormDialog:()=>h}),p=d();function m({response:e,submitLabel:s,send:d,onDone:f,onClose:m,description:h,classicHref:g}){let _=u(e,{classicHref:g});return(0,p.jsxs)(n,{className:`max-h-[90dvh] gap-4 overflow-y-auto sm:max-w-lg`,children:[(0,p.jsxs)(a,{children:[(0,p.jsx)(i,{children:e.title}),(0,p.jsx)(r,{className:h?void 0:`sr-only`,children:h??e.title})]}),(0,p.jsx)(l,{form:_,plain:!0,onSubmit:_.submit(d,f),children:(0,p.jsxs)(o,{className:`mt-1`,children:[(0,p.jsx)(t,{type:`button`,variant:`outline`,onClick:m,children:`Cancel`}),(0,p.jsx)(c,{form:_,label:s,pendingLabel:`Working…`})]})})]})}function h(e){let{open:t,...n}=e;return(0,p.jsx)(s,{open:t,onOpenChange:t=>!t&&e.onClose(),children:t&&(0,p.jsx)(m,{...n})})}export{f as n,h as t};
@@ -1 +1 @@
1
- import{R as e}from"./index-B51aUaAY.js";import{t}from"./vendor-react-C1iE8mnY.js";var n=t();function r(){return(0,n.jsx)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":!0,children:[3,2].map((t,r)=>(0,n.jsxs)(`div`,{className:`flex flex-col gap-5 rounded-lg border bg-card p-5`,children:[(0,n.jsx)(e,{className:`h-5 w-48`}),Array.from({length:t},(t,r)=>(0,n.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-1.5`,children:[(0,n.jsx)(e,{className:`h-4 w-28`}),(0,n.jsx)(e,{className:`h-8 w-full`})]},r))]},r))})}export{r as t};
1
+ import{R as e}from"./index-BX4ymNYp.js";import{t}from"./vendor-react-C1iE8mnY.js";var n=t();function r(){return(0,n.jsx)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":!0,children:[3,2].map((t,r)=>(0,n.jsxs)(`div`,{className:`flex flex-col gap-5 rounded-lg border bg-card p-5`,children:[(0,n.jsx)(e,{className:`h-5 w-48`}),Array.from({length:t},(t,r)=>(0,n.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-1.5`,children:[(0,n.jsx)(e,{className:`h-4 w-28`}),(0,n.jsx)(e,{className:`h-8 w-full`})]},r))]},r))})}export{r as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n,t as r}from"./vendor-react-C1iE8mnY.js";import{s as i}from"./vendor-query-DZ6APRNI.js";import{u as a}from"./vendor-router-CI6Vh4k_.js";import{n as o}from"./dist-IW4yX942.js";import{l as s,t as c}from"./button-CvZ4_DFC.js";import{$ as l,A as u,L as d,M as f,N as p,P as m,Q as h,X as g,Y as _,Z as ee,et as te,it as ne,j as v,nt as re,rt as ie,tt as ae}from"./Node-SQl61V4K.js";import{n as oe,t as y}from"./DatePicker-DuaK0iMg.js";import{t as b}from"./external-link-C2aR4slL.js";import{t as x}from"./utils-DwBGbDkG.js";import{Dt as se,N as S,R as C,St as ce,_t as le,dt as w,ft as T,ht as E,lt as D,mt as O,pt as k,yt as ue}from"./index-B51aUaAY.js";import{n as de,t as fe}from"./purify-G7QKJyJq.js";var A={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};A.node;var pe=s(A),j=e(t(),1),M=`X-Reactiveadmin-Frame`,N=()=>globalThis.location?.href,P=(e={})=>({[M]:`1`,Accept:`text/html, application/json`,...e});function me({action:e,method:t,enctype:n,data:r,base:i=N()}){let a=T(e||i,i),o=!t||t.toLowerCase()===`get`;if(!a||!o&&!v(e||i,i))return;if(r.delete(`authenticity_token`),o){a.search=``;for(let[e,t]of r)typeof t==`string`&&a.searchParams.append(e,t);return{url:a.pathname+a.search,init:{method:`GET`,headers:P()}}}let s=t.toLowerCase();s!==`post`&&!r.has(`_method`)&&r.set(`_method`,s);let c=n?.toLowerCase()===`multipart/form-data`,l=c?r:new URLSearchParams([...r].map(([e,t])=>[e,typeof t==`string`?t:t.name])),u=c?{}:{"Content-Type":`application/x-www-form-urlencoded;charset=UTF-8`};return{url:a.pathname+a.search,init:{method:`POST`,headers:P(u),body:l}}}function F(e,t=`get`,n=N()){let r=T(e,n),i=t.toLowerCase();if(!r||i!==`get`&&!v(e,n))return;let a=r.pathname+r.search;if(i===`get`)return{url:a,init:{method:`GET`,headers:P()}};let o=new URLSearchParams(i===`post`?{}:{_method:i});return{url:a,init:{method:`POST`,headers:P({"Content-Type":`application/x-www-form-urlencoded;charset=UTF-8`}),body:o}}}function I(e,t=N()){let n=new URL(e,t);return n.searchParams.delete(`embed`),k(n.pathname+n.search)}var L=e=>(e??``).toLowerCase().replace(/[^a-z0-9]+/g,``),R=(e,t)=>!!L(t)&&L(e)===L(t),he=e=>/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(e??``)?.[1]?.replace(/%20/g,` `),z=r(),B=160;function V({src:e,...t}){let n=u(e);return n?(0,z.jsx)(U,{src:n,...t}):null}var H=`allow-same-origin allow-scripts allow-forms allow-modals allow-downloads allow-popups allow-popups-to-escape-sandbox`;function U({src:e,title:t,bare:n,onLeave:r}){let i=(0,j.useRef)(null),s=a(),c=S(),[l,d]=(0,j.useState)({from:e,url:e}),h=l.from===e?l.url:e,[g,_]=(0,j.useState)(480);return(0,j.useEffect)(()=>{let t=({origin:t,source:n,data:a})=>{if(!m(t)||n!==i.current?.contentWindow)return;let l=p(a);if(l?.kind===`resize`&&_(Math.max(B,l.height)),l?.kind===`flash`&&l.flashes.forEach(({level:e,message:t})=>(e===`error`?o.error:o.success)(t)),l?.kind===`navigate`){let t=f(l,c);t&&`to`in t?(r?.(),s(t.to)):t&&u(t.stay)&&d({from:e,url:t.stay})}};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[c,s,r,e]),(0,z.jsxs)(`section`,{"aria-label":t??`Embedded page`,className:x(`flex min-w-0 flex-col overflow-hidden`,!n&&`rounded-lg border bg-card`),children:[(0,z.jsx)(`iframe`,{ref:i,src:h,title:t??`Embedded page`,loading:`lazy`,referrerPolicy:`same-origin`,sandbox:H,style:{height:g},className:`block w-full border-0`}),(0,z.jsx)(`footer`,{className:x(`flex items-center justify-end text-xs text-muted-foreground`,n?`pt-2`:`border-t px-4 py-2`),children:(0,z.jsxs)(`a`,{href:I(h),className:`inline-flex items-center gap-1 underline-offset-4 hover:underline`,children:[`Open in classic admin`,(0,z.jsx)(b,{className:`size-3`,"aria-hidden":!0})]})})]})}function W({src:e,title:t,children:n}){return(0,z.jsx)(E,{where:`frame`,fallback:()=>e?(0,z.jsx)(G,{src:e,title:t}):(0,z.jsx)(d,{}),children:n})}function G({src:e,title:t}){return(0,z.jsx)(E,{where:`iframe`,fallback:()=>(0,z.jsx)(O,{href:I(e)}),children:(0,z.jsx)(V,{src:D(e),title:t})})}var ge=e(n(),1),K=`input:not([type=hidden],[type=submit],[type=button],[type=reset],[type=image]), select, textarea`,q=e=>{let t=(e.match(/[^[\]]+/g)?.at(-1)??``).replace(/_/g,` `).trim();return t.charAt(0).toUpperCase()+t.slice(1)};function J(e){for(let t of e.querySelectorAll(K)){if(t.labels?.length||t.title||t.hasAttribute(`aria-label`)||t.hasAttribute(`aria-labelledby`))continue;let e=t.getAttribute(`placeholder`)||q(t.name||t.id);e&&t.setAttribute(`aria-label`,e)}}var Y=`:is(input,select,textarea):not([type=hidden]):not([hidden])`;function _e(e){(e.querySelector(`.error ${Y}, .error [data-ra-date] button`)??e.querySelector(`${Y}, [data-ra-date] button`)??e).focus()}function X(e,t){e.value=t,e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function ve({input:e}){let[t,n]=(0,j.useState)(e.value),r=(0,j.useId)(),i=e.labels?.[0];return i&&(i.id||=`${r}-label`),(0,z.jsx)(y,{id:r,value:t,"aria-labelledby":i?`${i.id} ${r}`:void 0,"aria-label":i?void 0:`Date`,"aria-required":e.required||void 0,clearable:!e.required,onChange:t=>{n(t),X(e,t)}})}function Z({src:e,html:t,title:n,autoFocus:r,bare:s,onLeave:u}){let d=a(),f=i(),p=S(),m=(0,j.useRef)(null),v=(0,j.useRef)(!1),y=(0,j.useRef)(void 0),[E,D]=(0,j.useState)(e?[e]:[]),[O,k]=(0,j.useState)(t),[A,M]=(0,j.useState)(!1),[N,P]=(0,j.useState)(!1),[L,B]=(0,j.useState)(),[V,H]=(0,j.useState)([]),U=E.at(-1),W=new URL(U??``,globalThis.location.href).href,G=(0,j.useMemo)(()=>O==null?void 0:de(O,`frame`),[O]),K=async({url:e,init:t},n=!1)=>{let r=t.method!==`GET`,i={...t.headers,...r&&{"X-CSRF-Token":await ce()}},a=await fetch(e,{credentials:`include`,...t,headers:i});return r&&!n&&a.status===422&&a.headers.get(`content-type`)?.includes(`json`)&&(await a.clone().json().catch(()=>null))?.code===`invalid_csrf`?(se(),K({url:e,init:t},!0)):a},q=async e=>{let t=Object.assign(document.createElement(`a`),{href:URL.createObjectURL(await e.blob()),download:he(e.headers.get(`content-disposition`))??`download`});t.click(),setTimeout(()=>URL.revokeObjectURL(t.href),1e3)},Y=({redirect:e,flash:t})=>{Object.entries(t??{}).forEach(([e,t])=>/alert|error/.test(e)?o.error(t):o.success(t)),le(f);let n=ue(e)||p(e.url);if(n)return u?.(),d(n);let r=F(e.url,`get`,W);if(r&&w(T(e.url)?.pathname??``))return X(r);window.open(e.url,`_blank`,`noopener,noreferrer`)},X=async(e,t=!0)=>{P(!0);try{let n=await K(e),r=n.headers.get(`content-type`)??``;if(n.headers.get(`content-disposition`)?.startsWith(`attachment`))return await q(n);if(r.includes(`json`)){let e=await n.json().catch(()=>({}));if(e.redirect)return Y(e);throw Error(e.message??`Request failed (${n.status})`)}if(!r.includes(`html`))throw Error(`Request failed (${n.status})`);k(await n.text()),M(!1),t&&n.ok&&e.init.method===`GET`&&D(t=>[...t,e.url])}catch(e){O==null?M(!0):o.error(e instanceof Error?e.message:`Something went wrong`)}finally{P(!1)}},Z=(0,j.useEffectEvent)(e=>X(F(e,`get`,W),!1));(0,j.useEffect)(()=>{t==null&&e&&y.current!==e&&(y.current=e,M(!1),Z(e))},[e,t]),(0,j.useLayoutEffect)(()=>{let e=m.current;if(!e)return;e.querySelectorAll(`#title_bar, #page_title, .page_title`).forEach(e=>e.hidden=!0);let t=e.querySelector(`h1, h2, h3`);t&&R(t.textContent,n)&&(t.hidden=!0),J(e),H([...e.querySelectorAll(`input[${fe}="date"]`)].map(e=>{let t=Object.assign(document.createElement(`span`),{className:`ra-date`});return t.dataset.raDate=``,e.before(t),e.hidden=!0,{input:e,host:t}}))},[G,n]),(0,j.useEffect)(()=>{if(G==null)return;let e=!v.current;v.current=!0,(!e||r)&&requestAnimationFrame(()=>m.current&&_e(m.current))},[G,r]);let Q=(e,t,n,r)=>e?B({message:e,label:t,destructive:n,run:r}):r(),ye=(e,t)=>{let n=T(e,W);if(!n)return void window.open(e,`_blank`,`noopener,noreferrer`);if(t.toLowerCase()===`get`){let t=p(n.pathname+n.search);if(t)return d(t);if(!w(n.pathname))return void window.open(e,`_blank`,`noopener`)}let r=F(e,t,W);if(!r)return void o.error(`That link can't be followed from here`);X(r)},be=e=>{let t=e.target.closest(`a`),n=t?.getAttribute(`href`);!t||!n||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||n.startsWith(`#`)||/^(mailto|tel):/i.test(n)||t.hasAttribute(`download`)||(e.preventDefault(),Q(t.dataset.confirm,t.textContent?.trim()||`Continue`,t.dataset.method===`delete`,()=>ye(n,t.dataset.method??`get`)))},xe=e=>{let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let n=e.nativeEvent.submitter,r=(e,r=e)=>n?.getAttribute(`form${e}`)??t.getAttribute(r),i=me({action:r(`action`),method:r(`method`),enctype:r(`enctype`),data:new FormData(t,n),base:W});if(!i)return void o.error(`That form can't be sent from here`);Q(n?.dataset.confirm??t.dataset.confirm,n?.value||`Continue`,i.init.body instanceof URLSearchParams&&i.init.body.get(`_method`)===`delete`,()=>X(i,!1))},Se=()=>{let e=E.at(-2);e&&(D(E.slice(0,-1)),X(F(e,`get`,W),!1))},$=U&&I(U);return(0,z.jsxs)(`section`,{"aria-label":n??`Classic page`,"aria-busy":N,className:x(`flex min-w-0 flex-col`,!s&&`rounded-lg border bg-card`),children:[(0,z.jsx)(`div`,{className:x(`min-h-12`,!s&&`p-4`,N&&`opacity-60 transition-opacity`),children:A?(0,z.jsxs)(re,{variant:`destructive`,children:[(0,z.jsx)(oe,{}),(0,z.jsx)(ne,{children:`Couldn't load this page`}),(0,z.jsx)(ie,{children:(0,z.jsx)(c,{variant:`outline`,size:`sm`,className:`mt-1`,onClick:()=>U&&X(F(U,`get`,W),!1),children:`Try again`})})]}):G==null?(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-hidden":!0,children:[60,90,75].map(e=>(0,z.jsx)(C,{className:`h-5`,style:{width:`${e}%`}},e))}):(0,z.jsx)(`div`,{ref:m,tabIndex:-1,className:`ra-frame`,onClick:be,onSubmit:xe,dangerouslySetInnerHTML:{__html:G}})}),(E.length>1||$)&&(0,z.jsxs)(`footer`,{className:x(`flex items-center justify-between gap-3 text-xs text-muted-foreground`,s?`pt-2`:`border-t px-4 py-2`),children:[E.length>1?(0,z.jsxs)(c,{variant:`ghost`,size:`xs`,onClick:Se,children:[(0,z.jsx)(pe,{}),`Back`]}):(0,z.jsx)(`span`,{}),$&&(0,z.jsxs)(`a`,{href:$,className:`inline-flex items-center gap-1 underline-offset-4 hover:underline`,children:[`Open in classic admin`,(0,z.jsx)(b,{className:`size-3`,"aria-hidden":!0})]})]}),V.map(e=>(0,ge.createPortal)((0,z.jsx)(ve,{input:e.input}),e.host)),(0,z.jsx)(_,{open:!!L,onOpenChange:e=>!e&&B(void 0),children:(0,z.jsxs)(h,{children:[(0,z.jsx)(ae,{children:L?.label}),(0,z.jsx)(l,{children:L?.message}),(0,z.jsxs)(te,{children:[(0,z.jsx)(ee,{children:`Cancel`}),(0,z.jsx)(g,{variant:L?.destructive?`destructive`:`default`,onClick:()=>L?.run(),children:L?.label})]})]})})]})}export{W as n,V as r,Z as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n,t as r}from"./vendor-react-C1iE8mnY.js";import{s as i}from"./vendor-query-DZ6APRNI.js";import{u as a}from"./vendor-router-CI6Vh4k_.js";import{n as o}from"./dist-IW4yX942.js";import{l as s,t as c}from"./button-CvZ4_DFC.js";import{$ as l,A as u,L as d,M as f,N as p,P as m,Q as h,X as g,Y as _,Z as ee,et as te,it as ne,j as v,nt as re,rt as ie,tt as ae}from"./Node-BFhcTc_1.js";import{n as oe,t as y}from"./DatePicker-CgNVJIOj.js";import{t as b}from"./external-link-C2aR4slL.js";import{t as x}from"./utils-DwBGbDkG.js";import{Dt as se,N as S,R as C,St as ce,_t as le,dt as w,ft as T,ht as E,lt as D,mt as O,pt as k,yt as ue}from"./index-BX4ymNYp.js";import{n as de,t as fe}from"./purify-G7QKJyJq.js";var A={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};A.node;var pe=s(A),j=e(t(),1),M=`X-Reactiveadmin-Frame`,N=()=>globalThis.location?.href,P=(e={})=>({[M]:`1`,Accept:`text/html, application/json`,...e});function me({action:e,method:t,enctype:n,data:r,base:i=N()}){let a=T(e||i,i),o=!t||t.toLowerCase()===`get`;if(!a||!o&&!v(e||i,i))return;if(r.delete(`authenticity_token`),o){a.search=``;for(let[e,t]of r)typeof t==`string`&&a.searchParams.append(e,t);return{url:a.pathname+a.search,init:{method:`GET`,headers:P()}}}let s=t.toLowerCase();s!==`post`&&!r.has(`_method`)&&r.set(`_method`,s);let c=n?.toLowerCase()===`multipart/form-data`,l=c?r:new URLSearchParams([...r].map(([e,t])=>[e,typeof t==`string`?t:t.name])),u=c?{}:{"Content-Type":`application/x-www-form-urlencoded;charset=UTF-8`};return{url:a.pathname+a.search,init:{method:`POST`,headers:P(u),body:l}}}function F(e,t=`get`,n=N()){let r=T(e,n),i=t.toLowerCase();if(!r||i!==`get`&&!v(e,n))return;let a=r.pathname+r.search;if(i===`get`)return{url:a,init:{method:`GET`,headers:P()}};let o=new URLSearchParams(i===`post`?{}:{_method:i});return{url:a,init:{method:`POST`,headers:P({"Content-Type":`application/x-www-form-urlencoded;charset=UTF-8`}),body:o}}}function I(e,t=N()){let n=new URL(e,t);return n.searchParams.delete(`embed`),k(n.pathname+n.search)}var L=e=>(e??``).toLowerCase().replace(/[^a-z0-9]+/g,``),R=(e,t)=>!!L(t)&&L(e)===L(t),he=e=>/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(e??``)?.[1]?.replace(/%20/g,` `),z=r(),B=160;function V({src:e,...t}){let n=u(e);return n?(0,z.jsx)(U,{src:n,...t}):null}var H=`allow-same-origin allow-scripts allow-forms allow-modals allow-downloads allow-popups allow-popups-to-escape-sandbox`;function U({src:e,title:t,bare:n,onLeave:r}){let i=(0,j.useRef)(null),s=a(),c=S(),[l,d]=(0,j.useState)({from:e,url:e}),h=l.from===e?l.url:e,[g,_]=(0,j.useState)(480);return(0,j.useEffect)(()=>{let t=({origin:t,source:n,data:a})=>{if(!m(t)||n!==i.current?.contentWindow)return;let l=p(a);if(l?.kind===`resize`&&_(Math.max(B,l.height)),l?.kind===`flash`&&l.flashes.forEach(({level:e,message:t})=>(e===`error`?o.error:o.success)(t)),l?.kind===`navigate`){let t=f(l,c);t&&`to`in t?(r?.(),s(t.to)):t&&u(t.stay)&&d({from:e,url:t.stay})}};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[c,s,r,e]),(0,z.jsxs)(`section`,{"aria-label":t??`Embedded page`,className:x(`flex min-w-0 flex-col overflow-hidden`,!n&&`rounded-lg border bg-card`),children:[(0,z.jsx)(`iframe`,{ref:i,src:h,title:t??`Embedded page`,loading:`lazy`,referrerPolicy:`same-origin`,sandbox:H,style:{height:g},className:`block w-full border-0`}),(0,z.jsx)(`footer`,{className:x(`flex items-center justify-end text-xs text-muted-foreground`,n?`pt-2`:`border-t px-4 py-2`),children:(0,z.jsxs)(`a`,{href:I(h),className:`inline-flex items-center gap-1 underline-offset-4 hover:underline`,children:[`Open in classic admin`,(0,z.jsx)(b,{className:`size-3`,"aria-hidden":!0})]})})]})}function W({src:e,title:t,children:n}){return(0,z.jsx)(E,{where:`frame`,fallback:()=>e?(0,z.jsx)(G,{src:e,title:t}):(0,z.jsx)(d,{}),children:n})}function G({src:e,title:t}){return(0,z.jsx)(E,{where:`iframe`,fallback:()=>(0,z.jsx)(O,{href:I(e)}),children:(0,z.jsx)(V,{src:D(e),title:t})})}var ge=e(n(),1),K=`input:not([type=hidden],[type=submit],[type=button],[type=reset],[type=image]), select, textarea`,q=e=>{let t=(e.match(/[^[\]]+/g)?.at(-1)??``).replace(/_/g,` `).trim();return t.charAt(0).toUpperCase()+t.slice(1)};function J(e){for(let t of e.querySelectorAll(K)){if(t.labels?.length||t.title||t.hasAttribute(`aria-label`)||t.hasAttribute(`aria-labelledby`))continue;let e=t.getAttribute(`placeholder`)||q(t.name||t.id);e&&t.setAttribute(`aria-label`,e)}}var Y=`:is(input,select,textarea):not([type=hidden]):not([hidden])`;function _e(e){(e.querySelector(`.error ${Y}, .error [data-ra-date] button`)??e.querySelector(`${Y}, [data-ra-date] button`)??e).focus()}function X(e,t){e.value=t,e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function ve({input:e}){let[t,n]=(0,j.useState)(e.value),r=(0,j.useId)(),i=e.labels?.[0];return i&&(i.id||=`${r}-label`),(0,z.jsx)(y,{id:r,value:t,"aria-labelledby":i?`${i.id} ${r}`:void 0,"aria-label":i?void 0:`Date`,"aria-required":e.required||void 0,clearable:!e.required,onChange:t=>{n(t),X(e,t)}})}function Z({src:e,html:t,title:n,autoFocus:r,bare:s,onLeave:u}){let d=a(),f=i(),p=S(),m=(0,j.useRef)(null),v=(0,j.useRef)(!1),y=(0,j.useRef)(void 0),[E,D]=(0,j.useState)(e?[e]:[]),[O,k]=(0,j.useState)(t),[A,M]=(0,j.useState)(!1),[N,P]=(0,j.useState)(!1),[L,B]=(0,j.useState)(),[V,H]=(0,j.useState)([]),U=E.at(-1),W=new URL(U??``,globalThis.location.href).href,G=(0,j.useMemo)(()=>O==null?void 0:de(O,`frame`),[O]),K=async({url:e,init:t},n=!1)=>{let r=t.method!==`GET`,i={...t.headers,...r&&{"X-CSRF-Token":await ce()}},a=await fetch(e,{credentials:`include`,...t,headers:i});return r&&!n&&a.status===422&&a.headers.get(`content-type`)?.includes(`json`)&&(await a.clone().json().catch(()=>null))?.code===`invalid_csrf`?(se(),K({url:e,init:t},!0)):a},q=async e=>{let t=Object.assign(document.createElement(`a`),{href:URL.createObjectURL(await e.blob()),download:he(e.headers.get(`content-disposition`))??`download`});t.click(),setTimeout(()=>URL.revokeObjectURL(t.href),1e3)},Y=({redirect:e,flash:t})=>{Object.entries(t??{}).forEach(([e,t])=>/alert|error/.test(e)?o.error(t):o.success(t)),le(f);let n=ue(e)||p(e.url);if(n)return u?.(),d(n);let r=F(e.url,`get`,W);if(r&&w(T(e.url)?.pathname??``))return X(r);window.open(e.url,`_blank`,`noopener,noreferrer`)},X=async(e,t=!0)=>{P(!0);try{let n=await K(e),r=n.headers.get(`content-type`)??``;if(n.headers.get(`content-disposition`)?.startsWith(`attachment`))return await q(n);if(r.includes(`json`)){let e=await n.json().catch(()=>({}));if(e.redirect)return Y(e);throw Error(e.message??`Request failed (${n.status})`)}if(!r.includes(`html`))throw Error(`Request failed (${n.status})`);k(await n.text()),M(!1),t&&n.ok&&e.init.method===`GET`&&D(t=>[...t,e.url])}catch(e){O==null?M(!0):o.error(e instanceof Error?e.message:`Something went wrong`)}finally{P(!1)}},Z=(0,j.useEffectEvent)(e=>X(F(e,`get`,W),!1));(0,j.useEffect)(()=>{t==null&&e&&y.current!==e&&(y.current=e,M(!1),Z(e))},[e,t]),(0,j.useLayoutEffect)(()=>{let e=m.current;if(!e)return;e.querySelectorAll(`#title_bar, #page_title, .page_title`).forEach(e=>e.hidden=!0);let t=e.querySelector(`h1, h2, h3`);t&&R(t.textContent,n)&&(t.hidden=!0),J(e),H([...e.querySelectorAll(`input[${fe}="date"]`)].map(e=>{let t=Object.assign(document.createElement(`span`),{className:`ra-date`});return t.dataset.raDate=``,e.before(t),e.hidden=!0,{input:e,host:t}}))},[G,n]),(0,j.useEffect)(()=>{if(G==null)return;let e=!v.current;v.current=!0,(!e||r)&&requestAnimationFrame(()=>m.current&&_e(m.current))},[G,r]);let Q=(e,t,n,r)=>e?B({message:e,label:t,destructive:n,run:r}):r(),ye=(e,t)=>{let n=T(e,W);if(!n)return void window.open(e,`_blank`,`noopener,noreferrer`);if(t.toLowerCase()===`get`){let t=p(n.pathname+n.search);if(t)return d(t);if(!w(n.pathname))return void window.open(e,`_blank`,`noopener`)}let r=F(e,t,W);if(!r)return void o.error(`That link can't be followed from here`);X(r)},be=e=>{let t=e.target.closest(`a`),n=t?.getAttribute(`href`);!t||!n||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||n.startsWith(`#`)||/^(mailto|tel):/i.test(n)||t.hasAttribute(`download`)||(e.preventDefault(),Q(t.dataset.confirm,t.textContent?.trim()||`Continue`,t.dataset.method===`delete`,()=>ye(n,t.dataset.method??`get`)))},xe=e=>{let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let n=e.nativeEvent.submitter,r=(e,r=e)=>n?.getAttribute(`form${e}`)??t.getAttribute(r),i=me({action:r(`action`),method:r(`method`),enctype:r(`enctype`),data:new FormData(t,n),base:W});if(!i)return void o.error(`That form can't be sent from here`);Q(n?.dataset.confirm??t.dataset.confirm,n?.value||`Continue`,i.init.body instanceof URLSearchParams&&i.init.body.get(`_method`)===`delete`,()=>X(i,!1))},Se=()=>{let e=E.at(-2);e&&(D(E.slice(0,-1)),X(F(e,`get`,W),!1))},$=U&&I(U);return(0,z.jsxs)(`section`,{"aria-label":n??`Classic page`,"aria-busy":N,className:x(`flex min-w-0 flex-col`,!s&&`rounded-lg border bg-card`),children:[(0,z.jsx)(`div`,{className:x(`min-h-12`,!s&&`p-4`,N&&`opacity-60 transition-opacity`),children:A?(0,z.jsxs)(re,{variant:`destructive`,children:[(0,z.jsx)(oe,{}),(0,z.jsx)(ne,{children:`Couldn't load this page`}),(0,z.jsx)(ie,{children:(0,z.jsx)(c,{variant:`outline`,size:`sm`,className:`mt-1`,onClick:()=>U&&X(F(U,`get`,W),!1),children:`Try again`})})]}):G==null?(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-hidden":!0,children:[60,90,75].map(e=>(0,z.jsx)(C,{className:`h-5`,style:{width:`${e}%`}},e))}):(0,z.jsx)(`div`,{ref:m,tabIndex:-1,className:`ra-frame`,onClick:be,onSubmit:xe,dangerouslySetInnerHTML:{__html:G}})}),(E.length>1||$)&&(0,z.jsxs)(`footer`,{className:x(`flex items-center justify-between gap-3 text-xs text-muted-foreground`,s?`pt-2`:`border-t px-4 py-2`),children:[E.length>1?(0,z.jsxs)(c,{variant:`ghost`,size:`xs`,onClick:Se,children:[(0,z.jsx)(pe,{}),`Back`]}):(0,z.jsx)(`span`,{}),$&&(0,z.jsxs)(`a`,{href:$,className:`inline-flex items-center gap-1 underline-offset-4 hover:underline`,children:[`Open in classic admin`,(0,z.jsx)(b,{className:`size-3`,"aria-hidden":!0})]})]}),V.map(e=>(0,ge.createPortal)((0,z.jsx)(ve,{input:e.input}),e.host)),(0,z.jsx)(_,{open:!!L,onOpenChange:e=>!e&&B(void 0),children:(0,z.jsxs)(h,{children:[(0,z.jsx)(ae,{children:L?.label}),(0,z.jsx)(l,{children:L?.message}),(0,z.jsxs)(te,{children:[(0,z.jsx)(ee,{children:`Cancel`}),(0,z.jsx)(g,{variant:L?.destructive?`destructive`:`default`,onClick:()=>L?.run(),children:L?.label})]})]})})]})}export{W as n,V as r,Z as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{t as r}from"./external-link-C2aR4slL.js";import{A as i,B as a,G as o,H as s,J as c,K as l,M as u,N as d,O as f,R as p,X as m,bt as h,ln as g,q as _,r as v,un as y,z as b}from"./index-B51aUaAY.js";import{t as x}from"./plus-CfJ9vo8X.js";import{d as S,t as C}from"./vendor-router-CI6Vh4k_.js";import{a as w,i as T,n as E,o as D,r as O,t as k}from"./breadcrumb-DSA3Tlyd.js";var A=e(t(),1),j=n(),M=5,N=e=>e.children.length?e.children.flatMap(N):[e],P=`inline-flex h-8 shrink-0 items-center gap-1 rounded-md border px-2.5 text-sm outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring [&_svg:last-child]:size-3.5`,F=`rounded-md border px-2 py-0.5 text-xs text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`;function I({item:e,resources:t,mapUrl:n}){let i=e.children.length>0,a=i?s(e.id):o(e,n),l=e.resource?t.find(t=>t.key===e.resource):void 0,u=!!l?.permissions.create&&l.actions.includes(`new`)&&(!c(l,`new`)||!!_(l,`new`,`/new`)),d=_(l,`new`,`/new`),p=i?N(e):[],h=!a&&!!e.url;return(0,j.jsxs)(`li`,{className:`flex items-start gap-3 px-4 py-3`,children:[(0,j.jsx)(`span`,{"aria-hidden":!0,className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,j.jsx)(f,{name:e.icon,fallback:i?g:y})}),(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[a?(0,j.jsx)(C,{to:a,className:`font-semibold underline-offset-4 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring`,children:e.label}):(0,j.jsxs)(`a`,{href:e.url??void 0,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 font-semibold underline-offset-4 hover:underline`,children:[e.label,(0,j.jsx)(r,{"aria-hidden":!0,className:`size-3.5 text-muted-foreground`}),(0,j.jsx)(`span`,{className:`sr-only`,children:`(opens in a new tab)`})]}),i&&(0,j.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[p.length,` `,p.length===1?`page`:`pages`]}),h&&(0,j.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Classic admin`})]}),e.description&&(0,j.jsx)(`p`,{className:`text-muted-foreground`,children:e.description}),i&&(0,j.jsxs)(`ul`,{"aria-label":`Pages in ${e.label}`,className:`flex flex-wrap gap-1.5 pt-1`,children:[p.slice(0,M).map(e=>{let t=o(e,n);return(0,j.jsx)(`li`,{children:t?(0,j.jsx)(C,{to:t,className:F,children:e.label}):(0,j.jsx)(`a`,{href:e.url??void 0,target:`_blank`,rel:`noopener noreferrer`,className:F,children:e.label})},e.id)}),p.length>M&&(0,j.jsx)(`li`,{children:(0,j.jsxs)(C,{to:s(e.id),className:F,children:[`+`,p.length-M,` more`]})})]})]}),u&&l&&(d?(0,j.jsxs)(m,{href:d,className:P,children:[(0,j.jsx)(x,{"aria-hidden":!0,className:`size-3.5`}),`New `,l.label]}):(0,j.jsxs)(C,{to:`/${l.key}/new`,className:P,children:[(0,j.jsx)(x,{"aria-hidden":!0,className:`size-3.5`}),`New `,l.label]}))]})}function L(){let{"*":e=``}=S(),{data:t,error:n}=u(),r=d(),o=t&&a(l(t.menu),e);return i(o?.group.label),n&&!t?(0,j.jsx)(b,{error:n,label:`this section`}):t&&!o?(0,j.jsx)(b,{error:new h(404),label:`this section`,backTo:{to:`/`,label:`Back to home`}}):(0,j.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[o&&o.path.length>0&&(0,j.jsx)(k,{children:(0,j.jsxs)(T,{children:[o.path.map(e=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsx)(E,{children:(0,j.jsx)(O,{asChild:!0,children:(0,j.jsx)(C,{to:s(e.id),children:e.label})})}),(0,j.jsx)(D,{})]},e.id)),(0,j.jsx)(E,{children:(0,j.jsx)(w,{children:o.group.label})})]})}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,j.jsx)(v,{title:o?.group.label??(0,j.jsx)(p,{className:`h-8 w-48`})}),o?.group.description&&(0,j.jsx)(`p`,{className:`max-w-2xl text-base text-muted-foreground`,children:o.group.description})]}),o&&t?(0,j.jsx)(`ul`,{className:`max-w-4xl divide-y rounded-lg border bg-card`,children:o.group.children.map(e=>(0,j.jsx)(I,{item:e,resources:t.resources,mapUrl:r},e.id))}):(0,j.jsx)(`div`,{className:`flex max-w-4xl flex-col gap-3`,children:Array.from({length:4},(e,t)=>(0,j.jsx)(p,{className:`h-14 w-full`},t))})]})}export{L as GroupOverview};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{t as r}from"./external-link-C2aR4slL.js";import{A as i,B as a,G as o,H as s,J as c,K as l,M as u,N as d,O as f,R as p,X as m,bt as h,ln as g,q as _,r as v,un as y,z as b}from"./index-BX4ymNYp.js";import{t as x}from"./plus-CfJ9vo8X.js";import{d as S,t as C}from"./vendor-router-CI6Vh4k_.js";import{a as w,i as T,n as E,o as D,r as O,t as k}from"./breadcrumb-FT076GDh.js";var A=e(t(),1),j=n(),M=5,N=e=>e.children.length?e.children.flatMap(N):[e],P=`inline-flex h-8 shrink-0 items-center gap-1 rounded-md border px-2.5 text-sm outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring [&_svg:last-child]:size-3.5`,F=`rounded-md border px-2 py-0.5 text-xs text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`;function I({item:e,resources:t,mapUrl:n}){let i=e.children.length>0,a=i?s(e.id):o(e,n),l=e.resource?t.find(t=>t.key===e.resource):void 0,u=!!l?.permissions.create&&l.actions.includes(`new`)&&(!c(l,`new`)||!!_(l,`new`,`/new`)),d=_(l,`new`,`/new`),p=i?N(e):[],h=!a&&!!e.url;return(0,j.jsxs)(`li`,{className:`flex items-start gap-3 px-4 py-3`,children:[(0,j.jsx)(`span`,{"aria-hidden":!0,className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground`,children:(0,j.jsx)(f,{name:e.icon,fallback:i?g:y})}),(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[a?(0,j.jsx)(C,{to:a,className:`font-semibold underline-offset-4 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring`,children:e.label}):(0,j.jsxs)(`a`,{href:e.url??void 0,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 font-semibold underline-offset-4 hover:underline`,children:[e.label,(0,j.jsx)(r,{"aria-hidden":!0,className:`size-3.5 text-muted-foreground`}),(0,j.jsx)(`span`,{className:`sr-only`,children:`(opens in a new tab)`})]}),i&&(0,j.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[p.length,` `,p.length===1?`page`:`pages`]}),h&&(0,j.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Classic admin`})]}),e.description&&(0,j.jsx)(`p`,{className:`text-muted-foreground`,children:e.description}),i&&(0,j.jsxs)(`ul`,{"aria-label":`Pages in ${e.label}`,className:`flex flex-wrap gap-1.5 pt-1`,children:[p.slice(0,M).map(e=>{let t=o(e,n);return(0,j.jsx)(`li`,{children:t?(0,j.jsx)(C,{to:t,className:F,children:e.label}):(0,j.jsx)(`a`,{href:e.url??void 0,target:`_blank`,rel:`noopener noreferrer`,className:F,children:e.label})},e.id)}),p.length>M&&(0,j.jsx)(`li`,{children:(0,j.jsxs)(C,{to:s(e.id),className:F,children:[`+`,p.length-M,` more`]})})]})]}),u&&l&&(d?(0,j.jsxs)(m,{href:d,className:P,children:[(0,j.jsx)(x,{"aria-hidden":!0,className:`size-3.5`}),`New `,l.label]}):(0,j.jsxs)(C,{to:`/${l.key}/new`,className:P,children:[(0,j.jsx)(x,{"aria-hidden":!0,className:`size-3.5`}),`New `,l.label]}))]})}function L(){let{"*":e=``}=S(),{data:t,error:n}=u(),r=d(),o=t&&a(l(t.menu),e);return i(o?.group.label),n&&!t?(0,j.jsx)(b,{error:n,label:`this section`}):t&&!o?(0,j.jsx)(b,{error:new h(404),label:`this section`,backTo:{to:`/`,label:`Back to home`}}):(0,j.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[o&&o.path.length>0&&(0,j.jsx)(k,{children:(0,j.jsxs)(T,{children:[o.path.map(e=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsx)(E,{children:(0,j.jsx)(O,{asChild:!0,children:(0,j.jsx)(C,{to:s(e.id),children:e.label})})}),(0,j.jsx)(D,{})]},e.id)),(0,j.jsx)(E,{children:(0,j.jsx)(w,{children:o.group.label})})]})}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,j.jsx)(v,{title:o?.group.label??(0,j.jsx)(p,{className:`h-8 w-48`})}),o?.group.description&&(0,j.jsx)(`p`,{className:`max-w-2xl text-base text-muted-foreground`,children:o.group.description})]}),o&&t?(0,j.jsx)(`ul`,{className:`max-w-4xl divide-y rounded-lg border bg-card`,children:o.group.children.map(e=>(0,j.jsx)(I,{item:e,resources:t.resources,mapUrl:r},e.id))}):(0,j.jsx)(`div`,{className:`flex max-w-4xl flex-col gap-3`,children:Array.from({length:4},(e,t)=>(0,j.jsx)(p,{className:`h-14 w-full`},t))})]})}export{L as GroupOverview};
@@ -1 +1 @@
1
- import{s as e}from"./vendor-query-DZ6APRNI.js";import{l as t,u as n}from"./vendor-router-CI6Vh4k_.js";import{n as r}from"./dist-IW4yX942.js";import{t as i}from"./query-CCsZN2fa.js";import{i as a,r as o,t as s}from"./useRecordForm-X_DExEP2.js";import{F as c,H as l}from"./Node-SQl61V4K.js";import{N as u,Ot as d,_t as f,ft as p,gt as m,pt as h,yt as g}from"./index-B51aUaAY.js";import{t as _}from"./vendor-react-C1iE8mnY.js";var v=_();function y({response:_,onDone:y}){let b=s(_,{classicHref:h(`${d}/${_.resource}`)}),x=n(),{pathname:S}=t(),C=e(),w=u(),T=_.submit_label||`Submit`,E=e=>c(_,e),D=e=>{let{location:t}=e;r.success(e.message??`${T} done`),f(C);let n=t&&(g(t)||(t.url?w(t.url):void 0));!t||n===S||t.url&&p(t.url)?.pathname===`${d}/${_.resource}`||m(x,t,S,w),y()},{setSearch:O}=l(),k=_.action.method===`get`?b.submit(async e=>O(i(e)),()=>{}):b.submit(E,D);return(0,v.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[_.title&&(0,v.jsx)(`h3`,{className:`text-base font-semibold`,children:_.title}),(0,v.jsx)(o,{form:b,plain:!0,onSubmit:k,children:(0,v.jsx)(`div`,{children:(0,v.jsx)(a,{form:b,label:T,pendingLabel:`Working…`})})})]})}export{y as InlineForm};
1
+ import{s as e}from"./vendor-query-DZ6APRNI.js";import{l as t,u as n}from"./vendor-router-CI6Vh4k_.js";import{n as r}from"./dist-IW4yX942.js";import{t as i}from"./query-CCsZN2fa.js";import{i as a,r as o,t as s}from"./useRecordForm-BOmRWZbo.js";import{F as c,H as l}from"./Node-BFhcTc_1.js";import{N as u,Ot as d,_t as f,ft as p,gt as m,pt as h,yt as g}from"./index-BX4ymNYp.js";import{t as _}from"./vendor-react-C1iE8mnY.js";var v=_();function y({response:_,onDone:y}){let b=s(_,{classicHref:h(`${d}/${_.resource}`)}),x=n(),{pathname:S}=t(),C=e(),w=u(),T=_.submit_label||`Submit`,E=e=>c(_,e),D=e=>{let{location:t}=e;r.success(e.message??`${T} done`),f(C);let n=t&&(g(t)||(t.url?w(t.url):void 0));!t||n===S||t.url&&p(t.url)?.pathname===`${d}/${_.resource}`||m(x,t,S,w),y()},{setSearch:O}=l(),k=_.action.method===`get`?b.submit(async e=>O(i(e)),()=>{}):b.submit(E,D);return(0,v.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[_.title&&(0,v.jsx)(`h3`,{className:`text-base font-semibold`,children:_.title}),(0,v.jsx)(o,{form:b,plain:!0,onSubmit:k,children:(0,v.jsx)(`div`,{children:(0,v.jsx)(a,{form:b,label:T,pendingLabel:`Working…`})})})]})}export{y as InlineForm};
@@ -1,3 +1,3 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{S as r,x as i}from"./Node-SQl61V4K.js";import{t as a}from"./utils-DwBGbDkG.js";import{JsonView as o}from"./JsonView-BrJLDmSN.js";import{t as s}from"./Segmented-BE9TCbph.js";var c=e(t(),1);function l(e){let t=/^\/(.*)\/([gimyu]*)$/.exec(e.toString());if(!t)throw Error(`Invalid RegExp`);return new RegExp(t[1]??``,t[2])}function u(e){if(typeof e!=`object`)return e;if(e===null)return null;if(Array.isArray(e))return e.map(u);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return l(e);let t={};for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=u(e[n]);n===`__proto__`?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r}return t}function d(e,t){if(e.length===0)throw Error(t||`Expected a non-empty array`)}var f=e=>e[e.length-1],p=class{setResult(e){return this.result=e,this.hasResult=!0,this}exit(){return this.exiting=!0,this}push(e,t){return e.parent=this,t!==void 0&&(e.childName=t),e.root=this.root||this,e.options=e.options||this.options,this.children?(d(this.children),f(this.children).next=e,this.children.push(e)):(this.children=[e],this.nextAfterChildren=this.next||null,this.next=e),e.next=this,this}},m=class extends p{constructor(e,t){super(),this.left=e,this.right=t,this.pipe=`diff`}prepareDeltaResult(e){if(typeof e==`object`&&(this.options?.omitRemovedValues&&Array.isArray(e)&&e.length>1&&(e.length===2||e[2]===0||e[2]===3)&&(e[0]=0),this.options?.cloneDiffValues)){let t=typeof this.options?.cloneDiffValues==`function`?this.options?.cloneDiffValues:u;typeof e[0]==`object`&&(e[0]=t(e[0])),typeof e[1]==`object`&&(e[1]=t(e[1]))}return e}setResult(e){return this.prepareDeltaResult(e),super.setResult(e)}},h=class extends p{constructor(e,t){super(),this.left=e,this.delta=t,this.pipe=`patch`}},g=class extends p{constructor(e){super(),this.delta=e,this.pipe=`reverse`}},_=class{constructor(e){this.name=e,this.filters=[]}process(e){if(!this.processor)throw Error(`add this pipe to a processor before using it`);let t=this.debug,n=this.filters.length,r=e;for(let e=0;e<n;e++){let n=this.filters[e];if(n&&(t&&this.log(`filter: ${n.filterName}`),n(r),typeof r==`object`&&r.exiting)){r.exiting=!1;break}}!r.next&&this.resultCheck&&this.resultCheck(r)}log(e){console.log(`[jsondiffpatch] ${this.name} pipe, ${e}`)}append(...e){return this.filters.push(...e),this}prepend(...e){return this.filters.unshift(...e),this}indexOf(e){if(!e)throw Error(`a filter name is required`);for(let t=0;t<this.filters.length;t++)if(this.filters[t]?.filterName===e)return t;throw Error(`filter not found: ${e}`)}list(){return this.filters.map(e=>e.filterName)}after(e,...t){let n=this.indexOf(e);return this.filters.splice(n+1,0,...t),this}before(e,...t){let n=this.indexOf(e);return this.filters.splice(n,0,...t),this}replace(e,...t){let n=this.indexOf(e);return this.filters.splice(n,1,...t),this}remove(e){let t=this.indexOf(e);return this.filters.splice(t,1),this}clear(){return this.filters.length=0,this}shouldHaveResult(e){return e===!1?(this.resultCheck=null,this):(this.resultCheck||=e=>{if(!e.hasResult){console.log(e);let t=Error(`${this.name} failed`);throw t.noResult=!0,t}},this)}},v=class{constructor(e){this.selfOptions=e||{},this.pipes={}}options(e){return e&&(this.selfOptions=e),this.selfOptions}pipe(e,t){let n=t;if(typeof e==`string`){if(n===void 0)return this.pipes[e];this.pipes[e]=n}if(e&&e.name){if(n=e,n.processor===this)return n;this.pipes[n.name]=n}if(!n)throw Error(`pipe is not defined: ${e}`);return n.processor=this,n}process(e,t){let n=e;n.options=this.options();let r=t||e.pipe||`default`,i;for(;r;)n.nextAfterChildren!==void 0&&(n.next=n.nextAfterChildren,n.nextAfterChildren=null),typeof r==`string`&&(r=this.pipe(r)),r.process(n),i=r,r=null,n&&n.next&&(n=n.next,r=n.pipe||i);return n.hasResult?n.result:void 0}},y=(e,t,n,r)=>e[n]===t[r],b=(e,t,n,r)=>{let i=e.length,a=t.length,o,s,c=Array(i+1);for(o=0;o<i+1;o++){let e=Array(a+1);for(s=0;s<a+1;s++)e[s]=0;c[o]=e}for(c.match=n,o=1;o<i+1;o++){let i=c[o];if(i===void 0)throw Error(`LCS matrix row is undefined`);let l=c[o-1];if(l===void 0)throw Error(`LCS matrix row is undefined`);for(s=1;s<a+1;s++)n(e,t,o-1,s-1,r)?i[s]=(l[s-1]??0)+1:i[s]=Math.max(l[s]??0,i[s-1]??0)}return c},ee=(e,t,n,r)=>{let i=t.length,a=n.length,o={sequence:[],indices1:[],indices2:[]};for(;i!==0&&a!==0;){if(e.match===void 0)throw Error(`LCS matrix match function is undefined`);if(e.match(t,n,i-1,a-1,r))o.sequence.unshift(t[i-1]),o.indices1.unshift(i-1),o.indices2.unshift(a-1),--i,--a;else{let t=e[i];if(t===void 0)throw Error(`LCS matrix row is undefined`);let n=t[a-1];if(n===void 0)throw Error(`LCS matrix value is undefined`);let r=e[i-1];if(r===void 0)throw Error(`LCS matrix row is undefined`);let o=r[a];if(o===void 0)throw Error(`LCS matrix value is undefined`);n>o?--a:--i}}return o},te={get:(e,t,n,r)=>{let i=r||{};return ee(b(e,t,n||y,i),e,t,i)}},x=3;function ne(e,t,n,r){for(let i=0;i<n;i++){let n=e[i];for(let e=0;e<r;e++){let r=t[e];if(i!==e&&n===r)return!0}}return!1}function S(e,t,n,r,i){let a=e[n],o=t[r];if(a===o)return!0;if(typeof a!=`object`||typeof o!=`object`)return!1;let s=i.objectHash;if(!s)return i.matchByPosition&&n===r;i.hashCache1=i.hashCache1||[];let c=i.hashCache1[n];if(c===void 0&&(i.hashCache1[n]=c=s(a,n)),c===void 0)return!1;i.hashCache2=i.hashCache2||[];let l=i.hashCache2[r];return l===void 0&&(i.hashCache2[r]=l=s(o,r)),l!==void 0&&c===l}var C=function(e){if(!e.leftIsArray)return;let t={objectHash:e.options?.objectHash,matchByPosition:e.options?.matchByPosition},n=0,r=0,i,a,o,s=e.left,c=e.right,l=s.length,u=c.length,d;for(l>0&&u>0&&!t.objectHash&&typeof t.matchByPosition!=`boolean`&&(t.matchByPosition=!ne(s,c,l,u));n<l&&n<u&&S(s,c,n,n,t);)i=n,d=new m(s[i],c[i]),e.push(d,i),n++;for(;r+n<l&&r+n<u&&S(s,c,l-1-r,u-1-r,t);)a=l-1-r,o=u-1-r,d=new m(s[a],c[o]),e.push(d,o),r++;let f;if(n+r===l){if(l===u){e.setResult(void 0).exit();return}for(f||={_t:`a`},i=n;i<u-r;i++)f[i]=[c[i]],e.prepareDeltaResult(f[i]);e.setResult(f).exit();return}if(n+r===u){for(f||={_t:`a`},i=n;i<l-r;i++){let t=`_${i}`;f[t]=[s[i],0,0],e.prepareDeltaResult(f[t])}e.setResult(f).exit();return}t.hashCache1=void 0,t.hashCache2=void 0;let p=s.slice(n,l-r),h=c.slice(n,u-r),g=te.get(p,h,S,t),_=[];for(f||={_t:`a`},i=n;i<l-r;i++)if(g.indices1.indexOf(i-n)<0){let t=`_${i}`;f[t]=[s[i],0,0],e.prepareDeltaResult(f[t]),_.push(i)}let v=!0;e.options?.arrays&&e.options.arrays.detectMove===!1&&(v=!1);let y=!1;e.options?.arrays?.includeValueOnMove&&(y=!0);let b=_.length;for(i=n;i<u-r;i++){let r=g.indices2.indexOf(i-n);if(r<0){let r=!1;if(v&&b>0)for(let l=0;l<b;l++){a=_[l];let u=a===void 0?void 0:f[`_${a}`];if(a!==void 0&&u&&S(p,h,a-n,i-n,t)){u.splice(1,2,i,x),u.splice(1,2,i,x),y||(u[0]=``),o=i,d=new m(s[a],c[o]),e.push(d,o),_.splice(l,1),r=!0;break}}r||(f[i]=[c[i]],e.prepareDeltaResult(f[i]))}else{if(g.indices1[r]===void 0)throw Error(`Invalid indexOnArray2: ${r}, seq.indices1: ${g.indices1}`);if(a=g.indices1[r]+n,g.indices2[r]===void 0)throw Error(`Invalid indexOnArray2: ${r}, seq.indices2: ${g.indices2}`);o=g.indices2[r]+n,d=new m(s[a],c[o]),e.push(d,o)}}e.setResult(f).exit()};C.filterName=`arrays`;var w={numerically(e,t){return e-t},numericallyBy(e){return(t,n)=>t[e]-n[e]}},T=function(e){if(!e.nested)return;let t=e.delta;if(t._t!==`a`)return;let n,r,i=t,a=e.left,o=[],s=[],c=[];for(n in i)if(n!==`_t`){if(n[0]===`_`){let e=n;if(i[e]!==void 0&&(i[e][2]===0||i[e][2]===x))o.push(Number.parseInt(n.slice(1),10));else throw Error(`only removal or move can be applied at original array indices, invalid diff type: ${i[e]?.[2]}`)}else{let e=n;i[e].length===1?s.push({index:Number.parseInt(e,10),value:i[e][0]}):c.push({index:Number.parseInt(e,10),delta:i[e]})}}for(o=o.sort(w.numerically),n=o.length-1;n>=0;n--){if(r=o[n],r===void 0)continue;let e=i[`_${r}`],t=a.splice(r,1)[0];e?.[2]===x&&s.push({index:e[1],value:t})}s=s.sort(w.numericallyBy(`index`));let l=s.length;for(n=0;n<l;n++){let e=s[n];e!==void 0&&a.splice(e.index,0,e.value)}let u=c.length;if(u>0)for(n=0;n<u;n++){let t=c[n];if(t===void 0)continue;let r=new h(a[t.index],t.delta);e.push(r,t.index)}e.children?e.exit():e.setResult(a).exit()};T.filterName=`arrays`;var E=function(e){if(!e||!e.children||e.delta._t!==`a`)return;let t=e.left,n=e.children.length;for(let r=0;r<n;r++){let n=e.children[r];if(n===void 0)continue;let i=n.childName;t[i]=n.result}e.setResult(t).exit()};E.filterName=`arraysCollectChildren`;var D=function(e){if(!e.nested){let t=e.delta;if(t[2]===x){let n=t;e.newName=`_${n[1]}`,e.setResult([n[0],Number.parseInt(e.childName.substring(1),10),x]).exit()}return}let t=e.delta;if(t._t!==`a`)return;let n=t;for(let t in n){if(t===`_t`)continue;let r=new g(n[t]);e.push(r,t)}e.exit()};D.filterName=`arrays`;var re=(e,t,n)=>{if(typeof t==`string`&&t[0]===`_`)return Number.parseInt(t.substring(1),10);if(Array.isArray(n)&&n[2]===0)return`_${t}`;let r=+t;for(let n in e){let i=e[n];if(Array.isArray(i)){if(i[2]===x){let e=Number.parseInt(n.substring(1),10),a=i[1];if(a===+t)return e;e<=r&&a>r?r++:e>=r&&a<r&&r--}else i[2]===0?Number.parseInt(n.substring(1),10)<=r&&r++:i.length===1&&Number.parseInt(n,10)<=r&&r--}}return r},O=e=>{if(!e||!e.children)return;let t=e.delta;if(t._t!==`a`)return;let n=t,r=e.children.length,i={_t:`a`};for(let t=0;t<r;t++){let r=e.children[t];if(r===void 0)continue;let a=r.newName;if(a===void 0){if(r.childName===void 0)throw Error(`child.childName is undefined`);a=re(n,r.childName,r.result)}i[a]!==r.result&&(i[a]=r.result)}e.setResult(i).exit()};O.filterName=`arraysCollectChildren`;var k=function(e){e.left instanceof Date?(e.right instanceof Date&&e.left.getTime()===e.right.getTime()?e.setResult(void 0):e.setResult([e.left,e.right]),e.exit()):e.right instanceof Date&&e.setResult([e.left,e.right]).exit()};k.filterName=`dates`;var A=new Set([`__proto__`]),j=e=>{if(!e||!e.children)return;let t=e.children.length,n=e.result;for(let r=0;r<t;r++){let t=e.children[r];if(t!==void 0&&t.result!==void 0){if(n||={},t.childName===void 0)throw Error(`diff child.childName is undefined`);n[t.childName]=t.result}}n&&e.leftIsArray&&(n._t=`a`),e.setResult(n).exit()};j.filterName=`collectChildren`;var M=e=>{if(e.leftIsArray||e.leftType!==`object`)return;let t=e.left,n=e.right,r=e.options?.propertyFilter;for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||r&&!r(i,e))continue;let a=new m(t[i],n[i]);e.push(a,i)}for(let i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&(!r||r(i,e))&&t[i]===void 0){let t=new m(void 0,n[i]);e.push(t,i)}!e.children||e.children.length===0?e.setResult(void 0).exit():e.exit()};M.filterName=`objects`;var N=function(e){if(!e.nested)return;let t=e.delta;if(t._t)return;let n=t,r=!1;for(let t in n){if(A.has(t)||!Object.prototype.hasOwnProperty.call(n,t))continue;let i=e.left,a=new h(typeof i==`object`&&i&&Object.prototype.hasOwnProperty.call(i,t)?i[t]:void 0,n[t]);e.push(a,t),r=!0}r?e.exit():e.setResult(e.left).exit()};N.filterName=`objects`;var P=function(e){if(!e||!e.children||e.delta._t)return;if(e.left===null||typeof e.left!=`object`){e.setResult(e.left).exit();return}let t=e.left,n=e.children.length;for(let r=0;r<n;r++){let n=e.children[r];if(n===void 0)continue;let i=n.childName;A.has(i)||(Object.prototype.hasOwnProperty.call(e.left,i)&&n.result===void 0?delete t[i]:t[i]!==n.result&&(t[i]=n.result))}e.setResult(t).exit()};P.filterName=`collectChildren`;var F=function(e){if(!e.nested||e.delta._t)return;let t=e.delta,n=!1;for(let r in t){if(A.has(r)||!Object.prototype.hasOwnProperty.call(t,r))continue;let i=new g(t[r]);e.push(i,r),n=!0}n?e.exit():e.setResult({}).exit()};F.filterName=`objects`;var I=e=>{if(!e||!e.children||e.delta._t)return;let t=e.children.length,n={};for(let r=0;r<t;r++){let t=e.children[r];if(t===void 0)continue;let i=t.childName;A.has(i)||n[i]!==t.result&&(n[i]=t.result)}e.setResult(n).exit()};I.filterName=`collectChildren`;var L=2,ie=60,R=null;function z(e,t){if(!R){let n;if(e?.textDiff?.diffMatchPatch)n=new e.textDiff.diffMatchPatch;else{if(!t)return null;let e=Error("The diff-match-patch library was not provided. Pass the library in through the options or use the `jsondiffpatch/with-text-diffs` entry-point.");throw e.diff_match_patch_not_found=!0,e}R={diff:(e,t)=>n.patch_toText(n.patch_make(e,t)),patch:(e,t)=>{let r=n.patch_apply(n.patch_fromText(t),e);for(let e of r[1])if(!e){let e=Error(`text patch failed`);throw e.textPatchFailed=!0,e}return r[0]}}}return R}var B=function(e){if(e.leftType!==`string`)return;let t=e.left,n=e.right,r=e.options?.textDiff?.minLength||ie;if(t.length<r||n.length<r){e.setResult([t,n]).exit();return}let i=z(e.options);if(!i){e.setResult([t,n]).exit();return}let a=i.diff;e.setResult([a(t,n),0,L]).exit()};B.filterName=`texts`;var V=function(e){if(e.nested)return;let t=e.delta;if(t[2]!==L)return;let n=t,r=z(e.options,!0).patch;e.setResult(r(e.left,n[0])).exit()};V.filterName=`texts`;var ae=e=>{let t=/^@@ +-(\d+),(\d+) +\+(\d+),(\d+) +@@$/,n=e.split(`
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./vendor-react-C1iE8mnY.js";import{S as r,x as i}from"./Node-BFhcTc_1.js";import{t as a}from"./utils-DwBGbDkG.js";import{JsonView as o}from"./JsonView-WqpIBVJn.js";import{t as s}from"./Segmented-BE9TCbph.js";var c=e(t(),1);function l(e){let t=/^\/(.*)\/([gimyu]*)$/.exec(e.toString());if(!t)throw Error(`Invalid RegExp`);return new RegExp(t[1]??``,t[2])}function u(e){if(typeof e!=`object`)return e;if(e===null)return null;if(Array.isArray(e))return e.map(u);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return l(e);let t={};for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=u(e[n]);n===`__proto__`?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r}return t}function d(e,t){if(e.length===0)throw Error(t||`Expected a non-empty array`)}var f=e=>e[e.length-1],p=class{setResult(e){return this.result=e,this.hasResult=!0,this}exit(){return this.exiting=!0,this}push(e,t){return e.parent=this,t!==void 0&&(e.childName=t),e.root=this.root||this,e.options=e.options||this.options,this.children?(d(this.children),f(this.children).next=e,this.children.push(e)):(this.children=[e],this.nextAfterChildren=this.next||null,this.next=e),e.next=this,this}},m=class extends p{constructor(e,t){super(),this.left=e,this.right=t,this.pipe=`diff`}prepareDeltaResult(e){if(typeof e==`object`&&(this.options?.omitRemovedValues&&Array.isArray(e)&&e.length>1&&(e.length===2||e[2]===0||e[2]===3)&&(e[0]=0),this.options?.cloneDiffValues)){let t=typeof this.options?.cloneDiffValues==`function`?this.options?.cloneDiffValues:u;typeof e[0]==`object`&&(e[0]=t(e[0])),typeof e[1]==`object`&&(e[1]=t(e[1]))}return e}setResult(e){return this.prepareDeltaResult(e),super.setResult(e)}},h=class extends p{constructor(e,t){super(),this.left=e,this.delta=t,this.pipe=`patch`}},g=class extends p{constructor(e){super(),this.delta=e,this.pipe=`reverse`}},_=class{constructor(e){this.name=e,this.filters=[]}process(e){if(!this.processor)throw Error(`add this pipe to a processor before using it`);let t=this.debug,n=this.filters.length,r=e;for(let e=0;e<n;e++){let n=this.filters[e];if(n&&(t&&this.log(`filter: ${n.filterName}`),n(r),typeof r==`object`&&r.exiting)){r.exiting=!1;break}}!r.next&&this.resultCheck&&this.resultCheck(r)}log(e){console.log(`[jsondiffpatch] ${this.name} pipe, ${e}`)}append(...e){return this.filters.push(...e),this}prepend(...e){return this.filters.unshift(...e),this}indexOf(e){if(!e)throw Error(`a filter name is required`);for(let t=0;t<this.filters.length;t++)if(this.filters[t]?.filterName===e)return t;throw Error(`filter not found: ${e}`)}list(){return this.filters.map(e=>e.filterName)}after(e,...t){let n=this.indexOf(e);return this.filters.splice(n+1,0,...t),this}before(e,...t){let n=this.indexOf(e);return this.filters.splice(n,0,...t),this}replace(e,...t){let n=this.indexOf(e);return this.filters.splice(n,1,...t),this}remove(e){let t=this.indexOf(e);return this.filters.splice(t,1),this}clear(){return this.filters.length=0,this}shouldHaveResult(e){return e===!1?(this.resultCheck=null,this):(this.resultCheck||=e=>{if(!e.hasResult){console.log(e);let t=Error(`${this.name} failed`);throw t.noResult=!0,t}},this)}},v=class{constructor(e){this.selfOptions=e||{},this.pipes={}}options(e){return e&&(this.selfOptions=e),this.selfOptions}pipe(e,t){let n=t;if(typeof e==`string`){if(n===void 0)return this.pipes[e];this.pipes[e]=n}if(e&&e.name){if(n=e,n.processor===this)return n;this.pipes[n.name]=n}if(!n)throw Error(`pipe is not defined: ${e}`);return n.processor=this,n}process(e,t){let n=e;n.options=this.options();let r=t||e.pipe||`default`,i;for(;r;)n.nextAfterChildren!==void 0&&(n.next=n.nextAfterChildren,n.nextAfterChildren=null),typeof r==`string`&&(r=this.pipe(r)),r.process(n),i=r,r=null,n&&n.next&&(n=n.next,r=n.pipe||i);return n.hasResult?n.result:void 0}},y=(e,t,n,r)=>e[n]===t[r],b=(e,t,n,r)=>{let i=e.length,a=t.length,o,s,c=Array(i+1);for(o=0;o<i+1;o++){let e=Array(a+1);for(s=0;s<a+1;s++)e[s]=0;c[o]=e}for(c.match=n,o=1;o<i+1;o++){let i=c[o];if(i===void 0)throw Error(`LCS matrix row is undefined`);let l=c[o-1];if(l===void 0)throw Error(`LCS matrix row is undefined`);for(s=1;s<a+1;s++)n(e,t,o-1,s-1,r)?i[s]=(l[s-1]??0)+1:i[s]=Math.max(l[s]??0,i[s-1]??0)}return c},ee=(e,t,n,r)=>{let i=t.length,a=n.length,o={sequence:[],indices1:[],indices2:[]};for(;i!==0&&a!==0;){if(e.match===void 0)throw Error(`LCS matrix match function is undefined`);if(e.match(t,n,i-1,a-1,r))o.sequence.unshift(t[i-1]),o.indices1.unshift(i-1),o.indices2.unshift(a-1),--i,--a;else{let t=e[i];if(t===void 0)throw Error(`LCS matrix row is undefined`);let n=t[a-1];if(n===void 0)throw Error(`LCS matrix value is undefined`);let r=e[i-1];if(r===void 0)throw Error(`LCS matrix row is undefined`);let o=r[a];if(o===void 0)throw Error(`LCS matrix value is undefined`);n>o?--a:--i}}return o},te={get:(e,t,n,r)=>{let i=r||{};return ee(b(e,t,n||y,i),e,t,i)}},x=3;function ne(e,t,n,r){for(let i=0;i<n;i++){let n=e[i];for(let e=0;e<r;e++){let r=t[e];if(i!==e&&n===r)return!0}}return!1}function S(e,t,n,r,i){let a=e[n],o=t[r];if(a===o)return!0;if(typeof a!=`object`||typeof o!=`object`)return!1;let s=i.objectHash;if(!s)return i.matchByPosition&&n===r;i.hashCache1=i.hashCache1||[];let c=i.hashCache1[n];if(c===void 0&&(i.hashCache1[n]=c=s(a,n)),c===void 0)return!1;i.hashCache2=i.hashCache2||[];let l=i.hashCache2[r];return l===void 0&&(i.hashCache2[r]=l=s(o,r)),l!==void 0&&c===l}var C=function(e){if(!e.leftIsArray)return;let t={objectHash:e.options?.objectHash,matchByPosition:e.options?.matchByPosition},n=0,r=0,i,a,o,s=e.left,c=e.right,l=s.length,u=c.length,d;for(l>0&&u>0&&!t.objectHash&&typeof t.matchByPosition!=`boolean`&&(t.matchByPosition=!ne(s,c,l,u));n<l&&n<u&&S(s,c,n,n,t);)i=n,d=new m(s[i],c[i]),e.push(d,i),n++;for(;r+n<l&&r+n<u&&S(s,c,l-1-r,u-1-r,t);)a=l-1-r,o=u-1-r,d=new m(s[a],c[o]),e.push(d,o),r++;let f;if(n+r===l){if(l===u){e.setResult(void 0).exit();return}for(f||={_t:`a`},i=n;i<u-r;i++)f[i]=[c[i]],e.prepareDeltaResult(f[i]);e.setResult(f).exit();return}if(n+r===u){for(f||={_t:`a`},i=n;i<l-r;i++){let t=`_${i}`;f[t]=[s[i],0,0],e.prepareDeltaResult(f[t])}e.setResult(f).exit();return}t.hashCache1=void 0,t.hashCache2=void 0;let p=s.slice(n,l-r),h=c.slice(n,u-r),g=te.get(p,h,S,t),_=[];for(f||={_t:`a`},i=n;i<l-r;i++)if(g.indices1.indexOf(i-n)<0){let t=`_${i}`;f[t]=[s[i],0,0],e.prepareDeltaResult(f[t]),_.push(i)}let v=!0;e.options?.arrays&&e.options.arrays.detectMove===!1&&(v=!1);let y=!1;e.options?.arrays?.includeValueOnMove&&(y=!0);let b=_.length;for(i=n;i<u-r;i++){let r=g.indices2.indexOf(i-n);if(r<0){let r=!1;if(v&&b>0)for(let l=0;l<b;l++){a=_[l];let u=a===void 0?void 0:f[`_${a}`];if(a!==void 0&&u&&S(p,h,a-n,i-n,t)){u.splice(1,2,i,x),u.splice(1,2,i,x),y||(u[0]=``),o=i,d=new m(s[a],c[o]),e.push(d,o),_.splice(l,1),r=!0;break}}r||(f[i]=[c[i]],e.prepareDeltaResult(f[i]))}else{if(g.indices1[r]===void 0)throw Error(`Invalid indexOnArray2: ${r}, seq.indices1: ${g.indices1}`);if(a=g.indices1[r]+n,g.indices2[r]===void 0)throw Error(`Invalid indexOnArray2: ${r}, seq.indices2: ${g.indices2}`);o=g.indices2[r]+n,d=new m(s[a],c[o]),e.push(d,o)}}e.setResult(f).exit()};C.filterName=`arrays`;var w={numerically(e,t){return e-t},numericallyBy(e){return(t,n)=>t[e]-n[e]}},T=function(e){if(!e.nested)return;let t=e.delta;if(t._t!==`a`)return;let n,r,i=t,a=e.left,o=[],s=[],c=[];for(n in i)if(n!==`_t`){if(n[0]===`_`){let e=n;if(i[e]!==void 0&&(i[e][2]===0||i[e][2]===x))o.push(Number.parseInt(n.slice(1),10));else throw Error(`only removal or move can be applied at original array indices, invalid diff type: ${i[e]?.[2]}`)}else{let e=n;i[e].length===1?s.push({index:Number.parseInt(e,10),value:i[e][0]}):c.push({index:Number.parseInt(e,10),delta:i[e]})}}for(o=o.sort(w.numerically),n=o.length-1;n>=0;n--){if(r=o[n],r===void 0)continue;let e=i[`_${r}`],t=a.splice(r,1)[0];e?.[2]===x&&s.push({index:e[1],value:t})}s=s.sort(w.numericallyBy(`index`));let l=s.length;for(n=0;n<l;n++){let e=s[n];e!==void 0&&a.splice(e.index,0,e.value)}let u=c.length;if(u>0)for(n=0;n<u;n++){let t=c[n];if(t===void 0)continue;let r=new h(a[t.index],t.delta);e.push(r,t.index)}e.children?e.exit():e.setResult(a).exit()};T.filterName=`arrays`;var E=function(e){if(!e||!e.children||e.delta._t!==`a`)return;let t=e.left,n=e.children.length;for(let r=0;r<n;r++){let n=e.children[r];if(n===void 0)continue;let i=n.childName;t[i]=n.result}e.setResult(t).exit()};E.filterName=`arraysCollectChildren`;var D=function(e){if(!e.nested){let t=e.delta;if(t[2]===x){let n=t;e.newName=`_${n[1]}`,e.setResult([n[0],Number.parseInt(e.childName.substring(1),10),x]).exit()}return}let t=e.delta;if(t._t!==`a`)return;let n=t;for(let t in n){if(t===`_t`)continue;let r=new g(n[t]);e.push(r,t)}e.exit()};D.filterName=`arrays`;var re=(e,t,n)=>{if(typeof t==`string`&&t[0]===`_`)return Number.parseInt(t.substring(1),10);if(Array.isArray(n)&&n[2]===0)return`_${t}`;let r=+t;for(let n in e){let i=e[n];if(Array.isArray(i)){if(i[2]===x){let e=Number.parseInt(n.substring(1),10),a=i[1];if(a===+t)return e;e<=r&&a>r?r++:e>=r&&a<r&&r--}else i[2]===0?Number.parseInt(n.substring(1),10)<=r&&r++:i.length===1&&Number.parseInt(n,10)<=r&&r--}}return r},O=e=>{if(!e||!e.children)return;let t=e.delta;if(t._t!==`a`)return;let n=t,r=e.children.length,i={_t:`a`};for(let t=0;t<r;t++){let r=e.children[t];if(r===void 0)continue;let a=r.newName;if(a===void 0){if(r.childName===void 0)throw Error(`child.childName is undefined`);a=re(n,r.childName,r.result)}i[a]!==r.result&&(i[a]=r.result)}e.setResult(i).exit()};O.filterName=`arraysCollectChildren`;var k=function(e){e.left instanceof Date?(e.right instanceof Date&&e.left.getTime()===e.right.getTime()?e.setResult(void 0):e.setResult([e.left,e.right]),e.exit()):e.right instanceof Date&&e.setResult([e.left,e.right]).exit()};k.filterName=`dates`;var A=new Set([`__proto__`]),j=e=>{if(!e||!e.children)return;let t=e.children.length,n=e.result;for(let r=0;r<t;r++){let t=e.children[r];if(t!==void 0&&t.result!==void 0){if(n||={},t.childName===void 0)throw Error(`diff child.childName is undefined`);n[t.childName]=t.result}}n&&e.leftIsArray&&(n._t=`a`),e.setResult(n).exit()};j.filterName=`collectChildren`;var M=e=>{if(e.leftIsArray||e.leftType!==`object`)return;let t=e.left,n=e.right,r=e.options?.propertyFilter;for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||r&&!r(i,e))continue;let a=new m(t[i],n[i]);e.push(a,i)}for(let i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&(!r||r(i,e))&&t[i]===void 0){let t=new m(void 0,n[i]);e.push(t,i)}!e.children||e.children.length===0?e.setResult(void 0).exit():e.exit()};M.filterName=`objects`;var N=function(e){if(!e.nested)return;let t=e.delta;if(t._t)return;let n=t,r=!1;for(let t in n){if(A.has(t)||!Object.prototype.hasOwnProperty.call(n,t))continue;let i=e.left,a=new h(typeof i==`object`&&i&&Object.prototype.hasOwnProperty.call(i,t)?i[t]:void 0,n[t]);e.push(a,t),r=!0}r?e.exit():e.setResult(e.left).exit()};N.filterName=`objects`;var P=function(e){if(!e||!e.children||e.delta._t)return;if(e.left===null||typeof e.left!=`object`){e.setResult(e.left).exit();return}let t=e.left,n=e.children.length;for(let r=0;r<n;r++){let n=e.children[r];if(n===void 0)continue;let i=n.childName;A.has(i)||(Object.prototype.hasOwnProperty.call(e.left,i)&&n.result===void 0?delete t[i]:t[i]!==n.result&&(t[i]=n.result))}e.setResult(t).exit()};P.filterName=`collectChildren`;var F=function(e){if(!e.nested||e.delta._t)return;let t=e.delta,n=!1;for(let r in t){if(A.has(r)||!Object.prototype.hasOwnProperty.call(t,r))continue;let i=new g(t[r]);e.push(i,r),n=!0}n?e.exit():e.setResult({}).exit()};F.filterName=`objects`;var I=e=>{if(!e||!e.children||e.delta._t)return;let t=e.children.length,n={};for(let r=0;r<t;r++){let t=e.children[r];if(t===void 0)continue;let i=t.childName;A.has(i)||n[i]!==t.result&&(n[i]=t.result)}e.setResult(n).exit()};I.filterName=`collectChildren`;var L=2,ie=60,R=null;function z(e,t){if(!R){let n;if(e?.textDiff?.diffMatchPatch)n=new e.textDiff.diffMatchPatch;else{if(!t)return null;let e=Error("The diff-match-patch library was not provided. Pass the library in through the options or use the `jsondiffpatch/with-text-diffs` entry-point.");throw e.diff_match_patch_not_found=!0,e}R={diff:(e,t)=>n.patch_toText(n.patch_make(e,t)),patch:(e,t)=>{let r=n.patch_apply(n.patch_fromText(t),e);for(let e of r[1])if(!e){let e=Error(`text patch failed`);throw e.textPatchFailed=!0,e}return r[0]}}}return R}var B=function(e){if(e.leftType!==`string`)return;let t=e.left,n=e.right,r=e.options?.textDiff?.minLength||ie;if(t.length<r||n.length<r){e.setResult([t,n]).exit();return}let i=z(e.options);if(!i){e.setResult([t,n]).exit();return}let a=i.diff;e.setResult([a(t,n),0,L]).exit()};B.filterName=`texts`;var V=function(e){if(e.nested)return;let t=e.delta;if(t[2]!==L)return;let n=t,r=z(e.options,!0).patch;e.setResult(r(e.left,n[0])).exit()};V.filterName=`texts`;var ae=e=>{let t=/^@@ +-(\d+),(\d+) +\+(\d+),(\d+) +@@$/,n=e.split(`
2
2
  `);for(let e=0;e<n.length;e++){let r=n[e];if(r===void 0)continue;let i=r.slice(0,1);if(i===`@`){let i=t.exec(r);if(i!==null){let t=e;n[t]=`@@ -${i[3]},${i[4]} +${i[1]},${i[2]} @@`}}else if(i===`+`){if(n[e]=`-${n[e]?.slice(1)}`,n[e-1]?.slice(0,1)===`+`){let t=n[e];n[e]=n[e-1],n[e-1]=t}}else i===`-`&&(n[e]=`+${n[e]?.slice(1)}`)}return n.join(`
3
3
  `)},H=function(e){if(e.nested)return;let t=e.delta;if(t[2]!==L)return;let n=t;e.setResult([ae(n[0]),0,L]).exit()};H.filterName=`texts`;var U=function(e){if(e.left===e.right)e.setResult(void 0).exit();else if(e.left===void 0){if(typeof e.right==`function`)throw Error(`functions are not supported`);e.setResult([e.right]).exit()}else if(e.right===void 0)e.setResult([e.left,0,0]).exit();else{if(typeof e.left==`function`||typeof e.right==`function`)throw Error(`functions are not supported`);e.leftType=e.left===null?`null`:typeof e.left,e.rightType=e.right===null?`null`:typeof e.right,e.leftType===e.rightType?e.leftType===`boolean`||e.leftType===`number`?e.setResult([e.left,e.right]).exit():(e.leftType===`object`&&(e.leftIsArray=Array.isArray(e.left)),e.rightType===`object`&&(e.rightIsArray=Array.isArray(e.right)),e.leftIsArray===e.rightIsArray?e.left instanceof RegExp&&(e.right instanceof RegExp?e.setResult([e.left.toString(),e.right.toString()]).exit():e.setResult([e.left,e.right]).exit()):e.setResult([e.left,e.right]).exit()):e.setResult([e.left,e.right]).exit()}};U.filterName=`trivial`;var W=function(e){if(e.delta===void 0){e.setResult(e.left).exit();return}if(e.nested=!Array.isArray(e.delta),e.nested)return;let t=e.delta;if(t.length===1)e.setResult(t[0]).exit();else if(t.length===2){if(e.left instanceof RegExp){let n=/^\/(.*)\/([gimyu]+)$/.exec(t[1]);if(n?.[1]){e.setResult(new RegExp(n[1],n[2])).exit();return}}e.setResult(t[1]).exit()}else t.length===3&&t[2]===0&&e.setResult(void 0).exit()};W.filterName=`trivial`;var G=function(e){if(e.delta===void 0){e.setResult(e.delta).exit();return}if(e.nested=!Array.isArray(e.delta),e.nested)return;let t=e.delta;t.length===1?e.setResult([t[0],0,0]).exit():t.length===2?e.setResult([t[1],t[0]]).exit():t.length===3&&t[2]===0&&e.setResult([t[0]]).exit()};G.filterName=`trivial`;var oe=class{constructor(e){this.processor=new v(e),this.processor.pipe(new _(`diff`).append(j,U,k,B,M,C).shouldHaveResult()),this.processor.pipe(new _(`patch`).append(P,E,W,V,N,T).shouldHaveResult()),this.processor.pipe(new _(`reverse`).append(I,O,G,H,F,D).shouldHaveResult())}options(e){return this.processor.options(e)}diff(e,t){return this.processor.process(new m(e,t))}patch(e,t){return this.processor.process(new h(e,t))}reverse(e){return this.processor.process(new g(e))}unpatch(e,t){return this.patch(e,this.reverse(t))}clone(e){return u(e)}};function se(e){return new oe(e)}var ce=se({arrays:{detectMove:!1}}),le=e=>`_t`in e&&e._t===`a`;function K(e,t,n){let r=i(t);if(Array.isArray(e)){e.length===1?n.push({path:r,op:`added`,after:e[0]}):e[2]===0?n.push({path:r,op:`removed`,before:e[0]}):n.push({path:r,op:`modified`,before:e[0],after:e[1]});return}let a=le(e);for(let[r,i]of Object.entries(e)){if(r===`_t`)continue;let e=a&&r.startsWith(`_`),o=a?Number(e?r.slice(1):r):r;K(i,[...t,o],n)}}function q(e,t,n=[]){let r=ce.diff(e,t),i=[];return r&&K(r,n,i),i}var J=e=>typeof e==`object`&&!!e;function ue(e){return Object.entries(e).flatMap(([e,[t,n]])=>{if(J(t)&&J(n)){let r=q(t,n,[e]);if(r.length)return r}let r=t==null?`added`:n==null?`removed`:`modified`;return[{path:i([e]),op:r,before:t,after:n}]})}var Y=n(),X={removed:`bg-danger-soft text-danger`,added:`bg-success-soft text-success`};function Z({value:e,absent:t}){return t?(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`—`,(0,Y.jsx)(`span`,{className:`sr-only`,children:`none`})]}):e===`[masked]`?(0,Y.jsx)(r,{}):(0,Y.jsx)(`code`,{className:`font-mono break-words whitespace-pre-wrap`,children:typeof e==`string`?JSON.stringify(e):JSON.stringify(e,null,2)})}var Q=({sign:e,label:t})=>(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`select-none`,title:t,children:e}),$=(e,t)=>t===`before`?e.op!==`added`:e.op!==`removed`;function de({rows:e}){return(0,Y.jsx)(`ul`,{className:`flex flex-col divide-y rounded-md border text-xs`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-1 p-2`,children:[(0,Y.jsx)(`code`,{className:`font-mono font-semibold`,children:e.path}),$(e,`before`)&&(0,Y.jsxs)(`div`,{className:a(`flex gap-2 rounded-sm px-2 py-1`,X.removed),children:[(0,Y.jsx)(Q,{sign:`−`,label:`Before`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Before:`}),(0,Y.jsx)(Z,{value:e.before})]}),$(e,`after`)&&(0,Y.jsxs)(`div`,{className:a(`flex gap-2 rounded-sm px-2 py-1`,X.added),children:[(0,Y.jsx)(Q,{sign:`+`,label:`After`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`After:`}),(0,Y.jsx)(Z,{value:e.after})]})]},e.path))})}function fe({rows:e}){return(0,Y.jsxs)(`div`,{role:`table`,"aria-label":`Changes`,className:`overflow-hidden rounded-md border text-xs`,children:[(0,Y.jsxs)(`div`,{role:`row`,className:`hidden bg-muted/60 font-semibold text-muted-foreground sm:grid sm:grid-cols-[minmax(7rem,14rem)_1fr_1fr]`,children:[(0,Y.jsx)(`div`,{role:`columnheader`,className:`p-2`,children:`Field`}),(0,Y.jsx)(`div`,{role:`columnheader`,className:`p-2`,children:`Before`}),(0,Y.jsx)(`div`,{role:`columnheader`,className:`p-2`,children:`After`})]}),e.map(e=>(0,Y.jsxs)(`div`,{role:`row`,className:`grid border-t first:border-t-0 sm:grid-cols-[minmax(7rem,14rem)_1fr_1fr]`,children:[(0,Y.jsx)(`code`,{role:`rowheader`,className:`p-2 font-mono font-semibold break-words`,children:e.path}),(0,Y.jsxs)(`div`,{role:`cell`,className:a(`min-w-0 p-2`,$(e,`before`)&&X.removed),children:[(0,Y.jsx)(`span`,{className:`mb-0.5 block text-[0.6875rem] uppercase text-muted-foreground sm:hidden`,children:`Before`}),(0,Y.jsx)(Z,{value:e.before,absent:!$(e,`before`)})]}),(0,Y.jsxs)(`div`,{role:`cell`,className:a(`min-w-0 p-2`,$(e,`after`)&&X.added),children:[(0,Y.jsx)(`span`,{className:`mb-0.5 block text-[0.6875rem] uppercase text-muted-foreground sm:hidden`,children:`After`}),(0,Y.jsx)(Z,{value:e.after,absent:!$(e,`after`)})]})]},e.path))]})}function pe({changes:e,before:t,after:n,mode:r=`inline`,raw:i,className:l}){let[u,d]=(0,c.useState)(r),f=(0,c.useMemo)(()=>e?ue(e):q(t,n),[e,t,n]),p=[{value:`inline`,label:`Inline`},{value:`split`,label:`Side by side`},...i===void 0?[]:[{value:`raw`,label:`JSON`}]];return(0,Y.jsxs)(`div`,{className:a(`flex min-w-0 max-w-full flex-col gap-2`,l),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f.length===0?`No changes`:`${f.length} ${f.length===1?`change`:`changes`}`}),(0,Y.jsx)(s,{label:`Diff view`,value:u,options:p,onChange:d})]}),u===`raw`?(0,Y.jsx)(o,{value:i,label:`Changes`}):f.length===0?null:u===`inline`?(0,Y.jsx)(de,{rows:f}):(0,Y.jsx)(fe,{rows:f})]})}export{pe as JsonDiff};