@ixo/editor 1.20.0 → 1.21.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.
@@ -72,46 +72,7 @@ var BlocknoteProvider = ({ children, editor, handlers, blockRequirements, editab
72
72
  const sharedProposalsRef = useRef2({});
73
73
  const [activeDrawerId, setActiveDrawerId] = useState(null);
74
74
  const [drawerContent, setDrawerContent] = useState(null);
75
- const initialDocType = editor?.getDocType?.() || "flow";
76
- console.log("[BlocknoteContext] Initial docType from editor:", initialDocType);
77
- const [docType, setDocType] = useState(initialDocType);
78
- useEffect2(() => {
79
- console.log("[BlocknoteContext] docType state updated to:", docType);
80
- }, [docType]);
81
- useEffect2(() => {
82
- if (!editor?._yRoot) {
83
- console.log("[BlocknoteContext] No editor._yRoot, skipping observer setup");
84
- return;
85
- }
86
- const updateDocType = () => {
87
- const authoritativeDocType = editor._authoritativeDocType;
88
- if (authoritativeDocType) {
89
- console.log("[BlocknoteContext] Using authoritative local docType:", authoritativeDocType);
90
- if (authoritativeDocType !== docType) {
91
- console.log("[BlocknoteContext] Setting docType to authoritative value:", authoritativeDocType);
92
- setDocType(authoritativeDocType);
93
- }
94
- return;
95
- }
96
- const newDocType = editor.getDocType?.() || "flow";
97
- console.log("[BlocknoteContext] updateDocType() called, newDocType from YMap:", newDocType, "current docType:", docType);
98
- if (newDocType !== docType) {
99
- console.log("[BlocknoteContext] docType changed from", docType, "to", newDocType, "(remote or initial change)");
100
- setDocType(newDocType);
101
- }
102
- };
103
- console.log("[BlocknoteContext] Setting up observer, calling updateDocType() initially");
104
- updateDocType();
105
- const observer = () => {
106
- console.log("[BlocknoteContext] YMap observer triggered, calling updateDocType()");
107
- updateDocType();
108
- };
109
- editor._yRoot?.observe(observer);
110
- return () => {
111
- console.log("[BlocknoteContext] Unobserving YMap");
112
- editor._yRoot?.unobserve(observer);
113
- };
114
- }, [editor, docType]);
75
+ const docType = editor?.docType || "flow";
115
76
  useEffect2(() => {
116
77
  sharedProposalsRef.current = sharedProposals;
117
78
  }, [sharedProposals]);
@@ -9930,193 +9891,2663 @@ var NotifyBlockSpec = createReactBlockSpec7(
9930
9891
  }
9931
9892
  );
9932
9893
 
9933
- // src/mantine/blocks/list/ui/ListBlocksToolbar.tsx
9934
- import React111 from "react";
9935
- import { ActionIcon as ActionIcon20, Group as Group37, Tooltip as Tooltip8 } from "@mantine/core";
9936
- import { IconChevronUp as IconChevronUp4, IconChevronDown as IconChevronDown4 } from "@tabler/icons-react";
9937
- var ListBlocksToolbar = () => {
9938
- const { broadcastCollapse } = useListBlocksUI();
9939
- return /* @__PURE__ */ React111.createElement(Group37, { gap: "xs" }, /* @__PURE__ */ React111.createElement(Tooltip8, { label: "Collapse all lists", withArrow: true }, /* @__PURE__ */ React111.createElement(ActionIcon20, { c: "dimmed", variant: "subtle", size: "sm", "aria-label": "Collapse all lists", onClick: () => broadcastCollapse("collapse") }, /* @__PURE__ */ React111.createElement(IconChevronUp4, { size: 18 }))), /* @__PURE__ */ React111.createElement(Tooltip8, { label: "Expand all lists", withArrow: true }, /* @__PURE__ */ React111.createElement(ActionIcon20, { c: "dimmed", variant: "subtle", size: "sm", "aria-label": "Expand all lists", onClick: () => broadcastCollapse("expand") }, /* @__PURE__ */ React111.createElement(IconChevronDown4, { size: 18 }))));
9894
+ // src/mantine/blocks/claim/ClaimBlockSpec.tsx
9895
+ import React119 from "react";
9896
+ import { createReactBlockSpec as createReactBlockSpec8 } from "@blocknote/react";
9897
+
9898
+ // src/mantine/blocks/claim/ClaimBlock.tsx
9899
+ import React118 from "react";
9900
+
9901
+ // src/mantine/blocks/claim/template/TemplateView.tsx
9902
+ import React114, { useMemo as useMemo20 } from "react";
9903
+ import { Card as Card24, Group as Group38, Stack as Stack84, Text as Text59, ActionIcon as ActionIcon20, Badge as Badge16 } from "@mantine/core";
9904
+
9905
+ // src/mantine/blocks/claim/template/TemplateConfig.tsx
9906
+ import React113, { useCallback as useCallback21 } from "react";
9907
+ import { Paper as Paper13, CloseButton as CloseButton8, Title as Title9 } from "@mantine/core";
9908
+
9909
+ // src/mantine/blocks/claim/template/GeneralTab.tsx
9910
+ import React112, { useEffect as useEffect20, useState as useState31, useCallback as useCallback20, useMemo as useMemo19 } from "react";
9911
+ import { Stack as Stack83, Text as Text58, TextInput as TextInput39, Textarea as Textarea22 } from "@mantine/core";
9912
+
9913
+ // src/mantine/components/CollectionSelector.tsx
9914
+ import React111, { useState as useState30, useEffect as useEffect19 } from "react";
9915
+ import { Stack as Stack82, Text as Text57, TextInput as TextInput38, Button as Button28, Group as Group37, Checkbox as Checkbox10, Loader as Loader7, Alert as Alert12 } from "@mantine/core";
9916
+ var CollectionSelector = ({
9917
+ did,
9918
+ selectedCollections,
9919
+ onDidChange,
9920
+ onCollectionsChange,
9921
+ onAdminAddressChange,
9922
+ currentAdminAddress
9923
+ }) => {
9924
+ console.log("[CollectionSelector] Rendered with selectedCollections:", selectedCollections);
9925
+ const handlers = useBlocknoteHandlers();
9926
+ const [localDid, setLocalDid] = useState30(did || "");
9927
+ const [collections, setCollections] = useState30([]);
9928
+ const [loading, setLoading] = useState30(false);
9929
+ const [error, setError] = useState30(null);
9930
+ useEffect19(() => {
9931
+ setLocalDid(did || "");
9932
+ }, [did]);
9933
+ const handleDidChange = (value) => {
9934
+ setLocalDid(value);
9935
+ onDidChange(value);
9936
+ };
9937
+ const handleGetCollections = async () => {
9938
+ if (!localDid.trim()) {
9939
+ setError("Please enter a DID first");
9940
+ return;
9941
+ }
9942
+ setLoading(true);
9943
+ setError(null);
9944
+ try {
9945
+ const response = await handlers.getClaimCollections({ deedDid: localDid });
9946
+ const { adminAddress, collections: fetchedCollections } = response || { adminAddress: "", collections: [] };
9947
+ setCollections(fetchedCollections || []);
9948
+ if (onAdminAddressChange && adminAddress && (!currentAdminAddress || currentAdminAddress === "")) {
9949
+ onAdminAddressChange(adminAddress);
9950
+ }
9951
+ if (!fetchedCollections || fetchedCollections.length === 0) {
9952
+ setError("No claim collections found for this DID");
9953
+ }
9954
+ } catch (err) {
9955
+ console.error("Error fetching claim collections:", err);
9956
+ setError(err instanceof Error ? err.message : "Failed to fetch claim collections");
9957
+ setCollections([]);
9958
+ } finally {
9959
+ setLoading(false);
9960
+ }
9961
+ };
9962
+ const handleToggleCollection = (collectionId) => {
9963
+ if (!collectionId) return;
9964
+ console.log("[CollectionSelector] Toggle collection:", collectionId);
9965
+ console.log("[CollectionSelector] Current selectedCollections:", selectedCollections);
9966
+ const currentSelections = selectedCollections || [];
9967
+ const newSelected = currentSelections.includes(collectionId) ? currentSelections.filter((id) => id !== collectionId) : [...currentSelections, collectionId];
9968
+ console.log("[CollectionSelector] New selectedCollections:", newSelected);
9969
+ onCollectionsChange(newSelected);
9970
+ };
9971
+ const getCollectionName = (collection) => {
9972
+ if (!collection) return "Unnamed Collection";
9973
+ return collection.protocol?.profile?.name || collection.name || "Unnamed Collection";
9974
+ };
9975
+ return /* @__PURE__ */ React111.createElement(Stack82, { gap: "lg" }, /* @__PURE__ */ React111.createElement(Stack82, { gap: "xs" }, /* @__PURE__ */ React111.createElement(Text57, { size: "sm", fw: 600 }, "DID"), /* @__PURE__ */ React111.createElement(Group37, { gap: "xs", align: "flex-start", wrap: "nowrap" }, /* @__PURE__ */ React111.createElement(
9976
+ TextInput38,
9977
+ {
9978
+ placeholder: "Enter DID",
9979
+ value: localDid,
9980
+ onChange: (event) => handleDidChange(event.currentTarget.value),
9981
+ description: "The DID identifier for fetching claim collections",
9982
+ style: { flex: 1 }
9983
+ }
9984
+ ), /* @__PURE__ */ React111.createElement(Button28, { onClick: handleGetCollections, disabled: !localDid.trim() || loading, style: { marginTop: "1px" } }, loading ? /* @__PURE__ */ React111.createElement(Loader7, { size: "xs", color: "white" }) : "Get Collections"))), error && /* @__PURE__ */ React111.createElement(Alert12, { color: "red", title: "Error" }, error), collections && collections.length > 0 && /* @__PURE__ */ React111.createElement(Stack82, { gap: "xs" }, /* @__PURE__ */ React111.createElement(Text57, { size: "sm", fw: 600 }, "Claim Collections"), /* @__PURE__ */ React111.createElement(Stack82, { gap: "sm" }, collections.map((collection) => {
9985
+ if (!collection || !collection.id) return null;
9986
+ return /* @__PURE__ */ React111.createElement(
9987
+ Checkbox10,
9988
+ {
9989
+ key: collection.id,
9990
+ label: /* @__PURE__ */ React111.createElement(Stack82, { gap: 2 }, /* @__PURE__ */ React111.createElement(Text57, { size: "sm", fw: 500 }, getCollectionName(collection)), /* @__PURE__ */ React111.createElement(Text57, { size: "xs", c: "dimmed", style: { fontFamily: "monospace" } }, "ID: ", collection.id), collection.description && /* @__PURE__ */ React111.createElement(Text57, { size: "xs", c: "dimmed" }, collection.description)),
9991
+ checked: selectedCollections?.includes(collection.id) ?? false,
9992
+ onChange: () => handleToggleCollection(collection.id)
9993
+ }
9994
+ );
9995
+ }))), selectedCollections && selectedCollections.length > 0 && /* @__PURE__ */ React111.createElement(Stack82, { gap: "xs" }, /* @__PURE__ */ React111.createElement(Text57, { size: "sm", c: "dimmed" }, selectedCollections.length, " collection", selectedCollections.length !== 1 ? "s" : "", " selected")));
9940
9996
  };
9941
9997
 
9942
- // src/mantine/blocks/registry/blockRegistry.ts
9943
- var BlockRegistry = class {
9944
- constructor() {
9945
- this.blocks = /* @__PURE__ */ new Map();
9946
- }
9947
- register(entry) {
9948
- this.blocks.set(entry.type, entry);
9949
- }
9950
- get(type) {
9951
- return this.blocks.get(type);
9952
- }
9953
- getAll() {
9954
- return new Map(this.blocks);
9955
- }
9956
- getValidDependencies(type) {
9957
- const entry = this.get(type);
9958
- return entry?.validDependencies || [];
9959
- }
9960
- getPropSchema(type) {
9961
- const entry = this.get(type);
9962
- return entry?.propSchema;
9963
- }
9964
- isValidDependency(blockType, dependencyType) {
9965
- const validDeps = this.getValidDependencies(blockType);
9966
- return validDeps.includes(dependencyType);
9967
- }
9998
+ // src/mantine/blocks/claim/template/GeneralTab.tsx
9999
+ var GeneralTab6 = ({
10000
+ title,
10001
+ description,
10002
+ deedDid,
10003
+ selectedCollections,
10004
+ adminAddress,
10005
+ onTitleChange,
10006
+ onDescriptionChange,
10007
+ onDeedDidChange,
10008
+ onSelectedCollectionsChange,
10009
+ onAdminAddressChange
10010
+ }) => {
10011
+ const [localTitle, setLocalTitle] = useState31(title || "");
10012
+ const [localDescription, setLocalDescription] = useState31(description || "");
10013
+ useEffect20(() => {
10014
+ setLocalTitle(title || "");
10015
+ }, [title]);
10016
+ useEffect20(() => {
10017
+ setLocalDescription(description || "");
10018
+ }, [description]);
10019
+ const parsedSelectedCollections = useMemo19(() => {
10020
+ try {
10021
+ return JSON.parse(selectedCollections || "[]");
10022
+ } catch {
10023
+ return [];
10024
+ }
10025
+ }, [selectedCollections]);
10026
+ const handleCollectionsChange = useCallback20(
10027
+ (collections) => {
10028
+ console.log("[Claim GeneralTab] handleCollectionsChange called with:", collections);
10029
+ const stringified = JSON.stringify(collections || []);
10030
+ console.log("[Claim GeneralTab] Stringified:", stringified);
10031
+ onSelectedCollectionsChange(stringified);
10032
+ },
10033
+ [onSelectedCollectionsChange]
10034
+ );
10035
+ const handleAdminAddressChange = useCallback20(
10036
+ (adminAddress2) => {
10037
+ if (onAdminAddressChange) {
10038
+ onAdminAddressChange(adminAddress2);
10039
+ }
10040
+ },
10041
+ [onAdminAddressChange]
10042
+ );
10043
+ return /* @__PURE__ */ React112.createElement(Stack83, { gap: "lg" }, /* @__PURE__ */ React112.createElement(Stack83, { gap: "xs" }, /* @__PURE__ */ React112.createElement(Text58, { size: "sm", fw: 600 }, "Title"), /* @__PURE__ */ React112.createElement(
10044
+ TextInput39,
10045
+ {
10046
+ placeholder: "e.g. Claim Title",
10047
+ value: localTitle,
10048
+ onChange: (event) => {
10049
+ const newTitle = event.currentTarget.value;
10050
+ setLocalTitle(newTitle);
10051
+ onTitleChange(newTitle);
10052
+ }
10053
+ }
10054
+ )), /* @__PURE__ */ React112.createElement(Stack83, { gap: "xs" }, /* @__PURE__ */ React112.createElement(Text58, { size: "sm", fw: 600 }, "Description"), /* @__PURE__ */ React112.createElement(
10055
+ Textarea22,
10056
+ {
10057
+ placeholder: "Describe what this claim is about",
10058
+ minRows: 3,
10059
+ value: localDescription,
10060
+ onChange: (event) => {
10061
+ const newDescription = event.currentTarget.value;
10062
+ setLocalDescription(newDescription);
10063
+ onDescriptionChange(newDescription);
10064
+ }
10065
+ }
10066
+ )), /* @__PURE__ */ React112.createElement(
10067
+ CollectionSelector,
10068
+ {
10069
+ did: deedDid,
10070
+ selectedCollections: parsedSelectedCollections,
10071
+ onDidChange: onDeedDidChange,
10072
+ onCollectionsChange: handleCollectionsChange,
10073
+ onAdminAddressChange: handleAdminAddressChange,
10074
+ currentAdminAddress: adminAddress
10075
+ }
10076
+ ));
9968
10077
  };
9969
- var blockRegistry = new BlockRegistry();
9970
- blockRegistry.register({
9971
- type: "proposal",
9972
- propSchema: {
9973
- title: "",
9974
- description: "",
9975
- icon: "\u{1F4DD}",
9976
- proposalId: "",
9977
- status: "draft",
9978
- contractAddress: "",
9979
- coreAddress: "",
9980
- createdProposalId: ""
9981
- },
9982
- validDependencies: [],
9983
- defaultProps: {
9984
- icon: "\u{1F4DD}",
9985
- status: "draft"
9986
- }
9987
- });
9988
- blockRegistry.register({
9989
- type: "proposalVote",
9990
- propSchema: {
9991
- title: "",
9992
- subtitle: "",
9993
- icon: "\u{1F5F3}\uFE0F",
9994
- status: "open",
9995
- daysLeft: 0,
9996
- proposalId: "",
9997
- proposalBlockId: "",
9998
- proposalContractAddress: ""
9999
- },
10000
- validDependencies: ["proposal"],
10001
- defaultProps: {
10002
- icon: "\u{1F5F3}\uFE0F",
10003
- status: "open",
10004
- daysLeft: 0,
10005
- proposalBlockId: ""
10006
- }
10007
- });
10008
- blockRegistry.register({
10009
- type: "list",
10010
- propSchema: {
10011
- title: "",
10012
- did: "",
10013
- fragmentIdentifier: ""
10014
- },
10015
- validDependencies: [],
10016
- defaultProps: {}
10017
- });
10018
- blockRegistry.register({
10019
- type: "overview",
10020
- propSchema: {
10021
- did: ""
10022
- },
10023
- validDependencies: [],
10024
- defaultProps: {}
10025
- });
10026
- blockRegistry.register({
10027
- type: "enumChecklist",
10028
- propSchema: {
10029
- listType: "",
10030
- listConfig: "{}"
10031
- },
10032
- validDependencies: [],
10033
- defaultProps: {}
10034
- });
10035
- blockRegistry.register({
10036
- type: "notify",
10037
- propSchema: {
10038
- title: "",
10039
- description: "",
10040
- icon: "bell",
10041
- channel: "email",
10042
- to: "[]",
10043
- cc: "[]",
10044
- bcc: "[]",
10045
- subject: "",
10046
- body: "",
10047
- bodyType: "text",
10048
- from: "",
10049
- replyTo: "",
10050
- templateId: "",
10051
- templateVariables: "{}",
10052
- status: "idle",
10053
- messageId: "",
10054
- sentAt: "",
10055
- errorMessage: "",
10056
- conditions: ""
10057
- },
10058
- validDependencies: [],
10059
- defaultProps: {
10060
- icon: "bell",
10061
- channel: "email",
10062
- bodyType: "text",
10063
- status: "idle"
10064
- }
10065
- });
10066
-
10067
- // src/mantine/blocks/hooks/useBlockDependencies.ts
10068
- import { useMemo as useMemo19, useEffect as useEffect19, useState as useState30, useCallback as useCallback20 } from "react";
10069
10078
 
10070
- // src/mantine/blocks/hooks/useDependsOn.ts
10071
- import { useMemo as useMemo20 } from "react";
10072
-
10073
- // src/mantine/blocks/index.ts
10074
- var blockSpecs = {
10075
- checkbox: CheckboxBlockSpec,
10076
- list: ListBlockSpec,
10077
- enumChecklist: EnumChecklistBlock,
10078
- overview: OverviewBlock,
10079
- proposal: ProposalBlockSpec,
10080
- apiRequest: ApiRequestBlockSpec,
10081
- notify: NotifyBlockSpec
10082
- };
10083
- var getExtraSlashMenuItems = (editor) => {
10084
- const slashMenuList = [
10085
- {
10086
- title: "Checkbox",
10087
- onItemClick: () => {
10088
- editor.insertBlocks(
10089
- [
10090
- {
10091
- type: "checkbox",
10092
- props: {
10093
- checked: false,
10094
- allowedCheckers: "all",
10095
- initialChecked: false,
10096
- title: "",
10097
- description: "",
10098
- visibility: "all",
10099
- dependencies: "",
10100
- conditions: ""
10101
- }
10102
- }
10103
- ],
10104
- editor.getTextCursorPosition().block,
10105
- "after"
10106
- );
10107
- },
10108
- aliases: ["checkbox", "task", "todo"],
10109
- group: "Basics",
10110
- subtext: "Add an interactive checkbox with flow permissions"
10079
+ // src/mantine/blocks/claim/template/TemplateConfig.tsx
10080
+ var TemplateConfig6 = ({ editor, block }) => {
10081
+ const { closePanel } = usePanelStore();
10082
+ const updateProp = useCallback21(
10083
+ (key, value) => {
10084
+ console.log("[Claim TemplateConfig] Updating prop:", key, value);
10085
+ editor.updateBlock(block, {
10086
+ props: {
10087
+ ...block.props,
10088
+ [key]: value
10089
+ }
10090
+ });
10111
10091
  },
10092
+ [editor, block]
10093
+ );
10094
+ return /* @__PURE__ */ React113.createElement(
10095
+ Paper13,
10112
10096
  {
10113
- title: "List",
10114
- onItemClick: () => {
10115
- editor.insertBlocks(
10116
- [
10117
- {
10118
- type: "list",
10119
- props: {
10097
+ p: "md",
10098
+ shadow: "sm",
10099
+ style: {
10100
+ height: "100%",
10101
+ display: "flex",
10102
+ flexDirection: "column"
10103
+ }
10104
+ },
10105
+ /* @__PURE__ */ React113.createElement(
10106
+ "div",
10107
+ {
10108
+ style: {
10109
+ display: "flex",
10110
+ justifyContent: "space-between",
10111
+ alignItems: "center",
10112
+ marginBottom: "1rem"
10113
+ }
10114
+ },
10115
+ /* @__PURE__ */ React113.createElement(Title9, { order: 3 }, "Claim Settings"),
10116
+ /* @__PURE__ */ React113.createElement(CloseButton8, { onClick: closePanel })
10117
+ ),
10118
+ /* @__PURE__ */ React113.createElement(
10119
+ ReusablePanel,
10120
+ {
10121
+ extraTabs: [
10122
+ {
10123
+ label: "General",
10124
+ value: "general",
10125
+ content: /* @__PURE__ */ React113.createElement(
10126
+ GeneralTab6,
10127
+ {
10128
+ title: block.props.title || "",
10129
+ description: block.props.description || "",
10130
+ deedDid: block.props.deedDid || "",
10131
+ selectedCollections: block.props.selectedCollections || "[]",
10132
+ adminAddress: block.props.adminAddress || "",
10133
+ onTitleChange: (value) => updateProp("title", value),
10134
+ onDescriptionChange: (value) => updateProp("description", value),
10135
+ onDeedDidChange: (value) => updateProp("deedDid", value),
10136
+ onSelectedCollectionsChange: (value) => updateProp("selectedCollections", value),
10137
+ onAdminAddressChange: (value) => updateProp("adminAddress", value)
10138
+ }
10139
+ )
10140
+ }
10141
+ ],
10142
+ context: { editor, block }
10143
+ }
10144
+ )
10145
+ );
10146
+ };
10147
+
10148
+ // src/mantine/blocks/claim/template/TemplateView.tsx
10149
+ var CLAIM_TEMPLATE_PANEL_ID = "claim-template-panel";
10150
+ var ClaimTemplateView = ({ editor, block }) => {
10151
+ const panelId = `${CLAIM_TEMPLATE_PANEL_ID}-${block.id}`;
10152
+ const panelContent = useMemo20(() => /* @__PURE__ */ React114.createElement(TemplateConfig6, { editor, block }), [editor, block]);
10153
+ const { open } = usePanel(panelId, panelContent);
10154
+ return /* @__PURE__ */ React114.createElement(Card24, { withBorder: true, padding: "md", radius: "md", style: { width: "100%", cursor: "pointer", position: "relative" }, onClick: open }, /* @__PURE__ */ React114.createElement(Badge16, { size: "xs", variant: "light", color: "gray", style: { position: "absolute", top: 8, right: 8 } }, "Template"), /* @__PURE__ */ React114.createElement(Group38, { wrap: "nowrap", justify: "space-between", align: "center" }, /* @__PURE__ */ React114.createElement(Group38, { wrap: "nowrap", align: "center" }, /* @__PURE__ */ React114.createElement(ActionIcon20, { variant: "light", color: "blue", size: "lg", radius: "xl", style: { flexShrink: 0 } }, getIcon(block.props.icon, 18, 1.5, "square-check")), /* @__PURE__ */ React114.createElement(Stack84, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React114.createElement(Text59, { fw: 500, size: "sm", contentEditable: false }, block.props.title || "Claim Title"), /* @__PURE__ */ React114.createElement(Text59, { size: "xs", c: "dimmed", contentEditable: false }, block.props.description || "Claim description")))));
10155
+ };
10156
+
10157
+ // src/mantine/blocks/claim/flow/FlowView.tsx
10158
+ import React117, { useState as useState34, useEffect as useEffect23, useMemo as useMemo23, useCallback as useCallback23 } from "react";
10159
+ import { Stack as Stack87, Text as Text62, Loader as Loader10, Center as Center5, Alert as Alert14, Title as Title11, Flex as Flex22, ActionIcon as ActionIcon23 } from "@mantine/core";
10160
+ import { IconSettings as IconSettings3, IconRefresh as IconRefresh2, IconAlertCircle as IconAlertCircle3 } from "@tabler/icons-react";
10161
+
10162
+ // src/mantine/blocks/claim/flow/ClaimCollectionsList.tsx
10163
+ import React116, { useMemo as useMemo22, useState as useState33, useEffect as useEffect22 } from "react";
10164
+ import { Stack as Stack86, Text as Text61, ActionIcon as ActionIcon22, Tooltip as Tooltip8, Loader as Loader9, Center as Center4 } from "@mantine/core";
10165
+
10166
+ // src/mantine/blocks/claim/flow/ClaimsListSheet.tsx
10167
+ import React115, { useState as useState32, useEffect as useEffect21, useCallback as useCallback22, useMemo as useMemo21 } from "react";
10168
+ import { CloseButton as CloseButton9, Title as Title10, Loader as Loader8, Stack as Stack85, Text as Text60, Button as Button29, ActionIcon as ActionIcon21, Alert as Alert13 } from "@mantine/core";
10169
+ import { IconArrowLeft as IconArrowLeft2, IconAlertCircle as IconAlertCircle2 } from "@tabler/icons-react";
10170
+ import { Survey, SurveyModel } from "@ixo/surveys";
10171
+
10172
+ // src/mantine/blocks/claim/flow/theme.ts
10173
+ var palette = {
10174
+ // Neutral
10175
+ Neutral50: "#FAFAFA",
10176
+ Neutral100: "#F8F8F8",
10177
+ Neutral200: "#F1F1F1",
10178
+ Neutral300: "#EBEBEB",
10179
+ Neutral500: "#D7D7D7",
10180
+ Neutral800: "#9A9A9A",
10181
+ Black: "#000000",
10182
+ // Neutral Dark
10183
+ NeutralDark50: "#050505",
10184
+ NeutralDark100: "#070707",
10185
+ NeutralDark200: "#0E0E0E",
10186
+ NeutralDark300: "#141414",
10187
+ NeutralDark500: "#282828",
10188
+ NeutralDark800: "#656565",
10189
+ // White
10190
+ White: "#FFFFFF",
10191
+ WhiteSecondary: "#D7ECE3",
10192
+ // EmergingBlue
10193
+ accentActive: "#0EB8DC",
10194
+ accentSecondary: "#20798C",
10195
+ accentHover: "#17C6EB",
10196
+ accentLight: "#ADEBF8",
10197
+ // CompanionBlue
10198
+ companionBlue: "#e8f9fd",
10199
+ // EmergingLighter
10200
+ accentLighter: "rgba(173,235,248,0.2)",
10201
+ accentDarker: "#296DAB",
10202
+ darkestBlue: "#000000",
10203
+ // Contribution
10204
+ contributionBlue: "rgba(22, 143, 168, 1)",
10205
+ // Danger
10206
+ dangerFull: "#E2223B",
10207
+ dangerBrighter: "#FCCFD5",
10208
+ dangerBright: "#F9909E",
10209
+ dangerDark: "#A11C43",
10210
+ // Success
10211
+ successFull: "#61B43A",
10212
+ successDarker: "#47822b",
10213
+ successBright: "#F4FCF0",
10214
+ successSecondary: "#1CBD6A",
10215
+ orangeFull: "#ED9526",
10216
+ orangeBright: "#FDC681",
10217
+ // Transparent
10218
+ transparent: "rgba(255, 255, 255, 0)",
10219
+ whiteTransparentDarker: "rgba(255, 255, 255, 0.10)",
10220
+ whiteTransparent: "rgba(255, 255, 255, 0.30)",
10221
+ whiteTransparentSecondary: "rgba(255, 255, 255, 0.65)",
10222
+ successTransparent: "rgba(67, 175, 98, 0.30)",
10223
+ // Glassmorphics
10224
+ glass: "rgba(255, 255, 255, 0.06)",
10225
+ glassGradient: "linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(153, 153, 153, 0.03) 100%)",
10226
+ glassDarker: "rgba(0, 0, 0, 0.5)",
10227
+ glassLighter: "rgba(255, 255, 255, 0.3)",
10228
+ // Gradients
10229
+ offsetCertificateGradient: "linear-gradient(45deg, rgba(59,152,51,1) 0%, rgba(70,193,193,1) 100%)",
10230
+ contributionCertificateGradient: "linear-gradient(45deg, rgba(22,143,168,1) 0%, rgba(30,204,183,1) 100%)",
10231
+ carbonCertificateGradient: "linear-gradient(55.09deg, rgba(54, 101, 135, 1) -2.49%, rgba(30, 173, 204, 1) 109.08%)",
10232
+ shadowGradient: "linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.2) 100%)"
10233
+ };
10234
+ var surveyTheme = {
10235
+ backgroundImageFit: "cover",
10236
+ backgroundImageAttachment: "scroll",
10237
+ backgroundOpacity: 0,
10238
+ cssVariables: {
10239
+ "-sjs-editorpanel-backcolor": palette.glassDarker,
10240
+ "--sjs-editor-background": palette.glassDarker,
10241
+ "--sjs-general-backcolor": palette.Black,
10242
+ "--sjs-general-backcolor-dark": palette.Black,
10243
+ "--sjs-general-backcolor-dim": palette.transparent,
10244
+ "--sjs-general-backcolor-dim-light": palette.glassDarker,
10245
+ "--sjs-general-backcolor-dim-dark": palette.glassDarker,
10246
+ "--sjs-general-forecolor": palette.White,
10247
+ "--sjs-general-forecolor-light": palette.White,
10248
+ "--sjs-general-dim-forecolor": palette.White,
10249
+ "--sjs-general-dim-forecolor-light": palette.White,
10250
+ "--sjs-font-surveytitle-color": palette.White,
10251
+ "--sjs-primary-backcolor": palette.accentActive,
10252
+ "--sjs-primary-backcolor-light": palette.accentLight,
10253
+ "--sjs-primary-backcolor-dark": palette.accentHover,
10254
+ "--sjs-primary-forecolor": "rgba(255, 255, 255, 1)",
10255
+ "--sjs-primary-forecolor-light": "rgba(255, 255, 255, 0.25)",
10256
+ "--sjs-base-unit": "8px",
10257
+ "--sjs-editorpanel-cornerRadius": "30px",
10258
+ "--sjs-questionpanel-cornerRadius": "12px",
10259
+ "--sjs-secondary-backcolor": "rgba(255, 152, 20, 1)",
10260
+ "--sjs-secondary-backcolor-light": "rgba(255, 152, 20, 0.1)",
10261
+ "--sjs-secondary-backcolor-semi-light": "rgba(255, 152, 20, 0.25)",
10262
+ "--sjs-secondary-forecolor": "rgba(255, 255, 255, 1)",
10263
+ "--sjs-secondary-forecolor-light": "rgba(255, 255, 255, 0.25)",
10264
+ "--sjs-shadow-small": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
10265
+ "--sjs-shadow-small-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
10266
+ "--sjs-shadow-medium": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
10267
+ "--sjs-shadow-large": "0px 8px 16px 0px rgba(0, 0, 0, 0.1)",
10268
+ "--sjs-shadow-inner": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
10269
+ "--sjs-shadow-inner-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
10270
+ "--sjs-border-light": "rgba(0, 0, 0, 0.09)",
10271
+ "--sjs-border-default": "rgba(0, 0, 0, 0.16)",
10272
+ "--sjs-border-inside": "rgba(0, 0, 0, 0.16)",
10273
+ "--sjs-special-red": "rgba(229, 10, 62, 1)",
10274
+ "--sjs-special-red-light": "rgba(229, 10, 62, 0.1)",
10275
+ "--sjs-special-red-forecolor": "rgba(255, 255, 255, 1)",
10276
+ "--sjs-special-green": "rgba(25, 179, 148, 1)",
10277
+ "--sjs-special-green-light": "rgba(25, 179, 148, 0.1)",
10278
+ "--sjs-special-green-forecolor": "rgba(255, 255, 255, 1)",
10279
+ "--sjs-special-blue": "rgba(67, 127, 217, 1)",
10280
+ "--sjs-special-blue-light": "rgba(67, 127, 217, 0.1)",
10281
+ "--sjs-special-blue-forecolor": "rgba(255, 255, 255, 1)",
10282
+ "--sjs-special-yellow": "rgba(255, 152, 20, 1)",
10283
+ "--sjs-special-yellow-light": "rgba(255, 152, 20, 0.1)",
10284
+ "--sjs-special-yellow-forecolor": "rgba(255, 255, 255, 1)",
10285
+ "--sjs-article-font-xx-large-textDecoration": "none",
10286
+ "--sjs-article-font-xx-large-fontWeight": "700",
10287
+ "--sjs-article-font-xx-large-fontStyle": "normal",
10288
+ "--sjs-article-font-xx-large-fontStretch": "normal",
10289
+ "--sjs-article-font-xx-large-letterSpacing": "0",
10290
+ "--sjs-article-font-xx-large-lineHeight": "64px",
10291
+ "--sjs-article-font-xx-large-paragraphIndent": "0px",
10292
+ "--sjs-article-font-xx-large-textCase": "none",
10293
+ "--sjs-article-font-x-large-textDecoration": "none",
10294
+ "--sjs-article-font-x-large-fontWeight": "700",
10295
+ "--sjs-article-font-x-large-fontStyle": "normal",
10296
+ "--sjs-article-font-x-large-fontStretch": "normal",
10297
+ "--sjs-article-font-x-large-letterSpacing": "0",
10298
+ "--sjs-article-font-x-large-lineHeight": "56px",
10299
+ "--sjs-article-font-x-large-paragraphIndent": "0px",
10300
+ "--sjs-article-font-x-large-textCase": "none",
10301
+ "--sjs-article-font-large-textDecoration": "none",
10302
+ "--sjs-article-font-large-fontWeight": "700",
10303
+ "--sjs-article-font-large-fontStyle": "normal",
10304
+ "--sjs-article-font-large-fontStretch": "normal",
10305
+ "--sjs-article-font-large-letterSpacing": "0",
10306
+ "--sjs-article-font-large-lineHeight": "40px",
10307
+ "--sjs-article-font-large-paragraphIndent": "0px",
10308
+ "--sjs-article-font-large-textCase": "none",
10309
+ "--sjs-article-font-medium-textDecoration": "none",
10310
+ "--sjs-article-font-medium-fontWeight": "700",
10311
+ "--sjs-article-font-medium-fontStyle": "normal",
10312
+ "--sjs-article-font-medium-fontStretch": "normal",
10313
+ "--sjs-article-font-medium-letterSpacing": "0",
10314
+ "--sjs-article-font-medium-lineHeight": "32px",
10315
+ "--sjs-article-font-medium-paragraphIndent": "0px",
10316
+ "--sjs-article-font-medium-textCase": "none",
10317
+ "--sjs-article-font-default-textDecoration": "none",
10318
+ "--sjs-article-font-default-fontWeight": "400",
10319
+ "--sjs-article-font-default-fontStyle": "normal",
10320
+ "--sjs-article-font-default-fontStretch": "normal",
10321
+ "--sjs-article-font-default-letterSpacing": "0",
10322
+ "--sjs-article-font-default-lineHeight": "28px",
10323
+ "--sjs-article-font-default-paragraphIndent": "0px",
10324
+ "--sjs-article-font-default-textCase": "none"
10325
+ },
10326
+ themeName: "userTheme",
10327
+ colorPalette: "dark",
10328
+ isPanelless: true
10329
+ };
10330
+
10331
+ // src/mantine/blocks/claim/flow/ClaimsListSheet.tsx
10332
+ var ClaimsListSheet = ({ collectionId, collectionName, deedId, adminAddress, userAddress, onSubmitComplete }) => {
10333
+ const { closePanel } = usePanelStore();
10334
+ const handlers = useBlocknoteHandlers();
10335
+ const [viewMode, setViewMode] = useState32("list");
10336
+ const [claims, setClaims] = useState32([]);
10337
+ const [loading, setLoading] = useState32(true);
10338
+ const [error, setError] = useState32(null);
10339
+ const [surveyJson, setSurveyJson] = useState32(null);
10340
+ const [surveyLoading, setSurveyLoading] = useState32(false);
10341
+ const [surveyError, setSurveyError] = useState32(null);
10342
+ const fetchClaims = useCallback22(async () => {
10343
+ try {
10344
+ setLoading(true);
10345
+ setError(null);
10346
+ const result = await handlers.getClaimsPerUserAddress({
10347
+ collectionId,
10348
+ userAddress
10349
+ });
10350
+ setClaims(result || []);
10351
+ } catch (err) {
10352
+ console.error("Error fetching claims:", err);
10353
+ setError(err instanceof Error ? err.message : "Failed to fetch claims");
10354
+ setClaims([]);
10355
+ } finally {
10356
+ setLoading(false);
10357
+ }
10358
+ }, [collectionId, userAddress, handlers]);
10359
+ const fetchSurveyTemplate = useCallback22(async () => {
10360
+ try {
10361
+ setSurveyLoading(true);
10362
+ setSurveyError(null);
10363
+ const result = await handlers.getDeedSurveyTemplate(deedId);
10364
+ if (result) {
10365
+ setSurveyJson(result.surveyTemplate);
10366
+ } else {
10367
+ setSurveyError("No survey template found for this deed");
10368
+ }
10369
+ } catch (err) {
10370
+ console.error("Error fetching survey template:", err);
10371
+ setSurveyError(err instanceof Error ? err.message : "Failed to load survey template");
10372
+ } finally {
10373
+ setSurveyLoading(false);
10374
+ }
10375
+ }, [deedId, handlers]);
10376
+ useEffect21(() => {
10377
+ fetchClaims();
10378
+ }, [fetchClaims]);
10379
+ const surveyModel = useMemo21(() => {
10380
+ if (!surveyJson) return null;
10381
+ const model = new SurveyModel(surveyJson);
10382
+ model.applyTheme(surveyTheme);
10383
+ model.showQuestionNumbers = "off";
10384
+ model.questionsOnPageMode = "singlePage";
10385
+ return model;
10386
+ }, [surveyJson]);
10387
+ const handleSurveyComplete = useCallback22(
10388
+ async (sender) => {
10389
+ const surveyData = sender.data;
10390
+ console.log("Survey completed:", surveyData);
10391
+ try {
10392
+ const pin = await handlers.requestPin({
10393
+ title: "Verify Identity",
10394
+ description: "Enter your PIN to submit the claim",
10395
+ submitText: "Verify"
10396
+ });
10397
+ if (!adminAddress) {
10398
+ throw new Error("Admin address is not set. Please configure the claim block first.");
10399
+ }
10400
+ const result = await handlers.submitClaim({
10401
+ surveyData,
10402
+ deedDid: deedId,
10403
+ collectionId,
10404
+ adminAddress,
10405
+ pin
10406
+ });
10407
+ console.log("Claim submitted successfully:", result);
10408
+ closePanel();
10409
+ onSubmitComplete?.();
10410
+ } catch (error2) {
10411
+ console.error("Failed to submit claim:", error2);
10412
+ setSurveyError(error2 instanceof Error ? error2.message : "Failed to submit claim");
10413
+ }
10414
+ },
10415
+ [handlers, deedId, collectionId, adminAddress, closePanel, onSubmitComplete]
10416
+ );
10417
+ useEffect21(() => {
10418
+ if (surveyModel) {
10419
+ surveyModel.onComplete.add(handleSurveyComplete);
10420
+ return () => {
10421
+ surveyModel.onComplete.remove(handleSurveyComplete);
10422
+ };
10423
+ }
10424
+ return void 0;
10425
+ }, [surveyModel, handleSurveyComplete]);
10426
+ const handleNewClaim = () => {
10427
+ if (!surveyJson) {
10428
+ fetchSurveyTemplate();
10429
+ }
10430
+ setViewMode("survey");
10431
+ };
10432
+ const handleBackToList = () => {
10433
+ setViewMode("list");
10434
+ setSurveyError(null);
10435
+ fetchClaims();
10436
+ };
10437
+ const getClaimStatus = (paymentsStatus) => {
10438
+ if (paymentsStatus.approval === "PAID") {
10439
+ return "approved";
10440
+ }
10441
+ if (paymentsStatus.rejection === "PAID") {
10442
+ return "rejected";
10443
+ }
10444
+ return "pending";
10445
+ };
10446
+ const getStatusColor = (status) => {
10447
+ switch (status) {
10448
+ case "approved":
10449
+ return "green";
10450
+ case "rejected":
10451
+ return "red";
10452
+ case "pending":
10453
+ default:
10454
+ return "yellow";
10455
+ }
10456
+ };
10457
+ const formatDate = (dateString) => {
10458
+ try {
10459
+ return new Date(dateString).toLocaleDateString();
10460
+ } catch {
10461
+ return dateString;
10462
+ }
10463
+ };
10464
+ return /* @__PURE__ */ React115.createElement(
10465
+ "div",
10466
+ {
10467
+ style: {
10468
+ height: "100%",
10469
+ display: "flex",
10470
+ flexDirection: "column",
10471
+ overflow: "hidden"
10472
+ }
10473
+ },
10474
+ /* @__PURE__ */ React115.createElement(
10475
+ "div",
10476
+ {
10477
+ style: {
10478
+ display: "flex",
10479
+ justifyContent: "space-between",
10480
+ alignItems: "center",
10481
+ marginBottom: "1rem"
10482
+ }
10483
+ },
10484
+ /* @__PURE__ */ React115.createElement("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" } }, viewMode === "survey" && /* @__PURE__ */ React115.createElement(ActionIcon21, { variant: "subtle", onClick: handleBackToList }, /* @__PURE__ */ React115.createElement(IconArrowLeft2, { size: 20 })), /* @__PURE__ */ React115.createElement(Title10, { order: 3 }, viewMode === "list" ? collectionName : "Submit New Claim")),
10485
+ /* @__PURE__ */ React115.createElement(CloseButton9, { onClick: closePanel })
10486
+ ),
10487
+ /* @__PURE__ */ React115.createElement(
10488
+ "div",
10489
+ {
10490
+ style: {
10491
+ flex: 1,
10492
+ overflow: "hidden",
10493
+ position: "relative"
10494
+ }
10495
+ },
10496
+ /* @__PURE__ */ React115.createElement(
10497
+ "div",
10498
+ {
10499
+ style: {
10500
+ position: "absolute",
10501
+ top: 0,
10502
+ left: 0,
10503
+ right: 0,
10504
+ bottom: 0,
10505
+ display: "flex",
10506
+ flexDirection: "column",
10507
+ overflow: "auto",
10508
+ transform: viewMode === "list" ? "translateX(0)" : "translateX(-100%)",
10509
+ opacity: viewMode === "list" ? 1 : 0,
10510
+ transition: "transform 0.3s ease-out, opacity 0.3s ease-out",
10511
+ pointerEvents: viewMode === "list" ? "auto" : "none"
10512
+ }
10513
+ },
10514
+ /* @__PURE__ */ React115.createElement(Stack85, { gap: "md", style: { flex: 1 } }, /* @__PURE__ */ React115.createElement(Button29, { onClick: handleNewClaim, fullWidth: true }, "New Claim"), loading ? /* @__PURE__ */ React115.createElement(Stack85, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React115.createElement(Loader8, { size: "lg" }), /* @__PURE__ */ React115.createElement(Text60, { size: "sm", c: "dimmed" }, "Loading claims...")) : error ? /* @__PURE__ */ React115.createElement(Alert13, { color: "red", title: "Failed to load claims", icon: /* @__PURE__ */ React115.createElement(IconAlertCircle2, { size: 18 }) }, /* @__PURE__ */ React115.createElement(Text60, { size: "sm" }, error)) : claims.length === 0 ? /* @__PURE__ */ React115.createElement(Stack85, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React115.createElement(Text60, { size: "sm", c: "dimmed", ta: "center" }, 'No claims found. Click "New Claim" to submit your first claim.')) : /* @__PURE__ */ React115.createElement(Stack85, { gap: "xs" }, claims.map((claim) => {
10515
+ const status = getClaimStatus(claim.paymentsStatus);
10516
+ return /* @__PURE__ */ React115.createElement(ListItemContainer, { key: claim.claimId }, /* @__PURE__ */ React115.createElement(Stack85, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React115.createElement(Text60, { size: "sm", fw: 500 }, "Claim #", claim.claimId.slice(-8)), /* @__PURE__ */ React115.createElement(Text60, { size: "xs", c: "dimmed" }, "Submitted: ", formatDate(claim.submissionDate))), /* @__PURE__ */ React115.createElement(Text60, { size: "xs", fw: 500, c: getStatusColor(status) }, status.toUpperCase()));
10517
+ })))
10518
+ ),
10519
+ /* @__PURE__ */ React115.createElement(
10520
+ "div",
10521
+ {
10522
+ style: {
10523
+ position: "absolute",
10524
+ top: 0,
10525
+ left: 0,
10526
+ right: 0,
10527
+ bottom: 0,
10528
+ display: "flex",
10529
+ flexDirection: "column",
10530
+ overflow: "auto",
10531
+ transform: viewMode === "survey" ? "translateX(0)" : "translateX(100%)",
10532
+ opacity: viewMode === "survey" ? 1 : 0,
10533
+ transition: "transform 0.3s ease-out, opacity 0.3s ease-out",
10534
+ pointerEvents: viewMode === "survey" ? "auto" : "none"
10535
+ }
10536
+ },
10537
+ /* @__PURE__ */ React115.createElement("div", null, surveyLoading && /* @__PURE__ */ React115.createElement(Stack85, { align: "center", justify: "center", style: { height: "100%" } }, /* @__PURE__ */ React115.createElement(Loader8, { size: "lg" }), /* @__PURE__ */ React115.createElement(Text60, { size: "sm", c: "dimmed" }, "Loading survey template...")), surveyError && /* @__PURE__ */ React115.createElement(Stack85, { align: "center", justify: "center", style: { height: "100%", padding: "1rem" } }, /* @__PURE__ */ React115.createElement(Text60, { size: "sm", c: "red" }, surveyError)), !surveyLoading && !surveyError && surveyModel && /* @__PURE__ */ React115.createElement(Survey, { model: surveyModel }))
10538
+ )
10539
+ )
10540
+ );
10541
+ };
10542
+
10543
+ // src/mantine/blocks/claim/flow/ClaimCollectionsList.tsx
10544
+ import { IconArrowRight as IconArrowRight2 } from "@tabler/icons-react";
10545
+ var CollectionItem = ({ collection, deedId, adminAddress, userRole, onRefresh }) => {
10546
+ const handlers = useBlocknoteHandlers();
10547
+ const currentUser = handlers.getCurrentUser();
10548
+ const getCollectionName = (collection2) => {
10549
+ return collection2.protocol?.profile?.name || collection2.name || "Unnamed Collection";
10550
+ };
10551
+ const isServiceAgent = userRole === "SA" /* ServiceProvider */;
10552
+ const canAccessClaims = isServiceAgent;
10553
+ const claimsPanelId = `claims-list-${collection.id}`;
10554
+ const collectionName = getCollectionName(collection);
10555
+ const claimsPanelContent = useMemo22(
10556
+ () => /* @__PURE__ */ React116.createElement(
10557
+ ClaimsListSheet,
10558
+ {
10559
+ collectionId: collection.id,
10560
+ collectionName,
10561
+ deedId,
10562
+ adminAddress,
10563
+ userAddress: currentUser.address,
10564
+ onSubmitComplete: onRefresh
10565
+ }
10566
+ ),
10567
+ [collection.id, collectionName, deedId, adminAddress, currentUser.address, onRefresh]
10568
+ );
10569
+ const { open: openClaimsPanel } = usePanel(claimsPanelId, claimsPanelContent);
10570
+ const handleClick = () => {
10571
+ if (canAccessClaims) {
10572
+ openClaimsPanel();
10573
+ }
10574
+ };
10575
+ return /* @__PURE__ */ React116.createElement("div", { style: { opacity: canAccessClaims ? 1 : 0.5 } }, /* @__PURE__ */ React116.createElement(ListItemContainer, null, /* @__PURE__ */ React116.createElement(Stack86, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React116.createElement(Text61, { size: "sm", fw: 500, c: canAccessClaims ? void 0 : "dimmed" }, getCollectionName(collection)), collection.description && /* @__PURE__ */ React116.createElement(Text61, { size: "xs", c: "dimmed" }, collection.description)), /* @__PURE__ */ React116.createElement(Tooltip8, { label: "You need to apply to be a service agent first", disabled: canAccessClaims, position: "left", withArrow: true }, /* @__PURE__ */ React116.createElement(ActionIcon22, { variant: "subtle", size: "lg", onClick: handleClick, disabled: !canAccessClaims, style: { cursor: canAccessClaims ? "pointer" : "not-allowed" } }, /* @__PURE__ */ React116.createElement(IconArrowRight2, { size: 20 })))));
10576
+ };
10577
+ var ClaimCollectionsList = ({ collections, deedId, adminAddress, userAddress, onRefresh }) => {
10578
+ const handlers = useBlocknoteHandlers();
10579
+ const [userRoles, setUserRoles] = useState33({});
10580
+ const [loadingRoles, setLoadingRoles] = useState33(true);
10581
+ useEffect22(() => {
10582
+ const fetchUserRoles = async () => {
10583
+ if (!collections || collections.length === 0 || !userAddress || !adminAddress) {
10584
+ setLoadingRoles(false);
10585
+ return;
10586
+ }
10587
+ try {
10588
+ setLoadingRoles(true);
10589
+ const collectionIds = collections.map((c) => c.id);
10590
+ const roles = await handlers.getUserRoles({
10591
+ userAddress,
10592
+ adminAddress,
10593
+ deedDid: deedId,
10594
+ collectionIds
10595
+ });
10596
+ const rolesMap = {};
10597
+ collections.forEach((collection) => {
10598
+ const roleData = roles?.find((r) => r.collectionId === collection.id);
10599
+ rolesMap[collection.id] = roleData?.role || null;
10600
+ });
10601
+ setUserRoles(rolesMap);
10602
+ } catch (error) {
10603
+ console.error("Error fetching user roles:", error);
10604
+ const rolesMap = {};
10605
+ collections.forEach((collection) => {
10606
+ rolesMap[collection.id] = null;
10607
+ });
10608
+ setUserRoles(rolesMap);
10609
+ } finally {
10610
+ setLoadingRoles(false);
10611
+ }
10612
+ };
10613
+ fetchUserRoles();
10614
+ }, [collections, userAddress, adminAddress, handlers, deedId]);
10615
+ if (!collections || collections.length === 0) {
10616
+ return /* @__PURE__ */ React116.createElement(Text61, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No claim collections found");
10617
+ }
10618
+ if (loadingRoles) {
10619
+ return /* @__PURE__ */ React116.createElement(Center4, { py: "md" }, /* @__PURE__ */ React116.createElement(Loader9, { size: "sm" }));
10620
+ }
10621
+ return /* @__PURE__ */ React116.createElement(Stack86, { gap: "md", px: 5 }, collections.map((collection) => /* @__PURE__ */ React116.createElement(CollectionItem, { key: collection.id, collection, deedId, adminAddress, userRole: userRoles[collection.id] || null, onRefresh })));
10622
+ };
10623
+
10624
+ // src/mantine/blocks/claim/flow/FlowView.tsx
10625
+ var CLAIM_FLOW_PANEL_ID = "claim-flow-panel";
10626
+ var ClaimFlowView = ({ editor, block }) => {
10627
+ const { editable } = useBlocknoteContext();
10628
+ const handlers = useBlocknoteHandlers();
10629
+ const currentUser = handlers.getCurrentUser();
10630
+ const [collections, setCollections] = useState34([]);
10631
+ const [loading, setLoading] = useState34(false);
10632
+ const [error, setError] = useState34(null);
10633
+ const panelId = `${CLAIM_FLOW_PANEL_ID}-${block.id}`;
10634
+ const panelContent = useMemo23(() => /* @__PURE__ */ React117.createElement(TemplateConfig6, { editor, block }), [editor, block]);
10635
+ const { open } = usePanel(panelId, panelContent);
10636
+ const selectedCollectionIds = useMemo23(() => {
10637
+ try {
10638
+ return JSON.parse(block.props.selectedCollections || "[]");
10639
+ } catch {
10640
+ return [];
10641
+ }
10642
+ }, [block.props.selectedCollections]);
10643
+ const did = block.props.deedDid;
10644
+ const adminAddress = block.props.adminAddress || "";
10645
+ const fetchCollections = useCallback23(async () => {
10646
+ if (!did || selectedCollectionIds.length === 0) {
10647
+ setCollections([]);
10648
+ return;
10649
+ }
10650
+ setLoading(true);
10651
+ setError(null);
10652
+ try {
10653
+ const response = await handlers.getClaimCollections({ deedDid: did });
10654
+ const { adminAddress: adminAddress2, collections: allCollections } = response || { adminAddress: "", collections: [] };
10655
+ if (adminAddress2 && (!block.props.adminAddress || block.props.adminAddress === "")) {
10656
+ editor.updateBlock(block, {
10657
+ props: {
10658
+ ...block.props,
10659
+ adminAddress: adminAddress2
10660
+ }
10661
+ });
10662
+ }
10663
+ const selectedCollections = (allCollections || []).filter((c) => selectedCollectionIds.includes(c?.id));
10664
+ setCollections(selectedCollections);
10665
+ } catch (err) {
10666
+ console.error("Error fetching collections:", err);
10667
+ setError(err instanceof Error ? err.message : "Failed to fetch collections");
10668
+ } finally {
10669
+ setLoading(false);
10670
+ }
10671
+ }, [did, selectedCollectionIds, handlers, editor, block]);
10672
+ useEffect23(() => {
10673
+ fetchCollections();
10674
+ }, [fetchCollections]);
10675
+ if (!did) {
10676
+ return /* @__PURE__ */ React117.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React117.createElement(Text62, { size: "sm", c: "dimmed" }, "Please configure the claim block in template mode first"));
10677
+ }
10678
+ if (selectedCollectionIds.length === 0) {
10679
+ return /* @__PURE__ */ React117.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React117.createElement(Text62, { size: "sm", c: "dimmed" }, "No claim collections selected"));
10680
+ }
10681
+ return /* @__PURE__ */ React117.createElement(Stack87, { w: "100%" }, /* @__PURE__ */ React117.createElement(Flex22, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React117.createElement(Title11, { order: 4 }, "Submit Claims"), /* @__PURE__ */ React117.createElement(Flex22, { gap: "xs" }, /* @__PURE__ */ React117.createElement(ActionIcon23, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React117.createElement(IconRefresh2, { size: 18 })), editable && /* @__PURE__ */ React117.createElement(ActionIcon23, { variant: "subtle", size: "sm", onClick: open }, /* @__PURE__ */ React117.createElement(IconSettings3, { size: 18 })))), loading ? /* @__PURE__ */ React117.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React117.createElement(Loader10, { size: "md" })) : error ? /* @__PURE__ */ React117.createElement(Alert14, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React117.createElement(IconAlertCircle3, { size: 18 }) }, /* @__PURE__ */ React117.createElement(Text62, { size: "sm" }, error)) : /* @__PURE__ */ React117.createElement(ClaimCollectionsList, { collections, deedId: did, adminAddress, userAddress: currentUser.address, onRefresh: fetchCollections }));
10682
+ };
10683
+
10684
+ // src/mantine/blocks/claim/ClaimBlock.tsx
10685
+ function ClaimBlock({ editor, block }) {
10686
+ const { docType } = useBlocknoteContext();
10687
+ if (docType === "template") {
10688
+ return /* @__PURE__ */ React118.createElement(ClaimTemplateView, { editor, block });
10689
+ }
10690
+ return /* @__PURE__ */ React118.createElement(ClaimFlowView, { editor, block });
10691
+ }
10692
+
10693
+ // src/mantine/blocks/claim/ClaimBlockSpec.tsx
10694
+ var ClaimBlockSpec = createReactBlockSpec8(
10695
+ {
10696
+ type: "claim",
10697
+ propSchema: {
10698
+ title: { default: "" },
10699
+ description: { default: "" },
10700
+ icon: { default: "square-check" },
10701
+ deedDid: { default: "" },
10702
+ selectedCollections: { default: "[]" },
10703
+ adminAddress: { default: "" }
10704
+ },
10705
+ content: "none"
10706
+ },
10707
+ {
10708
+ render: (props) => {
10709
+ const ixoProps = props;
10710
+ return /* @__PURE__ */ React119.createElement(ClaimBlock, { ...ixoProps });
10711
+ }
10712
+ }
10713
+ );
10714
+
10715
+ // src/mantine/blocks/bid/BidBlockSpec.tsx
10716
+ import React130 from "react";
10717
+ import { createReactBlockSpec as createReactBlockSpec9 } from "@blocknote/react";
10718
+
10719
+ // src/mantine/blocks/bid/BidBlock.tsx
10720
+ import React129 from "react";
10721
+
10722
+ // src/mantine/blocks/bid/template/TemplateView.tsx
10723
+ import React123, { useMemo as useMemo25 } from "react";
10724
+ import { Card as Card25, Group as Group39, Stack as Stack89, Text as Text64, ActionIcon as ActionIcon24, Badge as Badge17 } from "@mantine/core";
10725
+
10726
+ // src/mantine/blocks/bid/template/TemplateConfig.tsx
10727
+ import React122, { useCallback as useCallback25 } from "react";
10728
+ import { Paper as Paper14, CloseButton as CloseButton10, Title as Title12 } from "@mantine/core";
10729
+
10730
+ // src/mantine/blocks/bid/template/GeneralTab.tsx
10731
+ import React120, { useEffect as useEffect24, useState as useState35 } from "react";
10732
+ import { Stack as Stack88, Text as Text63, TextInput as TextInput40, Textarea as Textarea23 } from "@mantine/core";
10733
+ var GeneralTab7 = ({ title, description, onTitleChange, onDescriptionChange }) => {
10734
+ const [localTitle, setLocalTitle] = useState35(title || "");
10735
+ const [localDescription, setLocalDescription] = useState35(description || "");
10736
+ useEffect24(() => {
10737
+ setLocalTitle(title || "");
10738
+ }, [title]);
10739
+ useEffect24(() => {
10740
+ setLocalDescription(description || "");
10741
+ }, [description]);
10742
+ return /* @__PURE__ */ React120.createElement(Stack88, { gap: "lg" }, /* @__PURE__ */ React120.createElement(Stack88, { gap: "xs" }, /* @__PURE__ */ React120.createElement(Text63, { size: "sm", fw: 600 }, "Title"), /* @__PURE__ */ React120.createElement(
10743
+ TextInput40,
10744
+ {
10745
+ placeholder: "e.g. Bid Title",
10746
+ value: localTitle,
10747
+ onChange: (event) => {
10748
+ const newTitle = event.currentTarget.value;
10749
+ setLocalTitle(newTitle);
10750
+ onTitleChange(newTitle);
10751
+ }
10752
+ }
10753
+ )), /* @__PURE__ */ React120.createElement(Stack88, { gap: "xs" }, /* @__PURE__ */ React120.createElement(Text63, { size: "sm", fw: 600 }, "Description"), /* @__PURE__ */ React120.createElement(
10754
+ Textarea23,
10755
+ {
10756
+ placeholder: "Describe what this bid is about",
10757
+ minRows: 3,
10758
+ value: localDescription,
10759
+ onChange: (event) => {
10760
+ const newDescription = event.currentTarget.value;
10761
+ setLocalDescription(newDescription);
10762
+ onDescriptionChange(newDescription);
10763
+ }
10764
+ }
10765
+ )));
10766
+ };
10767
+
10768
+ // src/mantine/blocks/bid/template/CollectionsTab.tsx
10769
+ import React121, { useCallback as useCallback24, useMemo as useMemo24 } from "react";
10770
+ var CollectionsTab = ({ did, selectedCollections, adminAddress, onDidChange, onSelectedCollectionsChange, onAdminAddressChange }) => {
10771
+ const parsedSelectedCollections = useMemo24(() => {
10772
+ try {
10773
+ return JSON.parse(selectedCollections || "[]");
10774
+ } catch {
10775
+ return [];
10776
+ }
10777
+ }, [selectedCollections]);
10778
+ const handleCollectionsChange = useCallback24(
10779
+ (collections) => {
10780
+ onSelectedCollectionsChange(JSON.stringify(collections || []));
10781
+ },
10782
+ [onSelectedCollectionsChange]
10783
+ );
10784
+ const handleAdminAddressChange = useCallback24(
10785
+ (adminAddress2) => {
10786
+ if (onAdminAddressChange) {
10787
+ onAdminAddressChange(adminAddress2);
10788
+ }
10789
+ },
10790
+ [onAdminAddressChange]
10791
+ );
10792
+ return /* @__PURE__ */ React121.createElement(
10793
+ CollectionSelector,
10794
+ {
10795
+ did,
10796
+ selectedCollections: parsedSelectedCollections,
10797
+ onDidChange,
10798
+ onCollectionsChange: handleCollectionsChange,
10799
+ onAdminAddressChange: handleAdminAddressChange,
10800
+ currentAdminAddress: adminAddress
10801
+ }
10802
+ );
10803
+ };
10804
+
10805
+ // src/mantine/blocks/bid/template/TemplateConfig.tsx
10806
+ var TemplateConfig7 = ({ editor, block }) => {
10807
+ const { closePanel } = usePanelStore();
10808
+ const updateProp = useCallback25(
10809
+ (key, value) => {
10810
+ editor.updateBlock(block, {
10811
+ props: {
10812
+ ...block.props,
10813
+ [key]: value
10814
+ }
10815
+ });
10816
+ },
10817
+ [editor, block]
10818
+ );
10819
+ return /* @__PURE__ */ React122.createElement(
10820
+ Paper14,
10821
+ {
10822
+ p: "md",
10823
+ shadow: "sm",
10824
+ style: {
10825
+ height: "100%",
10826
+ display: "flex",
10827
+ flexDirection: "column"
10828
+ }
10829
+ },
10830
+ /* @__PURE__ */ React122.createElement(
10831
+ "div",
10832
+ {
10833
+ style: {
10834
+ display: "flex",
10835
+ justifyContent: "space-between",
10836
+ alignItems: "center",
10837
+ marginBottom: "1rem"
10838
+ }
10839
+ },
10840
+ /* @__PURE__ */ React122.createElement(Title12, { order: 3 }, "Bid Settings"),
10841
+ /* @__PURE__ */ React122.createElement(CloseButton10, { onClick: closePanel })
10842
+ ),
10843
+ /* @__PURE__ */ React122.createElement(
10844
+ ReusablePanel,
10845
+ {
10846
+ extraTabs: [
10847
+ {
10848
+ label: "General",
10849
+ value: "general",
10850
+ content: /* @__PURE__ */ React122.createElement(
10851
+ GeneralTab7,
10852
+ {
10853
+ title: block.props.title || "",
10854
+ description: block.props.description || "",
10855
+ onTitleChange: (value) => updateProp("title", value),
10856
+ onDescriptionChange: (value) => updateProp("description", value)
10857
+ }
10858
+ )
10859
+ },
10860
+ {
10861
+ label: "Collections",
10862
+ value: "collections",
10863
+ content: /* @__PURE__ */ React122.createElement(
10864
+ CollectionsTab,
10865
+ {
10866
+ did: block.props.did || "",
10867
+ selectedCollections: block.props.selectedCollections || "[]",
10868
+ adminAddress: block.props.adminAddress || "",
10869
+ onDidChange: (value) => updateProp("did", value),
10870
+ onSelectedCollectionsChange: (value) => updateProp("selectedCollections", value),
10871
+ onAdminAddressChange: (value) => updateProp("adminAddress", value)
10872
+ }
10873
+ )
10874
+ }
10875
+ ],
10876
+ context: { editor, block }
10877
+ }
10878
+ )
10879
+ );
10880
+ };
10881
+
10882
+ // src/mantine/blocks/bid/template/TemplateView.tsx
10883
+ var BID_TEMPLATE_PANEL_ID = "bid-template-panel";
10884
+ var BidTemplateView = ({ editor, block }) => {
10885
+ const panelId = `${BID_TEMPLATE_PANEL_ID}-${block.id}`;
10886
+ const panelContent = useMemo25(() => /* @__PURE__ */ React123.createElement(TemplateConfig7, { editor, block }), [editor, block]);
10887
+ const { open } = usePanel(panelId, panelContent);
10888
+ const selectedCollectionsCount = useMemo25(() => {
10889
+ try {
10890
+ const parsed = JSON.parse(block.props.selectedCollections || "[]");
10891
+ return parsed.length;
10892
+ } catch {
10893
+ return 0;
10894
+ }
10895
+ }, [block.props.selectedCollections]);
10896
+ const didDisplay = block.props.did ? `${block.props.did.substring(0, 15)}...${block.props.did.substring(block.props.did.length - 10)}` : "No DID configured";
10897
+ return /* @__PURE__ */ React123.createElement(Card25, { withBorder: true, padding: "md", radius: "md", style: { width: "100%", cursor: "pointer", position: "relative" }, onClick: open }, /* @__PURE__ */ React123.createElement(Badge17, { size: "xs", variant: "light", color: "gray", style: { position: "absolute", top: 8, right: 8 } }, "Template"), /* @__PURE__ */ React123.createElement(Group39, { wrap: "nowrap", justify: "space-between", align: "center" }, /* @__PURE__ */ React123.createElement(Group39, { wrap: "nowrap", align: "center" }, /* @__PURE__ */ React123.createElement(ActionIcon24, { variant: "light", color: "blue", size: "lg", radius: "xl", style: { flexShrink: 0 } }, getIcon("dollar-sign", 18, 1.5)), /* @__PURE__ */ React123.createElement(Stack89, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React123.createElement(Text64, { fw: 500, size: "sm", contentEditable: false }, "Bid Block"), /* @__PURE__ */ React123.createElement(Text64, { size: "xs", c: "dimmed", contentEditable: false }, block.props.did ? didDisplay : "Configure bid settings"), selectedCollectionsCount > 0 && /* @__PURE__ */ React123.createElement(Text64, { size: "xs", c: "blue", contentEditable: false }, selectedCollectionsCount, " collection", selectedCollectionsCount !== 1 ? "s" : "", " selected")))));
10898
+ };
10899
+
10900
+ // src/mantine/blocks/bid/flow/FlowView.tsx
10901
+ import React128, { useState as useState40, useEffect as useEffect29, useMemo as useMemo30, useCallback as useCallback28 } from "react";
10902
+ import { Stack as Stack94, Text as Text69, Loader as Loader15, Center as Center8, Alert as Alert17, Title as Title15, Flex as Flex23, ActionIcon as ActionIcon27 } from "@mantine/core";
10903
+ import { IconSettings as IconSettings4, IconRefresh as IconRefresh3, IconAlertCircle as IconAlertCircle6 } from "@tabler/icons-react";
10904
+
10905
+ // src/mantine/blocks/bid/flow/ClaimCollectionsList.tsx
10906
+ import React127, { useMemo as useMemo29, useState as useState39, useEffect as useEffect28 } from "react";
10907
+ import { Stack as Stack93, Text as Text68, Button as Button31, Menu as Menu2, Badge as Badge20, Collapse as Collapse4, Loader as Loader14, Center as Center7, ActionIcon as ActionIcon26 } from "@mantine/core";
10908
+ import { IconChevronDown as IconChevronDown4, IconArrowDown as IconArrowDown3, IconArrowUp as IconArrowUp3 } from "@tabler/icons-react";
10909
+
10910
+ // src/mantine/blocks/bid/flow/BidSurveyPanel.tsx
10911
+ import React124, { useMemo as useMemo26, useState as useState36, useEffect as useEffect25, useCallback as useCallback26 } from "react";
10912
+ import { Paper as Paper15, CloseButton as CloseButton11, Title as Title13, Loader as Loader11, Stack as Stack90, Text as Text65 } from "@mantine/core";
10913
+ import { Survey as Survey2, SurveyModel as SurveyModel2 } from "@ixo/surveys";
10914
+ var SURVEY_THEME_VARIABLES = Object.entries(surveyTheme.cssVariables ?? {}).reduce((acc, [key, value]) => {
10915
+ acc[key] = value;
10916
+ return acc;
10917
+ }, {});
10918
+ var SURVEY_THEME_BACKGROUND = SURVEY_THEME_VARIABLES["--sjs-general-backcolor"] ?? "#050505";
10919
+ var SURVEY_THEME_FOREGROUND = SURVEY_THEME_VARIABLES["--sjs-general-forecolor"] ?? "#ffffff";
10920
+ var BidSurveyPanel = ({ deedId, collectionId, role, onSubmitComplete }) => {
10921
+ const { closePanel } = usePanelStore();
10922
+ const handlers = useBlocknoteHandlers();
10923
+ const [surveyJson, setSurveyJson] = useState36(null);
10924
+ const [loading, setLoading] = useState36(true);
10925
+ const [error, setError] = useState36(null);
10926
+ const roleLabel = role === "service_agent" ? "Service Agent" : "Evaluation Agent";
10927
+ useEffect25(() => {
10928
+ const fetchSurveyTemplate = async () => {
10929
+ try {
10930
+ setLoading(true);
10931
+ setError(null);
10932
+ const result = role === "service_agent" ? await handlers.getBidContributorSurveyTemplate(deedId) : await handlers.getBidEvaluatorSurveyTemplate(deedId);
10933
+ if (result) {
10934
+ setSurveyJson(result.surveyTemplate);
10935
+ } else {
10936
+ setError("No survey template found for this role");
10937
+ }
10938
+ } catch (err) {
10939
+ console.error("Error fetching survey template:", err);
10940
+ setError(err instanceof Error ? err.message : "Failed to load survey template");
10941
+ } finally {
10942
+ setLoading(false);
10943
+ }
10944
+ };
10945
+ fetchSurveyTemplate();
10946
+ }, [deedId, role, handlers]);
10947
+ const surveyModel = useMemo26(() => {
10948
+ if (!surveyJson) return null;
10949
+ const model = new SurveyModel2(surveyJson);
10950
+ model.applyTheme(surveyTheme);
10951
+ model.showQuestionNumbers = "off";
10952
+ model.questionsOnPageMode = "singlePage";
10953
+ return model;
10954
+ }, [surveyJson]);
10955
+ const surveyContainerStyle = useMemo26(
10956
+ () => ({
10957
+ flex: 1,
10958
+ overflow: "auto",
10959
+ backgroundColor: SURVEY_THEME_BACKGROUND,
10960
+ color: SURVEY_THEME_FOREGROUND,
10961
+ ...SURVEY_THEME_VARIABLES
10962
+ }),
10963
+ []
10964
+ );
10965
+ const handleSurveyComplete = useCallback26(
10966
+ async (sender) => {
10967
+ const surveyData = sender.data;
10968
+ console.log("Survey completed:", surveyData);
10969
+ try {
10970
+ const bidRole = role === "service_agent" ? "SA" /* serviceProviders */ : "EA" /* evaluators */;
10971
+ await handlers.submitBid({
10972
+ collectionId,
10973
+ role: bidRole,
10974
+ surveyAnswers: surveyData
10975
+ });
10976
+ console.log("Bid submitted successfully");
10977
+ closePanel();
10978
+ onSubmitComplete?.();
10979
+ } catch (error2) {
10980
+ console.error("Failed to submit bid:", error2);
10981
+ setError(error2 instanceof Error ? error2.message : "Failed to submit bid");
10982
+ }
10983
+ },
10984
+ [handlers, collectionId, role, closePanel, onSubmitComplete]
10985
+ );
10986
+ useEffect25(() => {
10987
+ if (surveyModel) {
10988
+ surveyModel.onComplete.add(handleSurveyComplete);
10989
+ return () => {
10990
+ surveyModel.onComplete.remove(handleSurveyComplete);
10991
+ };
10992
+ }
10993
+ return void 0;
10994
+ }, [surveyModel, handleSurveyComplete]);
10995
+ return /* @__PURE__ */ React124.createElement(
10996
+ Paper15,
10997
+ {
10998
+ p: "md",
10999
+ shadow: "sm",
11000
+ style: {
11001
+ height: "100%",
11002
+ display: "flex",
11003
+ flexDirection: "column"
11004
+ }
11005
+ },
11006
+ /* @__PURE__ */ React124.createElement(
11007
+ "div",
11008
+ {
11009
+ style: {
11010
+ display: "flex",
11011
+ justifyContent: "space-between",
11012
+ alignItems: "center",
11013
+ marginBottom: "1rem"
11014
+ }
11015
+ },
11016
+ /* @__PURE__ */ React124.createElement(Title13, { order: 3 }, roleLabel, " Application"),
11017
+ /* @__PURE__ */ React124.createElement(CloseButton11, { onClick: closePanel })
11018
+ ),
11019
+ /* @__PURE__ */ React124.createElement("div", { style: surveyContainerStyle }, loading && /* @__PURE__ */ React124.createElement(Stack90, { align: "center", justify: "center", style: { height: "100%" } }, /* @__PURE__ */ React124.createElement(Loader11, { size: "lg" }), /* @__PURE__ */ React124.createElement(Text65, { size: "sm", c: "dimmed" }, "Loading survey template...")), error && /* @__PURE__ */ React124.createElement(Stack90, { align: "center", justify: "center", style: { height: "100%", padding: "1rem" } }, /* @__PURE__ */ React124.createElement(Text65, { size: "sm", c: "red" }, error)), !loading && !error && surveyModel && /* @__PURE__ */ React124.createElement(Survey2, { model: surveyModel }))
11020
+ );
11021
+ };
11022
+
11023
+ // src/mantine/blocks/bid/flow/BidsList.tsx
11024
+ import React126, { useState as useState38, useEffect as useEffect27, useMemo as useMemo28, useCallback as useCallback27 } from "react";
11025
+ import { Stack as Stack92, Text as Text67, Loader as Loader13, Center as Center6, Alert as Alert16, Badge as Badge19, Group as Group41, ActionIcon as ActionIcon25 } from "@mantine/core";
11026
+ import { IconAlertCircle as IconAlertCircle5, IconArrowRight as IconArrowRight3 } from "@tabler/icons-react";
11027
+
11028
+ // src/mantine/blocks/bid/flow/BidViewPanel.tsx
11029
+ import React125, { useMemo as useMemo27, useState as useState37, useEffect as useEffect26 } from "react";
11030
+ import { Paper as Paper16, CloseButton as CloseButton12, Title as Title14, Loader as Loader12, Stack as Stack91, Text as Text66, Badge as Badge18, Button as Button30, Group as Group40, Modal as Modal2, Textarea as Textarea24, Alert as Alert15 } from "@mantine/core";
11031
+ import { Survey as Survey3, SurveyModel as SurveyModel3 } from "@ixo/surveys";
11032
+ import { IconCheck as IconCheck2, IconX as IconX4, IconAlertCircle as IconAlertCircle4 } from "@tabler/icons-react";
11033
+ var SURVEY_THEME_VARIABLES2 = Object.entries(surveyTheme.cssVariables ?? {}).reduce((acc, [key, value]) => {
11034
+ acc[key] = value;
11035
+ return acc;
11036
+ }, {});
11037
+ var SURVEY_THEME_BACKGROUND2 = SURVEY_THEME_VARIABLES2["--sjs-general-backcolor"] ?? "#050505";
11038
+ var SURVEY_THEME_FOREGROUND2 = SURVEY_THEME_VARIABLES2["--sjs-general-forecolor"] ?? "#ffffff";
11039
+ var BidViewPanel = ({ bid, deedId, adminAddress, onRefresh }) => {
11040
+ const { closePanel } = usePanelStore();
11041
+ const handlers = useBlocknoteHandlers();
11042
+ const [surveyJson, setSurveyJson] = useState37(null);
11043
+ const [loading, setLoading] = useState37(true);
11044
+ const [error, setError] = useState37(null);
11045
+ const [actionLoading, setActionLoading] = useState37(false);
11046
+ const [actionError, setActionError] = useState37(null);
11047
+ const [rejectModalOpen, setRejectModalOpen] = useState37(false);
11048
+ const [rejectReason, setRejectReason] = useState37("");
11049
+ useEffect26(() => {
11050
+ const fetchSurveyTemplate = async () => {
11051
+ try {
11052
+ setLoading(true);
11053
+ setError(null);
11054
+ let result;
11055
+ if (bid.role === "service_agent" || bid.role === "SA") {
11056
+ result = await handlers.getBidContributorSurveyTemplate(deedId);
11057
+ } else if (bid.role === "evaluation_agent" || bid.role === "EA") {
11058
+ result = await handlers.getBidEvaluatorSurveyTemplate(deedId);
11059
+ } else {
11060
+ setError(`Unknown role: ${bid.role}`);
11061
+ setLoading(false);
11062
+ return;
11063
+ }
11064
+ if (result) {
11065
+ setSurveyJson(result.surveyTemplate);
11066
+ } else {
11067
+ setError("No survey template found for this role");
11068
+ }
11069
+ } catch (err) {
11070
+ console.error("Error fetching survey template:", err);
11071
+ setError(err instanceof Error ? err.message : "Failed to load survey template");
11072
+ } finally {
11073
+ setLoading(false);
11074
+ }
11075
+ };
11076
+ fetchSurveyTemplate();
11077
+ }, [deedId, bid.role, handlers]);
11078
+ const surveyModel = useMemo27(() => {
11079
+ if (!surveyJson) return null;
11080
+ const model = new SurveyModel3(surveyJson);
11081
+ model.applyTheme(surveyTheme);
11082
+ model.showQuestionNumbers = "off";
11083
+ model.questionsOnPageMode = "singlePage";
11084
+ model.mode = "display";
11085
+ let bidData;
11086
+ try {
11087
+ bidData = typeof bid.data === "string" ? JSON.parse(bid.data) : bid.data;
11088
+ } catch {
11089
+ bidData = bid.data;
11090
+ }
11091
+ model.data = bidData;
11092
+ return model;
11093
+ }, [surveyJson, bid.data]);
11094
+ const surveyContainerStyle = useMemo27(
11095
+ () => ({
11096
+ flex: 1,
11097
+ overflow: "auto",
11098
+ backgroundColor: SURVEY_THEME_BACKGROUND2,
11099
+ color: SURVEY_THEME_FOREGROUND2,
11100
+ ...SURVEY_THEME_VARIABLES2
11101
+ }),
11102
+ []
11103
+ );
11104
+ const getRoleLabel = (role) => {
11105
+ if (role === "service_agent" || role === "SA") return "Service Agent";
11106
+ if (role === "evaluation_agent" || role === "EA") return "Evaluation Agent";
11107
+ return role;
11108
+ };
11109
+ const getRoleBadge = (role) => {
11110
+ const roleConfig = {
11111
+ service_agent: { color: "blue", label: "Service Agent" },
11112
+ SA: { color: "blue", label: "Service Agent" },
11113
+ evaluation_agent: { color: "green", label: "Evaluation Agent" },
11114
+ EA: { color: "green", label: "Evaluation Agent" }
11115
+ };
11116
+ const config = roleConfig[role] || { color: "gray", label: role };
11117
+ return /* @__PURE__ */ React125.createElement(Badge18, { size: "sm", color: config.color }, config.label);
11118
+ };
11119
+ const handleApproveBid = async () => {
11120
+ try {
11121
+ setActionLoading(true);
11122
+ setActionError(null);
11123
+ if (bid.role === "service_agent" || bid.role === "SA") {
11124
+ await handlers.approveServiceAgentApplication({
11125
+ adminAddress,
11126
+ collectionId: bid.collection,
11127
+ agentQuota: 30,
11128
+ deedDid: deedId,
11129
+ currentUserAddress: bid.address
11130
+ });
11131
+ } else if (bid.role === "evaluation_agent" || bid.role === "EA") {
11132
+ await handlers.approveEvaluatorApplication({
11133
+ adminAddress,
11134
+ collectionId: bid.collection,
11135
+ deedDid: deedId,
11136
+ evaluatorAddress: bid.address,
11137
+ agentQuota: 10
11138
+ });
11139
+ } else {
11140
+ throw new Error(`Unknown role: ${bid.role}`);
11141
+ }
11142
+ await handlers.approveBid({
11143
+ bidId: bid.id,
11144
+ collectionId: bid.collection,
11145
+ did: bid.did
11146
+ });
11147
+ closePanel();
11148
+ onRefresh?.();
11149
+ } catch (err) {
11150
+ console.error("Error approving bid:", err);
11151
+ setActionError(err instanceof Error ? err.message : "Failed to approve bid");
11152
+ } finally {
11153
+ setActionLoading(false);
11154
+ }
11155
+ };
11156
+ const handleRejectBid = async () => {
11157
+ if (!rejectReason.trim()) {
11158
+ setActionError("Please provide a reason for rejection");
11159
+ return;
11160
+ }
11161
+ try {
11162
+ setActionLoading(true);
11163
+ setActionError(null);
11164
+ await handlers.rejectBid({
11165
+ bidId: bid.id,
11166
+ collectionId: bid.collection,
11167
+ did: deedId,
11168
+ reason: rejectReason
11169
+ });
11170
+ setRejectModalOpen(false);
11171
+ closePanel();
11172
+ onRefresh?.();
11173
+ } catch (err) {
11174
+ console.error("Error rejecting bid:", err);
11175
+ setActionError(err instanceof Error ? err.message : "Failed to reject bid");
11176
+ } finally {
11177
+ setActionLoading(false);
11178
+ }
11179
+ };
11180
+ const openRejectModal = () => {
11181
+ setRejectReason("");
11182
+ setActionError(null);
11183
+ setRejectModalOpen(true);
11184
+ };
11185
+ return /* @__PURE__ */ React125.createElement(
11186
+ Paper16,
11187
+ {
11188
+ p: "md",
11189
+ shadow: "sm",
11190
+ style: {
11191
+ height: "100%",
11192
+ display: "flex",
11193
+ flexDirection: "column"
11194
+ }
11195
+ },
11196
+ /* @__PURE__ */ React125.createElement(
11197
+ "div",
11198
+ {
11199
+ style: {
11200
+ display: "flex",
11201
+ justifyContent: "space-between",
11202
+ alignItems: "center",
11203
+ marginBottom: "1rem"
11204
+ }
11205
+ },
11206
+ /* @__PURE__ */ React125.createElement(Stack91, { gap: "xs" }, /* @__PURE__ */ React125.createElement(Title14, { order: 3 }, getRoleLabel(bid.role), " Bid"), getRoleBadge(bid.role)),
11207
+ /* @__PURE__ */ React125.createElement(CloseButton12, { onClick: closePanel })
11208
+ ),
11209
+ !loading && !error && /* @__PURE__ */ React125.createElement(Stack91, { gap: "md", mb: "md" }, actionError && /* @__PURE__ */ React125.createElement(Alert15, { color: "red", icon: /* @__PURE__ */ React125.createElement(IconAlertCircle4, { size: 16 }), onClose: () => setActionError(null), withCloseButton: true }, actionError), /* @__PURE__ */ React125.createElement(Group40, { justify: "flex-end" }, /* @__PURE__ */ React125.createElement(Button30, { variant: "outline", color: "red", leftSection: /* @__PURE__ */ React125.createElement(IconX4, { size: 16 }), onClick: openRejectModal, loading: actionLoading, disabled: actionLoading }, "Reject"), /* @__PURE__ */ React125.createElement(Button30, { variant: "filled", color: "green", leftSection: /* @__PURE__ */ React125.createElement(IconCheck2, { size: 16 }), onClick: handleApproveBid, loading: actionLoading, disabled: actionLoading }, "Approve"))),
11210
+ /* @__PURE__ */ React125.createElement("div", { style: surveyContainerStyle }, loading && /* @__PURE__ */ React125.createElement(Stack91, { align: "center", justify: "center", style: { height: "100%" } }, /* @__PURE__ */ React125.createElement(Loader12, { size: "lg" }), /* @__PURE__ */ React125.createElement(Text66, { size: "sm", c: "dimmed" }, "Loading bid details...")), error && /* @__PURE__ */ React125.createElement(Stack91, { align: "center", justify: "center", style: { height: "100%", padding: "1rem" } }, /* @__PURE__ */ React125.createElement(Text66, { size: "sm", c: "red" }, error)), !loading && !error && surveyModel && /* @__PURE__ */ React125.createElement(Survey3, { model: surveyModel })),
11211
+ /* @__PURE__ */ React125.createElement(Modal2, { opened: rejectModalOpen, onClose: () => setRejectModalOpen(false), title: "Reject Bid", centered: true }, /* @__PURE__ */ React125.createElement(Stack91, { gap: "md" }, /* @__PURE__ */ React125.createElement(Text66, { size: "sm" }, "Please provide a reason for rejecting this bid:"), /* @__PURE__ */ React125.createElement(Textarea24, { placeholder: "Enter rejection reason...", value: rejectReason, onChange: (e) => setRejectReason(e.currentTarget.value), minRows: 3 }), /* @__PURE__ */ React125.createElement(Group40, { justify: "flex-end" }, /* @__PURE__ */ React125.createElement(Button30, { variant: "outline", onClick: () => setRejectModalOpen(false), disabled: actionLoading }, "Cancel"), /* @__PURE__ */ React125.createElement(Button30, { color: "red", onClick: handleRejectBid, loading: actionLoading, disabled: !rejectReason.trim() }, "Reject Bid"))))
11212
+ );
11213
+ };
11214
+
11215
+ // src/mantine/blocks/bid/flow/BidsList.tsx
11216
+ var BidItem = ({ bid, deedId, adminAddress, onRefresh }) => {
11217
+ const handlers = useBlocknoteHandlers();
11218
+ const [userProfile, setUserProfile] = useState38(null);
11219
+ const [loadingProfile, setLoadingProfile] = useState38(false);
11220
+ useEffect27(() => {
11221
+ const fetchUserProfile = async () => {
11222
+ if (!bid.did) return;
11223
+ try {
11224
+ setLoadingProfile(true);
11225
+ const profile = await handlers.getMatrixInfoPerDid(bid.did);
11226
+ setUserProfile(profile);
11227
+ } catch (error) {
11228
+ console.error("Failed to fetch user profile:", error);
11229
+ } finally {
11230
+ setLoadingProfile(false);
11231
+ }
11232
+ };
11233
+ fetchUserProfile();
11234
+ }, [bid.did, handlers]);
11235
+ const bidPanelId = `bid-view-${bid.id}`;
11236
+ const bidPanelContent = useMemo28(() => /* @__PURE__ */ React126.createElement(BidViewPanel, { bid, deedId, adminAddress, onRefresh }), [bid, deedId, adminAddress, onRefresh]);
11237
+ const { open: openBidPanel } = usePanel(bidPanelId, bidPanelContent);
11238
+ const displayName = userProfile?.displayname || bid.did;
11239
+ const getRoleBadge = (role) => {
11240
+ const roleConfig = {
11241
+ service_agent: { color: "blue", label: "Service Agent" },
11242
+ SA: { color: "blue", label: "Service Agent" },
11243
+ evaluation_agent: { color: "green", label: "Evaluation Agent" },
11244
+ EA: { color: "green", label: "Evaluation Agent" }
11245
+ };
11246
+ const config = roleConfig[role] || { color: "gray", label: role };
11247
+ return /* @__PURE__ */ React126.createElement(Badge19, { size: "xs", variant: "light", color: config.color }, config.label);
11248
+ };
11249
+ const getStatusBadge = (status) => {
11250
+ const statusConfig = {
11251
+ pending: { color: "yellow", label: "Pending" },
11252
+ approved: { color: "green", label: "Approved" },
11253
+ rejected: { color: "red", label: "Rejected" }
11254
+ };
11255
+ const config = statusConfig[status] || { color: "gray", label: status };
11256
+ return /* @__PURE__ */ React126.createElement(Badge19, { size: "sm", color: config.color }, config.label);
11257
+ };
11258
+ const formatDate = (dateString) => {
11259
+ try {
11260
+ const date = new Date(dateString);
11261
+ return date.toLocaleDateString(void 0, {
11262
+ year: "numeric",
11263
+ month: "short",
11264
+ day: "numeric"
11265
+ });
11266
+ } catch {
11267
+ return dateString;
11268
+ }
11269
+ };
11270
+ const displayDate = bid.created || "";
11271
+ const displayStatus = bid.status;
11272
+ const displayReason = bid.reason;
11273
+ return /* @__PURE__ */ React126.createElement(ListItemContainer, null, /* @__PURE__ */ React126.createElement(Stack92, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React126.createElement(Group41, { gap: "xs" }, /* @__PURE__ */ React126.createElement(Text67, { size: "xs", fw: 500 }, loadingProfile ? "Loading..." : displayName), userProfile?.verified && /* @__PURE__ */ React126.createElement(Text67, { size: "xs", c: "blue", fw: 600, title: "Verified user" }, "\u2713"), getRoleBadge(bid.role)), /* @__PURE__ */ React126.createElement(Text67, { size: "xs", c: "dimmed" }, "Submitted: ", formatDate(displayDate)), displayStatus === "rejected" && displayReason && /* @__PURE__ */ React126.createElement(Text67, { size: "xs", c: "red" }, "Reason: ", displayReason)), /* @__PURE__ */ React126.createElement(Group41, { gap: "xs" }, displayStatus && getStatusBadge(displayStatus), /* @__PURE__ */ React126.createElement(ActionIcon25, { variant: "subtle", size: "lg", onClick: openBidPanel }, /* @__PURE__ */ React126.createElement(IconArrowRight3, { size: 20 }))));
11274
+ };
11275
+ var BidsList = ({ collectionId, deedId, adminAddress, onRefresh }) => {
11276
+ const handlers = useBlocknoteHandlers();
11277
+ const [bids, setBids] = useState38([]);
11278
+ const [loading, setLoading] = useState38(true);
11279
+ const [error, setError] = useState38(null);
11280
+ const fetchBids = useCallback27(async () => {
11281
+ if (!collectionId) {
11282
+ setLoading(false);
11283
+ return;
11284
+ }
11285
+ try {
11286
+ setLoading(true);
11287
+ setError(null);
11288
+ const response = await handlers.queryBids({ collectionId });
11289
+ setBids(response?.data || []);
11290
+ } catch (err) {
11291
+ console.error("Error fetching bids:", err);
11292
+ setError(err instanceof Error ? err.message : "Failed to fetch bids");
11293
+ setBids([]);
11294
+ } finally {
11295
+ setLoading(false);
11296
+ }
11297
+ }, [collectionId, handlers]);
11298
+ useEffect27(() => {
11299
+ fetchBids();
11300
+ }, [fetchBids]);
11301
+ const handleRefresh = useCallback27(() => {
11302
+ fetchBids();
11303
+ onRefresh();
11304
+ }, [fetchBids, onRefresh]);
11305
+ if (loading) {
11306
+ return /* @__PURE__ */ React126.createElement(Center6, { py: "md" }, /* @__PURE__ */ React126.createElement(Loader13, { size: "sm" }));
11307
+ }
11308
+ if (error) {
11309
+ return /* @__PURE__ */ React126.createElement(Alert16, { color: "red", icon: /* @__PURE__ */ React126.createElement(IconAlertCircle5, { size: 16 }), py: "xs" }, /* @__PURE__ */ React126.createElement(Text67, { size: "xs" }, error));
11310
+ }
11311
+ if (!bids || bids.length === 0) {
11312
+ return /* @__PURE__ */ React126.createElement(Text67, { size: "xs", c: "dimmed", ta: "center", py: "sm" }, "No bids submitted yet");
11313
+ }
11314
+ return /* @__PURE__ */ React126.createElement(Stack92, { gap: "xs", pl: "md" }, bids.map((bid) => /* @__PURE__ */ React126.createElement(BidItem, { key: bid.id, bid, deedId, adminAddress, onRefresh: handleRefresh })));
11315
+ };
11316
+
11317
+ // src/mantine/blocks/bid/flow/ClaimCollectionsList.tsx
11318
+ var CollectionItem2 = ({ collection, deedId, adminAddress, userRole, onRefresh }) => {
11319
+ const [isExpanded, setIsExpanded] = useState39(false);
11320
+ const getCollectionName = (collection2) => {
11321
+ return collection2.protocol?.profile?.name || collection2.name || "Unnamed Collection";
11322
+ };
11323
+ const getRoleBadge = (role) => {
11324
+ const roleConfig = {
11325
+ ["SA" /* ServiceProvider */]: { label: "Service Agent", color: "blue" },
11326
+ ["EA" /* Evaluator */]: { label: "Evaluation Agent", color: "green" },
11327
+ ["PO" /* Owner */]: { label: "Owner", color: "violet" },
11328
+ ["IA" /* Investor */]: { label: "Investor", color: "orange" }
11329
+ };
11330
+ const config = roleConfig[role] || { label: role, color: "gray" };
11331
+ return /* @__PURE__ */ React127.createElement(Badge20, { size: "sm", color: config.color }, config.label);
11332
+ };
11333
+ const serviceAgentPanelId = `bid-survey-${collection.id}-service_agent`;
11334
+ const serviceAgentPanelContent = useMemo29(
11335
+ () => /* @__PURE__ */ React127.createElement(
11336
+ BidSurveyPanel,
11337
+ {
11338
+ deedId,
11339
+ collectionId: collection.id,
11340
+ role: "service_agent",
11341
+ onSubmitComplete: onRefresh
11342
+ }
11343
+ ),
11344
+ [deedId, collection.id, onRefresh]
11345
+ );
11346
+ const { open: openServiceAgent } = usePanel(serviceAgentPanelId, serviceAgentPanelContent);
11347
+ const evaluationAgentPanelId = `bid-survey-${collection.id}-evaluation_agent`;
11348
+ const evaluationAgentPanelContent = useMemo29(
11349
+ () => /* @__PURE__ */ React127.createElement(
11350
+ BidSurveyPanel,
11351
+ {
11352
+ deedId,
11353
+ collectionId: collection.id,
11354
+ role: "evaluation_agent",
11355
+ onSubmitComplete: onRefresh
11356
+ }
11357
+ ),
11358
+ [deedId, collection.id, onRefresh]
11359
+ );
11360
+ const { open: openEvaluationAgent } = usePanel(evaluationAgentPanelId, evaluationAgentPanelContent);
11361
+ const renderActionButton = () => {
11362
+ if (userRole === "PO" /* Owner */) {
11363
+ return /* @__PURE__ */ React127.createElement(ActionIcon26, { variant: "subtle", size: "lg", onClick: () => setIsExpanded(!isExpanded) }, isExpanded ? /* @__PURE__ */ React127.createElement(IconArrowUp3, { size: 20 }) : /* @__PURE__ */ React127.createElement(IconArrowDown3, { size: 20 }));
11364
+ } else if (userRole === "SA" /* ServiceProvider */ || userRole === "EA" /* Evaluator */) {
11365
+ return getRoleBadge(userRole);
11366
+ } else {
11367
+ return /* @__PURE__ */ React127.createElement(Menu2, { shadow: "md", width: 200 }, /* @__PURE__ */ React127.createElement(Menu2.Target, null, /* @__PURE__ */ React127.createElement(Button31, { size: "xs", variant: "light", rightSection: /* @__PURE__ */ React127.createElement(IconChevronDown4, { size: 14 }) }, "Apply")), /* @__PURE__ */ React127.createElement(Menu2.Dropdown, null, /* @__PURE__ */ React127.createElement(Menu2.Label, null, "Select Role"), /* @__PURE__ */ React127.createElement(Menu2.Item, { onClick: openServiceAgent }, "Service Agent"), /* @__PURE__ */ React127.createElement(Menu2.Item, { onClick: openEvaluationAgent }, "Evaluation Agent")));
11368
+ }
11369
+ };
11370
+ return /* @__PURE__ */ React127.createElement(Stack93, { gap: "xs" }, /* @__PURE__ */ React127.createElement(ListItemContainer, null, /* @__PURE__ */ React127.createElement(Stack93, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React127.createElement(Text68, { size: "sm", fw: 500 }, getCollectionName(collection)), collection.description && /* @__PURE__ */ React127.createElement(Text68, { size: "xs", c: "dimmed" }, collection.description)), renderActionButton()), userRole === "PO" /* Owner */ && /* @__PURE__ */ React127.createElement(Collapse4, { in: isExpanded }, /* @__PURE__ */ React127.createElement(BidsList, { collectionId: collection.id, deedId, adminAddress, onRefresh })));
11371
+ };
11372
+ var ClaimCollectionsList2 = ({ collections, deedId, adminAddress, userAddress, onRefresh }) => {
11373
+ const handlers = useBlocknoteHandlers();
11374
+ const [userRoles, setUserRoles] = useState39({});
11375
+ const [loadingRoles, setLoadingRoles] = useState39(true);
11376
+ useEffect28(() => {
11377
+ const fetchUserRoles = async () => {
11378
+ if (!collections || collections.length === 0 || !userAddress || !adminAddress) {
11379
+ setLoadingRoles(false);
11380
+ return;
11381
+ }
11382
+ try {
11383
+ setLoadingRoles(true);
11384
+ const collectionIds = collections.map((c) => c.id);
11385
+ const roles = await handlers.getUserRoles({
11386
+ userAddress,
11387
+ adminAddress,
11388
+ deedDid: deedId,
11389
+ collectionIds
11390
+ });
11391
+ const rolesMap = {};
11392
+ collections.forEach((collection) => {
11393
+ const roleData = roles?.find((r) => r.collectionId === collection.id);
11394
+ rolesMap[collection.id] = roleData?.role || null;
11395
+ });
11396
+ setUserRoles(rolesMap);
11397
+ } catch (error) {
11398
+ console.error("Error fetching user roles:", error);
11399
+ const rolesMap = {};
11400
+ collections.forEach((collection) => {
11401
+ rolesMap[collection.id] = null;
11402
+ });
11403
+ setUserRoles(rolesMap);
11404
+ } finally {
11405
+ setLoadingRoles(false);
11406
+ }
11407
+ };
11408
+ fetchUserRoles();
11409
+ }, [collections, userAddress, adminAddress, handlers, deedId]);
11410
+ if (!collections || collections.length === 0) {
11411
+ return /* @__PURE__ */ React127.createElement(Text68, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No claim collections found");
11412
+ }
11413
+ if (loadingRoles) {
11414
+ return /* @__PURE__ */ React127.createElement(Center7, { py: "md" }, /* @__PURE__ */ React127.createElement(Loader14, { size: "sm" }));
11415
+ }
11416
+ return /* @__PURE__ */ React127.createElement(Stack93, { gap: "md", px: 5 }, collections.map((collection) => /* @__PURE__ */ React127.createElement(CollectionItem2, { key: collection.id, collection, deedId, adminAddress, userRole: userRoles[collection.id] || null, onRefresh })));
11417
+ };
11418
+
11419
+ // src/mantine/blocks/bid/flow/FlowView.tsx
11420
+ var BID_FLOW_PANEL_ID = "bid-flow-panel";
11421
+ var BidFlowView = ({ editor, block }) => {
11422
+ const { editable } = useBlocknoteContext();
11423
+ const handlers = useBlocknoteHandlers();
11424
+ const [collections, setCollections] = useState40([]);
11425
+ const [loading, setLoading] = useState40(false);
11426
+ const [error, setError] = useState40(null);
11427
+ const [userAddress, setUserAddress] = useState40("");
11428
+ const panelId = `${BID_FLOW_PANEL_ID}-${block.id}`;
11429
+ const panelContent = useMemo30(() => /* @__PURE__ */ React128.createElement(TemplateConfig7, { editor, block }), [editor, block]);
11430
+ const { open } = usePanel(panelId, panelContent);
11431
+ const selectedCollectionIds = useMemo30(() => {
11432
+ try {
11433
+ return JSON.parse(block.props.selectedCollections || "[]");
11434
+ } catch {
11435
+ return [];
11436
+ }
11437
+ }, [block.props.selectedCollections]);
11438
+ const did = block.props.did;
11439
+ const adminAddress = block.props.adminAddress || "";
11440
+ useEffect29(() => {
11441
+ const fetchUserAddress = () => {
11442
+ try {
11443
+ const user = handlers.getCurrentUser();
11444
+ setUserAddress(user?.address || "");
11445
+ } catch (err) {
11446
+ console.error("Error fetching current user:", err);
11447
+ setUserAddress("");
11448
+ }
11449
+ };
11450
+ fetchUserAddress();
11451
+ }, [handlers]);
11452
+ const fetchCollections = useCallback28(async () => {
11453
+ if (!did || selectedCollectionIds.length === 0) {
11454
+ setCollections([]);
11455
+ return;
11456
+ }
11457
+ setLoading(true);
11458
+ setError(null);
11459
+ try {
11460
+ const response = await handlers.getClaimCollections({ deedDid: did });
11461
+ const { adminAddress: adminAddress2, collections: allCollections } = response || { adminAddress: "", collections: [] };
11462
+ if (adminAddress2 && (!block.props.adminAddress || block.props.adminAddress === "")) {
11463
+ editor.updateBlock(block, {
11464
+ props: {
11465
+ ...block.props,
11466
+ adminAddress: adminAddress2
11467
+ }
11468
+ });
11469
+ }
11470
+ const selectedCollections = (allCollections || []).filter((c) => selectedCollectionIds.includes(c?.id));
11471
+ setCollections(selectedCollections);
11472
+ } catch (err) {
11473
+ console.error("Error fetching collections:", err);
11474
+ setError(err instanceof Error ? err.message : "Failed to fetch collections");
11475
+ } finally {
11476
+ setLoading(false);
11477
+ }
11478
+ }, [did, selectedCollectionIds, handlers, editor, block]);
11479
+ useEffect29(() => {
11480
+ fetchCollections();
11481
+ }, [fetchCollections]);
11482
+ if (!did) {
11483
+ return /* @__PURE__ */ React128.createElement(Center8, { py: "xl" }, /* @__PURE__ */ React128.createElement(Text69, { size: "sm", c: "dimmed" }, "Please configure the bid block in template mode first"));
11484
+ }
11485
+ if (selectedCollectionIds.length === 0) {
11486
+ return /* @__PURE__ */ React128.createElement(Center8, { py: "xl" }, /* @__PURE__ */ React128.createElement(Text69, { size: "sm", c: "dimmed" }, "No claim collections selected"));
11487
+ }
11488
+ return /* @__PURE__ */ React128.createElement(Stack94, { w: "100%" }, /* @__PURE__ */ React128.createElement(Flex23, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React128.createElement(Title15, { order: 4 }, "Bid Application"), /* @__PURE__ */ React128.createElement(Flex23, { gap: "xs" }, /* @__PURE__ */ React128.createElement(ActionIcon27, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React128.createElement(IconRefresh3, { size: 18 })), editable && /* @__PURE__ */ React128.createElement(ActionIcon27, { variant: "subtle", size: "sm", onClick: open }, /* @__PURE__ */ React128.createElement(IconSettings4, { size: 18 })))), loading ? /* @__PURE__ */ React128.createElement(Center8, { py: "xl" }, /* @__PURE__ */ React128.createElement(Loader15, { size: "md" })) : error ? /* @__PURE__ */ React128.createElement(Alert17, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React128.createElement(IconAlertCircle6, { size: 18 }) }, /* @__PURE__ */ React128.createElement(Text69, { size: "sm" }, error)) : /* @__PURE__ */ React128.createElement(ClaimCollectionsList2, { collections, deedId: did, adminAddress, userAddress, onRefresh: fetchCollections }));
11489
+ };
11490
+
11491
+ // src/mantine/blocks/bid/BidBlock.tsx
11492
+ function BidBlock({ editor, block }) {
11493
+ const { docType } = useBlocknoteContext();
11494
+ if (docType === "template") {
11495
+ return /* @__PURE__ */ React129.createElement(BidTemplateView, { editor, block });
11496
+ }
11497
+ return /* @__PURE__ */ React129.createElement(BidFlowView, { editor, block });
11498
+ }
11499
+
11500
+ // src/mantine/blocks/bid/BidBlockSpec.tsx
11501
+ var BidBlockSpec = createReactBlockSpec9(
11502
+ {
11503
+ type: "bid",
11504
+ propSchema: {
11505
+ title: { default: "" },
11506
+ description: { default: "" },
11507
+ did: { default: "" },
11508
+ selectedCollections: { default: "[]" },
11509
+ adminAddress: { default: "" }
11510
+ },
11511
+ content: "none"
11512
+ },
11513
+ {
11514
+ render: (props) => {
11515
+ const ixoProps = props;
11516
+ return /* @__PURE__ */ React130.createElement(BidBlock, { ...ixoProps });
11517
+ }
11518
+ }
11519
+ );
11520
+
11521
+ // src/mantine/blocks/evaluator/EvaluatorBlock.tsx
11522
+ import React137 from "react";
11523
+
11524
+ // src/mantine/blocks/evaluator/template/TemplateView.tsx
11525
+ import React133, { useMemo as useMemo32 } from "react";
11526
+ import { Card as Card26, Group as Group42, Stack as Stack96, Text as Text71, ActionIcon as ActionIcon28, Badge as Badge21 } from "@mantine/core";
11527
+
11528
+ // src/mantine/blocks/evaluator/template/TemplateConfig.tsx
11529
+ import React132, { useCallback as useCallback30 } from "react";
11530
+ import { Paper as Paper17, CloseButton as CloseButton13, Title as Title16 } from "@mantine/core";
11531
+
11532
+ // src/mantine/blocks/evaluator/template/GeneralTab.tsx
11533
+ import React131, { useEffect as useEffect30, useState as useState41, useCallback as useCallback29, useMemo as useMemo31 } from "react";
11534
+ import { Stack as Stack95, Text as Text70, TextInput as TextInput41, Textarea as Textarea25 } from "@mantine/core";
11535
+ var GeneralTab8 = ({
11536
+ title,
11537
+ description,
11538
+ deedDid,
11539
+ selectedCollections,
11540
+ adminAddress,
11541
+ onTitleChange,
11542
+ onDescriptionChange,
11543
+ onDeedDidChange,
11544
+ onSelectedCollectionsChange,
11545
+ onAdminAddressChange
11546
+ }) => {
11547
+ const [localTitle, setLocalTitle] = useState41(title || "");
11548
+ const [localDescription, setLocalDescription] = useState41(description || "");
11549
+ useEffect30(() => {
11550
+ setLocalTitle(title || "");
11551
+ }, [title]);
11552
+ useEffect30(() => {
11553
+ setLocalDescription(description || "");
11554
+ }, [description]);
11555
+ const parsedSelectedCollections = useMemo31(() => {
11556
+ try {
11557
+ return JSON.parse(selectedCollections || "[]");
11558
+ } catch {
11559
+ return [];
11560
+ }
11561
+ }, [selectedCollections]);
11562
+ const handleCollectionsChange = useCallback29(
11563
+ (collections) => {
11564
+ console.log("[Evaluator GeneralTab] handleCollectionsChange called with:", collections);
11565
+ const stringified = JSON.stringify(collections || []);
11566
+ console.log("[Evaluator GeneralTab] Stringified:", stringified);
11567
+ onSelectedCollectionsChange(stringified);
11568
+ },
11569
+ [onSelectedCollectionsChange]
11570
+ );
11571
+ const handleAdminAddressChange = useCallback29(
11572
+ (adminAddress2) => {
11573
+ if (onAdminAddressChange) {
11574
+ onAdminAddressChange(adminAddress2);
11575
+ }
11576
+ },
11577
+ [onAdminAddressChange]
11578
+ );
11579
+ return /* @__PURE__ */ React131.createElement(Stack95, { gap: "lg" }, /* @__PURE__ */ React131.createElement(Stack95, { gap: "xs" }, /* @__PURE__ */ React131.createElement(Text70, { size: "sm", fw: 600 }, "Title"), /* @__PURE__ */ React131.createElement(
11580
+ TextInput41,
11581
+ {
11582
+ placeholder: "e.g. Evaluator Title",
11583
+ value: localTitle,
11584
+ onChange: (event) => {
11585
+ const newTitle = event.currentTarget.value;
11586
+ setLocalTitle(newTitle);
11587
+ onTitleChange(newTitle);
11588
+ }
11589
+ }
11590
+ )), /* @__PURE__ */ React131.createElement(Stack95, { gap: "xs" }, /* @__PURE__ */ React131.createElement(Text70, { size: "sm", fw: 600 }, "Description"), /* @__PURE__ */ React131.createElement(
11591
+ Textarea25,
11592
+ {
11593
+ placeholder: "Describe what this evaluator block is about",
11594
+ minRows: 3,
11595
+ value: localDescription,
11596
+ onChange: (event) => {
11597
+ const newDescription = event.currentTarget.value;
11598
+ setLocalDescription(newDescription);
11599
+ onDescriptionChange(newDescription);
11600
+ }
11601
+ }
11602
+ )), /* @__PURE__ */ React131.createElement(
11603
+ CollectionSelector,
11604
+ {
11605
+ did: deedDid,
11606
+ selectedCollections: parsedSelectedCollections,
11607
+ onDidChange: onDeedDidChange,
11608
+ onCollectionsChange: handleCollectionsChange,
11609
+ onAdminAddressChange: handleAdminAddressChange,
11610
+ currentAdminAddress: adminAddress
11611
+ }
11612
+ ));
11613
+ };
11614
+
11615
+ // src/mantine/blocks/evaluator/template/TemplateConfig.tsx
11616
+ var TemplateConfig8 = ({ editor, block }) => {
11617
+ const { closePanel } = usePanelStore();
11618
+ const updateProp = useCallback30(
11619
+ (key, value) => {
11620
+ console.log("[Evaluator TemplateConfig] Updating prop:", key, value);
11621
+ editor.updateBlock(block, {
11622
+ props: {
11623
+ ...block.props,
11624
+ [key]: value
11625
+ }
11626
+ });
11627
+ },
11628
+ [editor, block]
11629
+ );
11630
+ return /* @__PURE__ */ React132.createElement(
11631
+ Paper17,
11632
+ {
11633
+ p: "md",
11634
+ shadow: "sm",
11635
+ style: {
11636
+ height: "100%",
11637
+ display: "flex",
11638
+ flexDirection: "column"
11639
+ }
11640
+ },
11641
+ /* @__PURE__ */ React132.createElement(
11642
+ "div",
11643
+ {
11644
+ style: {
11645
+ display: "flex",
11646
+ justifyContent: "space-between",
11647
+ alignItems: "center",
11648
+ marginBottom: "1rem"
11649
+ }
11650
+ },
11651
+ /* @__PURE__ */ React132.createElement(Title16, { order: 3 }, "Evaluator Settings"),
11652
+ /* @__PURE__ */ React132.createElement(CloseButton13, { onClick: closePanel })
11653
+ ),
11654
+ /* @__PURE__ */ React132.createElement(
11655
+ ReusablePanel,
11656
+ {
11657
+ extraTabs: [
11658
+ {
11659
+ label: "General",
11660
+ value: "general",
11661
+ content: /* @__PURE__ */ React132.createElement(
11662
+ GeneralTab8,
11663
+ {
11664
+ title: block.props.title || "",
11665
+ description: block.props.description || "",
11666
+ deedDid: block.props.deedDid || "",
11667
+ selectedCollections: block.props.selectedCollections || "[]",
11668
+ adminAddress: block.props.adminAddress || "",
11669
+ onTitleChange: (value) => updateProp("title", value),
11670
+ onDescriptionChange: (value) => updateProp("description", value),
11671
+ onDeedDidChange: (value) => updateProp("deedDid", value),
11672
+ onSelectedCollectionsChange: (value) => updateProp("selectedCollections", value),
11673
+ onAdminAddressChange: (value) => updateProp("adminAddress", value)
11674
+ }
11675
+ )
11676
+ }
11677
+ ],
11678
+ context: { editor, block }
11679
+ }
11680
+ )
11681
+ );
11682
+ };
11683
+
11684
+ // src/mantine/blocks/evaluator/template/TemplateView.tsx
11685
+ var EVALUATOR_TEMPLATE_PANEL_ID = "evaluator-template-panel";
11686
+ var EvaluatorTemplateView = ({ editor, block }) => {
11687
+ const panelId = `${EVALUATOR_TEMPLATE_PANEL_ID}-${block.id}`;
11688
+ const panelContent = useMemo32(() => /* @__PURE__ */ React133.createElement(TemplateConfig8, { editor, block }), [editor, block]);
11689
+ const { open } = usePanel(panelId, panelContent);
11690
+ return /* @__PURE__ */ React133.createElement(Card26, { withBorder: true, padding: "md", radius: "md", style: { width: "100%", cursor: "pointer", position: "relative" }, onClick: open }, /* @__PURE__ */ React133.createElement(Badge21, { size: "xs", variant: "light", color: "gray", style: { position: "absolute", top: 8, right: 8 } }, "Template"), /* @__PURE__ */ React133.createElement(Group42, { wrap: "nowrap", justify: "space-between", align: "center" }, /* @__PURE__ */ React133.createElement(Group42, { wrap: "nowrap", align: "center" }, /* @__PURE__ */ React133.createElement(ActionIcon28, { variant: "light", color: "blue", size: "lg", radius: "xl", style: { flexShrink: 0 } }, getIcon(block.props.icon, 18, 1.5, "checklist")), /* @__PURE__ */ React133.createElement(Stack96, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React133.createElement(Text71, { fw: 500, size: "sm", contentEditable: false }, block.props.title || "Evaluator Title"), /* @__PURE__ */ React133.createElement(Text71, { size: "xs", c: "dimmed", contentEditable: false }, block.props.description || "Evaluator description")))));
11691
+ };
11692
+
11693
+ // src/mantine/blocks/evaluator/flow/FlowView.tsx
11694
+ import React136, { useState as useState44, useEffect as useEffect33, useMemo as useMemo35, useCallback as useCallback32 } from "react";
11695
+ import { Stack as Stack99, Text as Text74, Loader as Loader18, Center as Center10, Alert as Alert19, Title as Title18, Flex as Flex24, ActionIcon as ActionIcon31 } from "@mantine/core";
11696
+ import { IconSettings as IconSettings5, IconRefresh as IconRefresh5, IconAlertCircle as IconAlertCircle8 } from "@tabler/icons-react";
11697
+
11698
+ // src/mantine/blocks/evaluator/flow/ClaimCollectionsList.tsx
11699
+ import React135, { useMemo as useMemo34, useState as useState43, useEffect as useEffect32 } from "react";
11700
+ import { Stack as Stack98, Text as Text73, ActionIcon as ActionIcon30, Tooltip as Tooltip9, Loader as Loader17, Center as Center9 } from "@mantine/core";
11701
+
11702
+ // src/mantine/blocks/evaluator/flow/ClaimsList.tsx
11703
+ import React134, { useState as useState42, useEffect as useEffect31, useCallback as useCallback31, useMemo as useMemo33 } from "react";
11704
+ import { Paper as Paper18, CloseButton as CloseButton14, Title as Title17, Loader as Loader16, Stack as Stack97, Text as Text72, ActionIcon as ActionIcon29, Alert as Alert18, Badge as Badge22, Group as Group43, Button as Button32, Divider as Divider7 } from "@mantine/core";
11705
+ import { IconAlertCircle as IconAlertCircle7, IconArrowRight as IconArrowRight4, IconRefresh as IconRefresh4, IconArrowLeft as IconArrowLeft3 } from "@tabler/icons-react";
11706
+ import { Survey as Survey4, SurveyModel as SurveyModel4 } from "@ixo/surveys";
11707
+
11708
+ // src/mantine/blocks/evaluator/flow/theme.ts
11709
+ var IXO_PALETTE = {
11710
+ // Neutral
11711
+ Neutral50: "#FAFAFA",
11712
+ Neutral100: "#F8F8F8",
11713
+ Neutral200: "#F1F1F1",
11714
+ Neutral300: "#EBEBEB",
11715
+ Neutral500: "#D7D7D7",
11716
+ Neutral800: "#9A9A9A",
11717
+ Black: "#000000",
11718
+ // Neutral Dark
11719
+ NeutralDark50: "#050505",
11720
+ NeutralDark100: "#070707",
11721
+ NeutralDark200: "#0E0E0E",
11722
+ NeutralDark300: "#141414",
11723
+ NeutralDark500: "#282828",
11724
+ NeutralDark800: "#656565",
11725
+ // White
11726
+ White: "#FFFFFF",
11727
+ WhiteSecondary: "#D7ECE3",
11728
+ // EmergingBlue
11729
+ accentActive: "#0EB8DC",
11730
+ accentSecondary: "#20798C",
11731
+ accentHover: "#17C6EB",
11732
+ accentLight: "#ADEBF8",
11733
+ // CompanionBlue
11734
+ companionBlue: "#e8f9fd",
11735
+ // EmergingLighter
11736
+ accentLighter: "rgba(173,235,248,0.2)",
11737
+ accentDarker: "#296DAB",
11738
+ darkestBlue: "#000000",
11739
+ // Contribution
11740
+ contributionBlue: "rgba(22, 143, 168, 1)",
11741
+ // Danger
11742
+ dangerFull: "#E2223B",
11743
+ dangerBrighter: "#FCCFD5",
11744
+ dangerBright: "#F9909E",
11745
+ dangerDark: "#A11C43",
11746
+ // Success
11747
+ successFull: "#61B43A",
11748
+ successDarker: "#47822b",
11749
+ successBright: "#F4FCF0",
11750
+ successSecondary: "#1CBD6A",
11751
+ orangeFull: "#ED9526",
11752
+ orangeBright: "#FDC681",
11753
+ // Transparent
11754
+ transparent: "rgba(255, 255, 255, 0)",
11755
+ whiteTransparentDarker: "rgba(255, 255, 255, 0.10)",
11756
+ whiteTransparent: "rgba(255, 255, 255, 0.30)",
11757
+ whiteTransparentSecondary: "rgba(255, 255, 255, 0.65)",
11758
+ successTransparent: "rgba(67, 175, 98, 0.30)",
11759
+ // Glassmorphics
11760
+ glass: "rgba(255, 255, 255, 0.06)",
11761
+ glassGradient: "linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(153, 153, 153, 0.03) 100%)",
11762
+ glassDarker: "rgba(0, 0, 0, 0.5)",
11763
+ glassLighter: "rgba(255, 255, 255, 0.3)",
11764
+ // Gradients
11765
+ offsetCertificateGradient: "linear-gradient(45deg, rgba(59,152,51,1) 0%, rgba(70,193,193,1) 100%)",
11766
+ contributionCertificateGradient: "linear-gradient(45deg, rgba(22,143,168,1) 0%, rgba(30,204,183,1) 100%)",
11767
+ carbonCertificateGradient: "linear-gradient(55.09deg, rgba(54, 101, 135, 1) -2.49%, rgba(30, 173, 204, 1) 109.08%)",
11768
+ shadowGradient: "linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.2) 100%)"
11769
+ };
11770
+ var surveyTheme2 = {
11771
+ backgroundImageFit: "cover",
11772
+ backgroundImageAttachment: "scroll",
11773
+ backgroundOpacity: 0,
11774
+ cssVariables: {
11775
+ "-sjs-editorpanel-backcolor": IXO_PALETTE.glassDarker,
11776
+ "--sjs-editor-background": IXO_PALETTE.glassDarker,
11777
+ "--sjs-general-backcolor": IXO_PALETTE.Black,
11778
+ "--sjs-general-backcolor-dark": IXO_PALETTE.Black,
11779
+ "--sjs-general-backcolor-dim": IXO_PALETTE.transparent,
11780
+ "--sjs-general-backcolor-dim-light": IXO_PALETTE.glassDarker,
11781
+ "--sjs-general-backcolor-dim-dark": IXO_PALETTE.glassDarker,
11782
+ "--sjs-general-forecolor": IXO_PALETTE.White,
11783
+ "--sjs-general-forecolor-light": IXO_PALETTE.White,
11784
+ "--sjs-general-dim-forecolor": IXO_PALETTE.White,
11785
+ "--sjs-general-dim-forecolor-light": IXO_PALETTE.White,
11786
+ "--sjs-font-surveytitle-color": IXO_PALETTE.White,
11787
+ "--sjs-primary-backcolor": IXO_PALETTE.accentActive,
11788
+ "--sjs-primary-backcolor-light": IXO_PALETTE.accentLight,
11789
+ "--sjs-primary-backcolor-dark": IXO_PALETTE.accentHover,
11790
+ "--sjs-primary-forecolor": "rgba(255, 255, 255, 1)",
11791
+ "--sjs-primary-forecolor-light": "rgba(255, 255, 255, 0.25)",
11792
+ "--sjs-base-unit": "8px",
11793
+ "--sjs-editorpanel-cornerRadius": "30px",
11794
+ "--sjs-questionpanel-cornerRadius": "12px",
11795
+ "--sjs-secondary-backcolor": "rgba(255, 152, 20, 1)",
11796
+ "--sjs-secondary-backcolor-light": "rgba(255, 152, 20, 0.1)",
11797
+ "--sjs-secondary-backcolor-semi-light": "rgba(255, 152, 20, 0.25)",
11798
+ "--sjs-secondary-forecolor": "rgba(255, 255, 255, 1)",
11799
+ "--sjs-secondary-forecolor-light": "rgba(255, 255, 255, 0.25)",
11800
+ "--sjs-shadow-small": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
11801
+ "--sjs-shadow-small-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
11802
+ "--sjs-shadow-medium": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
11803
+ "--sjs-shadow-large": "0px 8px 16px 0px rgba(0, 0, 0, 0.1)",
11804
+ "--sjs-shadow-inner": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
11805
+ "--sjs-shadow-inner-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
11806
+ "--sjs-border-light": "rgba(0, 0, 0, 0.09)",
11807
+ "--sjs-border-default": "rgba(0, 0, 0, 0.16)",
11808
+ "--sjs-border-inside": "rgba(0, 0, 0, 0.16)",
11809
+ "--sjs-special-red": "rgba(229, 10, 62, 1)",
11810
+ "--sjs-special-red-light": "rgba(229, 10, 62, 0.1)",
11811
+ "--sjs-special-red-forecolor": "rgba(255, 255, 255, 1)",
11812
+ "--sjs-special-green": "rgba(25, 179, 148, 1)",
11813
+ "--sjs-special-green-light": "rgba(25, 179, 148, 0.1)",
11814
+ "--sjs-special-green-forecolor": "rgba(255, 255, 255, 1)",
11815
+ "--sjs-special-blue": "rgba(67, 127, 217, 1)",
11816
+ "--sjs-special-blue-light": "rgba(67, 127, 217, 0.1)",
11817
+ "--sjs-special-blue-forecolor": "rgba(255, 255, 255, 1)",
11818
+ "--sjs-special-yellow": "rgba(255, 152, 20, 1)",
11819
+ "--sjs-special-yellow-light": "rgba(255, 152, 20, 0.1)",
11820
+ "--sjs-special-yellow-forecolor": "rgba(255, 255, 255, 1)",
11821
+ "--sjs-article-font-xx-large-textDecoration": "none",
11822
+ "--sjs-article-font-xx-large-fontWeight": "700",
11823
+ "--sjs-article-font-xx-large-fontStyle": "normal",
11824
+ "--sjs-article-font-xx-large-fontStretch": "normal",
11825
+ "--sjs-article-font-xx-large-letterSpacing": "0",
11826
+ "--sjs-article-font-xx-large-lineHeight": "64px",
11827
+ "--sjs-article-font-xx-large-paragraphIndent": "0px",
11828
+ "--sjs-article-font-xx-large-textCase": "none",
11829
+ "--sjs-article-font-x-large-textDecoration": "none",
11830
+ "--sjs-article-font-x-large-fontWeight": "700",
11831
+ "--sjs-article-font-x-large-fontStyle": "normal",
11832
+ "--sjs-article-font-x-large-fontStretch": "normal",
11833
+ "--sjs-article-font-x-large-letterSpacing": "0",
11834
+ "--sjs-article-font-x-large-lineHeight": "56px",
11835
+ "--sjs-article-font-x-large-paragraphIndent": "0px",
11836
+ "--sjs-article-font-x-large-textCase": "none",
11837
+ "--sjs-article-font-large-textDecoration": "none",
11838
+ "--sjs-article-font-large-fontWeight": "700",
11839
+ "--sjs-article-font-large-fontStyle": "normal",
11840
+ "--sjs-article-font-large-fontStretch": "normal",
11841
+ "--sjs-article-font-large-letterSpacing": "0",
11842
+ "--sjs-article-font-large-lineHeight": "40px",
11843
+ "--sjs-article-font-large-paragraphIndent": "0px",
11844
+ "--sjs-article-font-large-textCase": "none",
11845
+ "--sjs-article-font-medium-textDecoration": "none",
11846
+ "--sjs-article-font-medium-fontWeight": "700",
11847
+ "--sjs-article-font-medium-fontStyle": "normal",
11848
+ "--sjs-article-font-medium-fontStretch": "normal",
11849
+ "--sjs-article-font-medium-letterSpacing": "0",
11850
+ "--sjs-article-font-medium-lineHeight": "32px",
11851
+ "--sjs-article-font-medium-paragraphIndent": "0px",
11852
+ "--sjs-article-font-medium-textCase": "none",
11853
+ "--sjs-article-font-default-textDecoration": "none",
11854
+ "--sjs-article-font-default-fontWeight": "400",
11855
+ "--sjs-article-font-default-fontStyle": "normal",
11856
+ "--sjs-article-font-default-fontStretch": "normal",
11857
+ "--sjs-article-font-default-letterSpacing": "0",
11858
+ "--sjs-article-font-default-lineHeight": "28px",
11859
+ "--sjs-article-font-default-paragraphIndent": "0px",
11860
+ "--sjs-article-font-default-textCase": "none"
11861
+ },
11862
+ themeName: "ixoTheme",
11863
+ colorPalette: "dark"
11864
+ };
11865
+
11866
+ // src/mantine/blocks/evaluator/flow/ClaimsList.tsx
11867
+ var SURVEY_THEME_VARIABLES3 = Object.entries(surveyTheme2.cssVariables ?? {}).reduce((acc, [key, value]) => {
11868
+ acc[key] = value;
11869
+ return acc;
11870
+ }, {});
11871
+ var SURVEY_THEME_BACKGROUND3 = SURVEY_THEME_VARIABLES3["--sjs-general-backcolor"] ?? "#050505";
11872
+ var SURVEY_THEME_FOREGROUND3 = SURVEY_THEME_VARIABLES3["--sjs-general-forecolor"] ?? "#ffffff";
11873
+ var ClaimsList = ({ collectionId, collectionName, deedId, adminAddress, onEvaluationComplete }) => {
11874
+ const { closePanel } = usePanelStore();
11875
+ const handlers = useBlocknoteHandlers();
11876
+ const [viewMode, setViewMode] = useState42("list");
11877
+ const [claims, setClaims] = useState42([]);
11878
+ const [loading, setLoading] = useState42(true);
11879
+ const [error, setError] = useState42(null);
11880
+ const [selectedClaim, setSelectedClaim] = useState42(null);
11881
+ const [claimData, setClaimData] = useState42(null);
11882
+ const [surveyJson, setSurveyJson] = useState42(null);
11883
+ const [surveyLoading, setSurveyLoading] = useState42(false);
11884
+ const [surveyError, setSurveyError] = useState42(null);
11885
+ const [evaluating, setEvaluating] = useState42(false);
11886
+ const fetchClaims = useCallback31(async () => {
11887
+ try {
11888
+ setLoading(true);
11889
+ setError(null);
11890
+ const result = await handlers.getClaimsPerCollectionId({
11891
+ collectionId
11892
+ });
11893
+ setClaims(result || []);
11894
+ } catch (err) {
11895
+ console.error("Error fetching claims:", err);
11896
+ setError(err instanceof Error ? err.message : "Failed to fetch claims");
11897
+ setClaims([]);
11898
+ } finally {
11899
+ setLoading(false);
11900
+ }
11901
+ }, [collectionId, handlers]);
11902
+ useEffect31(() => {
11903
+ fetchClaims();
11904
+ }, [fetchClaims]);
11905
+ const fetchClaimAndSurvey = useCallback31(
11906
+ async (claim) => {
11907
+ try {
11908
+ setSurveyLoading(true);
11909
+ setSurveyError(null);
11910
+ const claimDataResult = await handlers.getClaimData(collectionId, claim.claimId);
11911
+ setClaimData(claimDataResult);
11912
+ const surveyResult = await handlers.getBidContributorSurveyTemplate(deedId);
11913
+ if (surveyResult) {
11914
+ setSurveyJson(surveyResult.surveyTemplate);
11915
+ } else {
11916
+ setSurveyError("No survey template found for this deed");
11917
+ }
11918
+ } catch (err) {
11919
+ console.error("Error fetching claim data:", err);
11920
+ setSurveyError(err instanceof Error ? err.message : "Failed to load claim data");
11921
+ } finally {
11922
+ setSurveyLoading(false);
11923
+ }
11924
+ },
11925
+ [collectionId, deedId, handlers]
11926
+ );
11927
+ const handleViewClaim = useCallback31(
11928
+ (claim) => {
11929
+ setSelectedClaim(claim);
11930
+ fetchClaimAndSurvey(claim);
11931
+ setViewMode("survey");
11932
+ },
11933
+ [fetchClaimAndSurvey]
11934
+ );
11935
+ const handleBackToList = useCallback31(() => {
11936
+ setViewMode("list");
11937
+ setSelectedClaim(null);
11938
+ setClaimData(null);
11939
+ setSurveyJson(null);
11940
+ setSurveyError(null);
11941
+ setEvaluating(false);
11942
+ fetchClaims();
11943
+ }, [fetchClaims]);
11944
+ const surveyModel = useMemo33(() => {
11945
+ if (!surveyJson || !claimData) return null;
11946
+ const model = new SurveyModel4(surveyJson);
11947
+ model.applyTheme(surveyTheme2);
11948
+ model.showQuestionNumbers = "off";
11949
+ model.questionsOnPageMode = "singlePage";
11950
+ model.mode = "display";
11951
+ if (claimData) {
11952
+ model.data = claimData;
11953
+ }
11954
+ return model;
11955
+ }, [surveyJson, claimData]);
11956
+ const surveyContainerStyle = useMemo33(
11957
+ () => ({
11958
+ flex: 1,
11959
+ overflow: "auto",
11960
+ backgroundColor: SURVEY_THEME_BACKGROUND3,
11961
+ color: SURVEY_THEME_FOREGROUND3,
11962
+ ...SURVEY_THEME_VARIABLES3,
11963
+ padding: "1rem"
11964
+ }),
11965
+ []
11966
+ );
11967
+ const handleApprove = useCallback31(async () => {
11968
+ if (!selectedClaim) return;
11969
+ try {
11970
+ setEvaluating(true);
11971
+ setSurveyError(null);
11972
+ const currentUser = handlers.getCurrentUser();
11973
+ await handlers.evaluateClaim(
11974
+ currentUser.address,
11975
+ // granteeAddress (evaluator address)
11976
+ deedId,
11977
+ // deed DID
11978
+ {
11979
+ claimId: selectedClaim.claimId,
11980
+ collectionId,
11981
+ adminAddress,
11982
+ status: void 0,
11983
+ // Optional - pass undefined for now
11984
+ verificationProof: "",
11985
+ // Required - empty string for now
11986
+ amount: void 0
11987
+ // Optional - pass undefined for now
11988
+ }
11989
+ );
11990
+ console.log("Claim approved successfully:", selectedClaim.claimId);
11991
+ handleBackToList();
11992
+ } catch (error2) {
11993
+ console.error("Failed to approve claim:", error2);
11994
+ setSurveyError(error2 instanceof Error ? error2.message : "Failed to approve claim");
11995
+ setEvaluating(false);
11996
+ }
11997
+ }, [selectedClaim, handlers, deedId, collectionId, adminAddress, handleBackToList]);
11998
+ const handleReject = useCallback31(async () => {
11999
+ if (!selectedClaim) return;
12000
+ try {
12001
+ setEvaluating(true);
12002
+ setSurveyError(null);
12003
+ console.log("Rejecting claim:", selectedClaim.claimId);
12004
+ handleBackToList();
12005
+ } catch (error2) {
12006
+ console.error("Failed to reject claim:", error2);
12007
+ setSurveyError(error2 instanceof Error ? error2.message : "Failed to reject claim");
12008
+ } finally {
12009
+ setEvaluating(false);
12010
+ }
12011
+ }, [selectedClaim, handleBackToList]);
12012
+ return /* @__PURE__ */ React134.createElement(
12013
+ Paper18,
12014
+ {
12015
+ p: "md",
12016
+ shadow: "sm",
12017
+ style: {
12018
+ height: "100%",
12019
+ display: "flex",
12020
+ flexDirection: "column",
12021
+ overflow: "hidden"
12022
+ }
12023
+ },
12024
+ /* @__PURE__ */ React134.createElement(
12025
+ "div",
12026
+ {
12027
+ style: {
12028
+ display: "flex",
12029
+ justifyContent: "space-between",
12030
+ alignItems: "center",
12031
+ marginBottom: "1rem"
12032
+ }
12033
+ },
12034
+ /* @__PURE__ */ React134.createElement("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" } }, viewMode === "survey" && /* @__PURE__ */ React134.createElement(ActionIcon29, { variant: "subtle", onClick: handleBackToList }, /* @__PURE__ */ React134.createElement(IconArrowLeft3, { size: 20 })), /* @__PURE__ */ React134.createElement(Title17, { order: 3 }, viewMode === "list" ? `${collectionName} - Claims` : `Evaluate Claim #${selectedClaim?.claimId.slice(-8)}`), viewMode === "list" && !loading && claims.length > 0 && /* @__PURE__ */ React134.createElement(Badge22, { size: "lg", variant: "light" }, claims.length)),
12035
+ /* @__PURE__ */ React134.createElement(Group43, { gap: "xs" }, viewMode === "list" && /* @__PURE__ */ React134.createElement(ActionIcon29, { variant: "subtle", onClick: fetchClaims, loading, title: "Refresh claims" }, /* @__PURE__ */ React134.createElement(IconRefresh4, { size: 18 })), /* @__PURE__ */ React134.createElement(CloseButton14, { onClick: closePanel }))
12036
+ ),
12037
+ /* @__PURE__ */ React134.createElement(
12038
+ "div",
12039
+ {
12040
+ style: {
12041
+ flex: 1,
12042
+ overflow: "hidden",
12043
+ position: "relative"
12044
+ }
12045
+ },
12046
+ /* @__PURE__ */ React134.createElement(
12047
+ "div",
12048
+ {
12049
+ style: {
12050
+ position: "absolute",
12051
+ top: 0,
12052
+ left: 0,
12053
+ right: 0,
12054
+ bottom: 0,
12055
+ display: "flex",
12056
+ flexDirection: "column",
12057
+ overflow: "auto",
12058
+ transform: viewMode === "list" ? "translateX(0)" : "translateX(-100%)",
12059
+ opacity: viewMode === "list" ? 1 : 0,
12060
+ transition: "transform 0.3s ease-out, opacity 0.3s ease-out",
12061
+ pointerEvents: viewMode === "list" ? "auto" : "none"
12062
+ }
12063
+ },
12064
+ /* @__PURE__ */ React134.createElement(Stack97, { gap: "md", style: { flex: 1 } }, loading ? /* @__PURE__ */ React134.createElement(Stack97, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Loader16, { size: "lg" }), /* @__PURE__ */ React134.createElement(Text72, { size: "sm", c: "dimmed" }, "Loading claims...")) : error ? /* @__PURE__ */ React134.createElement(Alert18, { color: "red", title: "Failed to load claims", icon: /* @__PURE__ */ React134.createElement(IconAlertCircle7, { size: 18 }) }, /* @__PURE__ */ React134.createElement(Text72, { size: "sm" }, error)) : claims.length === 0 ? /* @__PURE__ */ React134.createElement(Stack97, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Text72, { size: "sm", c: "dimmed", ta: "center" }, "No claims found for this collection.")) : /* @__PURE__ */ React134.createElement(Stack97, { gap: "xs" }, claims.map((claim) => /* @__PURE__ */ React134.createElement(ClaimListItem, { key: claim.claimId, claim, onViewClaim: () => handleViewClaim(claim) }))))
12065
+ ),
12066
+ /* @__PURE__ */ React134.createElement(
12067
+ "div",
12068
+ {
12069
+ style: {
12070
+ position: "absolute",
12071
+ top: 0,
12072
+ left: 0,
12073
+ right: 0,
12074
+ bottom: 0,
12075
+ display: "flex",
12076
+ flexDirection: "column",
12077
+ overflow: "auto",
12078
+ transform: viewMode === "survey" ? "translateX(0)" : "translateX(100%)",
12079
+ opacity: viewMode === "survey" ? 1 : 0,
12080
+ transition: "transform 0.3s ease-out, opacity 0.3s ease-out",
12081
+ pointerEvents: viewMode === "survey" ? "auto" : "none"
12082
+ }
12083
+ },
12084
+ surveyLoading ? /* @__PURE__ */ React134.createElement(Stack97, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Loader16, { size: "lg" }), /* @__PURE__ */ React134.createElement(Text72, { size: "sm", c: "dimmed" }, "Loading claim data...")) : surveyError ? /* @__PURE__ */ React134.createElement(Stack97, { style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Alert18, { color: "red", title: "Failed to load claim data", icon: /* @__PURE__ */ React134.createElement(IconAlertCircle7, { size: 18 }) }, /* @__PURE__ */ React134.createElement(Text72, { size: "sm" }, surveyError))) : /* @__PURE__ */ React134.createElement(React134.Fragment, null, /* @__PURE__ */ React134.createElement("div", { style: surveyContainerStyle }, surveyModel && /* @__PURE__ */ React134.createElement(Survey4, { model: surveyModel })), /* @__PURE__ */ React134.createElement(Divider7, { my: "md" }), /* @__PURE__ */ React134.createElement(Stack97, { gap: "sm" }, /* @__PURE__ */ React134.createElement(Button32, { color: "green", onClick: handleApprove, loading: evaluating, disabled: evaluating }, "Approve Claim"), /* @__PURE__ */ React134.createElement(Button32, { color: "red", variant: "outline", onClick: handleReject, loading: evaluating, disabled: evaluating }, "Reject Claim")))
12085
+ )
12086
+ )
12087
+ );
12088
+ };
12089
+ var ClaimListItem = ({ claim, onViewClaim }) => {
12090
+ const handlers = useBlocknoteHandlers();
12091
+ const [userProfile, setUserProfile] = useState42(null);
12092
+ const [loadingProfile, setLoadingProfile] = useState42(false);
12093
+ useEffect31(() => {
12094
+ const fetchUserProfile = async () => {
12095
+ if (!claim.agentDid) return;
12096
+ try {
12097
+ setLoadingProfile(true);
12098
+ const profile = await handlers.getMatrixInfoPerDid(claim.agentDid);
12099
+ setUserProfile(profile);
12100
+ } catch (error) {
12101
+ console.error("Failed to fetch user profile:", error);
12102
+ } finally {
12103
+ setLoadingProfile(false);
12104
+ }
12105
+ };
12106
+ fetchUserProfile();
12107
+ }, [claim.agentDid, handlers]);
12108
+ const getClaimStatus = (claim2) => {
12109
+ if ("status" in claim2 && claim2.status) {
12110
+ const status = String(claim2.status).toLowerCase();
12111
+ switch (status) {
12112
+ case "approved":
12113
+ return { status: "Approved", color: "green" };
12114
+ case "rejected":
12115
+ return { status: "Rejected", color: "red" };
12116
+ case "pending":
12117
+ return { status: "Pending", color: "yellow" };
12118
+ default:
12119
+ return { status: "Unknown", color: "gray" };
12120
+ }
12121
+ }
12122
+ if ("paymentsStatus" in claim2 && claim2.paymentsStatus) {
12123
+ const paymentsStatus = claim2.paymentsStatus;
12124
+ if (paymentsStatus.approval === "PAID") {
12125
+ return { status: "Approved", color: "green" };
12126
+ }
12127
+ if (paymentsStatus.rejection === "PAID") {
12128
+ return { status: "Rejected", color: "red" };
12129
+ }
12130
+ if (paymentsStatus.evaluation === "PAID" || paymentsStatus.submission === "PAID") {
12131
+ return { status: "Pending", color: "yellow" };
12132
+ }
12133
+ }
12134
+ return { status: "Pending", color: "yellow" };
12135
+ };
12136
+ const formatDate = (dateString) => {
12137
+ if (!dateString) return "N/A";
12138
+ try {
12139
+ return new Date(dateString).toLocaleDateString();
12140
+ } catch {
12141
+ return dateString;
12142
+ }
12143
+ };
12144
+ const claimStatus = getClaimStatus(claim);
12145
+ const displayName = userProfile?.displayname || (claim.agentAddress ? `${claim.agentAddress.slice(0, 12)}...` : "Unknown");
12146
+ return /* @__PURE__ */ React134.createElement(
12147
+ "div",
12148
+ {
12149
+ onClick: onViewClaim,
12150
+ onKeyDown: (e) => {
12151
+ if (e.key === "Enter" || e.key === " ") {
12152
+ e.preventDefault();
12153
+ onViewClaim();
12154
+ }
12155
+ },
12156
+ role: "button",
12157
+ tabIndex: 0,
12158
+ style: { cursor: "pointer" }
12159
+ },
12160
+ /* @__PURE__ */ React134.createElement(ListItemContainer, null, /* @__PURE__ */ React134.createElement(Stack97, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Text72, { size: "sm", fw: 500 }, "Claim #", claim.claimId.slice(-8)), /* @__PURE__ */ React134.createElement(Text72, { size: "xs", c: "dimmed" }, "Submitted: ", formatDate(claim.submissionDate || claim.submittedAt)), claim.agentDid && /* @__PURE__ */ React134.createElement(Group43, { gap: 4 }, /* @__PURE__ */ React134.createElement(Text72, { size: "xs", c: "dimmed" }, "Agent: ", loadingProfile ? "Loading..." : displayName), userProfile?.verified && /* @__PURE__ */ React134.createElement(Text72, { size: "xs", c: "blue", fw: 600, title: "Verified user" }, "\u2713"))), /* @__PURE__ */ React134.createElement(Stack97, { gap: 4, align: "flex-end" }, /* @__PURE__ */ React134.createElement(Badge22, { color: claimStatus.color, size: "sm" }, claimStatus.status), /* @__PURE__ */ React134.createElement(ActionIcon29, { variant: "subtle", size: "sm" }, /* @__PURE__ */ React134.createElement(IconArrowRight4, { size: 16 }))))
12161
+ );
12162
+ };
12163
+
12164
+ // src/mantine/blocks/evaluator/flow/ClaimCollectionsList.tsx
12165
+ import { IconArrowRight as IconArrowRight5 } from "@tabler/icons-react";
12166
+ var CollectionItem3 = ({ collection, deedId, adminAddress, userRole, onRefresh }) => {
12167
+ const handlers = useBlocknoteHandlers();
12168
+ const currentUser = handlers.getCurrentUser();
12169
+ const getCollectionName = (collection2) => {
12170
+ return collection2.protocol?.profile?.name || collection2.name || "Unnamed Collection";
12171
+ };
12172
+ const isEvaluator = userRole === "EA" /* Evaluator */;
12173
+ const canEvaluateClaims = isEvaluator;
12174
+ const claimsPanelId = `evaluator-claims-list-${collection.id}`;
12175
+ const collectionName = getCollectionName(collection);
12176
+ const claimsPanelContent = useMemo34(
12177
+ () => /* @__PURE__ */ React135.createElement(
12178
+ ClaimsList,
12179
+ {
12180
+ collectionId: collection.id,
12181
+ collectionName,
12182
+ deedId,
12183
+ adminAddress,
12184
+ userAddress: currentUser.address,
12185
+ onEvaluationComplete: onRefresh
12186
+ }
12187
+ ),
12188
+ [collection.id, collectionName, deedId, adminAddress, currentUser.address, onRefresh]
12189
+ );
12190
+ const { open: openClaimsPanel } = usePanel(claimsPanelId, claimsPanelContent);
12191
+ const handleClick = () => {
12192
+ if (canEvaluateClaims) {
12193
+ openClaimsPanel();
12194
+ }
12195
+ };
12196
+ return /* @__PURE__ */ React135.createElement("div", { style: { opacity: canEvaluateClaims ? 1 : 0.5 } }, /* @__PURE__ */ React135.createElement(ListItemContainer, null, /* @__PURE__ */ React135.createElement(Stack98, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React135.createElement(Text73, { size: "sm", fw: 500, c: canEvaluateClaims ? void 0 : "dimmed" }, getCollectionName(collection)), collection.description && /* @__PURE__ */ React135.createElement(Text73, { size: "xs", c: "dimmed" }, collection.description)), /* @__PURE__ */ React135.createElement(Tooltip9, { label: "You need to be an evaluator agent to review claims", disabled: canEvaluateClaims, position: "left", withArrow: true }, /* @__PURE__ */ React135.createElement(ActionIcon30, { variant: "subtle", size: "lg", onClick: handleClick, disabled: !canEvaluateClaims, style: { cursor: canEvaluateClaims ? "pointer" : "not-allowed" } }, /* @__PURE__ */ React135.createElement(IconArrowRight5, { size: 20 })))));
12197
+ };
12198
+ var ClaimCollectionsList3 = ({ collections, deedId, adminAddress, userAddress, onRefresh }) => {
12199
+ const handlers = useBlocknoteHandlers();
12200
+ const [userRoles, setUserRoles] = useState43({});
12201
+ const [loadingRoles, setLoadingRoles] = useState43(true);
12202
+ useEffect32(() => {
12203
+ const fetchUserRoles = async () => {
12204
+ if (!collections || collections.length === 0 || !userAddress || !adminAddress) {
12205
+ setLoadingRoles(false);
12206
+ return;
12207
+ }
12208
+ try {
12209
+ setLoadingRoles(true);
12210
+ const collectionIds = collections.map((c) => c.id);
12211
+ const roles = await handlers.getUserRoles({
12212
+ userAddress,
12213
+ adminAddress,
12214
+ deedDid: deedId,
12215
+ collectionIds
12216
+ });
12217
+ const rolesMap = {};
12218
+ collections.forEach((collection) => {
12219
+ const roleData = roles?.find((r) => r.collectionId === collection.id);
12220
+ rolesMap[collection.id] = roleData?.role || null;
12221
+ });
12222
+ setUserRoles(rolesMap);
12223
+ } catch (error) {
12224
+ console.error("Error fetching user roles:", error);
12225
+ const rolesMap = {};
12226
+ collections.forEach((collection) => {
12227
+ rolesMap[collection.id] = null;
12228
+ });
12229
+ setUserRoles(rolesMap);
12230
+ } finally {
12231
+ setLoadingRoles(false);
12232
+ }
12233
+ };
12234
+ fetchUserRoles();
12235
+ }, [collections, userAddress, adminAddress, handlers, deedId]);
12236
+ if (!collections || collections.length === 0) {
12237
+ return /* @__PURE__ */ React135.createElement(Text73, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No claim collections found");
12238
+ }
12239
+ if (loadingRoles) {
12240
+ return /* @__PURE__ */ React135.createElement(Center9, { py: "md" }, /* @__PURE__ */ React135.createElement(Loader17, { size: "sm" }));
12241
+ }
12242
+ return /* @__PURE__ */ React135.createElement(Stack98, { gap: "md", px: 5 }, collections.map((collection) => /* @__PURE__ */ React135.createElement(CollectionItem3, { key: collection.id, collection, deedId, adminAddress, userRole: userRoles[collection.id] || null, onRefresh })));
12243
+ };
12244
+
12245
+ // src/mantine/blocks/evaluator/flow/FlowView.tsx
12246
+ var EvaluatorFlowView = ({ editor, block }) => {
12247
+ const { editable } = useBlocknoteContext();
12248
+ const handlers = useBlocknoteHandlers();
12249
+ const currentUser = handlers.getCurrentUser();
12250
+ const [collections, setCollections] = useState44([]);
12251
+ const [loading, setLoading] = useState44(false);
12252
+ const [error, setError] = useState44(null);
12253
+ const selectedCollectionIds = useMemo35(() => {
12254
+ try {
12255
+ return JSON.parse(block.props.selectedCollections || "[]");
12256
+ } catch {
12257
+ return [];
12258
+ }
12259
+ }, [block.props.selectedCollections]);
12260
+ const did = block.props.deedDid;
12261
+ const adminAddress = block.props.adminAddress || "";
12262
+ const fetchCollections = useCallback32(async () => {
12263
+ if (!did || selectedCollectionIds.length === 0) {
12264
+ setCollections([]);
12265
+ return;
12266
+ }
12267
+ setLoading(true);
12268
+ setError(null);
12269
+ try {
12270
+ const response = await handlers.getClaimCollections({ deedDid: did });
12271
+ const { adminAddress: adminAddress2, collections: allCollections } = response || { adminAddress: "", collections: [] };
12272
+ if (adminAddress2 && (!block.props.adminAddress || block.props.adminAddress === "")) {
12273
+ editor.updateBlock(block, {
12274
+ props: {
12275
+ ...block.props,
12276
+ adminAddress: adminAddress2
12277
+ }
12278
+ });
12279
+ }
12280
+ const selectedCollections = (allCollections || []).filter((c) => selectedCollectionIds.includes(c?.id));
12281
+ setCollections(selectedCollections);
12282
+ } catch (err) {
12283
+ console.error("Error fetching collections:", err);
12284
+ setError(err instanceof Error ? err.message : "Failed to fetch collections");
12285
+ } finally {
12286
+ setLoading(false);
12287
+ }
12288
+ }, [did, selectedCollectionIds, handlers, editor, block]);
12289
+ useEffect33(() => {
12290
+ fetchCollections();
12291
+ }, [fetchCollections]);
12292
+ if (!did) {
12293
+ return /* @__PURE__ */ React136.createElement(Center10, { py: "xl" }, /* @__PURE__ */ React136.createElement(Text74, { size: "sm", c: "dimmed" }, "Please configure the evaluator block in template mode first"));
12294
+ }
12295
+ if (selectedCollectionIds.length === 0) {
12296
+ return /* @__PURE__ */ React136.createElement(Center10, { py: "xl" }, /* @__PURE__ */ React136.createElement(Text74, { size: "sm", c: "dimmed" }, "No claim collections selected"));
12297
+ }
12298
+ return /* @__PURE__ */ React136.createElement(Stack99, { w: "100%" }, /* @__PURE__ */ React136.createElement(Flex24, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React136.createElement(Title18, { order: 4 }, "Evaluate Claims"), /* @__PURE__ */ React136.createElement(Flex24, { gap: "xs" }, /* @__PURE__ */ React136.createElement(ActionIcon31, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React136.createElement(IconRefresh5, { size: 18 })), editable && /* @__PURE__ */ React136.createElement(ActionIcon31, { variant: "subtle", size: "sm" }, /* @__PURE__ */ React136.createElement(IconSettings5, { size: 18 })))), loading ? /* @__PURE__ */ React136.createElement(Center10, { py: "xl" }, /* @__PURE__ */ React136.createElement(Loader18, { size: "md" })) : error ? /* @__PURE__ */ React136.createElement(Alert19, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React136.createElement(IconAlertCircle8, { size: 18 }) }, /* @__PURE__ */ React136.createElement(Text74, { size: "sm" }, error)) : /* @__PURE__ */ React136.createElement(ClaimCollectionsList3, { collections, deedId: did, adminAddress, userAddress: currentUser.address, onRefresh: fetchCollections }));
12299
+ };
12300
+
12301
+ // src/mantine/blocks/evaluator/EvaluatorBlock.tsx
12302
+ function EvaluatorBlock({ editor, block }) {
12303
+ const { docType } = useBlocknoteContext();
12304
+ if (docType === "template") {
12305
+ return /* @__PURE__ */ React137.createElement(EvaluatorTemplateView, { editor, block });
12306
+ }
12307
+ return /* @__PURE__ */ React137.createElement(EvaluatorFlowView, { editor, block });
12308
+ }
12309
+
12310
+ // src/mantine/blocks/evaluator/EvaluatorBlockSpec.tsx
12311
+ import React138 from "react";
12312
+ import { createReactBlockSpec as createReactBlockSpec10 } from "@blocknote/react";
12313
+ var EvaluatorBlockSpec = createReactBlockSpec10(
12314
+ {
12315
+ type: "evaluator",
12316
+ propSchema: {
12317
+ title: { default: "" },
12318
+ description: { default: "" },
12319
+ icon: { default: "checklist" },
12320
+ deedDid: { default: "" },
12321
+ selectedCollections: { default: "[]" },
12322
+ adminAddress: { default: "" }
12323
+ },
12324
+ content: "none"
12325
+ },
12326
+ {
12327
+ render: (props) => {
12328
+ const ixoProps = props;
12329
+ return /* @__PURE__ */ React138.createElement(EvaluatorBlock, { ...ixoProps });
12330
+ }
12331
+ }
12332
+ );
12333
+
12334
+ // src/mantine/blocks/list/ui/ListBlocksToolbar.tsx
12335
+ import React139 from "react";
12336
+ import { ActionIcon as ActionIcon32, Group as Group44, Tooltip as Tooltip10 } from "@mantine/core";
12337
+ import { IconChevronUp as IconChevronUp4, IconChevronDown as IconChevronDown5 } from "@tabler/icons-react";
12338
+ var ListBlocksToolbar = () => {
12339
+ const { broadcastCollapse } = useListBlocksUI();
12340
+ return /* @__PURE__ */ React139.createElement(Group44, { gap: "xs" }, /* @__PURE__ */ React139.createElement(Tooltip10, { label: "Collapse all lists", withArrow: true }, /* @__PURE__ */ React139.createElement(ActionIcon32, { c: "dimmed", variant: "subtle", size: "sm", "aria-label": "Collapse all lists", onClick: () => broadcastCollapse("collapse") }, /* @__PURE__ */ React139.createElement(IconChevronUp4, { size: 18 }))), /* @__PURE__ */ React139.createElement(Tooltip10, { label: "Expand all lists", withArrow: true }, /* @__PURE__ */ React139.createElement(ActionIcon32, { c: "dimmed", variant: "subtle", size: "sm", "aria-label": "Expand all lists", onClick: () => broadcastCollapse("expand") }, /* @__PURE__ */ React139.createElement(IconChevronDown5, { size: 18 }))));
12341
+ };
12342
+
12343
+ // src/mantine/blocks/registry/blockRegistry.ts
12344
+ var BlockRegistry = class {
12345
+ constructor() {
12346
+ this.blocks = /* @__PURE__ */ new Map();
12347
+ }
12348
+ register(entry) {
12349
+ this.blocks.set(entry.type, entry);
12350
+ }
12351
+ get(type) {
12352
+ return this.blocks.get(type);
12353
+ }
12354
+ getAll() {
12355
+ return new Map(this.blocks);
12356
+ }
12357
+ getValidDependencies(type) {
12358
+ const entry = this.get(type);
12359
+ return entry?.validDependencies || [];
12360
+ }
12361
+ getPropSchema(type) {
12362
+ const entry = this.get(type);
12363
+ return entry?.propSchema;
12364
+ }
12365
+ isValidDependency(blockType, dependencyType) {
12366
+ const validDeps = this.getValidDependencies(blockType);
12367
+ return validDeps.includes(dependencyType);
12368
+ }
12369
+ };
12370
+ var blockRegistry = new BlockRegistry();
12371
+ blockRegistry.register({
12372
+ type: "proposal",
12373
+ propSchema: {
12374
+ title: "",
12375
+ description: "",
12376
+ icon: "\u{1F4DD}",
12377
+ proposalId: "",
12378
+ status: "draft",
12379
+ contractAddress: "",
12380
+ coreAddress: "",
12381
+ createdProposalId: ""
12382
+ },
12383
+ validDependencies: [],
12384
+ defaultProps: {
12385
+ icon: "\u{1F4DD}",
12386
+ status: "draft"
12387
+ }
12388
+ });
12389
+ blockRegistry.register({
12390
+ type: "proposalVote",
12391
+ propSchema: {
12392
+ title: "",
12393
+ subtitle: "",
12394
+ icon: "\u{1F5F3}\uFE0F",
12395
+ status: "open",
12396
+ daysLeft: 0,
12397
+ proposalId: "",
12398
+ proposalBlockId: "",
12399
+ proposalContractAddress: ""
12400
+ },
12401
+ validDependencies: ["proposal"],
12402
+ defaultProps: {
12403
+ icon: "\u{1F5F3}\uFE0F",
12404
+ status: "open",
12405
+ daysLeft: 0,
12406
+ proposalBlockId: ""
12407
+ }
12408
+ });
12409
+ blockRegistry.register({
12410
+ type: "list",
12411
+ propSchema: {
12412
+ title: "",
12413
+ did: "",
12414
+ fragmentIdentifier: ""
12415
+ },
12416
+ validDependencies: [],
12417
+ defaultProps: {}
12418
+ });
12419
+ blockRegistry.register({
12420
+ type: "overview",
12421
+ propSchema: {
12422
+ did: ""
12423
+ },
12424
+ validDependencies: [],
12425
+ defaultProps: {}
12426
+ });
12427
+ blockRegistry.register({
12428
+ type: "enumChecklist",
12429
+ propSchema: {
12430
+ listType: "",
12431
+ listConfig: "{}"
12432
+ },
12433
+ validDependencies: [],
12434
+ defaultProps: {}
12435
+ });
12436
+ blockRegistry.register({
12437
+ type: "notify",
12438
+ propSchema: {
12439
+ title: "",
12440
+ description: "",
12441
+ icon: "bell",
12442
+ channel: "email",
12443
+ to: "[]",
12444
+ cc: "[]",
12445
+ bcc: "[]",
12446
+ subject: "",
12447
+ body: "",
12448
+ bodyType: "text",
12449
+ from: "",
12450
+ replyTo: "",
12451
+ templateId: "",
12452
+ templateVariables: "{}",
12453
+ status: "idle",
12454
+ messageId: "",
12455
+ sentAt: "",
12456
+ errorMessage: "",
12457
+ conditions: ""
12458
+ },
12459
+ validDependencies: [],
12460
+ defaultProps: {
12461
+ icon: "bell",
12462
+ channel: "email",
12463
+ bodyType: "text",
12464
+ status: "idle"
12465
+ }
12466
+ });
12467
+ blockRegistry.register({
12468
+ type: "bid",
12469
+ propSchema: {
12470
+ title: "",
12471
+ description: "",
12472
+ did: "",
12473
+ selectedCollections: "[]",
12474
+ adminAddress: ""
12475
+ },
12476
+ validDependencies: [],
12477
+ defaultProps: {}
12478
+ });
12479
+ blockRegistry.register({
12480
+ type: "claim",
12481
+ propSchema: {
12482
+ title: "",
12483
+ description: "",
12484
+ icon: "square-check",
12485
+ deedDid: "",
12486
+ selectedCollections: "[]",
12487
+ adminAddress: ""
12488
+ },
12489
+ validDependencies: [],
12490
+ defaultProps: {
12491
+ icon: "square-check"
12492
+ }
12493
+ });
12494
+
12495
+ // src/mantine/blocks/hooks/useBlockDependencies.ts
12496
+ import { useMemo as useMemo36, useEffect as useEffect34, useState as useState45, useCallback as useCallback33 } from "react";
12497
+
12498
+ // src/mantine/blocks/hooks/useDependsOn.ts
12499
+ import { useMemo as useMemo37 } from "react";
12500
+
12501
+ // src/mantine/blocks/index.ts
12502
+ var blockSpecs = {
12503
+ checkbox: CheckboxBlockSpec,
12504
+ list: ListBlockSpec,
12505
+ enumChecklist: EnumChecklistBlock,
12506
+ overview: OverviewBlock,
12507
+ proposal: ProposalBlockSpec,
12508
+ apiRequest: ApiRequestBlockSpec,
12509
+ notify: NotifyBlockSpec,
12510
+ claim: ClaimBlockSpec,
12511
+ bid: BidBlockSpec,
12512
+ evaluator: EvaluatorBlockSpec
12513
+ };
12514
+ var getExtraSlashMenuItems = (editor) => {
12515
+ const slashMenuList = [
12516
+ {
12517
+ title: "Checkbox",
12518
+ onItemClick: () => {
12519
+ editor.insertBlocks(
12520
+ [
12521
+ {
12522
+ type: "checkbox",
12523
+ props: {
12524
+ checked: false,
12525
+ allowedCheckers: "all",
12526
+ initialChecked: false,
12527
+ title: "",
12528
+ description: "",
12529
+ visibility: "all",
12530
+ dependencies: "",
12531
+ conditions: ""
12532
+ }
12533
+ }
12534
+ ],
12535
+ editor.getTextCursorPosition().block,
12536
+ "after"
12537
+ );
12538
+ },
12539
+ aliases: ["checkbox", "task", "todo"],
12540
+ group: "Basics",
12541
+ subtext: "Add an interactive checkbox with flow permissions"
12542
+ },
12543
+ {
12544
+ title: "List",
12545
+ onItemClick: () => {
12546
+ editor.insertBlocks(
12547
+ [
12548
+ {
12549
+ type: "list",
12550
+ props: {
10120
12551
  title: "",
10121
12552
  did: "",
10122
12553
  fragmentIdentifier: ""
@@ -10262,6 +12693,60 @@ var getExtraSlashMenuItems = (editor) => {
10262
12693
  aliases: ["notify", "notification", "email", "alert", "message", "bird"],
10263
12694
  group: "Basics",
10264
12695
  subtext: "Send notifications via Email, SMS, or WhatsApp"
12696
+ },
12697
+ {
12698
+ title: "Claim",
12699
+ onItemClick: () => {
12700
+ editor.insertBlocks(
12701
+ [
12702
+ {
12703
+ type: "claim",
12704
+ props: {}
12705
+ }
12706
+ ],
12707
+ editor.getTextCursorPosition().block,
12708
+ "after"
12709
+ );
12710
+ },
12711
+ aliases: ["claim", "submission", "form", "attestation"],
12712
+ group: "DAO",
12713
+ subtext: "Create and manage claims with submission tracking"
12714
+ },
12715
+ {
12716
+ title: "Bid",
12717
+ onItemClick: () => {
12718
+ editor.insertBlocks(
12719
+ [
12720
+ {
12721
+ type: "bid",
12722
+ props: {}
12723
+ }
12724
+ ],
12725
+ editor.getTextCursorPosition().block,
12726
+ "after"
12727
+ );
12728
+ },
12729
+ aliases: ["bid", "offer", "tender"],
12730
+ group: "DAO",
12731
+ subtext: "Create and submit bids"
12732
+ },
12733
+ {
12734
+ title: "Evaluator",
12735
+ onItemClick: () => {
12736
+ editor.insertBlocks(
12737
+ [
12738
+ {
12739
+ type: "evaluator",
12740
+ props: {}
12741
+ }
12742
+ ],
12743
+ editor.getTextCursorPosition().block,
12744
+ "after"
12745
+ );
12746
+ },
12747
+ aliases: ["evaluator", "evaluate", "review", "assessment"],
12748
+ group: "DAO",
12749
+ subtext: "Evaluate and review submitted claims"
10265
12750
  }
10266
12751
  ];
10267
12752
  const yRoot = editor?._yRoot;
@@ -10286,7 +12771,8 @@ function useCreateIxoEditor(options) {
10286
12771
  formattingToolbar = true,
10287
12772
  linkToolbar = true,
10288
12773
  filePanel = true,
10289
- tableHandles = true
12774
+ tableHandles = true,
12775
+ docType = "flow"
10290
12776
  } = options || {};
10291
12777
  const defaultUploadFile = uploadFile || (async (file) => {
10292
12778
  return new Promise((resolve, reject) => {
@@ -10329,6 +12815,7 @@ function useCreateIxoEditor(options) {
10329
12815
  tableHandles
10330
12816
  };
10331
12817
  ixoEditor.mode = "flow";
12818
+ ixoEditor.docType = docType;
10332
12819
  ixoEditor.isEditable = editable;
10333
12820
  return ixoEditor;
10334
12821
  }
@@ -10340,15 +12827,15 @@ import { useCreateBlockNote as useCreateBlockNote2 } from "@blocknote/react";
10340
12827
  import { BlockNoteSchema as BlockNoteSchema2, defaultBlockSpecs as defaultBlockSpecs2, defaultInlineContentSpecs as defaultInlineContentSpecs2, defaultStyleSpecs as defaultStyleSpecs2 } from "@blocknote/core";
10341
12828
 
10342
12829
  // src/core/hooks/useMatrixProvider.ts
10343
- import { useEffect as useEffect20, useState as useState31, useRef as useRef4, useCallback as useCallback21, useMemo as useMemo21 } from "react";
12830
+ import { useEffect as useEffect35, useState as useState46, useRef as useRef4, useCallback as useCallback34, useMemo as useMemo38 } from "react";
10344
12831
  import { MatrixProvider } from "@ixo/matrix-crdt";
10345
12832
  function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10346
- const [matrixProvider, setProvider] = useState31(null);
10347
- const [status, setStatus] = useState31("disconnected");
12833
+ const [matrixProvider, setProvider] = useState46(null);
12834
+ const [status, setStatus] = useState46("disconnected");
10348
12835
  const isMountedRef = useRef4(true);
10349
12836
  const providerRef = useRef4(null);
10350
12837
  const retryTimeoutRef = useRef4(null);
10351
- const providerOptions = useMemo21(
12838
+ const providerOptions = useMemo38(
10352
12839
  () => ({
10353
12840
  translator: {
10354
12841
  updateEventType: "matrix-crdt.doc_update",
@@ -10361,22 +12848,22 @@ function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10361
12848
  }),
10362
12849
  []
10363
12850
  );
10364
- const handleDocumentAvailable = useCallback21(() => {
12851
+ const handleDocumentAvailable = useCallback34(() => {
10365
12852
  if (isMountedRef.current) {
10366
12853
  setStatus("connected");
10367
12854
  }
10368
12855
  }, []);
10369
- const handleDocumentUnavailable = useCallback21(() => {
12856
+ const handleDocumentUnavailable = useCallback34(() => {
10370
12857
  if (isMountedRef.current) {
10371
12858
  setStatus("failed");
10372
12859
  }
10373
12860
  }, []);
10374
- const handleCanWriteChanged = useCallback21(() => {
12861
+ const handleCanWriteChanged = useCallback34(() => {
10375
12862
  if (isMountedRef.current && providerRef.current) {
10376
12863
  setStatus(providerRef.current.canWrite ? "connected" : "failed");
10377
12864
  }
10378
12865
  }, []);
10379
- const initProvider = useCallback21(async () => {
12866
+ const initProvider = useCallback34(async () => {
10380
12867
  if (!isMountedRef.current) return;
10381
12868
  if (retryTimeoutRef.current) {
10382
12869
  clearTimeout(retryTimeoutRef.current);
@@ -10410,7 +12897,7 @@ function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10410
12897
  }
10411
12898
  }
10412
12899
  }, [matrixClient, providerOptions, handleDocumentAvailable, handleDocumentUnavailable, handleCanWriteChanged]);
10413
- useEffect20(() => {
12900
+ useEffect35(() => {
10414
12901
  isMountedRef.current = true;
10415
12902
  initProvider();
10416
12903
  return () => {
@@ -10427,7 +12914,7 @@ function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10427
12914
  setStatus("disconnected");
10428
12915
  };
10429
12916
  }, [initProvider]);
10430
- useEffect20(() => {
12917
+ useEffect35(() => {
10431
12918
  return () => {
10432
12919
  isMountedRef.current = false;
10433
12920
  };
@@ -10436,17 +12923,17 @@ function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10436
12923
  }
10437
12924
 
10438
12925
  // src/mantine/hooks/useCollaborativeYDoc.ts
10439
- import { useMemo as useMemo22 } from "react";
12926
+ import { useMemo as useMemo39 } from "react";
10440
12927
  import * as Y from "yjs";
10441
12928
  function useCollaborativeYDoc(_options) {
10442
- return useMemo22(() => {
12929
+ return useMemo39(() => {
10443
12930
  const doc = new Y.Doc();
10444
12931
  return doc;
10445
12932
  }, []);
10446
12933
  }
10447
12934
 
10448
12935
  // src/mantine/hooks/useCollaborativeIxoEditor.ts
10449
- import { useMemo as useMemo23, useEffect as useEffect21 } from "react";
12936
+ import { useMemo as useMemo40, useEffect as useEffect36 } from "react";
10450
12937
  function useCreateCollaborativeIxoEditor(options) {
10451
12938
  const yDoc = useCollaborativeYDoc(options);
10452
12939
  const {
@@ -10460,11 +12947,12 @@ function useCreateCollaborativeIxoEditor(options) {
10460
12947
  linkToolbar = true,
10461
12948
  filePanel = true,
10462
12949
  tableHandles = true,
12950
+ docType = "flow",
10463
12951
  user,
10464
12952
  matrixClient,
10465
12953
  permissions = { write: false }
10466
12954
  } = options || {};
10467
- const memoizedUser = useMemo23(
12955
+ const memoizedUser = useMemo40(
10468
12956
  () => ({
10469
12957
  id: user?.id || "",
10470
12958
  name: user?.name || "",
@@ -10479,7 +12967,7 @@ function useCreateCollaborativeIxoEditor(options) {
10479
12967
  matrixClient,
10480
12968
  roomId: options.roomId
10481
12969
  });
10482
- const defaultUploadFile = useMemo23(
12970
+ const defaultUploadFile = useMemo40(
10483
12971
  () => uploadFile || (async (file) => {
10484
12972
  return new Promise((resolve, reject) => {
10485
12973
  const reader = new FileReader();
@@ -10493,7 +12981,7 @@ function useCreateCollaborativeIxoEditor(options) {
10493
12981
  }),
10494
12982
  [uploadFile]
10495
12983
  );
10496
- const schema = useMemo23(
12984
+ const schema = useMemo40(
10497
12985
  () => BlockNoteSchema2.create({
10498
12986
  blockSpecs: {
10499
12987
  ...defaultBlockSpecs2,
@@ -10508,11 +12996,11 @@ function useCreateCollaborativeIxoEditor(options) {
10508
12996
  }),
10509
12997
  []
10510
12998
  );
10511
- const root = useMemo23(() => yDoc.getMap("root"), [yDoc]);
10512
- const documentFragment = useMemo23(() => yDoc.getXmlFragment("document"), [yDoc]);
10513
- const flowArray = useMemo23(() => yDoc.getArray("flow"), [yDoc]);
10514
- const userFragment = useMemo23(() => yDoc.getMap(memoizedUser.id), [yDoc, memoizedUser.id]);
10515
- const collaborationConfig = useMemo23(
12999
+ const root = useMemo40(() => yDoc.getMap("root"), [yDoc]);
13000
+ const documentFragment = useMemo40(() => yDoc.getXmlFragment("document"), [yDoc]);
13001
+ const flowArray = useMemo40(() => yDoc.getArray("flow"), [yDoc]);
13002
+ const userFragment = useMemo40(() => yDoc.getMap(memoizedUser.id), [yDoc, memoizedUser.id]);
13003
+ const collaborationConfig = useMemo40(
10516
13004
  () => ({
10517
13005
  provider: matrixProvider,
10518
13006
  fragment: documentFragment,
@@ -10524,7 +13012,7 @@ function useCreateCollaborativeIxoEditor(options) {
10524
13012
  }),
10525
13013
  [matrixProvider, documentFragment, memoizedUser.name, memoizedUser.color]
10526
13014
  );
10527
- const ixoConfig = useMemo23(
13015
+ const ixoConfig = useMemo40(
10528
13016
  () => ({
10529
13017
  theme,
10530
13018
  editable,
@@ -10543,7 +13031,7 @@ function useCreateCollaborativeIxoEditor(options) {
10543
13031
  uploadFile: defaultUploadFile,
10544
13032
  collaboration: collaborationConfig
10545
13033
  });
10546
- const titleText = useMemo23(() => yDoc.getText("title"), [yDoc]);
13034
+ const titleText = useMemo40(() => yDoc.getText("title"), [yDoc]);
10547
13035
  let ixoEditor;
10548
13036
  if (editor) {
10549
13037
  ixoEditor = editor;
@@ -10552,6 +13040,7 @@ function useCreateCollaborativeIxoEditor(options) {
10552
13040
  ixoEditor._yFlow = flowArray;
10553
13041
  ixoEditor.mode = editable ? "template" : "flow";
10554
13042
  ixoEditor.user = memoizedUser;
13043
+ ixoEditor.docType = docType;
10555
13044
  ixoEditor.getUserProps = (block) => {
10556
13045
  return userFragment.get(block.id) || {};
10557
13046
  };
@@ -10591,27 +13080,13 @@ function useCreateCollaborativeIxoEditor(options) {
10591
13080
  ixoEditor.getFlow = () => {
10592
13081
  return flowArray.toArray();
10593
13082
  };
10594
- ixoEditor.getDocType = () => {
10595
- const docType = root.get("docType") || "";
10596
- console.log("[useCollaborativeIxoEditor] getDocType() called, returning:", docType);
10597
- return docType;
10598
- };
10599
- ixoEditor.setDocType = (value) => {
10600
- if (!permissions.write) {
10601
- console.warn("Cannot set doc type: write permission denied");
10602
- return;
10603
- }
10604
- console.log("[useCollaborativeIxoEditor] setDocType() called, setting docType to:", value);
10605
- ixoEditor._authoritativeDocType = value;
10606
- root.set("docType", value);
10607
- };
10608
13083
  }
10609
- useEffect21(() => {
13084
+ useEffect36(() => {
10610
13085
  if (ixoEditor) {
10611
13086
  ixoEditor.isEditable = editable;
10612
13087
  }
10613
13088
  }, [ixoEditor, editable]);
10614
- useEffect21(() => {
13089
+ useEffect36(() => {
10615
13090
  if (connectionStatus !== "connected") {
10616
13091
  return;
10617
13092
  }
@@ -10628,8 +13103,6 @@ function useCreateCollaborativeIxoEditor(options) {
10628
13103
  root.set("doc_id", options.docId || `flow_${Date.now()}`);
10629
13104
  root.set("createdAt", (/* @__PURE__ */ new Date()).toISOString());
10630
13105
  root.set("createdBy", memoizedUser.id || "anonymous");
10631
- root.set("docType", "");
10632
- console.log("[useCollaborativeIxoEditor] Initializing docType to empty string for new document");
10633
13106
  if (titleText.length === 0 && options.title) {
10634
13107
  titleText.insert(0, options.title);
10635
13108
  }
@@ -10645,20 +13118,42 @@ function useCreateCollaborativeIxoEditor(options) {
10645
13118
  }
10646
13119
 
10647
13120
  // src/mantine/IxoEditor.tsx
10648
- import React113 from "react";
13121
+ import React141 from "react";
10649
13122
  import { getDefaultReactSlashMenuItems, SuggestionMenuController } from "@blocknote/react";
10650
13123
  import { BlockNoteView } from "@blocknote/mantine";
10651
13124
  import { filterSuggestionItems } from "@blocknote/core";
10652
- import { Flex as Flex22, MantineProvider, Text as Text57 } from "@mantine/core";
13125
+ import { Flex as Flex25, MantineProvider, Text as Text75 } from "@mantine/core";
10653
13126
 
10654
13127
  // src/mantine/components/PanelContent.tsx
10655
- import React112 from "react";
13128
+ import React140 from "react";
10656
13129
  import { Box as Box22 } from "@mantine/core";
10657
- function PanelContent() {
13130
+ var panelStyles = {
13131
+ light: {
13132
+ backgroundColor: "#ffffff",
13133
+ // editor background
13134
+ color: "#1a1a1a",
13135
+ // main text color
13136
+ border: "1px solid #e0e0e0",
13137
+ // border color
13138
+ // mimic menu/sidebar visual balance
13139
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)"
13140
+ },
13141
+ dark: {
13142
+ backgroundColor: "#1f1f1f",
13143
+ // editor background
13144
+ color: "#f0f0f0",
13145
+ // main text color
13146
+ border: "1px solid #1a1a1a",
13147
+ // border color
13148
+ // mimic menu/sidebar visual balance
13149
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)"
13150
+ }
13151
+ };
13152
+ function PanelContent({ theme }) {
10658
13153
  const { activePanel, registeredPanels } = usePanelStore();
10659
13154
  const isOpen = activePanel !== null;
10660
13155
  const content = activePanel ? registeredPanels.get(activePanel) : null;
10661
- return /* @__PURE__ */ React112.createElement(
13156
+ return /* @__PURE__ */ React140.createElement(
10662
13157
  Box22,
10663
13158
  {
10664
13159
  pos: "sticky",
@@ -10668,7 +13163,9 @@ function PanelContent() {
10668
13163
  width: isOpen ? "50%" : "0",
10669
13164
  height: "calc(100vh - 150px)",
10670
13165
  transition: "width 0.2s ease",
10671
- overflow: isOpen ? "auto" : "hidden"
13166
+ overflow: isOpen ? "auto" : "hidden",
13167
+ ...isOpen && panelStyles[theme]
13168
+ // You can switch between light/dark based on your theme
10672
13169
  }
10673
13170
  },
10674
13171
  isOpen && content
@@ -10683,10 +13180,9 @@ function IxoEditorContent({
10683
13180
  className,
10684
13181
  onChange,
10685
13182
  onSelectionChange,
10686
- isPanelVisible = true,
10687
13183
  children
10688
13184
  }) {
10689
- return /* @__PURE__ */ React113.createElement("div", { style: { display: "flex", height: "100%" } }, /* @__PURE__ */ React113.createElement("div", { className: `ixo-editor ixo-editor--theme-${config.theme} ${className}`, style: { flex: 1 } }, /* @__PURE__ */ React113.createElement(
13185
+ return /* @__PURE__ */ React141.createElement("div", { style: { display: "flex", height: "100%" } }, /* @__PURE__ */ React141.createElement("div", { className: `ixo-editor ixo-editor--theme-${config.theme} ${className}`, style: { flex: 1 } }, /* @__PURE__ */ React141.createElement(
10690
13186
  BlockNoteView,
10691
13187
  {
10692
13188
  editor,
@@ -10701,7 +13197,7 @@ function IxoEditorContent({
10701
13197
  onChange,
10702
13198
  onSelectionChange
10703
13199
  },
10704
- config.slashMenu && /* @__PURE__ */ React113.createElement(
13200
+ config.slashMenu && /* @__PURE__ */ React141.createElement(
10705
13201
  SuggestionMenuController,
10706
13202
  {
10707
13203
  triggerCharacter: "/",
@@ -10713,7 +13209,7 @@ function IxoEditorContent({
10713
13209
  }
10714
13210
  ),
10715
13211
  children
10716
- )), isPanelVisible && /* @__PURE__ */ React113.createElement(PanelContent, null));
13212
+ )), /* @__PURE__ */ React141.createElement(PanelContent, { theme: config.theme }));
10717
13213
  }
10718
13214
  function IxoEditor({
10719
13215
  editor,
@@ -10740,7 +13236,7 @@ function IxoEditor({
10740
13236
  tableHandles: true
10741
13237
  };
10742
13238
  const isEditable = editable;
10743
- const editorContent = /* @__PURE__ */ React113.createElement(BlocknoteProvider, { editor, handlers, blockRequirements, editable: isEditable }, /* @__PURE__ */ React113.createElement(ListBlocksUIProvider, null, /* @__PURE__ */ React113.createElement(Flex22, { pr: 25, justify: "flex-end", align: "center", gap: "xs" }, /* @__PURE__ */ React113.createElement(Text57, { size: "xs", c: "dimmed", tt: "uppercase" }, "Global actions"), /* @__PURE__ */ React113.createElement(ListBlocksToolbar, null)), /* @__PURE__ */ React113.createElement(
13239
+ const editorContent = /* @__PURE__ */ React141.createElement(BlocknoteProvider, { editor, handlers, blockRequirements, editable: isEditable }, /* @__PURE__ */ React141.createElement(ListBlocksUIProvider, null, /* @__PURE__ */ React141.createElement(Flex25, { pr: 25, justify: "flex-end", align: "center", gap: "xs" }, /* @__PURE__ */ React141.createElement(Text75, { size: "xs", c: "dimmed", tt: "uppercase" }, "Global actions"), /* @__PURE__ */ React141.createElement(ListBlocksToolbar, null)), /* @__PURE__ */ React141.createElement(
10744
13240
  IxoEditorContent,
10745
13241
  {
10746
13242
  isPanelVisible,
@@ -10754,7 +13250,7 @@ function IxoEditor({
10754
13250
  children
10755
13251
  )));
10756
13252
  if (mantineTheme) {
10757
- return /* @__PURE__ */ React113.createElement(MantineProvider, { theme: mantineTheme }, editorContent);
13253
+ return /* @__PURE__ */ React141.createElement(MantineProvider, { theme: mantineTheme }, editorContent);
10758
13254
  }
10759
13255
  return editorContent;
10760
13256
  }
@@ -10840,4 +13336,4 @@ export {
10840
13336
  ixoGraphQLClient,
10841
13337
  getEntity
10842
13338
  };
10843
- //# sourceMappingURL=chunk-O477KPVK.mjs.map
13339
+ //# sourceMappingURL=chunk-XEZXD5ZV.mjs.map